]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Remove <gtk/gtk.h> from gtkutil/window.h
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 22 Jul 2017 07:11:44 +0000 (17:11 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 31 Jul 2017 12:35:48 +0000 (22:35 +1000)
12 files changed:
libs/gtkutil/window.cpp
libs/gtkutil/window.h
libs/uilib/uilib.h
radiant/build.cpp
radiant/commands.cpp
radiant/console.cpp
radiant/entitylist.cpp
radiant/groupdialog.cpp
radiant/gtkdlgs.cpp
radiant/map.cpp
radiant/plugintoolbar.cpp
radiant/select.cpp

index 05f50e821720f781e0aae91a2cbff87c6ca80e10..7770821695f3eb76a6bae48076d95f4aa72ed8c6 100644 (file)
@@ -22,7 +22,6 @@
 #include "window.h"
 
 #include <gtk/gtk.h>
-#include <uilib/uilib.h>
 
 #include "pointer.h"
 #include "accelerator.h"
@@ -137,11 +136,102 @@ void window_remove_minmax( ui::Window window ){
 }
 
 
-ui::ScrolledWindow create_scrolled_window( GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, int border ){
+ui::ScrolledWindow create_scrolled_window( ui::Policy hscrollbar_policy, ui::Policy vscrollbar_policy, int border ){
        auto scr = ui::ScrolledWindow();
        gtk_widget_show( GTK_WIDGET( scr ) );
-       gtk_scrolled_window_set_policy( scr, hscrollbar_policy, vscrollbar_policy );
+       gtk_scrolled_window_set_policy( scr, (GtkPolicyType) hscrollbar_policy, (GtkPolicyType) vscrollbar_policy );
        gtk_scrolled_window_set_shadow_type( scr, GTK_SHADOW_IN );
        gtk_container_set_border_width( GTK_CONTAINER( scr ), border );
        return scr;
 }
+
+gboolean window_focus_in_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data)
+{
+    gtk_window_set_focus( GTK_WINDOW( widget ), NULL );
+    return FALSE;
+}
+
+guint window_connect_focus_in_clear_focus_widget(ui::Window window)
+{
+       return g_signal_connect( G_OBJECT( window ), "focus_in_event", G_CALLBACK( window_focus_in_clear_focus_widget ), NULL );
+}
+
+void window_get_position(ui::Window window, WindowPosition &position)
+{
+       ASSERT_MESSAGE( window , "error saving window position" );
+
+       gtk_window_get_position( window, &position.x, &position.y );
+       gtk_window_get_size( window, &position.w, &position.h );
+}
+
+void window_set_position(ui::Window window, const WindowPosition &position)
+{
+       gtk_window_set_gravity( window, GDK_GRAVITY_STATIC );
+
+       GdkScreen* screen = gdk_screen_get_default();
+       if ( position.x < 0
+                || position.y < 0
+                || position.x > gdk_screen_get_width( screen )
+                || position.y > gdk_screen_get_height( screen ) ) {
+               gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT );
+       }
+       else
+       {
+               gtk_window_move( window, position.x, position.y );
+       }
+
+       gtk_window_set_default_size( window, position.w, position.h );
+}
+
+void WindowPosition_Parse(WindowPosition &position, const char *value)
+{
+       if ( sscanf( value, "%d %d %d %d", &position.x, &position.y, &position.w, &position.h ) != 4 ) {
+               position = WindowPosition( c_default_window_pos ); // ensure sane default value for window position
+       }
+}
+
+void WindowPosition_Write(const WindowPosition &position, const StringImportCallback &importCallback)
+{
+       char buffer[64];
+       sprintf( buffer, "%d %d %d %d", position.x, position.y, position.w, position.h );
+       importCallback( buffer );
+}
+
+void WindowPositionTracker_importString(WindowPositionTracker &self, const char *value)
+{
+       WindowPosition position;
+       WindowPosition_Parse( position, value );
+       self.setPosition( position );
+}
+
+void WindowPositionTracker_exportString(const WindowPositionTracker &self, const StringImportCallback &importer)
+{
+       WindowPosition_Write( self.getPosition(), importer );
+}
+
+gboolean WindowPositionTracker::configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self)
+{
+       self->m_position = WindowPosition( event->x, event->y, event->width, event->height );
+       return FALSE;
+}
+
+void WindowPositionTracker::sync(ui::Window window)
+{
+       window_set_position( window, m_position );
+}
+
+void WindowPositionTracker::connect(ui::Window window)
+{
+       sync( window );
+       g_signal_connect( G_OBJECT( window ), "configure_event", G_CALLBACK( configure ), this );
+}
+
+const WindowPosition &WindowPositionTracker::getPosition() const
+{
+       return m_position;
+}
+
+void WindowPositionTracker::setPosition(const WindowPosition &position)
+{
+       m_position = position;
+}
index 3516857f9215d32a6ef7a85eddd6615a46c8232a..2adc3cafd5101106c3ac505c708dba352a829f0f 100644 (file)
 #if !defined( INCLUDED_GTKUTIL_WINDOW_H )
 #define INCLUDED_GTKUTIL_WINDOW_H
 
