Wrap gtkutil/button
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 21 Jul 2017 13:34:47 +0000 (23:34 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 31 Jul 2017 12:35:47 +0000 (22:35 +1000)
13 files changed:
libs/gtkutil/button.cpp
libs/gtkutil/button.h
libs/gtkutil/dialog.cpp
libs/gtkutil/dialog.h
libs/gtkutil/nonmodal.h
libs/gtkutil/toolbar.cpp
libs/gtkutil/toolbar.h
libs/uilib/uilib.cpp
libs/uilib/uilib.h
radiant/dialog.cpp
radiant/entityinspector.cpp
radiant/patchdialog.cpp
radiant/surfacedialog.cpp

index 08744ff..778a74a 100644 (file)
 #include "image.h"
 #include "pointer.h"
 
-void clicked_closure_callback( GtkWidget* widget, gpointer data ){
+void clicked_closure_callback( ui::Widget widget, gpointer data ){
        ( *reinterpret_cast<Callback*>( data ) )( );
 }
 
-void button_connect_callback( GtkButton* button, const Callback& callback ){
+void button_connect_callback( ui::Button button, const Callback& callback ){
 #if 1
        g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
 #else
@@ -42,7 +42,7 @@ void button_connect_callback( GtkButton* button, const Callback& callback ){
 #endif
 }
 
-void button_connect_callback( GtkToolButton* button, const Callback& callback ){
+void button_connect_callback( ui::ToolButton button, const Callback& callback ){
 #if 1
        g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
 #else
@@ -50,7 +50,7 @@ void button_connect_callback( GtkToolButton* button, const Callback& callback ){
 #endif
 }
 
-guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback ){
+guint toggle_button_connect_callback( ui::ToggleButton button, const Callback& callback ){
 #if 1
        guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
 #else
@@ -60,7 +60,7 @@ guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& c
        return handler;
 }
 
-guint toggle_button_connect_callback( GtkToggleToolButton* button, const Callback& callback ){
+guint toggle_button_connect_callback( ui::ToggleToolButton button, const Callback& callback ){
 #if 1
        guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
 #else
@@ -70,13 +70,13 @@ guint toggle_button_connect_callback( GtkToggleToolButton* button, const Callbac
        return handler;
 }
 
-void button_set_icon( GtkButton* button, const char* icon ){
-       GtkImage* image = new_local_image( icon );
-       gtk_widget_show( GTK_WIDGET( image ) );
+void button_set_icon( ui::Button button, const char* icon ){
+       ui::Image image = ui::Image(new_local_image( icon ));
+       image.show();
        gtk_container_add( GTK_CONTAINER( button ), GTK_WIDGET( image ) );
 }
 
-void toggle_button_set_active_no_signal( GtkToggleButton* button, gboolean active ){
+void toggle_button_set_active_no_signal( ui::ToggleButton button, gboolean active ){
        //globalOutputStream() << "set active: " << active << "\n";
        guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( button ), "handler" ) );
        //guint signal_id = g_signal_lookup("toggled", G_OBJECT_TYPE (button));
@@ -88,7 +88,7 @@ void toggle_button_set_active_no_signal( GtkToggleButton* button, gboolean activ
        g_signal_handler_unblock( G_OBJECT( button ), handler_id );
 }
 
-void toggle_button_set_active_no_signal( GtkToggleToolButton* button, gboolean active ){
+void toggle_button_set_active_no_signal( ui::ToggleToolButton button, gboolean active ){
        guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( button ), "handler" ) );
        g_signal_handler_block( G_OBJECT( button ), handler_id );
        gtk_toggle_tool_button_set_active( button, active );
@@ -96,7 +96,7 @@ void toggle_button_set_active_no_signal( GtkToggleToolButton* button, gboolean a
 }
 
 
-void radio_button_print_state( GtkRadioButton* button ){
+void radio_button_print_state( ui::RadioButton button ){
        globalOutputStream() << "toggle button: ";
        for ( GSList* radio = gtk_radio_button_get_group( button ); radio != 0; radio = g_slist_next( radio ) )
        {
@@ -105,18 +105,18 @@ void radio_button_print_state( GtkRadioButton* button ){
        globalOutputStream() << "\n";
 }
 
-GtkToggleButton* radio_button_get_nth( GtkRadioButton* radio, int index ){
+GtkToggleButton* radio_button_get_nth( ui::RadioButton radio, int index ){
        GSList *group = gtk_radio_button_get_group( radio );
        return GTK_TOGGLE_BUTTON( g_slist_nth_data( group, g_slist_length( group ) - index - 1 ) );
 }
 
-void radio_button_set_active( GtkRadioButton* radio, int index ){
+void radio_button_set_active( ui::RadioButton radio, int index ){
        //radio_button_print_state(radio);
        gtk_toggle_button_set_active( radio_button_get_nth( radio, index ), TRUE );
        //radio_button_print_state(radio);
 }
 
-void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ){
+void radio_button_set_active_no_signal( ui::RadioButton radio, int index ){
        {
                for ( GSList* l = gtk_radio_button_get_group( radio ); l != 0; l = g_slist_next( l ) )
                {
@@ -132,7 +132,7 @@ void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ){
        }
 }
 
-int radio_button_get_active( GtkRadioButton* radio ){
+int radio_button_get_active( ui::RadioButton radio ){
        //radio_button_print_state(radio);
        GSList *group = gtk_radio_button_get_group( radio );
        int index = g_slist_length( group ) - 1;
index 1ffb025..b7aa412 100644 (file)
 #if !defined( INCLUDED_GTKUTIL_BUTTON_H )
 #define INCLUDED_GTKUTIL_BUTTON_H
 
-#include <gtk/gtk.h>
+#include <uilib/uilib.h>
 #include "generic/callbackfwd.h"
 
-typedef struct _GtkButton GtkButton;
-typedef struct _GtkToggleButton GtkToggleButton;
-typedef struct _GtkRadioButton GtkRadioButton;
 typedef int gint;
 typedef gint gboolean;
 typedef unsigned int guint;
 
-void button_connect_callback( GtkButton* button, const Callback& callback );
-void button_connect_callback( GtkToolButton* button, const Callback& callback );
-guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback );
-guint toggle_button_connect_callback( GtkToggleToolButton* button, const Callback& callback );
+void button_connect_callback( ui::Button button, const Callback& callback );
+void button_connect_callback( ui::ToolButton button, const Callback& callback );
+guint toggle_button_connect_callback( ui::ToggleButton button, const Callback& callback );
+guint toggle_button_connect_callback( ui::ToggleToolButton button, const Callback& callback );
 
-void button_set_icon( GtkButton* button, const char* icon );
-void toggle_button_set_active_no_signal( GtkToggleButton* item, gboolean active );
-void toggle_button_set_active_no_signal( GtkToggleToolButton* item, gboolean active );
+void button_set_icon( ui::Button button, const char* icon );
+void toggle_button_set_active_no_signal( ui::ToggleButton item, gboolean active );
+void toggle_button_set_active_no_signal( ui::ToggleToolButton item, gboolean active );
 
-void radio_button_set_active( GtkRadioButton* radio, int index );
-void radio_button_set_active_no_signal( GtkRadioButton* radio, int index );
-int radio_button_get_active( GtkRadioButton* radio );
+void radio_button_set_active( ui::RadioButton radio, int index );
+void radio_button_set_active_no_signal( ui::RadioButton radio, int index );
+int radio_button_get_active( ui::RadioButton radio );
 
 #endif
index d22dc94..dfeece8 100644 (file)
@@ -209,7 +209,7 @@ PathEntry PathEntry_new(){
        gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
 
        // browse button
-       GtkButton* button = ui::Button();
+       auto button = ui::Button();
        button_set_icon( button, "ellipsis.bmp" );
        gtk_widget_show( GTK_WIDGET( button ) );
        gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
index b5a4319..010432d 100644 (file)
@@ -94,7 +94,7 @@ class RadioHBox
 {
 public:
 GtkHBox* m_hbox;
-GtkRadioButton* m_radio;
+ui::RadioButton m_radio;
 RadioHBox( GtkHBox* hbox, GtkRadioButton* radio ) :
        m_hbox( hbox ),
        m_radio( radio ){
index 4baf54b..b8dc3f8 100644 (file)
@@ -153,7 +153,7 @@ void connect( GtkRadioButton* radio ){
        GSList* group = gtk_radio_button_get_group( radio );
        for (; group != 0; group = g_slist_next( group ) )
        {
-               toggle_button_connect_callback( GTK_TOGGLE_BUTTON( group->data ), m_changed );
+               toggle_button_connect_callback( ui::ToggleButton(GTK_TOGGLE_BUTTON( group->data )), m_changed );
        }
 }
 };
index c065940..2f7cf5f 100644 (file)
@@ -36,15 +36,15 @@ void toolbar_append( GtkToolbar* toolbar, GtkToolItem* button, const char* descr
        gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button));
 }
 
-GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){
-       auto button = GTK_TOOL_BUTTON(gtk_tool_button_new(GTK_WIDGET(new_local_image(icon)), nullptr));
+ui::ToolButton toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){
+       auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(GTK_WIDGET(new_local_image(icon)), nullptr)));
        button_connect_callback(button, callback);
        toolbar_append(toolbar, GTK_TOOL_ITEM(button), description);
        return button;
 }
 
-GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){
-       auto button = GTK_TOGGLE_TOOL_BUTTON(gtk_toggle_tool_button_new());
+ui::ToggleToolButton toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){
+       auto button = ui::ToggleToolButton(GTK_TOGGLE_TOOL_BUTTON(gtk_toggle_tool_button_new()));
        toggle_button_connect_callback(button, callback);
        gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), GTK_WIDGET(new_local_image(icon)));
        gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description);
@@ -52,17 +52,18 @@ GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const ch
        return button;
 }
 
-GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ){
+ui::ToolButton toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ){
        return toolbar_append_button( toolbar, description, icon, command.m_callback );
 }
 
 void toggle_button_set_active_callback( GtkToggleToolButton& button, bool active ){
-       toggle_button_set_active_no_signal( &button, active );
+       toggle_button_set_active_no_signal( ui::ToggleToolButton(&button), active );
 }
 using ToggleButtonSetActiveCaller = ReferenceCaller1<GtkToggleToolButton, bool, toggle_button_set_active_callback>;
 
-GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ){
+ui::ToggleToolButton toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ){
        auto button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback );
-       toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button ) );
+       GtkToggleToolButton *button_ = button;
+       toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button_ ) );
        return button;
 }
index 687fa0a..421e20a 100644 (file)
@@ -23,6 +23,7 @@
 #define INCLUDED_GTKUTIL_TOOLBAR_H
 
 #include <gtk/gtk.h>
+#include <uilib/uilib.h>
 #include "generic/callbackfwd.h"
 
 typedef struct _GtkButton GtkButton;
@@ -31,9 +32,9 @@ typedef struct _GtkToolbar GtkToolbar;
 class Command;
 class Toggle;
 
-GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback );
-GtkToolButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command );
-GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback );
-GtkToggleToolButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle );
+ui::ToolButton toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback );
+ui::ToolButton toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command );
+ui::ToggleToolButton toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback );
+ui::ToggleToolButton toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle );
 
 #endif
