From 6eb9a08b29cf3a79be9c5e139b234d5acc4a85c5 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Wed, 17 Feb 1999 19:58:24 +0000 Subject: [PATCH] 1999-02-17 Miguel de Icaza * gdesktop.c (reload_desktop_icons): Load the information provided on the .desktop file for the desktop icon information: icon filename and text to be displayed. --- gnome/ChangeLog | 6 +++++- gnome/gdesktop.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gnome/ChangeLog b/gnome/ChangeLog index 69ab5f599..b41dbe92f 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,9 +1,13 @@ 1999-02-17 Miguel de Icaza + * gdesktop.c (reload_desktop_icons): Load the information provided + on the .desktop file for the desktop icon information: icon + filename and text to be displayed. + * gpopup.c (create_actions): Add ejectable * gdesktop.c (do_eject): Add eject command. - + 1999-02-16 Miguel de Icaza * gpopup.c (create_actions): Add support for mountable icons. diff --git a/gnome/gdesktop.c b/gnome/gdesktop.c index 1c7b69e0e..2994130be 100644 --- a/gnome/gdesktop.c +++ b/gnome/gdesktop.c @@ -368,6 +368,7 @@ reload_desktop_icons (int user_pos, int xpos, int ypos) GSList *need_position_list, *sl; GList *all_icons, *l; char *desktop_url, *caption; + const char *mime; int orig_xpos, orig_ypos; dir = mc_opendir (desktop_directory); @@ -502,6 +503,33 @@ reload_desktop_icons (int user_pos, int xpos, int ypos) get_icon_auto_pos (&xpos, &ypos); } + /* + * If the file dropped was a .desktop file, pull the suggested + * title and icon from there + */ + mime = gnome_mime_type_or_default (fau->filename, NULL); + if (mime && strcmp (mime, "application/x-gnome-app-info") == 0){ + GnomeDesktopEntry *entry; + char *fullname = g_concat_dir_and_file (desktop_directory, fau->filename); + + entry = gnome_desktop_entry_load (fullname); + if (entry){ + if (entry->name){ + if (fau->caption) + g_free (fau->caption); + fau->caption = g_strdup (entry->name); + gnome_metadata_set (fullname, "icon-caption", + strlen (fau->caption)+1, fau->caption); + } + if (entry->icon){ + gnome_metadata_set (fullname, "icon-filename", + strlen (entry->icon)+1, entry->icon); + } + gnome_desktop_entry_free (entry); + } + g_free (fullname); + } + dii = desktop_icon_info_new (fau->filename, fau->url, fau->caption, xpos, ypos); gtk_widget_show (dii->dicon); @@ -1587,7 +1615,8 @@ desktop_icon_info_new (char *filename, char *url, char *caption, int xpos, int y caption = url; } else { dii->url = NULL; - caption = filename; + if (caption == NULL) + caption = filename; } icon_im = gicon_get_icon_for_file (desktop_directory, fe, FALSE);