diff options
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/eom-application-internal.h | 60 | ||||
-rw-r--r-- | src/eom-application.c | 88 | ||||
-rw-r--r-- | src/eom-application.h | 21 | ||||
-rw-r--r-- | src/eom-window.c | 9 | ||||
-rw-r--r-- | src/main.c | 3 |
6 files changed, 121 insertions, 61 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 79fe623..8f9cab7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,7 @@ MARSHAL_OUTPUT = \ eom-marshal.c NOINST_H_FILES = \ + eom-application-internal.h \ eom-session.h \ eom-util.h \ eom-pixbuf-util.h \ diff --git a/src/eom-application-internal.h b/src/eom-application-internal.h new file mode 100644 index 0000000..07755e2 --- /dev/null +++ b/src/eom-application-internal.h @@ -0,0 +1,60 @@ +/* Eye Of Gnome - Application Facade (internal) + * + * Copyright (C) 2006-2012 The Free Software Foundation + * + * Author: Lucas Rocha <[email protected]> + * + * Based on evince code (shell/ev-application.h) by: + * - Martin Kretzschmar <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __EOM_APPLICATION_INTERNAL_H__ +#define __EOM_APPLICATION_INTERNAL_H__ + +#include <glib.h> +#include <glib-object.h> + +#include <libpeas/peas-extension-set.h> + +#include "eom-application.h" +#include "eom-plugin-engine.h" +#include "egg-toolbars-model.h" +#include "eom-window.h" + +G_BEGIN_DECLS + +struct _EomApplicationPrivate { + EggToolbarsModel *toolbars_model; + gchar *toolbars_file; + EomPluginEngine *plugin_engine; + + EomStartupFlags flags; + + PeasExtensionSet *extensions; +}; + + +EggToolbarsModel *eom_application_get_toolbars_model (EomApplication *application); + +void eom_application_save_toolbars_model (EomApplication *application); + +void eom_application_reset_toolbars_model (EomApplication *app); + +G_END_DECLS + +#endif /* __EOM_APPLICATION_INTERNAL_H__ */ + diff --git a/src/eom-application.c b/src/eom-application.c index 1ab52d1..9830bd2 100644 --- a/src/eom-application.c +++ b/src/eom-application.c @@ -31,6 +31,7 @@ #include "eom-window.h" #include "eom-application.h" #include "eom-application-activatable.h" +#include "eom-application-internal.h" #include "eom-util.h" #include <string.h> @@ -55,7 +56,7 @@ eom_application_activate (GApplication *application) { eom_application_open_window (EOM_APPLICATION (application), GDK_CURRENT_TIME, - EOM_APPLICATION (application)->flags, + EOM_APPLICATION (application)->priv->flags, NULL); } @@ -72,7 +73,7 @@ eom_application_open (GApplication *application, eom_application_open_file_list (EOM_APPLICATION (application), list, GDK_CURRENT_TIME, - EOM_APPLICATION (application)->flags, + EOM_APPLICATION (application)->priv->flags, NULL); } @@ -80,19 +81,20 @@ static void eom_application_finalize (GObject *object) { EomApplication *application = EOM_APPLICATION (object); + EomApplicationPrivate *priv = application->priv; - if (application->toolbars_model) { - g_object_unref (application->toolbars_model); - application->toolbars_model = NULL; - g_free (application->toolbars_file); - application->toolbars_file = NULL; + if (priv->toolbars_model) { + g_object_unref (priv->toolbars_model); + priv->toolbars_model = NULL; + g_free (priv->toolbars_file); + priv->toolbars_file = NULL; } - g_clear_object (&application->extensions); + g_clear_object (&priv->extensions); - if (application->plugin_engine) { - g_object_unref (application->plugin_engine); - application->plugin_engine = NULL; + if (priv->plugin_engine) { + g_object_unref (priv->plugin_engine); + priv->plugin_engine = NULL; } eom_application_save_accelerators (); } @@ -106,10 +108,10 @@ eom_application_add_platform_data (GApplication *application, G_APPLICATION_CLASS (eom_application_parent_class)->add_platform_data (application, builder); - if (app->flags) { + if (app->priv->flags) { g_variant_builder_add (builder, "{sv}", "eom-application-startup-flags", - g_variant_new_byte (app->flags)); + g_variant_new_byte (app->priv->flags)); } } @@ -121,11 +123,11 @@ eom_application_before_emit (GApplication *application, const gchar *key; GVariant *value; - EOM_APPLICATION (application)->flags = 0; + EOM_APPLICATION (application)->priv->flags = 0; g_variant_iter_init (&iter, platform_data); while (g_variant_iter_loop (&iter, "{&sv}", &key, &value)) { if (strcmp (key, "eom-application-startup-flags") == 0) { - EOM_APPLICATION (application)->flags = g_variant_get_byte (value); + EOM_APPLICATION (application)->priv->flags = g_variant_get_byte (value); } } @@ -139,6 +141,9 @@ eom_application_class_init (EomApplicationClass *eom_application_class) GApplicationClass *application_class; GObjectClass *object_class; + g_type_class_add_private (eom_application_class, + sizeof (EomApplicationPrivate)); + application_class = (GApplicationClass *) eom_application_class; object_class = (GObjectClass *) eom_application_class; @@ -171,42 +176,46 @@ on_extension_removed (PeasExtensionSet *set, static void eom_application_init (EomApplication *eom_application) { + EomApplicationPrivate *priv; const gchar *dot_dir = eom_util_dot_dir (); eom_session_init (eom_application); - eom_application->toolbars_model = egg_toolbars_model_new (); - eom_application->plugin_engine = eom_plugin_engine_new (); - eom_application->flags = 0; + eom_application->priv = EOM_APPLICATION_GET_PRIVATE (eom_application); + priv = eom_application->priv; + + priv->toolbars_model = egg_toolbars_model_new (); + priv->plugin_engine = eom_plugin_engine_new (); + priv->flags = 0; - egg_toolbars_model_load_names (eom_application->toolbars_model, + egg_toolbars_model_load_names (priv->toolbars_model, EOM_DATA_DIR "/eom-toolbar.xml"); if (G_LIKELY (dot_dir != NULL)) - eom_application->toolbars_file = g_build_filename + priv->toolbars_file = g_build_filename (dot_dir, "eom_toolbar.xml", NULL); - if (!dot_dir || !egg_toolbars_model_load_toolbars (eom_application->toolbars_model, - eom_application->toolbars_file)) { + if (!dot_dir || !egg_toolbars_model_load_toolbars (priv->toolbars_model, + priv->toolbars_file)) { - egg_toolbars_model_load_toolbars (eom_application->toolbars_model, + egg_toolbars_model_load_toolbars (priv->toolbars_model, EOM_DATA_DIR "/eom-toolbar.xml"); } - egg_toolbars_model_set_flags (eom_application->toolbars_model, 0, + egg_toolbars_model_set_flags (priv->toolbars_model, 0, EGG_TB_MODEL_NOT_REMOVABLE); eom_application_load_accelerators (); - eom_application->extensions = peas_extension_set_new ( - PEAS_ENGINE (eom_application->plugin_engine), + priv->extensions = peas_extension_set_new ( + PEAS_ENGINE (priv->plugin_engine), EOM_TYPE_APPLICATION_ACTIVATABLE, "app", EOM_APPLICATION (eom_application), NULL); - peas_extension_set_call (eom_application->extensions, "activate"); - g_signal_connect (eom_application->extensions, "extension-added", + peas_extension_set_call (priv->extensions, "activate"); + g_signal_connect (priv->extensions, "extension-added", G_CALLBACK (on_extension_added), eom_application); - g_signal_connect (eom_application->extensions, "extension-removed", + g_signal_connect (priv->extensions, "extension-removed", G_CALLBACK (on_extension_removed), eom_application); } @@ -475,7 +484,7 @@ eom_application_get_toolbars_model (EomApplication *application) { g_return_val_if_fail (EOM_IS_APPLICATION (application), NULL); - return application->toolbars_model; + return application->priv->toolbars_model; } /** @@ -487,9 +496,9 @@ eom_application_get_toolbars_model (EomApplication *application) void eom_application_save_toolbars_model (EomApplication *application) { - if (G_LIKELY(application->toolbars_file != NULL)) - egg_toolbars_model_save_toolbars (application->toolbars_model, - application->toolbars_file, + if (G_LIKELY(application->priv->toolbars_file != NULL)) + egg_toolbars_model_save_toolbars (application->priv->toolbars_model, + application->priv->toolbars_file, "1.0"); } @@ -502,17 +511,20 @@ eom_application_save_toolbars_model (EomApplication *application) void eom_application_reset_toolbars_model (EomApplication *app) { + EomApplicationPrivate *priv; g_return_if_fail (EOM_IS_APPLICATION (app)); - g_object_unref (app->toolbars_model); + priv = app->priv; + + g_object_unref (app->priv->toolbars_model); - app->toolbars_model = egg_toolbars_model_new (); + priv->toolbars_model = egg_toolbars_model_new (); - egg_toolbars_model_load_names (app->toolbars_model, + egg_toolbars_model_load_names (priv->toolbars_model, EOM_DATA_DIR "/eom-toolbar.xml"); - egg_toolbars_model_load_toolbars (app->toolbars_model, + egg_toolbars_model_load_toolbars (priv->toolbars_model, EOM_DATA_DIR "/eom-toolbar.xml"); - egg_toolbars_model_set_flags (app->toolbars_model, 0, + egg_toolbars_model_set_flags (priv->toolbars_model, 0, EGG_TB_MODEL_NOT_REMOVABLE); } diff --git a/src/eom-application.h b/src/eom-application.h index 01e8887..f3913ba 100644 --- a/src/eom-application.h +++ b/src/eom-application.h @@ -25,14 +25,12 @@ #ifndef __EOM_APPLICATION_H__ #define __EOM_APPLICATION_H__ -#include "eom-window.h" -#include "eom-plugin-engine.h" -#include "egg-toolbars-model.h" - #include <glib.h> #include <glib-object.h> #include <libpeas/peas-extension-set.h> +#include <gtk/gtk.h> +#include "eom-window.h" G_BEGIN_DECLS @@ -52,14 +50,7 @@ typedef struct _EomApplicationPrivate EomApplicationPrivate; struct _EomApplication { GtkApplication base_instance; - EggToolbarsModel *toolbars_model; - gchar *toolbars_file; - - EomPluginEngine *plugin_engine; - - EomStartupFlags flags; - - PeasExtensionSet *extensions; + EomApplicationPrivate *priv; }; struct _EomApplicationClass { @@ -93,12 +84,6 @@ gboolean eom_application_open_uris (EomApplication *applicati EomStartupFlags flags, GError **error); -EggToolbarsModel *eom_application_get_toolbars_model (EomApplication *application); - -void eom_application_save_toolbars_model (EomApplication *application); - -void eom_application_reset_toolbars_model (EomApplication *app); - G_END_DECLS #endif /* __EOM_APPLICATION_H__ */ diff --git a/src/eom-window.c b/src/eom-window.c index 1ac7365..787c116 100644 --- a/src/eom-window.c +++ b/src/eom-window.c @@ -44,6 +44,7 @@ #include "eom-print.h" #include "eom-error-message-area.h" #include "eom-application.h" +#include "eom-application-internal.h" #include "eom-thumb-nav.h" #include "eom-config-keys.h" #include "eom-job-queue.h" @@ -4664,12 +4665,12 @@ eom_window_dispose (GObject *object) window = EOM_WINDOW (object); priv = window->priv; - peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->plugin_engine)); + peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)); if (priv->extensions != NULL) { g_object_unref (priv->extensions); priv->extensions = NULL; - peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->plugin_engine)); + peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)); } if (priv->page_setup != NULL) { @@ -4789,7 +4790,7 @@ eom_window_dispose (GObject *object) priv->last_save_as_folder = NULL; } - peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->plugin_engine)); + peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)); G_OBJECT_CLASS (eom_window_parent_class)->dispose (object); } @@ -5127,7 +5128,7 @@ eom_window_constructor (GType type, eom_window_construct_ui (EOM_WINDOW (object)); - priv->extensions = peas_extension_set_new (PEAS_ENGINE (EOM_APP->plugin_engine), + priv->extensions = peas_extension_set_new (PEAS_ENGINE (EOM_APP->priv->plugin_engine), EOM_TYPE_WINDOW_ACTIVATABLE, "window", EOM_WINDOW (object), NULL); @@ -35,6 +35,7 @@ #include "eom-thumbnail.h" #include "eom-job-queue.h" #include "eom-application.h" +#include "eom-application-internal.h" #include "eom-util.h" #include <string.h> @@ -161,7 +162,7 @@ main (int argc, char **argv) gtk_window_set_default_icon_name ("eom"); g_set_application_name (_("Eye of MATE Image Viewer")); - EOM_APP->flags = flags; + EOM_APP->priv->flags = flags; if (force_new_instance) { GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOM_APP)); app_flags |= G_APPLICATION_NON_UNIQUE; |