summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/caja-places-sidebar.c310
1 files changed, 156 insertions, 154 deletions
diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c
index d176ad45..81ea95a2 100644
--- a/src/caja-places-sidebar.c
+++ b/src/caja-places-sidebar.c
@@ -149,9 +149,9 @@ typedef enum
} PlaceType;
typedef enum {
+ SECTION_COMPUTER,
SECTION_DEVICES,
SECTION_BOOKMARKS,
- SECTION_COMPUTER,
SECTION_NETWORK,
} SectionType;
@@ -489,6 +489,120 @@ update_places (CajaPlacesSidebar *sidebar)
volume_monitor = sidebar->volume_monitor;
+ /* COMPUTER */
+ last_iter = add_heading (sidebar, SECTION_COMPUTER,
+ _("Computer"));
+
+ /* add built in bookmarks */
+ desktop_path = caja_get_desktop_directory ();
+
+ /* home folder */
+ if (strcmp (g_get_home_dir(), desktop_path) != 0) {
+ char *display_name;
+
+ mount_uri = caja_get_home_directory_uri ();
+ display_name = g_filename_display_basename (g_get_home_dir ());
+ icon = g_themed_icon_new (CAJA_ICON_HOME);
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ display_name, icon,
+ mount_uri, NULL, NULL, NULL, 0,
+ _("Open your personal folder"));
+ g_object_unref (icon);
+ g_free (display_name);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_free (mount_uri);
+ }
+
+ /* desktop */
+ mount_uri = g_filename_to_uri (desktop_path, NULL, NULL);
+ icon = g_themed_icon_new (CAJA_ICON_DESKTOP);
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ _("Desktop"), icon,
+ mount_uri, NULL, NULL, NULL, 0,
+ _("Open the contents of your desktop in a folder"));
+ g_object_unref (icon);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_free (mount_uri);
+ g_free (desktop_path);
+
+ /* file system root */
+ mount_uri = "file:///"; /* No need to strdup */
+ icon = g_themed_icon_new (CAJA_ICON_FILESYSTEM);
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ _("File System"), icon,
+ mount_uri, NULL, NULL, NULL, 0,
+ _("Open the contents of the File System"));
+ g_object_unref (icon);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+
+
+ /* XDG directories */
+ xdg_dirs = NULL;
+ for (index = 0; index < G_USER_N_DIRECTORIES; index++) {
+
+ if (index == G_USER_DIRECTORY_DESKTOP ||
+ index == G_USER_DIRECTORY_TEMPLATES ||
+ index == G_USER_DIRECTORY_PUBLIC_SHARE) {
+ continue;
+ }
+
+ path = g_get_user_special_dir (index);
+
+ /* xdg resets special dirs to the home directory in case
+ * it's not finiding what it expects. We don't want the home
+ * to be added multiple times in that weird configuration.
+ */
+ if (path == NULL
+ || g_strcmp0 (path, g_get_home_dir ()) == 0
+ || g_list_find_custom (xdg_dirs, path, (GCompareFunc) g_strcmp0) != NULL) {
+ continue;
+ }
+
+ root = g_file_new_for_path (path);
+ name = g_file_get_basename (root);
+ icon = caja_user_special_directory_get_gicon (index);
+ mount_uri = g_file_get_uri (root);
+ tooltip = g_file_get_parse_name (root);
+
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ name, icon, mount_uri,
+ NULL, NULL, NULL, 0,
+ tooltip);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_free (name);
+ g_object_unref (root);
+ g_object_unref (icon);
+ g_free (mount_uri);
+ g_free (tooltip);
+
+ xdg_dirs = g_list_prepend (xdg_dirs, (char *)path);
+ }
+ g_list_free (xdg_dirs);
+
+ mount_uri = "trash:///"; /* No need to strdup */
+ icon = caja_trash_monitor_get_icon ();
+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_COMPUTER,
+ _("Trash"), icon, mount_uri,
+ NULL, NULL, NULL, 0,
+ _("Open the trash"));
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_object_unref (icon);
+
/* first go through all connected drives */
drives = g_volume_monitor_get_connected_drives (volume_monitor);
@@ -631,146 +745,6 @@ update_places (CajaPlacesSidebar *sidebar)
}
g_list_free (volumes);
- /* add bookmarks */
- bookmark_count = caja_bookmark_list_length (sidebar->bookmarks);
-
- for (index = 0; index < bookmark_count; ++index) {
- bookmark = caja_bookmark_list_item_at (sidebar->bookmarks, index);
-
- if (caja_bookmark_uri_known_not_to_exist (bookmark)) {
- continue;
- }
-
- root = caja_bookmark_get_location (bookmark);
- file = caja_file_get (root);
-
- if (is_built_in_bookmark (file)) {
- g_object_unref (root);
- caja_file_unref (file);
- continue;
- }
-
- name = caja_bookmark_get_name (bookmark);
- icon = caja_bookmark_get_icon (bookmark);
- mount_uri = caja_bookmark_get_uri (bookmark);
- tooltip = g_file_get_parse_name (root);
-
- last_iter = add_place (sidebar, PLACES_BOOKMARK,
- SECTION_BOOKMARKS,
- name, icon, mount_uri,
- NULL, NULL, NULL, index,
- tooltip);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
- g_free (name);
- g_object_unref (root);
- g_object_unref (icon);
- g_free (mount_uri);
- g_free (tooltip);
- }
-
- last_iter = add_heading (sidebar, SECTION_COMPUTER,
- _("Computer"));
-
- /* add built in bookmarks */
- desktop_path = caja_get_desktop_directory ();
-
- /* home folder */
- if (strcmp (g_get_home_dir(), desktop_path) != 0) {
- char *display_name;
-
- mount_uri = caja_get_home_directory_uri ();
- display_name = g_filename_display_basename (g_get_home_dir ());
- icon = g_themed_icon_new (CAJA_ICON_HOME);
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- SECTION_COMPUTER,
- display_name, icon,
- mount_uri, NULL, NULL, NULL, 0,
- _("Open your personal folder"));
- g_object_unref (icon);
- g_free (display_name);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
- g_free (mount_uri);
- }
-
- /* desktop */
- mount_uri = g_filename_to_uri (desktop_path, NULL, NULL);
- icon = g_themed_icon_new (CAJA_ICON_DESKTOP);
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- SECTION_COMPUTER,
- _("Desktop"), icon,
- mount_uri, NULL, NULL, NULL, 0,
- _("Open the contents of your desktop in a folder"));
- g_object_unref (icon);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
- g_free (mount_uri);
- g_free (desktop_path);
-
- /* file system root */
- mount_uri = "file:///"; /* No need to strdup */
- icon = g_themed_icon_new (CAJA_ICON_FILESYSTEM);
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- SECTION_COMPUTER,
- _("File System"), icon,
- mount_uri, NULL, NULL, NULL, 0,
- _("Open the contents of the File System"));
- g_object_unref (icon);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
-
-
- /* XDG directories */
- xdg_dirs = NULL;
- for (index = 0; index < G_USER_N_DIRECTORIES; index++) {
-
- if (index == G_USER_DIRECTORY_DESKTOP ||
- index == G_USER_DIRECTORY_TEMPLATES ||
- index == G_USER_DIRECTORY_PUBLIC_SHARE) {
- continue;
- }
-
- path = g_get_user_special_dir (index);
-
- /* xdg resets special dirs to the home directory in case
- * it's not finiding what it expects. We don't want the home
- * to be added multiple times in that weird configuration.
- */
- if (path == NULL
- || g_strcmp0 (path, g_get_home_dir ()) == 0
- || g_list_find_custom (xdg_dirs, path, (GCompareFunc) g_strcmp0) != NULL) {
- continue;
- }
-
- root = g_file_new_for_path (path);
- name = g_file_get_basename (root);
- icon = caja_user_special_directory_get_gicon (index);
- mount_uri = g_file_get_uri (root);
- tooltip = g_file_get_parse_name (root);
-
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- SECTION_COMPUTER,
- name, icon, mount_uri,
- NULL, NULL, NULL, 0,
- tooltip);
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
- g_free (name);
- g_object_unref (root);
- g_object_unref (icon);
- g_free (mount_uri);
- g_free (tooltip);
-
- xdg_dirs = g_list_prepend (xdg_dirs, (char *)path);
- }
- g_list_free (xdg_dirs);
-
/* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */
network_mounts = NULL;
mounts = g_volume_monitor_get_mounts (volume_monitor);
@@ -817,17 +791,45 @@ update_places (CajaPlacesSidebar *sidebar)
}
g_list_free (mounts);
- mount_uri = "trash:///"; /* No need to strdup */
- icon = caja_trash_monitor_get_icon ();
- last_iter = add_place (sidebar, PLACES_BUILT_IN,
- SECTION_COMPUTER,
- _("Trash"), icon, mount_uri,
- NULL, NULL, NULL, 0,
- _("Open the trash"));
- compare_for_selection (sidebar,
- location, mount_uri, last_uri,
- &last_iter, &select_path);
- g_object_unref (icon);
+
+ /* add bookmarks */
+ bookmark_count = caja_bookmark_list_length (sidebar->bookmarks);
+
+ for (index = 0; index < bookmark_count; ++index) {
+ bookmark = caja_bookmark_list_item_at (sidebar->bookmarks, index);
+
+ if (caja_bookmark_uri_known_not_to_exist (bookmark)) {
+ continue;
+ }
+
+ root = caja_bookmark_get_location (bookmark);
+ file = caja_file_get (root);
+
+ if (is_built_in_bookmark (file)) {
+ g_object_unref (root);
+ caja_file_unref (file);
+ continue;
+ }
+
+ name = caja_bookmark_get_name (bookmark);
+ icon = caja_bookmark_get_icon (bookmark);
+ mount_uri = caja_bookmark_get_uri (bookmark);
+ tooltip = g_file_get_parse_name (root);
+
+ last_iter = add_place (sidebar, PLACES_BOOKMARK,
+ SECTION_BOOKMARKS,
+ name, icon, mount_uri,
+ NULL, NULL, NULL, index,
+ tooltip);
+ compare_for_selection (sidebar,
+ location, mount_uri, last_uri,
+ &last_iter, &select_path);
+ g_free (name);
+ g_object_unref (root);
+ g_object_unref (icon);
+ g_free (mount_uri);
+ g_free (tooltip);
+ }
/* network */
last_iter = add_heading (sidebar, SECTION_NETWORK,
@@ -3095,7 +3097,7 @@ padding_cell_renderer_func (GtkTreeViewColumn *column,
g_object_set (cell,
"visible", TRUE,
"xpad", 3,
- "ypad", 3,
+ "ypad", 0,
NULL);
}
}
@@ -3164,7 +3166,7 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
g_object_set (cell,
"weight", PANGO_WEIGHT_BOLD,
"weight-set", TRUE,
- "ypad", 6,
+ "ypad", 1,
"xpad", 0,
NULL);
gtk_tree_view_column_set_cell_data_func (col, cell,