summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am11
-rw-r--r--src/eom-application.c223
-rw-r--r--src/eom-application.h21
-rw-r--r--src/eom-util.c2
-rw-r--r--src/eom-util.h2
-rw-r--r--src/eom-window.c25
-rw-r--r--src/main.c114
7 files changed, 100 insertions, 298 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c42c0de..66db511 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -191,17 +191,6 @@ EXTRA_DIST = \
eom-enum-types.c.template \
eom-marshal.list
-if HAVE_DBUS
-
-BUILT_SOURCES += eom-application-service.h
-
-EXTRA_DIST += eom-application-service.xml
-
-eom-application-service.h: eom-application-service.xml
- $(AM_V_GEN)dbus-binding-tool --prefix=eom_application --mode=glib-server --output=eom-application-service.h $<
-
-endif
-
CLEANFILES = $(BUILT_SOURCES)
if HAVE_INTROSPECTION
diff --git a/src/eom-application.c b/src/eom-application.c
index 1515d70..dbf1cb1 100644
--- a/src/eom-application.c
+++ b/src/eom-application.c
@@ -32,9 +32,7 @@
#include "eom-application.h"
#include "eom-util.h"
-#ifdef HAVE_DBUS
#include "totem-scrsaver.h"
-#endif
#include <string.h>
#include <glib.h>
@@ -43,12 +41,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#ifdef HAVE_DBUS
-#include "eom-application-service.h"
-#include <dbus/dbus-glib-bindings.h>
-
#define APPLICATION_SERVICE_NAME "org.mate.eom.ApplicationService"
-#endif
static void eom_application_load_accelerators (void);
static void eom_application_save_accelerators (void);
@@ -56,81 +49,103 @@ static void eom_application_save_accelerators (void);
#define EOM_APPLICATION_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EOM_TYPE_APPLICATION, EomApplicationPrivate))
-G_DEFINE_TYPE (EomApplication, eom_application, G_TYPE_OBJECT);
+G_DEFINE_TYPE (EomApplication, eom_application, GTK_TYPE_APPLICATION);
-#ifdef HAVE_DBUS
+static void
+eom_application_activate (GApplication *application)
+{
+ eom_application_open_window (EOM_APPLICATION (application),
+ GDK_CURRENT_TIME,
+ EOM_APPLICATION (application)->flags,
+ NULL);
+}
-/**
- * eom_application_register_service:
- * @application: An #EomApplication.
- *
- * Registers #EomApplication<!-- -->'s DBus service, to allow
- * remote calls. If the DBus service is already registered,
- * or there is any other connection error, returns %FALSE.
- *
- * Returns: %TRUE if the service was registered succesfully. %FALSE
- * otherwise.
- **/
-gboolean
-eom_application_register_service (EomApplication *application)
+static void
+eom_application_open (GApplication *application,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
{
- static DBusGConnection *connection = NULL;
- DBusGProxy *driver_proxy;
- GError *err = NULL;
- guint request_name_result;
-
- if (connection) {
- g_warning ("Service already registered.");
- return FALSE;
- }
+ GSList *list = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_STARTER, &err);
+ while (n_files--)
+ list = g_slist_prepend (list, files[n_files]);
- if (connection == NULL) {
- g_warning ("Service registration failed.");
- g_error_free (err);
+ eom_application_open_file_list (EOM_APPLICATION (application),
+ list, GDK_CURRENT_TIME,
+ EOM_APPLICATION (application)->flags,
+ NULL);
+}
- return FALSE;
- }
+static void
+eom_application_finalize (GObject *object)
+{
+ EomApplication *application = EOM_APPLICATION (object);
- driver_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- if (!org_freedesktop_DBus_request_name (driver_proxy,
- APPLICATION_SERVICE_NAME,
- DBUS_NAME_FLAG_DO_NOT_QUEUE,
- &request_name_result, &err)) {
- g_warning ("Service registration failed.");
- g_clear_error (&err);
+ if (application->toolbars_model) {
+ g_object_unref (application->toolbars_model);
+ application->toolbars_model = NULL;
+ g_free (application->toolbars_file);
+ application->toolbars_file = NULL;
}
-
- g_object_unref (driver_proxy);
-
- if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS) {
- return FALSE;
+ if (application->plugin_engine) {
+ g_object_unref (application->plugin_engine);
+ application->plugin_engine = NULL;
}
+ eom_application_save_accelerators ();
+}
- dbus_g_object_type_install_info (EOM_TYPE_APPLICATION,
- &dbus_glib_eom_application_object_info);
+static void
+eom_application_add_platform_data (GApplication *application,
+ GVariantBuilder *builder)
+{
+ EomApplication *app = EOM_APPLICATION (application);
- dbus_g_connection_register_g_object (connection,
- "/org/mate/eom/Eom",
- G_OBJECT (application));
+ G_APPLICATION_CLASS (eom_application_parent_class)->add_platform_data (application,
+ builder);
- application->scr_saver = totem_scrsaver_new ();
- g_object_set (application->scr_saver,
- "reason", _("Running in fullscreen mode"),
- NULL);
+ if (app->flags) {
+ g_variant_builder_add (builder, "{sv}",
+ "eom-application-startup-flags",
+ g_variant_new_byte (app->flags));
+ }
+}
- return TRUE;
+static void
+eom_application_before_emit (GApplication *application,
+ GVariant *platform_data)
+{
+ GVariantIter iter;
+ const gchar *key;
+ GVariant *value;
+
+ EOM_APPLICATION (application)->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);
+ }
+ }
+
+ G_APPLICATION_CLASS (eom_application_parent_class)->before_emit (application,
+ platform_data);
}
-#endif /* ENABLE_DBUS */
static void
eom_application_class_init (EomApplicationClass *eom_application_class)
{
+ GApplicationClass *application_class;
+ GObjectClass *object_class;
+
+ application_class = (GApplicationClass *) eom_application_class;
+ object_class = (GObjectClass *) eom_application_class;
+
+ object_class->finalize = eom_application_finalize;
+
+ application_class->activate = eom_application_activate;
+ application_class->open = eom_application_open;
+ application_class->add_platform_data = eom_application_add_platform_data;
+ application_class->before_emit = eom_application_before_emit;
}
static void
@@ -140,9 +155,9 @@ eom_application_init (EomApplication *eom_application)
eom_session_init (eom_application);
- eom_application->plugin_engine = eom_plugin_engine_new ();
-
eom_application->toolbars_model = egg_toolbars_model_new ();
+ eom_application->plugin_engine = eom_plugin_engine_new ();
+ eom_application->flags = 0;
egg_toolbars_model_load_names (eom_application->toolbars_model,
EOM_DATA_DIR "/eom-toolbar.xml");
@@ -178,7 +193,10 @@ eom_application_get_instance (void)
static EomApplication *instance;
if (!instance) {
- instance = EOM_APPLICATION (g_object_new (EOM_TYPE_APPLICATION, NULL));
+ instance = EOM_APPLICATION (g_object_new (EOM_TYPE_APPLICATION,
+ "application-id", APPLICATION_SERVICE_NAME,
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL));
}
return instance;
@@ -193,7 +211,7 @@ eom_application_get_empty_window (EomApplication *application)
g_return_val_if_fail (EOM_IS_APPLICATION (application), NULL);
- windows = eom_application_get_windows (application);
+ windows = gtk_application_get_windows (GTK_APPLICATION (application));
for (l = windows; l != NULL; l = l->next) {
EomWindow *window = EOM_WINDOW (l->data);
@@ -204,8 +222,6 @@ eom_application_get_empty_window (EomApplication *application)
}
}
- g_list_free (windows);
-
return empty_window;
}
@@ -386,7 +402,6 @@ eom_application_open_uri_list (EomApplication *application,
error);
}
-#ifdef HAVE_DBUS
/**
* eom_application_open_uris:
* @application: an #EomApplication
@@ -415,70 +430,6 @@ eom_application_open_uris (EomApplication *application,
return eom_application_open_file_list (application, file_list, timestamp,
flags, error);
}
-#endif
-
-/**
- * eom_application_shutdown:
- * @application: An #EomApplication.
- *
- * Takes care of shutting down the Eye of MATE, and quits.
- **/
-void
-eom_application_shutdown (EomApplication *application)
-{
- g_return_if_fail (EOM_IS_APPLICATION (application));
-
- if (application->toolbars_model) {
- g_object_unref (application->toolbars_model);
- application->toolbars_model = NULL;
-
- g_free (application->toolbars_file);
- application->toolbars_file = NULL;
- }
-
- if (application->plugin_engine) {
- g_object_unref (application->plugin_engine);
- application->plugin_engine = NULL;
- }
-
- eom_application_save_accelerators ();
-
- g_object_unref (application);
-
- gtk_main_quit ();
-}
-
-/**
- * eom_application_get_windows:
- * @application: An #EomApplication.
- *
- * Gets the list of existing #EomApplication<!-- -->s. The windows
- * in this list are not individually referenced, you need to keep
- * your own references if you want to perform actions that may destroy
- * them.
- *
- * Returns: (element-type EomWindow) (transfer container): A new list of #EomWindow<!-- -->s.
- **/
-GList *
-eom_application_get_windows (EomApplication *application)
-{
- GList *l, *toplevels;
- GList *windows = NULL;
-
- g_return_val_if_fail (EOM_IS_APPLICATION (application), NULL);
-
- toplevels = gtk_window_list_toplevels ();
-
- for (l = toplevels; l != NULL; l = l->next) {
- if (EOM_IS_WINDOW (l->data)) {
- windows = g_list_append (windows, l->data);
- }
- }
-
- g_list_free (toplevels);
-
- return windows;
-}
/**
* eom_application_get_toolbars_model:
@@ -534,7 +485,6 @@ eom_application_reset_toolbars_model (EomApplication *app)
EGG_TB_MODEL_NOT_REMOVABLE);
}
-#ifdef HAVE_DBUS
/**
* eom_application_screensaver_enable:
* @application: an #EomApplication.
@@ -562,7 +512,6 @@ eom_application_screensaver_disable (EomApplication *application)
if (application->scr_saver)
totem_scrsaver_disable (application->scr_saver);
}
-#endif
static void
eom_application_load_accelerators (void)
diff --git a/src/eom-application.h b/src/eom-application.h
index dcf4cb8..7741d50 100644
--- a/src/eom-application.h
+++ b/src/eom-application.h
@@ -29,9 +29,7 @@
#include "eom-plugin-engine.h"
#include "egg-toolbars-model.h"
-#ifdef HAVE_DBUS
#include "totem-scrsaver.h"
-#endif
#include <glib.h>
#include <glib-object.h>
@@ -52,32 +50,25 @@ typedef struct _EomApplicationPrivate EomApplicationPrivate;
#define EOM_APP (eom_application_get_instance ())
struct _EomApplication {
- GObject base_instance;
+ GtkApplication base_instance;
EggToolbarsModel *toolbars_model;
gchar *toolbars_file;
EomPluginEngine *plugin_engine;
-#ifdef HAVE_DBUS
TotemScrsaver *scr_saver;
-#endif
+ EomStartupFlags flags;
};
struct _EomApplicationClass {
- GObjectClass parent_class;
+ GtkApplicationClass parent_class;
};
GType eom_application_get_type (void) G_GNUC_CONST;
EomApplication *eom_application_get_instance (void);
-#ifdef HAVE_DBUS
-gboolean eom_application_register_service (EomApplication *application);
-#endif
-
-void eom_application_shutdown (EomApplication *application);
-
gboolean eom_application_open_window (EomApplication *application,
guint timestamp,
EomStartupFlags flags,
@@ -95,15 +86,11 @@ gboolean eom_application_open_file_list (EomApplication *applicati
EomStartupFlags flags,
GError **error);
-#ifdef HAVE_DBUS
gboolean eom_application_open_uris (EomApplication *application,
gchar **uris,
guint timestamp,
EomStartupFlags flags,
GError **error);
-#endif
-
-GList *eom_application_get_windows (EomApplication *application);
EggToolbarsModel *eom_application_get_toolbars_model (EomApplication *application);
@@ -111,11 +98,9 @@ void eom_application_save_toolbars_model (EomApplication *applicati
void eom_application_reset_toolbars_model (EomApplication *app);
-#ifdef HAVE_DBUS
void eom_application_screensaver_enable (EomApplication *application);
void eom_application_screensaver_disable (EomApplication *application);
-#endif
G_END_DECLS
diff --git a/src/eom-util.c b/src/eom-util.c
index 33bd36f..bfffbcf 100644
--- a/src/eom-util.c
+++ b/src/eom-util.c
@@ -157,7 +157,6 @@ eom_util_string_list_to_file_list (GSList *string_list)
return g_slist_reverse (file_list);
}
-#ifdef HAVE_DBUS
GSList*
eom_util_strings_to_file_list (gchar **strings)
{
@@ -171,7 +170,6 @@ eom_util_strings_to_file_list (gchar **strings)
return g_slist_reverse (file_list);
}
-#endif
GSList*
eom_util_string_array_to_list (const gchar **files, gboolean create_uri)
diff --git a/src/eom-util.h b/src/eom-util.h
index 3d0f40c..30c9658 100644
--- a/src/eom-util.h
+++ b/src/eom-util.h
@@ -42,10 +42,8 @@ GSList *eom_util_parse_uri_string_list_to_file_list (const gchar *uri_list);
G_GNUC_INTERNAL
GSList *eom_util_string_list_to_file_list (GSList *string_list);
-#ifdef HAVE_DBUS
G_GNUC_INTERNAL
GSList *eom_util_strings_to_file_list (gchar **strings);
-#endif
G_GNUC_INTERNAL
GSList *eom_util_string_array_to_list (const gchar **files,
diff --git a/src/eom-window.c b/src/eom-window.c
index 1fb2e60..b8ca305 100644
--- a/src/eom-window.c
+++ b/src/eom-window.c
@@ -2057,9 +2057,7 @@ eom_window_run_fullscreen (EomWindow *window, gboolean slideshow)
gtk_window_fullscreen (GTK_WINDOW (window));
eom_window_update_fullscreen_popup (window);
-#ifdef HAVE_DBUS
eom_application_screensaver_disable (EOM_APP);
-#endif
/* Update both actions as we could've already been in one those modes */
eom_window_update_slideshow_action (window);
@@ -2124,9 +2122,7 @@ eom_window_stop_fullscreen (EomWindow *window, gboolean slideshow)
eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (priv->view));
-#ifdef HAVE_DBUS
eom_application_screensaver_enable (EOM_APP);
-#endif
}
static void
@@ -4572,6 +4568,8 @@ eom_window_init (EomWindow *window)
window->priv->save_disabled = FALSE;
window->priv->page_setup = NULL;
+
+ gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (EOM_APP));
}
static void
@@ -4717,24 +4715,6 @@ eom_window_dispose (GObject *object)
G_OBJECT_CLASS (eom_window_parent_class)->dispose (object);
}
-static void
-eom_window_finalize (GObject *object)
-{
- GList *windows = eom_application_get_windows (EOM_APP);
-
- g_return_if_fail (EOM_IS_WINDOW (object));
-
- eom_debug (DEBUG_WINDOW);
-
- if (windows == NULL) {
- eom_application_shutdown (EOM_APP);
- } else {
- g_list_free (windows);
- }
-
- G_OBJECT_CLASS (eom_window_parent_class)->finalize (object);
-}
-
static gint
eom_window_delete (GtkWidget *widget, GdkEventAny *event)
{
@@ -5090,7 +5070,6 @@ eom_window_class_init (EomWindowClass *class)
g_object_class->constructor = eom_window_constructor;
g_object_class->dispose = eom_window_dispose;
- g_object_class->finalize = eom_window_finalize;
g_object_class->set_property = eom_window_set_property;
g_object_class->get_property = eom_window_get_property;
diff --git a/src/main.c b/src/main.c
index d5c5079..bafaaf3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,10 +26,6 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef HAVE_DBUS
-#include <dbus/dbus-glib-bindings.h>
-#include <gdk/gdkx.h>
-#endif
#ifdef HAVE_INTROSPECTION
#include <girepository.h>
#endif
@@ -56,9 +52,7 @@ static EomStartupFlags flags;
static gboolean fullscreen = FALSE;
static gboolean slide_show = FALSE;
static gboolean disable_collection = FALSE;
-#if HAVE_DBUS
static gboolean force_new_instance = FALSE;
-#endif
static gchar **startup_files = NULL;
static gboolean
@@ -77,12 +71,9 @@ static const GOptionEntry goption_options[] =
{ "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen, N_("Open in fullscreen mode"), NULL },
{ "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection"), NULL },
{ "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode"), NULL },
-#if HAVE_DBUS
{ "new-instance", 'n', 0, G_OPTION_ARG_NONE, &force_new_instance, N_("Start a new instance instead of reusing an existing one"), NULL },
-#endif
{ "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
_print_version_and_exit, N_("Show the application's version"), NULL},
- { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &startup_files, NULL, N_("[FILE…]") },
{ NULL }
};
@@ -99,90 +90,6 @@ set_startup_flags (void)
flags |= EOM_STARTUP_SLIDE_SHOW;
}
-static void
-load_files (void)
-{
- GSList *files = NULL;
-
- files = eom_util_string_array_to_list ((const gchar **) startup_files, TRUE);
-
- eom_application_open_uri_list (EOM_APP,
- files,
- GDK_CURRENT_TIME,
- flags,
- NULL);
-
- g_slist_foreach (files, (GFunc) g_free, NULL);
- g_slist_free (files);
-}
-
-#ifdef HAVE_DBUS
-static gboolean
-load_files_remote (void)
-{
- GError *error = NULL;
- DBusGConnection *connection;
- DBusGProxy *remote_object;
- gboolean result = TRUE;
- GdkDisplay *display;
- guint32 timestamp;
- gchar **files;
-
- display = gdk_display_get_default ();
-
- timestamp = gdk_x11_display_get_user_time (display);
- connection = dbus_g_bus_get (DBUS_BUS_STARTER, &error);
-
- if (connection == NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
-
- return FALSE;
- }
-
- files = eom_util_string_array_make_absolute (startup_files);
-
- remote_object = dbus_g_proxy_new_for_name (connection,
- "org.mate.eom.ApplicationService",
- "/org/mate/eom/Eom",
- "org.mate.eom.Application");
-
- if (!files) {
- if (!dbus_g_proxy_call (remote_object, "OpenWindow", &error,
- G_TYPE_UINT, timestamp,
- G_TYPE_UCHAR, flags,
- G_TYPE_INVALID,
- G_TYPE_INVALID)) {
- g_warning ("%s", error->message);
- g_clear_error (&error);
-
- result = FALSE;
- }
- } else {
- if (!dbus_g_proxy_call (remote_object, "OpenUris", &error,
- G_TYPE_STRV, files,
- G_TYPE_UINT, timestamp,
- G_TYPE_UCHAR, flags,
- G_TYPE_INVALID,
- G_TYPE_INVALID)) {
- g_warning ("%s", error->message);
- g_clear_error (&error);
-
- result = FALSE;
- }
-
- g_strfreev (files);
- }
-
- g_object_unref (remote_object);
- dbus_g_connection_unref (connection);
-
- gdk_notify_startup_complete ();
-
- return result;
-}
-#endif /* HAVE_DBUS */
-
int
main (int argc, char **argv)
{
@@ -196,7 +103,7 @@ main (int argc, char **argv)
gdk_set_allowed_backends ("x11");
- ctx = g_option_context_new (NULL);
+ ctx = g_option_context_new (_("[FILE…]"));
g_option_context_add_main_entries (ctx, goption_options, PACKAGE);
/* Option groups are free'd together with the context
* Using gtk_get_option_group here initializes gtk during parsing */
@@ -224,15 +131,6 @@ main (int argc, char **argv)
set_startup_flags ();
-#ifdef HAVE_DBUS
- if (!force_new_instance &&
- !eom_application_register_service (EOM_APP)) {
- if (load_files_remote ()) {
- return 0;
- }
- }
-#endif /* HAVE_DBUS */
-
#ifdef HAVE_EXEMPI
xmp_init();
#endif
@@ -263,9 +161,15 @@ main (int argc, char **argv)
gtk_window_set_default_icon_name ("eom");
g_set_application_name (_("Eye of MATE Image Viewer"));
- load_files ();
+ EOM_APP->flags = flags;
+ if (force_new_instance) {
+ GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOM_APP));
+ app_flags |= G_APPLICATION_NON_UNIQUE;
+ g_application_set_flags (G_APPLICATION (EOM_APP), app_flags);
+ }
- gtk_main ();
+ g_application_run (G_APPLICATION (EOM_APP), argc, argv);
+ g_object_unref (EOM_APP);
if (startup_files)
g_strfreev (startup_files);