-#include <gtk/gtk.h>
 #include <uilib/uilib.h>
 
 #include "debugging/debugging.h"
 #include "generic/callback.h"
 #include "widget.h"
 
-inline gboolean window_focus_in_clear_focus_widget( ui::Widget widget, GdkEventKey* event, gpointer data ){
-       gtk_window_set_focus( GTK_WINDOW( widget ), NULL );
-       return FALSE;
-}
+gboolean window_focus_in_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data);
 
-inline guint window_connect_focus_in_clear_focus_widget( ui::Window window ){
-       return g_signal_connect( G_OBJECT( window ), "focus_in_event", G_CALLBACK( window_focus_in_clear_focus_widget ), NULL );
-}
+guint window_connect_focus_in_clear_focus_widget(ui::Window window);
 
+unsigned int connect_floating(ui::Window main_window, ui::Window floating);
 
-unsigned int connect_floating( ui::Window main_window, ui::Window floating );
-ui::Window create_floating_window( const char* title, ui::Window parent );
-void destroy_floating_window( ui::Window window );
+ui::Window create_floating_window(const char *title, ui::Window parent);
 
-ui::Window create_persistent_floating_window( const char* title, ui::Window main_window );
-gboolean persistent_floating_window_delete( ui::Window floating, GdkEvent *event, ui::Window main_window );
+void destroy_floating_window(ui::Window window);
 
-void window_remove_minmax( ui::Window window );
+ui::Window create_persistent_floating_window(const char *title, ui::Window main_window);
 
-ui::ScrolledWindow create_scrolled_window( GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, int border = 0 );
+gboolean persistent_floating_window_delete(ui::Window floating, GdkEvent *event, ui::Window main_window);
 
+void window_remove_minmax(ui::Window window);
 
-struct WindowPosition
-{
-       int x, y, w, h;
+ui::ScrolledWindow create_scrolled_window(ui::Policy hscrollbar_policy, ui::Policy vscrollbar_policy, int border = 0);
 
-       WindowPosition(){
-       }
-       WindowPosition( int _x, int _y, int _w, int _h )
-               : x( _x ), y( _y ), w( _w ), h( _h ){
-       }
-};
 
-const WindowPosition c_default_window_pos( 50, 25, 400, 300 );
+struct WindowPosition {
+    int x, y, w, h;
+
+    WindowPosition()
+    {
+    }
 
-inline void window_get_position( ui::Window window, WindowPosition& position ){
-       ASSERT_MESSAGE( window , "error saving window position" );
+    WindowPosition(int _x, int _y, int _w, int _h)
+            : x(_x), y(_y), w(_w), h(_h)
+    {
+    }
+};
 
-       gtk_window_get_position( window, &position.x, &position.y );
-       gtk_window_get_size( window, &position.w, &position.h );
-}
+const WindowPosition c_default_window_pos(50, 25, 400, 300);
 
-inline void window_set_position( ui::Window window, const WindowPosition& position ){
-       gtk_window_set_gravity( window, GDK_GRAVITY_STATIC );
+void window_get_position(ui::Window window, WindowPosition &position);
 
-       GdkScreen* screen = gdk_screen_get_default();
-       if ( position.x < 0
-                || position.y < 0
-                || position.x > gdk_screen_get_width( screen )
-                || position.y > gdk_screen_get_height( screen ) ) {
-               gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT );
-       }
-       else
-       {
-               gtk_window_move( window, position.x, position.y );
-       }
+void window_set_position(ui::Window window, const WindowPosition &position);
 
