[vinagre] Added im-status plugin



commit ffcf0449d93ecba37099f04dfc749fe1b34ff391
Author: Jonh Wendell <jwendell gnome org>
Date:   Sat Sep 4 17:36:51 2010 -0300

    Added im-status plugin

 configure.ac                                  |    1 +
 plugins/Makefile.am                           |    8 ++-
 plugins/im-status/Makefile.am                 |   15 +++++
 plugins/im-status/im-status.js                |   85 +++++++++++++++++++++++++
 plugins/im-status/im-status.vinagre-plugin.in |   10 +++
 po/POTFILES.in                                |    2 +
 6 files changed, 119 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index da27744..0c5fe51 100644
--- a/configure.ac
+++ b/configure.ac
@@ -312,6 +312,7 @@ plugins/vnc/Makefile
 plugins/ssh/Makefile
 plugins/rdp/Makefile
 plugins/reverse-vnc/Makefile
+plugins/im-status/Makefile
 vinagre/Makefile
 vinagre/view/Makefile
 ])
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 0411bb4..ce85df8 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -2,9 +2,13 @@ DIST_SUBDIRS =	\
   vnc		\
   ssh		\
   rdp		\
-  reverse-vnc
+  reverse-vnc	\
+  im-status
 
-SUBDIRS = vnc reverse-vnc
+SUBDIRS =	\
+  vnc		\
+  reverse-vnc	\
+  im-status
 
 if SSH
 SUBDIRS += ssh
diff --git a/plugins/im-status/Makefile.am b/plugins/im-status/Makefile.am
new file mode 100644
index 0000000..c84c409
--- /dev/null
+++ b/plugins/im-status/Makefile.am
@@ -0,0 +1,15 @@
+plugindir = $(VINAGRE_PLUGINS_LIBS_DIR)
+
+plugin_in_files = im-status.vinagre-plugin.in
+
+im-status.vinagre-plugin: im-status.vinagre-plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA =  $(plugin_in_files:.vinagre-plugin.in=.vinagre-plugin)
+
+plugin_JAVASCRIPT = im-status.js
+
+EXTRA_DIST = $(plugin_in_files) $(plugin_JAVASCRIPT)
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/im-status/im-status.js b/plugins/im-status/im-status.js
new file mode 100644
index 0000000..8719051
--- /dev/null
+++ b/plugins/im-status/im-status.js
@@ -0,0 +1,85 @@
+const Tp = imports.gi.TelepathyGLib;
+const Presence = Tp.ConnectionPresenceType;
+const Lang = imports.lang;
+const _ = imports.gettext.gettext;
+
+var am = null;
+var ready = false;
+
+function ImStatus () {
+  this._init ();
+}
+
+ImStatus.prototype = {
+  _init: function () {
+    this.previous_state = 0;
+    this.signal_id = 0;
+  },
+
+  save_state: function () {
+    var status = {};
+    this.previous_state = am.get_most_available_presence ();
+    if ([Presence.AVAILABLE, Presence.AWAY, Presence.BUSY, Presence.EXTENDED_AWAY].indexOf (this.previous_state) >= 0)
+      ready = true;
+  },
+
+  set_state: function (busy) {
+    if (!ready)
+      return;
+
+    var status = {};
+    var message = {};
+    var state = busy ? Presence.BUSY : this.previous_state;
+    var new_status = busy ? "busy" : "";
+
+    am.get_most_available_presence (status, message);
+    am.set_all_requested_presences (state, new_status, message.value);
+  },
+
+  activate: function () {
+   if (this._initAccountManager ())
+     this.signal_id = this.object.signal.window_state_event.connect (Lang.bind (this, this._windowStateChanged));
+   else
+     print (_("Could not communicate to Telepathy. IM Status plugin will not work."));
+  },
+
+  deactivate: function () {
+    this.set_state (false);
+    if (this.signal_id > 0)
+      this.object.signal.disconnect (this.signal_id);
+  },
+
+  _initAccountManager: function () {
+    if (am == null) {
+       am = Tp.AccountManager.dup ();
+       if (!am)
+         return false;
+
+       am.prepare_async (null, Lang.bind (this,
+         function (o, r) {
+           am.prepare_finish (r);
+           this._changeImStatus ();
+         }));
+    }
+    return true;
+  },
+
+  _windowStateChanged: function (window, e) {
+    if (e.window_state.changed_mask & imports.gi.Gdk.WindowState.FULLSCREEN)
+      this._changeImStatus ();
+    return false;
+  },
+
+  _changeImStatus: function () {
+    if (this.object.window.get_state () & imports.gi.Gdk.WindowState.FULLSCREEN) {
+      this.save_state ();
+      this.set_state (true);
+    } else {
+      this.set_state (false);
+    }
+  }
+}
+
+var extensions = {
+  'PeasActivatable': new ImStatus ()
+};
diff --git a/plugins/im-status/im-status.vinagre-plugin.in b/plugins/im-status/im-status.vinagre-plugin.in
new file mode 100644
index 0000000..8fb96fe
--- /dev/null
+++ b/plugins/im-status/im-status.vinagre-plugin.in
@@ -0,0 +1,10 @@
+[Vinagre Plugin]
+Module=im-status
+Loader=seed
+IAge=1
+_Name=IM Status
+_Description=Changes Instant Messenger status to busy when window toggles to fullscreen (works with Empathy)
+Authors=Jonh Wendell
+Copyright=Copyright © 2010 Jonh Wendell
+Website=http://www.bani.com.br
+Version=1.0
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 40f4a04..66b2ef4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -24,6 +24,8 @@ plugins/reverse-vnc/vinagre-reverse-vnc-listener-dialog.c
 plugins/reverse-vnc/vinagre-reverse-vnc-listener.c
 plugins/reverse-vnc/vinagre-reverse-vnc-plugin.c
 [type: gettext/glade]plugins/reverse-vnc/reverse-vnc.ui
+plugins/im-status/im-status.vinagre-plugin.desktop.in
+plugins/im-status/im-status.js
 vinagre/GNOME_VinagreApplet.server.in.in
 vinagre/vinagre-applet.c
 vinagre/vinagre-bookmarks.c



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]