[maemo-commits] [maemo-commits] r8789 - projects/haf/branches/hildon-fm/1.x/hildon-fm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Dec 15 17:31:33 EET 2006
Author: marivoll
Date: 2006-12-15 17:31:32 +0200 (Fri, 15 Dec 2006)
New Revision: 8789

Modified:
   projects/haf/branches/hildon-fm/1.x/hildon-fm/hildon-file-chooser-dialog.c
Log:
	* hildon-fm/hildon-file-chooser-dialog.c (set_stub_and_ext): Call
	hildon_file_chooser_dialog_do_autonaming instead of set_entry so
	that the new stub name gets the required autonaming treatment.
	That took a while...


Modified: projects/haf/branches/hildon-fm/1.x/hildon-fm/hildon-file-chooser-dialog.c
===================================================================
--- projects/haf/branches/hildon-fm/1.x/hildon-fm/hildon-file-chooser-dialog.c	2006-12-15 15:18:39 UTC (rev 8788)
+++ projects/haf/branches/hildon-fm/1.x/hildon-fm/hildon-file-chooser-dialog.c	2006-12-15 15:31:32 UTC (rev 8789)
@@ -394,6 +394,60 @@
   return name;
 }
 
+
+static void
+hildon_file_chooser_dialog_do_autonaming(HildonFileChooserDialogPrivate *
+                                         priv)
+{
+    g_assert(HILDON_IS_FILE_SELECTION(priv->filetree));
+
+    if (GTK_WIDGET_VISIBLE(priv->caption_control_name) &&
+        priv->stub_name && !priv->edited) 
+    {
+        gchar *name = NULL;
+        gboolean selection;
+        gint pos;
+
+        g_signal_handler_block(priv->entry_name, priv->changed_handler);
+        if (priv->autonaming_enabled) {
+            GtkTreeIter iter;
+
+            ULOG_INFO("Trying [%s] [%s]", priv->stub_name, priv->ext_name);
+            if (hildon_file_selection_get_current_folder_iter
+                (priv->filetree, &iter)) {
+                name =
+                    hildon_file_system_model_new_item(priv->model, &iter,
+                                                      priv->stub_name,
+                                                      priv->ext_name);
+                ULOG_INFO("Got [%s]", name);
+            }
+        }
+
+        pos = gtk_editable_get_position(GTK_EDITABLE(priv->entry_name));
+        selection =
+          gtk_editable_get_selection_bounds(GTK_EDITABLE(priv->entry_name),
+                                            NULL, NULL);
+
+        if (name)
+        {
+	  gboolean edited = !selection && 
+		  	     (pos != g_utf8_strlen (gtk_entry_get_text(GTK_ENTRY(priv->entry_name)), -1));
+	  set_entry (priv->entry_name, name, priv->ext_name);
+          g_free(name);
+          if (!edited)
+            gtk_editable_select_region(GTK_EDITABLE(priv->entry_name), 0, -1);
+          else
+            /* if the user has already started to edit the name,
+               try to preserve cursor position and don't autoselect */
+            gtk_editable_set_position(GTK_EDITABLE(priv->entry_name), pos);
+        }
+        else
+	  set_entry (priv->entry_name, priv->stub_name, priv->ext_name);
+
+        g_signal_handler_unblock(priv->entry_name, priv->changed_handler);
+    }
+}
+
 /* Set PRIV->stub_name and PRIV->ext_name from NAME so that stub_name
    contains everything before any potential autonaming token and
    ext_name everything after it.
@@ -479,70 +533,10 @@
     *dot = '\0';
   }
 
-  {
-    /* We need to make sure not to mess with the 'edited' flag here
-       so that autonaming will still work.
-    */
-    gboolean old_edited = priv->edited;
-    set_entry (priv->entry_name, priv->stub_name, priv->ext_name);
-    priv->edited = old_edited;
-  }
+  hildon_file_chooser_dialog_do_autonaming (priv);
 }
 
 static void
-hildon_file_chooser_dialog_do_autonaming(HildonFileChooserDialogPrivate *
-                                         priv)
-{
-    g_assert(HILDON_IS_FILE_SELECTION(priv->filetree));
-
-    if (GTK_WIDGET_VISIBLE(priv->caption_control_name) &&
-        priv->stub_name && !priv->edited) 
-    {
-        gchar *name = NULL;
-        gboolean selection;
-        gint pos;
-
-        g_signal_handler_block(priv->entry_name, priv->changed_handler);
-        if (priv->autonaming_enabled) {
-            GtkTreeIter iter;
-
-            ULOG_INFO("Trying [%s] [%s]", priv->stub_name, priv->ext_name);
-            if (hildon_file_selection_get_current_folder_iter
-                (priv->filetree, &iter)) {
-                name =
-                    hildon_file_system_model_new_item(priv->model, &iter,
-                                                      priv->stub_name,
-                                                      priv->ext_name);
-                ULOG_INFO("Got [%s]", name);
-            }
-        }
-
-        pos = gtk_editable_get_position(GTK_EDITABLE(priv->entry_name));
-        selection =
-          gtk_editable_get_selection_bounds(GTK_EDITABLE(priv->entry_name),
-                                            NULL, NULL);
-
-        if (name)
-        {
-	  gboolean edited = !selection && 
-		  	     (pos != g_utf8_strlen (gtk_entry_get_text(GTK_ENTRY(priv->entry_name)), -1));
-	  set_entry (priv->entry_name, name, priv->ext_name);
-          g_free(name);
-          if (!edited)
-            gtk_editable_select_region(GTK_EDITABLE(priv->entry_name), 0, -1);
-          else
-            /* if the user has already started to edit the name,
-               try to preserve cursor position and don't autoselect */
-            gtk_editable_set_position(GTK_EDITABLE(priv->entry_name), pos);
-        }
-        else
-	  set_entry (priv->entry_name, priv->stub_name, priv->ext_name);
-
-        g_signal_handler_unblock(priv->entry_name, priv->changed_handler);
-    }
-}
-
-static void
 hildon_file_chooser_dialog_finished_loading(GObject *sender, GtkTreeIter *iter, gpointer data)
 {
   GtkTreeIter current_iter;


More information about the maemo-commits mailing list