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 349733 - rename feature in file manager
rename feature in file manager
Status: RESOLVED FIXED
Product: anjuta
Classification: Applications
Component: plugins: file-manager
2.4.x
Other All
: Normal enhancement
: ---
Assigned To: Anjuta maintainers
Anjuta maintainers
: 676673 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-08-03 00:15 UTC by hariseldon78
Modified: 2014-04-16 19:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Rename features works (2.57 KB, patch)
2013-09-30 17:05 UTC, Quentin Huot-Marchand
needs-work Details | Review
Apatch for rename (6.07 KB, patch)
2014-04-12 16:11 UTC, Quentin Huot-Marchand
needs-work Details | Review
code improvement (4.82 KB, patch)
2014-04-14 13:17 UTC, Quentin Huot-Marchand
needs-work Details | Review
patch for bug 349733 (4.75 KB, patch)
2014-04-16 01:58 UTC, Quentin Huot-Marchand
committed Details | Review

Description hariseldon78 2006-08-03 00:15:10 UTC
i think that should be very useful an utility to rename a source file. The autotools files should be updated but i think it would be implemented as a delete-insert which already work well.
Comment 1 hariseldon78 2008-04-22 13:54:13 UTC
it would have some impacts on the repository plugins too..
Comment 2 Johannes Schmid 2012-05-23 18:13:31 UTC
*** Bug 676673 has been marked as a duplicate of this bug. ***
Comment 3 Thomas Leberbauer 2012-09-10 13:49:38 UTC
Please address this issue. This is a basic functionality that really should not be missing.
Comment 4 Quentin Huot-Marchand 2013-09-20 14:42:32 UTC
Hi,
I would like work on it, but i can't find the way too implement it.
Where is the lis of the right click menu.
Comment 5 Sébastien Granjoux 2013-09-20 19:53:53 UTC
Thank for your interest. Most menus are defined in .xml file, for the file manager it is plugins/file-manager/file-manager.xml.

There is already a menu item define for renaming file here, you don't have to do it. In fact, you just need to implement the function file_view_rename in plugins/file-manager/file-view.c.
Comment 6 Quentin Huot-Marchand 2013-09-20 20:06:43 UTC
Ok thanks i'll work on it in the next day...
Comment 7 Quentin Huot-Marchand 2013-09-30 17:05:09 UTC
Created attachment 256118 [details] [review]
Rename features works

Hi,
This patch looks me good, but i've only one problem it's the parent for the dialog, i don't know how to get the parent window, so i put NULL in parents.

And i can't try to rename / because i can't build a project on /, so i don't know if my test is so stupid or not.
Comment 8 Sébastien Granjoux 2013-10-03 21:10:38 UTC
Review of attachment 256118 [details] [review]:

Thank for your work.

First a small detail, you shouldn't include the gsprintf and gstdio directly, just glib.h.

Then, the parent window is the shell, you can get it with something like GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell). In the AnjutaFileView object, you don't have a pointer to the plugin anymore so I think the easiest solution is to add the parent window as a parameter of the rename function. This function is called from the AnjutaFileManager object which is a Anjuta plugin, so it's easy to get it.

