diff options
-rw-r--r-- | src/empathy-main-window.c | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 671e228c1..db7c6c34f 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -145,6 +145,7 @@ struct _EmpathyMainWindowPriv { GtkWidget *edit_context_separator; GtkActionGroup *balance_action_group; + GtkWidget *balance_vbox; guint size_timeout_id; @@ -1002,36 +1003,18 @@ main_window_balance_changed_cb (TpConnection *conn, (GValueArray *) balance); } -static void -main_window_setup_balance_conn_ready (GObject *conn, - GAsyncResult *result, - gpointer user_data) +static GtkAction * +main_window_setup_balance_create_action (EmpathyMainWindow *window, + TpAccount *account) { - EmpathyMainWindow *window = user_data; EmpathyMainWindowPriv *priv = GET_PRIV (window); - TpAccount *account = g_object_get_data (conn, "account"); GtkAction *action; char *name, *ui; guint merge_id; GError *error = NULL; - if (!tp_proxy_prepare_finish (conn, result, &error)) { - DEBUG ("Failed to prepare connection: %s", error->message); - - g_error_free (error); - return; - } - - if (!tp_proxy_has_interface_by_id (conn, - TP_IFACE_QUARK_CONNECTION_INTERFACE_BALANCE)) { - return; - } - - DEBUG ("Setting up balance for acct: %s", - tp_account_get_display_name (account)); - + /* create the action group if required */ if (priv->balance_action_group == NULL) { - /* create the action group */ priv->balance_action_group = gtk_action_group_new ("balance-action-group"); @@ -1067,20 +1050,50 @@ main_window_setup_balance_conn_ready (GObject *conn, merge_id = gtk_ui_manager_add_ui_from_string (priv->ui_manager, ui, -1, &error); + if (error != NULL) { + DEBUG ("Failed to add balance UI for %s: %s", + tp_account_get_display_name (account), + error->message); + g_error_free (error); + } + g_object_set_data (G_OBJECT (action), "merge-id", GUINT_TO_POINTER (merge_id)); g_free (name); g_free (ui); - if (error != NULL) { - DEBUG ("Failed to add balance UI for %s: %s", - tp_account_get_display_name (account), - error->message); + return action; +} + +static void +main_window_setup_balance_conn_ready (GObject *conn, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyMainWindow *window = user_data; + TpAccount *account = g_object_get_data (conn, "account"); + GtkAction *action; + GError *error = NULL; + + if (!tp_proxy_prepare_finish (conn, result, &error)) { + DEBUG ("Failed to prepare connection: %s", error->message); + g_error_free (error); return; } + if (!tp_proxy_has_interface_by_id (conn, + TP_IFACE_QUARK_CONNECTION_INTERFACE_BALANCE)) { + return; + } + + DEBUG ("Setting up balance for acct: %s", + tp_account_get_display_name (account)); + + /* create the action */ + action = main_window_setup_balance_create_action (window, account); + /* request the current balance and monitor for any changes */ tp_cli_dbus_properties_call_get (conn, -1, TP_IFACE_CONNECTION_INTERFACE_BALANCE, @@ -2108,6 +2121,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, "errors_vbox", &priv->errors_vbox, "auth_vbox", &priv->auth_vbox, "ui_manager", &priv->ui_manager, |