index dc0b93f..1e37a1e 100644 (file)
@@ -24,13 +24,25 @@ namespace ui {
 
     Widget root{nullptr};
 
-#define this (*static_cast<self>(this))
+#define IMPL(T, F) template<> _IMPL(T, F)
+#define _IMPL(T, F) struct verify<T *> { using self = T; static self test(self it) { return self(F(it)); } }
+
+    template<class T>
+    struct verify;
+
+    template<class T> _IMPL(T,);
+
+#define this verify<self>::test(*static_cast<self>(this))
+
+    IMPL(Editable, GTK_EDITABLE);
 
     void IEditable::editable(bool value)
     {
         gtk_editable_set_editable(GTK_EDITABLE(this), value);
     }
 
+    IMPL(Widget, GTK_WIDGET);
+
     Widget::Widget() : Widget(nullptr)
     {}
 
@@ -66,6 +78,13 @@ namespace ui {
         return ::file_dialog(this, open, title, path, pattern, want_load, want_import, want_save);
     }
 
+    void IWidget::show()
+    {
+        gtk_widget_show(this);
+    }
+
+    IMPL(Window, GTK_WINDOW);
+
     Window::Window() : Window(nullptr)
     {}
 
@@ -113,27 +132,39 @@ namespace ui {
         gtk_window_add_accel_group(this, group);
     }
 
+    IMPL(Alignment, GTK_ALIGNMENT);
+
     Alignment::Alignment(float xalign, float yalign, float xscale, float yscale)
             : Alignment(GTK_ALIGNMENT(gtk_alignment_new(xalign, yalign, xscale, yscale)))
     {}
 
+    IMPL(Frame, GTK_FRAME);
+
     Frame::Frame(const char *label) : Frame(GTK_FRAME(gtk_frame_new(label)))
     {}
 
+    IMPL(Button, GTK_BUTTON);
+
     Button::Button() : Button(GTK_BUTTON(gtk_button_new()))
     {}
 
     Button::Button(const char *label) : Button(GTK_BUTTON(gtk_button_new_with_label(label)))
     {}
 
+    IMPL(ToggleButton, GTK_TOGGLE_BUTTON);
+
     bool IToggleButton::active()
     {
         return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(this)) != 0;
     }
 