-       gtk_window_set_default_size( window, position.w, position.h );
-}
+void WindowPosition_Parse(WindowPosition &position, const char *value);
 
-inline void WindowPosition_Parse( WindowPosition& position, const char* value ){
-       if ( sscanf( value, "%d %d %d %d", &position.x, &position.y, &position.w, &position.h ) != 4 ) {
-               position = WindowPosition( c_default_window_pos ); // ensure sane default value for window position
-       }
-}
-typedef ReferenceCaller1<WindowPosition, const char*, WindowPosition_Parse> WindowPositionImportStringCaller;
+typedef ReferenceCaller1<WindowPosition, const char *, WindowPosition_Parse> WindowPositionImportStringCaller;
 
-inline void WindowPosition_Write( const WindowPosition& position, const StringImportCallback& importCallback ){
-       char buffer[64];
-       sprintf( buffer, "%d %d %d %d", position.x, position.y, position.w, position.h );
-       importCallback( buffer );
-}
-typedef ConstReferenceCaller1<WindowPosition, const StringImportCallback&, WindowPosition_Write> WindowPositionExportStringCaller;
+void WindowPosition_Write(const WindowPosition &position, const StringImportCallback &importCallback);
 
+typedef ConstReferenceCaller1<WindowPosition, const StringImportCallback &, WindowPosition_Write> WindowPositionExportStringCaller;
 
 
-class WindowPositionTracker
-{
-WindowPosition m_position;
+class WindowPositionTracker {
+    WindowPosition m_position;
 
-static gboolean configure( ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker* self ){
-       self->m_position = WindowPosition( event->x, event->y, event->width, event->height );
-       return FALSE;
-}
+    static gboolean configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self);
 
 public:
-WindowPositionTracker()
-       : m_position( c_default_window_pos ){
-}
+    WindowPositionTracker()
+            : m_position(c_default_window_pos)
+    {
+    }
 
-void sync( ui::Window window ){
-       window_set_position( window, m_position );
-}
+    void sync(ui::Window window);
 
-void connect( ui::Window window ){
-       sync( window );
-       g_signal_connect( G_OBJECT( window ), "configure_event", G_CALLBACK( configure ), this );
-}
+    void connect(ui::Window window);
 
-const WindowPosition& getPosition() const {
-       return m_position;
-}
+    const WindowPosition &getPosition() const;
 
 //hack
-void setPosition( const WindowPosition& position ){
-       m_position = position;
-}
+    void setPosition(const WindowPosition &position);
 };
 
 
-inline void WindowPositionTracker_importString( WindowPositionTracker& self, const char* value ){
-       WindowPosition position;
-       WindowPosition_Parse( position, value );
-       self.setPosition( position );
-}
-typedef ReferenceCaller1<WindowPositionTracker, const char*, WindowPositionTracker_importString> WindowPositionTrackerImportStringCaller;
+void WindowPositionTracker_importString(WindowPositionTracker &self, const char *value);
+
+typedef ReferenceCaller1<WindowPositionTracker, const char *, WindowPositionTracker_importString> WindowPositionTrackerImportStringCaller;
 
-inline void WindowPositionTracker_exportString( const WindowPositionTracker& self, const StringImportCallback& importer ){
-       WindowPosition_Write( self.getPosition(), importer );
-}
-typedef ConstReferenceCaller1<WindowPositionTracker, const StringImportCallback&, WindowPositionTracker_exportString> WindowPositionTrackerExportStringCaller;
+void WindowPositionTracker_exportString(const WindowPositionTracker &self, const StringImportCallback &importer);
 
+typedef ConstReferenceCaller1<WindowPositionTracker, const StringImportCallback &, WindowPositionTracker_exportString> WindowPositionTrackerExportStringCaller;
 
 
 #endif
index b9588dee282aff0169971b837efc59e15770be0f..3fca43c7c557f411879b4dab7b2dd4f18206680f 100644 (file)
@@ -110,6 +110,12 @@ namespace ui {
         ETCHED_OUT
     };
 
