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 <uilib/uilib.h>
26 #include "generic/callback.h"
28 #include "accelerator.h"
33 void toolbar_append( ui::Toolbar toolbar, GtkToolItem* button, const char* description ){
34 gtk_widget_show_all(GTK_WIDGET(button));
35 gtk_widget_set_tooltip_text(GTK_WIDGET(button), description);
36 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button));
39 ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ){
40 auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(GTK_WIDGET(new_local_image(icon)), nullptr)));
41 button_connect_callback(button, callback);
42 toolbar_append(toolbar, GTK_TOOL_ITEM(button), description);
46 ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ){
47 auto button = ui::ToggleToolButton(GTK_TOGGLE_TOOL_BUTTON(gtk_toggle_tool_button_new()));
48 toggle_button_connect_callback(button, callback);
49 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), GTK_WIDGET(new_local_image(icon)));
50 gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description);
51 toolbar_append(toolbar, GTK_TOOL_ITEM(button), description);
55 ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Command& command ){
56 return toolbar_append_button( toolbar, description, icon, command.m_callback );
59 void toggle_button_set_active_callback( GtkToggleToolButton& button, bool active ){
60 toggle_button_set_active_no_signal( ui::ToggleToolButton(&button), active );
62 using ToggleButtonSetActiveCaller = ReferenceCaller1<GtkToggleToolButton, bool, toggle_button_set_active_callback>;
64 ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Toggle& toggle ){
65 auto button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback );
66 GtkToggleToolButton *button_ = button;
67 toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button_ ) );