]> www.fi.muni.cz Git - evince.git/commitdiff
Add an _init functions that enabled metadata management at runtime.
authorMarco Pesenti Gritti <mpg@redhat.com>
Thu, 7 Jul 2005 14:57:39 +0000 (14:57 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Thu, 7 Jul 2005 14:57:39 +0000 (14:57 +0000)
2005-07-07  Marco Pesenti Gritti  <mpg@redhat.com>

        * shell/ev-metadata-manager.c: (ev_metadata_manager_init),
        (ev_metadata_manager_get), (ev_metadata_manager_set):
        * shell/ev-metadata-manager.h:

        Add an _init functions that enabled metadata management
        at runtime.

        * shell/ev-window.c: (page_changed_cb),
        (setup_document_from_metadata), (ev_window_setup_document),
        (setup_view_from_metadata), (ev_window_open_uri),
        (ev_window_run_fullscreen), (ev_window_stop_fullscreen),
        (ev_window_run_presentation), (ev_window_stop_presentation),
        (save_sizing_mode), (ev_window_zoom_changed_cb),
        (ev_window_continuous_changed_cb),
        (ev_window_dual_mode_changed_cb), (window_state_event_cb),
        (window_configure_event_cb):

        Remove all ugly metadata define since we deal with it
        at runtime now.

        * shell/main.c: (load_files_remote), (main):

        Add support for dbus cvs head. Hopefully didnt break one
        of the other versions now!

        If we dont get a response from the dbus server just
        give up with it and not enable metadata.

ChangeLog
shell/ev-metadata-manager.c
shell/ev-metadata-manager.h
shell/ev-window.c
shell/main.c

index 06090bc42958937a0b7e54c1c4dc22de29637a95..6d69b82ecc1dcb37e401ace3dd9c24c76cbfcdee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2005-07-07  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * shell/ev-metadata-manager.c: (ev_metadata_manager_init),
+       (ev_metadata_manager_get), (ev_metadata_manager_set):
+       * shell/ev-metadata-manager.h:
+
+       Add an _init functions that enabled metadata management
+       at runtime.
+
+       * shell/ev-window.c: (page_changed_cb),
+       (setup_document_from_metadata), (ev_window_setup_document),
+       (setup_view_from_metadata), (ev_window_open_uri),
+       (ev_window_run_fullscreen), (ev_window_stop_fullscreen),
+       (ev_window_run_presentation), (ev_window_stop_presentation),
+       (save_sizing_mode), (ev_window_zoom_changed_cb),
+       (ev_window_continuous_changed_cb),
+       (ev_window_dual_mode_changed_cb), (window_state_event_cb),
+       (window_configure_event_cb):
+
+       Remove all ugly metadata define since we deal with it
+       at runtime now.
+
+       * shell/main.c: (load_files_remote), (main):
+
+       Add support for dbus cvs head. Hopefully didnt break one
+       of the other versions now!
+
+       If we dont get a response from the dbus server just
+       give up with it and not enable metadata.
+
 2005-07-07  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * Makefile.am:
index 712f124f0b0da0e1603bed37bdf1412b0445bd07..2bbd291580362bd9ab04f33adf2a80cbad2c2bf5 100644 (file)
@@ -87,12 +87,9 @@ item_free (gpointer data)
        g_free (item);
 }
 
-static gboolean
+void
 ev_metadata_manager_init (void)
 {
-       if (ev_metadata_manager != NULL)
-               return TRUE;
-
        ev_metadata_manager = g_new0 (GeditMetadataManager, 1);
 
        ev_metadata_manager->values_loaded = FALSE;
@@ -110,8 +107,6 @@ ev_metadata_manager_init (void)
                                    (GSourceFunc)ev_metadata_manager_save,
                                    NULL,
                                    NULL);
-       
-       return TRUE;
 }
 
 /* This function must be called before exiting ev */
@@ -303,7 +298,7 @@ ev_metadata_manager_get (const gchar *uri,
        g_return_val_if_fail (key != NULL, FALSE);
 
        if (ev_metadata_manager == NULL)
-               ev_metadata_manager_init ();
+               return FALSE;
 
        if (!ev_metadata_manager->values_loaded)
        {
@@ -358,7 +353,7 @@ ev_metadata_manager_set (const gchar  *uri,
        g_return_if_fail (key != NULL);
 
        if (ev_metadata_manager == NULL)
-               ev_metadata_manager_init ();
+               return;
 
        if (!ev_metadata_manager->values_loaded)
        {
index 9934c251de1d9cfa614d88cfe086bd68783df47f..97abb3ec4ad15649b96675a697b92cfa768a5059 100644 (file)
@@ -28,6 +28,7 @@
 
 G_BEGIN_DECLS
 
+void           ev_metadata_manager_init        (void);
 gboolean       ev_metadata_manager_get         (const gchar  *uri,
                                                 const gchar  *key,
                                                 GValue       *value);
index a487c88b7fd63d7bf8c03bc7022e88cd3a6329a5..6dcdc0b7fd386980e0df9ee1e0b867928798d275 100644 (file)
@@ -619,9 +619,7 @@ page_changed_cb (EvPageCache *page_cache,
 {
        update_action_sensitivity (ev_window);
 
-#ifdef ENABLE_METADATA
        ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
-#endif
 }
 
 static void
@@ -635,7 +633,6 @@ update_document_mode (EvWindow *window, EvDocumentMode mode)
        }
 }
 
-#ifdef ENABLE_METADATA
 static void
 setup_document_from_metadata (EvWindow *window)
 {
@@ -649,7 +646,6 @@ setup_document_from_metadata (EvWindow *window)
        }
 
 }
-#endif
 
 static void
 ev_window_setup_document (EvWindow *ev_window)
@@ -696,9 +692,7 @@ ev_window_setup_document (EvWindow *ev_window)
                                                   ev_window->priv->document);
        }
 
