Reorder PanelGadget Items

Linux specific forum
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Reorder PanelGadget Items

Post 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...
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

this is a little tricky as you dont have the ID's from the panel tabs when you use AddGadgetItem() :cry:

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* :D )

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

User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post 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 ?
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post 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() :( )
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

But how can we have the GadgetItemID for an item in a panel ?
Post Reply