summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorClaudio Saavedra <[email protected]>2011-06-09 22:33:30 +0300
committerraveit65 <[email protected]>2018-07-08 12:19:44 +0200
commit20d704b7b4f2560ee27cc9be25359107ceb4a14b (patch)
tree202e9a1335722c7f288019972b4e4afe5ae0f98a /src/main.c
parent63a6313edf251919487047f47ad1f08228e7ba8d (diff)
downloadeom-20d704b7b4f2560ee27cc9be25359107ceb4a14b.tar.bz2
eom-20d704b7b4f2560ee27cc9be25359107ceb4a14b.tar.xz
Port EomApplication to GtkApplication
This removes the direct dependency on dbus and makes use of the GApplication/GtkApplication facilities for uniqueness and activation. Bump the glib requirement to 2.29.4, since we need G_APPLICATION_NON_UNIQUE. https://bugzilla.gnome.org/show_bug.cgi?id=622876 origin commit: https://gitlab.gnome.org/GNOME/eog/commit/3d39587 Enable TotemScreensaver unconditionally It uses GDBus instead of libdbus now. It can be enabled even if libdbus is not available as GDBus/GIO is always present. origin commit: https://gitlab.gnome.org/GNOME/eog/commit/4c32882
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c114
1 files changed, 9 insertions, 105 deletions
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);