1999-08-27 Federico Mena Quintero <federico@redhat.com>
* ext.c (quote_block): How did this ever work? People, if you realloc() things, don't keep pointers to stuff inside the original block. * screen.c (do_enter_on_file_entry): Pass in the full name to if_link_is_exe(). * dir.[ch] (if_link_is_exe): Take in the full name, not the directory and the file entry. 1999-08-26 Federico Mena Quintero <federico@redhat.com> * gscreen.c (panel_clist_drag_motion): Pass the full name to gdnd_validate_action(). (panel_icon_list_drag_motion): Likewise. (panel_tree_drag_motion): Likewise. * gdnd.c (gdnd_perform_drop): Renamed the "directory" argument to "dest_full_name" for clarity. (gdnd_validate_action): Likewise. Pass in the full name to if_link_is_exe(). (drop_on_file): Do not compute the full name, since we are already get it from the caller. (drop_on_file): Pass in the full name to if_link_is_exe(). * gscreen.c (panel_tree_drag_data_received): Free the pathname. * gdesktop.c (icon_drag_data_received): Pass the full name of the file to gdnd_perform_drop(), not just the desktop directory.
Этот коммит содержится в:
родитель
2eae1a244e
Коммит
871a880139
@ -1,3 +1,23 @@
|
||||
1999-08-26 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
* gscreen.c (panel_clist_drag_motion): Pass the full name to
|
||||
gdnd_validate_action().
|
||||
(panel_icon_list_drag_motion): Likewise.
|
||||
(panel_tree_drag_motion): Likewise.
|
||||
|
||||
* gdnd.c (gdnd_perform_drop): Renamed the "directory" argument to
|
||||
"dest_full_name" for clarity.
|
||||
(gdnd_validate_action): Likewise. Pass in the full name to
|
||||
if_link_is_exe().
|
||||
(drop_on_file): Do not compute the full name, since we are already
|
||||
get it from the caller.
|
||||
(drop_on_file): Pass in the full name to if_link_is_exe().
|
||||
|
||||
* gscreen.c (panel_tree_drag_data_received): Free the pathname.
|
||||
|
||||
* gdesktop.c (icon_drag_data_received): Pass the full name of the
|
||||
file to gdnd_perform_drop(), not just the desktop directory.
|
||||
|
||||
1999-08-23 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
* gdesktop-prefs.[ch]: New files that handle the desktop
|
||||
|
@ -2044,7 +2044,7 @@ icon_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gin
|
||||
return;
|
||||
}
|
||||
|
||||
if (gdnd_perform_drop (context, data, desktop_directory, fe))
|
||||
if (gdnd_perform_drop (context, data, full_name, fe))
|
||||
desktop_reload_icons (FALSE, 0, 0);
|
||||
|
||||
file_entry_free (fe);
|
||||
|
36
gnome/gdnd.c
36
gnome/gdnd.c
@ -301,20 +301,17 @@ drop_on_directory (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
/* Drop stuff on a non-directory file. This uses metadata and MIME as well. */
|
||||
static int
|
||||
drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
char *directory, file_entry *dest_fe)
|
||||
char *dest_full_name, file_entry *dest_fe)
|
||||
{
|
||||
int size;
|
||||
char *buf;
|
||||
const char *mime_type;
|
||||
char *full_name;
|
||||
int retval;
|
||||
GList *names, *l;
|
||||
int len, i;
|
||||
char **drops;
|
||||
|
||||
|
||||
retval = FALSE; /* assume we cannot drop */
|
||||
full_name = g_concat_dir_and_file (directory, dest_fe->fname);
|
||||
|
||||
/* Convert the data list into an array of strings */
|
||||
|
||||
@ -334,8 +331,8 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
|
||||
/* 1. Try to use a metadata-based drop action */
|
||||
|
||||
if (gnome_metadata_get (full_name, "drop-action", &size, &buf) == 0) {
|
||||
exec_extension (full_name, buf, drops, NULL, 0, 0);
|
||||
if (gnome_metadata_get (dest_full_name, "drop-action", &size, &buf) == 0) {
|
||||
exec_extension (dest_full_name, buf, drops, NULL, 0, 0);
|
||||
g_free (buf);
|
||||
retval = TRUE;
|
||||
goto out;
|
||||
@ -343,13 +340,13 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
|
||||
/* 2. Try a drop action from the MIME-type */
|
||||
|
||||
mime_type = gnome_mime_type_or_default (full_name, NULL);
|
||||
mime_type = gnome_mime_type_or_default (dest_full_name, NULL);
|
||||
if (mime_type) {
|
||||
const char *action;
|
||||
|
||||
action = gnome_mime_get_value (mime_type, "drop-action");
|
||||
if (action) {
|
||||
exec_extension (full_name, action, drops, NULL, 0, 0);
|
||||
exec_extension (dest_full_name, action, drops, NULL, 0, 0);
|
||||
retval = TRUE;
|
||||
goto out;
|
||||
}
|
||||
@ -357,13 +354,13 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
|
||||
/* 3. If executable, try metadata keys for "open" */
|
||||
|
||||
if (is_exe (dest_fe->buf.st_mode) && if_link_is_exe (directory, dest_fe)) {
|
||||
if (is_exe (dest_fe->buf.st_mode) && if_link_is_exe (dest_full_name, dest_fe)) {
|
||||
/* FIXME: handle the case for Netscape URLs */
|
||||
|
||||
if (gnome_metadata_get (full_name, "open", &size, &buf) == 0)
|
||||
exec_extension (full_name, buf, drops, NULL, 0, 0);
|
||||
if (gnome_metadata_get (dest_full_name, "open", &size, &buf) == 0)
|
||||
exec_extension (dest_full_name, buf, drops, NULL, 0, 0);
|
||||
else
|
||||
exec_extension (full_name, "%f %q", drops, NULL, 0, 0);
|
||||
exec_extension (dest_full_name, "%f %q", drops, NULL, 0, 0);
|
||||
|
||||
g_free (buf);
|
||||
|
||||
@ -374,19 +371,18 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
out:
|
||||
g_free (drops);
|
||||
gnome_uri_list_free_strings (names);
|
||||
g_free (full_name);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
gdnd_perform_drop (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
char *directory, file_entry *dest_fe)
|
||||
char *dest_full_name, file_entry *dest_fe)
|
||||
{
|
||||
GdkDragAction action;
|
||||
|
||||
g_return_val_if_fail (context != NULL, FALSE);
|
||||
g_return_val_if_fail (selection_data != NULL, FALSE);
|
||||
g_return_val_if_fail (directory != NULL, FALSE);
|
||||
g_return_val_if_fail (dest_full_name != NULL, FALSE);
|
||||
g_return_val_if_fail (dest_fe != NULL, FALSE);
|
||||
|
||||
/* Get action */
|
||||
@ -399,9 +395,9 @@ gdnd_perform_drop (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
action = context->action;
|
||||
|
||||
if (S_ISDIR (dest_fe->buf.st_mode) || dest_fe->f.link_to_dir)
|
||||
return drop_on_directory (context, selection_data, action, directory);
|
||||
return drop_on_directory (context, selection_data, action, dest_full_name);
|
||||
else
|
||||
return drop_on_file (context, selection_data, directory, dest_fe);
|
||||
return drop_on_file (context, selection_data, dest_full_name, dest_fe);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -486,13 +482,13 @@ gdnd_find_panel_by_drag_context (GdkDragContext *context, GtkWidget **source_wid
|
||||
GdkDragAction
|
||||
gdnd_validate_action (GdkDragContext *context,
|
||||
int on_desktop, int same_process, int same_source,
|
||||
char *directory, file_entry *dest_fe, int dest_selected)
|
||||
char *dest_full_name, file_entry *dest_fe, int dest_selected)
|
||||
{
|
||||
int on_directory;
|
||||
int on_exe;
|
||||
|
||||
g_return_val_if_fail (context != NULL, 0);
|
||||
g_return_val_if_fail (directory != NULL, 0);
|
||||
g_return_val_if_fail (dest_full_name != NULL, 0);
|
||||
|
||||
/* If we are dragging a desktop icon onto the desktop or onto a selected
|
||||
* desktop icon, unconditionally specify MOVE.
|
||||
@ -506,7 +502,7 @@ gdnd_validate_action (GdkDragContext *context,
|
||||
|
||||
if (dest_fe) {
|
||||
on_directory = S_ISDIR (dest_fe->buf.st_mode) || dest_fe->f.link_to_dir;
|
||||
on_exe = is_exe (dest_fe->buf.st_mode) && if_link_is_exe (directory, dest_fe);
|
||||
on_exe = is_exe (dest_fe->buf.st_mode) && if_link_is_exe (dest_full_name, dest_fe);
|
||||
}
|
||||
|
||||
if (gdnd_drag_context_has_target (context, TARGET_URI_LIST)) {
|
||||
|
@ -40,7 +40,7 @@ void gdnd_init (void);
|
||||
* Returns TRUE if an action was performed, FALSE otherwise (i.e. invalid drop).
|
||||
*/
|
||||
int gdnd_perform_drop (GdkDragContext *context, GtkSelectionData *selection_data,
|
||||
char *directory, file_entry *dest_fe);
|
||||
char *dest_full_name, file_entry *dest_fe);
|
||||
|
||||
/* Test whether the specified context has a certain target type */
|
||||
int gdnd_drag_context_has_target (GdkDragContext *context, TargetType type);
|
||||
@ -53,7 +53,7 @@ WPanel *gdnd_find_panel_by_drag_context (GdkDragContext *context, GtkWidget **so
|
||||
*/
|
||||
GdkDragAction gdnd_validate_action (GdkDragContext *context,
|
||||
int on_desktop, int same_process, int same_source,
|
||||
char *directory, file_entry *dest_fe, int dest_selected);
|
||||
char *dest_full_name, file_entry *dest_fe, int dest_selected);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -909,8 +909,10 @@ panel_tree_drag_data_received (GtkWidget *widget,
|
||||
|
||||
path = gtk_dtree_get_row_path (dtree, node, 0);
|
||||
fe = file_entry_from_file (path);
|
||||
if (!fe)
|
||||
if (!fe) {
|
||||
g_free (path);
|
||||
return; /* eeeek */
|
||||
}
|
||||
|
||||
reload = gdnd_perform_drop (context, selection_data, path, fe);
|
||||
|
||||
@ -1071,6 +1073,7 @@ panel_clist_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gin
|
||||
GtkWidget *source_widget;
|
||||
gint idx;
|
||||
file_entry *fe;
|
||||
char *full_name;
|
||||
|
||||
panel = data;
|
||||
|
||||
@ -1101,14 +1104,19 @@ panel_clist_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gin
|
||||
else
|
||||
fe = &panel->dir.list[idx];
|
||||
|
||||
full_name = fe ? g_concat_dir_and_file (panel->cwd, fe->fname) : panel->cwd;
|
||||
|
||||
action = gdnd_validate_action (context,
|
||||
FALSE,
|
||||
source_widget != NULL,
|
||||
source_widget == widget,
|
||||
panel->cwd,
|
||||
full_name,
|
||||
fe,
|
||||
fe ? fe->f.marked : FALSE);
|
||||
|
||||
if (full_name != panel->cwd)
|
||||
g_free (full_name);
|
||||
|
||||
gdk_drag_status (context, action, time);
|
||||
|
||||
out:
|
||||
@ -1202,6 +1210,7 @@ panel_icon_list_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x,
|
||||
GtkWidget *source_widget;
|
||||
int idx;
|
||||
file_entry *fe;
|
||||
char *full_name;
|
||||
|
||||
panel = data;
|
||||
|
||||
@ -1218,14 +1227,19 @@ panel_icon_list_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x,
|
||||
idx = gnome_icon_list_get_icon_at (GNOME_ICON_LIST (widget), x, y);
|
||||
fe = (idx == -1) ? NULL : &panel->dir.list[idx];
|
||||
|
||||
full_name = fe ? g_concat_dir_and_file (panel->cwd, fe->fname) : panel->cwd;
|
||||
|
||||
action = gdnd_validate_action (context,
|
||||
FALSE,
|
||||
source_widget != NULL,
|
||||
source_widget == widget,
|
||||
panel->cwd,
|
||||
full_name,
|
||||
fe,
|
||||
fe ? fe->f.marked : FALSE);
|
||||
|
||||
if (full_name != panel->cwd)
|
||||
g_free (full_name);
|
||||
|
||||
gdk_drag_status (context, action, time);
|
||||
return TRUE;
|
||||
}
|
||||
@ -1995,7 +2009,6 @@ panel_tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y
|
||||
GtkWidget *source_widget;
|
||||
char *row_path;
|
||||
int on_drag_row;
|
||||
char *parent_dir, *p;
|
||||
|
||||
dtree = GTK_DTREE (widget);
|
||||
panel = data;
|
||||
@ -2046,13 +2059,6 @@ panel_tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y
|
||||
panel->drag_tree_row = row;
|
||||
}
|
||||
|
||||
/* Compute the parent directory of the file entry */
|
||||
|
||||
parent_dir = g_strdup (row_path);
|
||||
p = strrchr (parent_dir, PATH_SEP);
|
||||
g_assert (p != NULL);
|
||||
p[1] = 0;
|
||||
|
||||
/* Validate the action */
|
||||
|
||||
gdnd_find_panel_by_drag_context (context, &source_widget);
|
||||
@ -2071,11 +2077,10 @@ panel_tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y
|
||||
FALSE,
|
||||
source_widget != NULL,
|
||||
source_widget == widget,
|
||||
parent_dir,
|
||||
row_path,
|
||||
panel->drag_tree_fe,
|
||||
on_drag_row);
|
||||
|
||||
g_free (parent_dir);
|
||||
g_free (row_path);
|
||||
} else {
|
||||
panel->drag_tree_row = -1;
|
||||
|
@ -1,3 +1,15 @@
|
||||
1999-08-27 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
* ext.c (quote_block): How did this ever work? People, if you
|
||||
realloc() things, don't keep pointers to stuff inside the original
|
||||
block.
|
||||
|
||||
* screen.c (do_enter_on_file_entry): Pass in the full name to
|
||||
if_link_is_exe().
|
||||
|
||||
* dir.[ch] (if_link_is_exe): Take in the full name, not the directory
|
||||
and the file entry.
|
||||
|
||||
1999-08-15 Norbert Warmuth <nwarmuth@privat.circular.de>
|
||||
|
||||
* cmd.c (guess_message_value): New function. Determine locale used
|
||||
|
@ -519,17 +519,12 @@ link_isdir (file_entry *file)
|
||||
}
|
||||
|
||||
int
|
||||
if_link_is_exe (char *directory, file_entry *file)
|
||||
if_link_is_exe (char *full_name, file_entry *file)
|
||||
{
|
||||
struct stat b;
|
||||
char *full_name;
|
||||
|
||||
full_name = concat_dir_and_file (directory, file->fname);
|
||||
|
||||
if (S_ISLNK (file->buf.st_mode)) {
|
||||
full_name = concat_dir_and_file (directory, file->fname);
|
||||
mc_stat (full_name, &b);
|
||||
g_free (full_name);
|
||||
return is_exe (b.st_mode);
|
||||
} else
|
||||
return 1;
|
||||
|
@ -79,7 +79,7 @@ typedef struct {
|
||||
extern sort_orders_t sort_orders [SORT_TYPES_TOTAL];
|
||||
|
||||
int link_isdir (file_entry *);
|
||||
int if_link_is_exe (char *directory, file_entry *file);
|
||||
int if_link_is_exe (char *full_name, file_entry *file);
|
||||
|
||||
extern int show_backups;
|
||||
extern int show_dot_files;
|
||||
|
29
src/ext.c
29
src/ext.c
@ -76,23 +76,32 @@ typedef char *(*quote_func_t)(const char *name, int i);
|
||||
static char *
|
||||
quote_block (quote_func_t quote_func, char **quoting_block)
|
||||
{
|
||||
char **p = quoting_block;
|
||||
char *result = 0;
|
||||
char *tail = 0;
|
||||
int current_len = 0;
|
||||
char **p;
|
||||
char *result;
|
||||
char *tail;
|
||||
int tail_index;
|
||||
int current_len;
|
||||
|
||||
for (p = quoting_block; *p; p++){
|
||||
result = NULL;
|
||||
current_len = 0;
|
||||
tail_index = 0;
|
||||
|
||||
for (p = quoting_block; *p; p++) {
|
||||
int temp_len;
|
||||
char *temp = quote_func (*p, 0);
|
||||
char *temp;
|
||||
|
||||
temp = quote_func (*p, FALSE);
|
||||
temp_len = strlen (temp);
|
||||
|
||||
current_len += temp_len + 2;
|
||||
result = g_realloc (result, current_len);
|
||||
if (!tail)
|
||||
tail = result;
|
||||
tail = result + tail_index;
|
||||
|
||||
strcpy (tail, temp);
|
||||
strcat (tail, " ");
|
||||
tail += temp_len + 1;
|
||||
tail[temp_len] = ' ';
|
||||
tail[temp_len + 1] = '\0';
|
||||
tail_index += temp_len + 1;
|
||||
|
||||
g_free (temp);
|
||||
}
|
||||
|
||||
|
18
src/screen.c
18
src/screen.c
@ -2087,6 +2087,7 @@ int
|
||||
do_enter_on_file_entry (file_entry *fe)
|
||||
{
|
||||
gint retval;
|
||||
char *full_name;
|
||||
|
||||
set_cursor_busy (cpanel);
|
||||
/* Can we change dirs? */
|
||||
@ -2101,7 +2102,9 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
return 1;
|
||||
}
|
||||
/* can we change dirs? */
|
||||
if (is_exe (fe->buf.st_mode) && if_link_is_exe (cpanel->cwd, fe)) {
|
||||
full_name = concat_dir_and_file (cpanel->cwd, fe->fname);
|
||||
if (is_exe (fe->buf.st_mode) && if_link_is_exe (full_name, fe)) {
|
||||
g_free (full_name);
|
||||
#ifdef USE_VFS
|
||||
if (vfs_current_is_local ())
|
||||
#endif
|
||||
@ -2112,6 +2115,7 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
_(" Do you really want to execute? "),
|
||||
0, 2, _("Yes"), _("No")) == 0))
|
||||
execute (cmd);
|
||||
|
||||
g_free (tmp);
|
||||
g_free (cmd);
|
||||
}
|
||||
@ -2128,6 +2132,8 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
set_cursor_normal (cpanel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_free (full_name);
|
||||
/* looks like we couldn't open it. Let's ask the user */
|
||||
retval = gmc_open_with (fe->fname);
|
||||
set_cursor_normal (cpanel);
|
||||
@ -2137,11 +2143,16 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
int
|
||||
do_enter_on_file_entry (file_entry *fe)
|
||||
{
|
||||
char *full_name;
|
||||
|
||||
if (S_ISDIR (fe->buf.st_mode) || link_isdir (fe)) {
|
||||
do_cd (fe->fname, cd_exact);
|
||||
return 1;
|
||||
} else {
|
||||
if (is_exe (fe->buf.st_mode) && if_link_is_exe (cpanel->cwd, fe)) {
|
||||
full_name = concat_dir_and_file (cpanel->cwd, fe->fname);
|
||||
if (is_exe (fe->buf.st_mode) && if_link_is_exe (full_name, fe)) {
|
||||
g_free (full_name);
|
||||
|
||||
#ifdef USE_VFS
|
||||
if (vfs_current_is_local ())
|
||||
#endif
|
||||
@ -2171,9 +2182,10 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
#endif /* USE_VFS */
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
char *p;
|
||||
|
||||
g_free (full_name);
|
||||
|
||||
p = regex_command (fe->fname, "Open", NULL, 0);
|
||||
if (p && (strcmp (p, "Success") == 0))
|
||||
return 1;
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user