X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=libs%2Fgtkutil%2Ftoolbar.cpp;h=fa7cc4f49df52a7475df5f0d0cbf820e11b0fafa;hb=9dfae1c9b270ee369c6362903a9205b30751b95f;hp=194aff2d25df65217190f74642d14ac3c40aae6e;hpb=bfc8a12a6b315ae261101a34db8ba1b682c67bb7;p=xonotic%2Fnetradiant.git diff --git a/libs/gtkutil/toolbar.cpp b/libs/gtkutil/toolbar.cpp index 194aff2d..fa7cc4f4 100644 --- a/libs/gtkutil/toolbar.cpp +++ b/libs/gtkutil/toolbar.cpp @@ -1,78 +1,79 @@ /* -Copyright (C) 2001-2006, William Joseph. -All Rights Reserved. + Copyright (C) 2001-2006, William Joseph. + All Rights Reserved. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "toolbar.h" -#include -#include +#include +#include #include "generic/callback.h" #include "accelerator.h" #include "button.h" -#include "closure.h" -#include "pointer.h" +#include "image.h" -void toolbar_append(GtkToolbar* toolbar, GtkButton* button, const char* description) +void toolbar_append(ui::Toolbar toolbar, ui::ToolItem button, const char *description) { - gtk_widget_show(GTK_WIDGET(button)); - gtk_button_set_relief(button, GTK_RELIEF_NONE); - GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(button), GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(button), GTK_CAN_DEFAULT); - gtk_toolbar_append_element(toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET(button), "", description, "", 0, 0, 0); + gtk_widget_show_all(button); + gtk_widget_set_tooltip_text(button, description); + toolbar.add(button); } -GtkButton* toolbar_append_button(GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback) +ui::ToolButton +toolbar_append_button(ui::Toolbar toolbar, const char *description, const char *icon, const Callback &callback) { - GtkButton* button = GTK_BUTTON(gtk_button_new()); - button_set_icon(button, icon); - button_connect_callback(button, callback); - toolbar_append(toolbar, button, description); - return button; + auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr)); + button_connect_callback(button, callback); + toolbar_append(toolbar, button, description); + return button; } -GtkToggleButton* toolbar_append_toggle_button(GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback) +ui::ToggleToolButton toolbar_append_toggle_button(ui::Toolbar toolbar, const char *description, const char *icon, + const Callback &callback) { - GtkToggleButton* button = GTK_TOGGLE_BUTTON(gtk_toggle_button_new()); - button_set_icon(GTK_BUTTON(button), icon); - toggle_button_connect_callback(button, callback); - toolbar_append(toolbar, GTK_BUTTON(button), description); - return button; + auto button = ui::ToggleToolButton::from(gtk_toggle_tool_button_new()); + toggle_button_connect_callback(button, callback); + gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), new_local_image(icon)); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description); + toolbar_append(toolbar, button, description); + return button; } -GtkButton* toolbar_append_button(GtkToolbar* toolbar, const char* description, const char* icon, const Command& command) +ui::ToolButton +toolbar_append_button(ui::Toolbar toolbar, const char *description, const char *icon, const Command &command) { - return toolbar_append_button(toolbar, description, icon, command.m_callback); + return toolbar_append_button(toolbar, description, icon, command.m_callback); } -void toggle_button_set_active_callback(GtkToggleButton& button, bool active) +void toggle_button_set_active_callback(void *it, bool active) { - toggle_button_set_active_no_signal(&button, active); + auto button = ui::ToggleToolButton::from(it); + toggle_button_set_active_no_signal(button, active); } -typedef ReferenceCaller1 ToggleButtonSetActiveCaller; -GtkToggleButton* toolbar_append_toggle_button(GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle) +ui::ToggleToolButton +toolbar_append_toggle_button(ui::Toolbar toolbar, const char *description, const char *icon, const Toggle &toggle) { - GtkToggleButton* button = toolbar_append_toggle_button(toolbar, description, icon, toggle.m_command.m_callback); - toggle.m_exportCallback(ToggleButtonSetActiveCaller(*button)); - return button; + auto button = toolbar_append_toggle_button(toolbar, description, icon, toggle.m_command.m_callback); + toggle.m_exportCallback(PointerCaller(button._handle)); + return button; }