here is a simple way to use the GTK-Toolbar in your projects which looks quite more proffessional than the build-in toolbar (and the text of the buttons will be automatically translated into the users language - if installed)

The code is commented where necessary (hope so).
Code: Select all
;HowTo include a professional looking toolbar with PB3.94
;using the gtk2 Toolbar
;2006 by walker
;
;to access them everywhere
Global *toolbar1.gtkwidget
Global *toolbutton1.gtkwidget
Global *toolbutton2.gtkwidget
Global *toolbutton3.gtkwidget
Global *toolbutton4.gtkwidget
Global *toolbutton5.gtkwidget
Global *toolbutton6.gtkwidget
;constants
Enumeration
#toolbar_0
EndEnumeration
ProcedureCDLL on_new_toolbutton_clicked (toolbutton,user_data)
;Your code here
EndProcedure
ProcedureCDLL on_open_toolbutton_clicked (toolbutton,user_data)
;Your code here
EndProcedure
ProcedureCDLL on_save_toolbutton_clicked (toolbutton,user_data)
;Your code here
EndProcedure
ProcedureCDLL on_preferences_toolbutton_clicked (toolbutton,user_data)
;Your code here
EndProcedure
ProcedureCDLL on_info_toolbutton_clicked (toolbutton,user_data)
;Your code here
EndProcedure
ProcedureCDLL on_exit_toolbutton_clicked (toolbutton,user_data)
;Your code here
End;for example
EndProcedure
Procedure Open_Window_0()
If OpenWindow(0,0,0,500,350,#PB_Window_ScreenCentered,"GTK2-Toolbar")
If CreateGadgetList(WindowID())
*toolbar1= CreateToolBar(#toolbar_0,WindowID())
gtk_widget_show_(*toolbar1);
gtk_toolbar_set_style_(*toolbar1, #GTK_TOOLBAR_ICONS); use #GTK_TOOLBAR_TEXT to show text only and #GTK_TOOLBAR_BOTH for both, text and Icon
tmp_toolbar_icon_size = gtk_toolbar_get_icon_size_(*toolbar1);
*toolbutton1 = gtk_tool_button_new_from_stock_("gtk-new");
gtk_widget_show_(*toolbutton1);
gtk_container_add_(*toolbar1, *toolbutton1);
*toolbutton2 = gtk_tool_button_new_from_stock_("gtk-open");
gtk_widget_show_(*toolbutton2);
gtk_container_add_(*toolbar1, *toolbutton2);
*toolbutton3 = gtk_tool_button_new_from_stock_("gtk-save-as");
gtk_widget_show_(*toolbutton3);
gtk_container_add_(*toolbar1, *toolbutton3);
*separatortoolitem1 = gtk_separator_tool_item_new_();
gtk_widget_show_(*separatortoolitem1);
gtk_container_add_(*toolbar1, *separatortoolitem1);
*toolbutton4 = gtk_tool_button_new_from_stock_("gtk-preferences");
gtk_widget_show_(*toolbutton4);
gtk_container_add_(*toolbar1, *toolbutton4);
*toolbutton5 = gtk_tool_button_new_from_stock_("gtk-info");
gtk_widget_show_(*toolbutton5);
gtk_container_add_(*toolbar1, *toolbutton5);
*separatortoolitem3 = gtk_separator_tool_item_new_();
gtk_widget_show_(*separatortoolitem3);
gtk_tool_item_set_expand_(*separatortoolitem3, #True);to move the last button to the right side of the window, otherwise comment this line
gtk_container_add_(*toolbar1, *separatortoolitem3);
*toolbutton6 = gtk_tool_button_new_from_stock_("gtk-quit");
gtk_widget_show_(*toolbutton6);
gtk_container_add_(*toolbar1, *toolbutton6);
;add any pb gadgets here - you can use 0 as y-parameter - the gadget will properly shown below the toolbar
;close the gadgetlist properly
CloseGadgetList()
;connect each button of the toolbar to a procedure
g_signal_connect_object_( *toolbutton1, "clicked",@on_new_toolbutton_clicked(),*pointer,0)
g_signal_connect_object_( *toolbutton2, "clicked",@on_open_toolbutton_clicked(),*pointer,0)
g_signal_connect_object_( *toolbutton3, "clicked",@on_save_toolbutton_clicked(),*pointer,0)
g_signal_connect_object_( *toolbutton4, "clicked",@on_preferences_toolbutton_clicked(),*pointer,0)
g_signal_connect_object_( *toolbutton5, "clicked",@on_info_toolbutton_clicked(),*pointer,0)
g_signal_connect_object_( *toolbutton6, "clicked",@on_exit_toolbutton_clicked(),*pointer,0)
EndIf
EndIf
EndProcedure
;the gtk-events of the toolbar doesn't appear in the wait_window_event() (maybe tey do, but aren't reported by WaitWindowEvent()
;if you have a menu entry with the same action as a toolbarbutton, simply call the ProcedureCDLL when the MenuID is fired
Open_Window_0()
Repeat
event=WaitWindowEvent()
Until event = #PB_Event_CloseWindow
End
if you need other ones.
Compile with GTK2 as subsystem!
Questions, comments etc. are appreciated