From 37b76ff1d1c446b1add8cde3df84531a0da1db6c Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Wed, 28 Mar 2012 14:05:18 -0400
Subject: [PATCH] * #9490: update account_config_list_dialog status bar on
 status update

---
 gnome/src/config/accountlistconfigdialog.c | 61 ++++++++++++++--------
 gnome/src/config/accountlistconfigdialog.h | 10 ++--
 gnome/src/dbus/dbus.c                      |  8 ++-
 3 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/gnome/src/config/accountlistconfigdialog.c b/gnome/src/config/accountlistconfigdialog.c
index 570decb23e..3f8b76f26d 100644
--- a/gnome/src/config/accountlistconfigdialog.c
+++ b/gnome/src/config/accountlistconfigdialog.c
@@ -204,27 +204,7 @@ select_account_cb(GtkTreeSelection *selection, GtkTreeModel *model)
         gtk_widget_set_sensitive(delete_button, TRUE);
 
         /* Update status bar about current registration state */
-        gtk_statusbar_pop(GTK_STATUSBAR(account_list_status_bar), CONTEXT_ID_REGISTRATION);
-
-        const gchar *state_name = account_state_name(selected_account->state);
-        if (selected_account->protocol_state_description != NULL
-            && selected_account->protocol_state_code != 0) {
-
-            gchar * response = g_strdup_printf(
-                                   _("Server returned \"%s\" (%d)"),
-                                   selected_account->protocol_state_description,
-                                   selected_account->protocol_state_code);
-            gchar * message = g_strconcat(state_name, ". ", response, NULL);
-            gtk_statusbar_push(GTK_STATUSBAR(account_list_status_bar),
-                               CONTEXT_ID_REGISTRATION, message);
-
-            g_free(response);
-            g_free(message);
-
-        } else {
-            gtk_statusbar_push(GTK_STATUSBAR(account_list_status_bar),
-                               CONTEXT_ID_REGISTRATION, state_name);
-        }
+        update_account_list_status_bar(selected_account);
     } else {
         gtk_widget_set_sensitive(move_up_button, FALSE);
         gtk_widget_set_sensitive(move_down_button, FALSE);
@@ -484,8 +464,7 @@ create_account_list()
     renderer = gtk_cell_renderer_text_new();
     tree_view_column = gtk_tree_view_column_new_with_attributes(_("Status"),
                      renderer,
-                     "markup", COLUMN_ACCOUNT_STATUS,
-                     NULL);
+                     "markup", COLUMN_ACCOUNT_STATUS, NULL);
     gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), tree_view_column);
     // Highlight IP profile
     gtk_tree_view_column_set_cell_data_func(tree_view_column, renderer,
@@ -566,6 +545,32 @@ create_account_list()
     return table;
 }
 
+void update_account_list_status_bar(account_t *account)
+{
+    if (!account || !account_list_status_bar)
+        return;
+
+    /* Update status bar about current registration state */
+    gtk_statusbar_pop(GTK_STATUSBAR(account_list_status_bar), CONTEXT_ID_REGISTRATION);
+
+    const gchar *state_name = account_state_name(account->state);
+    if (account->protocol_state_description != NULL && account->protocol_state_code != 0) {
+
+        gchar * response = g_strdup_printf(_("Server returned \"%s\" (%d)"),
+                                           account->protocol_state_description,
+                                           account->protocol_state_code);
+        gchar * message = g_strconcat(state_name, ". ", response, NULL);
+        gtk_statusbar_push(GTK_STATUSBAR(account_list_status_bar),
+                           CONTEXT_ID_REGISTRATION, message);
+
+        g_free(response);
+        g_free(message);
+    } else {
+        gtk_statusbar_push(GTK_STATUSBAR(account_list_status_bar),
+                           CONTEXT_ID_REGISTRATION, state_name);
+    }
+}
+
 void show_account_list_config_dialog(void)
 {
     account_list_dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Accounts"),
@@ -611,7 +616,17 @@ void show_account_list_config_dialog(void)
     status_bar_display_account();
 
     gtk_widget_destroy(GTK_WIDGET(account_list_dialog));
+
+    /* Invalidate static pointers */
     account_list_dialog = NULL;
+    account_list_status_bar = NULL;
+    edit_button = NULL;
+    delete_button = NULL;
+    move_down_button = NULL;
+    move_up_button = NULL;
+    gtk_list_store_clear(account_store);
+    account_store = NULL;
+
     update_actions();
 }
 
diff --git a/gnome/src/config/accountlistconfigdialog.h b/gnome/src/config/accountlistconfigdialog.h
index 8e206054ed..bae376b6d9 100644
--- a/gnome/src/config/accountlistconfigdialog.h
+++ b/gnome/src/config/accountlistconfigdialog.h
@@ -29,10 +29,12 @@
  */
 
 
-#ifndef __SFL_ACCOUNTLISTDIALOG_H__
-#define __SFL_ACCOUNTLISTDIALOG_H__
+#ifndef ACCOUNTLISTDIALOG_H_
+#define ACCOUNTLISTDIALOG_H_
+
+#include "accountlist.h"
 
 void show_account_list_config_dialog(void);
-void account_store_fill(void);
+void update_account_list_status_bar(account_t *account);
 
-#endif
+#endif // ACCOUNTLISTDIALOG_H_
diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c
index 98bae46fd9..a4809b3bac 100644
--- a/gnome/src/dbus/dbus.c
+++ b/gnome/src/dbus/dbus.c
@@ -29,7 +29,10 @@
  *  shall include the source code for the parts of OpenSSL used as well
  *  as that of the covered work.
  */
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
+
 #include <glib/gi18n.h>
 #include "str_utils.h"
 #include "logger.h"
@@ -43,6 +46,7 @@
 #include "sliders.h"
 #include "statusicon.h"
 #include "assistant.h"
+#include "accountlistconfigdialog.h"
 
 #include "dbus.h"
 #include "actions.h"
@@ -428,8 +432,10 @@ registration_state_changed_cb(DBusGProxy *proxy UNUSED, const gchar *accountID,
     DEBUG("DBus: Registration state changed to %s for account %s",
           account_state_name(state), accountID);
     account_t *acc = account_list_get_by_id(accountID);
-    if (acc)
+    if (acc) {
         acc->state = state;
+        update_account_list_status_bar(acc);
+    }
 }
 
 static void
-- 
GitLab