-#ifdef ENABLE_METADATA
        setup_document_from_metadata (ev_window);
-#endif
 }
 
 static void
@@ -935,7 +929,6 @@ ev_window_xfer_job_cb  (EvJobXfer *job,
        }               
 }
 
-#ifdef ENABLE_METADATA
 static void
 setup_view_from_metadata (EvWindow *window)
 {
@@ -1016,7 +1009,6 @@ setup_view_from_metadata (EvWindow *window)
                }
        }
 }
-#endif
 
 void
 ev_window_open_uri (EvWindow *ev_window, const char *uri)
@@ -1027,9 +1019,7 @@ ev_window_open_uri (EvWindow *ev_window, const char *uri)
        g_free (ev_window->priv->uri);
        ev_window->priv->uri = g_strdup (uri);
 
-#ifdef ENABLE_METADATA
        setup_view_from_metadata (ev_window);
-#endif
        
        ev_window_clear_jobs (ev_window);
        ev_window_clear_local_uri (ev_window);
@@ -1757,9 +1747,7 @@ ev_window_run_fullscreen (EvWindow *window)
        gtk_window_fullscreen (GTK_WINDOW (window));
        ev_window_update_fullscreen_popup (window);
 
-#ifdef ENABLE_METADATA
        ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", TRUE);
-#endif
 }
 
 static void
@@ -1787,9 +1775,7 @@ ev_window_stop_fullscreen (EvWindow *window)
        gtk_window_unfullscreen (GTK_WINDOW (window));
        update_chrome_visibility (window);
 
-#ifdef ENABLE_METADATA
        ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
-#endif
 }
 
 static void
@@ -1835,9 +1821,7 @@ ev_window_run_presentation (EvWindow *window)
        ev_window_update_presentation_action (window);
        update_chrome_visibility (window);
 
-#ifdef ENABLE_METADATA
        ev_metadata_manager_set_boolean (window->priv->uri, "presentation", TRUE);
-#endif
 }
 
 static void
@@ -1854,9 +1838,7 @@ ev_window_stop_presentation (EvWindow *window)
        ev_window_update_presentation_action (window);
        update_chrome_visibility (window);
 
-#ifdef ENABLE_METADATA
        ev_metadata_manager_set_boolean (window->priv->uri, "presentation", FALSE);
-#endif
 }
 
 static void
@@ -2202,7 +2184,6 @@ update_view_size (EvView *view, EvWindow *window)
 static void
 save_sizing_mode (EvWindow *window)
 {
-#ifdef ENABLE_METADATA
        EvSizingMode mode;
        GEnumValue *enum_value;
 
@@ -2213,7 +2194,6 @@ save_sizing_mode (EvWindow *window)
                ev_metadata_manager_set_string (window->priv->uri, "sizing_mode",
                                                enum_value->value_nick);
        }
-#endif
 }
 
 static void     
@@ -2270,12 +2250,10 @@ ev_window_zoom_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
 {
         update_action_sensitivity (ev_window);
 
-#ifdef ENABLE_METADATA
        if (ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
                ev_metadata_manager_set_double (ev_window->priv->uri, "zoom",
                                                ev_view_get_zoom (view));
        }
-#endif
 }
 
 static void
@@ -2311,10 +2289,8 @@ ev_window_continuous_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_w
 {
        ev_window_update_continuous_action (ev_window);
 
-#ifdef ENABLE_METADATA
        ev_metadata_manager_set_boolean (ev_window->priv->uri, "continuous",
                                         ev_view_get_continuous (EV_VIEW (ev_window->priv->view)));
-#endif
 }
 
 static void     
@@ -2322,10 +2298,8 @@ ev_window_dual_mode_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_wi
 {
        ev_window_update_dual_page_action (ev_window);
 
-#ifdef ENABLE_METADATA
        ev_metadata_manager_set_boolean (ev_window->priv->uri, "dual-page",
                                         ev_view_get_dual_page (EV_VIEW (ev_window->priv->view)));
-#endif
 }
 
 static char *
