]> icculus.org git repositories - divverent/netradiant.git/blob - libs/gtkutil/toolbar.cpp
slightly better font handling, enjoy!
[divverent/netradiant.git] / libs / gtkutil / toolbar.cpp
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
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.
11
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.
16
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
20 */
21
22 #include "toolbar.h"
23
24 #include <gtk/gtktoolbar.h>
25 #include <gtk/gtktogglebutton.h>
26
27 #include "generic/callback.h"
28
29 #include "accelerator.h"
30 #include "button.h"
31 #include "closure.h"
32 #include "pointer.h"
33
34
35 void toolbar_append(GtkToolbar* toolbar, GtkButton* button, const char* description)
36 {
37   gtk_widget_show(GTK_WIDGET(button));
38   gtk_button_set_relief(button, GTK_RELIEF_NONE);
39   GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(button), GTK_CAN_FOCUS);
40   GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(button), GTK_CAN_DEFAULT);
41   gtk_toolbar_append_element(toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET(button), "", description, "", 0, 0, 0);
42 }
43
44 GtkButton* toolbar_append_button(GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback)
45 {
46   GtkButton* button = GTK_BUTTON(gtk_button_new());
47   button_set_icon(button, icon);
48   button_connect_callback(button, callback);
49   toolbar_append(toolbar, button, description);
50   return button;
51 }
52
53 GtkToggleButton* toolbar_append_toggle_button(GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback)
54 {
55   GtkToggleButton* button = GTK_TOGGLE_BUTTON(gtk_toggle_button_new());
56   button_set_icon(GTK_BUTTON(button), icon);
57   toggle_button_connect_callback(button, callback);
58   toolbar_append(toolbar, GTK_BUTTON(button), description);
59   return button;
60 }
61
62 GtkButton* toolbar_append_button(GtkToolbar* toolbar, const char* description, const char* icon, const Command& command)
63 {
64   return toolbar_append_button(toolbar, description, icon, command.m_callback);
65 }
66
67 void toggle_button_set_active_callback(GtkToggleButton& button, bool active)
68 {
69   toggle_button_set_active_no_signal(&button, active);
70 }
71 typedef ReferenceCaller1<GtkToggleButton, bool, toggle_button_set_active_callback> ToggleButtonSetActiveCaller;
72
73 GtkToggleButton* toolbar_append_toggle_button(GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle)
74 {
75   GtkToggleButton* button = toolbar_append_toggle_button(toolbar, description, icon, toggle.m_command.m_callback);
76   toggle.m_exportCallback(ToggleButtonSetActiveCaller(*button));
77   return button;
78 }