diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2013-01-21 17:38:34 -0500 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2013-01-21 17:49:01 -0500 |
commit | f59a618db929d0db0e09e82d4563943e12a8c09a (patch) | |
tree | 3792e7215e885de33605d94b73f60de12a75c6d1 /gtk | |
parent | 03f220e4c20374b027845fd050b69e8a4acdff9f (diff) | |
download | gtk+-f59a618db929d0db0e09e82d4563943e12a8c09a.tar.gz |
Apply custom names to XDG dirs if possible
And make it possible to rename them
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkbookmarksmanager.c | 10 | ||||
-rw-r--r-- | gtk/gtkbookmarksmanager.h | 3 | ||||
-rw-r--r-- | gtk/gtkplacessidebar.c | 15 |
3 files changed, 25 insertions, 3 deletions
diff --git a/gtk/gtkbookmarksmanager.c b/gtk/gtkbookmarksmanager.c index 45acd47667..91ccd89c29 100644 --- a/gtk/gtkbookmarksmanager.c +++ b/gtk/gtkbookmarksmanager.c @@ -303,6 +303,16 @@ find_bookmark_link_for_file (GSList *bookmarks, GFile *file, int *position_ret) } gboolean +_gtk_bookmarks_manager_has_bookmark (GtkBookmarksManager *manager, + GFile *file) +{ + GSList *link; + + link = find_bookmark_link_for_file (manager->bookmarks, file, NULL); + return (link != NULL); +} + +gboolean _gtk_bookmarks_manager_insert_bookmark (GtkBookmarksManager *manager, GFile *file, gint position, diff --git a/gtk/gtkbookmarksmanager.h b/gtk/gtkbookmarksmanager.h index 44db7b6dde..f2efd6577b 100644 --- a/gtk/gtkbookmarksmanager.h +++ b/gtk/gtkbookmarksmanager.h @@ -69,6 +69,9 @@ gboolean _gtk_bookmarks_manager_reorder_bookmark (GtkBookmarksManager *manager, gint new_position, GError **error); +gboolean _gtk_bookmarks_manager_has_bookmark (GtkBookmarksManager *manager, + GFile *file); + gchar * _gtk_bookmarks_manager_get_bookmark_label (GtkBookmarksManager *manager, GFile *file); diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 7b2e5dcffc..2a1003f0dc 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -559,7 +559,12 @@ add_special_dirs (GtkPlacesSidebar *sidebar) } root = g_file_new_for_path (path); - name = g_file_get_basename (root); + + name = _gtk_bookmarks_manager_get_bookmark_label (sidebar->bookmarks_manager, root); + if (!name) { + name = g_file_get_basename (root); + } + icon = special_directory_get_gicon (index); mount_uri = g_file_get_uri (root); tooltip = g_file_get_parse_name (root); @@ -1725,7 +1730,7 @@ check_popup_sensitivity (GtkPlacesSidebar *sidebar, PopupMenuData *data, Selecti gtk_widget_set_visible (data->add_shortcut_item, (info->type == PLACES_MOUNTED_VOLUME)); gtk_widget_set_sensitive (data->remove_item, (info->type == PLACES_BOOKMARK)); - gtk_widget_set_sensitive (data->rename_item, (info->type == PLACES_BOOKMARK)); + gtk_widget_set_sensitive (data->rename_item, (info->type == PLACES_BOOKMARK || info->type == PLACES_XDG_DIR)); check_visibility (info->mount, info->volume, info->drive, &show_mount, &show_unmount, &show_eject, &show_rescan, &show_start, &show_stop); @@ -1992,7 +1997,7 @@ rename_selected_bookmark (GtkPlacesSidebar *sidebar) PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, -1); - if (type != PLACES_BOOKMARK) { + if (type != PLACES_BOOKMARK && type != PLACES_XDG_DIR) { return; } @@ -2969,6 +2974,10 @@ bookmarks_edited (GtkCellRenderer *cell, gtk_tree_path_free (path); file = g_file_new_for_uri (uri); + if (!_gtk_bookmarks_manager_has_bookmark (sidebar->bookmarks_manager, file)) { + _gtk_bookmarks_manager_insert_bookmark (sidebar->bookmarks_manager, file, -1, NULL); + } + _gtk_bookmarks_manager_set_bookmark_label (sidebar->bookmarks_manager, file, new_text, NULL); /* NULL-GError */ g_object_unref (file); |