Merge lp:~robru/libfriends/deprecate into lp:libfriends

Proposed by Robert Bruce Park
Status: Merged
Merged at revision: 45
Proposed branch: lp:~robru/libfriends/deprecate
Merge into: lp:libfriends
Diff against target: 452 lines (+89/-143)
5 files modified
gtk/account.vala (+18/-4)
gtk/entry.vala (+20/-14)
src/service.vala (+13/-53)
src/utils.vala (+0/-1)
tests/vala/test-service.vala (+38/-71)
To merge this branch: bzr merge lp:~robru/libfriends/deprecate
Reviewer Review Type Date Requested Status
Ken VanDine Pending
Review via email: mp+143013@code.launchpad.net

Description of the change

So, I identified and fixed a bunch of warnings, but this is really just the start: the testsuite has been determined to be effectively tautological, so that needs to get fixed, and also I likely broke a bunch of other stuff too. Watch out for the FIXMEs ;-)

To post a comment you must log in.
lp:~robru/libfriends/deprecate updated
50. By Robert Bruce Park

Fix comments.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'gtk/account.vala'
--- gtk/account.vala 2013-01-11 17:25:44 +0000
+++ gtk/account.vala 2013-01-12 02:18:21 +0000
@@ -82,8 +82,15 @@
82 }82 }
83 set {83 set {
84 GLib.Value t = value;84 GLib.Value t = value;
85 _account.set_value("friends/color", t);85 try
86 _account.store_blocking();86 {
87 _account.set_value("friends/color", t);
88 _account.store_blocking();
89 }
90 catch (Ag.AccountsError e)
91 {
92 warning (e.message);
93 }
87 }94 }
88 }95 }
8996
@@ -117,8 +124,15 @@
117 GLib.Value t = false;124 GLib.Value t = false;
118 if (value == "1")125 if (value == "1")
119 t = true;126 t = true;
120 _account.set_value("friends/send_enabled", t);127 try
121 _account.store_blocking();128 {
129 _account.set_value("friends/send_enabled", t);
130 _account.store_blocking();
131 }
132 catch (Ag.AccountsError e)
133 {
134 warning (e.message);
135 }
122 }136 }
123 }137 }
124138
125139
=== modified file 'gtk/entry.vala'
--- gtk/entry.vala 2013-01-11 17:25:44 +0000
+++ gtk/entry.vala 2013-01-12 02:18:21 +0000
@@ -124,14 +124,14 @@
124 private Friends.Service service;124 private Friends.Service service;
125125
126 /**126 /**
127 * The {@link Gdk.Color} for the foreground127 * The {@link Gdk.RGBA} for the foreground
128 */128 */
129 public Gdk.Color fg_color;129 public Gdk.RGBA fg_color;
130130
131 /**131 /**
132 * The {@link Gdk.Color} for the error state132 * The {@link Gdk.RGBA} for the error state
133 */133 */
134 public Gdk.Color error_color;134 public Gdk.RGBA error_color;
135135
136 bool last_was_shortened = false;136 bool last_was_shortened = false;
137 private string _mid = null;137 private string _mid = null;
@@ -159,9 +159,13 @@
159 Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("Return"), 0, "submit", 0);159 Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("Return"), 0, "submit", 0);
160 Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("KP_Enter"), 0, "submit", 0);160 Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("KP_Enter"), 0, "submit", 0);
161 Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("Escape"), 0, "clear", 0);161 Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("Escape"), 0, "clear", 0);
162 fg_color = get_style ().text[Gtk.StateType.NORMAL];162
163163 // FIXME: How do we tell this StyleContext to get the color from the right place?
164 Gdk.Color.parse ("indianred", out error_color);164 Gtk.StyleContext context = new Gtk.StyleContext ();
165 fg_color = context.get_color (Gtk.StateFlags.NORMAL);
166
167 error_color = Gdk.RGBA ();
168 error_color.parse("indianred");
165169
166 get_buffer ().changed.connect (on_text_changed);170 get_buffer ().changed.connect (on_text_changed);
167 get_buffer ().insert_text.connect (on_text_inserted);171 get_buffer ().insert_text.connect (on_text_inserted);
@@ -245,8 +249,10 @@
245 private void on_text_changed ()249 private void on_text_changed ()
246 {250 {
247 var chars = get_buffer ().get_char_count ();251 var chars = get_buffer ().get_char_count ();
248 modify_fg (Gtk.StateType.NORMAL,252 override_color (
249 chars > MAX_MESSAGE_LENGTH ? error_color : fg_color);253 Gtk.StateFlags.NORMAL,
254 chars > MAX_MESSAGE_LENGTH ? error_color : fg_color
255 );
250 }256 }
251257
252 private void on_text_inserted (ref Gtk.TextIter iter, string text, int len)258 private void on_text_inserted (ref Gtk.TextIter iter, string text, int len)
@@ -300,9 +306,9 @@
300 {306 {
301 context.translate(-1, -1);307 context.translate(-1, -1);
302 factor = 1.0;308 factor = 1.0;
303 } else if (get_state () == 2) {309 } else if (get_state_flags () == Gtk.StateFlags.PRELIGHT) {
304 factor = 0.3;310 factor = 0.3;
305 } else if (get_state () == 1) {311 } else if (get_state_flags () == Gtk.StateFlags.ACTIVE) {
306 factor = 0.5;312 factor = 0.5;
307 }313 }
308314
@@ -354,10 +360,10 @@
354 {360 {
355 Object (spacing:0);361 Object (spacing:0);
356 }362 }
357 363
358 /*364 /*
359 * The {@Ag.Account.id} of the account button to be displayed365 * The {@Ag.Account.id} of the account button to be displayed
360 * This is used in the case of replies or private messages 366 * This is used in the case of replies or private messages
361 * where the post will only go to a single account367 * where the post will only go to a single account
362 */368 */
363 public uint? selected {369 public uint? selected {
@@ -490,7 +496,7 @@
490 return account_button;496 return account_button;
491 }497 }
492498
493 /* 499 /*
494 * Set the number of remaining characters allowed to post500 * Set the number of remaining characters allowed to post
495 * @param chars Number of characters remaining501 * @param chars Number of characters remaining
496 */502 */
497503
=== modified file 'src/service.vala'
--- src/service.vala 2013-01-11 18:53:44 +0000
+++ src/service.vala 2013-01-12 02:18:21 +0000
@@ -236,12 +236,7 @@
236 */236 */
237 public bool retweet(uint account_id, string message_id)237 public bool retweet(uint account_id, string message_id)
238 {238 {
239 try {239 return do("retweet", account_id.to_string(), message_id);
240 return do("retweet", account_id.to_string(), message_id);
241 } catch (GLib.Error e) {
242 warning (e.message);
243 }
244 return false;
245 }240 }
246241
247 /**242 /**
@@ -257,12 +252,7 @@
257 */252 */
258 public bool home(uint account_id)253 public bool home(uint account_id)
259 {254 {
260 try {255 return do("home", account_id.to_string(), "");
261 return do("home", account_id.to_string(), "");
262 } catch (GLib.Error e) {
263 warning (e.message);
264 }
265 return false;
266 }256 }
267257
268 /**258 /**
@@ -279,12 +269,7 @@
279 */269 */
280 public bool wall(uint account_id)270 public bool wall(uint account_id)
281 {271 {
282 try {272 return do("wall", account_id.to_string(), "");
283 return do("wall", account_id.to_string(), "");
284 } catch (GLib.Error e) {
285 warning (e.message);
286 }
287 return false;
288 }273 }
289274
290 /**275 /**
@@ -299,15 +284,10 @@
299 */284 */
300 public bool search(uint? account_id, string query)285 public bool search(uint? account_id, string query)
301 {286 {
302 try {287 if (account_id != null)
303 if (account_id != null)288 return do("search", account_id.to_string(), query);
304 return do("search", account_id.to_string(), query);289 else
305 else290 return do("search", "", query);
306 return do("search", "", query);
307 } catch (GLib.Error e) {
308 warning (e.message);
309 }
310 return false;
311 }291 }
312292
313 /**293 /**
@@ -322,12 +302,7 @@
322 */302 */
323 public bool like(uint account_id, string message_id)303 public bool like(uint account_id, string message_id)
324 {304 {
325 try {305 return do("like", account_id.to_string(), message_id);
326 return do("like", account_id.to_string(), message_id);
327 } catch (GLib.Error e) {
328 warning (e.message);
329 }
330 return false;
331 }306 }
332307
333 /**308 /**
@@ -342,12 +317,7 @@
342 */317 */
343 public bool unlike(uint account_id, string message_id)318 public bool unlike(uint account_id, string message_id)
344 {319 {
345 try {320 return do("unlike", account_id.to_string(), message_id);
346 return do("unlike", account_id.to_string(), message_id);
347 } catch (GLib.Error e) {
348 warning (e.message);
349 }
350 return false;
351 }321 }
352322
353 /**323 /**
@@ -362,12 +332,7 @@
362 */332 */
363 public bool delete(uint account_id, string message_id)333 public bool delete(uint account_id, string message_id)
364 {334 {
365 try {335 return do("delete", account_id.to_string(), message_id);
366 return do("delete", account_id.to_string(), message_id);
367 } catch (GLib.Error e) {
368 warning (e.message);
369 }
370 return false;
371 }336 }
372337
373 /**338 /**
@@ -381,12 +346,7 @@
381 */346 */
382 public bool contacts(uint account_id)347 public bool contacts(uint account_id)
383 {348 {
384 try {349 return do("contacts", account_id.to_string(), "");
385 return do("contacts", account_id.to_string(), "");
386 } catch (GLib.Error e) {
387 warning (e.message);
388 }
389 return false;
390 }350 }
391351
392 /**352 /**
@@ -413,8 +373,8 @@
413 /**373 /**
414 * This method returns a list of all the possible actions374 * This method returns a list of all the possible actions
415 * supported by a given protocol. This can be used to375 * supported by a given protocol. This can be used to
416 * determine what actions are available for the requested 376 * determine what actions are available for the requested
417 * protocol. 377 * protocol.
418 *378 *
419 * @param protocol One of ``facebook``, ``flickr``,379 * @param protocol One of ``facebook``, ``flickr``,
420 * ``foursquare``, ``identica``, or ``twitter``.380 * ``foursquare``, ``identica``, or ``twitter``.
421381
=== modified file 'src/utils.vala'
--- src/utils.vala 2013-01-09 18:50:08 +0000
+++ src/utils.vala 2013-01-12 02:18:21 +0000
@@ -54,7 +54,6 @@
54 {54 {
55 string _avatar_cache_image = Path.build_path (Path.DIR_SEPARATOR_S, Environment.get_user_cache_dir(), "friends/avatars", GLib.Checksum.compute_for_string (GLib.ChecksumType.SHA1, url));55 string _avatar_cache_image = Path.build_path (Path.DIR_SEPARATOR_S, Environment.get_user_cache_dir(), "friends/avatars", GLib.Checksum.compute_for_string (GLib.ChecksumType.SHA1, url));
56 debug ("AVATAR PATH: %s", _avatar_cache_image);56 debug ("AVATAR PATH: %s", _avatar_cache_image);
57 var file = File.new_for_path (_avatar_cache_image);
58 return _avatar_cache_image;57 return _avatar_cache_image;
59 }58 }
60 }59 }
6160
=== modified file 'tests/vala/test-service.vala'
--- tests/vala/test-service.vala 2013-01-09 19:41:41 +0000
+++ tests/vala/test-service.vala 2013-01-12 02:18:21 +0000
@@ -63,50 +63,37 @@
6363
64 internal static void test_refresh ()64 internal static void test_refresh ()
65 {65 {
66 // https://bugs.launchpad.net/libfriends/+bug/1098773
67 // FIXME: Need to capture STDOUT and ensure correct DBus
68 // call is present.
66 var service = new Friends.Service ();69 var service = new Friends.Service ();
67 bool success = false;70 bool success = false;
68 try71 service.refresh ();
69 {72 success = true;
70 service.refresh ();
71 success = true;
72 }
73 catch (GLib.IOError e)
74 {
75 warning ("Failed to refresh - %s", e.message);
76 }
77 assert (success == true);73 assert (success == true);
78
79 }74 }
8075
81 internal static void test_quit ()76 internal static void test_quit ()
82 {77 {
78 // https://bugs.launchpad.net/libfriends/+bug/1098773
79 // FIXME: Need to capture STDOUT and ensure correct DBus
80 // call is present.
83 var service = new Friends.Service ();81 var service = new Friends.Service ();
84 bool success = false;82 bool success = false;
85 try83 service.quit ();
86 {84 success = true;
87 service.quit ();
88 success = true;
89 }
90 catch (GLib.IOError e)
91 {
92 warning ("Failed to shutdown - %s", e.message);
93 }
94 assert (success == true);85 assert (success == true);
9586
96 }87 }
9788
98 internal static void test_features ()89 internal static void test_features ()
99 {90 {
91 // https://bugs.launchpad.net/libfriends/+bug/1098773
92 // FIXME: Need to capture STDOUT and ensure correct DBus
93 // call is present.
100 var service = new Friends.Service ();94 var service = new Friends.Service ();
101 string[] features;95 string[] features;
102 try96 features = service.features ("twitter");
103 {
104 features = service.features ("twitter");
105 }
106 catch (GLib.IOError e)
107 {
108 warning ("Failed to get features - %s", e.message);
109 }
110 assert ("send" in features);97 assert ("send" in features);
111 }98 }
11299
@@ -129,87 +116,67 @@
129116
130 internal static void test_send_message ()117 internal static void test_send_message ()
131 {118 {
119 // https://bugs.launchpad.net/libfriends/+bug/1098773
120 // FIXME: Need to capture STDOUT and ensure correct DBus
121 // call is present.
132 var service = new Friends.Service ();122 var service = new Friends.Service ();
133 uint? acct = null;123 uint? acct = null;
134 string msg = "A message";124 string msg = "A message";
135 bool success = false;125 bool success = false;
136 try126 service.send_message (acct, msg);
137 {127 success = true;
138 service.send_message (acct, msg);
139 success = true;
140 }
141 catch (GLib.IOError e)
142 {
143 warning ("Failed to SendMessage - %s", e.message);
144 }
145 assert (success == true);128 assert (success == true);
146 }129 }
147130
148 internal static void test_send_message_with_account ()131 internal static void test_send_message_with_account ()
149 {132 {
133 // https://bugs.launchpad.net/libfriends/+bug/1098773
134 // FIXME: Need to capture STDOUT and ensure correct DBus
135 // call is present.
150 var service = new Friends.Service ();136 var service = new Friends.Service ();
151 uint acct = 1;137 uint acct = 1;
152 string msg = "A message";138 string msg = "A message";
153 bool success = false;139 bool success = false;
154 try140 service.send_message (acct, msg);
155 {141 success = true;
156 service.send_message (acct, msg);
157 success = true;
158 }
159 catch (GLib.IOError e)
160 {
161 warning ("Failed to SendMessage - %s", e.message);
162 }
163 assert (success == true);142 assert (success == true);
164 }143 }
165144
166 internal static void test_send_reply ()145 internal static void test_send_reply ()
167 {146 {
147 // https://bugs.launchpad.net/libfriends/+bug/1098773
148 // FIXME: Need to capture STDOUT and ensure correct DBus
149 // call is present.
168 var service = new Friends.Service ();150 var service = new Friends.Service ();
169 uint acct = 1;151 uint acct = 1;
170 string msg = "A message";152 string msg = "A message";
171 string msg_id = "100";153 string msg_id = "100";
172 bool success = false;154 bool success = false;
173 try155 service.send_reply (acct, msg_id, msg);
174 {156 success = true;
175 service.send_reply (acct, msg_id, msg);
176 success = true;
177 }
178 catch (GLib.IOError e)
179 {
180 warning ("Failed to SendReply - %s", e.message);
181 }
182 assert (success == true);157 assert (success == true);
183 }158 }
184159
185 internal static void test_clear_indicators ()160 internal static void test_clear_indicators ()
186 {161 {
162 // https://bugs.launchpad.net/libfriends/+bug/1098773
163 // FIXME: Need to capture STDOUT and ensure correct DBus
164 // call is present.
187 var service = new Friends.Service ();165 var service = new Friends.Service ();
188 bool success = false;166 bool success = false;
189 try167 service.messaging_menu_clear ();
190 {168 success = true;
191 service.messaging_menu_clear ();
192 success = true;
193 }
194 catch (GLib.IOError e)
195 {
196 warning ("Failed to clear indicators - %s", e.message);
197 }
198 assert (success == true);169 assert (success == true);
199 }170 }
200171
201 internal static void test_url_shorten ()172 internal static void test_url_shorten ()
202 {173 {
174 // https://bugs.launchpad.net/libfriends/+bug/1098773
175 // FIXME: Need to capture STDOUT and ensure correct DBus
176 // call is present.
203 var service = new Friends.Service ();177 var service = new Friends.Service ();
204 string result = "";178 string result = "";
205 try179 result = service.shorten ("http://example.com/really/really/long");
206 {
207 result = service.shorten ("http://example.com/really/really/long");
208 }
209 catch (GLib.IOError e)
210 {
211 warning ("Failed to shorten URL - %s", e.message);
212 }
213 assert (result == "http://is.gd/short");180 assert (result == "http://is.gd/short");
214 }181 }
215 }182 }

Subscribers

People subscribed via source and target branches