[empathy: 7/12] Using GtkTreeRowReference instead of a string path.



commit 0f70b1bfb5714c98aa70d062b5ac7ec0e5a03dac
Author: Jonathan Tellier <jonathan tellier gmail com>
Date:   Fri Aug 28 11:23:44 2009 -0400

    Using GtkTreeRowReference instead of a string path.
    
    - When the user selects another account and has pending changes to the
      currently selected account, we need to keed track of the destination
      row. Instead of saving that information as the string representation
      of a GtkTreePath, we now use a GtkTreeRowReference.

 src/empathy-accounts-dialog.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 6cfc830..5e5c947 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -118,7 +118,7 @@ typedef struct {
    * is retrieved asynchronously, we keep some information as member of the
    * EmpathyAccountsDialog object. */
   gboolean force_change_row;
-  gchar *destination_path;
+  GtkTreeRowReference *destination_row;
 
 
 } EmpathyAccountsDialogPriv;
@@ -897,30 +897,31 @@ accounts_dialog_selection_change_response_cb (GtkDialog *message_dialog,
 
   gtk_widget_destroy (GTK_WIDGET (message_dialog));
 
-    if (response_id == GTK_RESPONSE_YES)
+    if (response_id == GTK_RESPONSE_YES && priv->destination_row != NULL)
       {
         /* The user wants to lose unsaved changes to the currently selected
          * account and select another account. We discard the changes and
          * select the other account. */
-        GtkTreeIter iter;
+        GtkTreePath *path;
         GtkTreeSelection *selection;
-        GtkTreeModel *model;
 
         priv->force_change_row = TRUE;
         empathy_account_widget_discard_pending_changes (
             priv->setting_widget_object);
 
-        model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+        path = gtk_tree_row_reference_get_path (priv->destination_row);
         selection = gtk_tree_view_get_selection (
             GTK_TREE_VIEW (priv->treeview));
 
-        if (gtk_tree_model_get_iter_from_string (model,
-              &iter, priv->destination_path))
+        if (path != NULL)
           {
             /* This will trigger a call to
              * accounts_dialog_account_selection_change() */
-            gtk_tree_selection_select_iter (selection, &iter);
+            gtk_tree_selection_select_path (selection, path);
+            gtk_tree_path_free (path);
           }
+
+        gtk_tree_row_reference_free (priv->destination_row);
       }
     else
       {
@@ -954,7 +955,7 @@ accounts_dialog_account_selection_change (GtkTreeSelection *selection,
        * the user if he really wants to lose his changes and select another
        * account */
       gchar *question_dialog_primary_text;
-      priv->destination_path = gtk_tree_path_to_string (path);
+      priv->destination_row = gtk_tree_row_reference_new (model, path);
 
       question_dialog_primary_text = g_strdup_printf (
           PENDING_CHANGES_QUESTION_PRIMARY_TEXT,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]