Re[2]: [PHP-GTK-DEV] Overrides for GtkUIManager and GtkCalendar
| From: | Tom Rogers | Date: | Mon, 19 Dec 2005 02:23:58 +0000 |
| Subject: | Re[2]: [PHP-GTK-DEV] Overrides for GtkUIManager and GtkCalendar | ||
| References: | 1 2 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-2130@lists.php.net to get a copy of this message | ||
Hi Steph,
Sunday, December 18, 2005, 6:07:56 AM, you wrote:
SF> Tom, hi,
SF> Would you mind putting short test scripts in with your patches? It takes
SF> much longer to review things like this when I'm having to look through
SF> sources to figure out what the expected behaviour is and how to reproduce it
SF> via PHP... and I'd guess you tested it already, no?
UiManager test script:
<?php
if( !class_exists('gtk')) {
die('Please load the php-gtk2 module in your php.ini' . "\r\n");
}
function EndDialog($button, $fs) {
print "OK button clicked, ";
$path = $fs->get_filename();
print "$path selected.\n";
$GLOBALS['acgroups']['EditActions']->set_sensitive(1);
return true;
}
function CancelDialog() {
print("Cancel button clicked\n");
return true;
}
function FileDialog() {
$fs = &new GtkFileSelection('File Selection Example');
$ok_button = $fs->ok_button;
$ok_button->connect('clicked', 'EndDialog', $fs);
$ok_button->connect_simple('clicked', array($fs, 'destroy'));
$cancel_button = $fs->cancel_button;
$cancel_button->connect('clicked', 'CancelDialog');
$cancel_button->connect_simple('clicked', array($fs, 'destroy'));
$fs->show();
}
function FileClose(){
$GLOBALS['acgroups']['EditActions']->set_sensitive(0);
}
function shutdown() {
Gtk::main_quit();
}
function canClose() {
return false;
}
$layout = '
<ui>
<menubar name="menubar1">
<menu action="FileMenu">
<menuitem action="Open"/>
<menuitem action="Close"/>
<separator/>
<menuitem action="Exit"/>
</menu>
<menu action="EditMenu">
<menuitem action="Copy"/>
<menuitem action="Paste"/>
</menu>
</menubar>
<toolbar action="toolbar1">
<placeholder name="JustifyToolItems">
<separator/>
<toolitem action="Open"/>
<toolitem action="Close"/>
<separator/>
</placeholder>
</toolbar>
</ui>';
$window = &new GtkWindow();
$window->set_title('PHP Editor');
$window->set_uposition(10, 10);
$window->set_size_request(800,600);
$window->connect('delete-event', 'canClose');
$window->connect('destroy', 'shutdown');
$accelgroup = &new GtkAccelGroup();
$window->add_accel_group($accelgroup);
$vbox1 =& new GtkVBox(FALSE, 0);
$vbox1->show();
$vbox1->set_spacing(1);
$ui_manager = new GtkUiManager();
$file_action_group = new GtkActionGroup("FileActions");
$ui_manager->insert_action_group($file_action_group, 0);
$fileAction = new GtkAction('FileMenu','_File','File
Actions','');
$openAction = new GtkAction('Open','_Open','Open
File','GTK_STOCK_OPEN');
$openAction->connect('activate','FileDialog');
$closeAction = new GtkAction('Close','_Close','Close
File','GTK_STOCK_CLOSE');
$closeAction->connect('activate','FileClose');
$exitAction = new
GtkAction('Exit','E_xit','Quit','GTK_STOCK_QUIT');
$exitAction->connect('activate','shutdown');
$file_action_group->add_action($fileAction);
$file_action_group->add_action($openAction);
$file_action_group->add_action($closeAction);
$file_action_group->add_action($exitAction);
$edit_action_group = new GtkActionGroup("EditActions");
$ui_manager->insert_action_group($edit_action_group, 0);
$editAction = new GtkAction('EditMenu','_Edit','Edit
Actions','');
$copyAction = new GtkAction('Copy','_Copy','Copy to
clipboard','GTK_STOCK_COPY');
$pasteAction = new GtkAction('Paste','_Paste','Paste from
clipboard','GTK_STOCK_PASTE');
$edit_action_group->add_action($editAction);
$edit_action_group->add_action($copyAction);
$edit_action_group->add_action($pasteAction);
$ui_manager->add_ui_from_string($layout);
$ui_manager->ensure_update();
$toplevels = $ui_manager->get_toplevels(5);
//print_r($toplevels);
$vbox1->pack_start($toplevels['menubar1'],FALSE,FALSE,0);
$vbox1->pack_start($toplevels['toolbar1'],FALSE,FALSE,0);
$acgroups = $ui_manager->get_action_groups();
//print_r($acgroups);
$acgroups['EditActions']->set_sensitive(0);
$window->add($vbox1);
$window->show_all();
Gtk::main();
--
regards,
Tom