From 4ddbcc542b23dab8672e9b376e5c3ec0cbd2490b Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 17 Feb 2016 16:09:07 +1100 Subject: [PATCH] Wrap GtkAccelGroup --- libs/gtkutil/accelerator.cpp | 3 ++- libs/gtkutil/messagebox.cpp | 2 +- libs/uilib/uilib.cpp | 3 +++ libs/uilib/uilib.h | 8 +++++++- radiant/commands.cpp | 2 +- radiant/gtkdlgs.cpp | 10 +++++----- radiant/map.cpp | 2 +- radiant/patchmanip.cpp | 4 ++-- radiant/select.cpp | 4 ++-- 9 files changed, 24 insertions(+), 14 deletions(-) diff --git a/libs/gtkutil/accelerator.cpp b/libs/gtkutil/accelerator.cpp index bba9ebe3..3b9924f9 100644 --- a/libs/gtkutil/accelerator.cpp +++ b/libs/gtkutil/accelerator.cpp @@ -327,6 +327,7 @@ PressedButtons g_pressedButtons; #include +#include struct PressedKeys { @@ -484,7 +485,7 @@ void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerat GtkAccelGroup* global_accel = 0; void global_accel_init(){ - global_accel = gtk_accel_group_new(); + global_accel = ui::AccelGroup(); } void global_accel_destroy(){ diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index b3d17a24..d07deddc 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -75,7 +75,7 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha gtk_window_deiconify( parentWindow ); } - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); GtkVBox* vbox = create_dialog_vbox( 8, 8 ); diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 21a603d5..79d3848b 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -84,6 +84,9 @@ namespace ui { return g_signal_connect(G_OBJECT(*this), "key-press-event", (GCallback) +func, &pass); } + AccelGroup::AccelGroup() : AccelGroup(GTK_ACCEL_GROUP(gtk_accel_group_new())) + { } + Adjustment::Adjustment(double value, double lower, double upper, double step_increment, double page_increment, diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index d42428a0..f0eb3b1f 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -3,6 +3,7 @@ #include +using ui_accelgroup = struct _GtkAccelGroup; using ui_adjustment = struct _GtkAdjustment; using ui_alignment = struct _GtkAlignment; using ui_box = struct _GtkBox; @@ -74,6 +75,7 @@ namespace ui { class Object : public Convertible { public: + using native = ui_object; void *_handle; Object(void *h) : _handle(h) @@ -118,6 +120,10 @@ namespace ui { }; \ static_assert(sizeof(name) == sizeof(super), "object slicing") + WRAP(AccelGroup, Object, ui_accelgroup, + AccelGroup(); + ); + WRAP(Adjustment, Widget, ui_adjustment, Adjustment(double value, double lower, double upper, @@ -136,7 +142,7 @@ namespace ui { Button(const char *label); ); - WRAP(CellRenderer, Widget, ui_cellrenderer,); + WRAP(CellRenderer, Object, ui_cellrenderer,); WRAP(CellRendererText, CellRenderer, ui_cellrenderertext, CellRendererText(); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index eaf4a15f..b220e3b5 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -393,7 +393,7 @@ void DoCommandListDlg(){ return accelerator_window_key_press(widget, event, dialogptr); }, &dialog); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); GtkHBox* hbox = create_dialog_hbox( 4, 4 ); diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index bfffe8f4..91cb00c4 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -386,7 +386,7 @@ void DoSides( int type, int axis ){ ui::Window window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); { @@ -604,7 +604,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); { @@ -865,7 +865,7 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Light intensity", dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); + GtkAccelGroup *accel_group = ui::AccelGroup(); gtk_window_add_accel_group( window, accel_group ); { @@ -932,7 +932,7 @@ EMessageBoxReturn DoShaderTagDlg( std::string* tag, const char* title ){ ui::Window window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); + GtkAccelGroup *accel_group = ui::AccelGroup(); gtk_window_add_accel_group( window, accel_group ); { @@ -991,7 +991,7 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const ui::Window window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); + GtkAccelGroup *accel_group = ui::AccelGroup(); gtk_window_add_accel_group( window, accel_group ); { diff --git a/radiant/map.cpp b/radiant/map.cpp index a035726b..10b60754 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -2007,7 +2007,7 @@ void DoFind(){ ui::Window window = MainFrame_getWindow().create_dialog_window("Find Brush", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); { diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 1bc56c21..f4e9c17d 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -853,7 +853,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( window, accel ); { @@ -980,7 +980,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ ui::Window window = MainFrame_getWindow().create_modal_dialog_window( "Cap", dialog ); - GtkAccelGroup *accel_group = gtk_accel_group_new(); + GtkAccelGroup *accel_group = ui::AccelGroup(); gtk_window_add_accel_group( window, accel_group ); { diff --git a/radiant/select.cpp b/radiant/select.cpp index e8f1db1d..fa04701e 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -914,7 +914,7 @@ void DoRotateDlg(){ if ( !g_rotate_dialog.window ) { g_rotate_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary rotation", G_CALLBACK(rotatedlg_delete ), &g_rotate_dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( g_rotate_dialog.window, accel ); { @@ -1067,7 +1067,7 @@ void DoScaleDlg(){ if ( !g_scale_dialog.window ) { g_scale_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary scale", G_CALLBACK(scaledlg_delete ), &g_scale_dialog ); - GtkAccelGroup* accel = gtk_accel_group_new(); + GtkAccelGroup* accel = ui::AccelGroup(); gtk_window_add_accel_group( g_scale_dialog.window, accel ); { -- 2.39.2