@@ -3189,7 +3163,6 @@ sidebar_page_main_widget_update_cb (GObject *ev_sidebar_page,
 static gboolean
 window_state_event_cb (EvWindow *window, GdkEventWindowState *event, gpointer dummy)
 {
-#ifdef ENABLE_METADATA
        char *uri = window->priv->uri;
 
        if (uri && !(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
@@ -3198,7 +3171,6 @@ window_state_event_cb (EvWindow *window, GdkEventWindowState *event, gpointer du
                maximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
                ev_metadata_manager_set_boolean (uri, "window_maximized", maximized);
        }
-#endif
 
        return FALSE;
 }
@@ -3206,7 +3178,6 @@ window_state_event_cb (EvWindow *window, GdkEventWindowState *event, gpointer du
 static gboolean
 window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer dummy)
 {
-#ifdef ENABLE_METADATA
        char *uri = window->priv->uri;
        GdkWindowState state;
        int x, y, width, height;
@@ -3222,7 +3193,6 @@ window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer
                ev_metadata_manager_set_int (uri, "window_width", width);
                ev_metadata_manager_set_int (uri, "window_height", height);
        }
-#endif
 
        return FALSE;
 }
index eb55ecd2c16ead4aef74da64d34a95d36efa6734..7a070912b32b552fb8b1d9733f71f27167cc50c4 100644 (file)
@@ -68,21 +68,23 @@ load_files (const char **files)
 }
 
 #ifdef ENABLE_DBUS
-static void
+static gboolean
 load_files_remote (const char **files)
 {
        int i;
        GError *error = NULL;
        DBusGConnection *connection;
+#if DBUS_VERSION < 35
        DBusGPendingCall *call;
+#endif
        DBusGProxy *remote_object;
 
        connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
        if (connection == NULL) {
                g_warning (error->message);
-               g_error_free (error);
-               
-               return;
+               g_error_free (error);   
+
+               return FALSE;
        }
 
        remote_object = dbus_g_proxy_new_for_name (connection,
@@ -90,22 +92,32 @@ load_files_remote (const char **files)
                                                    "/org/gnome/evince/Evince",
                                                    "org.gnome.evince.Application");
        if (!files) {
+#if DBUS_VERSION < 35
                call = dbus_g_proxy_begin_call (remote_object, "OpenWindow", G_TYPE_INVALID);
 
                if (!dbus_g_proxy_end_call (remote_object, call, &error, G_TYPE_INVALID)) {
                        g_warning (error->message);
                        g_clear_error (&error);
+                       return FALSE;
                }
-               return;
+#else
+               if (!dbus_g_proxy_call (remote_object, "OpenWindow", &error, G_TYPE_INVALID)) {
+                       g_warning (error->message);
+                       g_clear_error (&error);
+                       return FALSE;
+               }
+#endif
+               return TRUE;
        }
 
        for (i = 0; files[i]; i++) {
+               gboolean result = TRUE;
                const char *page_label;
                char *uri;
 
                uri = gnome_vfs_make_uri_from_shell_arg (files[i]);
                page_label = ev_page_label ? ev_page_label : ""; 
-
+#if DBUS_VERSION < 35
                call = dbus_g_proxy_begin_call (remote_object, "OpenURI",
                                                G_TYPE_STRING, uri,
                                                G_TYPE_STRING, page_label,
@@ -114,16 +126,32 @@ load_files_remote (const char **files)
                if (!dbus_g_proxy_end_call (remote_object, call, &error, G_TYPE_INVALID)) {
                        g_warning (error->message);
                        g_clear_error (&error);
+                       result = FALSE;
                }
-               
+#else
+               if (!dbus_g_proxy_call (remote_object, "OpenURI", &error,
+                                       G_TYPE_STRING, uri,
+                                       G_TYPE_STRING, page_label,
+                                       G_TYPE_INVALID)) {
+                       g_warning (error->message);
+                       g_clear_error (&error);
+                       result = FALSE;
+               }
+#endif
                g_free (uri);
+               return result;
         }
+
+       return TRUE;
 }
 #endif /* ENABLE_DBUS */
 
 int
 main (int argc, char *argv[])
 {
+#ifdef ENABLE_METADATA
+       gboolean enable_metadata = FALSE;
+#endif
        poptContext context;
         GValue context_as_value = { 0 };
        GnomeProgram *program;
@@ -149,16 +177,24 @@ main (int argc, char *argv[])
 
 #ifdef ENABLE_DBUS
        if (!ev_application_register_service (EV_APP)) {
-               load_files_remote (poptGetArgs (context));
-               g_warning ("Another process was running.");
-               return 0;
+               if (load_files_remote (poptGetArgs (context))) {
+                       g_warning ("Another process was running.");
+                       return 0;
+               }
        } else {
                g_warning ("Starting evince process.");
+               enable_metadata = TRUE;
        }
 #endif
 
        gnome_authentication_manager_init ();
 
+#if ENABLE_METADATA
+       if (enable_metadata) {
+               ev_metadata_manager_init ();
+       }
+#endif
+
        ev_job_queue_init ();
        g_set_application_name (_("Evince Document Viewer"));
 
@@ -174,8 +210,11 @@ main (int argc, char *argv[])
        gnome_accelerators_sync ();
        poptFreeContext (context);
        ev_file_helpers_shutdown ();
+
 #if ENABLE_METADATA
-       ev_metadata_manager_shutdown ();
+       if (enable_metadata) {
+               ev_metadata_manager_shutdown ();
+       }
 #endif
 
        return 0;