aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-04-15 13:47:50 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-05-05 15:12:27 +0800
commit4f128d19a94c2315db1bab800be93d97e6033b72 (patch)
tree96e2de531cb6205beaec0dd4958902b3f63e9343
parentc26345ba2beb3957327810e201a9f71097910738 (diff)
downloadgsoc2013-empathy-4f128d19a94c2315db1bab800be93d97e6033b72.tar
gsoc2013-empathy-4f128d19a94c2315db1bab800be93d97e6033b72.tar.gz
gsoc2013-empathy-4f128d19a94c2315db1bab800be93d97e6033b72.tar.bz2
gsoc2013-empathy-4f128d19a94c2315db1bab800be93d97e6033b72.tar.lz
gsoc2013-empathy-4f128d19a94c2315db1bab800be93d97e6033b72.tar.xz
gsoc2013-empathy-4f128d19a94c2315db1bab800be93d97e6033b72.tar.zst
gsoc2013-empathy-4f128d19a94c2315db1bab800be93d97e6033b72.zip
Factor out main_window_setup_balance_create_action()
-rw-r--r--src/empathy-main-window.c66
1 files changed, 40 insertions, 26 deletions
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index ed306509e..80bfd92d5 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -146,6 +146,7 @@ struct _EmpathyMainWindowPriv {
GtkWidget *edit_context_separator;
GtkActionGroup *balance_action_group;
+ GtkWidget *balance_vbox;
guint size_timeout_id;
@@ -886,36 +887,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");
@@ -951,20 +934,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_all (conn, -1,
TP_IFACE_CONNECTION_INTERFACE_BALANCE,
@@ -2013,6 +2026,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,