[Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/locations-select into lp:indicator-datetime

2011-04-12 Thread noreply
The proposal to merge lp:~karl-qdh/indicator-datetime/locations-select into 
lp:indicator-datetime has been updated.

Status: Needs review = Merged

For more details, see:
https://code.launchpad.net/~karl-qdh/indicator-datetime/locations-select/+merge/57151
-- 
https://code.launchpad.net/~karl-qdh/indicator-datetime/locations-select/+merge/57151
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.

___
Mailing list: https://launchpad.net/~ayatana-commits
Post to : ayatana-commits@lists.launchpad.net
Unsubscribe : https://launchpad.net/~ayatana-commits
More help   : https://help.launchpad.net/ListHelp


[Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/locations-select into lp:indicator-datetime

2011-04-11 Thread Karl Lattimer
Karl Lattimer has proposed merging 
lp:~karl-qdh/indicator-datetime/locations-select into lp:indicator-datetime.

Requested reviews:
  Ted Gould (ted)
Related bugs:
  Bug #740948 in Indicator Date and Time: Removing a location doesn't select 
the next one
  https://bugs.launchpad.net/indicator-datetime/+bug/740948

For more details, see:
https://code.launchpad.net/~karl-qdh/indicator-datetime/locations-select/+merge/57151

fixes associated bug.
-- 
https://code.launchpad.net/~karl-qdh/indicator-datetime/locations-select/+merge/57151
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'src/datetime-prefs-locations.c'
--- src/datetime-prefs-locations.c	2011-03-30 13:12:30 +
+++ src/datetime-prefs-locations.c	2011-04-11 12:12:31 +
@@ -77,13 +77,81 @@
 gtk_tree_path_free (iter-data);
   }
   g_list_free (paths);
-
+  
+  // Find the next item to select
+  GtkTreeIter *last_selected = g_list_nth_data(tree_iters, 0);
+  GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL (store), last_selected);
+  GtkTreeIter titer;
+  if (!gtk_tree_model_get_iter(GTK_TREE_MODEL (store), titer, path)) {
+g_debug(Failed to get last selected iter from path);
+  	last_selected = NULL;
+  } else {
+	  if (!gtk_tree_model_iter_next(GTK_TREE_MODEL (store), titer)) {
+	  	if (gtk_tree_path_prev(path)) {
+	  	  	if (!gtk_tree_model_get_iter(GTK_TREE_MODEL (store), titer, path)) {
+	  			g_debug(Failed to get iter from path);
+	  			last_selected = NULL;
+	  		} else {
+		  		last_selected = titer;
+		  	}
+	  	} else {
+	  		g_debug(handle_remove: Failed to find another location to select (assume single selected));
+	  		last_selected = NULL;
+	  	}
+	  } else {
+	  	g_debug(Got next item in model);
+		last_selected = titer;
+	  }
+  }
+ 
+  if (last_selected) {
+	  gboolean clear = TRUE;
+	  path = gtk_tree_model_get_path(GTK_TREE_MODEL (store), last_selected);
+	  
+  // Step over the path to find an item which isn't in the delete list
+	  if (g_list_length(tree_iters)  1) {
+		  for (iter = tree_iters; iter; iter = iter-next) {
+		  	GtkTreePath *ipath = gtk_tree_model_get_path(GTK_TREE_MODEL (store), (GtkTreeIter *)iter-data);
+		  	if (gtk_tree_path_compare(path, ipath) == 0) {
+		  		clear = FALSE;
+		  		break;
+		  	}
+		  }
+	  	  while (clear == FALSE) {
+			if (gtk_tree_path_prev(path)) {
+clear = TRUE;
+		  	  	for (iter = tree_iters; iter; iter = iter-next) {
+		  			GtkTreePath *ipath = gtk_tree_model_get_path(GTK_TREE_MODEL (store), (GtkTreeIter *)iter-data);
+		  			if (gtk_tree_path_compare(path, ipath) == 0) {
+		  clear = FALSE;
+		  break;
+		  			}
+		  		}
+		  		if (clear) {
+			  		if (!gtk_tree_model_get_iter(GTK_TREE_MODEL (store), titer, path)) {
+			  			g_debug(Failed to get iter from path);
+			  			last_selected = NULL;
+			  		} else {
+  		last_selected = titer;
+  	}
+}
+		  	} else {
+		  		last_selected = NULL;
+		  		break;
+		  	}
+		  }
+	  }
+  }
+  
   /* Now delete each iterator */
   for (iter = tree_iters; iter; iter = iter-next) {
 gtk_list_store_remove (store, (GtkTreeIter *)iter-data);
 g_free (iter-data);
   }
   g_list_free (tree_iters);
+  
+  if (last_selected)
+	  gtk_tree_selection_select_iter(selection, last_selected);
 }
 
 static void

___
Mailing list: https://launchpad.net/~ayatana-commits
Post to : ayatana-commits@lists.launchpad.net
Unsubscribe : https://launchpad.net/~ayatana-commits
More help   : https://help.launchpad.net/ListHelp