[gedit] app: use new G_DECLARE macros



commit 4b4e08ce0c142daa50b5581178c27e502a7d5256
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Apr 19 15:48:43 2015 +0200

    app: use new G_DECLARE macros

 gedit/gedit-app-osx.c   |   79 ++++-----
 gedit/gedit-app-osx.h   |   39 +----
 gedit/gedit-app-win32.c |    4 +
 gedit/gedit-app-win32.h |   26 +---
 gedit/gedit-app-x11.c   |    5 +
 gedit/gedit-app-x11.h   |   24 +---
 gedit/gedit-app.c       |  420 +++++++++++++++++++++++++++++------------------
 gedit/gedit-app.h       |   39 +----
 8 files changed, 328 insertions(+), 308 deletions(-)
---
diff --git a/gedit/gedit-app-osx.c b/gedit/gedit-app-osx.c
index cd26805..d7d4237 100644
--- a/gedit/gedit-app-osx.c
+++ b/gedit/gedit-app-osx.c
@@ -150,8 +150,10 @@ ensure_window (GeditAppOSX *app,
 
 @end
 
-struct _GeditAppOSXPrivate
+struct _GeditAppOSX
 {
+       GeditApp parent_instance;
+
        GeditMenuExtension *recent_files_menu;
        gulong recent_manager_changed_id;
 
@@ -161,40 +163,38 @@ struct _GeditAppOSXPrivate
        GeditRecentConfiguration recent_config;
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (GeditAppOSX, gedit_app_osx, GEDIT_TYPE_APP)
+G_DEFINE_TYPE (GeditAppOSX, gedit_app_osx, GEDIT_TYPE_APP)
 
 static void
 remove_recent_actions (GeditAppOSX *app)
 {
-       GeditAppOSXPrivate *priv = app->priv;
-
-       while (priv->recent_actions)
+       while (app->recent_actions)
        {
-               gchar *action_name = priv->recent_actions->data;
+               gchar *action_name = app->recent_actions->data;
 
                g_action_map_remove_action (G_ACTION_MAP (app), action_name);
                g_free (action_name);
 
-               priv->recent_actions = g_list_delete_link (priv->recent_actions, priv->recent_actions);
+               app->recent_actions = g_list_delete_link (app->recent_actions,
+                                                         app->recent_actions);
        }
 }
 
 static void
 gedit_app_osx_finalize (GObject *object)
 {
-       GeditAppOSX *app_osx;
+       GeditAppOSX *app = GEDIT_APP_OSX (object);
 
-       app_osx = GEDIT_APP_OSX (object);
-       g_object_unref (app_osx->priv->recent_files_menu);
+       g_object_unref (app->recent_files_menu);
 
-       remove_recent_actions (app_osx);
+       remove_recent_actions (app);
 
-       g_signal_handler_disconnect (app_osx->priv->recent_config.manager,
-                                    app_osx->priv->recent_manager_changed_id);
+       g_signal_handler_disconnect (app->recent_config.manager,
+                                    app->recent_manager_changed_id);
 
-       gedit_recent_configuration_destroy (&app_osx->priv->recent_config);
+       gedit_recent_configuration_destroy (&app->recent_config);
 
-       [app_osx->priv->app_delegate release];
+       [app->app_delegate release];
 
        G_OBJECT_CLASS (gedit_app_osx_parent_class)->finalize (object);
 }
@@ -330,15 +330,15 @@ recent_file_activated (GAction        *action,
 }
 
 static void
-recent_files_menu_populate (GeditAppOSX *app_osx)
+recent_files_menu_populate (GeditAppOSX *app)
 {
        GList *items;
        gint i = 0;
 
-       gedit_menu_extension_remove_items (app_osx->priv->recent_files_menu);
-       remove_recent_actions (app_osx);
+       gedit_menu_extension_remove_items (app->recent_files_menu);
+       remove_recent_actions (app);
 
-       items = gedit_recent_get_items (&app_osx->priv->recent_config);
+       items = gedit_recent_get_items (&app->recent_config);
 
        while (items)
        {
@@ -356,7 +356,7 @@ recent_files_menu_populate (GeditAppOSX *app_osx)
                action = g_simple_action_new (acname, NULL);
 
                finfo = g_slice_new (RecentFileInfo);
-               finfo->app = g_object_ref (app_osx);
+               finfo->app = g_object_ref (app);
                finfo->info = gtk_recent_info_ref (info);
 
                g_signal_connect_data (action,
@@ -366,16 +366,15 @@ recent_files_menu_populate (GeditAppOSX *app_osx)
                                       recent_file_info_free,
                                       0);
 
-               g_action_map_add_action (G_ACTION_MAP (app_osx), G_ACTION (action));
+               g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (action));
                g_object_unref (action);
 
                acfullname = g_strdup_printf ("app.%s", acname);
 
-               app_osx->priv->recent_actions = g_list_prepend (app_osx->priv->recent_actions,
-                                                               acname);
+               app->recent_actions = g_list_prepend (app->recent_actions, acname);
 
                mitem = g_menu_item_new (name, acfullname);
-               gedit_menu_extension_append_menu_item (app_osx->priv->recent_files_menu, mitem);
+               gedit_menu_extension_append_menu_item (app->recent_files_menu, mitem);
 
                g_free (acfullname);
 
@@ -388,9 +387,9 @@ recent_files_menu_populate (GeditAppOSX *app_osx)
 
 static void
 recent_manager_changed (GtkRecentManager *manager,
-                        GeditAppOSX      *app_osx)
+                        GeditAppOSX      *app)
 {
-       recent_files_menu_populate (app_osx);
+       recent_files_menu_populate (app);
 }
 
 static void
@@ -420,8 +419,6 @@ update_open_sensitivity (GeditAppOSX *app)
 static void
 gedit_app_osx_startup (GApplication *application)
 {
-       GeditAppOSX *app_osx;
-
        const gchar *replace_accels[] = {
                "<Primary><Alt>F",
                NULL
@@ -437,10 +434,11 @@ gedit_app_osx_startup (GApplication *application)
                NULL
        };
 
+       GeditAppOSX *app = GEDIT_APP_OSX (application);
+
        G_APPLICATION_CLASS (gedit_app_osx_parent_class)->startup (application);
 
-       app_osx = GEDIT_APP_OSX (application);
-       app_osx->priv->app_delegate = [[[GeditAppOSXDelegate alloc] initWithApp:app_osx] retain];
+       app->app_delegate = [[[GeditAppOSXDelegate alloc] initWithApp:app] retain];
 
        g_action_map_add_action_entries (G_ACTION_MAP (application),
                                         app_entries,
@@ -459,21 +457,20 @@ gedit_app_osx_startup (GApplication *application)
                                               "win.fullscreen",
                                               fullscreen_accels);
 
-       gedit_recent_configuration_init_default (&app_osx->priv->recent_config);
+       gedit_recent_configuration_init_default (&app->recent_config);
 
-       app_osx->priv->recent_files_menu = _gedit_app_extend_menu (GEDIT_APP (application),
-                                                                  "recent-files-section");
+       app->recent_files_menu = _gedit_app_extend_menu (GEDIT_APP (application),
+                                                        "recent-files-section");
 
-       app_osx->priv->recent_manager_changed_id =
-               g_signal_connect (app_osx->priv->recent_config.manager,
-                                 "changed",
-                                 G_CALLBACK (recent_manager_changed),
-                                 app_osx);
+       app->recent_manager_changed_id = g_signal_connect (app->recent_config.manager,
+                                                          "changed",
+                                                          G_CALLBACK (recent_manager_changed),
+                                                          app);
 
-       recent_files_menu_populate (app_osx);
+       recent_files_menu_populate (app);
 
        g_application_hold (application);
-       update_open_sensitivity (app_osx);
+       update_open_sensitivity (app);
 }
 
 static void
@@ -589,8 +586,6 @@ gedit_app_osx_class_init (GeditAppOSXClass *klass)
 static void
 gedit_app_osx_init (GeditAppOSX *app)
 {
-       app->priv = gedit_app_osx_get_instance_private (app);
-
        /* This is required so that Cocoa is not going to parse the
           command line arguments by itself and generate OpenFile events.
           We already parse the command line ourselves, so this is needed
diff --git a/gedit/gedit-app-osx.h b/gedit/gedit-app-osx.h
index e3ee89d..6a01311 100644
--- a/gedit/gedit-app-osx.h
+++ b/gedit/gedit-app-osx.h
@@ -27,40 +27,17 @@
 
 G_BEGIN_DECLS
 
-#define GEDIT_TYPE_APP_OSX             (gedit_app_osx_get_type ())
-#define GEDIT_APP_OSX(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_OSX, GeditAppOSX))
-#define GEDIT_APP_OSX_CONST(obj)       (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_OSX, GeditAppOSX 
const))
-#define GEDIT_APP_OSX_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_APP_OSX, 
GeditAppOSXClass))
-#define GEDIT_IS_APP_OSX(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_APP_OSX))
-#define GEDIT_IS_APP_OSX_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_APP_OSX))
-#define GEDIT_APP_OSX_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_APP_OSX, 
GeditAppOSXClass))
+#define GEDIT_TYPE_APP_OSX (gedit_app_osx_get_type ())
 
-typedef struct _GeditAppOSX            GeditAppOSX;
-typedef struct _GeditAppOSXClass       GeditAppOSXClass;
-typedef struct _GeditAppOSXPrivate     GeditAppOSXPrivate;
+G_DECLARE_FINAL_TYPE (GeditAppOSX, gedit_app_osx, GEDIT, APP_OSX, GeditApp)
 
-struct _GeditAppOSX
-{
-       GeditApp parent;
+void            gedit_app_osx_set_window_title         (GeditAppOSX   *app,
+                                                        GeditWindow   *window,
+                                                        const gchar   *title,
+                                                        GeditDocument *document);
 
-       /*< private > */
-       GeditAppOSXPrivate *priv;
-};
-
-struct _GeditAppOSXClass
-{
-       GeditAppClass parent_class;
-};
-
-GType           gedit_app_osx_get_type         (void) G_GNUC_CONST;
-
-void            gedit_app_osx_set_window_title (GeditAppOSX   *app,
-                                                GeditWindow   *window,
-                                                const gchar   *title,
-                                                GeditDocument *document);
-
-gboolean         gedit_app_osx_show_url         (GeditAppOSX *app,
-                                                 const gchar *url);
+gboolean        gedit_app_osx_show_url                 (GeditAppOSX *app,
+                                                        const gchar *url);
 
 G_END_DECLS
 
diff --git a/gedit/gedit-app-win32.c b/gedit/gedit-app-win32.c
index 96aca51..696dfbb 100644
--- a/gedit/gedit-app-win32.c
+++ b/gedit/gedit-app-win32.c
@@ -33,6 +33,10 @@
 #define DATADIR SAVE_DATADIR
 #undef SAVE_DATADIR
 
+struct _GeditAppWin32
+{
+       GeditApp parent_instance;
+};
 
 G_DEFINE_TYPE (GeditAppWin32, gedit_app_win32, GEDIT_TYPE_APP)
 
diff --git a/gedit/gedit-app-win32.h b/gedit/gedit-app-win32.h
index db4b574..4f18de7 100644
--- a/gedit/gedit-app-win32.h
+++ b/gedit/gedit-app-win32.h
@@ -27,29 +27,9 @@
 
 G_BEGIN_DECLS
 
-#define GEDIT_TYPE_APP_WIN32           (gedit_app_win32_get_type ())
-#define GEDIT_APP_WIN32(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_WIN32, 
GeditAppWin32))
-#define GEDIT_APP_WIN32_CONST(obj)     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_WIN32, 
GeditAppWin32 const))
-#define GEDIT_APP_WIN32_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_APP_WIN32, 
GeditAppWin32Class))
-#define GEDIT_IS_APP_WIN32(obj)                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_APP_WIN32))
-#define GEDIT_IS_APP_WIN32_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_APP_WIN32))
-#define GEDIT_APP_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_APP_WIN32, 
GeditAppWin32Class))
-
-typedef struct _GeditAppWin32          GeditAppWin32;
-typedef struct _GeditAppWin32Class     GeditAppWin32Class;
-typedef struct _GeditAppWin32Private   GeditAppWin32Private;
-
-struct _GeditAppWin32
-{
-       GeditApp parent;
-};
-
-struct _GeditAppWin32Class
-{
-       GeditAppClass parent_class;
-};
-
-GType   gedit_app_win32_get_type (void) G_GNUC_CONST;
+#define GEDIT_TYPE_APP_WIN32 (gedit_app_win32_get_type ())
+
+G_DECLARE_FINAL_TYPE (GeditAppWin32, gedit_app_win32, GEDIT, APP_WIN32, GeditApp)
 
 G_END_DECLS
 
