Commit c3670555 authored by Christian Neumair's avatar Christian Neumair Committed by Christian Neumair

Allow to open location popup menu for any location, and not just for

2008-05-13  Christian Neumair  <cneumair@gnome.org>

	* libnautilus-private/nautilus-view.c
	(nautilus_view_pop_up_location_context_menu):
	* libnautilus-private/nautilus-view.h:
	* src/file-manager/fm-actions.h:
	* src/file-manager/fm-directory-view.c
	(action_self_properties_callback),
	(action_location_properties_callback),
	(fm_directory_view_finalize),
	(action_location_mount_volume_callback),
	(action_location_unmount_volume_callback),
	(action_location_eject_volume_callback),
	(action_location_format_volume_callback),
	(action_location_open_folder_window_callback),
	(action_location_cut_callback), (action_location_copy_callback),
	(action_location_trash_callback),
	(action_location_delete_callback),
	(real_update_location_menu_volumes), (real_update_location_menu),
	(fm_directory_view_pop_up_background_context_menu),
	(real_pop_up_location_context_menu),
	(location_popup_file_attributes_ready),
	(unschedule_pop_up_location_context_menu),
	(schedule_pop_up_location_context_menu),
	(fm_directory_view_pop_up_location_context_menu), (load_directory):
	* src/file-manager/fm-directory-view.h:
	* src/file-manager/nautilus-directory-view-ui.xml:
	* src/nautilus-location-bar.c (label_button_pressed_callback):
	* src/nautilus-navigation-window.c
	(nautilus_navigation_window_init),
	(path_bar_button_pressed_callback), (path_bar_path_set_callback):
	* src/nautilus-pathbar.c (nautilus_path_bar_class_init),
	(nautilus_path_bar_update_path),
	(nautilus_path_bar_get_path_for_button):
	* src/nautilus-pathbar.h:
	* src/nautilus-spatial-window.c (location_button_pressed_callback):
	Allow to open location popup menu for any location, and not just for
	currently open folder. Enable location popup menu for all path bar
	buttons. Add volume operations to location context menu. Fix
	separators in location context menu. Fixes #309844.
	Do not unref file when opening properties dialog from background
	context menu.

