After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 171416 - Resume editing if name of new folder is "Type name of new folder"
Resume editing if name of new folder is "Type name of new folder"
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.6.x
Other All
: High normal
: Small fix
Assigned To: Milan Bouchet-Valat
Federico Mena Quintero
: 314220 346254 352916 412083 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-03-23 21:39 UTC by Federico Mena Quintero
Modified: 2009-06-12 18:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
refuse with the default folder name and empty name (1.66 KB, patch)
2005-08-07 20:58 UTC, Guillaume Desmottes
none Details | Review
Fixes refusing to create directory if name unchanged or empty. (4.03 KB, patch)
2005-08-26 01:13 UTC, Claudio Saavedra
none Details | Review
Patch against gtkfilechooserdefault.c in trunk (1.04 KB, patch)
2009-02-27 11:19 UTC, Milan Bouchet-Valat
accepted-commit_now Details | Review
Fixed patch (1.03 KB, patch)
2009-03-04 09:20 UTC, Milan Bouchet-Valat
none Details | Review

Description Federico Mena Quintero 2005-03-23 21:39:13 UTC
Currently it's very easy to accidentally create folders called "Type name of new
folder", or its local translation.

We should set a flag that says whether the used has changed the default string,
and just resume editing if we are in the confirmation stage and the flag hasn't
changed.

[Also, resume editing if the string is empty; currently the file chooser says
that you can't re-create the current folder because it exists:  it's clearly
appending "" to "/current/folder/" and getting back the "same" string :) ]
Comment 1 Lasse Kärkkäinen 2005-03-24 18:26:50 UTC
Mozilla has an interesting workaround for this problem. Instead of using the
Windows-style approach, it pops up a dialog window asking for name for the new
directory. If user hits OK, the directory will be created, but if he hits
Cancel, the directory is not created. Very simple, very intuitive.
Comment 2 Matthias Clasen 2005-03-26 01:35:22 UTC
I think a simple fix would be to just allow renaming in the file list, by adding
a "Rename" entry to the context menu.
Comment 3 Guillaume Desmottes 2005-08-07 20:58:36 UTC
Created attachment 50354 [details] [review]
refuse with the default folder name and empty name

As a gnome-lover, i try to work on this bug.

This first patch seems to work well when you confirme the folder name by
hitting enter key but doesn't when you click outside the cell during the
editing:
Gtk-CRITICAL **: _gtk_tree_view_column_start_editing: assertion
`tree_column->editable_widget == NULL' failed
and display problem into the tree view.

I don't understand why it's not working in this cass. :\
Comment 4 Nickolay V. Shmyrev 2005-08-22 19:08:37 UTC
Welcome aboard, Guillaume. We just need you.

Several comments about your patch

1. Although it's very minor just to keep style it's better to use N_() instead
of _() in defines. Look for example in gtkfilechooserbutton.c

2. It's better first check string for emptyness, only then compare it. This is
more natural order of things.

3. I don't know why do you need to set cursor. Isn't it better just ignore call
of queue_edited_idle. But you should call 

g_object_set (cell_renderer_text, 
 		"mode", GTK_CELL_RENDERER_MODE_INERT, NULL);

in both cases. Probably it's the main reason of your pbm.
Comment 5 Nickolay V. Shmyrev 2005-08-22 19:15:45 UTC
And, sorry, probably you should also use queue_edited_idle (impl, NULL); as in
cancel function below. 
Comment 6 Federico Mena Quintero 2005-08-25 19:01:37 UTC
*** Bug 314220 has been marked as a duplicate of this bug. ***
Comment 7 Claudio Saavedra 2005-08-26 01:13:18 UTC
Created attachment 51356 [details] [review]
Fixes refusing to create directory if name unchanged or empty.
Comment 8 Federico Mena Quintero 2007-01-25 20:54:02 UTC
*** Bug 346254 has been marked as a duplicate of this bug. ***
Comment 9 Milan Bouchet-Valat 2009-01-23 18:24:01 UTC
Could some body review this patch? Looks like the author fixed what Nickolay asked him to more than two years ago!
Comment 10 Milan Bouchet-Valat 2009-02-27 11:18:34 UTC
Well, I'm going to propose another patch since I find the previous to ones too complex for what they want to achieve. There's no need to check if the folder name was edited, we only have to see if it's empty or equal to the default name. If it's the case, just stop editing as if it was correct, but don't create the folder.

This is the best behavior IMHO since there's no way to remove a bad folder in the file chooser. So if you change your mind and don't want to create that folder, you need a way to go out of this process, and avoid creating a nice folder called "Type name of new folder". If you mistakingly clicked out of the label, you can still click on "Create folder" again.

The patch is only 6 lines and does not need to modify anything except adding two conditions to an already present if(). It works nicely so I think that solution is legitimate. Please comment, I'll change it needed! We can solve it, that's been opened for a long time...
Comment 11 Milan Bouchet-Valat 2009-02-27 11:19:16 UTC
Created attachment 129643 [details] [review]
Patch against gtkfilechooserdefault.c in trunk
Comment 12 Federico Mena Quintero 2009-02-27 20:01:15 UTC
*** Bug 352916 has been marked as a duplicate of this bug. ***
Comment 13 Federico Mena Quintero 2009-02-27 20:15:33 UTC
Hmmm.  For maintainability, Milan's patch is certainly better, and likely just
as effective.  Sorry to make you work more than needed, Claudio :)

Did you mean N_("Type name...") or just _("Type name...")?  I think you want
_(), or the string won't be translated at all.

If you make that change, please go ahead and commit.  Thanks for the patch!
Comment 14 Federico Mena Quintero 2009-02-27 20:21:41 UTC
*** Bug 412083 has been marked as a duplicate of this bug. ***
Comment 15 Milan Bouchet-Valat 2009-02-27 20:23:59 UTC
I meant to use gettext_noop(), but I guess I was misled by a previous comment, as there's no need for it here. Just use _().

Funny, that's the second time I'm asked to commit a patch. I'd be glad to do so, but I've no commit rights, so you'll need to do this yourself... ;-)

Thanks for having a look at all those patches, we really need to clean them!
Comment 16 Milan Bouchet-Valat 2009-03-04 09:20:23 UTC
Created attachment 129997 [details] [review]
Fixed patch
Comment 17 Milan Bouchet-Valat 2009-05-02 20:39:07 UTC
Federico wrote: 
> If you make that change, please go ahead and commit.
As I said some time ago, I don't have the required commit rights, so I need a dev to do this for me. Thanks!
Comment 18 Federico Mena Quintero 2009-06-12 18:09:52 UTC
Committed with minor whitespace changes as d87dbd66d6f4533df85e0967f9dfb45da0681c1e.