1999-02-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdnd.c (drop_on_file): Fix these so that they can use the metadata drop-action.
Этот коммит содержится в:
родитель
1caafe5ce5
Коммит
222cb72a9a
67
gnome/gdnd.c
67
gnome/gdnd.c
@ -317,13 +317,41 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
|
|||||||
const char *mime_type;
|
const char *mime_type;
|
||||||
char *full_name;
|
char *full_name;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
|
retval = FALSE; /* assume we cannot drop */
|
||||||
|
full_name = g_concat_dir_and_file (directory, dest_fe->fname);
|
||||||
|
|
||||||
|
/* 1. Try to use a metadata-based drop action */
|
||||||
|
|
||||||
|
if (gnome_metadata_get (full_name, "drop-action", &size, &buf) == 0) {
|
||||||
|
gmc_execute (full_name, buf, 0);
|
||||||
|
g_free (buf);
|
||||||
|
retval = TRUE;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2. Try a drop action from the MIME-type */
|
||||||
|
|
||||||
|
mime_type = gnome_mime_type_or_default (full_name, NULL);
|
||||||
|
if (mime_type) {
|
||||||
|
const char *action;
|
||||||
|
|
||||||
|
action = gnome_mime_get_value (mime_type, "drop-action");
|
||||||
|
if (action) {
|
||||||
|
gmc_execute (full_name, action, 0);
|
||||||
|
retval = TRUE;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3. If executable, try metadata keys for "open" */
|
||||||
|
|
||||||
|
if (is_exe (dest_fe->buf.st_mode) && if_link_is_exe (directory, dest_fe)) {
|
||||||
GList *names, *l;
|
GList *names, *l;
|
||||||
int len, i;
|
int len, i;
|
||||||
char **drops;
|
char **drops;
|
||||||
|
|
||||||
|
/* FIXME: handle the case for Netscape URLs */
|
||||||
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 */
|
/* Convert the data list into an array of strings */
|
||||||
|
|
||||||
@ -341,39 +369,13 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
|
|||||||
}
|
}
|
||||||
drops[i] = NULL;
|
drops[i] = NULL;
|
||||||
|
|
||||||
/* 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);
|
|
||||||
g_free (buf);
|
|
||||||
retval = TRUE;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 2. Try a drop action from the MIME-type */
|
|
||||||
|
|
||||||
mime_type = gnome_mime_type_or_default (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);
|
|
||||||
retval = TRUE;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 3. If executable, try metadata keys for "open" */
|
|
||||||
|
|
||||||
if (is_exe (dest_fe->buf.st_mode) && if_link_is_exe (directory, dest_fe)) {
|
|
||||||
/* FIXME: handle the case for Netscape URLs */
|
|
||||||
|
|
||||||
if (gnome_metadata_get (full_name, "open", &size, &buf) == 0)
|
if (gnome_metadata_get (full_name, "open", &size, &buf) == 0)
|
||||||
exec_extension (full_name, buf, drops, NULL, 0, 0);
|
exec_extension (full_name, buf, drops, NULL, 0, 0);
|
||||||
else
|
else
|
||||||
exec_extension (full_name, "%f %q", drops, NULL, 0, 0);
|
exec_extension (full_name, "%f %q", drops, NULL, 0, 0);
|
||||||
|
|
||||||
|
g_free (drops);
|
||||||
|
gnome_uri_list_free_strings (names);
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
|
|
||||||
retval = TRUE;
|
retval = TRUE;
|
||||||
@ -381,8 +383,7 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (drops);
|
|
||||||
gnome_uri_list_free_strings (names);
|
|
||||||
g_free (full_name);
|
g_free (full_name);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user