Anyway, I think it can be better if you add an edit box in the tree view, like it's done in nautilus, you shouldn't need the parent window in this case. What do you think?
Comment 9 Quentin Huot-Marchand 2013-10-03 21:50:03 UTC
(In reply to comment #8)
> First a small detail, you shouldn't include the gsprintf and gstdio directly,
> just glib.h.

I didn't know for their includes

> Anyway, I think it can be better if you add an edit box in the tree view, like
> it's done in nautilus, you shouldn't need the parent window in this case. What
> do you think?

I think it's better i've never use tree view, and i think it's more easier too work with a little dialog, because with an edit box you must check if the user click away from the edit box or exit key.. But i agree it will be better with tree view.
Comment 10 Quentin Huot-Marchand 2014-04-12 16:11:56 UTC
Created attachment 274165 [details] [review]
Apatch for rename

I it's been a long time.
I'm really happy to present my patch!

It permit to rename a file directly into the file tree view

Please verify it

> First a small detail, you shouldn't include the gsprintf and gstdio directly,
> just glib.h.
But i tried with onlyu glib, but i've an error and some warning about some undeclared function.

Regards
Quentin
Comment 11 Sébastien Granjoux 2014-04-12 20:04:08 UTC
Review of attachment 274165 [details] [review]:

Thank you for these improvements, I have checked you patch, it is working but I have a few remarks on the code:

+	if(file == NULL) {
+		printf("file is null :\n") ;
+		return ;
+	}
Do not use printf function for reporting. Anjuta is a graphical program, the user will probably don't have a console. If you want to display a message, use rather g_warning.


+	newFilename = g_strconcat(oldPath, "/", new_text, NULL);
+	oldFilename = g_strconcat(oldPath, "/", fileBasename, NULL);
Instead of "/", you should rather use G_DIR_SEPARATOR_S


+	if(g_rename(oldFilename, newFilename))
Instead of g_rename, it would be better to use g_file_move. With this, you won't need to concatenate strings to get path names and can use g_file_get_parent and g_file_get_child.


+	GtkTreeModel * model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
I think it's not needed because gtk_tree_selection_get_selected will get the model too.


+	gchar * value ;
+	gtk_tree_model_get(model, &iter, COLUMN_FILENAME, &value,
+	                   COLUMN_FILE, &file, -1);
Why do you get the file and the filename here?


+	/*gtk_widget_grab_focus(view) ;*/
If some code is not needed, it's better to remove it than to put it in comment.


+	priv->renderer_display = renderer_display ;
I think you don't need that, you can send NULL to the function gtk_tree_view_set_cursor_on_cell. I think as the pixbuf is not editable, it understands that you want to edit the text part.


+void file_view_rename_edit_finish (GtkCellRendererText *renderer,
+                                   gchar *path,
+                                   gchar *new_text,
+                                   gpointer user_data) ;
+void
+file_view_rename_edit_start (GtkCellRenderer *cell,
+                      GtkCellEditable *editable,
+                      const gchar     *path,
+                      gpointer         data) ;
I think it's better to not declare those functions in the header file because they have no use outside. You should even define them as static to make clear that they are used only inside file-view.c.


+	g_return_if_fail (GTK_IS_WIDGET (rename));
+	gtk_menu_popup (GTK_MENU (rename), NULL, NULL, NULL, NULL, button, time);
I think it is not needed. gtk_menu_popup is only needed for the whole menu, not a menu item.
Comment 12 Quentin Huot-Marchand 2014-04-14 13:17:42 UTC
Created attachment 274266 [details] [review]
code improvement

I fix all of these problem

(In reply to comment #11)
> +    if(g_rename(oldFilename, newFilename))
> Instead of g_rename, it would be better to use g_file_move. With this, you
> won't need to concatenate strings to get path names and can use
> g_file_get_parent and g_file_get_child.

I'm not sure because with g_rename you must concatenate but it's the only cost. g_file_move can copy + delete so in this case it's so.
Comment 13 Sébastien Granjoux 2014-04-14 19:37:39 UTC
Review of attachment 274266 [details] [review]:

Thank for this update. I agree with the user of g_rename and I have just one remark about a printf remaining.

+		if(file == NULL) {
+			printf("file is null :\n") ;
+			return ;
+		}
Do not use printf function for reporting. Anjuta is a graphical program, the
user will probably don't have a console. If you want to display a message, use
rather g_warning.
Comment 14 Quentin Huot-Marchand 2014-04-16 01:58:39 UTC
Created attachment 274413 [details] [review]
patch for bug 349733

I'm sorry i forgot this stuff, it was a debug message...
Comment 15 Sébastien Granjoux 2014-04-16 19:00:24 UTC
Review of attachment 274413 [details] [review]:

Thank you, I have committed your patch without any changes.