Commit ffcf0449 authored by Jonh Wendell's avatar Jonh Wendell
Browse files

Added im-status plugin

parent 801899b8
......@@ -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
])
......
......@@ -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
......
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
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 ()
};
[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
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment