Commit f105b8e4 authored by Vincent Untz's avatar Vincent Untz Committed by Vincent Untz
Browse files

add icon for home folder new (panel_place_menu_item_create_menu): don't

2007-07-01  Vincent Untz  <vuntz@gnome.org>

	* panel-icon-names.h: add icon for home folder
	* panel-menu-items.c: (activate_home_uri): new
	(panel_place_menu_item_create_menu): don't use nautilus-home.desktop,
	but create a "place" menu item. Fix bug #338700.
	Also, put an uri for the Desktop menu item, else it will crash on drag
	and drop.
	* panel-util.c: (panel_util_get_icon_for_uri_known_folders): new, gets
	the icon for some well-know folders ($HOME, $Desktop)
	(panel_util_get_icon_for_uri): updated to use
	panel_util_get_icon_for_uri_known_folders()
	* panel.c: (drop_uri): get the icon too
	(drop_urilist): updated, don't get an icon here for uris

svn path=/trunk/; revision=10507
parent c6a3a83e
2007-07-01 Vincent Untz <vuntz@gnome.org>
* panel-icon-names.h: add icon for home folder
* panel-menu-items.c: (activate_home_uri): new
(panel_place_menu_item_create_menu): don't use nautilus-home.desktop,
but create a "place" menu item. Fix bug #338700.
Also, put an uri for the Desktop menu item, else it will crash on drag
and drop.
* panel-util.c: (panel_util_get_icon_for_uri_known_folders): new, gets
the icon for some well-know folders ($HOME, $Desktop)
(panel_util_get_icon_for_uri): updated to use
panel_util_get_icon_for_uri_known_folders()
* panel.c: (drop_uri): get the icon too
(drop_urilist): updated, don't get an icon here for uris
2007-07-01 Vincent Untz <vuntz@gnome.org>
 
* panel-lockdown.c: (panel_lockdown_notify_find): compare the
......
......@@ -9,6 +9,7 @@
#define PANEL_ICON_FOLDER "folder"
#define PANEL_ICON_FONTS "preferences-desktop-font"
#define PANEL_ICON_FORCE_QUIT "gnome-panel-force-quit"
#define PANEL_ICON_HOME "user-home"
#define PANEL_ICON_LAUNCHER "gnome-panel-launcher"
#define PANEL_ICON_LOCKSCREEN "system-lock-screen"
#define PANEL_ICON_LOGOUT "gnome-logout"
......
......@@ -128,6 +128,13 @@ activate_uri (GtkWidget *menuitem,
g_free (url);
}
static void
activate_home_uri (GtkWidget *menuitem,
gpointer data)
{
activate_uri (menuitem, g_get_home_dir ());
}
static void
activate_desktop_uri (GtkWidget *menuitem,
gpointer data)
......@@ -565,21 +572,31 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
GtkWidget *places_menu;
GtkWidget *item;
char *gconf_name;
char *uri;
places_menu = panel_create_menu ();
gconf_name = gconf_client_get_string (panel_gconf_get_client (),
HOME_NAME_KEY,
NULL);
panel_menu_items_append_from_desktop (places_menu,
"nautilus-home.desktop",
gconf_name);
uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
panel_menu_items_append_place_item (PANEL_ICON_HOME,
string_empty (gconf_name) ?
_("Home Folder") : gconf_name,
_("Open your personal folder"),
places_menu,
G_CALLBACK (activate_home_uri),
uri);
g_free (uri);
if (gconf_name)
g_free (gconf_name);
if (!gconf_client_get_bool (panel_gconf_get_client (),
DESKTOP_IS_HOME_DIR_KEY,
NULL)) {
uri = gnome_vfs_get_uri_from_local_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
panel_menu_items_append_place_item (
PANEL_ICON_DESKTOP,
/* Translators: Desktop is used here as in
......@@ -590,7 +607,9 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
_("Open the contents of your desktop in a folder"),
places_menu,
G_CALLBACK (activate_desktop_uri),
NULL);
/* FIXME: if the dir changes, we'd need to update the drag data since the uri is not the same */
uri);
g_free (uri);
}
panel_place_menu_item_append_gtk_bookmarks (places_menu);
......
......@@ -1410,6 +1410,31 @@ panel_util_get_icon_for_uri_method (const char *uri)
return NULL;
}
static const char *
panel_util_get_icon_for_uri_known_folders (const char *uri)
{
const char *icon;
char *path;
int len;
icon = NULL;
path = gnome_vfs_get_local_path_from_uri (uri);
len = strlen (path);
if (path[len] == '/')
path[len] = '\0';
if (strcmp (path, g_get_home_dir ()) == 0)
icon = PANEL_ICON_HOME;
else if (strcmp (path,
g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP)) == 0)
icon = PANEL_ICON_DESKTOP;
g_free (path);
return icon;
}
/* This is based on nautilus_compute_title_for_uri() and
* nautilus_file_get_display_name_nocopy() */
char *
......@@ -1508,6 +1533,10 @@ panel_util_get_icon_for_uri (const char *text_uri)
if (!g_str_has_prefix (text_uri, "file:"))
return NULL;
icon = panel_util_get_icon_for_uri_known_folders (text_uri);
if (icon)
return g_strdup (icon);
return gnome_icon_lookup_sync (gtk_icon_theme_get_default (),
NULL, text_uri, NULL,
GNOME_ICON_LOOKUP_FLAGS_NONE,
......
......@@ -514,23 +514,32 @@ static gboolean
drop_uri (PanelWidget *panel,
int position,
const char *uri,
const char *icon)
const char *fallback_icon)
{
char *name;
char *comment;
char *buf;
char *icon;
if (!panel_profile_id_lists_are_writable ())
return FALSE;
name = panel_util_get_label_for_uri (uri);
icon = panel_util_get_icon_for_uri (uri);
if (!icon)
icon = g_strdup (fallback_icon);
comment = gnome_vfs_unescape_string_for_display (uri);
buf = gnome_vfs_unescape_string_for_display (uri);
/* Translators: %s is a URI */
comment = g_strdup_printf (_("Open '%s'"), buf);
g_free (buf);
panel_launcher_create_from_info (panel->toplevel, position, FALSE,
uri, name, comment, icon);
g_free (name);
g_free (comment);
g_free (icon);
return TRUE;
}
......@@ -651,22 +660,9 @@ drop_urilist (PanelWidget *panel,
success = FALSE;
g_free (filename);
} else {
char *icon;
//FIXME: use panel_util_get_icon_for_uri
icon = gnome_icon_lookup (gtk_icon_theme_get_default (),
NULL, NULL, NULL,
info, info->mime_type,
GNOME_ICON_LOOKUP_FLAGS_NONE,
NULL);
if (!icon)
icon = g_strdup (PANEL_ICON_UNKNOWN);
if (!drop_uri (panel, pos, uri, icon))
if (!drop_uri (panel, pos, uri,
PANEL_ICON_UNKNOWN))
success = FALSE;
g_free (icon);
}
} else {
if (!drop_uri (panel, pos, uri, PANEL_ICON_UNKNOWN))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment