Merge lp:~mefrio-g/cable/1200886 into lp:cable

Proposed by Mario Guerriero
Status: Merged
Merge reported by: Eduard Gotwig
Merged at revision: not available
Proposed branch: lp:~mefrio-g/cable/1200886
Merge into: lp:cable
Diff against target: 241 lines (+122/-7)
5 files modified
CMakeLists.txt (+4/-1)
src/Cable.vala (+3/-0)
src/Services/Unity.vala (+64/-0)
src/Widgets/Room.vala (+50/-6)
src/Widgets/User.vala (+1/-0)
To merge this branch: bzr merge lp:~mefrio-g/cable/1200886
Reviewer Review Type Date Requested Status
Cable Developers Pending
Review via email: mp+174582@code.launchpad.net

Description of the change

the badges are removed once the entry is focused. It happens because it seems that the entry is the only widget of which we can detect focus_in_event. I think you should focus the entry every time a key is pressed, every time the window is focused and every time the user changes between channels.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-07-09 20:35:11 +0000
+++ CMakeLists.txt 2013-07-13 20:46:22 +0000
@@ -33,7 +33,8 @@
33 gio-2.0>=2.28.033 gio-2.0>=2.28.0
34 gtk+-3.0>=3.4.034 gtk+-3.0>=3.4.0
35 gee-1.035 gee-1.0
36 libnotify)36 libnotify
37 unity)
3738
38add_definitions(${DEPS_CFLAGS})39add_definitions(${DEPS_CFLAGS})
3940
@@ -54,6 +55,7 @@
54 src/Services/Settings.vala55 src/Services/Settings.vala
55 src/Services/Identity.vala56 src/Services/Identity.vala
56 src/Services/Network.vala57 src/Services/Network.vala
58 src/Services/Unity.vala
57 59
58 src/Widgets/Room.vala60 src/Widgets/Room.vala
59 src/Widgets/Server.vala61 src/Widgets/Server.vala
@@ -73,6 +75,7 @@
73 gtk+-3.075 gtk+-3.0
74 granite76 granite
75 libnotify77 libnotify
78 unity
76 #WebKit-3.079 #WebKit-3.0
77OPTIONS80OPTIONS
78 --target-glib=2.3281 --target-glib=2.32
7982
=== modified file 'src/Cable.vala'
--- src/Cable.vala 2013-07-09 20:35:11 +0000
+++ src/Cable.vala 2013-07-13 20:46:22 +0000
@@ -73,6 +73,9 @@
73 73
74 Notify.init ("Cable");74 Notify.init ("Cable");
75 75
76 // libunity support
77 Cable.Services.unity = new Cable.Services.Unity ("cable.desktop");
78
76 try {79 try {
77 context.parse (ref args);80 context.parse (ref args);
78 }81 }
7982
=== added file 'src/Services/Unity.vala'
--- src/Services/Unity.vala 1970-01-01 00:00:00 +0000
+++ src/Services/Unity.vala 2013-07-13 20:46:22 +0000
@@ -0,0 +1,64 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/***
3 BEGIN LICENSE
4
5 Copyright (C) 2013 Mario Guerriero <mario@elementaryos.org>
6 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License version 3, as published
8 by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranties of
12 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>
17
18 END LICENSE
19***/
20
21using Unity;
22
23namespace Cable.Services {
24
25 public Unity unity;
26
27 public class Unity : GLib.Object {
28
29 private int jobs = 0;
30 private LauncherEntry launcher_entry;
31
32 public Unity (string desktop_id) {
33 launcher_entry = LauncherEntry.get_for_desktop_id (desktop_id);
34 }
35
36 public void set_progress (double percentage) {
37 // If it is not 100 % show it
38 launcher_entry.progress = (percentage/jobs);
39 launcher_entry.progress_visible = true;
40 }
41
42 // Add new red badge to show the number of pending works
43 public void append_job () {
44 jobs++;
45
46 launcher_entry.count = jobs;
47 launcher_entry.count_visible = (jobs > 0);
48 }
49
50 public void remove_job () {
51 jobs--;
52
53 launcher_entry.count = jobs;
54 launcher_entry.count_visible = (jobs > 0);
55 }
56
57 public void clear () {
58 jobs = 0;
59 launcher_entry.count = jobs;
60 launcher_entry.count_visible = false;
61 launcher_entry.progress_visible = false;
62 }
63 }
64}
065
=== modified file 'src/Widgets/Room.vala'
--- src/Widgets/Room.vala 2013-07-09 20:35:11 +0000
+++ src/Widgets/Room.vala 2013-07-13 20:46:22 +0000
@@ -44,6 +44,7 @@
44 Granite.Widgets.SourceList.ExpandableItem regular;44 Granite.Widgets.SourceList.ExpandableItem regular;
4545
46 Granite.Widgets.SourceList users;46 Granite.Widgets.SourceList users;
47 Gtk.Entry entry;
47 ChatDisplay chat;48 ChatDisplay chat;
48 Gtk.ScrolledWindow left_scrolled;49 Gtk.ScrolledWindow left_scrolled;
4950
@@ -51,7 +52,9 @@
51 Gtk.Box user_box;52 Gtk.Box user_box;
52 53
53 Gee.HashMap<string, string> color_map;54 Gee.HashMap<string, string> color_map;
5455
56 private int unity_badge_count = 0;
57
55 public Gtk.InfoBar topic;58 public Gtk.InfoBar topic;
56 public Gtk.Label topic_name;59 public Gtk.Label topic_name;
57 private Gtk.Button identity_button;60 private Gtk.Button identity_button;
@@ -68,7 +71,7 @@
68 public Room (string channel, Server server) {71 public Room (string channel, Server server) {
69 this.channel = channel;72 this.channel = channel;
70 this.server = server;73 this.server = server;
71 74
72 color_map = new Gee.HashMap<string, string> (null, null);75 color_map = new Gee.HashMap<string, string> (null, null);
73 76
74 this.orientation = Gtk.Orientation.VERTICAL;77 this.orientation = Gtk.Orientation.VERTICAL;
@@ -137,14 +140,14 @@
137 var content = topic.get_content_area () as Gtk.Container;140 var content = topic.get_content_area () as Gtk.Container;
138 content.add (topic_name);141 content.add (topic_name);
139 142
140 var entry = new Gtk.Entry ();143 entry = new Gtk.Entry ();
141 entry.hexpand = true;144 entry.hexpand = true;
142 145
143 left_scrolled = new Gtk.ScrolledWindow (null, null);146 left_scrolled = new Gtk.ScrolledWindow (null, null);
144 left_scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER;147 left_scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER;
145 148
146 chat = new ChatDisplay ();149 chat = new ChatDisplay ();
147150
148 var pseudo_label = new Gtk.Label (server.identity.nick_name);151 var pseudo_label = new Gtk.Label (server.identity.nick_name);
149 pseudo_label.set_alignment (1, (float)0.5);152 pseudo_label.set_alignment (1, (float)0.5);
150 pseudo_label.width_request = 80;153 pseudo_label.width_request = 80;
@@ -165,11 +168,46 @@
165 box.pack_start (entry_eventbox, false);168 box.pack_start (entry_eventbox, false);
166169
167 this.pack_start (paned);170 this.pack_start (paned);
168171
172 entry.focus_in_event.connect (() => {
173 for (int n = 0; n < unity_badge_count; n++)
174 Cable.Services.unity.remove_job ();
175 unity_badge_count = 0;
176 return false;
177 });
169 entry.activate.connect (() => {178 entry.activate.connect (() => {
170 send_message (entry.text);179 send_message (entry.text);
171 entry.text = "";180 entry.text = "";
172 });181 });
182 string text = "";
183 entry.key_press_event.connect ((ev) => {
184 if (ev.keyval == Gdk.Key.Tab) {
185 if (entry.text == null || entry.text == "")
186 return false;
187
188 var txt = entry.text.split (" ");
189 var word = txt[txt.length-1];
190
191 if (word == null || word == "")
192 return false;
193
194 var collection = new Gee.LinkedList<Granite.Widgets.SourceList.Item> ();
195 collection.add_all (operators.children);
196 collection.add_all (voiced.children);
197 collection.add_all (regular.children);
198 var user_array = collection.to_array ();
199
200 for (int n = 0; n < user_array.length; n++)
201 if (user_array[n].name != null)
202 if (word == user_array[n].name[0:word.length]) {
203 entry.delete_from_cursor (Gtk.DeleteType.WORDS, 1);
204 entry.insert_at_cursor (user_array[n].name + ": ");
205 return true;
206 }
207 return true;
208 }
209 return false;
210 });
173 211
174 /* Load nickname's color from settings */212 /* Load nickname's color from settings */
175 string[] colors = Settings.settings.get_strv ("colors");213 string[] colors = Settings.settings.get_strv ("colors");
@@ -216,6 +254,7 @@
216 regular.name = _("Regular") + " (" + regular.n_children.to_string () + ")";254 regular.name = _("Regular") + " (" + regular.n_children.to_string () + ")";
217 operators.name = _("Operators") + " (" + operators.n_children.to_string () + ")";255 operators.name = _("Operators") + " (" + operators.n_children.to_string () + ")";
218 voiced.name = _("Voiced") + " (" + voiced.n_children.to_string () + ")";256 voiced.name = _("Voiced") + " (" + voiced.n_children.to_string () + ")";
257
219 }258 }
220259
221 public void remove_user (string name, bool silent = false) {260 public void remove_user (string name, bool silent = false) {
@@ -282,6 +321,11 @@
282 try {321 try {
283 notify.show ();322 notify.show ();
284 } catch (Error e) { warning (e.message); }323 } catch (Error e) { warning (e.message); }
324 // libunity badge
325 if (!entry.has_focus) {
326 Cable.Services.unity.append_job ();
327 unity_badge_count++;
328 }
285 } else {329 } else {
286 if (color_map.has_key (from)) {330 if (color_map.has_key (from)) {
287 chat.add_message ("<span color='"+color_map.get (from)+@"'>$from</span>", new_message);331 chat.add_message ("<span color='"+color_map.get (from)+@"'>$from</span>", new_message);
288332
=== modified file 'src/Widgets/User.vala'
--- src/Widgets/User.vala 2013-07-04 01:34:38 +0000
+++ src/Widgets/User.vala 2013-07-13 20:46:22 +0000
@@ -31,6 +31,7 @@
31 31
32 public User (string name) {32 public User (string name) {
33 base (name);33 base (name);
34
34 menu = new Gtk.Menu ();35 menu = new Gtk.Menu ();
35 var item_color = new Gtk.MenuItem.with_label (_("Change color…"));36 var item_color = new Gtk.MenuItem.with_label (_("Change color…"));
36 37

Subscribers

People subscribed via source and target branches

to all changes: