aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-04-15 14:18:33 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-04-15 14:18:33 +0800
commit0156804d7d3b6066c8cc0535561fa679a3b8a201 (patch)
tree7f9d828213de7a9a73128eb35be78b6fa6b6e813
parent7a51c2eade988075020cf4b5a0765806e9f3e897 (diff)
downloadgsoc2013-empathy-0156804d7d3b6066c8cc0535561fa679a3b8a201.tar
gsoc2013-empathy-0156804d7d3b6066c8cc0535561fa679a3b8a201.tar.gz
gsoc2013-empathy-0156804d7d3b6066c8cc0535561fa679a3b8a201.tar.bz2
gsoc2013-empathy-0156804d7d3b6066c8cc0535561fa679a3b8a201.tar.lz
gsoc2013-empathy-0156804d7d3b6066c8cc0535561fa679a3b8a201.tar.xz
gsoc2013-empathy-0156804d7d3b6066c8cc0535561fa679a3b8a201.tar.zst
gsoc2013-empathy-0156804d7d3b6066c8cc0535561fa679a3b8a201.zip
Create balance widget, tie it to the action
TODO: - show and hide balance widgets in response to a toggleaction
-rw-r--r--src/empathy-main-window.c53
-rw-r--r--src/empathy-main-window.ui19
2 files changed, 68 insertions, 4 deletions
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index db7c6c34f..4853ef09b 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -1066,6 +1066,50 @@ main_window_setup_balance_create_action (EmpathyMainWindow *window,
return action;
}
+static GtkWidget *
+main_window_setup_balance_create_widget (EmpathyMainWindow *window,
+ GtkAction *action)
+{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+ GtkWidget *hbox, *image, *label, *button;
+
+ if (action == NULL)
+ return NULL;
+
+ hbox = gtk_hbox_new (FALSE, 6);
+
+ image = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+ gtk_widget_show (image);
+
+ 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);
+
+ button = gtk_button_new_with_label (_("Top Up..."));
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
+ gtk_widget_show (button);
+
+ 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);
+
+ return hbox;
+}
+
static void
main_window_setup_balance_conn_ready (GObject *conn,
GAsyncResult *result,
@@ -1074,6 +1118,7 @@ main_window_setup_balance_conn_ready (GObject *conn,
EmpathyMainWindow *window = user_data;
TpAccount *account = g_object_get_data (conn, "account");
GtkAction *action;
+ GtkWidget *widget;
GError *error = NULL;
if (!tp_proxy_prepare_finish (conn, result, &error)) {
@@ -1094,6 +1139,9 @@ main_window_setup_balance_conn_ready (GObject *conn,
/* create the action */
action = main_window_setup_balance_create_action (window, account);
+ /* create the display widget */
+ widget = main_window_setup_balance_create_widget (window, action);
+
/* request the current balance and monitor for any changes */
tp_cli_dbus_properties_call_get (conn, -1,
TP_IFACE_CONNECTION_INTERFACE_BALANCE,
@@ -2121,7 +2169,7 @@ empathy_main_window_init (EmpathyMainWindow *window)
filename = empathy_file_lookup ("empathy-main-window.ui", "src");
gui = empathy_builder_get_file (filename,
"main_vbox", &priv->main_vbox,
- "balance_box", &priv->balance_vbox,
+ "balance_vbox", &priv->balance_vbox,
"errors_vbox", &priv->errors_vbox,
"auth_vbox", &priv->auth_vbox,
"ui_manager", &priv->ui_manager,
@@ -2296,6 +2344,9 @@ empathy_main_window_init (EmpathyMainWindow *window)
/* Set window size. */
empathy_geometry_bind (GTK_WINDOW (window), GEOMETRY_NAME);
+ /* FIXME: bind balance_vbox to action */
+ gtk_widget_show (priv->balance_vbox);
+
/* Enable event handling */
priv->call_observer = empathy_call_observer_dup_singleton ();
priv->event_manager = empathy_event_manager_dup_singleton ();
diff --git a/src/empathy-main-window.ui b/src/empathy-main-window.ui
index 609a7eca0..f9f5bd9b5 100644
--- a/src/empathy-main-window.ui
+++ b/src/empathy-main-window.ui
@@ -307,7 +307,7 @@
</packing>
</child>
<child>
- <object class="GtkVBox" id="errors_vbox">
+ <object class="GtkVBox" id="balance_vbox">
<child>
<placeholder/>
</child>
@@ -316,10 +316,11 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
+ <property name="spacing">3</property>
</packing>
</child>
<child>
- <object class="GtkVBox" id="auth_vbox">
+ <object class="GtkVBox" id="errors_vbox">
<child>
<placeholder/>
</child>
@@ -331,6 +332,18 @@
</packing>
</child>
<child>
+ <object class="GtkVBox" id="auth_vbox">
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -362,7 +375,7 @@
</child>
</object>
<packing>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
</object>