gnope php gtk gui gnope.org  

Detatchable Window objects?

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
CoryChristison



Joined: 18 Dec 2005
Posts: 9

PostPosted: Thu Jan 05, 2006 2:55 pm    Post subject: Detatchable Window objects? Reply with quote

Is PHP-GTK2 capable of producing these? Like in The GIMP, where you can grab one of the tool boxes and remove it from the main window and vise-versa?[pull a toolbox into the main window]

If this is possible, can someone point me in the right direction as to how to achieve a similar result?

Thanks.
Back to top
CoryChristison



Joined: 18 Dec 2005
Posts: 9

PostPosted: Mon Jan 09, 2006 6:41 am    Post subject: Reply with quote

* bump *
Anyone..?
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Mon Jan 09, 2006 9:28 am    Post subject: Re: Detatchable Window objects? Reply with quote

CoryChristison wrote:
Is PHP-GTK2 capable of producing these? Like in The GIMP, where you can grab one of the tool boxes and remove it from the main window and vise-versa?[pull a toolbox into the main window]

The thing with the Gimp menus is called "Tearoffmenuitem". To make complete windows detachable, you have to implement some own things. E.g. removing the box from the parent and re-parenting it to a newly created window. I had the same question on the php-gtk-general or php-gtk-dev mailing list some months ago; and andrei told me how to do it.
Back to top
ron_t



Joined: 11 Dec 2005
Posts: 78
Location: Gatineau, Quebec

PostPosted: Wed Jan 11, 2006 4:38 am    Post subject: Re: Detatchable Window objects? Reply with quote

cweiske wrote:
CoryChristison wrote:
Is PHP-GTK2 capable of producing these? Like in The GIMP, where you can grab one of the tool boxes and remove it from the main window and vise-versa?[pull a toolbox into the main window]

The thing with the Gimp menus is called "Tearoffmenuitem". To make complete windows detachable, you have to implement some own things. E.g. removing the box from the parent and re-parenting it to a newly created window. I had the same question on the php-gtk-general or php-gtk-dev mailing list some months ago; and andrei told me how to do it.


Yes, there is something like that. It's called a GtkHandleBox. Here's an example of using it with a menu:

Code:

<?php

/*
 *File name: gtk_handlebox.php
 */


/*-- This function allows the program to exit properly when the window is closed --*/
function destroyapp($widget, $gdata)
{
   print("Quitting..\n");
   Gtk::main_quit();
}


/*-- This function allows the program to exit properly when the window is closed --*/
function ClosingAppWindow()
{
   print("Quitting...\n");
   Gtk::main_quit();
}

$window = new GtkWindow(); /*-- Create the new window --*/
$vbox = new GtkVBox(false, 0); /*-- Create the vbox --*/
$text = new GtkTextView(); /*-- Create a text area --*/
$handlebox = new GtkHandleBox(); /*-- Create the handlebox --*/

$menubar = new GtkMenuBar();   /*-- Create the menu bar --*/

$menuFileHeader = new GtkMenuItem("File");
$menubar->append($menuFileHeader);
$menuEditHeader = new GtkMenuItem("Edit");
$menubar->append($menuEditHeader);
$menuHelpHeader = new GtkMenuItem("Help");
$menubar->append($menuHelpHeader);

$menuFile = new GtkMenu();
$newItem = new GtkMenuItem("New");
$menuFile->add($newItem);
$openItem = new GtkMenuItem("Open");
$menuFile->add($openItem);
$exitItem = new GtkMenuItem("Exit");
$exitItem->connect_simple("activate", "ClosingAppWindow");
$menuFile->add($exitItem);

$menuFileHeader->set_submenu($menuFile);

$menuEdit = new GtkMenu();
$undoItem = new GtkMenuItem("Undo");
$menuEdit->add($undoItem);
$copyItem = new GtkMenuItem("Copy");
$menuEdit->add($copyItem);
$cutItem = new GtkMenuItem("Cut");
$menuEdit->add($cutItem);

$menuEditHeader->set_submenu($menuEdit);

$menuHelp = new GtkMenu();
$aboutItem = new GtkMenuItem("About");
$menuHelp->add($aboutItem);

$menuHelpHeader->set_submenu($menuHelp);

$bufferStuffer = "Go to the file menu and select Exit to close the application.";

$text->set_editable(true);

$window->connect("destroy", "destroyapp");

$handlebox->add($menubar);

$vbox->pack_start($handlebox, false, true, 0);

$vbox->pack_end($text);

$window->add($vbox);

$text->set_editable(true);
$text->set_wrap_mode(Gtk::WRAP_WORD);
$buffer = $text->get_buffer();
$buffer->insert_at_cursor($bufferStuffer);

$window->set_title("GtkHandleBox Demo");
$window->set_default_size(640, 480);
$window->show_all();

  /*-- Start the GTK event loop --*/
Gtk::Main();

?>


Keep in mind that a GtkHandleBox can be used with any widget so, presumably, you could use it for a sub-menu or even a single menu item. This works with PHP-Gtk2, but I don't know about php-gtk1.

-Ron T.
Back to top
CoryChristison



Joined: 18 Dec 2005
Posts: 9

PostPosted: Thu Jan 12, 2006 2:31 am    Post subject: Reply with quote

Great!

Thank you very much! GTK/GTK2 is something I am very new to. These forums are a god-send! Hehe.
Back to top
karlbowden



Joined: 18 Dec 2005
Posts: 21
Location: Taree, NSW, Australia

PostPosted: Fri Jan 13, 2006 4:45 am    Post subject: Reply with quote

What about any way of being able to drag a detachable item from one handlebox and attach it to another?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.