diff --git a/gedit/gedit-app-x11.c b/gedit/gedit-app-x11.c
index ee57507..8436159 100644
--- a/gedit/gedit-app-x11.c
+++ b/gedit/gedit-app-x11.c
@@ -26,6 +26,11 @@
 #include <gdk/gdkx.h>
 #endif
 
+struct _GeditAppX11
+{
+       GeditApp parent_instance;
+};
+
 G_DEFINE_TYPE (GeditAppX11, gedit_app_x11, GEDIT_TYPE_APP)
 
 /* This should go in GtkApplication at some point... */
diff --git a/gedit/gedit-app-x11.h b/gedit/gedit-app-x11.h
index 064ead7..0935e7a 100644
--- a/gedit/gedit-app-x11.h
+++ b/gedit/gedit-app-x11.h
@@ -28,28 +28,8 @@
 G_BEGIN_DECLS
 
 #define GEDIT_TYPE_APP_X11             (gedit_app_x11_get_type ())
-#define GEDIT_APP_X11(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_X11, GeditAppX11))
-#define GEDIT_APP_X11_CONST(obj)       (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_APP_X11, GeditAppX11 
const))
-#define GEDIT_APP_X11_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_APP_X11, 
GeditAppX11Class))
-#define GEDIT_IS_APP_X11(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_APP_X11))
-#define GEDIT_IS_APP_X11_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_APP_X11))
-#define GEDIT_APP_X11_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_APP_X11, 
GeditAppX11Class))
-
-typedef struct _GeditAppX11            GeditAppX11;
-typedef struct _GeditAppX11Class       GeditAppX11Class;
-typedef struct _GeditAppX11Private     GeditAppX11Private;
-
-struct _GeditAppX11
-{
-       GeditApp parent;
-};
-
-struct _GeditAppX11Class
-{
-       GeditAppClass parent_class;
-};
-
-GType   gedit_app_x11_get_type (void) G_GNUC_CONST;
+
+G_DECLARE_FINAL_TYPE (GeditAppX11, gedit_app_x11, GEDIT, APP_X11, GeditApp)
 
 G_END_DECLS
 
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 7b0c710..e244c34 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -64,7 +64,7 @@ enum
        PROP_LOCKDOWN
 };
 
