Page 1 of 1
Reorder PanelGadget Items
Posted: Thu Aug 23, 2007 3:44 pm
by Progi1984
Hi,
The question is easy...
How can i reorder panelgadget items like this Windows code (
http://www.purebasic.fr/english/viewtopic.php?t=28479) ?
Thank you...
Posted: Fri Aug 24, 2007 12:20 am
by walker
this is a little tricky as you dont have the ID's from the panel tabs when you use AddGadgetItem()
Here is a small example how to reorder the tabs... one bad thing... you can't use PB Gadgets on this panel as you don't have the tabs in the gadgetlist.... you must use gtk widgets instead... (if someone could tell how to get the id's from each tab from the panelgadget..... if possible at all....*looking at fred*

)
Code: Select all
If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
*nb1= PanelGadget (#PB_Any, 5, 5, 290, 166)
*notebook1=GadgetID(*nb1)
*empty_notebook_page0 = gtk_vbox_new_(#False, 0);
gtk_widget_show_(*empty_notebook_page0);
gtk_container_add_(*notebook1, *empty_notebook_page0);
*label1 = gtk_label_new_("label1");
gtk_widget_show_(*label1);
gtk_notebook_set_tab_label_(*notebook1, gtk_notebook_get_nth_page_(*notebook1 , 0), *label1);
*empty_notebook_page1 = gtk_vbox_new_(#False, 0);
gtk_widget_show_(*empty_notebook_page1);
gtk_container_add_(*notebook1, *empty_notebook_page1);
*label2 = gtk_label_new_("label2");
gtk_widget_show_(*label2);
gtk_notebook_set_tab_label_(*notebook1, gtk_notebook_get_nth_page_(*notebook1 , 1), *label2);
;this is the part where you can reorder the tabs.... the last parameter is the new position or -1 = moved to the end
gtk_notebook_reorder_child_(*notebook1,*empty_notebook_page1,0)
SetGadgetState(*nb1,0) ; to activate the first tab again
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Posted: Fri Aug 24, 2007 7:47 am
by Progi1984
An another solution was (Thanks srod) to redefine the parent of a button placed on an item... so to move a button from a tab to an another tab.
Under Windows, Solution is SetParent_ but under linux ?
Posted: Fri Aug 24, 2007 8:35 am
by walker
Code: Select all
gtk_widget_set_parent_(*widget,*parent_widget)
or
Code: Select all
gtk_widget_set_parent_window_(*widget,*parent_window)
(unfortunately GetGadgetItemID() only works on TreeGadget()

)
Posted: Fri Aug 24, 2007 8:44 am
by Progi1984
But how can we have the GadgetItemID for an item in a panel ?