From 8ac50cf59cc976bd26bcb5575a4443d0319463ba Mon Sep 17 00:00:00 2001 From: Nickolay V. Shmyrev Date: Sun, 03 Dec 2006 20:54:44 +0000 Subject: Move screensaver handling to application. No more message on startup. 2006-12-03 Nickolay V. Shmyrev * cut-n-paste/totem-screensaver/totem-scrsaver.c: (screensaver_init_dbus), (totem_scrsaver_new), (totem_scrsaver_init): * cut-n-paste/totem-screensaver/totem-scrsaver.h: * shell/ev-application.c: (ev_application_register_service), (ev_application_screensaver_enable), (ev_application_screensaver_disable): * shell/ev-application.h: * shell/ev-window.c: (ev_window_run_presentation), (ev_window_stop_presentation), (build_comments_string), (ev_window_init): Move screensaver handling to application. No more message on startup. --- diff --git a/ChangeLog b/ChangeLog index d52d023..f2ac630 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2006-12-03 Nickolay V. Shmyrev + + * cut-n-paste/totem-screensaver/totem-scrsaver.c: + (screensaver_init_dbus), (totem_scrsaver_new), + (totem_scrsaver_init): + * cut-n-paste/totem-screensaver/totem-scrsaver.h: + * shell/ev-application.c: (ev_application_register_service), + (ev_application_screensaver_enable), + (ev_application_screensaver_disable): + * shell/ev-application.h: + * shell/ev-window.c: (ev_window_run_presentation), + (ev_window_stop_presentation), (build_comments_string), + (ev_window_init): + + Move screensaver handling to application. No more + message on startup. + 2006-12-03 Carlos Garcia Campos * configure.ac: diff --git a/cut-n-paste/totem-screensaver/totem-scrsaver.c b/cut-n-paste/totem-screensaver/totem-scrsaver.c index 18c9431..1990b0c 100644 --- a/cut-n-paste/totem-screensaver/totem-scrsaver.c +++ b/cut-n-paste/totem-screensaver/totem-scrsaver.c @@ -188,13 +188,16 @@ gs_proxy_destroy_cb (GObject *proxy, } #endif +#ifdef ENABLE_DBUS static void -screensaver_init_dbus (TotemScrsaver *scr) +screensaver_init_dbus (TotemScrsaver *scr, DBusGConnection *connection) { -#ifdef ENABLE_DBUS GError *error = NULL; - scr->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (!connection) + scr->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + else + scr->priv->connection = connection; if (! scr->priv->connection) { if (error) { @@ -218,8 +221,8 @@ screensaver_init_dbus (TotemScrsaver *scr) } -#endif /* ENABLE_DBUS */ } +#endif /* ENABLE_DBUS */ static void screensaver_finalize_dbus (TotemScrsaver *scr) @@ -355,19 +358,35 @@ totem_scrsaver_class_init (TotemScrsaverClass *klass) object_class->finalize = totem_scrsaver_finalize; } +#ifdef ENABLE_DBUS +TotemScrsaver * +totem_scrsaver_new (DBusGConnection *connection) +{ + TotemScrsaver * scr; + scr = TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL)); + + screensaver_init_dbus (scr, connection); + screensaver_init_x11 (scr); + + return scr; +} +#else TotemScrsaver * -totem_scrsaver_new (void) +totem_scrsaver_new() { - return TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL)); + TotemScrsaver * scr; + scr = TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL)); + + screensaver_init_x11 (scr); + + return scr; } +#endif static void totem_scrsaver_init (TotemScrsaver *scr) { scr->priv = g_new0 (TotemScrsaverPrivate, 1); - - screensaver_init_dbus (scr); - screensaver_init_x11 (scr); } void diff --git a/cut-n-paste/totem-screensaver/totem-scrsaver.h b/cut-n-paste/totem-screensaver/totem-scrsaver.h index f34fb15..e84299a 100644 --- a/cut-n-paste/totem-screensaver/totem-scrsaver.h +++ b/cut-n-paste/totem-screensaver/totem-scrsaver.h @@ -22,6 +22,10 @@ #include #include +#ifdef ENABLE_DBUS +#include +#endif + #define TOTEM_TYPE_SCRSAVER (totem_scrsaver_get_type ()) #define TOTEM_SCRSAVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOTEM_TYPE_SCRSAVER, TotemScrsaver)) #define TOTEM_SCRSAVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOTEM_TYPE_SCRSAVER, TotemScrsaverClass)) @@ -43,7 +47,11 @@ struct TotemScrsaverClass { }; GType totem_scrsaver_get_type (void); -TotemScrsaver *totem_scrsaver_new (void); +#ifdef ENABLE_DBUS +TotemScrsaver *totem_scrsaver_new (DBusGConnection *connection); +#else +TotemScrsaver *totem_scrsaver_new (); +#endif void totem_scrsaver_enable (TotemScrsaver *scr); void totem_scrsaver_disable (TotemScrsaver *scr); diff --git a/shell/ev-application.c b/shell/ev-application.c index 7f912f2..aee7390 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -109,7 +109,9 @@ ev_application_register_service (EvApplication *application) dbus_g_connection_register_g_object (connection, "/org/gnome/evince/Evince", G_OBJECT (application)); - + + application->scr_saver = totem_scrsaver_new (connection); + return TRUE; } #endif /* ENABLE_DBUS */ @@ -551,3 +553,14 @@ const gchar* ev_application_get_chooser_uri (EvApplication *application) return application->last_chooser_uri; } +void ev_application_screensaver_enable (EvApplication *application) +{ + if (application->scr_saver) + totem_scrsaver_enable (application->scr_saver); +} + +void ev_application_screensaver_disable (EvApplication *application) +{ + if (application->scr_saver) + totem_scrsaver_disable (application->scr_saver); +} diff --git a/shell/ev-application.h b/shell/ev-application.h index 4f3ce7e..53e97c2 100644 --- a/shell/ev-application.h +++ b/shell/ev-application.h @@ -32,6 +32,7 @@ #ifndef HAVE_GTK_RECENT #include "egg-recent-model.h" #endif +#include "totem-scrsaver.h" G_BEGIN_DECLS @@ -58,6 +59,8 @@ struct _EvApplication { #ifndef HAVE_GTK_RECENT EggRecentModel *recent_model; #endif + + TotemScrsaver *scr_saver; gchar *last_chooser_uri; }; @@ -103,7 +106,8 @@ EggRecentModel *ev_application_get_recent_model (EvApplication *applicati void ev_application_set_chooser_uri (EvApplication *application, const gchar *uri); const gchar *ev_application_get_chooser_uri (EvApplication *application); - +void ev_application_screensaver_enable (EvApplication *application); +void ev_application_screensaver_disable (EvApplication *application); G_END_DECLS #endif /* !EV_APPLICATION_H */ diff --git a/shell/ev-window.c b/shell/ev-window.c index 7ece884..271cfe2 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -91,8 +91,6 @@ #include #include -#include "totem-scrsaver.h" - #include typedef enum { @@ -153,9 +151,6 @@ struct _EvWindowPrivate { GtkWidget *fullscreen_popup; guint fullscreen_timeout_id; - /* Screensaver */ - TotemScrsaver *screensaver; - /* Popup link */ GtkWidget *view_popup; EvLink *link; @@ -2557,8 +2552,8 @@ ev_window_run_presentation (EvWindow *window) window); fullscreen_set_timeout (window); - totem_scrsaver_disable (window->priv->screensaver); - + ev_application_screensaver_disable (EV_APP); + if (!ev_window_is_empty (window)) ev_metadata_manager_set_boolean (window->priv->uri, "presentation", TRUE); } @@ -2585,7 +2580,7 @@ ev_window_stop_presentation (EvWindow *window) window); fullscreen_clear_timeout (window); - totem_scrsaver_enable (window->priv->screensaver); + ev_application_screensaver_enable (EV_APP); if (!ev_window_is_empty (window)) ev_metadata_manager_set_boolean (window->priv->uri, "presentation", FALSE); @@ -3128,7 +3123,7 @@ build_comments_string (void) "Using poppler %s (%s)"), version, backend_name); #else - return g_strdup_printf (_("Document Viewer.")); + return g_strdup_printf (_("Document Viewer")); #endif } @@ -4652,10 +4647,6 @@ ev_window_init (EvWindow *ev_window) G_CALLBACK (drag_data_received_cb), ev_window); - /* Screensaver */ - - ev_window->priv->screensaver = totem_scrsaver_new (); - /* Set it user interface params */ ev_window_setup_recent (ev_window); -- cgit v0.9.1