-struct _GeditAppPrivate
+typedef struct
 {
        GeditPluginsEngine *engine;
 
@@ -97,7 +97,7 @@ struct _GeditAppPrivate
        gint line_position;
        gint column_position;
        GApplicationCommandLine *command_line;
-};
+} GeditAppPrivate;
 
 static const GOptionEntry options[] =
 {
@@ -170,32 +170,35 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GeditApp, gedit_app, GTK_TYPE_APPLICATION)
 static void
 gedit_app_dispose (GObject *object)
 {
-       GeditApp *app = GEDIT_APP (object);
+       GeditAppPrivate *priv;
+
+       priv = gedit_app_get_instance_private (GEDIT_APP (object));
 
-       g_clear_object (&app->priv->ui_settings);
-       g_clear_object (&app->priv->window_settings);
-       g_clear_object (&app->priv->settings);
+       g_clear_object (&priv->ui_settings);
+       g_clear_object (&priv->window_settings);
+       g_clear_object (&priv->settings);
 
-       g_clear_object (&app->priv->page_setup);
-       g_clear_object (&app->priv->print_settings);
+       g_clear_object (&priv->page_setup);
+       g_clear_object (&priv->print_settings);
 
        /* Note that unreffing the extensions will automatically remove
-          all extensions which in turn will deactivate the extension */
-       g_clear_object (&app->priv->extensions);
+        * all extensions which in turn will deactivate the extension
+        */
+       g_clear_object (&priv->extensions);
 
-       g_clear_object (&app->priv->engine);
+       g_clear_object (&priv->engine);
 
-       if (app->priv->theme_provider != NULL)
+       if (priv->theme_provider != NULL)
        {
                gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
-                                                             GTK_STYLE_PROVIDER (app->priv->theme_provider));
-               g_clear_object (&app->priv->theme_provider);
+                                                             GTK_STYLE_PROVIDER (priv->theme_provider));
+               g_clear_object (&priv->theme_provider);
        }
 
-       g_clear_object (&app->priv->window_menu);
-       g_clear_object (&app->priv->notebook_menu);
-       g_clear_object (&app->priv->tab_width_menu);
-       g_clear_object (&app->priv->line_col_menu);
+       g_clear_object (&priv->window_menu);
+       g_clear_object (&priv->notebook_menu);
+       g_clear_object (&priv->tab_width_menu);
+       g_clear_object (&priv->line_col_menu);
 
        G_OBJECT_CLASS (gedit_app_parent_class)->dispose (object);
 }
