diff options
author | Bastien Nocera <hadess@hadess.net> | 2007-04-11 19:11:26 +0000 |
---|---|---|
committer | Bastien Nocera <hadess@src.gnome.org> | 2007-04-11 19:11:26 +0000 |
commit | d49953b0db4e4536a99fff912941cc8ce6c3422b (patch) | |
tree | 6dbe1d9eed9d3d6413ad49b1a4811ab382b5d28f /lib | |
parent | bc79d15a2e71d1afcc9618011a52d2dddcce1c8d (diff) | |
download | totem-d49953b0db4e4536a99fff912941cc8ce6c3422b.tar.gz |
Patch from Philip Withnall <bugzilla@tecnocode.co.uk> to add a Galago
2007-04-11 Bastien Nocera <hadess@hadess.net>
* configure.in:
* lib/Makefile.am:
* lib/totem-galago.[ch]:
* lib/totem-galago.h:
* src/plugins/Makefile.am:
* src/plugins/galago/*:
Patch from Philip Withnall <bugzilla@tecnocode.co.uk> to add a
Galago plugin that will set your IM status as away when playing
a film in fullscreen (Closes: #427580)
svn path=/trunk/; revision=4214
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.am | 18 | ||||
-rw-r--r-- | lib/totem-galago.c | 124 | ||||
-rw-r--r-- | lib/totem-galago.h | 49 |
3 files changed, 189 insertions, 2 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index c67d8c470..6f1e14296 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,5 +1,6 @@ noinst_LTLIBRARIES = \ - libtotemscrsaver.la + libtotemscrsaver.la \ + libtotemgalago.la common_defines = \ -D_REENTRANT \ @@ -21,10 +22,23 @@ libtotemscrsaver_la_CFLAGS = \ $(WARN_CFLAGS) \ $(DBUS_CFLAGS) \ $(AM_CFLAGS) - libtotemscrsaver_la_LDFLAGS = \ $(AM_LDFLAGS) libtotemscrsaver_la_LIBADD = \ $(DBUS_LIBS) \ $(XTEST_LIBS) +libtotemgalago_la_SOURCES = \ + totem-galago.c \ + totem-galago.h +libtotemgalago_la_CFLAGS = \ + $(common_defines) \ + $(EXTRA_GNOME_CFLAGS) \ + $(WARN_CFLAGS) \ + $(LIBGALAGO_CFLAGS) \ + $(AM_CFLAGS) +libtotemgalago_la_LDFLAGS = \ + $(AM_LDFLAGS) +libtotemgalago_la_LIBADD = \ + $(LIBGALAGO_LIBS) + diff --git a/lib/totem-galago.c b/lib/totem-galago.c new file mode 100644 index 000000000..410c9e386 --- /dev/null +++ b/lib/totem-galago.c @@ -0,0 +1,124 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + + Copyright (C) 2004-2006 Bastien Nocera <hadess@hadess.net> + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + 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. + + Author: Bastien Nocera <hadess@hadess.net>, Philip Withnall <philip@tecnocode.co.uk> + */ + + +#include "config.h" + +#include <glib/gi18n.h> +#include <gdk/gdk.h> +#include <libgalago/galago.h> + +#include "totem-galago.h" + +static GObjectClass *parent_class = NULL; +static void totem_galago_class_init (TotemGalagoClass *class); +static void totem_galago_init (TotemGalago *ggo); +static void totem_galago_finalize (GObject *object); + +struct TotemGalagoPrivate { + gboolean idle; /* Whether we're idle */ + GList *accounts; /* Galago accounts */ +}; + +G_DEFINE_TYPE(TotemGalago, totem_galago, G_TYPE_OBJECT) + +static void +totem_galago_class_init (TotemGalagoClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = totem_galago_finalize; +} + +TotemGalago * +totem_galago_new (void) +{ + return TOTEM_GALAGO (g_object_new (TOTEM_TYPE_GALAGO, NULL)); +} + +static void +totem_galago_init (TotemGalago *ggo) +{ + GalagoPerson *person; + + ggo->priv = g_new0 (TotemGalagoPrivate, 1); + + if (!galago_init (PACKAGE_NAME, GALAGO_INIT_FEED) || !galago_is_connected()) { + g_warning ("Failed to initialise libgalago."); + return; + } + + /* Get "me" and list accounts */ + person = galago_get_me (GALAGO_REMOTE, TRUE); + ggo->priv->accounts = galago_person_get_accounts (person, TRUE); + g_object_unref (person); +} + +void +totem_galago_idle (TotemGalago *ggo) +{ + totem_galago_set_idleness (ggo, TRUE); +} + +void +totem_galago_not_idle (TotemGalago *ggo) +{ + totem_galago_set_idleness (ggo, FALSE); +} + +void +totem_galago_set_idleness (TotemGalago *ggo, gboolean idle) +{ + GList *account; + GalagoPresence *presence; + + g_return_if_fail (galago_is_connected()); + + if (ggo->priv->idle == idle) + return; + + ggo->priv->idle = idle; + for (account = ggo->priv->accounts; account != NULL; account = g_list_next (account)) { + presence = galago_account_get_presence ((GalagoAccount *)account->data, TRUE); + galago_presence_set_idle (presence, idle, time (NULL)); + g_object_unref (presence); + } +} + +static void +totem_galago_finalize (GObject *object) +{ + TotemGalago *ggo = TOTEM_GALAGO (object); + + if (galago_is_connected()) + galago_uninit (); + + g_list_free (ggo->priv->accounts); + g_free (ggo->priv); + + if (G_OBJECT_CLASS (parent_class)->finalize != NULL) { + (* G_OBJECT_CLASS (parent_class)->finalize) (object); + } +} + diff --git a/lib/totem-galago.h b/lib/totem-galago.h new file mode 100644 index 000000000..086c967b5 --- /dev/null +++ b/lib/totem-galago.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2004, Bastien Nocera <hadess@hadess.net> + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + 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. + + Author: Bastien Nocera <hadess@hadess.net>, Philip Withnall <philip@tecnocode.co.uk> + */ + +#include <glib.h> +#include <glib-object.h> + +#define TOTEM_TYPE_GALAGO (totem_galago_get_type ()) +#define TOTEM_GALAGO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOTEM_TYPE_GALAGO, TotemGalago)) +#define TOTEM_GALAGO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOTEM_TYPE_GALAGO, TotemGalagoClass)) +#define TOTEM_IS_GALAGO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOTEM_TYPE_GALAGO)) +#define TOTEM_IS_GALAGO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOTEM_TYPE_GALAGO)) + +typedef struct TotemGalago TotemGalago; +typedef struct TotemGalagoClass TotemGalagoClass; +typedef struct TotemGalagoPrivate TotemGalagoPrivate; + +struct TotemGalago { + GObject parent; + TotemGalagoPrivate *priv; +}; + +struct TotemGalagoClass { + GObjectClass parent_class; +}; + +GType totem_galago_get_type (void); +TotemGalago *totem_galago_new (void); +void totem_galago_idle (TotemGalago *scr); +void totem_galago_not_idle (TotemGalago *scr); +void totem_galago_set_idleness (TotemGalago *scr, gboolean idle); + |