[Xfce4-commits] <postler:master> Implement support for message indicator

Christian Dywan noreply at xfce.org
Tue Jan 4 05:52:03 CET 2011


Updating branch refs/heads/master
         to 42dc217c98393c41a83e60b764a02f1e37c60b19 (commit)
       from 315201b4e0f3ab8e58bc441da14a1cf77dabf5ba (commit)

commit 42dc217c98393c41a83e60b764a02f1e37c60b19
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Jan 2 19:50:12 2011 +0100

    Implement support for message indicator
    
    Fixes: https://bugs.launchpad.net/postler/+bug/671566

 postler/indicate.vapi        |  160 ++++++++++++++++++++++++++++++++++++++++++
 postler/postler-service.vala |   49 +++++++++++++-
 postler/wscript_build        |    5 +-
 wscript                      |    1 +
 4 files changed, 212 insertions(+), 3 deletions(-)

diff --git a/postler/indicate.vapi b/postler/indicate.vapi
new file mode 100644
index 0000000..c107645
--- /dev/null
+++ b/postler/indicate.vapi
@@ -0,0 +1,160 @@
+/*
+ Copyright (C) 2011 Christian Dywan <christian at twotoasts.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+[CCode (cprefix = "Indicate", lower_case_cprefix = "indicate_")]
+namespace Indicate {
+	[CCode (cheader_filename = "libindicate/indicator.h")]
+	public class Indicator : GLib.Object {
+		[CCode (has_construct_function = false)]
+		public Indicator ();
+		public bool get_displayed ();
+		public uint get_id ();
+		public virtual unowned string get_property (string key);
+		[CCode (cname = "indicate_indicator_hide")]
+		public void emit_hide ();
+		public bool is_visible ();
+		public virtual unowned GLib.PtrArray list_properties ();
+		public void set_displayed (bool displayed);
+		public virtual void set_property (string key, string data);
+		public void set_property_bool (string key, bool value);
+		public void set_property_int (string key, int value);
+		public void set_property_time (string key, GLib.TimeVal time);
+		public void set_server (Indicate.Server server);
+		[CCode (cname = "indicate_indicator_show")]
+		public void emit_show ();
+		[CCode (cname = "indicate_indicator_user_display")]
+		public void emit_user_display ();
+		[CCode (has_construct_function = false)]
+		public Indicator.with_server (Indicate.Server server);
+		public virtual signal void displayed (bool displayed);
+		public virtual signal void hide ();
+		public virtual signal void modified (string property);
+		public virtual signal void show ();
+		public virtual signal void user_display ();
+	}
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public class Listener : GLib.Object {
+		[CCode (has_construct_function = false)]
+		public Listener ();
+		public void display (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator);
+		public void displayed (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, bool displayed);
+		public void get_property (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, string property, Indicate.indicate_listener_get_property_cb callback, void* data);
+		public void get_property_bool (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, string property, Indicate.indicate_listener_get_property_bool_cb callback, void* data);
+		public void get_property_int (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, string property, Indicate.indicate_listener_get_property_int_cb callback, void* data);
+		public void get_property_time (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, string property, Indicate.indicate_listener_get_property_time_cb callback, void* data);
+		public static unowned Indicate.Listener ref_default ();
+		public void set_default_max_indicators (int max);
+		public void set_server_max_indicators (Indicate.ListenerServer server, int max);
+		public virtual signal void indicator_added (Indicate.ListenerServer indicator, Indicate.ListenerIndicator p1);
+		public virtual signal void indicator_modified (Indicate.ListenerServer indicator, Indicate.ListenerIndicator property, string p2);
+		public virtual signal void indicator_removed (Indicate.ListenerServer indicator, Indicate.ListenerIndicator p1);
+		public virtual signal void server_added (Indicate.ListenerServer type, string p1);
+		public virtual signal void server_count_changed (Indicate.ListenerServer count, uint p1);
+		public virtual signal void server_removed (Indicate.ListenerServer type, string p1);
+	}
+	[Compact]
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public class ListenerIndicator {
+		public static GLib.Type get_gtype ();
+		public uint get_id ();
+	}
+	[Compact]
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public class ListenerServer {
+		public static bool check_interest (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.Interests interest);
+		public static void get_count (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.indicate_listener_get_server_uint_property_cb callback, void* data);
+		public unowned string get_dbusname ();
+		public static void get_desktop (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.indicate_listener_get_server_property_cb callback, void* data);
+		public static GLib.Type get_gtype ();
+		public static void remove_interest (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.Interests interest);
+		public static void show_interest (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.Interests interest);
+	}
+	[CCode (cheader_filename = "libindicate/server.h")]
+	public static class Server : GLib.Object {
+		public void add_indicator (Indicate.Indicator indicator);
+		public virtual bool check_interest (Indicate.Interests interest);
+		[NoWrapper]
+		public virtual bool get_indicator_count (uint count) throws GLib.Error;
+		[NoWrapper]
+		public virtual bool get_indicator_list (out unowned GLib.Array indicators) throws GLib.Error;
+		[NoWrapper]
+		public virtual bool get_indicator_properties (uint id, string properties) throws GLib.Error;
+		[NoWrapper]
+		public virtual bool get_indicator_property (uint id, string property, string value) throws GLib.Error;
+		[NoWrapper]
+		public virtual bool get_indicator_property_group (uint id, GLib.PtrArray properties, string value) throws GLib.Error;
+		public int get_max_indicators ();
+		public virtual uint get_next_id ();
+		public void hide ();
+		[NoWrapper]
+		public virtual void indicator_added (uint id);
+		[NoWrapper]
+		public virtual bool indicator_displayed (string sender, uint id, bool displayed) throws GLib.Error;
+		[NoWrapper]
+		public virtual void indicator_removed (uint id);
+		[NoWrapper]
+		public virtual int max_indicators_get ();
+		[NoWrapper]
+		public virtual bool max_indicators_set (string sender, int max);
+		public static unowned Indicate.Server ref_default ();
+		public void remove_indicator (Indicate.Indicator indicator);
+		[NoWrapper]
+		public virtual bool remove_interest (string sender, Indicate.Interests interest);
+		public void set_count (uint count);
+		public static void set_dbus_object (string obj);
+		public void set_default ();
+		public void set_desktop_file (string path);
+		public void set_type (string type);
+		public void show ();
+		[NoWrapper]
+		public virtual bool show_indicator_to_user (uint id) throws GLib.Error;
+		[NoWrapper]
+		public virtual bool show_interest (string sender, Indicate.Interests interest);
+		[NoAccessorMethod]
+		public uint count { get; set; }
+		[NoAccessorMethod]
+		public string desktop { owned get; set; }
+		[NoAccessorMethod]
+		public string type { owned get; set; }
+		public virtual signal void indicator_delete (uint p0);
+		public virtual signal void indicator_modified (uint id, string property);
+		public virtual signal void indicator_new (uint p0);
+		public virtual signal void interest_added (uint interest);
+		public virtual signal void interest_removed (uint interest);
+		public virtual signal void max_indicators_changed (int max);
+		public virtual signal void server_count_changed (uint count);
+		public virtual signal void server_display ();
+		public virtual signal void server_hide (string type);
+		public virtual signal void server_show (string type);
+	}
+	[CCode (cprefix = "INDICATE_INTEREST_", cheader_filename = "libindicate/interests.h")]
+	public enum Interests {
+		NONE,
+		SERVER_DISPLAY,
+		SERVER_SIGNAL,
+		INDICATOR_DISPLAY,
+		INDICATOR_SIGNAL,
+		INDICATOR_COUNT,
+		LAST
+	}
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public delegate void indicate_listener_get_property_bool_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, string property, bool propertydata);
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public delegate void indicate_listener_get_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, string property, string propertydata);
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public delegate void indicate_listener_get_property_int_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, string property, int propertydata);
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public delegate void indicate_listener_get_property_time_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, string property, GLib.TimeVal propertydata);
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public delegate void indicate_listener_get_server_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, string value);
+	[CCode (cheader_filename = "libindicate/listener.h")]
+	public delegate void indicate_listener_get_server_uint_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, uint value);
+}
diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index 310fff0..0d74b8e 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -10,12 +10,59 @@
 */
 
 namespace Postler {
-
     [DBus (name = "org.elementary.Postler")]
     class PostlerService : Object {
         double total = 0;
         int unread = 0;
         string folder = "";
+        Indicate.Server indicator;
+        List<Indicate.Indicator> items;
+
+        void add_inbox_indicator (AccountInfo info) {
+            if (info.type != AccountType.IMAP)
+                    return;
+
+            var item = new Indicate.Indicator.with_server (indicator);
+            item.set_property ("name", info.name);
+            item.user_display.connect ((item) => {
+                Postler.App.spawn_module ("bureau");
+            });
+            item.emit_show ();
+            items.append (item);
+        }
+
+        public PostlerService () {
+            indicator = Indicate.Server.ref_default ();
+            indicator.set_type ("message.email");
+            indicator.set_desktop_file (
+                Config.DATADIR + "/applications/postler.desktop");
+            indicator.server_display.connect (() => {
+                Postler.App.spawn_module ("bureau");
+            });
+
+            var item = new Indicate.Indicator.with_server (indicator);
+            item.set_property ("name", _("Compose Message"));
+            item.user_display.connect (() => {
+                Postler.App.spawn_module ("compose");
+            });
+            item.emit_show ();
+            items.append (item);
+
+            if (Environment.find_program_in_path ("dexter") != null) {
+                item = new Indicate.Indicator.with_server (indicator);
+                item.set_property ("name", _("Contacts"));
+                item.user_display.connect (() => {
+                    new Dexter.Dexter ().show_window ();
+                });
+                item.emit_show ();
+                items.append (item);
+            }
+
+            var accounts = new Accounts ();
+            foreach (var info in accounts.get_infos ())
+                add_inbox_indicator (info);
+            indicator.show ();
+        }
 
         bool execute_command_with_status (string command, IOFunc io_callback) {
             try {
diff --git a/postler/wscript_build b/postler/wscript_build
index 4e9051d..7cb5ce2 100644
--- a/postler/wscript_build
+++ b/postler/wscript_build
@@ -13,7 +13,8 @@ obj.name = 'postler'
 obj.target = 'postler'
 obj.includes = '. ..'
 obj.find_sources_in_dirs ('.')
-obj.uselib = 'GIO GTHREAD GTK LIBNOTIFY LIBCANBERRA UNIQUE WEBKIT'
-obj.packages = 'config postler posix gio-2.0 gtk+-2.0 libnotify libcanberra unique-1.0 webkit-1.0'
+obj.uselib = 'GIO GTHREAD GTK LIBNOTIFY LIBCANBERRA INDICATE UNIQUE WEBKIT'
+obj.packages = 'config postler posix gio-2.0 gtk+-2.0 libnotify libcanberra ' \
+               'indicate unique-1.0 webkit-1.0'
 obj.vapi_dirs = '.'
 
diff --git a/wscript b/wscript
index 326eea9..a12e525 100644
--- a/wscript
+++ b/wscript
@@ -113,6 +113,7 @@ def configure (conf):
     check_pkg ('webkit-1.0', '1.1.1')
     check_pkg ('libnotify', var='LIBNOTIFY')
     check_pkg ('libcanberra', var='LIBCANBERRA')
+    check_pkg ('indicate')
 
     # isync
     conf.check (header_name='sys/filio.h')



More information about the Xfce4-commits mailing list