@@ -390,9 +393,13 @@ static void
 set_command_line_wait (GeditApp *app,
                       GeditTab *tab)
 {
+       GeditAppPrivate *priv;
+
+       priv = gedit_app_get_instance_private (app);
+
        g_object_set_data_full (G_OBJECT (tab),
                                "GeditTabCommandLineWait",
-                               g_object_ref (app->priv->command_line),
+                               g_object_ref (priv->command_line),
                                (GDestroyNotify)g_object_unref);
 }
 
@@ -660,6 +667,10 @@ theme_changed (GtkSettings *settings,
               GParamSpec  *pspec,
               GeditApp    *app)
 {
+       GeditAppPrivate *priv;
+
+       priv = gedit_app_get_instance_private (app);
+
        gchar *theme, *lc_theme, *theme_css;
 
        g_object_get (settings, "gtk-theme-name", &theme, NULL);
@@ -669,14 +680,14 @@ theme_changed (GtkSettings *settings,
        theme_css = g_strdup_printf ("gedit.%s.css", lc_theme);
        g_free (lc_theme);
 
-       if (app->priv->theme_provider != NULL)
+       if (priv->theme_provider != NULL)
        {
                gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
-                                                             GTK_STYLE_PROVIDER (app->priv->theme_provider));
-               g_clear_object (&app->priv->theme_provider);
+                                                             GTK_STYLE_PROVIDER (priv->theme_provider));
+               g_clear_object (&priv->theme_provider);
        }
 
-       app->priv->theme_provider = load_css_from_resource (theme_css, FALSE);
+       priv->theme_provider = load_css_from_resource (theme_css, FALSE);
 
        g_free (theme_css);
 }
@@ -704,27 +715,29 @@ get_menu_model (GeditApp   *app,
 }
 
 static void
-add_accelerator (GeditApp    *app,
-                 const gchar *action_name,
-                 const gchar *accel)
+add_accelerator (GtkApplication *app,
+                 const gchar    *action_name,
+                 const gchar    *accel)
 {
        const gchar *vaccels[] = {
                accel,
                NULL
        };
 
-       gtk_application_set_accels_for_action (GTK_APPLICATION (app), action_name, vaccels);
+       gtk_application_set_accels_for_action (app, action_name, vaccels);
 }
 
 static void
 gedit_app_startup (GApplication *application)
 {
-       GeditApp *app = GEDIT_APP (application);
+       GeditAppPrivate *priv;
        GtkCssProvider *css_provider;
        GtkSourceStyleSchemeManager *manager;
        const gchar *dir;
        gchar *icon_dir;
 
+       priv = gedit_app_get_instance_private (GEDIT_APP (application));
+
        G_APPLICATION_CLASS (gedit_app_parent_class)->startup (application);
 
        /* Setup debugging */
@@ -739,71 +752,71 @@ gedit_app_startup (GApplication *application)
        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), icon_dir);
        g_free (icon_dir);
 
-       setup_theme_extensions (app);
+       setup_theme_extensions (GEDIT_APP (application));
 
 #ifndef ENABLE_GVFS_METADATA
        gedit_metadata_manager_init ();
 #endif
 
        /* Load settings */
-       app->priv->settings = gedit_settings_new ();
-       app->priv->ui_settings = g_settings_new ("org.gnome.gedit.preferences.ui");
-       app->priv->window_settings = g_settings_new ("org.gnome.gedit.state.window");
+       priv->settings = gedit_settings_new ();
+       priv->ui_settings = g_settings_new ("org.gnome.gedit.preferences.ui");
+       priv->window_settings = g_settings_new ("org.gnome.gedit.state.window");
 
        /* initial lockdown state */
-       app->priv->lockdown = gedit_settings_get_lockdown (GEDIT_SETTINGS (app->priv->settings));
+       priv->lockdown = gedit_settings_get_lockdown (GEDIT_SETTINGS (priv->settings));
 
-       g_action_map_add_action_entries (G_ACTION_MAP (app),
+       g_action_map_add_action_entries (G_ACTION_MAP (application),
                                         app_entries,
                                         G_N_ELEMENTS (app_entries),
-                                        app);
+                                        application);
 
        /* menus */
-       app->priv->window_menu = gtk_application_get_menubar (GTK_APPLICATION (app));
+       priv->window_menu = gtk_application_get_menubar (GTK_APPLICATION (application));
 
-       if (app->priv->window_menu == NULL)
+       if (priv->window_menu == NULL)
        {
-               app->priv->window_menu = get_menu_model (app, "gear-menu");
+               priv->window_menu = get_menu_model (GEDIT_APP (application), "gear-menu");
        }
        else
        {
-               g_object_ref (app->priv->window_menu);
+               g_object_ref (priv->window_menu);
        }
 
-       app->priv->notebook_menu = get_menu_model (app, "notebook-menu");
-       app->priv->tab_width_menu = get_menu_model (app, "tab-width-menu");
-       app->priv->line_col_menu = get_menu_model (app, "line-col-menu");
+       priv->notebook_menu = get_menu_model (GEDIT_APP (application), "notebook-menu");
+       priv->tab_width_menu = get_menu_model (GEDIT_APP (application), "tab-width-menu");
+       priv->line_col_menu = get_menu_model (GEDIT_APP (application), "line-col-menu");
 
        /* Accelerators */
