Add set_show_properties and set_show_trash APIs

Currently they default to false.  This also fixes warnings with uninitialized widgets
in bookmarks_check_popup_sensitivity().

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
This commit is contained in:
Federico Mena Quintero 2012-09-11 14:33:47 -05:00
parent 992602e106
commit caf659e791
2 changed files with 53 additions and 39 deletions

View File

@ -114,6 +114,8 @@ struct _GtkPlacesSidebar {
guint multiple_tabs_supported : 1; guint multiple_tabs_supported : 1;
guint multiple_windows_supported : 1; guint multiple_windows_supported : 1;
guint show_desktop : 1; guint show_desktop : 1;
guint show_properties : 1;
guint show_trash : 1;
}; };
struct _GtkPlacesSidebarClass { struct _GtkPlacesSidebarClass {
@ -705,6 +707,7 @@ update_places (GtkPlacesSidebar *sidebar)
/* XDG directories */ /* XDG directories */
add_special_dirs (sidebar); add_special_dirs (sidebar);
if (sidebar->show_trash) {
mount_uri = "trash:///"; /* No need to strdup */ mount_uri = "trash:///"; /* No need to strdup */
icon = g_themed_icon_new (ICON_NAME_TRASH); icon = g_themed_icon_new (ICON_NAME_TRASH);
add_place (sidebar, PLACES_BUILT_IN, add_place (sidebar, PLACES_BUILT_IN,
@ -713,6 +716,7 @@ update_places (GtkPlacesSidebar *sidebar)
NULL, NULL, NULL, 0, NULL, NULL, NULL, 0,
_("Open the trash")); _("Open the trash"));
g_object_unref (icon); g_object_unref (icon);
}
/* go through all connected drives */ /* go through all connected drives */
drives = g_volume_monitor_get_connected_drives (volume_monitor); drives = g_volume_monitor_get_connected_drives (volume_monitor);
@ -1702,9 +1706,6 @@ bookmarks_check_popup_sensitivity (GtkPlacesSidebar *sidebar)
GVolume *volume = NULL; GVolume *volume = NULL;
GMount *mount = NULL; GMount *mount = NULL;
GFile *location; GFile *location;
#if DO_NOT_COMPILE
NautilusDirectory *directory;
#endif
gboolean show_mount; gboolean show_mount;
gboolean show_unmount; gboolean show_unmount;
gboolean show_eject; gboolean show_eject;
@ -1742,28 +1743,22 @@ bookmarks_check_popup_sensitivity (GtkPlacesSidebar *sidebar)
check_visibility (mount, volume, drive, check_visibility (mount, volume, drive,
&show_mount, &show_unmount, &show_eject, &show_rescan, &show_start, &show_stop); &show_mount, &show_unmount, &show_eject, &show_rescan, &show_start, &show_stop);
/* We actually want both eject and unmount since eject will unmount all volumes. if (sidebar->show_trash) {
* TODO: hide unmount if the drive only has a single mountable volume show_empty_trash = ((uri != NULL) &&
*/ (!strcmp (uri, "trash:///")));
} else
show_empty_trash = FALSE;
show_empty_trash = (uri != NULL) &&
(!strcmp (uri, "trash:///"));
#if DO_NOT_COMPILE
/* Only show properties for local mounts */ /* Only show properties for local mounts */
if (sidebar->show_properties) {
show_properties = (mount != NULL); show_properties = (mount != NULL);
if (mount != NULL) { if (mount != NULL) {
location = g_mount_get_default_location (mount); location = g_mount_get_default_location (mount);
directory = nautilus_directory_get (location); show_properties = g_file_is_native (location);
show_properties = nautilus_directory_is_local (directory);
nautilus_directory_unref (directory);
g_object_unref (location); g_object_unref (location);
} }
#else } else
show_properties = FALSE; show_properties = FALSE;
#endif
gtk_widget_set_visible (sidebar->popup_menu_separator_item, gtk_widget_set_visible (sidebar->popup_menu_separator_item,
show_mount || show_unmount || show_eject || show_empty_trash); show_mount || show_unmount || show_eject || show_empty_trash);
@ -2545,14 +2540,14 @@ stop_shortcut_cb (GtkMenuItem *item,
g_object_unref (drive); g_object_unref (drive);
} }
#if DO_NOT_COMPILE
static void static void
empty_trash_cb (GtkMenuItem *item, empty_trash_cb (GtkMenuItem *item,
GtkPlacesSidebar *sidebar) GtkPlacesSidebar *sidebar)
{ {
#if DO_NOT_COMPILE
nautilus_file_operations_empty_trash (GTK_WIDGET (sidebar->window)); nautilus_file_operations_empty_trash (GTK_WIDGET (sidebar->window));
}
#endif #endif
}
static gboolean static gboolean
find_prev_or_next_row (GtkPlacesSidebar *sidebar, find_prev_or_next_row (GtkPlacesSidebar *sidebar,
@ -2856,7 +2851,6 @@ bookmarks_build_popup_menu (GtkPlacesSidebar *sidebar)
gtk_widget_show (item); gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item); gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item);
#if DO_NOT_COMPILE
/* Empty Trash menu item */ /* Empty Trash menu item */
item = gtk_menu_item_new_with_mnemonic (_("Empty _Trash")); item = gtk_menu_item_new_with_mnemonic (_("Empty _Trash"));
@ -2868,8 +2862,7 @@ bookmarks_build_popup_menu (GtkPlacesSidebar *sidebar)
/* Properties menu item */ /* Properties menu item */
sidebar->popup_menu_properties_separator_item = sidebar->popup_menu_properties_separator_item = GTK_WIDGET (append_menu_separator (GTK_MENU (sidebar->popup_menu)));
GTK_WIDGET (eel_gtk_menu_append_separator (GTK_MENU (sidebar->popup_menu)));
item = gtk_menu_item_new_with_mnemonic (_("_Properties")); item = gtk_menu_item_new_with_mnemonic (_("_Properties"));
sidebar->popup_menu_properties_item = item; sidebar->popup_menu_properties_item = item;
@ -2878,8 +2871,6 @@ bookmarks_build_popup_menu (GtkPlacesSidebar *sidebar)
gtk_widget_show (item); gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item); gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item);
#endif
bookmarks_check_popup_sensitivity (sidebar); bookmarks_check_popup_sensitivity (sidebar);
} }
@ -3817,3 +3808,22 @@ gtk_places_sidebar_set_show_desktop (GtkPlacesSidebar *sidebar, gboolean show_de
sidebar->show_desktop = !!show_desktop; sidebar->show_desktop = !!show_desktop;
update_places (sidebar); update_places (sidebar);
} }
void
gtk_places_sidebar_set_show_properties (GtkPlacesSidebar *sidebar, gboolean show_properties)
{
g_return_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar));
sidebar->show_properties = !!show_properties;
bookmarks_check_popup_sensitivity (sidebar);
}
void
gtk_places_sidebar_set_show_trash (GtkPlacesSidebar *sidebar, gboolean show_trash)
{
g_return_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar));
sidebar->show_trash = !!show_trash;
update_places (sidebar);
}

View File

@ -62,6 +62,10 @@ void gtk_places_sidebar_set_multiple_windows_supported (GtkPlacesSidebar *sideba
void gtk_places_sidebar_set_show_desktop (GtkPlacesSidebar *sidebar, gboolean show_desktop); void gtk_places_sidebar_set_show_desktop (GtkPlacesSidebar *sidebar, gboolean show_desktop);
void gtk_places_sidebar_set_show_properties (GtkPlacesSidebar *sidebar, gboolean show_properties);
void gtk_places_sidebar_set_show_trash (GtkPlacesSidebar *sidebar, gboolean show_trash);
G_END_DECLS G_END_DECLS
#endif /* __GTK_PLACES_SIDEBAR_H__ */ #endif /* __GTK_PLACES_SIDEBAR_H__ */