diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2011-05-03 15:33:34 +0800 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2011-05-05 15:13:41 +0800 |
commit | 8b7ca3f8fc98f353c439841efbf6951e86ad45a7 (patch) | |
tree | 4bafc306d6f9cd0bb2a96421993481dc5859701b | |
parent | 49af530a5bfa17173e28a7b706c5e68117c2cd21 (diff) | |
download | gsoc2013-empathy-8b7ca3f8fc98f353c439841efbf6951e86ad45a7.tar gsoc2013-empathy-8b7ca3f8fc98f353c439841efbf6951e86ad45a7.tar.gz gsoc2013-empathy-8b7ca3f8fc98f353c439841efbf6951e86ad45a7.tar.bz2 gsoc2013-empathy-8b7ca3f8fc98f353c439841efbf6951e86ad45a7.tar.lz gsoc2013-empathy-8b7ca3f8fc98f353c439841efbf6951e86ad45a7.tar.xz gsoc2013-empathy-8b7ca3f8fc98f353c439841efbf6951e86ad45a7.tar.zst gsoc2013-empathy-8b7ca3f8fc98f353c439841efbf6951e86ad45a7.zip |
Update balance view in roster per feedback
-rw-r--r-- | src/empathy-main-window.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 4dc357fa7..c31f237c7 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -820,6 +820,7 @@ main_window_balance_update_balance (GtkAction *action, GValueArray *balance) { TpAccount *account = g_object_get_data (G_OBJECT (action), "account"); + GtkWidget *label; int amount = 0; guint scale = G_MAXINT32; const char *currency = ""; @@ -852,8 +853,11 @@ main_window_balance_update_balance (GtkAction *action, gtk_action_set_label (action, str); g_free (str); - /* pass ownership of @money to object data */ - g_object_set_data_full (G_OBJECT (action), "money", money, g_free); + /* update the money label in the roster */ + label = g_object_get_data (G_OBJECT (action), "money-label"); + + gtk_label_set_text (GTK_LABEL (label), money); + g_free (money); } static void @@ -964,35 +968,42 @@ main_window_setup_balance_create_widget (EmpathyMainWindow *window, GtkAction *action) { EmpathyMainWindowPriv *priv = GET_PRIV (window); + TpAccount *account; GtkWidget *hbox, *image, *label, *button; + account = g_object_get_data (G_OBJECT (action), "account"); + g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); + hbox = gtk_hbox_new (FALSE, 6); + /* protocol icon */ image = gtk_image_new (); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0); - gtk_widget_show (image); + g_object_bind_property (action, "icon-name", image, "icon-name", + G_BINDING_SYNC_CREATE); + /* account name label */ label = gtk_label_new (""); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - gtk_widget_show (label); + g_object_bind_property (account, "display-name", label, "label", + G_BINDING_SYNC_CREATE); + + /* balance label */ + label = gtk_label_new (""); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); + g_object_set_data (G_OBJECT (action), "money-label", label); + /* top up button */ button = gtk_button_new_with_label (_("Top Up...")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0); - gtk_widget_show (button); + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (gtk_action_activate), action); gtk_box_pack_start (GTK_BOX (priv->balance_vbox), hbox, FALSE, TRUE, 0); gtk_widget_show_all (hbox); - /* bind the properties from the action to the widgets -- I could have - * written a widget that implemented GtkActivatable, but effort */ - g_object_bind_property (action, "label", label, "label", - G_BINDING_SYNC_CREATE); - g_object_bind_property (action, "icon-name", image, "icon-name", - G_BINDING_SYNC_CREATE); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_action_activate), action); - /* tie the lifetime of the widget to the lifetime of the action */ g_object_weak_ref (G_OBJECT (action), (GWeakNotify) gtk_widget_destroy, hbox); |