Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyoken <kyoken@kyoken.ninja>2017-11-22 15:08:11 +0300
committerKyoken <kyoken@kyoken.ninja>2017-11-23 09:34:34 +0300
commit9aa41cc447d9e858be013c033e24b4ac2959adf7 (patch)
tree59bd8368937990db86b307478947e4a6f83d55a5
parent5f054bec89fa9f69985552b302c24fa68b183bcb (diff)
[ubuntu_dock] Add plugin
-rw-r--r--ubuntu_dock/__init__.py1
-rw-r--r--ubuntu_dock/manifest.ini8
-rw-r--r--ubuntu_dock/preview.pngbin0 -> 3053 bytes
-rw-r--r--ubuntu_dock/ubuntu_dock.py90
4 files changed, 99 insertions, 0 deletions
diff --git a/ubuntu_dock/__init__.py b/ubuntu_dock/__init__.py
new file mode 100644
index 0000000..5534807
--- /dev/null
+++ b/ubuntu_dock/__init__.py
@@ -0,0 +1 @@
+from .ubuntu_dock import UbuntuDockPlugin
diff --git a/ubuntu_dock/manifest.ini b/ubuntu_dock/manifest.ini
new file mode 100644
index 0000000..47bca38
--- /dev/null
+++ b/ubuntu_dock/manifest.ini
@@ -0,0 +1,8 @@
+[info]
+name = Ubuntu Dock Integration
+short_name = ubuntu_dock
+version = 0.0.1
+homepage = https://dev.gajim.org/gajim/gajim-plugins/wikis/UbuntuDockPlugin
+max_gajim_version = 0.16.9
+description = This plugin integrates Gajim into the Ubuntu Dock and can show number of unread messages.
+authors = Kyoken <kyoken@kyoken.ninja>
diff --git a/ubuntu_dock/preview.png b/ubuntu_dock/preview.png
new file mode 100644
index 0000000..cf9a83f
--- /dev/null
+++ b/ubuntu_dock/preview.png
Binary files differ
diff --git a/ubuntu_dock/ubuntu_dock.py b/ubuntu_dock/ubuntu_dock.py
new file mode 100644
index 0000000..2f4626c
--- /dev/null
+++ b/ubuntu_dock/ubuntu_dock.py
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2017 Kyoken, kyoken@kyoken.ninja
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 3
+# of the License, or (at your option) any later version.
+
+# This program 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+import os
+
+from plugins import GajimPlugin
+from plugins.helpers import log_calls
+from common import dbus_support, gajim as app
+
+ERR_MSG = ''
+
+if dbus_support.supported:
+ import dbus
+ import dbus.service
+
+ class LauncherEntry(dbus.service.Object):
+ '''
+ https://wiki.ubuntu.com/Unity/LauncherAPI
+ '''
+ def __init__(self, conn, object_path='/org/gajim/Gajim'):
+ dbus.service.Object.__init__(self, conn, object_path)
+
+ @dbus.service.signal('com.canonical.Unity.LauncherEntry',
+ signature='sa{sv}')
+ def Update(self, app_uri, properties):
+ pass
+
+else:
+ ERR_MSG = 'D-Bus Python bindings are missing.'
+
+if os.name == 'nt':
+ ERR_MSG = "Plugin can't be run under Windows."
+
+
+class UbuntuDockPlugin(GajimPlugin):
+ @log_calls('UbuntuDockPlugin')
+ def init(self):
+ self.config_dialog = None
+ if ERR_MSG:
+ self.available_text = ERR_MSG
+ self.activatable = False
+
+ @log_calls('UbuntuDockPlugin')
+ def activate(self):
+ bus = dbus.SessionBus()
+ self.launcher = LauncherEntry(bus)
+
+ app.events.event_added_subscribe(self.update_count)
+ app.events.event_removed_subscribe(self.update_count)
+ self.active = True
+
+ @log_calls('UbuntuDockPlugin')
+ def deactivate(self):
+ app.events.event_added_unsubscribe(self.update_count)
+ app.events.event_removed_unsubscribe(self.update_count)
+ self.active = False
+
+ def update_count(self, *args):
+ nb_unread = 0
+ for account in app.connections:
+ events = [
+ 'chat', 'normal',
+ 'file-request', 'file-error', 'file-completed',
+ 'file-request-error', 'file-send-error', 'file-stopped',
+ 'printed_chat',
+ 'printed_marked_gc_msg',
+ ]
+ if app.config.get('notify_on_all_muc_messages'):
+ events.append('printed_gc_msg')
+ nb_unread += app.events.get_nb_events(events, account)
+
+ self.launcher.Update('application://gajim.desktop', {
+ 'count': dbus.Int64(nb_unread),
+ 'count-visible': bool(nb_unread),
+ })