From 4ebf4de56410776f8aa2b1e47ff71d40c57af629 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 22 Jul 2017 12:37:10 +1000 Subject: [PATCH] Purge GTK forward declarations --- contrib/bobtoolz/dialogs/dialogs-gtk.h | 2 -- contrib/brushexport/callbacks.h | 2 -- include/igtkgl.h | 12 +++++------ include/qerplugin.h | 1 - libs/gtkutil/accelerator.cpp | 2 +- libs/gtkutil/accelerator.h | 4 +--- libs/gtkutil/glwidget.cpp | 28 +++++++++++++------------- libs/gtkutil/glwidget.h | 13 ++++++------ libs/uilib/uilib.cpp | 7 +++++++ libs/uilib/uilib.h | 2 ++ radiant/build.cpp | 2 -- radiant/camwindow.h | 1 - radiant/dialog.h | 6 ------ radiant/entitylist.cpp | 1 - radiant/feedback.h | 1 - radiant/gtkmisc.cpp | 8 ++++---- radiant/gtkmisc.h | 24 ++++------------------ radiant/mainframe.cpp | 6 +++--- radiant/mainframe.h | 1 - radiant/patchdialog.cpp | 1 - radiant/pluginmenu.cpp | 4 ++-- radiant/pluginmenu.h | 7 +++---- radiant/texwindow.cpp | 2 +- radiant/xywindow.h | 1 - 24 files changed, 55 insertions(+), 83 deletions(-) diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.h b/contrib/bobtoolz/dialogs/dialogs-gtk.h index 75db2d18..fe374309 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.h +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.h @@ -91,8 +91,6 @@ struct MakeChainRS { int linkNum; }; -typedef struct _GtkWidget GtkWidget; - struct TwinWidget { GtkWidget* one; GtkComboBox* two; diff --git a/contrib/brushexport/callbacks.h b/contrib/brushexport/callbacks.h index eea5aa8b..eece65a1 100644 --- a/contrib/brushexport/callbacks.h +++ b/contrib/brushexport/callbacks.h @@ -1,5 +1,3 @@ -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkButton GtkButton; namespace callbacks { diff --git a/include/igtkgl.h b/include/igtkgl.h index e6e85254..a78a0570 100644 --- a/include/igtkgl.h +++ b/include/igtkgl.h @@ -22,9 +22,9 @@ #if !defined( INCLUDED_IGTKGL_H ) #define INCLUDED_IGTKGL_H +#include #include "generic/constant.h" -typedef struct _GtkWidget GtkWidget; typedef int gint; typedef gint gboolean; @@ -33,11 +33,11 @@ struct _QERGtkGLTable INTEGER_CONSTANT( Version, 1 ); STRING_CONSTANT( Name, "gtkgl" ); - GtkWidget* ( *glwidget_new )(gboolean zbufffer); - void ( *glwidget_swap_buffers )( GtkWidget* widget ); - gboolean ( *glwidget_make_current )( GtkWidget* widget ); - void ( *glwidget_destroy_context )( GtkWidget* widget ); - void ( *glwidget_create_context )( GtkWidget* widget ); + ui::Widget ( *glwidget_new )(gboolean zbufffer); + void ( *glwidget_swap_buffers )( ui::Widget widget ); + gboolean ( *glwidget_make_current )( ui::Widget widget ); + void ( *glwidget_destroy_context )( ui::Widget widget ); + void ( *glwidget_create_context )( ui::Widget widget ); }; #endif diff --git a/include/qerplugin.h b/include/qerplugin.h index 4adefa36..8e56da9c 100644 --- a/include/qerplugin.h +++ b/include/qerplugin.h @@ -85,7 +85,6 @@ typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Widget parent, Vector3& color, // load a .bmp file and create a GtkImage widget from it // NOTE: 'filename' is relative to /plugins/bitmaps/ -typedef struct _GtkImage GtkImage; typedef ui::Image ( *PFN_QERAPP_NEWIMAGE )( const char* filename ); // ======================================== diff --git a/libs/gtkutil/accelerator.cpp b/libs/gtkutil/accelerator.cpp index 09cc7aa1..59ec317c 100644 --- a/libs/gtkutil/accelerator.cpp +++ b/libs/gtkutil/accelerator.cpp @@ -303,7 +303,7 @@ gboolean PressedButtons_focus_out( GtkWidget* widget, GdkEventFocus* event, Pres return FALSE; } -void PressedButtons_connect( PressedButtons& pressedButtons, GtkWidget* widget ){ +void PressedButtons_connect( PressedButtons& pressedButtons, ui::Widget widget ){ g_signal_connect( G_OBJECT( widget ), "button_press_event", G_CALLBACK( PressedButtons_button_press ), &pressedButtons ); g_signal_connect( G_OBJECT( widget ), "button_release_event", G_CALLBACK( PressedButtons_button_release ), &pressedButtons ); g_signal_connect( G_OBJECT( widget ), "focus_out_event", G_CALLBACK( PressedButtons_focus_out ), &pressedButtons ); diff --git a/libs/gtkutil/accelerator.h b/libs/gtkutil/accelerator.h index 0a47ba49..821830f4 100644 --- a/libs/gtkutil/accelerator.h +++ b/libs/gtkutil/accelerator.h @@ -85,7 +85,6 @@ void keydown_accelerators_remove( Accelerator accelerator ); void keyup_accelerators_add( Accelerator accelerator, const Callback& callback ); void keyup_accelerators_remove( Accelerator accelerator ); -typedef struct _GtkWidget GtkWidget; void global_accel_connect_window( ui::Window window ); void global_accel_disconnect_window( ui::Window window ); @@ -130,8 +129,7 @@ KeyEvent( const Accelerator& accelerator, const Callback& keyDown, const Callbac struct PressedButtons; -typedef struct _GtkWidget GtkWidget; -void PressedButtons_connect( PressedButtons& pressedButtons, GtkWidget* widget ); +void PressedButtons_connect( PressedButtons& pressedButtons, ui::Widget widget ); extern PressedButtons g_pressedButtons; diff --git a/libs/gtkutil/glwidget.cpp b/libs/gtkutil/glwidget.cpp index 3f9b9a00..8661e4ef 100644 --- a/libs/gtkutil/glwidget.cpp +++ b/libs/gtkutil/glwidget.cpp @@ -181,10 +181,10 @@ unsigned int g_context_count = 0; namespace { -GtkWidget* g_shared = 0; + ui::Widget g_shared; } -gint glwidget_context_created( GtkWidget* widget, gpointer data ){ +gint glwidget_context_created( ui::Widget widget, gpointer data ){ if ( ++g_context_count == 1 ) { g_shared = widget; g_object_ref( g_shared ); @@ -197,27 +197,27 @@ gint glwidget_context_created( GtkWidget* widget, gpointer data ){ return FALSE; } -gint glwidget_context_destroyed( GtkWidget* widget, gpointer data ){ +gint glwidget_context_destroyed( ui::Widget widget, gpointer data ){ if ( --g_context_count == 0 ) { GlobalOpenGL().contextValid = false; GLWidget_sharedContextDestroyed(); g_object_unref( g_shared ); - g_shared = 0; + g_shared = ui::Widget(nullptr); } return FALSE; } -gboolean glwidget_enable_gl( GtkWidget* widget, GtkWidget* widget2, gpointer data ){ - if ( widget2 == 0 && !gtk_widget_is_gl_capable( widget ) ) { +gboolean glwidget_enable_gl( ui::Widget widget, ui::Widget widget2, gpointer data ){ + if ( !widget2 && !gtk_widget_is_gl_capable( widget ) ) { GdkGLConfig* glconfig = ( g_object_get_data( G_OBJECT( widget ), "zbuffer" ) ) ? glconfig_new_with_depth() : glconfig_new(); ASSERT_MESSAGE( glconfig != 0, "failed to create OpenGL config" ); - gtk_widget_set_gl_capability( widget, glconfig, g_shared != 0 ? gtk_widget_get_gl_context( g_shared ) : 0, TRUE, GDK_GL_RGBA_TYPE ); + gtk_widget_set_gl_capability( widget, glconfig, g_shared ? gtk_widget_get_gl_context( g_shared ) : 0, TRUE, GDK_GL_RGBA_TYPE ); gtk_widget_realize( widget ); - if ( g_shared == 0 ) { + if ( !g_shared ) { g_shared = widget; } @@ -226,8 +226,8 @@ gboolean glwidget_enable_gl( GtkWidget* widget, GtkWidget* widget2, gpointer dat return FALSE; } -GtkWidget* glwidget_new( gboolean zbuffer ){ - GtkWidget* widget = gtk_drawing_area_new(); +ui::Widget glwidget_new( gboolean zbuffer ){ + auto widget = ui::Widget(gtk_drawing_area_new()); g_object_set_data( G_OBJECT( widget ), "zbuffer", gint_to_pointer( zbuffer ) ); @@ -239,18 +239,18 @@ GtkWidget* glwidget_new( gboolean zbuffer ){ return widget; } -void glwidget_destroy_context( GtkWidget *widget ){ +void glwidget_destroy_context( ui::Widget widget ){ } -void glwidget_create_context( GtkWidget *widget ){ +void glwidget_create_context( ui::Widget widget ){ } -void glwidget_swap_buffers( GtkWidget *widget ){ +void glwidget_swap_buffers( ui::Widget widget ){ GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable( widget ); gdk_gl_drawable_swap_buffers( gldrawable ); } -gboolean glwidget_make_current( GtkWidget *widget ){ +gboolean glwidget_make_current( ui::Widget widget ){ GdkGLContext *glcontext = gtk_widget_get_gl_context( widget ); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable( widget ); return gdk_gl_drawable_gl_begin( gldrawable, glcontext ); diff --git a/libs/gtkutil/glwidget.h b/libs/gtkutil/glwidget.h index 43e26dc7..3da07c3d 100644 --- a/libs/gtkutil/glwidget.h +++ b/libs/gtkutil/glwidget.h @@ -19,18 +19,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_GTKUTIL_GLWIDGET_H ) #define INCLUDED_GTKUTIL_GLWIDGET_H -typedef struct _GtkWidget GtkWidget; typedef int gint; typedef gint gboolean; -GtkWidget* glwidget_new( gboolean zbuffer ); -void glwidget_swap_buffers( GtkWidget* widget ); -gboolean glwidget_make_current( GtkWidget* widget ); -void glwidget_destroy_context( GtkWidget* widget ); -void glwidget_create_context( GtkWidget* widget ); +ui::Widget glwidget_new( gboolean zbuffer ); +void glwidget_swap_buffers( ui::Widget widget ); +gboolean glwidget_make_current( ui::Widget widget ); +void glwidget_destroy_context( ui::Widget widget ); +void glwidget_create_context( ui::Widget widget ); extern void ( *GLWidget_sharedContextCreated )(); extern void ( *GLWidget_sharedContextDestroyed )(); diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 1e37a1e0..e91f03fe 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -22,6 +22,13 @@ namespace ui { gtk_main(); } + void process() + { + while (gtk_events_pending()) { + gtk_main_iteration(); + } + } + Widget root{nullptr}; #define IMPL(T, F) template<> _IMPL(T, F) diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 2b18ffb2..f5b6e180 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -69,6 +69,8 @@ namespace ui { void main(); + void process(); + extern class Widget root; enum class alert_type { diff --git a/radiant/build.cpp b/radiant/build.cpp index 8fd89912..24dc28e9 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -973,8 +973,6 @@ void DoBuildMenu(){ #include "preferences.h" #include "qe3.h" -typedef struct _GtkMenuItem GtkMenuItem; - class BuildMenuItem { const char* m_name; diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 7f802970..312cf66d 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -40,7 +40,6 @@ void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ); void GlobalCamera_setCamWnd( CamWnd& camwnd ); void fill_view_camera_menu( ui::Menu menu ); -typedef struct _GtkToolbar GtkToolbar; void CamWnd_constructToolbar( ui::Toolbar toolbar ); void CamWnd_registerShortcuts(); diff --git a/radiant/dialog.h b/radiant/dialog.h index 85b2d8a9..d202f83a 100644 --- a/radiant/dialog.h +++ b/radiant/dialog.h @@ -93,12 +93,6 @@ struct DLG_DATA virtual void exportData() const = 0; }; -typedef struct _GtkToggleButton GtkToggleButton; -typedef struct _GtkRadioButton GtkRadioButton; -typedef struct _GtkSpinButton GtkSpinButton; -typedef struct _GtkComboBox GtkComboBox; -typedef struct _GtkEntry GtkEntry; -typedef struct _GtkAdjustment GtkAdjustment; template class CallbackDialogData; diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 0e97b609..efdc9ca0 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -42,7 +42,6 @@ void RedrawEntityList(); typedef FreeCaller RedrawEntityListCaller; -typedef struct _GtkTreeView GtkTreeView; class EntityList { diff --git a/radiant/feedback.h b/radiant/feedback.h index 567f00af..42fdbbb3 100644 --- a/radiant/feedback.h +++ b/radiant/feedback.h @@ -143,7 +143,6 @@ void DecRef() { void Draw2D( VIEWTYPE vt ); }; -typedef struct _GtkListStore GtkListStore; class CDbgDlg : public Dialog { diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 39b24243..2c4175c7 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -71,14 +71,14 @@ void toggle_remove_accelerator( const char* name ){ global_accel_group_disconnect( toggle.m_command.m_accelerator, toggle.m_command.m_callback ); } -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ){ +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ){ GlobalShortcuts_register( commandName, 2 ); const Toggle& toggle = GlobalToggles_find( commandName ); global_accel_group_connect( toggle.m_command.m_accelerator, toggle.m_command.m_callback ); return create_check_menu_item_with_mnemonic( menu, mnemonic, toggle ); } -GtkMenuItem* create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ){ +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ){ GlobalShortcuts_register( commandName, 1 ); const Command& command = GlobalCommands_find( commandName ); global_accel_group_connect( command.m_accelerator, command.m_callback ); @@ -126,7 +126,7 @@ bool color_dialog( ui::Widget parent, Vector3& color, const char* title ){ return ok; } -void button_clicked_entry_browse_file( ui::Widget widget, GtkEntry* entry ){ +void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ){ const char *filename = ui::Widget(gtk_widget_get_toplevel( widget )).file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) ); if ( filename != 0 ) { @@ -134,7 +134,7 @@ void button_clicked_entry_browse_file( ui::Widget widget, GtkEntry* entry ){ } } -void button_clicked_entry_browse_directory( ui::Widget widget, GtkEntry* entry ){ +void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry ){ const char* text = gtk_entry_get_text( entry ); char *dir = dir_dialog( ui::Widget(gtk_widget_get_toplevel( widget )), "Choose Directory", path_is_absolute( text ) ? text : "" ); diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 1de1aa4a..ed6114ce 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -31,33 +31,18 @@ #if !defined( INCLUDED_GTKMISC_H ) #define INCLUDED_GTKMISC_H -#include #include -inline void process_gui(){ - while ( gtk_events_pending() ) - { - gtk_main_iteration(); - } -} - void command_connect_accelerator( const char* commandName ); void command_disconnect_accelerator( const char* commandName ); void toggle_add_accelerator( const char* commandName ); void toggle_remove_accelerator( const char* name ); -typedef struct _GtkMenu GtkMenu; -typedef struct _GtkMenuItem GtkMenuItem; -typedef struct _GtkCheckMenuItem GtkCheckMenuItem; - // this also sets up the shortcut using command_connect_accelerator -GtkMenuItem* create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ); +ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ); // this also sets up the shortcut using command_connect_accelerator -GtkCheckMenuItem* create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ); +ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ); -typedef struct _GtkButton GtkButton; -typedef struct _GtkToggleButton GtkToggleButton; -typedef struct _GtkToolbar GtkToolbar; // this DOES NOT set up the shortcut using command_connect_accelerator ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName ); @@ -69,8 +54,7 @@ template class BasicVector3; typedef BasicVector3 Vector3; bool color_dialog( ui::Widget parent, Vector3& color, const char* title = "Choose Color" ); -typedef struct _GtkEntry GtkEntry; -void button_clicked_entry_browse_file( ui::Widget widget, GtkEntry* entry ); -void button_clicked_entry_browse_directory( ui::Widget widget, GtkEntry* entry ); +void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ); +void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry ); #endif diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index e9378d47..adf4797c 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -1683,7 +1683,7 @@ bool ScreenUpdates_Enabled(){ void ScreenUpdates_process(){ if ( redrawRequired() && gtk_widget_get_visible( g_wait.m_window ) ) { - process_gui(); + ui::process(); } } @@ -1692,7 +1692,7 @@ void ScreenUpdates_Disable( const char* message, const char* title ){ if ( g_wait_stack.empty() ) { EverySecondTimer_disable(); - process_gui(); + ui::process(); bool isActiveApp = MainFrame_isActiveApp(); @@ -2691,7 +2691,7 @@ static ui::Window splash_screen; void show_splash(){ splash_screen = create_splash(); - process_gui(); + ui::process(); } void hide_splash(){ diff --git a/radiant/mainframe.h b/radiant/mainframe.h index e370b01f..27d09c01 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -37,7 +37,6 @@ class XYWnd; class CamWnd; class ZWnd; -typedef struct _GtkWidget GtkWidget; const int c_command_status = 0; const int c_position_status = 1; diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 2c12c5bf..b3785496 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -151,7 +151,6 @@ void Scene_PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions Scene_forEachVisibleSelectedPatch( PatchSetFixedSubdivisions( subdivisions ) ); } -typedef struct _GtkCheckButton GtkCheckButton; class Subdivisions { diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index d3c1519d..b9dd5dc7 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -152,9 +152,9 @@ void PluginsMenu_clear(){ } } -GtkMenuItem* create_plugins_menu(){ +ui::MenuItem create_plugins_menu(){ // Plugins menu - GtkMenuItem* plugins_menu_item = new_sub_menu_item_with_mnemonic( "_Plugins" ); + auto plugins_menu_item = new_sub_menu_item_with_mnemonic( "_Plugins" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( plugins_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); diff --git a/radiant/pluginmenu.h b/radiant/pluginmenu.h index 254db777..b1685a61 100644 --- a/radiant/pluginmenu.h +++ b/radiant/pluginmenu.h @@ -19,14 +19,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #if !defined( INCLUDED_PLUGINMENU_H ) #define INCLUDED_PLUGINMENU_H -typedef struct _GtkMenuItem GtkMenuItem; -GtkMenuItem* create_plugins_menu(); +ui::MenuItem create_plugins_menu(); -typedef struct _GtkMenu GtkMenu; -typedef struct _GtkMenuItem GtkMenuItem; void PluginsMenu_populate(); void PluginsMenu_clear(); diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index d6b2b812..7a79eb05 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1366,7 +1366,7 @@ gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event, textureBrowser->m_heightChanged = true; textureBrowser->m_tag_frame.show(); - process_gui(); + ui::process(); TextureBrowser_Focus( *textureBrowser, textureBrowser->shader.c_str() ); } diff --git a/radiant/xywindow.h b/radiant/xywindow.h index d95e1c3b..3eefc11e 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -40,7 +40,6 @@ namespace scene { class Node; } -typedef struct _GtkMenu GtkMenu; void FlipClip(); -- 2.39.2