-       add_accelerator (app, "app.new-window", "<Primary>N");
-       add_accelerator (app, "app.quit", "<Primary>Q");
-       add_accelerator (app, "app.help", "F1");
-
-       add_accelerator (app, "win.gear-menu", "F10");
-       add_accelerator (app, "win.open", "<Primary>O");
-       add_accelerator (app, "win.save", "<Primary>S");
-       add_accelerator (app, "win.save-as", "<Primary><Shift>S");
-       add_accelerator (app, "win.save-all", "<Primary><Shift>L");
-       add_accelerator (app, "win.new-tab", "<Primary>T");
-       add_accelerator (app, "win.reopen-closed-tab", "<Primary><Shift>T");
-       add_accelerator (app, "win.close", "<Primary>W");
-       add_accelerator (app, "win.close-all", "<Primary><Shift>W");
-       add_accelerator (app, "win.print", "<Primary>P");
-       add_accelerator (app, "win.find", "<Primary>F");
-       add_accelerator (app, "win.find-next", "<Primary>G");
-       add_accelerator (app, "win.find-prev", "<Primary><Shift>G");
-       add_accelerator (app, "win.replace", "<Primary>H");
-       add_accelerator (app, "win.clear-highlight", "<Primary><Shift>K");
-       add_accelerator (app, "win.goto-line", "<Primary>I");
-       add_accelerator (app, "win.focus-active-view", "Escape");
-       add_accelerator (app, "win.side-panel", "F9");
-       add_accelerator (app, "win.bottom-panel", "<Primary>F9");
-       add_accelerator (app, "win.fullscreen", "F11");
-       add_accelerator (app, "win.new-tab-group", "<Primary><Alt>N");
-       add_accelerator (app, "win.previous-tab-group", "<Primary><Shift><Alt>Page_Up");
-       add_accelerator (app, "win.next-tab-group", "<Primary><Shift><Alt>Page_Down");
-       add_accelerator (app, "win.previous-document", "<Primary><Alt>Page_Up");
-       add_accelerator (app, "win.next-document", "<Primary><Alt>Page_Down");
+       add_accelerator (GTK_APPLICATION (application), "app.new-window", "<Primary>N");
+       add_accelerator (GTK_APPLICATION (application), "app.quit", "<Primary>Q");
+       add_accelerator (GTK_APPLICATION (application), "app.help", "F1");
+
+       add_accelerator (GTK_APPLICATION (application), "win.gear-menu", "F10");
+       add_accelerator (GTK_APPLICATION (application), "win.open", "<Primary>O");
+       add_accelerator (GTK_APPLICATION (application), "win.save", "<Primary>S");
+       add_accelerator (GTK_APPLICATION (application), "win.save-as", "<Primary><Shift>S");
+       add_accelerator (GTK_APPLICATION (application), "win.save-all", "<Primary><Shift>L");
+       add_accelerator (GTK_APPLICATION (application), "win.new-tab", "<Primary>T");
+       add_accelerator (GTK_APPLICATION (application), "win.reopen-closed-tab", "<Primary><Shift>T");
+       add_accelerator (GTK_APPLICATION (application), "win.close", "<Primary>W");
+       add_accelerator (GTK_APPLICATION (application), "win.close-all", "<Primary><Shift>W");
+       add_accelerator (GTK_APPLICATION (application), "win.print", "<Primary>P");
+       add_accelerator (GTK_APPLICATION (application), "win.find", "<Primary>F");
+       add_accelerator (GTK_APPLICATION (application), "win.find-next", "<Primary>G");
+       add_accelerator (GTK_APPLICATION (application), "win.find-prev", "<Primary><Shift>G");
+       add_accelerator (GTK_APPLICATION (application), "win.replace", "<Primary>H");
+       add_accelerator (GTK_APPLICATION (application), "win.clear-highlight", "<Primary><Shift>K");
+       add_accelerator (GTK_APPLICATION (application), "win.goto-line", "<Primary>I");
+       add_accelerator (GTK_APPLICATION (application), "win.focus-active-view", "Escape");
+       add_accelerator (GTK_APPLICATION (application), "win.side-panel", "F9");
+       add_accelerator (GTK_APPLICATION (application), "win.bottom-panel", "<Primary>F9");
+       add_accelerator (GTK_APPLICATION (application), "win.fullscreen", "F11");
+       add_accelerator (GTK_APPLICATION (application), "win.new-tab-group", "<Primary><Alt>N");
+       add_accelerator (GTK_APPLICATION (application), "win.previous-tab-group", 
"<Primary><Shift><Alt>Page_Up");
+       add_accelerator (GTK_APPLICATION (application), "win.next-tab-group", 
"<Primary><Shift><Alt>Page_Down");
+       add_accelerator (GTK_APPLICATION (application), "win.previous-document", "<Primary><Alt>Page_Up");
+       add_accelerator (GTK_APPLICATION (application), "win.next-document", "<Primary><Alt>Page_Down");
 
        load_accels ();
 
@@ -821,31 +834,33 @@ gedit_app_startup (GApplication *application)
        gtk_source_style_scheme_manager_append_search_path (manager,
                                                            gedit_dirs_get_user_styles_dir ());
 
-       app->priv->engine = gedit_plugins_engine_get_default ();
-       app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (app->priv->engine),
-                                                       GEDIT_TYPE_APP_ACTIVATABLE,
-                                                       "app", app,
-                                                       NULL);
+       priv->engine = gedit_plugins_engine_get_default ();
+       priv->extensions = peas_extension_set_new (PEAS_ENGINE (priv->engine),
+                                                  GEDIT_TYPE_APP_ACTIVATABLE,
+                                                  "app", GEDIT_APP (application),
+                                                  NULL);
 
-       g_signal_connect (app->priv->extensions,
+       g_signal_connect (priv->extensions,
                          "extension-added",
                          G_CALLBACK (extension_added),
-                         app);
+                         application);
 
-       g_signal_connect (app->priv->extensions,
+       g_signal_connect (priv->extensions,
                          "extension-removed",
                          G_CALLBACK (extension_removed),
-                         app);
+                         application);
 