+    enum class Policy {
+        ALWAYS,
+        AUTOMATIC,
+        NEVER
+    };
+
     namespace details {
 
         enum class Convert {
index 830bf2f025f2fe3306d3c3efb27c36d6949ff52c..7d9d630002f0249760481f76630d0870c9b0849c 100644 (file)
@@ -22,6 +22,7 @@
 #include "build.h"
 #include "debugging/debugging.h"
 
+#include <gtk/gtk.h>
 #include <map>
 #include <list>
 #include "stream/stringstream.h"
@@ -864,7 +865,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi
                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
                        {
-                               auto scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 );
+                               auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
                                frame.add(scr);
 
                                {
@@ -901,7 +902,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi
                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                          (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
                        {
-                               auto scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 );
+                               auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
                                frame.add(scr);
 
                                {
index 5d2cadafb3f7c9e77b3cd56818c02425894e8c39..b3def079e8642c4fee4c78b840d33b47d869a9f0 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "commands.h"
 
+#include "gtk/gtk.h"
 #include "debugging/debugging.h"
 #include "warnings.h"
 
@@ -398,7 +399,7 @@ void DoCommandListDlg(){
        window.add(hbox);
 
        {
-               auto scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
+               auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC );
                gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 );
 
                {
index f7bdc929c233b7eb2b924354f3b2627ceeee6681..1f31fb3d94465556cd013c847a7b9a4dbceb8291 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <time.h>
 #include <uilib/uilib.h>
+#include <gtk/gtk.h>
 
 #include "gtkutil/accelerator.h"
 #include "gtkutil/messagebox.h"
index f8847255c51b8ba1063645981059a805a82cabd1..e3d176a0597588c12cf5d41d9307bbf82ea7d907 100644 (file)
@@ -24,6 +24,7 @@
 #include "iselection.h"
 
 #include <uilib/uilib.h>
+#include <gtk/gtk.h>
 
 #include "string/string.h"
 #include "scenelib.h"
@@ -291,7 +292,7 @@ void EntityList_constructWindow( ui::Window main_window ){
        getEntityList().m_window = window;
 
        {
-               auto scr = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+               auto scr = create_scrolled_window( ui::Policy::AUTOMATIC, ui::Policy::AUTOMATIC );
                window.add(scr);
 
                {
index 2158f59a5a3b3a7b15feaacd8f246c89b30f9328..1e076c1a1e05b3da521c9649d550585227b380c0 100644 (file)
@@ -31,6 +31,7 @@
 #include "debugging/debugging.h"
 
 #include <vector>
+#include <gtk/gtk.h>
 
 #include "gtkutil/widget.h"
 #include "gtkutil/accelerator.h"
index caf74cb83cc4f160a722dae3b1f0ee169c832ccb..3ad56a8b88775621b33a6bdf30b6ffdab745c05c 100644 (file)
@@ -561,7 +561,7 @@ void DoAbout(){
                                auto frame = create_dialog_frame( "OpenGL Extensions" );
                                gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
                                {
-                                       auto sc_extensions = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS, 4 );
+                                       auto sc_extensions = create_scrolled_window( ui::Policy::AUTOMATIC, ui::Policy::ALWAYS, 4 );
                                        frame.add(sc_extensions);
                                        {
                                                auto text_extensions = ui::TextView();
index fa54737a59f68b0943079a32e70890970e64b94d..518886f690e9bf7f6cdb05dfb5cc6df95d29fa16 100644 (file)
@@ -835,7 +835,7 @@ void DoMapInfo(){
                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                }
                {
-                       auto scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 );
+                       auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
                        gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 );
 
                        {
index ac79b10188dbbbd4ff7133a69d1730c885a0e758..5753e76b76acd3c36d030742a943c1a92c60d531 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "plugintoolbar.h"
 
+#include <gtk/gtk.h>
 
 #include "itoolbar.h"
 #include "modulesystem.h"
index 0ac4467deb5e18784737dda335b8c4953f84e11b..0f2fae1c3709e317051bc185d71277e95de65aff 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "select.h"
 
+#include <gtk/gtk.h>
+
 #include "debugging/debugging.h"
 
 #include "ientity.h"