Any GTK-PHP monsters out there?
Posted: Wed Jul 24, 2002 4:39 pm
OK, here's what's going on. I am working on learning GTK-PHP (duh) and decided I'd try to write a script that builds a GTK frontend for a movie player backend (M Player for Linux).
The problem is as such. I managed to create a (very) simple front end that manages to open a file selection dialog. From there I can select a file and actually have the movie player start playing that file. However, the problem comes in before the file starts playing. The file selection dialog doesn't go away. Instead, it sits on the screen and doesn't go away until the file is either finished or terminated.
Now that's NOT the correct behaviour. I want the file dialog to go away first, then the movie start playing. I even put in code that's supposed to accomplish this. Anyway, here's the code. I've been at it two days and am at a loss. If anyone else has an idea, tell me what you think.
And remember, when it comes to this GTK stuff, I'm a nuubee.
Anyways, if you can see where i've gone stupid, I'd love to know.
Later on,
BDKR
The problem is as such. I managed to create a (very) simple front end that manages to open a file selection dialog. From there I can select a file and actually have the movie player start playing that file. However, the problem comes in before the file starts playing. The file selection dialog doesn't go away. Instead, it sits on the screen and doesn't go away until the file is either finished or terminated.
Now that's NOT the correct behaviour. I want the file dialog to go away first, then the movie start playing. I even put in code that's supposed to accomplish this. Anyway, here's the code. I've been at it two days and am at a loss. If anyone else has an idea, tell me what you think.
Code: Select all
<?php
# Load the appropriate extension based on OS
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
{ dl('php_gtk.dll'); }
else
{ dl('php_gtk.so'); }
# Now setup the movie container
$main_feature = &new movieContainer;
# Create our window
$window = &new GtkWindow();
$window->set_title('PHat GeeT''s Movie Player');
$window->set_default_size(300,0);
$window->connect('destroy','destroy');
# This is the initial vertical box that we will pack
# the rest of the application into.
$vbox = &new GtkVBox();
$window->add($vbox);
$vbox->show();
# The first step to creating a menu
$menu = &new GtkMenu;
# Now let's start creating the individual menu options.
# The first one is the Open command on the File list.
$menufile_open = &new GtkMenuItem("Open");
$menufile_open->connect("activate", "FileDialog");
# This is the quit dialog. There isn't going to be much here.
$menufile_quit = &new GtkMenuItem("Quit");
$menufile_quit->connect("activate", "destroy");
# Add the items to the menu
$menu->append($menufile_open);
$menu->append($menufile_quit);
# Let's see if we can create a menu box as well. Perhaps
# we should look at this as being a menu containe?
$menubar = &new GtkMenuBar();
$menubar->set_shadow_type(GTK_SHADOW_IN);
$vbox->add($menubar);
# This menuitem will be used as the label for our
# drop down menu.
$label_file = &new GtkMenuItem("File");
$label_file->set_submenu($menu);
# Now make sure that the menubar has this item
$menubar->append($label_file);
# Show everything and start GTK::main() - THIS IS IMPORTANT :O)
$window->show_all();
Gtk::main();
#############################################################################################
# Functions used by this program
#############################################################################################
# Used to kill the application
function destroy()
{ Gtk::main_quit(); }
# In the interest of choosing a file.
function FileDialog()
{
# The File selection box
$fs = &new GtkFileSelection('Pick da'' Flick');
$fs->hide_fileop_buttons(); // They can change file names elsewhere
# Now for the OK button
$ok_button = $fs->ok_button;
$ok_button->connect_object('clicked', 'PlayMovie', $fs); // The object is passed to the PlayMovie function to
// facilitate acting directly on it.
# And the cancel button
$cancel_button = $fs->cancel_button;
$cancel_button->connect_object('clicked', array($fs, 'destroy'));
$fs->show();
}
# Now play the movie fool!
function PlayMovie(&$dialog)
{
# Let's reference movieContainer
global $main_feature;
# Get the movie name
$mov = $dialog->get_filename();
$main_feature->setData($mov);
# This is where the File Selection dialog should be destroyed.
$dialog->destroy();
# And here, the movie should be played. However, this will be changed
# in time to provide more control over movie player while it's playing.
system("mplayer $mov");
}
# Just a funkmaster container thrown together to store
# the movie information for a short period.
class movieContainer
{
function setData($data)
{ $this->info = $data; }
function getData()
{ return $this->info; }
}
?>Anyways, if you can see where i've gone stupid, I'd love to know.
Later on,
BDKR