1999-08-06 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop.c (try_rename): New function to rename a desktop icon's file by using a file operation context. (text_changed): Use try_rename() instead of fiddling with the VFS directly. BUGFIX: GNOME bug tracker #707. Also, destroy the old icon before updating the desktop.
Этот коммит содержится в:
родитель
972271c9e2
Коммит
a98d957baa
@ -1,3 +1,11 @@
|
|||||||
|
1999-08-06 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||||
|
|
||||||
|
* gdesktop.c (try_rename): New function to rename a desktop icon's
|
||||||
|
file by using a file operation context.
|
||||||
|
(text_changed): Use try_rename() instead of fiddling with the VFS
|
||||||
|
directly. BUGFIX: GNOME bug tracker #707. Also, destroy the old
|
||||||
|
icon before updating the desktop.
|
||||||
|
|
||||||
1999-08-06 Norbert Warmuth <nwarmuth@privat.circular.de>
|
1999-08-06 Norbert Warmuth <nwarmuth@privat.circular.de>
|
||||||
|
|
||||||
* gconf.h (PORT_STATIC_IN_STRING_FILE_XTIME): new port specific
|
* gconf.h (PORT_STATIC_IN_STRING_FILE_XTIME): new port specific
|
||||||
|
@ -804,8 +804,41 @@ set_icon_wmclass (DesktopIconInfo *dii)
|
|||||||
XFree (h);
|
XFree (h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Renames a file using a file operation context */
|
||||||
* Callback used when an icon's text changes. We must validate the
|
static int
|
||||||
|
try_rename (char *source, char *dest)
|
||||||
|
{
|
||||||
|
FileOpContext *ctx;
|
||||||
|
struct stat s;
|
||||||
|
long count;
|
||||||
|
double bytes;
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
if (mc_lstat (source, &s) != 0)
|
||||||
|
return FILE_ABORT;
|
||||||
|
|
||||||
|
ctx = file_op_context_new ();
|
||||||
|
file_op_context_create_ui (ctx, OP_MOVE, FALSE);
|
||||||
|
|
||||||
|
count = 1;
|
||||||
|
bytes = s.st_size;
|
||||||
|
|
||||||
|
retval = move_file_file (ctx, source, dest, &count, &bytes);
|
||||||
|
file_op_context_destroy (ctx);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Removes the Gtk and Gdk grabs that are present when editing a desktop icon */
|
||||||
|
static void
|
||||||
|
remove_editing_grab (DesktopIconInfo *dii)
|
||||||
|
{
|
||||||
|
gtk_grab_remove (dii->dicon);
|
||||||
|
gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
||||||
|
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Callback used when an icon's text changes. We must validate the
|
||||||
* rename and return the appropriate value. The desktop icon info
|
* rename and return the appropriate value. The desktop icon info
|
||||||
* structure is passed in the user data.
|
* structure is passed in the user data.
|
||||||
*/
|
*/
|
||||||
@ -821,6 +854,7 @@ text_changed (GnomeIconTextItem *iti, gpointer data)
|
|||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
dii = data;
|
dii = data;
|
||||||
|
remove_editing_grab (dii);
|
||||||
|
|
||||||
source = g_concat_dir_and_file (desktop_directory, dii->filename);
|
source = g_concat_dir_and_file (desktop_directory, dii->filename);
|
||||||
new_name = gnome_icon_text_item_get_text (iti);
|
new_name = gnome_icon_text_item_get_text (iti);
|
||||||
@ -830,9 +864,23 @@ text_changed (GnomeIconTextItem *iti, gpointer data)
|
|||||||
|
|
||||||
dest = g_concat_dir_and_file (desktop_directory, new_name);
|
dest = g_concat_dir_and_file (desktop_directory, new_name);
|
||||||
|
|
||||||
if (mc_rename (source, dest) == 0) {
|
if (try_rename (source, dest) == FILE_CONT) {
|
||||||
gnome_metadata_delete (dest);
|
GList *icons;
|
||||||
gnome_metadata_rename (source, dest);
|
GList *l;
|
||||||
|
|
||||||
|
/* See if there was an icon for the new name. If so,
|
||||||
|
* destroy it first; desktop_reload_icons() will not be
|
||||||
|
* happy if two icons have the same filename.
|
||||||
|
*/
|
||||||
|
|
||||||
|
icons = get_all_icons ();
|
||||||
|
l = icon_exists_in_list (icons, new_name);
|
||||||
|
if (l)
|
||||||
|
desktop_icon_info_destroy (l->data);
|
||||||
|
|
||||||
|
g_list_free (icons);
|
||||||
|
|
||||||
|
/* Set the new name */
|
||||||
|
|
||||||
g_free (dii->filename);
|
g_free (dii->filename);
|
||||||
dii->filename = g_strdup (new_name);
|
dii->filename = g_strdup (new_name);
|
||||||
@ -928,10 +976,7 @@ editing_stopped (GnomeIconTextItem *iti, gpointer data)
|
|||||||
DesktopIconInfo *dii;
|
DesktopIconInfo *dii;
|
||||||
|
|
||||||
dii = data;
|
dii = data;
|
||||||
|
remove_editing_grab (dii);
|
||||||
gtk_grab_remove (dii->dicon);
|
|
||||||
gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
|
||||||
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
|
|
||||||
|
|
||||||
/* Re-enable drags from this icon */
|
/* Re-enable drags from this icon */
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user