? patch.diff
? gtk/dddd
? gtk/totot
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.7015
diff -u -p -r1.7015 ChangeLog
--- ChangeLog	25 Aug 2005 19:22:29 -0000	1.7015
+++ ChangeLog	26 Aug 2005 01:09:21 -0000
@@ -1,3 +1,22 @@
+2005-08-26  Claudio Saavedra  <csaavedra@alumnos.utalca.cl>
+
+	* gtk/gtkfilechooserdefault.c: 	Added filename_changed flag
+	to _GtkFileChooserDefault.
+	(renderer_edited_cb): Once edited, check if filename is 
+	changed before creating the directory.
+	(editable_insert_text_cb): Sets filename_changed TRUE
+	when the filename is edited.
+	(renderer_editing_started_cb): Connects "insert-text" signal
+	to editable_insert_text_cb (), to be aware of new directory
+	name changed.
+	(create_file_list): Connects "editing-started" signal.
+	(list_name_data_func): Sets filename_changed FALSE when the
+	new directory entry is created.
+
+	This fix #171416 by requiring the user to change the name
+	of the new directory before creating a new one.
+	It also refuses empty directory names.
+	
 2005-08-25  Owen Taylor  <otaylor@redhat.com>
 
 	* gdk/x11/gdkcursor-x11.c (gdk_x11_display_set_cursor_theme): 
Index: gtk/gtkfilechooserdefault.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserdefault.c,v
retrieving revision 1.282
diff -u -p -r1.282 gtkfilechooserdefault.c
--- gtk/gtkfilechooserdefault.c	23 Aug 2005 12:48:05 -0000	1.282
+++ gtk/gtkfilechooserdefault.c	26 Aug 2005 01:09:22 -0000
@@ -217,6 +217,7 @@ struct _GtkFileChooserDefault
 
   gboolean has_home;
   gboolean has_desktop;
+  gboolean filename_changed;
 
   int num_volumes;
   int num_shortcuts;
@@ -1976,10 +1977,16 @@ renderer_edited_cb (GtkCellRendererText 
 		    const gchar           *new_text,
 		    GtkFileChooserDefault *impl)
 {
- /* work around bug #154921 */
-  g_object_set (cell_renderer_text, 
-		"mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
-   queue_edited_idle (impl, new_text);
+  if (impl->filename_changed) {
+    /* work around bug #154921 */
+    g_object_set (cell_renderer_text, 
+		  "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
+    queue_edited_idle (impl, new_text);
+  }
+  else
+  {
+    queue_edited_idle (impl, NULL);
+  }
 }
 
 /* Callback used from the text cell renderer when the new folder edition gets
@@ -1995,6 +2002,34 @@ renderer_editing_canceled_cb (GtkCellRen
    queue_edited_idle (impl, NULL);
 }
 
+/* Callback used from the text cell renderer when the new folder edition
+ * begins.
+ */
+static void editable_insert_text_cb (GtkEditable *editable,
+				     gchar *new_text,
+				     gint new_text_length,
+				     gint *position,
+				     gpointer user_data)
+{
+  GtkFileChooserDefault *impl;
+  impl = (GtkFileChooserDefault *) user_data;
+
+  impl->filename_changed = TRUE;
+
+}
+
+static void renderer_editing_started_cb (GtkCellRenderer *renderer,
+					 GtkCellEditable *editable,
+					 gchar *path,
+					 gpointer user_data)
+{
+  if (GTK_IS_ENTRY (editable)) 
+  {
+    g_signal_connect (G_OBJECT (editable), "insert-text",
+		      G_CALLBACK (editable_insert_text_cb), user_data);
+  }
+}
+
 /* Creates the widgets for the filter combo box */
 static GtkWidget *
 filter_create (GtkFileChooserDefault *impl)
@@ -3775,6 +3810,9 @@ create_file_list (GtkFileChooserDefault 
 		    G_CALLBACK (renderer_edited_cb), impl);
   g_signal_connect (impl->list_name_renderer, "editing-canceled",
 		    G_CALLBACK (renderer_editing_canceled_cb), impl);
+  g_signal_connect (impl->list_name_renderer, "editing-started",
+		    G_CALLBACK (renderer_editing_started_cb), impl);
+
   gtk_tree_view_column_pack_start (impl->list_name_column, impl->list_name_renderer, TRUE);
   gtk_tree_view_column_set_cell_data_func (impl->list_name_column, impl->list_name_renderer,
 					   list_name_data_func, impl, NULL);
@@ -6925,6 +6963,7 @@ list_name_data_func (GtkTreeViewColumn *
       g_object_set (cell,
 		    "text", _("Type name of new folder"),
 		    NULL);
+      impl->filename_changed = FALSE;
 
       return;
     }
