+/* Simplify checks for NULLs: */
+static gboolean strings_are_equal (const gchar *a, const gchar *b)
+{
+ if (!a && !b)
+ return TRUE;
+ if (a && b)
+ {
+ return (strcmp (a, b) == 0);
+ }
+ else
+ return FALSE;
+}
+
+static gboolean on_model_foreach_set_name(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+ GObject *instance = NULL;
+
+ gtk_tree_model_get (model, iter,
+ TNY_GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN, &instance,
+ -1);
+
+ if (!instance)
+ return FALSE; /* keep walking */
+
+ if (!TNY_IS_ACCOUNT (instance)) {
+ g_object_unref (instance);
+ return FALSE; /* keep walking */
+ }
+
+ /* Check if this is the looked-for account: */
+ TnyAccount *this_account = TNY_ACCOUNT (instance);
+ TnyAccount *account = TNY_ACCOUNT (data);
+
+ const gchar *this_account_id = tny_account_get_id(this_account);
+ const gchar *account_id = tny_account_get_id(account);
+ g_object_unref (instance);
+ instance = NULL;
+
+ /* printf ("DEBUG: %s: this_account_id=%s, account_id=%s\n", __FUNCTION__, this_account_id, account_id); */
+ if (strings_are_equal(this_account_id, account_id)) {
+ /* Tell the model that the data has changed, so that
+ * it calls the cell_data_func callbacks again: */
+ /* TODO: This does not seem to actually cause the new string to be shown: */
+ gtk_tree_model_row_changed (model, path, iter);
+
+ return TRUE; /* stop walking */
+ }
+
+ return FALSE; /* keep walking */
+}
+
+typedef struct
+{
+ ModestFolderView *self;
+ gchar *previous_name;
+} GetMmcAccountNameData;
+
+static void on_get_mmc_account_name (TnyStoreAccount* account, gpointer user_data)
+{
+ /* printf ("DEBU1G: %s: account name=%s\n", __FUNCTION__, tny_account_get_name (TNY_ACCOUNT(account))); */
+
+ GetMmcAccountNameData *data = (GetMmcAccountNameData*)user_data;
+
+ if (!strings_are_equal (
+ tny_account_get_name(TNY_ACCOUNT(account)),
+ data->previous_name)) {
+
+ /* Tell the model that the data has changed, so that
+ * it calls the cell_data_func callbacks again: */
+ ModestFolderView *self = data->self;
+ GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
+ if (model)
+ gtk_tree_model_foreach(model, on_model_foreach_set_name, account);
+ }
+
+ g_free (data->previous_name);
+ g_slice_free (GetMmcAccountNameData, data);
+}
+