~ubuntu-branches/ubuntu/oneiric/gwibber/oneiric

« back to all changes in this revision

Viewing changes to libgwibber-gtk/action-box.c

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2011-09-01 16:42:34 UTC
  • mfrom: (1.1.60 upstream)
  • Revision ID: package-import@ubuntu.com-20110901164234-icffypskmtwn66xs
Tags: 3.1.90-0ubuntu1
* New upstream release
  - Ensure replies go to the proper nick name, with duplicate messages 
    replies didn't necessarily go to the right nick
  - Ensure we have a name to display in the notification for "like"
  - Don't spam with notifications for "prepared" and make sure the icon is 
    shown without relying on "prepared" spam
  - Initialize i18n infrastructure, thanks Gabor Kelemen (LP: 837530)
  - Fixed tooltips on the toolbar buttons, thanks David Klasnic. (LP: #837625)
  - don't wait for an idle to refresh the StreamView

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <gtk/gtk.h>
28
28
#include <gwibber.h>
29
29
#include <glib/gi18n-lib.h>
 
30
#include <json-glib/json-glib.h>
 
31
#include <gio/gio.h>
30
32
#include <libnotify/notify.h>
31
33
#include <config.h>
32
34
#include <glib/gstdio.h>
37
39
#define _g_free0(var) (var = (g_free (var), NULL))
38
40
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
39
41
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
 
42
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
40
43
 
41
44
struct _GwibberGtkActionBoxItemPrivate {
42
45
        gchar* _service;
272
275
}
273
276
 
274
277
 
 
278
static gpointer _json_object_ref0 (gpointer self) {
 
279
        return self ? json_object_ref (self) : NULL;
 
280
}
 
281
 
 
282
 
275
283
static void _lambda0_ (GwibberGtkActionBoxItem* self) {
276
 
        g_signal_emit_by_name (self, "reply", self->priv->_mid, self->priv->_account, self->priv->_sender);
 
284
        gchar* _tmp0_;
 
285
        gchar* nick;
 
286
        JsonObject* obj;
 
287
        JsonObject* sender_obj;
 
288
        GwibberMessages* _tmp1_ = NULL;
 
289
        GwibberMessages* messages;
 
290
        gchar* _tmp2_ = NULL;
 
291
        gchar* msg;
 
292
        JsonParser* _tmp3_ = NULL;
 
293
        JsonParser* parser;
 
294
        JsonNode* _tmp4_ = NULL;
 
295
        JsonObject* _tmp5_ = NULL;
 
296
        JsonObject* _tmp6_;
 
297
        gint _tmp13_;
 
298
        GError * _inner_error_ = NULL;
 
299
        _tmp0_ = g_strdup ("");
 
300
        nick = _tmp0_;
 
301
        obj = NULL;
 
302
        sender_obj = NULL;
 
303
        _tmp1_ = gwibber_messages_new ();
 
304
        messages = _tmp1_;
 
305
        _tmp2_ = gwibber_messages_get_message (messages, self->priv->_mid);
 
306
        msg = _tmp2_;
 
307
        _tmp3_ = json_parser_new ();
 
308
        parser = _tmp3_;
 
309
        json_parser_load_from_data (parser, msg, (gssize) (-1), &_inner_error_);
 
310
        if (_inner_error_ != NULL) {
 
311
                _g_object_unref0 (parser);
 
312
                _g_free0 (msg);
 
313
                _g_object_unref0 (messages);
 
314
                if (_inner_error_->domain == G_IO_ERROR) {
 
315
                        goto __catch1_g_io_error;
 
316
                }
 
317
                goto __finally1;
 
318
        }
 
319
        _tmp4_ = json_parser_get_root (parser);
 
320
        _tmp5_ = json_node_get_object (_tmp4_);
 
321
        _tmp6_ = _json_object_ref0 (_tmp5_);
 
322
        _json_object_unref0 (obj);
 
323
        obj = _tmp6_;
 
324
        if (obj != NULL) {
 
325
                gboolean _tmp7_;
 
326
                _tmp7_ = json_object_has_member (obj, "sender");
 
327
                if (_tmp7_) {
 
328
                        JsonObject* _tmp8_ = NULL;
 
329
                        JsonObject* _tmp9_;
 
330
                        _tmp8_ = json_object_get_object_member (obj, "sender");
 
331
                        _tmp9_ = _json_object_ref0 (_tmp8_);
 
332
                        _json_object_unref0 (sender_obj);
 
333
                        sender_obj = _tmp9_;
 
334
                        if (sender_obj != NULL) {
 
335
                                gboolean _tmp10_;
 
336
                                _tmp10_ = json_object_has_member (sender_obj, "nick");
 
337
                                if (_tmp10_) {
 
338
                                        const gchar* _tmp11_ = NULL;
 
339
                                        gchar* _tmp12_;
 
340
                                        _tmp11_ = json_object_get_string_member (sender_obj, "nick");
 
341
                                        _tmp12_ = g_strdup (_tmp11_);
 
342
                                        _g_free0 (nick);
 
343
                                        nick = _tmp12_;
 
344
                                }
 
345
                        }
 
346
                }
 
347
        }
 
348
        _g_object_unref0 (parser);
 
349
        _g_free0 (msg);
 
350
        _g_object_unref0 (messages);
 
351
        goto __finally1;
 
352
        __catch1_g_io_error:
 
353
        {
 
354
                GError * e;
 
355
                e = _inner_error_;
 
356
                _inner_error_ = NULL;
 
357
                g_warning ("action-box.vala:175: %s", e->message);
 
358
                _g_error_free0 (e);
 
359
        }
 
360
        __finally1:
 
361
        if (_inner_error_ != NULL) {
 
362
                _json_object_unref0 (sender_obj);
 
363
                _json_object_unref0 (obj);
 
364
                _g_free0 (nick);
 
365
                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
366
                g_clear_error (&_inner_error_);
 
367
                return;
 
368
        }
 
369
        _tmp13_ = strlen (nick);
 
370
        if (_tmp13_ > 0) {
 
371
                gchar* _tmp14_;
 
372
                _tmp14_ = g_strconcat ("@", nick, NULL);
 
373
                _g_free0 (nick);
 
374
                nick = _tmp14_;
 
375
        }
 
376
        g_signal_emit_by_name (self, "reply", self->priv->_mid, self->priv->_account, nick);
 
377
        _json_object_unref0 (sender_obj);
 
378
        _json_object_unref0 (obj);
 
379
        _g_free0 (nick);
277
380
}
278
381
 
279
382
 
289
392
        _tmp0_ = gwibber_gtk_action_box_item_like (self, self->priv->_mid, self->priv->_account);
290
393
        ret = _tmp0_;
291
394
        if (ret) {
292
 
                const gchar* _tmp1_ = NULL;
293
 
                const gchar* _tmp2_ = NULL;
294
 
                gchar* _tmp3_;
295
 
                gchar* _tmp4_;
296
 
                NotifyNotification* _tmp5_ = NULL;
297
 
                NotifyNotification* _tmp6_;
 
395
                gchar* _tmp1_;
 
396
                gchar* name;
 
397
                gchar* _tmp2_;
 
398
                gchar* nick;
 
399
                JsonObject* obj;
 
400
                JsonObject* sender_obj;
 
401
                GwibberMessages* _tmp3_ = NULL;
 
402
                GwibberMessages* messages;
 
403
                gchar* _tmp4_ = NULL;
 
404
                gchar* msg;
 
405
                JsonParser* _tmp5_ = NULL;
 
406
                JsonParser* parser;
 
407
                JsonNode* _tmp6_ = NULL;
 
408
                JsonObject* _tmp7_ = NULL;
 
409
                JsonObject* _tmp8_;
 
410
                gint _tmp18_;
 
411
                const gchar* _tmp20_ = NULL;
 
412
                const gchar* _tmp21_ = NULL;
 
413
                gchar* _tmp22_;
 
414
                gchar* _tmp23_;
 
415
                NotifyNotification* _tmp24_ = NULL;
 
416
                NotifyNotification* _tmp25_;
298
417
                NotifyNotification* notification;
299
 
                _tmp1_ = _ ("Liked");
300
 
                _tmp2_ = _ ("Liked post from ");
301
 
                _tmp3_ = g_strconcat (_tmp2_, self->priv->_sender, NULL);
302
 
                _tmp4_ = _tmp3_;
303
 
                _tmp5_ = notify_notification_new (_tmp1_, _tmp4_, self->priv->_scalable_icon);
304
 
                _tmp6_ = _tmp5_;
305
 
                _g_free0 (_tmp4_);
306
 
                notification = _tmp6_;
 
418
                _tmp1_ = g_strdup ("");
 
419
                name = _tmp1_;
 
420
                _tmp2_ = g_strdup ("");
 
421
                nick = _tmp2_;
 
422
                obj = NULL;
 
423
                sender_obj = NULL;
 
424
                _tmp3_ = gwibber_messages_new ();
 
425
                messages = _tmp3_;
 
426
                _tmp4_ = gwibber_messages_get_message (messages, self->priv->_mid);
 
427
                msg = _tmp4_;
 
428
                _tmp5_ = json_parser_new ();
 
429
                parser = _tmp5_;
 
430
                json_parser_load_from_data (parser, msg, (gssize) (-1), &_inner_error_);
 
431
                if (_inner_error_ != NULL) {
 
432
                        _g_object_unref0 (parser);
 
433
                        _g_free0 (msg);
 
434
                        _g_object_unref0 (messages);
 
435
                        if (_inner_error_->domain == G_IO_ERROR) {
 
436
                                goto __catch2_g_io_error;
 
437
                        }
 
438
                        goto __finally2;
 
439
                }
 
440
                _tmp6_ = json_parser_get_root (parser);
 
441
                _tmp7_ = json_node_get_object (_tmp6_);
 
442
                _tmp8_ = _json_object_ref0 (_tmp7_);
 
443
                _json_object_unref0 (obj);
 
444
                obj = _tmp8_;
 
445
                if (obj != NULL) {
 
446
                        gboolean _tmp9_;
 
447
                        _tmp9_ = json_object_has_member (obj, "sender");
 
448
                        if (_tmp9_) {
 
449
                                JsonObject* _tmp10_ = NULL;
 
450
                                JsonObject* _tmp11_;
 
451
                                _tmp10_ = json_object_get_object_member (obj, "sender");
 
452
                                _tmp11_ = _json_object_ref0 (_tmp10_);
 
453
                                _json_object_unref0 (sender_obj);
 
454
                                sender_obj = _tmp11_;
 
455
                                if (sender_obj != NULL) {
 
456
                                        gboolean _tmp12_;
 
457
                                        gboolean _tmp15_;
 
458
                                        _tmp12_ = json_object_has_member (sender_obj, "nick");
 
459
                                        if (_tmp12_) {
 
460
                                                const gchar* _tmp13_ = NULL;
 
461
                                                gchar* _tmp14_;
 
462
                                                _tmp13_ = json_object_get_string_member (sender_obj, "nick");
 
463
                                                _tmp14_ = g_strdup (_tmp13_);
 
464
                                                _g_free0 (nick);
 
465
                                                nick = _tmp14_;
 
466
                                        }
 
467
                                        _tmp15_ = json_object_has_member (sender_obj, "name");
 
468
                                        if (_tmp15_) {
 
469
                                                const gchar* _tmp16_ = NULL;
 
470
                                                gchar* _tmp17_;
 
471
                                                _tmp16_ = json_object_get_string_member (sender_obj, "name");
 
472
                                                _tmp17_ = g_strdup (_tmp16_);
 
473
                                                _g_free0 (name);
 
474
                                                name = _tmp17_;
 
475
                                        }
 
476
                                }
 
477
                        }
 
478
                }
 
479
                _g_object_unref0 (parser);
 
480
                _g_free0 (msg);
 
481
                _g_object_unref0 (messages);
 
482
                goto __finally2;
 
483
                __catch2_g_io_error:
 
484
                {
 
485
                        GError * e;
 
486
                        e = _inner_error_;
 
487
                        _inner_error_ = NULL;
 
488
                        g_warning ("action-box.vala:218: %s", e->message);
 
489
                        _g_error_free0 (e);
 
490
                }
 
491
                __finally2:
 
492
                if (_inner_error_ != NULL) {
 
493
                        _json_object_unref0 (sender_obj);
 
494
                        _json_object_unref0 (obj);
 
495
                        _g_free0 (nick);
 
496
                        _g_free0 (name);
 
497
                        g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
498
                        g_clear_error (&_inner_error_);
 
499
                        return;
 
500
                }
 
501
                _tmp18_ = strlen (name);
 
502
                if (_tmp18_ > 0) {
 
503
                        gchar* _tmp19_;
 
504
                        _tmp19_ = g_strdup (name);
 
505
                        _g_free0 (nick);
 
506
                        nick = _tmp19_;
 
507
                }
 
508
                _tmp20_ = _ ("Liked");
 
509
                _tmp21_ = _ ("Liked post from ");
 
510
                _tmp22_ = g_strconcat (_tmp21_, nick, NULL);
 
511
                _tmp23_ = _tmp22_;
 
512
                _tmp24_ = notify_notification_new (_tmp20_, _tmp23_, self->priv->_scalable_icon);
 
513
                _tmp25_ = _tmp24_;
 
514
                _g_free0 (_tmp23_);
 
515
                notification = _tmp25_;
307
516
                notify_notification_show (notification, &_inner_error_);
308
517
                if (_inner_error_ != NULL) {
309
518
                        _g_object_unref0 (notification);
 
519
                        _json_object_unref0 (sender_obj);
 
520
                        _json_object_unref0 (obj);
 
521
                        _g_free0 (nick);
 
522
                        _g_free0 (name);
310
523
                        g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
311
524
                        g_clear_error (&_inner_error_);
312
525
                        return;
313
526
                }
314
527
                _g_object_unref0 (notification);
 
528
                _json_object_unref0 (sender_obj);
 
529
                _json_object_unref0 (obj);
 
530
                _g_free0 (nick);
 
531
                _g_free0 (name);
315
532
        }
316
533
}
317
534