+    IMPL(CheckButton, GTK_CHECK_BUTTON);
+
     CheckButton::CheckButton(const char *label) : CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_label(label)))
     {}
 
+    IMPL(MenuItem, GTK_MENU_ITEM);
+
     MenuItem::MenuItem() : MenuItem(GTK_MENU_ITEM(gtk_menu_item_new()))
     {}
 
@@ -141,35 +172,55 @@ namespace ui {
             GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label)))
     {}
 
+    IMPL(TearoffMenuItem, GTK_TEAROFF_MENU_ITEM);
+
     TearoffMenuItem::TearoffMenuItem() : TearoffMenuItem(GTK_TEAROFF_MENU_ITEM(gtk_tearoff_menu_item_new()))
     {}
 
+    IMPL(ComboBoxText, GTK_COMBO_BOX_TEXT);
+
     ComboBoxText::ComboBoxText() : ComboBoxText(GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new()))
     {}
 
+    IMPL(ScrolledWindow, GTK_SCROLLED_WINDOW);
+
     ScrolledWindow::ScrolledWindow() : ScrolledWindow(GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(nullptr, nullptr)))
     {}
 
+    IMPL(VBox, GTK_VBOX);
+
     VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing)))
     {}
 
+    IMPL(HBox, GTK_HBOX);
+
     HBox::HBox(bool homogenous, int spacing) : HBox(GTK_HBOX(gtk_hbox_new(homogenous, spacing)))
     {}
 
