← Back to team overview

birdie-team team mailing list archive

[Merge] lp:~vasco-m-nunes/birdie/birdie-launcher into lp:birdie

 

vasco has proposed merging lp:~vasco-m-nunes/birdie/birdie-launcher into lp:birdie.

Requested reviews:
  Birdie Team (birdie-team)

For more details, see:
https://code.launchpad.net/~vasco-m-nunes/birdie/birdie-launcher/+merge/152808

launcher badges implemented;
focus-in event to clear badges and indicators.
-- 
https://code.launchpad.net/~vasco-m-nunes/birdie/birdie-launcher/+merge/152808
Your team Birdie Team is requested to review the proposed merge of lp:~vasco-m-nunes/birdie/birdie-launcher into lp:birdie.
=== modified file 'src/Birdie.vala'
--- src/Birdie.vala	2013-03-11 21:48:20 +0000
+++ src/Birdie.vala	2013-03-12 02:44:21 +0000
@@ -29,7 +29,8 @@
         
         public string current_timeline;
         
-        public Utils.Indicator indicator;  
+        public Utils.Indicator indicator; 
+        public Utils.Launcher launcher; 
         public int unread_tweets;
         public int unread_mentions;
         public int unread_dm;
@@ -61,6 +62,7 @@
                 this.m_window.set_application (this);
                 
                 this.indicator = new Utils.Indicator (this);
+                this.launcher = new Utils.Launcher(this);
                 this.unread_tweets = 0;
                 this.unread_mentions = 0;
                 this.unread_dm = 0;
@@ -204,6 +206,12 @@
                 this.api = new Twitter ();
                 
                 this.m_window.add (this.notebook);
+                
+                this.m_window.focus_in_event.connect ((w, e) => {
+                    this.activate();
+                    return true;
+                });           
+                
                 this.m_window.show_all ();
                 
                 if (this.api.token == "" || this.api.token_secret == "") {
@@ -212,17 +220,20 @@
                     new Thread<void*> (null, this.init);
                 }
             } else {
-                this.m_window.present();
+                this.m_window.show();
                 switch (this.current_timeline) {
                     case "home":
+                        this.launcher.clean_launcher_count (this.unread_tweets);
                         this.unread_tweets = 0;
                         this.indicator.clean_tweets_indicator();
                         break;
                     case "mentions":
+                        this.launcher.clean_launcher_count (this.unread_mentions);
                         this.unread_mentions = 0;
                         this.indicator.clean_mentions_indicator();
                         break;
                     case "dm":
+                        this.launcher.clean_launcher_count (this.unread_dm);
                         this.unread_dm = 0;
                         this.indicator.clean_dm_indicator();
                         break;
@@ -301,16 +312,19 @@
                         break;
                     case "home":
                         this.notebook.page = 3;
+                        this.launcher.clean_launcher_count (this.unread_tweets);
                         this.unread_tweets = 0;
                         this.indicator.clean_tweets_indicator();
                         break;
                     case "mentions":
                         this.notebook.page = 4;
+                        this.launcher.clean_launcher_count (this.unread_mentions);
                         this.unread_mentions = 0;
                         this.indicator.clean_mentions_indicator();
                         break;
                     case "dm":
                         this.notebook.page = 5;
+                        this.launcher.clean_launcher_count (this.unread_dm);
                         this.unread_dm = 0;
                         this.indicator.clean_dm_indicator();
                         break;
@@ -374,17 +388,21 @@
                 this.home_list.append (tweet, this);
                 this.unread_tweets++;
 	        });
+	        	        
             this.indicator.update_tweets_indicator (this.unread_tweets);
+            this.launcher.update_launcher_count (this.unread_tweets + this.unread_mentions + this.unread_dm);
         }
         
         public void update_mentions () {
             this.api.get_mentions_timeline ();
-            
+           
             this.api.mentions_timeline_since_id.foreach ((tweet) => {
                 this.mentions_list.append (tweet, this);
                 this.unread_mentions++;
 	        });
+            
             this.indicator.update_mentions_indicator (this.unread_mentions);
+            this.launcher.update_launcher_count (this.unread_tweets + this.unread_mentions + this.unread_dm);
         }
         
         public void tweet_callback (string text, string id = "") {

=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt	2013-03-11 18:49:52 +0000
+++ src/CMakeLists.txt	2013-03-12 02:44:21 +0000
@@ -18,7 +18,7 @@
 
 #Now we're declaring GTK+ 3 and Granite as our REQUIRE dependancies.
 #If PkgConfig can't find these, you need to install them in Step 1.
-pkg_check_modules(DEPS REQUIRED gtk+-3.0 granite rest-0.7 json-glib-1.0 libnotify libcanberra indicate-0.7)
+pkg_check_modules(DEPS REQUIRED gtk+-3.0 granite rest-0.7 json-glib-1.0 libnotify libcanberra indicate-0.7 unity)
 
 #Now we're going to ready the libraries and get their directories to include them.
 set(CFLAGS
@@ -48,6 +48,7 @@
     Utils/Date.vala
     Utils/Notifications.vala
     Utils/Indicator.vala
+    Utils/Launcher.vala
 PACKAGES
     gtk+-3.0
     granite
@@ -57,6 +58,7 @@
     libcanberra>=0.28
     Indicate-0.7
     Dbusmenu-0.4
+    unity
 OPTIONS
     --thread --target-glib=2.32)
 

=== added file 'src/Utils/Launcher.vala'
--- src/Utils/Launcher.vala	1970-01-01 00:00:00 +0000
+++ src/Utils/Launcher.vala	2013-03-12 02:44:21 +0000
@@ -0,0 +1,60 @@
+namespace Birdie.Utils {
+
+    public class Launcher : Object {
+
+        private Unity.LauncherEntry? launcher = null;
+        
+        Birdie birdie;
+        
+        public Launcher(Birdie birdie) {
+            
+            this.birdie = birdie;
+            
+            launcher = Unity.LauncherEntry.get_for_desktop_id ("birdie.desktop");
+            set_count(0);
+            
+            /*
+            // construct quicklist
+            var ql = new Dbusmenu.Menuitem ();
+            var new_tweet = new Dbusmenu.Menuitem ();
+            var home = new Dbusmenu.Menuitem ();
+            var mentions = new Dbusmenu.Menuitem ();
+            var dm = new Dbusmenu.Menuitem ();
+            
+            home.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Home"));
+            home.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true);
+            ql.child_append (home);
+            mentions.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Mentions"));
+            mentions.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true);
+            ql.child_append (mentions);
+            dm.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Messages"));
+            dm.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true);
+            ql.child_append (dm);
+            new_tweet.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("New Tweet"));
+            new_tweet.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true);
+            ql.child_append (new_tweet);
+            launcher.quicklist = ql;   
+            
+            */        
+        }
+        
+        private void set_count (int count) {
+            launcher.count = count;
+            if (launcher.count > 0) {
+                launcher.count_visible = true;
+            }
+            debug("set unity launcher entry count to %s", launcher.count.to_string());
+        }
+        
+        public void update_launcher_count (int count) {
+            set_count(count);
+        }
+        
+        public void clean_launcher_count (int count) {
+            launcher.count = launcher.count-count;
+            if (launcher.count == 0) {
+                launcher.count_visible = false;
+            }
+        }
+    }
+}


Follow ups