network-manager-applet r1010 - in trunk: . src/connection-editor



Author: dcbw
Date: Thu Nov  6 03:14:38 2008
New Revision: 1010
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=1010&view=rev

Log:
2008-11-05  Dan Williams  <dcbw redhat com>

	* src/connection-editor/page-ip4.c
	  src/connection-editor/ip4-routes-dialog.c
		- Make address/route list editing less sucky by re-focusing on the next
			column in the list rather than out of the list entirely



Modified:
   trunk/ChangeLog
   trunk/src/connection-editor/ip4-routes-dialog.c
   trunk/src/connection-editor/page-ip4.c

Modified: trunk/src/connection-editor/ip4-routes-dialog.c
==============================================================================
--- trunk/src/connection-editor/ip4-routes-dialog.c	(original)
+++ trunk/src/connection-editor/ip4-routes-dialog.c	Thu Nov  6 03:14:38 2008
@@ -38,6 +38,7 @@
 #define COL_PREFIX  1
 #define COL_NEXT_HOP 2
 #define COL_METRIC  3
+#define COL_LAST COL_METRIC
 
 static void
 route_add_clicked (GtkButton *button, gpointer user_data)
@@ -124,11 +125,13 @@
              gpointer user_data)
 {
 	GladeXML *xml = GLADE_XML (user_data);
-	GtkWidget *widget;
+	GtkWidget *widget, *dialog;
 	GtkListStore *store;
 	GtkTreePath *path;
 	GtkTreeIter iter;
 	guint32 column;
+	GtkTreeViewColumn *next_col;
+	GtkCellRenderer *next_cell;
 
 	widget = glade_xml_get_widget (xml, "ip4_routes");
 	store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (widget)));
@@ -137,6 +140,16 @@
 
 	gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path);
 	gtk_list_store_set (store, &iter, column, new_text, -1);
+
+	/* Move focus to the next column */
+	column = (column >= COL_LAST) ? 0 : column + 1;
+	next_col = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), column);
+	dialog = glade_xml_get_widget (xml, "ip4_routes_dialog");
+	next_cell = g_slist_nth_data (g_object_get_data (G_OBJECT (dialog), "renderers"), column);
+
+	gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (widget), path, next_col, next_cell, TRUE);
+	gtk_widget_grab_focus (widget);
+
 	gtk_tree_path_free (path);
 }
 
@@ -199,6 +212,7 @@
 	GtkTreeViewColumn *column;
 	GtkCellRenderer *renderer;
 	int i;
+	GSList *renderers = NULL;
 
 	xml = glade_xml_new (GLADEDIR "/ce-page-ip4.glade", "ip4_routes_dialog", NULL);
 	if (!xml) {
@@ -263,6 +277,7 @@
 	g_signal_connect (renderer, "edited", G_CALLBACK (cell_edited), xml);
 	g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER (COL_ADDRESS));
 	g_signal_connect (renderer, "editing-started", G_CALLBACK (cell_editing_started), store);
+	renderers = g_slist_append (renderers, renderer);
 
 	offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
 	                                                      -1, _("Address"), renderer,
@@ -278,6 +293,7 @@
 	g_signal_connect (renderer, "edited", G_CALLBACK (cell_edited), xml);
 	g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER (COL_PREFIX));
 	g_signal_connect (renderer, "editing-started", G_CALLBACK (cell_editing_started), store);
+	renderers = g_slist_append (renderers, renderer);
 
 	offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
 	                                                      -1, _("Netmask"), renderer,
@@ -293,6 +309,7 @@
 	g_signal_connect (renderer, "edited", G_CALLBACK (cell_edited), xml);
 	g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER (COL_NEXT_HOP));
 	g_signal_connect (renderer, "editing-started", G_CALLBACK (cell_editing_started), store);
+	renderers = g_slist_append (renderers, renderer);
 
 	offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
 	                                                      -1, _("Gateway"), renderer,
@@ -308,6 +325,7 @@
 	g_signal_connect (renderer, "edited", G_CALLBACK (cell_edited), xml);
 	g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER (COL_METRIC));
 	g_signal_connect (renderer, "editing-started", G_CALLBACK (cell_editing_started), store);