+    IMPL(HPaned, GTK_HPANED);
+
     HPaned::HPaned() : HPaned(GTK_HPANED(gtk_hpaned_new()))
     {}
 
+    IMPL(VPaned, GTK_VPANED);
+
     VPaned::VPaned() : VPaned(GTK_VPANED(gtk_vpaned_new()))
     {}
 
+    IMPL(Menu, GTK_MENU);
+
     Menu::Menu() : Menu(GTK_MENU(gtk_menu_new()))
     {}
 
+    IMPL(Table, GTK_TABLE);
+
     Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table(
             GTK_TABLE(gtk_table_new(rows, columns, homogenous))
     )
     {}
 
+    IMPL(TextView, GTK_TEXT_VIEW);
+
     TextView::TextView() : TextView(GTK_TEXT_VIEW(gtk_text_view_new()))
     {}
 
@@ -179,12 +230,18 @@ namespace ui {
     TreeView::TreeView(TreeModel model) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new_with_model(model)))
     {}
 
+    IMPL(Label, GTK_LABEL);
+
     Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label)))
     {}
 
+    IMPL(Image, GTK_IMAGE);
+
     Image::Image() : Image(GTK_IMAGE(gtk_image_new()))
     {}
 
+    IMPL(Entry, GTK_ENTRY);
+
     Entry::Entry() : Entry(GTK_ENTRY(gtk_entry_new()))
     {}
 