svn path=/trunk/; revision=14156
parent 54c9be4e
2008-05-13 Christian Neumair <cneumair@gnome.org>
* libnautilus-private/nautilus-view.c
(nautilus_view_pop_up_location_context_menu):
* libnautilus-private/nautilus-view.h:
* src/file-manager/fm-actions.h:
* src/file-manager/fm-directory-view.c
(action_self_properties_callback),
(action_location_properties_callback),
(fm_directory_view_finalize),
(action_location_mount_volume_callback),
(action_location_unmount_volume_callback),
(action_location_eject_volume_callback),
(action_location_format_volume_callback),
(action_location_open_folder_window_callback),
(action_location_cut_callback), (action_location_copy_callback),
(action_location_trash_callback),
(action_location_delete_callback),
(real_update_location_menu_volumes), (real_update_location_menu),
(fm_directory_view_pop_up_background_context_menu),
(real_pop_up_location_context_menu),
(location_popup_file_attributes_ready),
(unschedule_pop_up_location_context_menu),
(schedule_pop_up_location_context_menu),
(fm_directory_view_pop_up_location_context_menu), (load_directory):
* src/file-manager/fm-directory-view.h:
* src/file-manager/nautilus-directory-view-ui.xml:
* src/nautilus-location-bar.c (label_button_pressed_callback):
* src/nautilus-navigation-window.c
(nautilus_navigation_window_init),
(path_bar_button_pressed_callback), (path_bar_path_set_callback):
* src/nautilus-pathbar.c (nautilus_path_bar_class_init),
(nautilus_path_bar_update_path),
(nautilus_path_bar_get_path_for_button):
* src/nautilus-pathbar.h:
* src/nautilus-spatial-window.c (location_button_pressed_callback):
Allow to open location popup menu for any location, and not just for
currently open folder. Enable location popup menu for all path bar
buttons. Add volume operations to location context menu. Fix
separators in location context menu. Fixes #309844.
Do not unref file when opening properties dialog from background
context menu.
2008-05-13 Martin Wehner <martin.wehner@gmail.com>
* configure.in:
......
......@@ -269,11 +269,12 @@ nautilus_view_grab_focus (NautilusView *view)
void
nautilus_view_pop_up_location_context_menu (NautilusView *view,
GdkEventButton *event)
GdkEventButton *event,
const char *location)
{
g_return_if_fail (NAUTILUS_IS_VIEW (view));
if (NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu != NULL) {
(* NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu) (view, event);
(* NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu) (view, event, location);
}
}
......@@ -114,11 +114,14 @@ struct _NautilusViewIface
/* Request popup of context menu referring to the open location.
* This is triggered in spatial windows by right-clicking the location button,
* in navigational windows by right-clicking the "Location:" label in the
* navigation bar.
* navigation bar or any of the buttons in the pathbar.
* The location parameter specifies the location this popup should be displayed for.
* If it is NULL, the currently displayed location should be used.
* The view may display the popup synchronously, asynchronously
* or not react to the popup request at all. */
void (* pop_up_location_context_menu) (NautilusView *view,
GdkEventButton *event);
GdkEventButton *event,
const char *location);
/* Padding for future expansion */
void (*_reserved1) (void);
......@@ -156,7 +159,8 @@ gboolean nautilus_view_can_zoom_in (NautilusView *v
gboolean nautilus_view_can_zoom_out (NautilusView *view);
NautilusZoomLevel nautilus_view_get_zoom_level (NautilusView *view);
void nautilus_view_pop_up_location_context_menu (NautilusView *view,
GdkEventButton *event);
GdkEventButton *event,
const char *location);
void nautilus_view_grab_focus (NautilusView *view);
G_END_DECLS
......
......@@ -36,6 +36,7 @@
#define FM_ACTION_PROPERTIES "Properties"
#define FM_ACTION_PROPERTIES_ACCEL "PropertiesAccel"
#define FM_ACTION_SELF_PROPERTIES "SelfProperties"
#define FM_ACTION_LOCATION_PROPERTIES "LocationProperties"
#define FM_ACTION_NO_TEMPLATES "No Templates"
#define FM_ACTION_EMPTY_TRASH "Empty Trash"
#define FM_ACTION_SAVE_SEARCH "Save Search"
......@@ -67,6 +68,10 @@
#define FM_ACTION_SELF_UNMOUNT_VOLUME "Self Unmount Volume"
#define FM_ACTION_SELF_EJECT_VOLUME "Self Eject Volume"
#define FM_ACTION_SELF_FORMAT_VOLUME "Self Format Volume"
#define FM_ACTION_LOCATION_MOUNT_VOLUME "Location Mount Volume"
#define FM_ACTION_LOCATION_UNMOUNT_VOLUME "Location Unmount Volume"
#define FM_ACTION_LOCATION_EJECT_VOLUME "Location Eject Volume"
#define FM_ACTION_LOCATION_FORMAT_VOLUME "Location Format Volume"
#define FM_ACTION_SCRIPTS "Scripts"
#define FM_ACTION_NEW_DOCUMENTS "New Documents"
#define FM_ACTION_NEW_EMPTY_FILE "New Empty File"
......
......@@ -181,6 +181,8 @@ struct FMDirectoryViewDetails
NautilusWindowInfo *window;
NautilusDirectory *model;
NautilusFile *directory_as_file;
NautilusFile *location_popup_directory_as_file;
GdkEventButton *location_popup_event;
GtkActionGroup *dir_action_group;
guint dir_merge_id;
......@@ -378,6 +380,10 @@ static void action_location_trash_callback (GtkAction *action,
gpointer callback_data);
static void action_location_delete_callback (GtkAction *action,
gpointer callback_data);
static void action_location_properties_callback (GtkAction *action,
gpointer callback_data);
static void unschedule_pop_up_location_context_menu (FMDirectoryView *view);
EEL_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW)
......@@ -1382,7 +1388,29 @@ action_self_properties_callback (GtkAction *action,
g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
view = FM_DIRECTORY_VIEW (callback_data);
files = g_list_append (NULL, view->details->directory_as_file);
if (view->details->directory_as_file != NULL) {
files = g_list_append (NULL, nautilus_file_ref (view->details->directory_as_file));
fm_properties_window_present (files, GTK_WIDGET (view));
nautilus_file_list_free (files);
}
}
static void
action_location_properties_callback (GtkAction *action,
gpointer callback_data)
{
FMDirectoryView *view;
GList *files;
g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
view = FM_DIRECTORY_VIEW (callback_data);
g_assert (NAUTILUS_IS_FILE (view->details->location_popup_directory_as_file));
files = g_list_append (NULL, nautilus_file_ref (view->details->location_popup_directory_as_file));
fm_properties_window_present (files, GTK_WIDGET (view));
......@@ -1967,6 +1995,11 @@ fm_directory_view_finalize (GObject *object)
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST,
sort_directories_first_changed_callback, view);
unschedule_pop_up_location_context_menu (view);
if (view->details->location_popup_event != NULL) {
gdk_event_free ((GdkEvent *) view->details->location_popup_event);
}
g_hash_table_destroy (view->details->non_ready_files);
g_free (view->details);
......@@ -5991,6 +6024,81 @@ action_self_format_volume_callback (GtkAction *action,
#endif
}
static void
action_location_mount_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
FMDirectoryView *view;
GMountOperation *mount_op;
view = FM_DIRECTORY_VIEW (data);
file = view->details->location_popup_directory_as_file;
if (file == NULL) {
return;
}
mount_op = eel_mount_operation_new (fm_directory_view_get_containing_window (view));
nautilus_file_mount (file, mount_op, NULL, NULL, NULL);
g_object_unref (mount_op);
}
static void
action_location_unmount_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
file = view->details->location_popup_directory_as_file;
if (file == NULL) {
return;
}
nautilus_file_unmount (file);
}
static void
action_location_eject_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
file = view->details->location_popup_directory_as_file;
if (file == NULL) {
return;
}
nautilus_file_eject (file);
}
static void
action_location_format_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
file = view->details->location_popup_directory_as_file;
if (file == NULL) {
return;
}
#ifdef TODO_GIO
if (something) {
g_spawn_command_line_async ("gfloppy", NULL);
}
#endif
}
static void
connect_to_server_response_callback (GtkDialog *dialog,
int response_id,
......@@ -6145,7 +6253,7 @@ action_location_open_folder_window_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
file = view->details->directory_as_file;
file = view->details->location_popup_directory_as_file;
g_return_if_fail (file != NULL);
fm_directory_view_activate_file (view,
......@@ -6164,7 +6272,7 @@ action_location_cut_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
file = fm_directory_view_get_directory_as_file (view);
file = view->details->location_popup_directory_as_file;
g_return_if_fail (file != NULL);
files = g_list_append (NULL, file);
......@@ -6182,7 +6290,7 @@ action_location_copy_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
file = fm_directory_view_get_directory_as_file (view);
file = view->details->location_popup_directory_as_file;
g_return_if_fail (file != NULL);
files = g_list_append (NULL, file);
......@@ -6200,7 +6308,7 @@ action_location_trash_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
file = fm_directory_view_get_directory_as_file (view);
file = view->details->location_popup_directory_as_file;
g_return_if_fail (file != NULL);
files = g_list_append (NULL, file);
......@@ -6221,7 +6329,7 @@ action_location_delete_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
file = fm_directory_view_get_directory_as_file (view);
file = view->details->location_popup_directory_as_file;
g_return_if_fail (file != NULL);
location = nautilus_file_get_location (file);
......@@ -6475,6 +6583,28 @@ static const GtkActionEntry directory_view_entries[] = {
/* label, accelerator */ N_("_Delete"), "",
/* tooltip */ N_("Delete this folder, without moving to the Trash"),
G_CALLBACK (action_location_delete_callback) },
/* name, stock id */ { "Location Mount Volume", NULL,
/* label, accelerator */ N_("_Mount Volume"), NULL,
/* tooltip */ N_("Mount the volume associated with this folder"),
G_CALLBACK (action_location_mount_volume_callback) },
/* name, stock id */ { "Location Unmount Volume", NULL,
/* label, accelerator */ N_("_Unmount Volume"), NULL,
/* tooltip */ N_("Unmount the volume associated with this folder"),
G_CALLBACK (action_location_unmount_volume_callback) },
/* name, stock id */ { "Location Eject Volume", NULL,
/* label, accelerator */ N_("_Eject"), NULL,
/* tooltip */ N_("Eject the volume associated with this folder"),
G_CALLBACK (action_location_eject_volume_callback) },
/* name, stock id */ { "Location Format Volume", NULL,
/* label, accelerator */ N_("_Format"), NULL,
/* tooltip */ N_("Format the volume associated with this folder"),
G_CALLBACK (action_location_format_volume_callback) },
/* name, stock id */ { "LocationProperties", GTK_STOCK_PROPERTIES,
/* label, accelerator */ N_("_Properties"), NULL,
/* tooltip */ N_("View or modify the properties of this folder"),
G_CALLBACK (action_location_properties_callback) },
};
static const GtkToggleActionEntry directory_view_toggle_entries[] = {
......@@ -6931,6 +7061,45 @@ real_update_menus_volumes (FMDirectoryView *view,
gtk_action_set_visible (action, show_self_format);
}
static void
real_update_location_menu_volumes (FMDirectoryView *view)
{
GtkAction *action;
NautilusFile *file;
gboolean show_mount;
gboolean show_unmount;
gboolean show_eject;
gboolean show_connect;
gboolean show_format;
g_assert (FM_IS_DIRECTORY_VIEW (view));
g_assert (NAUTILUS_IS_FILE (view->details->location_popup_directory_as_file));
file = NAUTILUS_FILE (view->details->location_popup_directory_as_file);
file_should_show_foreach (file,
&show_mount,
&show_unmount,
&show_eject,
&show_connect,
&show_format);
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_LOCATION_MOUNT_VOLUME);
gtk_action_set_visible (action, show_mount);
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_LOCATION_UNMOUNT_VOLUME);
gtk_action_set_visible (action, show_unmount);
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_LOCATION_EJECT_VOLUME);
gtk_action_set_visible (action, show_eject);
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_LOCATION_FORMAT_VOLUME);
gtk_action_set_visible (action, show_format);
}
static void
real_update_paste_menu (FMDirectoryView *view,
GList *selection,
......@@ -7003,7 +7172,12 @@ real_update_location_menu (FMDirectoryView *view)
FM_ACTION_LOCATION_OPEN_FOLDER_WINDOW);
gtk_action_set_visible (action, show_open_folder_window);
file = view->details->directory_as_file;
file = view->details->location_popup_directory_as_file;
g_assert (NAUTILUS_IS_FILE (file));
g_assert (nautilus_file_check_if_ready (file, NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO));
is_special_link = NAUTILUS_IS_DESKTOP_ICON_FILE (file);
is_desktop_or_home_dir = nautilus_file_is_home (file)
|| nautilus_file_is_desktop_directory (file);
......@@ -7043,8 +7217,10 @@ real_update_location_menu (FMDirectoryView *view)
gtk_action_set_sensitive (action, can_delete_file);
}
real_update_location_menu_volumes (view);
/* we silently assume that fm_directory_view_supports_properties always returns the same value.
* Therefore, we don't update the sensitivity of FM_ACTION_SELF_PROPERTIES */
* Therefore, we don't update the sensitivity of FM_ACTION_LOCATION_PROPERTIES */
}
static void
......@@ -7412,6 +7588,7 @@ fm_directory_view_pop_up_background_context_menu (FMDirectoryView *view,
update_context_menu_position_from_event (view, event);
eel_pop_up_context_menu (create_popup_menu
(view, FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND),
EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
......@@ -7419,30 +7596,108 @@ fm_directory_view_pop_up_background_context_menu (FMDirectoryView *view,
event);
}
static void
real_pop_up_location_context_menu (FMDirectoryView *view)
{
/* always update the menu before showing it. Shouldn't be too expensive. */
real_update_location_menu (view);
update_context_menu_position_from_event (view, view->details->location_popup_event);
eel_pop_up_context_menu (create_popup_menu
(view, FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION),
EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
view->details->location_popup_event);
}
static void
location_popup_file_attributes_ready (NautilusFile *file,
gpointer data)
{
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
g_assert (FM_IS_DIRECTORY_VIEW (view));
g_assert (file == view->details->location_popup_directory_as_file);
real_pop_up_location_context_menu (view);
}
static void
unschedule_pop_up_location_context_menu (FMDirectoryView *view)
{
if (view->details->location_popup_directory_as_file != NULL) {
g_assert (NAUTILUS_IS_FILE (view->details->location_popup_directory_as_file));
nautilus_file_cancel_call_when_ready (view->details->location_popup_directory_as_file,
location_popup_file_attributes_ready,
view);
nautilus_file_unref (view->details->location_popup_directory_as_file);
view->details->location_popup_directory_as_file = NULL;
}
}
static void
schedule_pop_up_location_context_menu (FMDirectoryView *view,
GdkEventButton *event,
NautilusFile *file)
{
g_assert (NAUTILUS_IS_FILE (file));
if (view->details->location_popup_event != NULL) {
gdk_event_free ((GdkEvent *) view->details->location_popup_event);
}
view->details->location_popup_event = (GdkEventButton *) gdk_event_copy ((GdkEvent *)event);
if (file == view->details->location_popup_directory_as_file) {
if (nautilus_file_check_if_ready (file, NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO)) {
real_pop_up_location_context_menu (view);
}
} else {
unschedule_pop_up_location_context_menu (view);
view->details->location_popup_directory_as_file = nautilus_file_ref (file);
nautilus_file_call_when_ready (view->details->location_popup_directory_as_file,
NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO,
location_popup_file_attributes_ready,
view);
}
}
/**
* fm_directory_view_pop_up_location_context_menu
*
* Pop up a context menu appropriate to the view globally.
* @view: FMDirectoryView of interest.
* @event: GdkEventButton triggering the popup.
* @location: The location the popup-menu should be created for,
* or NULL for the currently displayed location.
*
**/
void
fm_directory_view_pop_up_location_context_menu (FMDirectoryView *view,
GdkEventButton *event)
GdkEventButton *event,
const char *location)
{
g_assert (FM_IS_DIRECTORY_VIEW (view));
NautilusFile *file;
/* always update the menu before showing it. Shouldn't be too expensive. */
real_update_location_menu (view);
g_assert (FM_IS_DIRECTORY_VIEW (view));
update_context_menu_position_from_event (view, event);
if (location != NULL) {
file = nautilus_file_get_by_uri (location);
} else {
file = nautilus_file_ref (view->details->directory_as_file);
}
eel_pop_up_context_menu (create_popup_menu
(view, FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION),
EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
event);
if (file != NULL) {
schedule_pop_up_location_context_menu (view, event, file);
nautilus_file_unref (file);
}
}
static void
......@@ -7629,7 +7884,8 @@ load_directory (FMDirectoryView *view,
* change the directory's file metadata.
*/
attributes =
NAUTILUS_FILE_ATTRIBUTE_METADATA |
NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO;
view->details->metadata_for_directory_as_file_pending = TRUE;
view->details->metadata_for_files_in_directory_pending = TRUE;
......
......@@ -414,7 +414,8 @@ void fm_directory_view_pop_up_background_context_menu (FMDirect
void fm_directory_view_pop_up_selection_context_menu (FMDirectoryView *view,
GdkEventButton *event);
void fm_directory_view_pop_up_location_context_menu (FMDirectoryView *view,
GdkEventButton *event);
GdkEventButton *event,
const char *location);
void fm_directory_view_send_selection_change (FMDirectoryView *view);
gboolean fm_directory_view_should_show_file (FMDirectoryView *view,
NautilusFile *file);
......
......@@ -171,23 +171,22 @@
<menuitem name="LocationOpenAlternate" action="LocationOpenAlternate"/>
<menuitem name="LocationOpenFolderWindow" action="LocationOpenFolderWindow"/>
</placeholder>
<separator/>
<separator name="Location After Open Separator"/>
<placeholder name="Clipboard Actions">
<menuitem name="Cut" action="LocationCut"/>
<menuitem name="Copy" action="LocationCopy"/>
</placeholder>
<separator/>
<separator name="Location After Clipboard Separator"/>
<placeholder name="Dangerous File Actions">
<menuitem name="Trash" action="LocationTrash"/>
<menuitem name="Delete" action="LocationDelete"/>
</placeholder>
<separator/>
<menuitem name="Self Mount Volume" action="Self Mount Volume"/>
<menuitem name="Self Unmount Volume" action="Self Unmount Volume"/>
<menuitem name="Self Eject Volume" action="Self Eject Volume"/>
<menuitem name="Self Format Volume" action="Self Format Volume"/>
<separator name="Location After Dangerous Separator"/>
<menuitem name="Location Mount Volume" action="Location Mount Volume"/>
<menuitem name="Location Unmount Volume" action="Location Unmount Volume"/>
<menuitem name="Location Eject Volume" action="Location Eject Volume"/>
<menuitem name="Location Format Volume" action="Location Format Volume"/>
<separator name="Properties Separator"/>
<menuitem name="Properties" action="SelfProperties"/>
<menuitem name="LocationProperties" action="LocationProperties"/>
</popup>
</ui>
......@@ -276,7 +276,7 @@ label_button_pressed_callback (GtkWidget *widget,
return FALSE;
}
nautilus_view_pop_up_location_context_menu (view, event);
nautilus_view_pop_up_location_context_menu (view, event, NULL);
return FALSE;
}
......
......@@ -116,6 +116,9 @@ static void navigation_bar_cancel_callback (GtkWidget *
static void path_bar_location_changed_callback (GtkWidget *widget,
GFile *path,
NautilusNavigationWindow *window);
static void path_bar_path_set_callback (GtkWidget *widget,
GFile *location,
NautilusNavigationWindow *window);
static void always_use_location_entry_changed (gpointer callback_data);
static void always_use_browser_changed (gpointer callback_data);
......@@ -274,6 +277,8 @@ nautilus_navigation_window_init (NautilusNavigationWindow *window)
g_signal_connect_object (window->path_bar, "path_clicked",
G_CALLBACK (path_bar_location_changed_callback), window, 0);
g_signal_connect_object (window->path_bar, "path_set",
G_CALLBACK (path_bar_path_set_callback), window, 0);
gtk_box_pack_start (GTK_BOX (hbox),
window->path_bar,
......@@ -1027,6 +1032,66 @@ real_set_content_view_widget (NautilusWindow *nautilus_window,
}
}
static gboolean
path_bar_button_pressed_callback (GtkWidget *widget,
GdkEventButton *event,
NautilusNavigationWindow *window)
{
NautilusView *view;
GFile *location;
char *uri;
if (event->button == 3) {
view = NAUTILUS_WINDOW (window)->content_view;
if (view != NULL) {
location = nautilus_path_bar_get_path_for_button (
NAUTILUS_PATH_BAR (window->path_bar), widget);
if (location != NULL) {
uri = g_file_get_uri (location);
nautilus_view_pop_up_location_context_menu (
view, event, uri);
g_object_unref (G_OBJECT (location));
g_free (uri);
return TRUE;
}
}
}
return FALSE;
}
static void
path_bar_path_set_callback (GtkWidget *widget,
GFile *location,
NautilusNavigationWindow *window)
{
GList *children, *l;
GtkWidget *child;
children = gtk_container_get_children (GTK_CONTAINER (widget));
for (l = children; l != NULL; l = l->next) {
child = GTK_WIDGET (l->data);
if (!GTK_IS_TOGGLE_BUTTON (child)) {
continue;
}
if (!g_signal_handler_find (child,
G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
0, 0, NULL,
path_bar_button_pressed_callback,
window)) {
g_signal_connect (child, "button-press-event",
G_CALLBACK (path_bar_button_pressed_callback),
window);
}
}
g_list_free (children);
}
static void
real_set_throbber_active (NautilusWindow *window, gboolean active)
{
......
......@@ -43,6 +43,7 @@
enum {
PATH_CLICKED,
PATH_SET,
LAST_SIGNAL
};
......@@ -299,6 +300,15 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_FILE);