-       peas_extension_set_foreach (app->priv->extensions,
+       peas_extension_set_foreach (priv->extensions,
                                    (PeasExtensionSetForeachFunc) extension_added,
-                                   app);
+                                   application);
 }
 
 static void
 gedit_app_activate (GApplication *application)
 {
-       GeditAppPrivate *priv = GEDIT_APP (application)->priv;
+       GeditAppPrivate *priv;
+
+       priv = gedit_app_get_instance_private (GEDIT_APP (application));
 
        open_files (application,
                    priv->new_window,
@@ -862,7 +877,9 @@ gedit_app_activate (GApplication *application)
 static void
 clear_options (GeditApp *app)
 {
-       GeditAppPrivate *priv = app->priv;
+       GeditAppPrivate *priv;
+
+       priv = gedit_app_get_instance_private (app);
 
        g_free (priv->geometry);
        g_clear_object (&priv->stdin_stream);
@@ -912,7 +929,7 @@ gedit_app_command_line (GApplication            *application,
        const gchar *encoding_charset;
        const gchar **remaining_args;
 
-       priv = GEDIT_APP (application)->priv;
+       priv = gedit_app_get_instance_private (GEDIT_APP (application));
 
        options = g_application_command_line_get_options_dict (cl);
 
@@ -1131,24 +1148,28 @@ get_page_setup_file (void)
 static void
 save_page_setup (GeditApp *app)
 {
-       gchar *filename;
-       GError *error = NULL;
-
-       if (app->priv->page_setup == NULL)
-               return;
+       GeditAppPrivate *priv;
 
-       filename = get_page_setup_file ();
+       priv = gedit_app_get_instance_private (app);
 
-       gtk_page_setup_to_file (app->priv->page_setup,
-                               filename,
-                               &error);
-       if (error)
+       if (priv->page_setup != NULL)
        {
-               g_warning ("%s", error->message);
-               g_error_free (error);
-       }
+               gchar *filename;
+               GError *error = NULL;
 
-       g_free (filename);
+               filename = get_page_setup_file ();
+
+               gtk_page_setup_to_file (priv->page_setup,
+                                       filename,
+                                       &error);
+               if (error)
+               {
+                       g_warning ("%s", error->message);
+                       g_error_free (error);
+               }
+
+               g_free (filename);
+       }
 }
 
 static gchar *
@@ -1172,24 +1193,28 @@ get_print_settings_file (void)
 static void
 save_print_settings (GeditApp *app)
 {
-       gchar *filename;
-       GError *error = NULL;
+       GeditAppPrivate *priv;
 
-       if (app->priv->print_settings == NULL)
-               return;
+       priv = gedit_app_get_instance_private (app);
 
-       filename = get_print_settings_file ();
-
-       gtk_print_settings_to_file (app->priv->print_settings,
-                                   filename,
-                                   &error);
-       if (error)
+       if (priv->print_settings != NULL)
        {
-               g_warning ("%s", error->message);
-               g_error_free (error);
-       }
+               gchar *filename;
+               GError *error = NULL;
 
-       g_free (filename);
+               filename = get_print_settings_file ();
+
+               gtk_print_settings_to_file (priv->print_settings,
+                                           filename,
+                                           &error);
+               if (error)
+               {
+                       g_warning ("%s", error->message);
+                       g_error_free (error);
+               }
+
+               g_free (filename);
+       }
 }
 
 static void
@@ -1290,15 +1315,17 @@ gedit_app_class_init (GeditAppClass *klass)
 static void
 load_page_setup (GeditApp *app)
 {
+       GeditAppPrivate *priv;
        gchar *filename;
        GError *error = NULL;
 
-       g_return_if_fail (app->priv->page_setup == NULL);
+       priv = gedit_app_get_instance_private (app);
+
+       g_return_if_fail (priv->page_setup == NULL);
 
        filename = get_page_setup_file ();
 
-       app->priv->page_setup = gtk_page_setup_new_from_file (filename,
-                                                             &error);
+       priv->page_setup = gtk_page_setup_new_from_file (filename, &error);
        if (error)
        {
                /* Ignore file not found error */
@@ -1314,22 +1341,26 @@ load_page_setup (GeditApp *app)
        g_free (filename);
 
        /* fall back to default settings */
-       if (app->priv->page_setup == NULL)
-               app->priv->page_setup = gtk_page_setup_new ();
+       if (priv->page_setup == NULL)
+       {
+               priv->page_setup = gtk_page_setup_new ();
+       }
 }
 
 static void
 load_print_settings (GeditApp *app)
 {
+       GeditAppPrivate *priv;
        gchar *filename;
        GError *error = NULL;
 
-       g_return_if_fail (app->priv->print_settings == NULL);
+       priv = gedit_app_get_instance_private (app);
+
+       g_return_if_fail (priv->print_settings == NULL);
 
        filename = get_print_settings_file ();
 
-       app->priv->print_settings = gtk_print_settings_new_from_file (filename,
-                                                                     &error);
+       priv->print_settings = gtk_print_settings_new_from_file (filename, &error);
        if (error)
        {
                /* Ignore file not found error */
@@ -1345,8 +1376,10 @@ load_print_settings (GeditApp *app)
        g_free (filename);
 
        /* fall back to default settings */
-       if (app->priv->print_settings == NULL)
-               app->priv->print_settings = gtk_print_settings_new ();
+       if (priv->print_settings == NULL)
+       {
+               priv->print_settings = gtk_print_settings_new ();
+       }
 }
 
 static void
@@ -1385,16 +1418,18 @@ get_network_available (GNetworkMonitor *monitor,
 static void
 gedit_app_init (GeditApp *app)
 {
-       app->priv = gedit_app_get_instance_private (app);
+       GeditAppPrivate *priv;
+
+       priv = gedit_app_get_instance_private (app);
 
        g_set_application_name ("gedit");
        gtk_window_set_default_icon_name ("accessories-text-editor");
 
-       app->priv->monitor = g_network_monitor_get_default ();
-       g_signal_connect (app->priv->monitor,
-                         "network-changed",
-                         G_CALLBACK (get_network_available),
-                         app);
+       priv->monitor = g_network_monitor_get_default ();
+       g_signal_connect (priv->monitor,
+                         "network-changed",
+                         G_CALLBACK (get_network_available),
+                         app);
 
        g_application_add_main_option_entries (G_APPLICATION (app), options);
 
@@ -1432,6 +1467,7 @@ GeditWindow *
 gedit_app_create_window (GeditApp  *app,
                         GdkScreen *screen)
 {
+       GeditAppPrivate *priv;
        GeditWindow *window;
        gchar *role;
        GdkWindowState state;
@@ -1439,6 +1475,8 @@ gedit_app_create_window (GeditApp  *app,
 
        gedit_debug (DEBUG_APP);
 
+       priv = gedit_app_get_instance_private (app);
+
        window = GEDIT_APP_GET_CLASS (app)->create_window (app);
 
        if (screen != NULL)
@@ -1450,12 +1488,12 @@ gedit_app_create_window (GeditApp  *app,
        gtk_window_set_role (GTK_WINDOW (window), role);
        g_free (role);
 
-       state = g_settings_get_int (app->priv->window_settings,
-                                   GEDIT_SETTINGS_WINDOW_STATE);
+       state = g_settings_get_int (priv->window_settings,
+                                   GEDIT_SETTINGS_WINDOW_STATE);
 
-       g_settings_get (app->priv->window_settings,
-                       GEDIT_SETTINGS_WINDOW_SIZE,
-                       "(ii)", &w, &h);
+       g_settings_get (priv->window_settings,
+                       GEDIT_SETTINGS_WINDOW_SIZE,
+                       "(ii)", &w, &h);
 
        gtk_window_set_default_size (GTK_WINDOW (window), w, h);
 
@@ -1582,9 +1620,13 @@ gedit_app_get_views (GeditApp *app)
 GeditLockdownMask
 gedit_app_get_lockdown (GeditApp *app)
 {
+       GeditAppPrivate *priv;
+
        g_return_val_if_fail (GEDIT_IS_APP (app), GEDIT_LOCKDOWN_ALL);
 
-       return app->priv->lockdown;
+       priv = gedit_app_get_instance_private (app);
+
+       return priv->lockdown;
 }
 
 gboolean
@@ -1673,17 +1715,18 @@ find_extension_point_section (GMenuModel  *model,
 static void
 app_lockdown_changed (GeditApp *app)
 {
+       GeditAppPrivate *priv;
        GList *windows, *l;
 
+       priv = gedit_app_get_instance_private (app);
+
        windows = gtk_application_get_windows (GTK_APPLICATION (app));
        for (l = windows; l != NULL; l = g_list_next (l))
        {
-               GtkWindow *window = l->data;
-
-               if (GEDIT_IS_WINDOW (window))
+               if (GEDIT_IS_WINDOW (l->data))
                {
-                       _gedit_window_set_lockdown (GEDIT_WINDOW (window),
-                                                   app->priv->lockdown);
+                       _gedit_window_set_lockdown (GEDIT_WINDOW (l->data),
+                                                   priv->lockdown);
                }
        }
 
@@ -1694,10 +1737,13 @@ void
 _gedit_app_set_lockdown (GeditApp          *app,
                         GeditLockdownMask  lockdown)
 {
+       GeditAppPrivate *priv;
+
        g_return_if_fail (GEDIT_IS_APP (app));
 
-       app->priv->lockdown = lockdown;
+       priv = gedit_app_get_instance_private (app);
 
+       priv->lockdown = lockdown;
        app_lockdown_changed (app);
 }
 
@@ -1706,12 +1752,20 @@ _gedit_app_set_lockdown_bit (GeditApp          *app,
                             GeditLockdownMask  bit,
                             gboolean           value)
 {
+       GeditAppPrivate *priv;
+
        g_return_if_fail (GEDIT_IS_APP (app));
 
+       priv = gedit_app_get_instance_private (app);
+
        if (value)
-               app->priv->lockdown |= bit;
+       {
+               priv->lockdown |= bit;
+       }
        else
-               app->priv->lockdown &= ~bit;
+       {
+               priv->lockdown &= ~bit;
+       }
 
        app_lockdown_changed (app);
 }
@@ -1720,105 +1774,151 @@ _gedit_app_set_lockdown_bit (GeditApp          *app,
 GtkPageSetup *
 _gedit_app_get_default_page_setup (GeditApp *app)
 {
+       GeditAppPrivate *priv;
+
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
 
-       if (app->priv->page_setup == NULL)
+       priv = gedit_app_get_instance_private (app);
+
+       if (priv->page_setup == NULL)
+       {
                load_page_setup (app);
+       }
 
-       return gtk_page_setup_copy (app->priv->page_setup);
+       return gtk_page_setup_copy (priv->page_setup);
 }
 
 void
 _gedit_app_set_default_page_setup (GeditApp     *app,
                                   GtkPageSetup *page_setup)
 {
+       GeditAppPrivate *priv;
+
        g_return_if_fail (GEDIT_IS_APP (app));
        g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup));
 
-       if (app->priv->page_setup != NULL)
-               g_object_unref (app->priv->page_setup);
+       priv = gedit_app_get_instance_private (app);
+
+       if (priv->page_setup != NULL)
+       {
+               g_object_unref (priv->page_setup);
+       }
 
-       app->priv->page_setup = g_object_ref (page_setup);
+       priv->page_setup = g_object_ref (page_setup);
 }
 
 /* Returns a copy */
 GtkPrintSettings *
 _gedit_app_get_default_print_settings (GeditApp *app)
 {
+       GeditAppPrivate *priv;
+
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
 
-       if (app->priv->print_settings == NULL)
+       priv = gedit_app_get_instance_private (app);
+
+       if (priv->print_settings == NULL)
+       {
                load_print_settings (app);
+       }
 
-       return gtk_print_settings_copy (app->priv->print_settings);
+       return gtk_print_settings_copy (priv->print_settings);
 }
 
 void
 _gedit_app_set_default_print_settings (GeditApp         *app,
                                       GtkPrintSettings *settings)
 {
+       GeditAppPrivate *priv;
+
        g_return_if_fail (GEDIT_IS_APP (app));
        g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
 
-       if (app->priv->print_settings != NULL)
-               g_object_unref (app->priv->print_settings);
+       priv = gedit_app_get_instance_private (app);
+
+       if (priv->print_settings != NULL)
+       {
+               g_object_unref (priv->print_settings);
+       }
 
-       app->priv->print_settings = g_object_ref (settings);
+       priv->print_settings = g_object_ref (settings);
 }
 
 GObject *
 _gedit_app_get_settings (GeditApp *app)
 {
+       GeditAppPrivate *priv;
+
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
 
-       return app->priv->settings;
+       priv = gedit_app_get_instance_private (app);
+
+       return priv->settings;
 }
 
 GMenuModel *
 _gedit_app_get_window_menu (GeditApp *app)
 {
+       GeditAppPrivate *priv;
+
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
 
-       return app->priv->window_menu;
+       priv = gedit_app_get_instance_private (app);
+
+       return priv->window_menu;
 }
 
 GMenuModel *
 _gedit_app_get_notebook_menu (GeditApp *app)
 {
+       GeditAppPrivate *priv;
+
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
 
-       return app->priv->notebook_menu;
+       priv = gedit_app_get_instance_private (app);
+
+       return priv->notebook_menu;
 }
 
 GMenuModel *
 _gedit_app_get_tab_width_menu (GeditApp *app)
 {
+       GeditAppPrivate *priv;
+
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
 
-       return app->priv->tab_width_menu;
+       priv = gedit_app_get_instance_private (app);
+
+       return priv->tab_width_menu;
 }
 
 GMenuModel *
 _gedit_app_get_line_col_menu (GeditApp *app)
 {
+       GeditAppPrivate *priv;
+
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
 
-       return app->priv->line_col_menu;
-}
+       priv = gedit_app_get_instance_private (app);
 
+       return priv->line_col_menu;
+}
 
 GeditMenuExtension *
 _gedit_app_extend_menu (GeditApp    *app,
                        const gchar *extension_point)
 {
+       GeditAppPrivate *priv;
        GMenuModel *model;
        GMenuModel *section;
 
        g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
        g_return_val_if_fail (extension_point != NULL, NULL);
 
+       priv = gedit_app_get_instance_private (app);
+
        /* First look in the window menu */
-       section = find_extension_point_section (app->priv->window_menu, extension_point);
+       section = find_extension_point_section (priv->window_menu, extension_point);
 
        /* otherwise look in the app menu */
        if (section == NULL)
diff --git a/gedit/gedit-app.h b/gedit/gedit-app.h
index 69cec85..85c3b31 100644
--- a/gedit/gedit-app.h
+++ b/gedit/gedit-app.h
@@ -28,52 +28,34 @@
 
 G_BEGIN_DECLS
 
-#define GEDIT_TYPE_APP              (gedit_app_get_type())
-#define GEDIT_APP(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_APP, GeditApp))
-#define GEDIT_APP_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_APP, GeditAppClass))
-#define GEDIT_IS_APP(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), GEDIT_TYPE_APP))
-#define GEDIT_IS_APP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_APP))
-#define GEDIT_APP_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_APP, GeditAppClass))
-
-typedef struct _GeditApp        GeditApp;
-typedef struct _GeditAppClass   GeditAppClass;
-typedef struct _GeditAppPrivate GeditAppPrivate;
-
-struct _GeditApp
-{
-       GtkApplication parent;
+#define GEDIT_TYPE_APP (gedit_app_get_type())
 
-       /*< private > */
-       GeditAppPrivate *priv;
-};
+G_DECLARE_DERIVABLE_TYPE (GeditApp, gedit_app, GEDIT, APP, GtkApplication)
 
 struct _GeditAppClass
 {
        GtkApplicationClass parent_class;
 
-       gboolean (*show_help)                   (GeditApp    *app,
+       gboolean (*show_help)                   (GeditApp    *app,
                                                 GtkWindow   *parent,
                                                 const gchar *name,
                                                 const gchar *link_id);
 
-       gchar *(*help_link_id)                  (GeditApp    *app,
+       gchar *(*help_link_id)                  (GeditApp    *app,
                                                 const gchar *name,
                                                 const gchar *link_id);
 
-       void (*set_window_title)                (GeditApp    *app,
+       void (*set_window_title)                (GeditApp    *app,
                                                 GeditWindow *window,
                                                 const gchar *title);
 
-       GeditWindow *(*create_window)           (GeditApp    *app);
+       GeditWindow *(*create_window)           (GeditApp    *app);
 
-       gboolean (*process_window_event)        (GeditApp    *app,
-                                                GeditWindow *window,
-                                                GdkEvent    *event);
+       gboolean (*process_window_event)        (GeditApp    *app,
+                                                GeditWindow *window,
+                                                GdkEvent    *event);
 };
 
-/*
- * Lockdown mask definition
- */
 typedef enum
 {
        GEDIT_LOCKDOWN_COMMAND_LINE     = 1 << 0,
@@ -85,9 +67,6 @@ typedef enum
 /* We need to define this here to avoid problems with bindings and gsettings */
 #define GEDIT_LOCKDOWN_ALL 0xF
 
-/* Public methods */
-GType           gedit_app_get_type                     (void) G_GNUC_CONST;
-
 GeditWindow    *gedit_app_create_window                (GeditApp    *app,
                                                         GdkScreen   *screen);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]