@@ -193,16 +250,22 @@ namespace ui {
         gtk_entry_set_max_length(this, static_cast<gint>(max_length));
     }
 
+    IMPL(SpinButton, GTK_SPIN_BUTTON);
+
     SpinButton::SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits) : SpinButton(
             GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits)))
     {}
 
+    IMPL(HScale, GTK_HSCALE);
+
     HScale::HScale(Adjustment adjustment) : HScale(GTK_HSCALE(gtk_hscale_new(adjustment)))
     {}
 
     HScale::HScale(double min, double max, double step) : HScale(GTK_HSCALE(gtk_hscale_new_with_range(min, max, step)))
     {}
 
+    IMPL(Adjustment, GTK_ADJUSTMENT);
+
     Adjustment::Adjustment(double value,
                            double lower, double upper,
                            double step_increment, double page_increment,
@@ -211,9 +274,13 @@ namespace ui {
             GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size)))
     {}
 
+    IMPL(CellRendererText, GTK_CELL_RENDERER_TEXT);
+
     CellRendererText::CellRendererText() : CellRendererText(GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new()))
     {}
 
+    IMPL(TreeViewColumn, GTK_TREE_VIEW_COLUMN);
+
     TreeViewColumn::TreeViewColumn(const char *title, CellRenderer renderer,
                                    std::initializer_list<TreeViewColumnAttribute> attributes)
             : TreeViewColumn(gtk_tree_view_column_new_with_attributes(title, renderer, nullptr))
@@ -223,13 +290,20 @@ namespace ui {
         }
     };
 
+    IMPL(AccelGroup, GTK_ACCEL_GROUP);
+
     AccelGroup::AccelGroup() : AccelGroup(GTK_ACCEL_GROUP(gtk_accel_group_new()))
     {}
 
-    void IListStore::clear() {
+    IMPL(ListStore, GTK_LIST_STORE);
+
+    void IListStore::clear()
+    {
         gtk_list_store_clear(this);
     }
 
+    // IMPL(TreePath, GTK_TREE_PATH);
+
     TreePath::TreePath() : TreePath(gtk_tree_path_new())
     {}
 
index 284609d..72ec0ca 100644 (file)
@@ -29,11 +29,13 @@ struct _GtkItem;
 struct _GtkLabel;
 struct _GtkListStore;
 struct _GtkMenu;
-struct _GtkMenuShell;
 struct _GtkMenuItem;
+struct _GtkMenuShell;
 struct _GtkMisc;
 struct _GtkObject;
 struct _GtkPaned;
+struct _GtkRadioButton;
+struct _GtkRadioToolButton;
 struct _GtkRange;
 struct _GtkScale;
 struct _GtkScrolledWindow;
@@ -42,6 +44,9 @@ struct _GtkTable;
 struct _GtkTearoffMenuItem;
 struct _GtkTextView;
 struct _GtkToggleButton;
+struct _GtkToggleToolButton;
+struct _GtkToolButton;
+struct _GtkToolItem;
 struct _GtkTreeModel;
 struct _GtkTreePath;
 struct _GtkTreeView;
@@ -194,6 +199,7 @@ namespace ui {
                  bool want_import = false,
                  bool want_save = false
          );
+         void show();
     );
 
     WRAP(Container, Widget, _GtkContainer, (),
@@ -264,6 +270,10 @@ namespace ui {
     ,
     );
 
+    WRAP(RadioButton, CheckButton, _GtkRadioButton, (),
+    ,
+    );
+
     WRAP(Item, Bin, _GtkItem, (),
     ,
     );
@@ -287,6 +297,22 @@ namespace ui {
     ,
     );
 
+    WRAP(ToolItem, Bin, _GtkToolItem, (),
+    ,
+    );
+
+    WRAP(ToolButton, ToolItem, _GtkToolButton, (),
+    ,
+    );
+
+    WRAP(ToggleToolButton, ToolButton, _GtkToggleToolButton, (),
+    ,
+    );
+
+    WRAP(RadioToolButton, ToggleToolButton, _GtkRadioToolButton, (),
+    ,
+    );
+
     WRAP(ScrolledWindow, Bin, _GtkScrolledWindow, (),
          ScrolledWindow();
     ,
index 51c2b10..b93bf00 100644 (file)
@@ -142,10 +142,10 @@ typedef ImportExport<GtkToggleButton, bool, BoolToggleImport, BoolToggleExport>
 
 
 void IntRadioImport( GtkRadioButton& widget, int index ){
-       radio_button_set_active( &widget, index );
+       radio_button_set_active( ui::RadioButton(&widget), index );
 }
 void IntRadioExport( GtkRadioButton& widget, const IntImportCallback& importCallback ){
-       importCallback( radio_button_get_active( &widget ) );
+       importCallback( radio_button_get_active( ui::RadioButton(&widget) ) );
 }
 typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
 
index 527e023..912cd74 100644 (file)
@@ -146,11 +146,11 @@ typedef MemberCaller<BooleanAttribute, &BooleanAttribute::apply> ApplyCaller;
 void update(){
        const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
        if ( !string_empty( value ) ) {
-               toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_check ), atoi( value ) != 0 );
+               toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( m_check )), atoi( value ) != 0 );
        }
        else
        {
-               toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_check ), false );
+               toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( m_check )), false );
        }
 }
 typedef MemberCaller<BooleanAttribute, &BooleanAttribute::update> UpdateCaller;
