Commit e6470787 authored by Felix Riemann's avatar Felix Riemann
Browse files

EogApplication: Make most members private

This allows plugin usage without installing toolbar editor headers.
parent cdfe77e1
......@@ -18,6 +18,7 @@ MARSHAL_OUTPUT = \
eog-marshal.c
NOINST_H_FILES = \
eog-application-internal.h \
eog-close-confirmation-dialog.h \
eog-config-keys.h \
eog-error-message-area.h \
......
/* Eye Of Gnome - Application Facade (internal)
*
* Copyright (C) 2006-2012 The Free Software Foundation
*
* Author: Lucas Rocha <lucasr@gnome.org>
*
* Based on evince code (shell/ev-application.h) by:
* - Martin Kretzschmar <martink@gnome.org>
*
* 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 __EOG_APPLICATION_INTERNAL_H__
#define __EOG_APPLICATION_INTERNAL_H__
#include <glib.h>
#include <glib-object.h>
#include <libpeas/peas-extension-set.h>
#include "eog-application.h"
#include "eog-plugin-engine.h"
#include "egg-toolbars-model.h"
#include "eog-window.h"
#include "totem-scrsaver.h"
G_BEGIN_DECLS
struct _EogApplicationPrivate {
EggToolbarsModel *toolbars_model;
gchar *toolbars_file;
EogPluginEngine *plugin_engine;
TotemScrsaver *scr_saver;
EogStartupFlags flags;
GSettings *ui_settings;
PeasExtensionSet *extensions;
};
EggToolbarsModel *eog_application_get_toolbars_model (EogApplication *application);
void eog_application_save_toolbars_model (EogApplication *application);
void eog_application_reset_toolbars_model (EogApplication *app);
void eog_application_screensaver_enable (EogApplication *application);
void eog_application_screensaver_disable (EogApplication *application);
G_END_DECLS
#endif /* __EOG_APPLICATION_INTERNAL_H__ */
......@@ -32,6 +32,7 @@
#include "eog-window.h"
#include "eog-application.h"
#include "eog-application-activatable.h"
#include "eog-application-internal.h"
#include "eog-util.h"
#include "totem-scrsaver.h"
......@@ -165,6 +166,7 @@ _settings_map_set_variant (const GValue *value,
static void
eog_application_init_app_menu (EogApplication *application)
{
EogApplicationPrivate *priv = application->priv;
GtkBuilder *builder;
GError *error = NULL;
GAction *action;
......@@ -187,7 +189,7 @@ eog_application_init_app_menu (EogApplication *application)
action = g_action_map_lookup_action (G_ACTION_MAP (application),
"view-gallery");
g_settings_bind_with_mapping (application->ui_settings,
g_settings_bind_with_mapping (priv->ui_settings,
EOG_CONF_UI_IMAGE_GALLERY, action,
"state", G_SETTINGS_BIND_DEFAULT,
_settings_map_get_bool_variant,
......@@ -196,7 +198,7 @@ eog_application_init_app_menu (EogApplication *application)
action = g_action_map_lookup_action (G_ACTION_MAP (application),
"toolbar");
g_settings_bind_with_mapping (application->ui_settings,
g_settings_bind_with_mapping (priv->ui_settings,
EOG_CONF_UI_TOOLBAR, action, "state",
G_SETTINGS_BIND_DEFAULT,
_settings_map_get_bool_variant,
......@@ -204,7 +206,7 @@ eog_application_init_app_menu (EogApplication *application)
NULL, NULL);
action = g_action_map_lookup_action (G_ACTION_MAP (application),
"view-sidebar");
g_settings_bind_with_mapping (application->ui_settings,
g_settings_bind_with_mapping (priv->ui_settings,
EOG_CONF_UI_SIDEBAR, action, "state",
G_SETTINGS_BIND_DEFAULT,
_settings_map_get_bool_variant,
......@@ -212,7 +214,7 @@ eog_application_init_app_menu (EogApplication *application)
NULL, NULL);
action = g_action_map_lookup_action (G_ACTION_MAP (application),
"view-statusbar");
g_settings_bind_with_mapping (application->ui_settings,
g_settings_bind_with_mapping (priv->ui_settings,
EOG_CONF_UI_STATUSBAR, action, "state",
G_SETTINGS_BIND_DEFAULT,
_settings_map_get_bool_variant,
......@@ -235,7 +237,7 @@ eog_application_activate (GApplication *application)
{
eog_application_open_window (EOG_APPLICATION (application),
GDK_CURRENT_TIME,
EOG_APPLICATION (application)->flags,
EOG_APPLICATION (application)->priv->flags,
NULL);
}
......@@ -252,7 +254,7 @@ eog_application_open (GApplication *application,
eog_application_open_file_list (EOG_APPLICATION (application),
list, GDK_CURRENT_TIME,
EOG_APPLICATION (application)->flags,
EOG_APPLICATION (application)->priv->flags,
NULL);
}
......@@ -260,22 +262,23 @@ static void
eog_application_finalize (GObject *object)
{
EogApplication *application = EOG_APPLICATION (object);
EogApplicationPrivate *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;
}
g_clear_object (&application->ui_settings);
g_clear_object (&priv->ui_settings);
eog_application_save_accelerators ();
}
......@@ -289,10 +292,10 @@ eog_application_add_platform_data (GApplication *application,
G_APPLICATION_CLASS (eog_application_parent_class)->add_platform_data (application,
builder);
if (app->flags) {
if (app->priv->flags) {
g_variant_builder_add (builder, "{sv}",
"eog-application-startup-flags",
g_variant_new_byte (app->flags));
g_variant_new_byte (app->priv->flags));
}
}
......@@ -304,11 +307,11 @@ eog_application_before_emit (GApplication *application,
const gchar *key;
GVariant *value;
EOG_APPLICATION (application)->flags = 0;
EOG_APPLICATION (application)->priv->flags = 0;
g_variant_iter_init (&iter, platform_data);
while (g_variant_iter_loop (&iter, "{&sv}", &key, &value)) {
if (strcmp (key, "eog-application-startup-flags") == 0) {
EOG_APPLICATION (application)->flags = g_variant_get_byte (value);
EOG_APPLICATION (application)->priv->flags = g_variant_get_byte (value);
}
}
......@@ -322,6 +325,9 @@ eog_application_class_init (EogApplicationClass *eog_application_class)
GApplicationClass *application_class;
GObjectClass *object_class;
g_type_class_add_private (eog_application_class,
sizeof (EogApplicationPrivate));
application_class = (GApplicationClass *) eog_application_class;
object_class = (GObjectClass *) eog_application_class;
......@@ -355,44 +361,48 @@ on_extension_removed (PeasExtensionSet *set,
static void
eog_application_init (EogApplication *eog_application)
{
EogApplicationPrivate *priv;
const gchar *dot_dir = eog_util_dot_dir ();
eog_session_init (eog_application);
eog_application->toolbars_model = egg_toolbars_model_new ();
eog_application->plugin_engine = eog_plugin_engine_new ();
eog_application->flags = 0;
eog_application->priv = EOG_APPLICATION_GET_PRIVATE (eog_application);
priv = eog_application->priv;
priv->toolbars_model = egg_toolbars_model_new ();
priv->plugin_engine = eog_plugin_engine_new ();
priv->flags = 0;
eog_application->ui_settings = g_settings_new (EOG_CONF_UI);
priv->ui_settings = g_settings_new (EOG_CONF_UI);
egg_toolbars_model_load_names (eog_application->toolbars_model,
egg_toolbars_model_load_names (priv->toolbars_model,
EOG_DATA_DIR "/eog-toolbar.xml");
if (G_LIKELY (dot_dir != NULL))
eog_application->toolbars_file = g_build_filename
priv->toolbars_file = g_build_filename
(dot_dir, "eog_toolbar.xml", NULL);
if (!dot_dir || !egg_toolbars_model_load_toolbars (eog_application->toolbars_model,
eog_application->toolbars_file)) {
if (!dot_dir || !egg_toolbars_model_load_toolbars (priv->toolbars_model,
priv->toolbars_file)) {
egg_toolbars_model_load_toolbars (eog_application->toolbars_model,
egg_toolbars_model_load_toolbars (priv->toolbars_model,
EOG_DATA_DIR "/eog-toolbar.xml");
}
egg_toolbars_model_set_flags (eog_application->toolbars_model, 0,
egg_toolbars_model_set_flags (priv->toolbars_model, 0,
EGG_TB_MODEL_NOT_REMOVABLE);
eog_application_load_accelerators ();
eog_application->extensions = peas_extension_set_new (
PEAS_ENGINE (eog_application->plugin_engine),
priv->extensions = peas_extension_set_new (
PEAS_ENGINE (priv->plugin_engine),
EOG_TYPE_APPLICATION_ACTIVATABLE,
"app", EOG_APPLICATION (eog_application),
NULL);
peas_extension_set_call (eog_application->extensions, "activate");
g_signal_connect (eog_application->extensions, "extension-added",
peas_extension_set_call (priv->extensions, "activate");
g_signal_connect (priv->extensions, "extension-added",
G_CALLBACK (on_extension_added), eog_application);
g_signal_connect (eog_application->extensions, "extension-removed",
g_signal_connect (priv->extensions, "extension-removed",
G_CALLBACK (on_extension_removed), eog_application);
}
......@@ -678,7 +688,7 @@ eog_application_get_toolbars_model (EogApplication *application)
{
g_return_val_if_fail (EOG_IS_APPLICATION (application), NULL);
return application->toolbars_model;
return application->priv->toolbars_model;
}
/**
......@@ -690,9 +700,9 @@ eog_application_get_toolbars_model (EogApplication *application)
void
eog_application_save_toolbars_model (EogApplication *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");
}
......@@ -705,17 +715,20 @@ eog_application_save_toolbars_model (EogApplication *application)
void
eog_application_reset_toolbars_model (EogApplication *app)
{
EogApplicationPrivate *priv;
g_return_if_fail (EOG_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,
EOG_DATA_DIR "/eog-toolbar.xml");
egg_toolbars_model_load_toolbars (app->toolbars_model,
egg_toolbars_model_load_toolbars (priv->toolbars_model,
EOG_DATA_DIR "/eog-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);
}
......@@ -729,8 +742,8 @@ eog_application_reset_toolbars_model (EogApplication *app)
void
eog_application_screensaver_enable (EogApplication *application)
{
if (application->scr_saver)
totem_scrsaver_enable (application->scr_saver);
if (application->priv->scr_saver)
totem_scrsaver_enable (application->priv->scr_saver);
}
/**
......@@ -743,8 +756,8 @@ eog_application_screensaver_enable (EogApplication *application)
void
eog_application_screensaver_disable (EogApplication *application)
{
if (application->scr_saver)
totem_scrsaver_disable (application->scr_saver);
if (application->priv->scr_saver)
totem_scrsaver_disable (application->priv->scr_saver);
}
static void
......
......@@ -25,16 +25,12 @@
#ifndef __EOG_APPLICATION_H__
#define __EOG_APPLICATION_H__
#include "eog-window.h"
#include "egg-toolbars-model.h"
#include "eog-plugin-engine.h"
#include "totem-scrsaver.h"
#include <glib.h>
#include <glib-object.h>
#include <libpeas/peas-extension-set.h>
#include <gtk/gtk.h>
#include "eog-window.h"
G_BEGIN_DECLS
......@@ -54,16 +50,7 @@ typedef struct _EogApplicationPrivate EogApplicationPrivate;
struct _EogApplication {
GtkApplication base_instance;
EggToolbarsModel *toolbars_model;
gchar *toolbars_file;
EogPluginEngine *plugin_engine;
TotemScrsaver *scr_saver;
EogStartupFlags flags;
GSettings *ui_settings;
PeasExtensionSet *extensions;
EogApplicationPrivate *priv;
};
struct _EogApplicationClass {
......@@ -97,12 +84,6 @@ gboolean eog_application_open_uris (EogApplication *applicati
EogStartupFlags flags,
GError **error);
EggToolbarsModel *eog_application_get_toolbars_model (EogApplication *application);
void eog_application_save_toolbars_model (EogApplication *application);
void eog_application_reset_toolbars_model (EogApplication *app);
void eog_application_screensaver_enable (EogApplication *application);
void eog_application_screensaver_disable (EogApplication *application);
......
......@@ -44,6 +44,7 @@
#include "eog-print.h"
#include "eog-error-message-area.h"
#include "eog-application.h"
#include "eog-application-internal.h"
#include "eog-thumb-nav.h"
#include "eog-config-keys.h"
#include "eog-job-queue.h"
......@@ -4738,12 +4739,12 @@ eog_window_dispose (GObject *object)
window = EOG_WINDOW (object);
priv = window->priv;
peas_engine_garbage_collect (PEAS_ENGINE (EOG_APP->plugin_engine));
peas_engine_garbage_collect (PEAS_ENGINE (EOG_APP->priv->plugin_engine));
if (priv->extensions != NULL) {
g_object_unref (priv->extensions);
priv->extensions = NULL;
peas_engine_garbage_collect (PEAS_ENGINE (EOG_APP->plugin_engine));
peas_engine_garbage_collect (PEAS_ENGINE (EOG_APP->priv->plugin_engine));
}
if (priv->store != NULL) {
......@@ -4855,7 +4856,7 @@ eog_window_dispose (GObject *object)
priv->page_setup = NULL;
}
peas_engine_garbage_collect (PEAS_ENGINE (EOG_APP->plugin_engine));
peas_engine_garbage_collect (PEAS_ENGINE (EOG_APP->priv->plugin_engine));
G_OBJECT_CLASS (eog_window_parent_class)->dispose (object);
}
......@@ -5193,7 +5194,7 @@ eog_window_constructor (GType type,
eog_window_construct_ui (EOG_WINDOW (object));
priv->extensions = peas_extension_set_new (PEAS_ENGINE (EOG_APP->plugin_engine),
priv->extensions = peas_extension_set_new (PEAS_ENGINE (EOG_APP->priv->plugin_engine),
EOG_TYPE_WINDOW_ACTIVATABLE,
"window",
EOG_WINDOW (object), NULL);
......
......@@ -35,6 +35,7 @@
#include "eog-thumbnail.h"
#include "eog-job-queue.h"
#include "eog-application.h"
#include "eog-application-internal.h"
#include "eog-plugin-engine.h"
#include "eog-util.h"
......@@ -180,7 +181,7 @@ main (int argc, char **argv)
"gtk-application-prefer-dark-theme", TRUE,
NULL);
EOG_APP->flags = flags;
EOG_APP->priv->flags = flags;
if (force_new_instance) {
GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOG_APP));
app_flags |= G_APPLICATION_NON_UNIQUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment