You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA.
Author: Bastien Nocera <hadess@hadess.net>
*/
#define XSCREENSAVER_MIN_TIMEOUT 60
static GObjectClass *parent_class = NULL;
-static void totem_scrsaver_class_init (TotemScrsaverClass *class);
-static void totem_scrsaver_init (TotemScrsaver *parser);
static void totem_scrsaver_finalize (GObject *object);
/* try the old API */
res = dbus_g_proxy_call (scr->priv->gs_proxy,
"InhibitActivation",
- &error,
+ NULL,
G_TYPE_STRING, reason,
G_TYPE_INVALID,
G_TYPE_INVALID);
+ if (res)
+ g_error_free (error);
}
g_free (reason);
/* try the old API */
res = dbus_g_proxy_call (scr->priv->gs_proxy,
"AllowActivation",
- &error,
+ NULL,
G_TYPE_INVALID,
G_TYPE_INVALID);
+ if (res)
+ g_error_free (error);
}
}
}
#endif
-#ifdef ENABLE_DBUS
static void
-screensaver_init_dbus (TotemScrsaver *scr, DBusGConnection *connection)
+screensaver_init_dbus (TotemScrsaver *scr)
{
+#ifdef ENABLE_DBUS
GError *error = NULL;
- if (!connection)
- scr->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- else
- scr->priv->connection = connection;
+ scr->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (! scr->priv->connection) {
if (error) {
0);
}
-
-}
#endif /* ENABLE_DBUS */
+}
static void
screensaver_finalize_dbus (TotemScrsaver *scr)
&scr->priv->allow_exposures);
XUnlockDisplay (GDK_DISPLAY());
- if (scr->priv->timeout != 0)
- {
+ if (scr->priv->timeout != 0) {
g_timeout_add_seconds (scr->priv->timeout / 2,
(GSourceFunc) fake_event, scr);
} else {
g_timeout_add_seconds (XSCREENSAVER_MIN_TIMEOUT / 2,
- (GSourceFunc) fake_event, scr);
+ (GSourceFunc) fake_event, scr);
}
return;
object_class->finalize = totem_scrsaver_finalize;
}
-#ifdef ENABLE_DBUS
TotemScrsaver *
-totem_scrsaver_new (DBusGConnection *connection)
+totem_scrsaver_new (void)
{
- TotemScrsaver * scr;
- scr = TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL));
-
- screensaver_init_dbus (scr, connection);
-#ifdef GDK_WINDOWING_X11
- screensaver_init_x11 (scr);
-#else
-#warning Unimplemented
-#endif
-
- return scr;
+ return TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL));
}
-#else
-TotemScrsaver *
-totem_scrsaver_new()
+
+static void
+totem_scrsaver_init (TotemScrsaver *scr)
{
- TotemScrsaver * scr;
- scr = TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL));
+ scr->priv = g_new0 (TotemScrsaverPrivate, 1);
+ screensaver_init_dbus (scr);
#ifdef GDK_WINDOWING_X11
screensaver_init_x11 (scr);
#else
#warning Unimplemented
#endif
-
- return scr;
-}
-#endif
-
-static void
-totem_scrsaver_init (TotemScrsaver *scr)
-{
- scr->priv = g_new0 (TotemScrsaverPrivate, 1);
-
-
}
void
#endif
}
+void
+totem_scrsaver_set_state (TotemScrsaver *scr, gboolean enable)
+{
+ g_return_if_fail (TOTEM_SCRSAVER (scr));
+
+ if (scr->priv->disabled == !enable)
+ return;
+
+ if (enable == FALSE)
+ totem_scrsaver_disable (scr);
+ else
+ totem_scrsaver_enable (scr);
+}
+
static void
totem_scrsaver_finalize (GObject *object)
{
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA.
Author: Bastien Nocera <hadess@hadess.net>
*/
#include <glib.h>
#include <glib-object.h>
-#ifdef ENABLE_DBUS
-#include <dbus/dbus-glib.h>
-#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))
GObjectClass parent_class;
};
-GType totem_scrsaver_get_type (void);
-#ifdef ENABLE_DBUS
-TotemScrsaver *totem_scrsaver_new (DBusGConnection *connection);
-#else
-TotemScrsaver *totem_scrsaver_new ();
-#endif
+GType totem_scrsaver_get_type (void) G_GNUC_CONST;
+TotemScrsaver *totem_scrsaver_new (void);
void totem_scrsaver_enable (TotemScrsaver *scr);
void totem_scrsaver_disable (TotemScrsaver *scr);
+void totem_scrsaver_set_state (TotemScrsaver *scr,
+ gboolean enable);
ev_application_accel_map_save (application);
+ g_object_unref (application->scr_saver);
+ application->scr_saver = NULL;
+
#ifdef ENABLE_DBUS
if (application->keys) {
g_object_unref (application->keys);
ev_application_accel_map_load (ev_application);
+ ev_application->scr_saver = totem_scrsaver_new ();
+
#ifdef ENABLE_DBUS
ev_application->connection = dbus_g_bus_get (DBUS_BUS_STARTER, &error);
if (ev_application->connection) {
dbus_g_connection_register_g_object (ev_application->connection,
APPLICATION_DBUS_OBJECT_PATH,
G_OBJECT (ev_application));
- ev_application->scr_saver = totem_scrsaver_new (ev_application->connection);
} else {
g_warning ("Error connection to DBus: %s\n", error->message);
g_error_free (error);
void
ev_application_screensaver_enable (EvApplication *application)
{
- if (application->scr_saver)
- totem_scrsaver_enable (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);
+ totem_scrsaver_disable (application->scr_saver);
}
const gchar *