@@ -989,14 +989,14 @@ void EntityInspector_updateSpawnflags(){
                {
                        int v = !!( f & ( 1 << spawn_table[i] ) );
 
-                       toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ), v );
+                       toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), v );
                }
        }
        {
                // take care of the remaining ones
                for ( int i = g_spawnflag_count; i < MAX_FLAGS; ++i )
                {
-                       toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ), FALSE );
+                       toggle_button_set_active_no_signal( ui::ToggleButton(GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] )), FALSE );
                }
        }
 }
index 10d1806..9068b75 100644 (file)
@@ -158,16 +158,16 @@ typedef struct _GtkCheckButton GtkCheckButton;
 class Subdivisions
 {
 public:
-GtkCheckButton* m_enabled;
+ui::CheckButton m_enabled;
 GtkEntry* m_horizontal;
 GtkEntry* m_vertical;
-Subdivisions() : m_enabled( 0 ), m_horizontal( 0 ), m_vertical( 0 ){
+Subdivisions() : m_enabled( (GtkCheckButton *) 0 ), m_horizontal( 0 ), m_vertical( 0 ){
 }
 void update(){
        PatchFixedSubdivisions subdivisions;
        Scene_PatchGetFixedSubdivisions( subdivisions );
 
-       toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_enabled ), subdivisions.m_enabled );
+       toggle_button_set_active_no_signal( m_enabled, subdivisions.m_enabled );
 
        if ( subdivisions.m_enabled ) {
                entry_set_int( m_horizontal, static_cast<int>( subdivisions.m_x ) );
@@ -748,7 +748,7 @@ ui::Window PatchInspector::BuildDialog(){
                                                                                                  (GtkAttachOptions)( 0 ), 0, 0 );
                                                        }
                                                        {
-                                                               GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new() );
+                                                               auto check = ui::CheckButton(GTK_CHECK_BUTTON( gtk_check_button_new() ));
                                                                gtk_widget_show( GTK_WIDGET( check ) );
                                                                gtk_table_attach( table, GTK_WIDGET( check ), 1, 2, 0, 1,
                                                                                                  (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
index 438498e..2a2d098 100644 (file)
@@ -1171,12 +1171,12 @@ void SurfaceInspector::Update(){
 
                for ( GtkCheckButton** p = m_surfaceFlags; p != m_surfaceFlags + 32; ++p )
                {
-                       toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) );
+                       toggle_button_set_active_no_signal( ui::CheckButton( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) );
                }
 
                for ( GtkCheckButton** p = m_contentFlags; p != m_contentFlags + 32; ++p )
                {
-                       toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) );
+                       toggle_button_set_active_no_signal( ui::CheckButton( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) );
                }
        }
 }