2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <gtk/gtktoolbar.h>
25 #include <gtk/gtktogglebutton.h>
27 #include "generic/callback.h"
29 #include "accelerator.h"
35 void toolbar_append( GtkToolbar* toolbar, GtkButton* button, const char* description ){
36 gtk_widget_show( GTK_WIDGET( button ) );
37 gtk_button_set_relief( button, GTK_RELIEF_NONE );
38 GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_FOCUS );
39 GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_DEFAULT );
40 gtk_toolbar_append_element( toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET( button ), "", description, "", 0, 0, 0 );
43 GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){
44 GtkButton* button = GTK_BUTTON( gtk_button_new() );
45 button_set_icon( button, icon );
46 button_connect_callback( button, callback );
47 toolbar_append( toolbar, button, description );
51 GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){
52 GtkToggleButton* button = GTK_TOGGLE_BUTTON( gtk_toggle_button_new() );
53 button_set_icon( GTK_BUTTON( button ), icon );
54 toggle_button_connect_callback( button, callback );
55 toolbar_append( toolbar, GTK_BUTTON( button ), description );
59 GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ){
60 return toolbar_append_button( toolbar, description, icon, command.m_callback );
63 void toggle_button_set_active_callback( GtkToggleButton& button, bool active ){
64 toggle_button_set_active_no_signal( &button, active );
66 typedef ReferenceCaller1<GtkToggleButton, bool, toggle_button_set_active_callback> ToggleButtonSetActiveCaller;
68 GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ){
69 GtkToggleButton* button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback );
70 toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button ) );