+	renderers = g_slist_append (renderers, renderer);
 
 	offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
 	                                                      -1, _("Metric"), renderer,
@@ -317,6 +335,7 @@
 	gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
 	gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
 
+	g_object_set_data_full (G_OBJECT (dialog), "renderers", renderers, (GDestroyNotify) g_slist_free);
 
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
 	g_signal_connect (selection, "changed",

Modified: trunk/src/connection-editor/page-ip4.c
==============================================================================
--- trunk/src/connection-editor/page-ip4.c	(original)
+++ trunk/src/connection-editor/page-ip4.c	Thu Nov  6 03:14:38 2008
@@ -46,6 +46,11 @@
 
 #define CE_PAGE_IP4_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CE_TYPE_PAGE_IP4, CEPageIP4Private))
 
+#define COL_ADDRESS 0
+#define COL_PREFIX 1
+#define COL_GATEWAY 2
+#define COL_LAST COL_GATEWAY
+
 typedef struct {
 	NMSettingIP4Config *setting;
 	char *connection_id;
@@ -58,6 +63,7 @@
 	GtkButton *addr_add;
 	GtkButton *addr_delete;
 	GtkTreeView *addr_list;
+	GtkCellRenderer *addr_cells[COL_LAST];
 
 	/* DNS servers */
 	GtkWidget *dns_servers_label;
@@ -86,10 +92,6 @@
 #define IP4_METHOD_LINK_LOCAL      3
 #define IP4_METHOD_SHARED          4
 
-#define COL_ADDRESS 0
-#define COL_PREFIX 1
-#define COL_GATEWAY 2
-
 static void
 ip4_private_init (CEPageIP4 *self, NMConnection *connection)
 {
@@ -450,12 +452,20 @@
 	GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (priv->addr_list));
 	GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
 	GtkTreeIter iter;
-	guint32 column = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (cell), "column"));
+	guint32 column;
+	GtkTreeViewColumn *next_col;
 
+	column = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (cell), "column"));
 	gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path);
 	gtk_list_store_set (store, &iter, column, new_text, -1);
-	gtk_tree_path_free (path);
 
+	/* Move focus to the next column */
+	column = (column >= COL_LAST) ? 0 : column + 1;
+	next_col = gtk_tree_view_get_column (priv->addr_list, column);
+	gtk_tree_view_set_cursor_on_cell (priv->addr_list, path, next_col, priv->addr_cells[column], TRUE);
+	gtk_widget_grab_focus (GTK_WIDGET (priv->addr_list));
+
+	gtk_tree_path_free (path);
 	ce_page_changed (CE_PAGE (self));
 }
 
@@ -625,6 +635,7 @@
 	g_signal_connect (renderer, "edited", G_CALLBACK (cell_edited), self);
 	g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER (COL_ADDRESS));
 	g_signal_connect (renderer, "editing-started", G_CALLBACK (cell_editing_started), store);
+	priv->addr_cells[COL_ADDRESS] = GTK_CELL_RENDERER (renderer);
 
 	offset = gtk_tree_view_insert_column_with_attributes (priv->addr_list,
 	                                                      -1, _("Address"), renderer,
@@ -640,6 +651,7 @@
 	g_signal_connect (renderer, "edited", G_CALLBACK (cell_edited), self);
 	g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER (COL_PREFIX));
 	g_signal_connect (renderer, "editing-started", G_CALLBACK (cell_editing_started), store);
+	priv->addr_cells[COL_PREFIX] = GTK_CELL_RENDERER (renderer);
 
 	offset = gtk_tree_view_insert_column_with_attributes (priv->addr_list,
 	                                                      -1, _("Netmask"), renderer,
@@ -655,6 +667,7 @@
 	g_signal_connect (renderer, "edited", G_CALLBACK (cell_edited), self);
 	g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER (COL_GATEWAY));
 	g_signal_connect (renderer, "editing-started", G_CALLBACK (cell_editing_started), store);
+	priv->addr_cells[COL_GATEWAY] = GTK_CELL_RENDERER (renderer);
 
 	offset = gtk_tree_view_insert_column_with_attributes (priv->addr_list,
 	                                                      -1, _("Gateway"), renderer,



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