* gdesktop.c (desktop_create_url): Accept new parameter
is_template. Use mc_mkstemps() is it's TRUE. Change all callers. * gcmd.c (gnome_new_link): Don't calculate the filename, trust desktop_create_url() to do it. * gdnd.c (drop_url_on_directory): Likewise. Add support for drag and drop from Mozilla.
Этот коммит содержится в:
родитель
b4be52ba78
Коммит
7f0c460355
@ -1,3 +1,13 @@
|
|||||||
|
2001-07-27 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* gdesktop.c (desktop_create_url): Accept new parameter
|
||||||
|
is_template. Use mc_mkstemps() is it's TRUE. Change all
|
||||||
|
callers.
|
||||||
|
* gcmd.c (gnome_new_link): Don't calculate the filename, trust
|
||||||
|
desktop_create_url() to do it.
|
||||||
|
* gdnd.c (drop_url_on_directory): Likewise. Add support for
|
||||||
|
drag and drop from Mozilla.
|
||||||
|
|
||||||
2001-07-26 Pavel Roskin <proski@gnu.org>
|
2001-07-26 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* gfind.c (get_list_info): Get row number as argument. Return
|
* gfind.c (get_list_info): Get row number as argument. Return
|
||||||
|
12
gnome/gcmd.c
12
gnome/gcmd.c
@ -973,6 +973,7 @@ void
|
|||||||
gnome_new_link (GtkWidget *widget, WPanel *panel)
|
gnome_new_link (GtkWidget *widget, WPanel *panel)
|
||||||
{
|
{
|
||||||
char *template;
|
char *template;
|
||||||
|
char *icon;
|
||||||
char *url;
|
char *url;
|
||||||
|
|
||||||
url = input_expand_dialog (_("Creating a desktop link"),
|
url = input_expand_dialog (_("Creating a desktop link"),
|
||||||
@ -980,15 +981,12 @@ gnome_new_link (GtkWidget *widget, WPanel *panel)
|
|||||||
if (!url)
|
if (!url)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
template = g_concat_dir_and_file (desktop_directory, "urlXXXXXX");
|
template = g_concat_dir_and_file (desktop_directory, "url");
|
||||||
|
|
||||||
if (mktemp (template)) {
|
icon = g_concat_dir_and_file (ICONDIR, "gnome-http-url.png");
|
||||||
char *icon;
|
desktop_create_url (template, url, url, icon, TRUE);
|
||||||
|
|
||||||
icon = g_concat_dir_and_file (ICONDIR, "gnome-http-url.png");
|
g_free (icon);
|
||||||
desktop_create_url (template, url, url, icon);
|
|
||||||
g_free (icon);
|
|
||||||
}
|
|
||||||
g_free (template);
|
g_free (template);
|
||||||
g_free (url);
|
g_free (url);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ desktop_load_init_from (const char *file)
|
|||||||
if (url && *url){
|
if (url && *url){
|
||||||
char *filename = g_concat_dir_and_file (desktop_directory, key);
|
char *filename = g_concat_dir_and_file (desktop_directory, key);
|
||||||
|
|
||||||
desktop_create_url (filename, title, url, icon2);
|
desktop_create_url (filename, title, url, icon2, FALSE);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3593,21 +3593,36 @@ desktop_destroy (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
desktop_create_url (const char *filename, const char *title, const char *url, const char *icon)
|
desktop_create_url (const char *filename, const char *title,
|
||||||
|
const char *url, const char *icon, gboolean is_template)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
char *tmpname = NULL;
|
||||||
|
|
||||||
f = fopen (filename, "w");
|
if (is_template) {
|
||||||
if (f) {
|
int fd;
|
||||||
|
|
||||||
fprintf (f, "URL: %s\n", url);
|
fd = mc_mkstemps (&tmpname, filename, NULL);
|
||||||
fclose (f);
|
if (fd == -1)
|
||||||
|
return;
|
||||||
gnome_metadata_set (filename, "desktop-url",
|
f = fdopen (fd, "w");
|
||||||
strlen (url) + 1, url);
|
filename = tmpname;
|
||||||
gnome_metadata_set (filename, "icon-caption",
|
} else {
|
||||||
strlen (title) + 1, title);
|
f = fopen (filename, "w");
|
||||||
|
|
||||||
gnome_metadata_set (filename, "icon-filename", strlen (icon) + 1, icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!f) {
|
||||||
|
g_free (tmpname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (f, "URL: %s\n", url);
|
||||||
|
fclose (f);
|
||||||
|
|
||||||
|
gnome_metadata_set (filename, "desktop-url",
|
||||||
|
strlen (url) + 1, url);
|
||||||
|
gnome_metadata_set (filename, "icon-caption",
|
||||||
|
strlen (title) + 1, title);
|
||||||
|
|
||||||
|
gnome_metadata_set (filename, "icon-filename", strlen (icon) + 1, icon);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,9 @@ void desktop_rescan_devices (void);
|
|||||||
void desktop_recreate_default_icons (void);
|
void desktop_recreate_default_icons (void);
|
||||||
void desktop_reload_icons (int user_pos, int xpos, int ypos);
|
void desktop_reload_icons (int user_pos, int xpos, int ypos);
|
||||||
void desktop_arrange_icons (SortType type);
|
void desktop_arrange_icons (SortType type);
|
||||||
void desktop_create_url (const char *filename, const char *title, const char *url, const char *icon);
|
void desktop_create_url (const char *filename, const char *title,
|
||||||
|
const char *url, const char *icon,
|
||||||
|
gboolean is_template);
|
||||||
void desktop_tidy_icons (void);
|
void desktop_tidy_icons (void);
|
||||||
|
|
||||||
|
|
||||||
|
29
gnome/gdnd.c
29
gnome/gdnd.c
@ -263,20 +263,27 @@ static void
|
|||||||
drop_url_on_directory (GdkDragContext *context, GtkSelectionData *selection_data, char *destdir)
|
drop_url_on_directory (GdkDragContext *context, GtkSelectionData *selection_data, char *destdir)
|
||||||
{
|
{
|
||||||
char *template;
|
char *template;
|
||||||
|
char *icon;
|
||||||
|
char *url;
|
||||||
|
char *title;
|
||||||
|
|
||||||
template = g_concat_dir_and_file (destdir, "urlXXXXXX");
|
template = g_concat_dir_and_file (destdir, "url");
|
||||||
|
icon = g_concat_dir_and_file (ICONDIR, "gnome-http-url.png");
|
||||||
|
|
||||||
if (mktemp (template)) {
|
/* Mozilla uses newline to separate URL from title. */
|
||||||
char *icon;
|
url = g_strdup(selection_data->data);
|
||||||
|
title = strchr (url, '\n');
|
||||||
icon = g_concat_dir_and_file (ICONDIR, "gnome-http-url.png");
|
if (title) {
|
||||||
desktop_create_url (
|
title[0] = 0;
|
||||||
template,
|
title++;
|
||||||
selection_data->data,
|
} else {
|
||||||
selection_data->data,
|
title = url;
|
||||||
icon);
|
|
||||||
g_free (icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
desktop_create_url (template, title, url, icon, TRUE);
|
||||||
|
|
||||||
|
g_free (url);
|
||||||
|
g_free (icon);
|
||||||
g_free (template);
|
g_free (template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user