From 55a211972b9b31c23bb58b6b3dedd9315098101d Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Sun, 17 May 2020 02:05:23 +0200 Subject: Use XfceGtkMenuAction for thunar window menu (Bug #16654) --- thunar/thunar-menu.c | 9 +- thunar/thunar-window.c | 1404 +++++++++++++++++++++++++----------------------- thunar/thunar-window.h | 107 +++- 3 files changed, 830 insertions(+), 690 deletions(-) diff --git a/thunar/thunar-menu.c b/thunar/thunar-menu.c index eeffde14..86ba8f2f 100644 --- a/thunar/thunar-menu.c +++ b/thunar/thunar-menu.c @@ -305,7 +305,14 @@ thunar_menu_add_sections (ThunarMenu *menu, if (menu_sections & THUNAR_MENU_SECTION_ZOOM) { - // TODO + window = thunar_launcher_get_widget (menu->launcher); + if (THUNAR_IS_WINDOW (window)) + { + thunar_window_append_menu_item (THUNAR_WINDOW (window), GTK_MENU_SHELL (menu), THUNAR_WINDOW_ACTION_ZOOM_IN); + thunar_window_append_menu_item (THUNAR_WINDOW (window), GTK_MENU_SHELL (menu), THUNAR_WINDOW_ACTION_ZOOM_OUT); + thunar_window_append_menu_item (THUNAR_WINDOW (window), GTK_MENU_SHELL (menu), THUNAR_WINDOW_ACTION_ZOOM_RESET); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (menu)); + } } if (menu_sections & THUNAR_MENU_SECTION_PROPERTIES) diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index dbfcb749..c106b64b 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -71,7 +72,6 @@ enum { PROP_0, PROP_CURRENT_DIRECTORY, - PROP_SHOW_HIDDEN, PROP_UI_MANAGER, PROP_ZOOM_LEVEL, }; @@ -92,139 +92,109 @@ enum -static void thunar_window_dispose (GObject *object); -static void thunar_window_finalize (GObject *object); -static gboolean thunar_window_delete (GtkWidget *widget, - GdkEvent *event, - gpointer data); -static void thunar_window_get_property (GObject *object, +static void thunar_window_dispose (GObject *object); +static void thunar_window_finalize (GObject *object); +static gboolean thunar_window_delete (GtkWidget *widget, + GdkEvent *event, + gpointer data); +static void thunar_window_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void thunar_window_set_property (GObject *object, +static void thunar_window_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static gboolean thunar_window_back (ThunarWindow *window); static gboolean thunar_window_reload (ThunarWindow *window, gboolean reload_info); -static gboolean thunar_window_toggle_sidepane (ThunarWindow *window); -static gboolean thunar_window_toggle_menubar (ThunarWindow *window); -static void thunar_window_toggle_menubar_deactivate (GtkWidget *menubar, - ThunarWindow *window); -static gboolean thunar_window_zoom_in (ThunarWindow *window); -static gboolean thunar_window_zoom_out (ThunarWindow *window); -static gboolean thunar_window_zoom_reset (ThunarWindow *window); -static gboolean thunar_window_tab_change (ThunarWindow *window, +static gboolean thunar_window_toggle_sidepane (ThunarWindow *window); +static gboolean thunar_window_zoom_in (ThunarWindow *window); +static gboolean thunar_window_zoom_out (ThunarWindow *window); +static gboolean thunar_window_zoom_reset (ThunarWindow *window); +static gboolean thunar_window_tab_change (ThunarWindow *window, gint nth); -static void thunar_window_realize (GtkWidget *widget); -static void thunar_window_unrealize (GtkWidget *widget); -static gboolean thunar_window_configure_event (GtkWidget *widget, +static void thunar_window_realize (GtkWidget *widget); +static void thunar_window_unrealize (GtkWidget *widget); +static gboolean thunar_window_configure_event (GtkWidget *widget, GdkEventConfigure *event); -static void thunar_window_notebook_switch_page (GtkWidget *notebook, +static void thunar_window_notebook_switch_page (GtkWidget *notebook, GtkWidget *page, guint page_num, ThunarWindow *window); -static void thunar_window_notebook_page_added (GtkWidget *notebook, +static void thunar_window_notebook_page_added (GtkWidget *notebook, GtkWidget *page, guint page_num, ThunarWindow *window); -static void thunar_window_notebook_page_removed (GtkWidget *notebook, +static void thunar_window_notebook_page_removed (GtkWidget *notebook, GtkWidget *page, guint page_num, ThunarWindow *window); -static gboolean thunar_window_notebook_button_press_event (GtkWidget *notebook, +static gboolean thunar_window_notebook_button_press_event(GtkWidget *notebook, GdkEventButton *event, ThunarWindow *window); -static gboolean thunar_window_notebook_popup_menu (GtkWidget *notebook, +static gboolean thunar_window_notebook_popup_menu (GtkWidget *notebook, ThunarWindow *window); -static gpointer thunar_window_notebook_create_window (GtkWidget *notebook, +static gpointer thunar_window_notebook_create_window (GtkWidget *notebook, GtkWidget *page, gint x, gint y, ThunarWindow *window); static void thunar_window_merge_custom_preferences (ThunarWindow *window); static gboolean thunar_window_bookmark_merge (gpointer user_data); -static void thunar_window_merge_go_actions (ThunarWindow *window); -static void thunar_window_update_location_bar_visible (ThunarWindow *window); -static void thunar_window_handle_reload_request (ThunarWindow *window); -static void thunar_window_install_sidepane (ThunarWindow *window, +static void thunar_window_update_location_bar_visible(ThunarWindow *window); +static void thunar_window_handle_reload_request (ThunarWindow *window); +static void thunar_window_install_sidepane (ThunarWindow *window, GType type); -static void thunar_window_start_open_location (ThunarWindow *window, +static void thunar_window_start_open_location (ThunarWindow *window, const gchar *initial_text); -static void thunar_window_action_open_new_tab (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_new_window (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_empty_trash (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_detach_tab (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_close_all_windows (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_close_tab (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_close_window (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_preferences (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_reload (GtkAction *action, - ThunarWindow *window); -static void switch_next_tab (GtkAction *action, - ThunarWindow *window); -static void switch_previous_tab (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_pathbar_changed (GtkToggleAction *action, - ThunarWindow *window); -static void thunar_window_action_toolbar_changed (GtkToggleAction *action, - ThunarWindow *window); -static void thunar_window_action_shortcuts_changed (GtkToggleAction *action, - ThunarWindow *window); -static void thunar_window_action_tree_changed (GtkToggleAction *action, - ThunarWindow *window); -static void thunar_window_action_statusbar_changed (GtkToggleAction *action, - ThunarWindow *window); -static void thunar_window_action_menubar_changed (GtkToggleAction *action, - ThunarWindow *window); -static void thunar_window_action_zoom_in (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_zoom_out (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_zoom_reset (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_view_changed (GtkRadioAction *action, - GtkRadioAction *current, - ThunarWindow *window); -static void thunar_window_action_go_up (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_home (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_desktop (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_computer (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_templates (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_file_system (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_trash (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_network (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_bookmark (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_open_location (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_contents (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_about (GtkAction *action, - ThunarWindow *window); -static void thunar_window_action_show_hidden (GtkToggleAction *action, - ThunarWindow *window); -static gboolean thunar_window_propagate_key_event (GtkWindow *window, +static void thunar_window_action_open_new_tab (ThunarWindow *window, + GtkWidget *menu_item); +static void thunar_window_action_open_new_window (ThunarWindow *window, + GtkWidget *menu_item); +static void thunar_window_action_detach_tab (ThunarWindow *window, + GtkWidget *menu_item); +static void thunar_window_action_close_all_windows (ThunarWindow *window, + GtkWidget *menu_item); +static void thunar_window_action_close_tab (ThunarWindow *window, + GtkWidget *menu_item); +static void thunar_window_action_close_window (ThunarWindow *window, + GtkWidget *menu_item); +static void thunar_window_action_preferences (ThunarWindow *window, + GtkWidget *menu_item); +static void thunar_window_action_reload (ThunarWindow *window, + GtkWidget *menu_item); +static void thunar_window_action_switch_next_tab (ThunarWindow *window); +static void thunar_window_action_switch_previous_tab (ThunarWindow *window); +static void thunar_window_action_pathbar_changed (ThunarWindow *window); +static void thunar_window_action_toolbar_changed (ThunarWindow *window); +static void thunar_window_action_shortcuts_changed (ThunarWindow *window); +static void thunar_window_action_tree_changed (ThunarWindow *window); +static void thunar_window_action_statusbar_changed (ThunarWindow *window); +static void thunar_window_action_menubar_changed (ThunarWindow *window); +static void thunar_window_action_detailed_view (ThunarWindow *window); +static void thunar_window_action_icon_view (ThunarWindow *window); +static void thunar_window_action_compact_view (ThunarWindow *window); +static void thunar_window_action_view_changed (ThunarWindow *window, + GType view_type); +static void thunar_window_action_go_up (ThunarWindow *window); +static void thunar_window_action_open_home (ThunarWindow *window); +static void thunar_window_action_open_desktop (ThunarWindow *window); +static void thunar_window_action_open_computer (ThunarWindow *window); +static void thunar_window_action_open_templates (ThunarWindow *window); +static void thunar_window_action_open_file_system (ThunarWindow *window); +static void thunar_window_action_open_trash (ThunarWindow *window); +static void thunar_window_action_open_network (ThunarWindow *window); +static void thunar_window_action_open_bookmark (GtkWidget *menu_item); +static void thunar_window_action_open_location (ThunarWindow *window); +static void thunar_window_action_contents (ThunarWindow *window); +static void thunar_window_action_about (ThunarWindow *window); +static void thunar_window_action_show_hidden (ThunarWindow *window); +static gboolean thunar_window_propagate_key_event (GtkWindow *window, GdkEvent *key_event, gpointer user_data); -static void thunar_window_current_directory_changed (ThunarFile *current_directory, +static void thunar_window_action_open_file_menu (ThunarWindow *window); +static void thunar_window_current_directory_changed (ThunarFile *current_directory, ThunarWindow *window); static void thunar_window_connect_proxy (GtkUIManager *manager, GtkAction *action, @@ -241,26 +211,50 @@ static void thunar_window_menu_item_deselected (GtkWidget static void thunar_window_update_custom_actions (ThunarView *view, GParamSpec *pspec, ThunarWindow *window); -static void thunar_window_notify_loading (ThunarView *view, +static void thunar_window_notify_loading (ThunarView *view, GParamSpec *pspec, ThunarWindow *window); -static void thunar_window_device_pre_unmount (ThunarDeviceMonitor *device_monitor, +static void thunar_window_device_pre_unmount (ThunarDeviceMonitor *device_monitor, ThunarDevice *device, GFile *root_file, ThunarWindow *window); -static void thunar_window_device_changed (ThunarDeviceMonitor *device_monitor, +static void thunar_window_device_changed (ThunarDeviceMonitor *device_monitor, ThunarDevice *device, ThunarWindow *window); static gboolean thunar_window_merge_idle (gpointer user_data); static void thunar_window_merge_idle_destroy (gpointer user_data); -static gboolean thunar_window_save_paned (ThunarWindow *window); -static gboolean thunar_window_save_geometry_timer (gpointer user_data); -static void thunar_window_save_geometry_timer_destroy (gpointer user_data); -static void thunar_window_set_zoom_level (ThunarWindow *window, +static gboolean thunar_window_save_paned (ThunarWindow *window); +static gboolean thunar_window_save_geometry_timer (gpointer user_data); +static void thunar_window_save_geometry_timer_destroy(gpointer user_data); +static void thunar_window_set_zoom_level (ThunarWindow *window, ThunarZoomLevel zoom_level); -static void thunar_window_update_window_icon (ThunarWindow *window); -static void thunar_window_select_files (ThunarWindow *window, +static void thunar_window_update_window_icon (ThunarWindow *window); +static gboolean thunar_window_create_file_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu); +static gboolean thunar_window_create_edit_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu); +static gboolean thunar_window_create_view_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu); +static gboolean thunar_window_create_go_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu); +static gboolean thunar_window_create_help_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu); +static void thunar_window_select_files (ThunarWindow *window, GList *path_list); +static void thunar_window_binding_create (ThunarWindow *window, + gpointer src_object, + const gchar *src_prop, + gpointer dst_object, + const gchar *dst_prop, + GBindingFlags flags); +static gboolean thunar_window_menu_item_hovered (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu); @@ -272,8 +266,6 @@ struct _ThunarWindowClass gboolean (*back) (ThunarWindow *window); gboolean (*reload) (ThunarWindow *window, gboolean reload_info); - gboolean (*toggle_sidepane) (ThunarWindow *window); - gboolean (*toggle_menubar) (ThunarWindow *window); gboolean (*zoom_in) (ThunarWindow *window); gboolean (*zoom_out) (ThunarWindow *window); gboolean (*zoom_reset) (ThunarWindow *window); @@ -339,6 +331,7 @@ struct _ThunarWindow ThunarLauncher *launcher; ThunarFile *current_directory; + GtkAccelGroup *accel_group; /* zoom-level support */ ThunarZoomLevel zoom_level; @@ -346,6 +339,8 @@ struct _ThunarWindow /* menu merge idle source */ guint merge_idle_id; + gboolean show_hidden; + /* support to remember window geometry */ guint save_geometry_timer_id; @@ -363,53 +358,110 @@ struct _ThunarWindow static GtkActionEntry action_entries[] = { { "file-menu", NULL, N_ ("_File"), NULL, }, - { "new-tab", "tab-new", N_ ("New _Tab"), "T", N_ ("Open a new tab for the displayed location"), G_CALLBACK (thunar_window_action_open_new_tab), }, - { "new-window", "window-new", N_ ("New _Window"), "N", N_ ("Open a new Thunar window for the displayed location"), G_CALLBACK (thunar_window_action_open_new_window), }, + { "new-tab", "tab-new", N_ ("New _Tab"), "T", N_ ("Open a new tab for the displayed location"), G_CALLBACK (NULL), }, + { "new-window", "window-new", N_ ("New _Window"), "N", N_ ("Open a new Thunar window for the displayed location"), G_CALLBACK (NULL), }, { "sendto-menu", NULL, N_ ("_Send To"), NULL, }, - { "empty-trash", NULL, N_ ("_Empty Trash"), NULL, N_ ("Delete all files and folders in the Trash"), G_CALLBACK (thunar_window_action_empty_trash), }, - { "detach-tab", NULL, N_ ("Detac_h Tab"), NULL, N_ ("Open current folder in a new window"), G_CALLBACK (thunar_window_action_detach_tab), }, - { "switch-previous-tab", "go-previous", N_ ("_Previous Tab"), "Page_Up", N_ ("Switch to Previous Tab"), G_CALLBACK (switch_previous_tab), }, - { "switch-next-tab", "go-next", N_ ("_Next Tab"), "Page_Down", N_ ("Switch to Next Tab"), G_CALLBACK (switch_next_tab), }, - { "close-all-windows", NULL, N_ ("Close _All Windows"), "W", N_ ("Close all Thunar windows"), G_CALLBACK (thunar_window_action_close_all_windows), }, - { "close-tab", "window-close", N_ ("C_lose Tab"), "W", N_ ("Close this folder"), G_CALLBACK (thunar_window_action_close_tab), }, - { "close-window", "application-exit", N_ ("_Close Window"), "Q", N_ ("Close this window"), G_CALLBACK (thunar_window_action_close_window), }, + { "empty-trash", NULL, N_ ("_Empty Trash"), NULL, N_ ("Delete all files and folders in the Trash"), G_CALLBACK (NULL), }, + { "detach-tab", NULL, N_ ("Detac_h Tab"), NULL, N_ ("Open current folder in a new window"), G_CALLBACK (NULL), }, + { "switch-previous-tab", "go-previous", N_ ("_Previous Tab"), "Page_Up", N_ ("Switch to Previous Tab"), G_CALLBACK (NULL), }, + { "switch-next-tab", "go-next", N_ ("_Next Tab"), "Page_Down", N_ ("Switch to Next Tab"), G_CALLBACK (NULL), }, + { "close-all-windows", NULL, N_ ("Close _All Windows"), "W", N_ ("Close all Thunar windows"), G_CALLBACK (NULL), }, + { "close-tab", "window-close", N_ ("C_lose Tab"), "W", N_ ("Close this folder"), G_CALLBACK (NULL), }, + { "close-window", "application-exit", N_ ("_Close Window"), "Q", N_ ("Close this window"), G_CALLBACK (NULL), }, { "edit-menu", NULL, N_ ("_Edit"), NULL, }, - { "preferences", "preferences-system", N_ ("Pr_eferences..."), NULL, N_ ("Edit Thunars Preferences"), G_CALLBACK (thunar_window_action_preferences), }, + { "preferences", "preferences-system", N_ ("Pr_eferences..."), NULL, N_ ("Edit Thunars Preferences"), G_CALLBACK (NULL), }, { "view-menu", NULL, N_ ("_View"), NULL, }, - { "reload", "view-refresh-symbolic", N_ ("_Reload"), "R", N_ ("Reload the current folder"), G_CALLBACK (thunar_window_action_reload), }, + { "reload", "view-refresh-symbolic", N_ ("_Reload"), "R", N_ ("Reload the current folder"), G_CALLBACK (NULL), }, { "view-location-selector-menu", NULL, N_ ("_Location Selector"), NULL, }, { "view-side-pane-menu", NULL, N_ ("_Side Pane"), NULL, }, - { "zoom-in", "zoom-in-symbolic", N_ ("Zoom I_n"), "plus", N_ ("Show the contents in more detail"), G_CALLBACK (thunar_window_action_zoom_in), }, - { "zoom-in-alt", NULL, "zoom-in-alt", "equal", NULL, G_CALLBACK (thunar_window_action_zoom_in), }, - { "zoom-out", "zoom-out-symbolic", N_ ("Zoom _Out"), "minus", N_ ("Show the contents in less detail"), G_CALLBACK (thunar_window_action_zoom_out), }, - { "zoom-reset", "zoom-original-symbolic", N_ ("Normal Si_ze"), "0", N_ ("Show the contents at the normal size"), G_CALLBACK (thunar_window_action_zoom_reset), }, + { "zoom-in", "zoom-in-symbolic", N_ ("Zoom I_n"), "plus", N_ ("Show the contents in more detail"), G_CALLBACK (NULL), }, + { "zoom-in-alt", NULL, "zoom-in-alt", "equal", NULL, G_CALLBACK (NULL), }, + { "zoom-out", "zoom-out-symbolic", N_ ("Zoom _Out"), "minus", N_ ("Show the contents in less detail"), G_CALLBACK (NULL), }, + { "zoom-reset", "zoom-original-symbolic", N_ ("Normal Si_ze"), "0", N_ ("Show the contents at the normal size"), G_CALLBACK (NULL), }, { "go-menu", NULL, N_ ("_Go"), NULL, }, - { "open-parent", "go-up-symbolic", N_ ("Open _Parent"), "Up", N_ ("Open the parent folder"), G_CALLBACK (thunar_window_action_go_up), }, - { "open-home", "go-home-symbolic", N_ ("_Home"), "Home", N_ ("Go to the home folder"), G_CALLBACK (thunar_window_action_open_home), }, - { "open-desktop", "user-desktop", N_ ("Desktop"), NULL, N_ ("Go to the desktop folder"), G_CALLBACK (thunar_window_action_open_desktop), }, - { "open-computer", "computer", N_ ("Computer"), NULL, N_ ("Browse all local and remote disks and folders accessible from this computer"), G_CALLBACK (thunar_window_action_open_computer), }, - { "open-file-system", "drive-harddisk", N_ ("File System"), NULL, N_ ("Browse the file system"), G_CALLBACK (thunar_window_action_open_file_system), }, - { "open-network", "network-workgroup", N_("B_rowse Network"), NULL, N_ ("Browse local network connections"), G_CALLBACK (thunar_window_action_open_network), }, - { "open-templates", "text-x-generic-template", N_("T_emplates"), NULL, N_ ("Go to the templates folder"), G_CALLBACK (thunar_window_action_open_templates), }, - { "open-location", NULL, N_ ("_Open Location..."), "L", N_ ("Specify a location to open"), G_CALLBACK (thunar_window_action_open_location), }, - { "open-location-alt", NULL, "open-location-alt", "D", NULL, G_CALLBACK (thunar_window_action_open_location), }, + { "open-parent", "go-up-symbolic", N_ ("Open _Parent"), "Up", N_ ("Open the parent folder"), G_CALLBACK (NULL), }, + { "open-home", "go-home-symbolic", N_ ("_Home"), "Home", N_ ("Go to the home folder"), G_CALLBACK (NULL), }, + { "open-desktop", "user-desktop", N_ ("Desktop"), NULL, N_ ("Go to the desktop folder"), G_CALLBACK (NULL), }, + { "open-computer", "computer", N_ ("Computer"), NULL, N_ ("Browse all local and remote disks and folders accessible from this computer"), G_CALLBACK (NULL), }, + { "open-file-system", "drive-harddisk", N_ ("File System"), NULL, N_ ("Browse the file system"), G_CALLBACK (NULL), }, + { "open-network", "network-workgroup", N_("B_rowse Network"), NULL, N_ ("Browse local network connections"), G_CALLBACK (NULL), }, + { "open-templates", "text-x-generic-template", N_("T_emplates"), NULL, N_ ("Go to the templates folder"), G_CALLBACK (NULL), }, + { "open-location", NULL, N_ ("_Open Location..."), "L", N_ ("Specify a location to open"), G_CALLBACK (NULL), }, + { "open-location-alt", NULL, "open-location-alt", "D", NULL, G_CALLBACK (NULL), }, { "help-menu", NULL, N_ ("_Help"), NULL, }, - { "contents", "help-browser", N_ ("_Contents"), "F1", N_ ("Display Thunar user manual"), G_CALLBACK (thunar_window_action_contents), }, - { "about", "help-about", N_ ("_About"), NULL, N_ ("Display information about Thunar"), G_CALLBACK (thunar_window_action_about), }, + { "contents", "help-browser", N_ ("_Contents"), "F1", N_ ("Display Thunar user manual"), G_CALLBACK (NULL), }, + { "about", "help-about", N_ ("_About"), NULL, N_ ("Display information about Thunar"), G_CALLBACK (NULL), }, }; static const GtkToggleActionEntry toggle_action_entries[] = { - { "show-hidden", NULL, N_ ("Show _Hidden Files"), "H", N_ ("Toggles the display of hidden files in the current window"), G_CALLBACK (thunar_window_action_show_hidden), FALSE, }, - { "view-location-selector-pathbar", NULL, N_ ("_Pathbar Style"), NULL, N_ ("Modern approach with buttons that correspond to folders"), G_CALLBACK (thunar_window_action_pathbar_changed), FALSE, }, - { "view-location-selector-toolbar", NULL, N_ ("_Toolbar Style"), NULL, N_ ("Traditional approach with location bar and navigation buttons"), G_CALLBACK (thunar_window_action_toolbar_changed), FALSE, }, - { "view-side-pane-shortcuts", NULL, N_ ("_Shortcuts"), "B", N_ ("Toggles the visibility of the shortcuts pane"), G_CALLBACK (thunar_window_action_shortcuts_changed), FALSE, }, - { "view-side-pane-tree", NULL, N_ ("_Tree"), "E", N_ ("Toggles the visibility of the tree pane"), G_CALLBACK (thunar_window_action_tree_changed), FALSE, }, - { "view-statusbar", NULL, N_ ("St_atusbar"), NULL, N_ ("Change the visibility of this window's statusbar"), G_CALLBACK (thunar_window_action_statusbar_changed), FALSE, }, - { "view-menubar", NULL, N_ ("_Menubar"), "M", N_ ("Change the visibility of this window's menubar"), G_CALLBACK (thunar_window_action_menubar_changed), TRUE, }, + { "show-hidden", NULL, N_ ("Show _Hidden Files"), "H", N_ ("Toggles the display of hidden files in the current window"), G_CALLBACK (NULL), FALSE, }, + { "view-location-selector-pathbar", NULL, N_ ("_Pathbar Style"), NULL, N_ ("Modern approach with buttons that correspond to folders"), G_CALLBACK (NULL), FALSE, }, + { "view-location-selector-toolbar", NULL, N_ ("_Toolbar Style"), NULL, N_ ("Traditional approach with location bar and navigation buttons"), G_CALLBACK (NULL), FALSE, }, + { "view-side-pane-shortcuts", NULL, N_ ("_Shortcuts"), "B", N_ ("Toggles the visibility of the shortcuts pane"), G_CALLBACK (NULL), FALSE, }, + { "view-side-pane-tree", NULL, N_ ("_Tree"), "E", N_ ("Toggles the visibility of the tree pane"), G_CALLBACK (NULL), FALSE, }, + { "view-statusbar", NULL, N_ ("St_atusbar"), NULL, N_ ("Change the visibility of this window's statusbar"), G_CALLBACK (NULL), FALSE, }, + { "view-menubar", NULL, N_ ("_Menubar"), "M", N_ ("Change the visibility of this window's menubar"), G_CALLBACK (NULL), TRUE, }, }; +static XfceGtkActionEntry thunar_window_action_entries[] = +{ + { THUNAR_WINDOW_ACTION_FILE_MENU, "/ThunarWindow/file-menu", "", XFCE_GTK_MENU_ITEM, N_ ("_File"), NULL, NULL, NULL,}, + { THUNAR_WINDOW_ACTION_NEW_TAB, "/ThunarWindow/new-tab", "t", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("New _Tab"), N_ ("Open a new tab for the displayed location"), "tab-new", G_CALLBACK (thunar_window_action_open_new_tab), }, + { THUNAR_WINDOW_ACTION_NEW_WINDOW, "/ThunarWindow/new-window", "n", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("New _Window"), N_ ("Open a new Thunar window for the displayed location"), "window-new", G_CALLBACK (thunar_window_action_open_new_window), }, + { THUNAR_WINDOW_ACTION_DETACH_TAB, "/ThunarWindow/detach-tab", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Detac_h Tab"), N_ ("Open current folder in a new window"), NULL, G_CALLBACK (thunar_window_action_detach_tab), }, + { THUNAR_WINDOW_ACTION_CLOSE_TAB, "/ThunarWindow/close-tab", "w", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("C_lose Tab"), N_ ("Close this folder"), "window-close", G_CALLBACK (thunar_window_action_close_tab), }, + { THUNAR_WINDOW_ACTION_CLOSE_WINDOW, "/ThunarWindow/close-window", "q", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Close Window"), N_ ("Close this window"), "application-exit", G_CALLBACK (thunar_window_action_close_window), }, + { THUNAR_WINDOW_ACTION_CLOSE_ALL_WINDOWS, "/ThunarWindow/close-all-windows", "w", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Close _All Windows"), N_ ("Close all Thunar windows"), NULL, G_CALLBACK (thunar_window_action_close_all_windows), }, + + { THUNAR_WINDOW_ACTION_EDIT_MENU, "/ThunarWindow/edit-menu", "", XFCE_GTK_MENU_ITEM, N_ ("_Edit"), NULL, NULL, NULL, }, + { THUNAR_WINDOW_ACTION_PREFERENCES, "/ThunarWindow/preferences", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Pr_eferences..."), N_ ("Edit Thunars Preferences"), "preferences-system", G_CALLBACK (thunar_window_action_preferences), }, + + { THUNAR_WINDOW_ACTION_VIEW_MENU, "/ThunarWindow/view-menu", "", XFCE_GTK_MENU_ITEM, N_ ("_View"), NULL, NULL, NULL, }, + { THUNAR_WINDOW_ACTION_RELOAD, "/ThunarWindow/reload", "r", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Reload"), N_ ("Reload the current folder"), "view-refresh-symbolic", G_CALLBACK (thunar_window_action_reload), }, + { THUNAR_WINDOW_ACTION_RELOAD_ALT, "/ThunarWindow/reload-alt", "F5", XFCE_GTK_IMAGE_MENU_ITEM, NULL, NULL, NULL, G_CALLBACK (thunar_window_action_reload), }, + { THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_MENU, "/ThunarWindow/view-location-selector-menu", "", XFCE_GTK_MENU_ITEM, N_ ("_Location Selector"), NULL, NULL, NULL, }, + { THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_PATHBAR, "/ThunarWindow/view-location-selector-pathbar", "", XFCE_GTK_CHECK_MENU_ITEM, N_ ("_Pathbar Style"), N_ ("Modern approach with buttons that correspond to folders"), NULL, G_CALLBACK (thunar_window_action_pathbar_changed), }, + { THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_TOOLBAR, "/ThunarWindow/view-location-selector-toolbar", "", XFCE_GTK_CHECK_MENU_ITEM, N_ ("_Toolbar Style"), N_ ("Traditional approach with location bar and navigation buttons"), NULL, G_CALLBACK (thunar_window_action_toolbar_changed), }, + { THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_MENU, "/ThunarWindow/view-side-pane-menu", "", XFCE_GTK_MENU_ITEM, N_ ("_Side Pane"), NULL, NULL, NULL, }, + { THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_SHORTCUTS, "/ThunarWindow/view-side-pane-shortcuts", "b", XFCE_GTK_CHECK_MENU_ITEM, N_ ("_Shortcuts"), N_ ("Toggles the visibility of the shortcuts pane"), NULL, G_CALLBACK (thunar_window_action_shortcuts_changed), }, + { THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_TREE, "/ThunarWindow/view-side-pane-tree", "e", XFCE_GTK_CHECK_MENU_ITEM, N_ ("_Tree"), N_ ("Toggles the visibility of the tree pane"), NULL, G_CALLBACK (thunar_window_action_tree_changed), }, + { THUNAR_WINDOW_ACTION_TOGGLE_SIDE_PANE, "/ThunarWindow/toggle-side-pane", "F9", XFCE_GTK_MENU_ITEM, NULL, NULL, NULL, G_CALLBACK (thunar_window_toggle_sidepane), }, + { THUNAR_WINDOW_ACTION_VIEW_STATUSBAR, "/ThunarWindow/view-statusbar", "", XFCE_GTK_CHECK_MENU_ITEM, N_ ("St_atusbar"), N_ ("Change the visibility of this window's statusbar"), NULL, G_CALLBACK (thunar_window_action_statusbar_changed), }, + { THUNAR_WINDOW_ACTION_VIEW_MENUBAR, "/ThunarWindow/view-menubar", "m", XFCE_GTK_CHECK_MENU_ITEM, N_ ("_Menubar"), N_ ("Change the visibility of this window's menubar"), NULL, G_CALLBACK (thunar_window_action_menubar_changed), }, + { THUNAR_WINDOW_ACTION_SHOW_HIDDEN, "/ThunarWindow/show-hidden", "h", XFCE_GTK_CHECK_MENU_ITEM, N_ ("Show _Hidden Files"), N_ ("Toggles the display of hidden files in the current window"), NULL, G_CALLBACK (thunar_window_action_show_hidden), }, + { THUNAR_WINDOW_ACTION_ZOOM_IN, "/ThunarWindow/zoom-in", "KP_Add", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Zoom I_n"), N_ ("Show the contents in more detail"), "zoom-in-symbolic", G_CALLBACK (thunar_window_zoom_in), }, + { THUNAR_WINDOW_ACTION_ZOOM_OUT, "/ThunarWindow/zoom-out", "KP_Subtract", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Zoom _Out"), N_ ("Show the contents in less detail"), "zoom-out-symbolic", G_CALLBACK (thunar_window_zoom_out), }, + { THUNAR_WINDOW_ACTION_ZOOM_RESET, "/ThunarWindow/zoom-reset", "KP_0", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Normal Si_ze"), N_ ("Show the contents at the normal size"), "zoom-original-symbolic", G_CALLBACK (thunar_window_zoom_reset), }, + { THUNAR_WINDOW_ACTION_VIEW_AS_ICONS, "/ThunarWindow/view-as-icons", "1", XFCE_GTK_RADIO_MENU_ITEM, N_ ("View as _Icons"), N_("Display folder content in an icon view"), NULL, G_CALLBACK (thunar_window_action_icon_view), }, + { THUNAR_WINDOW_ACTION_VIEW_AS_DETAILED_LIST, "/ThunarWindow/view-as-detailed-list", "2", XFCE_GTK_RADIO_MENU_ITEM, N_ ("View as _Detailed List"), N_("Display folder content in a detailed list view"), NULL, G_CALLBACK (thunar_window_action_detailed_view), }, + { THUNAR_WINDOW_ACTION_VIEW_AS_COMPACT_LIST, "/ThunarWindow/view-as-compact-list", "3", XFCE_GTK_RADIO_MENU_ITEM, N_ ("View as _Compact List"), N_("Display folder content in a compact list view"), NULL, G_CALLBACK (thunar_window_action_compact_view), }, + + { THUNAR_WINDOW_ACTION_GO_MENU, "/ThunarWindow/go-menu", "", XFCE_GTK_MENU_ITEM, N_ ("_Go"), NULL, NULL, NULL }, + { THUNAR_WINDOW_ACTION_OPEN_FILE_SYSTEM, "/ThunarWindow/open-file-system", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("File System"), N_ ("Browse the file system"), "drive-harddisk", G_CALLBACK (thunar_window_action_open_file_system), }, + { THUNAR_WINDOW_ACTION_OPEN_COMPUTER, "/ThunarWindow/open-computer", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Computer"), N_ ("Go to the computer folder"), "computer", G_CALLBACK (thunar_window_action_open_computer), }, + { THUNAR_WINDOW_ACTION_OPEN_HOME, "/ThunarWindow/open-home", "Home", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Home"), N_ ("Go to the home folder"), "go-home-symbolic", G_CALLBACK (thunar_window_action_open_home), }, + { THUNAR_WINDOW_ACTION_OPEN_DESKTOP, "/ThunarWindow/open-desktop", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Desktop"), N_ ("Go to the desktop folder"), "user-desktop", G_CALLBACK (thunar_window_action_open_desktop), }, + { THUNAR_WINDOW_ACTION_OPEN_COMPUTER, "/ThunarWindow/open-computer", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Computer"), N_ ("Browse all local and remote disks and folders accessible from this computer"), "computer", G_CALLBACK (thunar_window_action_open_computer), }, + { THUNAR_WINDOW_ACTION_OPEN_TRASH, "/ThunarWindow/open-trash", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("T_rash"), N_ ("Display the contents of the trash can"), NULL, G_CALLBACK (thunar_window_action_open_trash), }, + { THUNAR_WINDOW_ACTION_OPEN_PARENT, "/ThunarWindow/open-parent", "Up", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Open _Parent"), N_ ("Open the parent folder"), "go-up-symbolic", G_CALLBACK (thunar_window_action_go_up), }, + { THUNAR_WINDOW_ACTION_OPEN_LOCATION, "/ThunarWindow/open-location", "l", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Open Location..."), N_ ("Specify a location to open"), NULL, G_CALLBACK (thunar_window_action_open_location), }, + { THUNAR_WINDOW_ACTION_OPEN_LOCATION_ALT, "/ThunarWindow/open-location-alt", "d", XFCE_GTK_MENU_ITEM, "open-location-alt", NULL, NULL, G_CALLBACK (thunar_window_action_open_location), }, + { THUNAR_WINDOW_ACTION_OPEN_TEMPLATES, "/ThunarWindow/open-templates", "", XFCE_GTK_IMAGE_MENU_ITEM, N_("T_emplates"), N_ ("Go to the templates folder"), "text-x-generic-template", G_CALLBACK (thunar_window_action_open_templates), }, + { THUNAR_WINDOW_ACTION_OPEN_NETWORK, "/ThunarWindow/open-network", "", XFCE_GTK_IMAGE_MENU_ITEM, N_("B_rowse Network"), N_ ("Browse local network connections"), "network-workgroup", G_CALLBACK (thunar_window_action_open_network), }, + + { THUNAR_WINDOW_ACTION_HELP_MENU, "/ThunarWindow/contents/help-menu", "", XFCE_GTK_MENU_ITEM , N_ ("_Help"), NULL, NULL, NULL}, + { THUNAR_WINDOW_ACTION_CONTENTS, "/ThunarWindow/contents", "F1", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Contents"), N_ ("Display Thunar user manual"), "help-browser", G_CALLBACK (thunar_window_action_contents), }, + { THUNAR_WINDOW_ACTION_ABOUT, "/ThunarWindow/about", "", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_About"), N_ ("Display information about Thunar"), "help-about", G_CALLBACK (thunar_window_action_about), }, + { THUNAR_WINDOW_ACTION_SWITCH_PREV_TAB, "/ThunarWindow/switch-previous-tab", "Page_Up", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Previous Tab"), N_ ("Switch to Previous Tab"), "go-previous", G_CALLBACK (thunar_window_action_switch_previous_tab), }, + { THUNAR_WINDOW_ACTION_SWITCH_NEXT_TAB, "/ThunarWindow/switch-next-tab", "Page_Down", XFCE_GTK_IMAGE_MENU_ITEM, N_ ("_Next Tab"), N_ ("Switch to Next Tab"), "go-next", G_CALLBACK (thunar_window_action_switch_next_tab), }, + { 0, "/ThunarWindow/open-file-menu", "F10", 0, NULL, NULL, NULL, G_CALLBACK (thunar_window_action_open_file_menu), }, +}; + +#define get_action_entry(id) xfce_gtk_get_action_entry_by_id(thunar_window_action_entries,G_N_ELEMENTS(thunar_window_action_entries),id) + + static guint window_signals[LAST_SIGNAL]; @@ -441,13 +493,13 @@ thunar_window_class_init (ThunarWindowClass *klass) klass->back = thunar_window_back; klass->reload = thunar_window_reload; - klass->toggle_sidepane = thunar_window_toggle_sidepane; - klass->toggle_menubar = thunar_window_toggle_menubar; klass->zoom_in = thunar_window_zoom_in; klass->zoom_out = thunar_window_zoom_out; klass->zoom_reset = thunar_window_zoom_reset; klass->tab_change = thunar_window_tab_change; + xfce_gtk_translate_action_entries (thunar_window_action_entries, G_N_ELEMENTS (thunar_window_action_entries)); + /** * ThunarWindow:current-directory: * @@ -462,19 +514,6 @@ thunar_window_class_init (ThunarWindowClass *klass) THUNAR_TYPE_FILE, EXO_PARAM_READWRITE)); - /** - * ThunarWindow:show-hidden: - * - * Whether to show hidden files in the current window. - **/ - g_object_class_install_property (gobject_class, - PROP_SHOW_HIDDEN, - g_param_spec_boolean ("show-hidden", - "show-hidden", - "show-hidden", - FALSE, - EXO_PARAM_READABLE)); - G_GNUC_BEGIN_IGNORE_DEPRECATIONS /** * ThunarWindow:ui-manager: @@ -529,8 +568,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS * @window : a #ThunarWindow instance. * * Emitted whenever the user requests to reload the contents - * of the currently displayed folder. This is an internal - * signal used to bind the action to keys. + * of the currently displayed folder. **/ window_signals[RELOAD] = g_signal_new (I_("reload"), @@ -542,40 +580,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN); - /** - * ThunarWindow::toggle-sidepane: - * @window : a #ThunarWindow instance. - * - * Emitted whenever the user toggles the visibility of the - * sidepane. This is an internal signal used to bind the - * action to keys. - **/ - window_signals[TOGGLE_SIDEPANE] = - g_signal_new (I_("toggle-sidepane"), - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ThunarWindowClass, toggle_sidepane), - g_signal_accumulator_true_handled, NULL, - _thunar_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - - /** - * ThunarWindow::toggle-menubar: - * @window : a #ThunarWindow instance. - * - * Emitted whenever the user toggles the visibility of the - * menubar. This is an internal signal used to bind the - * action to keys. - **/ - window_signals[TOGGLE_MENUBAR] = - g_signal_new (I_("toggle-menubar"), - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ThunarWindowClass, toggle_menubar), - g_signal_accumulator_true_handled, NULL, - _thunar_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - /** * ThunarWindow::zoom-in: * @window : a #ThunarWindow instance. @@ -644,14 +648,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS /* setup the key bindings for the windows */ binding_set = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0, "back", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_F5, 0, "reload", 1, G_TYPE_BOOLEAN, TRUE); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_F9, 0, "toggle-sidepane", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_F10, 0, "toggle-menubar", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Add, GDK_CONTROL_MASK, "zoom-in", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Subtract, GDK_CONTROL_MASK, "zoom-out", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_0, GDK_CONTROL_MASK, "zoom-reset", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, GDK_CONTROL_MASK, "zoom-reset", 0); /* setup the key bindings for Alt+N */ for (i = 0; i < 10; i++) @@ -722,11 +718,11 @@ thunar_window_init (ThunarWindow *window) GtkWidget *infobar; GtkWidget *item; GtkAction *action; - gboolean last_show_hidden; gboolean last_menubar_visible; GSList *group; gchar *last_location_bar; gchar *last_side_pane; + gchar *last_view; GType type; gint last_separator_position; gint last_window_width; @@ -746,9 +742,18 @@ thunar_window_init (ThunarWindow *window) /* grab a reference on the preferences */ window->preferences = thunar_preferences_get (); + window->accel_group = gtk_accel_group_new (); + xfce_gtk_accel_map_add_entries (thunar_window_action_entries, G_N_ELEMENTS (thunar_window_action_entries)); + xfce_gtk_accel_group_connect_action_entries (window->accel_group, + thunar_window_action_entries, + G_N_ELEMENTS (thunar_window_action_entries), + window); + + gtk_window_add_accel_group (GTK_WINDOW (window), window->accel_group); + /* get all properties for init */ g_object_get (G_OBJECT (window->preferences), - "last-show-hidden", &last_show_hidden, + "last-show-hidden", &window->show_hidden, "last-window-width", &last_window_width, "last-window-height", &last_window_height, "last-window-maximized", &last_window_maximized, @@ -792,8 +797,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_action_group_add_toggle_actions (window->action_group, toggle_action_entries, G_N_ELEMENTS (toggle_action_entries), GTK_WIDGET (window)); /* initialize the "show-hidden" action using the last value from the preferences */ - action = gtk_action_group_get_action (window->action_group, "show-hidden"); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), last_show_hidden); + //action = gtk_action_group_get_action (window->action_group, "show-hidden"); + //gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), last_show_hidden); /* * add view options @@ -838,6 +843,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS exo_binding_new (G_OBJECT (window), "current-directory", G_OBJECT (window->launcher), "current-directory"); g_signal_connect_swapped (G_OBJECT (window->launcher), "change-directory", G_CALLBACK (thunar_window_set_current_directory), window); g_signal_connect_swapped (G_OBJECT (window->launcher), "open-new-tab", G_CALLBACK (thunar_window_notebook_insert), window); + thunar_launcher_append_accelerators (window->launcher, window->accel_group); /* determine the default window size from the preferences */ gtk_window_set_default_size (GTK_WINDOW (window), last_window_width, last_window_height); @@ -857,13 +863,35 @@ G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_BEGIN_IGNORE_DEPRECATIONS window->menubar = gtk_ui_manager_get_widget (window->ui_manager, "/main-menu"); G_GNUC_END_IGNORE_DEPRECATIONS + + /* build the menubar */ + window->menubar = gtk_menu_bar_new (); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_FILE_MENU), G_OBJECT (window), GTK_MENU_SHELL (window->menubar)); + g_signal_connect_swapped (G_OBJECT (item), "button-press-event", G_CALLBACK (thunar_window_create_file_menu), window); + g_signal_connect_swapped (G_OBJECT (item), "enter-notify-event", G_CALLBACK (thunar_window_menu_item_hovered), window); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_EDIT_MENU), G_OBJECT (window), GTK_MENU_SHELL (window->menubar)); + g_signal_connect_swapped (G_OBJECT (item), "button-press-event", G_CALLBACK (thunar_window_create_edit_menu), window); + g_signal_connect_swapped (G_OBJECT (item), "enter-notify-event", G_CALLBACK (thunar_window_menu_item_hovered), window); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_MENU), G_OBJECT (window), GTK_MENU_SHELL (window->menubar)); + g_signal_connect_swapped (G_OBJECT (item), "button-press-event", G_CALLBACK (thunar_window_create_view_menu), window); + g_signal_connect_swapped (G_OBJECT (item), "enter-notify-event", G_CALLBACK (thunar_window_menu_item_hovered), window); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_GO_MENU), G_OBJECT (window), GTK_MENU_SHELL (window->menubar)); + g_signal_connect_swapped (G_OBJECT (item), "button-press-event", G_CALLBACK (thunar_window_create_go_menu), window); + g_signal_connect_swapped (G_OBJECT (item), "enter-notify-event", G_CALLBACK (thunar_window_menu_item_hovered), window); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_HELP_MENU), G_OBJECT (window), GTK_MENU_SHELL (window->menubar)); + g_signal_connect_swapped (G_OBJECT (item), "button-press-event", G_CALLBACK (thunar_window_create_help_menu), window); + g_signal_connect_swapped (G_OBJECT (item), "enter-notify-event", G_CALLBACK (thunar_window_menu_item_hovered), window); + gtk_widget_show_all (window->menubar); + + if (last_menubar_visible == FALSE) + gtk_widget_hide (window->menubar); gtk_widget_set_hexpand (window->menubar, TRUE); gtk_grid_attach (GTK_GRID (window->grid), window->menubar, 0, 0, 1, 1); G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* update menubar visibiliy */ action = gtk_action_group_get_action (window->action_group, "view-menubar"); - g_signal_connect (G_OBJECT (window->menubar), "deactivate", G_CALLBACK (thunar_window_toggle_menubar_deactivate), window); + g_signal_connect (G_OBJECT (window->menubar), "deactivate", G_CALLBACK (NULL), window); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), last_menubar_visible); G_GNUC_END_IGNORE_DEPRECATIONS @@ -980,13 +1008,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS /* update window icon whenever preferences change */ g_signal_connect_object (G_OBJECT (window->preferences), "notify::misc-change-window-icon", G_CALLBACK (thunar_window_update_window_icon), window, G_CONNECT_SWAPPED); - /* determine the selected side pane (FIXME: Should probably be last-shortcuts-visible and last-tree-visible preferences) */ + /* determine the selected side pane */ if (exo_str_is_equal (last_side_pane, g_type_name (THUNAR_TYPE_SHORTCUTS_PANE))) type = THUNAR_TYPE_SHORTCUTS_PANE; else if (exo_str_is_equal (last_side_pane, g_type_name (THUNAR_TYPE_TREE_PANE))) type = THUNAR_TYPE_TREE_PANE; else type = G_TYPE_NONE; + thunar_window_install_sidepane (window, type); g_free (last_side_pane); G_GNUC_BEGIN_IGNORE_DEPRECATIONS @@ -1005,8 +1034,16 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS g_signal_connect (G_OBJECT (action), "changed", G_CALLBACK (thunar_window_action_view_changed), window); + /* ensure that all the view types are registered */ + g_type_ensure (THUNAR_TYPE_ICON_VIEW); + g_type_ensure (THUNAR_TYPE_DETAILS_VIEW); + g_type_ensure (THUNAR_TYPE_COMPACT_VIEW); + /* schedule asynchronous menu action merging */ window->merge_idle_id = g_idle_add_full (G_PRIORITY_LOW + 20, thunar_window_merge_idle, window, thunar_window_merge_idle_destroy); + + /* same is done for view in thunar_window_action_view_changed */ + thunar_side_pane_set_show_hidden (THUNAR_SIDE_PANE (window->sidepane), window->show_hidden); } @@ -1034,6 +1071,261 @@ thunar_window_select_files (ThunarWindow *window, +static gboolean +thunar_window_menu_is_open (ThunarWindow *window) +{ + GList *lp; + GtkWidget *submenu; + + g_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); + + for(lp = gtk_container_get_children (GTK_CONTAINER (window->menubar)); lp != NULL; lp = lp->next) + { + submenu = gtk_menu_item_get_submenu(lp->data); + if (submenu != NULL && gtk_widget_get_visible (submenu)) + return TRUE; + } + return FALSE; +} + + + +static gboolean +thunar_window_menu_item_hovered (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu) +{ + gboolean ret; + + g_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); + + if (thunar_window_menu_is_open(window)) + g_signal_emit_by_name (menu, "button-press-event", NULL, &ret); + return FALSE; +} + + + +static gboolean +thunar_window_create_file_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu) +{ + ThunarMenu *submenu; + GtkWidget *item; + + _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); + _thunar_return_val_if_fail (GTK_IS_MENU_ITEM (menu), FALSE); + + submenu = g_object_new (THUNAR_TYPE_MENU, "menu-type", THUNAR_MENU_TYPE_WINDOW, + "launcher", window->launcher, NULL); + gtk_menu_set_accel_group (GTK_MENU (submenu), window->accel_group); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_NEW_TAB), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_NEW_WINDOW), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + thunar_menu_add_sections (submenu, THUNAR_MENU_SECTION_OPEN + | THUNAR_MENU_SECTION_SENDTO + | THUNAR_MENU_SECTION_CREATE_NEW_FILES + | THUNAR_MENU_SECTION_EMPTY_TRASH + | THUNAR_MENU_SECTION_CUSTOM_ACTIONS + | THUNAR_MENU_SECTION_PROPERTIES); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_DETACH_TAB), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + gtk_widget_set_sensitive (item, gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)) > 1); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_CLOSE_ALL_WINDOWS), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_CLOSE_TAB), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_CLOSE_WINDOW), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), GTK_WIDGET (submenu)); + gtk_widget_show_all (GTK_WIDGET (submenu)); + + return FALSE; +} + + + +static gboolean +thunar_window_create_edit_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu) +{ + ThunarMenu *submenu; + + _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); + _thunar_return_val_if_fail (GTK_IS_MENU_ITEM (menu), FALSE); + + submenu = g_object_new (THUNAR_TYPE_MENU, "launcher", window->launcher, NULL); + gtk_menu_set_accel_group (GTK_MENU (submenu), window->accel_group); + thunar_menu_add_sections (submenu, THUNAR_MENU_SECTION_CUT + | THUNAR_MENU_SECTION_COPY_PASTE + | THUNAR_MENU_SECTION_TRASH_DELETE); + thunar_menu_add_sections (submenu, THUNAR_MENU_SECTION_DUPLICATE + | THUNAR_MENU_SECTION_MAKELINK + | THUNAR_MENU_SECTION_RENAME + | THUNAR_MENU_SECTION_RESTORE); + + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_PREFERENCES), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), GTK_WIDGET (submenu)); + gtk_widget_show_all (GTK_WIDGET (submenu)); + + return FALSE; +} + + + +static gboolean +thunar_window_create_view_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu) +{ + ThunarMenu *submenu; + GtkWidget *item; + GtkWidget *sub_items; + gchar *last_location_bar; + gchar *last_side_pane; + + _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); + _thunar_return_val_if_fail (GTK_IS_MENU_ITEM (menu), FALSE); + + submenu = g_object_new (THUNAR_TYPE_MENU, "launcher", window->launcher, NULL); + gtk_menu_set_accel_group (GTK_MENU (submenu), window->accel_group); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_RELOAD), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_MENU), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + sub_items = gtk_menu_new(); + gtk_menu_set_accel_group (GTK_MENU (sub_items), window->accel_group); + g_object_get (window->preferences, "last-location-bar", &last_location_bar, NULL); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_PATHBAR), G_OBJECT (window), + exo_str_is_equal (last_location_bar, g_type_name (THUNAR_TYPE_LOCATION_ENTRY)), GTK_MENU_SHELL (sub_items)); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_TOOLBAR), G_OBJECT (window), + exo_str_is_equal (last_location_bar, g_type_name (THUNAR_TYPE_LOCATION_BUTTONS)), GTK_MENU_SHELL (sub_items)); + g_free (last_location_bar); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (sub_items)); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_MENU), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + sub_items = gtk_menu_new(); + gtk_menu_set_accel_group (GTK_MENU (sub_items), window->accel_group); + g_object_get (window->preferences, "last-side-pane", &last_side_pane, NULL); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_SHORTCUTS), G_OBJECT (window), + exo_str_is_equal (last_side_pane, g_type_name (THUNAR_TYPE_SHORTCUTS_PANE)), GTK_MENU_SHELL (sub_items)); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_TREE), G_OBJECT (window), + exo_str_is_equal (last_side_pane, g_type_name (THUNAR_TYPE_TREE_PANE)), GTK_MENU_SHELL (sub_items)); + g_free (last_side_pane); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (sub_items)); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_STATUSBAR), G_OBJECT (window), + gtk_widget_get_visible (window->statusbar), GTK_MENU_SHELL (submenu)); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_MENUBAR), G_OBJECT (window), + gtk_widget_get_visible (window->menubar), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_SHOW_HIDDEN), G_OBJECT (window), + window->show_hidden, GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + thunar_window_append_menu_item (window, GTK_MENU_SHELL (submenu), THUNAR_WINDOW_ACTION_ZOOM_IN); + thunar_window_append_menu_item (window, GTK_MENU_SHELL (submenu), THUNAR_WINDOW_ACTION_ZOOM_OUT); + thunar_window_append_menu_item (window, GTK_MENU_SHELL (submenu), THUNAR_WINDOW_ACTION_ZOOM_RESET); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_AS_ICONS), + G_OBJECT (window), window->view_type == THUNAR_TYPE_ICON_VIEW, GTK_MENU_SHELL (submenu)); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_AS_DETAILED_LIST), + G_OBJECT (window), window->view_type == THUNAR_TYPE_DETAILS_VIEW, GTK_MENU_SHELL (submenu)); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_AS_COMPACT_LIST), + G_OBJECT (window), window->view_type == THUNAR_TYPE_COMPACT_VIEW, GTK_MENU_SHELL (submenu)); + + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), GTK_WIDGET (submenu)); + gtk_widget_show_all (GTK_WIDGET (submenu)); + + return FALSE; +} + + + +static gboolean +thunar_window_create_go_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu) +{ + ThunarMenu *submenu; + gchar *icon_name; + const XfceGtkActionEntry *action_entry; + GtkWidget *item; + + _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); + _thunar_return_val_if_fail (GTK_IS_MENU_ITEM (menu), FALSE); + + submenu = g_object_new (THUNAR_TYPE_MENU, "launcher", window->launcher, NULL); + gtk_menu_set_accel_group (GTK_MENU (submenu), window->accel_group); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), GTK_WIDGET (submenu)); + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_OPEN_PARENT), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + gtk_widget_set_sensitive (item, !thunar_g_file_is_root (thunar_file_get_file (window->current_directory))); + + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_OPEN_COMPUTER), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_OPEN_HOME), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_OPEN_DESKTOP), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + if (thunar_g_vfs_is_uri_scheme_supported ("trash")) + { + GFile *gfile; + ThunarFile *trash_folder; + + /* try to connect to the trash bin */ + gfile = thunar_g_file_new_for_trash (); + if (gfile != NULL) + { + trash_folder = thunar_file_get (gfile, NULL); + if (trash_folder != NULL) + { + action_entry = get_action_entry (THUNAR_WINDOW_ACTION_OPEN_TRASH); + if (action_entry != NULL) + { + if (thunar_file_get_item_count (trash_folder) > 0) + icon_name = "user-trash-full"; + else + icon_name = "user-trash"; + xfce_gtk_image_menu_item_new_from_icon_name (action_entry->menu_item_label_text, action_entry->menu_item_tooltip_text, + action_entry->accel_path, action_entry->callback, G_OBJECT (window), icon_name, GTK_MENU_SHELL (submenu)); + g_object_unref (trash_folder); + } + } + g_object_unref (gfile); + } + } + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_OPEN_TEMPLATES), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_OPEN_FILE_SYSTEM), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_OPEN_NETWORK), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_OPEN_LOCATION), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + gtk_widget_show_all (GTK_WIDGET (submenu)); + + return FALSE; +} + + + +static gboolean +thunar_window_create_help_menu (ThunarWindow *window, + GdkEventCrossing *event, + GtkWidget *menu) +{ + ThunarMenu *submenu; + + _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); + _thunar_return_val_if_fail (GTK_IS_MENU_ITEM (menu), FALSE); + + submenu = g_object_new (THUNAR_TYPE_MENU, "launcher", window->launcher, NULL); + gtk_menu_set_accel_group (GTK_MENU (submenu), window->accel_group); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_CONTENTS), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_ABOUT), G_OBJECT (window), GTK_MENU_SHELL (submenu)); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), GTK_WIDGET (submenu)); + gtk_widget_show_all (GTK_WIDGET (submenu)); + + return FALSE; +} + + + static void thunar_window_dispose (GObject *object) { @@ -1080,6 +1372,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS window->bookmark_reload_idle_id = 0; } + /* destroy the save geometry timer source */ + if (G_UNLIKELY (window->save_geometry_timer_id != 0)) + g_source_remove (window->save_geometry_timer_id); + /* disconnect from the current-directory */ thunar_window_set_current_directory (window, NULL); @@ -1131,6 +1427,9 @@ thunar_window_finalize (GObject *object) /* release the preferences reference */ g_object_unref (window->preferences); + g_closure_invalidate (window->select_files_closure); + g_closure_unref (window->select_files_closure); + (*G_OBJECT_CLASS (thunar_window_parent_class)->finalize) (object); } @@ -1184,7 +1483,6 @@ thunar_window_get_property (GObject *object, GParamSpec *pspec) { ThunarWindow *window = THUNAR_WINDOW (object); - GtkAction *action; switch (prop_id) { @@ -1192,13 +1490,6 @@ thunar_window_get_property (GObject *object, g_value_set_object (value, thunar_window_get_current_directory (window)); break; - case PROP_SHOW_HIDDEN: -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - action = gtk_action_group_get_action (window->action_group, "show-hidden"); - g_value_set_boolean (value, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))); -G_GNUC_END_IGNORE_DEPRECATIONS - break; - case PROP_UI_MANAGER: g_value_set_object (value, window->ui_manager); break; @@ -1343,9 +1634,6 @@ GtkWidget* thunar_window_get_sidepane (ThunarWindow *window) static gboolean thunar_window_toggle_sidepane (ThunarWindow *window) { - GtkAction *action; - gchar *type_name; - _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); /* check if a side pane is currently active */ @@ -1353,36 +1641,13 @@ thunar_window_toggle_sidepane (ThunarWindow *window) { /* determine the currently active side pane type */ window->toggle_sidepane_type = G_OBJECT_TYPE (window->sidepane); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* just reset both side pane actions */ - action = gtk_action_group_get_action (window->action_group, "view-side-pane-shortcuts"); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE); - action = gtk_action_group_get_action (window->action_group, "view-side-pane-tree"); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE); -G_GNUC_END_IGNORE_DEPRECATIONS + thunar_window_install_sidepane (window, G_TYPE_NONE); } else { /* check if we have a previously remembered toggle type */ - if (G_UNLIKELY (window->toggle_sidepane_type == G_TYPE_INVALID)) - { - /* guess type based on the last-side-pane preference, default to shortcuts */ - g_object_get (G_OBJECT (window->preferences), "last-side-pane", &type_name, NULL); - if (exo_str_is_equal (type_name, g_type_name (THUNAR_TYPE_TREE_PANE))) - window->toggle_sidepane_type = THUNAR_TYPE_TREE_PANE; - else - window->toggle_sidepane_type = THUNAR_TYPE_SHORTCUTS_PANE; - g_free (type_name); - } - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* activate the given side pane */ - action = gtk_action_group_get_action (window->action_group, "view-side-pane-shortcuts"); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), (window->toggle_sidepane_type == THUNAR_TYPE_SHORTCUTS_PANE)); - action = gtk_action_group_get_action (window->action_group, "view-side-pane-tree"); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), (window->toggle_sidepane_type == THUNAR_TYPE_TREE_PANE)); -G_GNUC_END_IGNORE_DEPRECATIONS + if (window->toggle_sidepane_type == THUNAR_TYPE_TREE_PANE || window->toggle_sidepane_type == THUNAR_TYPE_SHORTCUTS_PANE) + thunar_window_install_sidepane (window, window->toggle_sidepane_type); } return TRUE; @@ -1390,42 +1655,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS -static gboolean -thunar_window_toggle_menubar (ThunarWindow *window) -{ - _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); - - if (!gtk_widget_get_visible (window->menubar)) - { - /* temporarily show menu bar */ - gtk_widget_show (window->menubar); - return TRUE; - } - - return FALSE; -} - - - -static void -thunar_window_toggle_menubar_deactivate (GtkWidget *menubar, - ThunarWindow *window) -{ - GtkAction *action; - - _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - _thunar_return_if_fail (window->menubar == menubar); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* this was a temporarily show, hide the bar */ - action = gtk_action_group_get_action (window->action_group, "view-menubar"); - if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) - gtk_widget_hide (menubar); -G_GNUC_END_IGNORE_DEPRECATIONS -} - - - static gboolean thunar_window_zoom_in (ThunarWindow *window) { @@ -1493,8 +1722,7 @@ thunar_window_tab_change (ThunarWindow *window, static void -switch_next_tab (GtkAction *action, - ThunarWindow *window) +thunar_window_action_switch_next_tab (ThunarWindow *window) { gint current_page; gint new_page; @@ -1512,8 +1740,7 @@ switch_next_tab (GtkAction *action, static void -switch_previous_tab (GtkAction *action, - ThunarWindow *window) +thunar_window_action_switch_previous_tab (ThunarWindow *window) { gint current_page; gint new_page; @@ -1638,9 +1865,8 @@ thunar_window_notebook_switch_page (GtkWidget *notebook, guint page_num, ThunarWindow *window) { - GtkAction *action; - GSList *view_bindings; - ThunarFile *current_directory; + GSList *view_bindings; + ThunarFile *current_directory; _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); _thunar_return_if_fail (GTK_IS_NOTEBOOK (notebook)); @@ -1669,18 +1895,8 @@ thunar_window_notebook_switch_page (GtkWidget *notebook, current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (page)); thunar_window_set_current_directory (window, current_directory); -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* activate the selected view */ - action = gtk_action_group_get_action (window->action_group, "view-as-icons"); - g_signal_handlers_block_by_func (action, thunar_window_action_view_changed, window); - gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), view_type2index (G_OBJECT_TYPE (page))); -G_GNUC_END_IGNORE_DEPRECATIONS - g_signal_handlers_unblock_by_func (action, thunar_window_action_view_changed, window); - - /* add stock bindings */ thunar_window_binding_create (window, window, "current-directory", page, "current-directory", G_BINDING_DEFAULT); - thunar_window_binding_create (window, window, "show-hidden", page, "show-hidden", G_BINDING_SYNC_CREATE); thunar_window_binding_create (window, page, "loading", window->spinner, "active", G_BINDING_SYNC_CREATE); thunar_window_binding_create (window, page, "selected-files", window->launcher, "selected-files", G_BINDING_SYNC_CREATE); thunar_window_binding_create (window, page, "zoom-level", window, "zoom-level", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); @@ -1703,6 +1919,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS /* activate new view */ window->view = page; + window->view_type = G_TYPE_FROM_INSTANCE (page); + + if (window->view_type != G_TYPE_NONE) + g_object_set (G_OBJECT (window->preferences), "last-view", g_type_name (window->view_type), NULL); /* integrate the standard view action in the ui */ thunar_component_set_ui_manager (THUNAR_COMPONENT (page), window->ui_manager); @@ -1720,7 +1940,6 @@ thunar_window_notebook_show_tabs (ThunarWindow *window) { gint n_pages; gboolean show_tabs = TRUE; - GtkAction *action; /* check if tabs should be visible */ n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); @@ -1732,12 +1951,6 @@ thunar_window_notebook_show_tabs (ThunarWindow *window) /* update visibility */ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->notebook), show_tabs); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* visibility of the detach action */ - action = gtk_action_group_get_action (window->action_group, "detach-tab"); - gtk_action_set_visible (action, n_pages > 1); -G_GNUC_END_IGNORE_DEPRECATIONS } @@ -1755,7 +1968,6 @@ thunar_window_notebook_page_added (GtkWidget *notebook, /* connect signals */ g_signal_connect (G_OBJECT (page), "notify::loading", G_CALLBACK (thunar_window_notify_loading), window); - g_signal_connect (G_OBJECT (page), "notify::selected-files", G_CALLBACK (thunar_window_update_custom_actions), window); g_signal_connect_swapped (G_OBJECT (page), "start-open-location", G_CALLBACK (thunar_window_start_open_location), window); g_signal_connect_swapped (G_OBJECT (page), "change-directory", G_CALLBACK (thunar_window_set_current_directory), window); g_signal_connect_swapped (G_OBJECT (page), "open-new-tab", G_CALLBACK (thunar_window_notebook_insert), window); @@ -1804,20 +2016,6 @@ thunar_window_notebook_page_removed (GtkWidget *notebook, -static void -thunar_window_notebook_popup_menu_real (ThunarWindow *window) -{ - GtkWidget *menu; - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* run the menu (figuring out whether to use the file or the folder context menu) */ - menu = gtk_ui_manager_get_widget (window->ui_manager, "/tab-context-menu"); -G_GNUC_END_IGNORE_DEPRECATIONS - thunar_gtk_menu_run (GTK_MENU (menu)); -} - - - static gboolean thunar_window_notebook_button_press_event (GtkWidget *notebook, GdkEventButton *event, @@ -1868,7 +2066,7 @@ thunar_window_notebook_button_press_event (GtkWidget *notebook, gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num); /* show the tab menu */ - thunar_window_notebook_popup_menu_real (window); + thunar_window_notebook_popup_menu (notebook, window); } return TRUE; @@ -1883,7 +2081,19 @@ static gboolean thunar_window_notebook_popup_menu (GtkWidget *notebook, ThunarWindow *window) { - thunar_window_notebook_popup_menu_real (window); + GtkWidget *menu; + + menu = gtk_menu_new (); + gtk_menu_set_accel_group (GTK_MENU (menu), window->accel_group); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_NEW_TAB), G_OBJECT (window), GTK_MENU_SHELL (menu)); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (menu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_DETACH_TAB), G_OBJECT (window), GTK_MENU_SHELL (menu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_SWITCH_PREV_TAB), G_OBJECT (window), GTK_MENU_SHELL (menu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_SWITCH_NEXT_TAB), G_OBJECT (window), GTK_MENU_SHELL (menu)); + xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (menu)); + xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_CLOSE_TAB), G_OBJECT (window), GTK_MENU_SHELL (menu)); + gtk_widget_show_all (menu); + thunar_gtk_menu_run (GTK_MENU (menu)); return TRUE; } @@ -1968,7 +2178,8 @@ thunar_window_notebook_insert (ThunarWindow *window, history = thunar_standard_view_copy_history (THUNAR_STANDARD_VIEW (window->view)); /* allocate and setup a new view */ - view = g_object_new (window->view_type, "current-directory", directory, NULL); + view = g_object_new (window->view_type, "current-directory", directory, "accel-group", window->accel_group, NULL); + thunar_view_set_show_hidden (THUNAR_VIEW (view), window->show_hidden); gtk_widget_show (view); /* use the history of the origin view if available */ @@ -2075,10 +2286,10 @@ thunar_window_update_location_bar_visible (ThunarWindow *window) g_object_get (window->preferences, "last-location-bar", &last_location_bar, NULL); - if (strcmp (last_location_bar, g_type_name (G_TYPE_NONE))) - gtk_widget_show (window->location_toolbar); - else + if (exo_str_is_equal (last_location_bar, g_type_name (G_TYPE_NONE))) gtk_widget_hide (window->location_toolbar); + else + gtk_widget_show (window->location_toolbar); g_free (last_location_bar); } @@ -2140,8 +2351,6 @@ thunar_window_install_sidepane (ThunarWindow *window, /* allocate the new side pane widget */ window->sidepane = g_object_new (type, NULL); gtk_widget_set_size_request (window->sidepane, 0, -1); - thunar_component_set_ui_manager (THUNAR_COMPONENT (window->sidepane), window->ui_manager); - exo_binding_new (G_OBJECT (window), "show-hidden", G_OBJECT (window->sidepane), "show-hidden"); exo_binding_new (G_OBJECT (window), "current-directory", G_OBJECT (window->sidepane), "current-directory"); g_signal_connect_swapped (G_OBJECT (window->sidepane), "change-directory", G_CALLBACK (thunar_window_set_current_directory), window); g_signal_connect_swapped (G_OBJECT (window->sidepane), "open-new-tab", G_CALLBACK (thunar_window_notebook_insert), window); @@ -2423,47 +2632,6 @@ THUNAR_THREADS_LEAVE -static void -thunar_window_merge_go_actions (ThunarWindow *window) -{ - GtkAction *action; - - _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - _thunar_return_if_fail (window->go_items_actions_merge_id == 0); - - /* setup the "open-trash" action */ - if (thunar_g_vfs_is_uri_scheme_supported ("trash")) - { -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* allocate a new merge id from the UI manager */ - window->go_items_actions_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager); - - /* add the trash action to the action group */ - action = thunar_trash_action_new (); - g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (thunar_window_action_open_trash), window); - gtk_action_group_add_action_with_accel (window->action_group, action, NULL); - - /* add the action to the UI manager */ - gtk_ui_manager_add_ui (window->ui_manager, - window->go_items_actions_merge_id, - "/main-menu/go-menu/placeholder-go-items-actions", - gtk_action_get_name (GTK_ACTION (action)), - gtk_action_get_name (GTK_ACTION (action)), - GTK_UI_MANAGER_MENUITEM, FALSE); -G_GNUC_END_IGNORE_DEPRECATIONS - - g_object_unref (action); - } - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* setup visibility of the "open-network" action */ - action = gtk_action_group_get_action (window->action_group, "open-network"); - gtk_action_set_visible (action, thunar_g_vfs_is_uri_scheme_supported ("network")); -G_GNUC_END_IGNORE_DEPRECATIONS -} - - - static void thunar_window_open_or_launch (ThunarWindow *window, ThunarFile *file) @@ -2530,8 +2698,8 @@ thunar_window_start_open_location (ThunarWindow *window, static void -thunar_window_action_open_new_tab (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_new_tab (ThunarWindow *window, + GtkWidget *menu_item) { /* insert new tab with current directory as default */ thunar_window_notebook_insert (window, thunar_window_get_current_directory (window)); @@ -2540,8 +2708,8 @@ thunar_window_action_open_new_tab (GtkAction *action, static void -thunar_window_action_open_new_window (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_new_window (ThunarWindow *window, + GtkWidget *menu_item) { ThunarApplication *application; ThunarHistory *history; @@ -2577,22 +2745,8 @@ thunar_window_action_open_new_window (GtkAction *action, static void -thunar_window_action_empty_trash (GtkAction *action, - ThunarWindow *window) -{ - ThunarApplication *application; - - /* launch the operation */ - application = thunar_application_get (); - thunar_application_empty_trash (application, GTK_WIDGET (window), NULL); - g_object_unref (G_OBJECT (application)); -} - - - -static void -thunar_window_action_detach_tab (GtkAction *action, - ThunarWindow *window) +thunar_window_action_detach_tab (ThunarWindow *window, + GtkWidget *menu_item) { GtkWidget *notebook; GtkWidget *label; @@ -2633,8 +2787,8 @@ thunar_window_action_detach_tab (GtkAction *action, static void -thunar_window_action_close_all_windows (GtkAction *action, - ThunarWindow *window) +thunar_window_action_close_all_windows (ThunarWindow *window, + GtkWidget *menu_item) { ThunarApplication *application; GList *windows; @@ -2651,8 +2805,8 @@ thunar_window_action_close_all_windows (GtkAction *action, static void -thunar_window_action_close_tab (GtkAction *action, - ThunarWindow *window) +thunar_window_action_close_tab (ThunarWindow *window, + GtkWidget *menu_item) { if (window->view != NULL) gtk_widget_destroy (window->view); @@ -2661,8 +2815,8 @@ thunar_window_action_close_tab (GtkAction *action, static void -thunar_window_action_close_window (GtkAction *action, - ThunarWindow *window) +thunar_window_action_close_window (ThunarWindow *window, + GtkWidget *menu_item) { gtk_widget_destroy (GTK_WIDGET (window)); } @@ -2670,15 +2824,12 @@ thunar_window_action_close_window (GtkAction *action, static void -thunar_window_action_preferences (GtkAction *action, - ThunarWindow *window) +thunar_window_action_preferences (ThunarWindow *window, + GtkWidget *menu_item) { GtkWidget *dialog; ThunarApplication *application; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); /* allocate and display a preferences dialog */; @@ -2694,14 +2845,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS static void -thunar_window_action_reload (GtkAction *action, - ThunarWindow *window) +thunar_window_action_reload (ThunarWindow *window, + GtkWidget *menu_item) { gboolean result; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); /* force the view to reload */ @@ -2715,148 +2863,108 @@ G_GNUC_END_IGNORE_DEPRECATIONS static void -thunar_window_action_pathbar_changed (GtkToggleAction *action, - ThunarWindow *window) +thunar_window_action_pathbar_changed (ThunarWindow *window) { -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - GtkAction *other_action; - GType type; + gchar *last_location_bar; + gboolean pathbar_checked; - _thunar_return_if_fail (GTK_IS_TOGGLE_ACTION (action)); _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - /* determine the new type of location bar */ - type = gtk_toggle_action_get_active (action) ? THUNAR_TYPE_LOCATION_BUTTONS : G_TYPE_NONE; - - /* update the preferences */ - g_object_set (window->preferences, "last-location-bar", g_type_name (type), NULL); + g_object_get (window->preferences, "last-location-bar", &last_location_bar, NULL); + pathbar_checked = exo_str_is_equal (last_location_bar, g_type_name (THUNAR_TYPE_LOCATION_ENTRY)); + g_free (last_location_bar); - /* check if we actually installed anything */ - if (G_LIKELY (type != G_TYPE_NONE)) - { - /* reset the state of the toolbar action (without firing the handler) */ - other_action = gtk_action_group_get_action (window->action_group, "view-location-selector-toolbar"); - g_signal_handlers_block_by_func (G_OBJECT (other_action), thunar_window_action_toolbar_changed, window); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (other_action), FALSE); - g_signal_handlers_unblock_by_func (G_OBJECT (other_action), thunar_window_action_toolbar_changed, window); - } -G_GNUC_END_IGNORE_DEPRECATIONS + if (pathbar_checked) + g_object_set (window->preferences, "last-location-bar", g_type_name (G_TYPE_NONE), NULL); + else + g_object_set (window->preferences, "last-location-bar", g_type_name (THUNAR_TYPE_LOCATION_ENTRY), NULL); } static void -thunar_window_action_toolbar_changed (GtkToggleAction *action, - ThunarWindow *window) +thunar_window_action_toolbar_changed (ThunarWindow *window) { -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - GtkAction *other_action; - GType type; + gchar *last_location_bar; + gboolean toolbar_checked; - _thunar_return_if_fail (GTK_IS_TOGGLE_ACTION (action)); _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - /* determine the new type of location bar */ - type = gtk_toggle_action_get_active (action) ? THUNAR_TYPE_LOCATION_ENTRY : G_TYPE_NONE; - - /* update the preferences */ - g_object_set (window->preferences, "last-location-bar", g_type_name (type), NULL); + g_object_get (window->preferences, "last-location-bar", &last_location_bar, NULL); + toolbar_checked = exo_str_is_equal (last_location_bar, g_type_name (THUNAR_TYPE_LOCATION_BUTTONS)); + g_free (last_location_bar); - /* check if we actually installed anything */ - if (G_LIKELY (type != G_TYPE_NONE)) - { - /* reset the state of the pathbar action (without firing the handler) */ - other_action = gtk_action_group_get_action (window->action_group, "view-location-selector-pathbar"); - g_signal_handlers_block_by_func (G_OBJECT (other_action), thunar_window_action_pathbar_changed, window); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (other_action), FALSE); - g_signal_handlers_unblock_by_func (G_OBJECT (other_action), thunar_window_action_pathbar_changed, window); - } -G_GNUC_END_IGNORE_DEPRECATIONS + if (toolbar_checked) + g_object_set (window->preferences, "last-location-bar", g_type_name (G_TYPE_NONE), NULL); + else + g_object_set (window->preferences, "last-location-bar", g_type_name (THUNAR_TYPE_LOCATION_BUTTONS), NULL); } static void -thunar_window_action_shortcuts_changed (GtkToggleAction *action, - ThunarWindow *window) +thunar_window_action_shortcuts_changed (ThunarWindow *window) { - GtkAction *other_action; - GType type; + gchar *last_side_pane; + gboolean shortcuts_checked; + GType type = G_TYPE_NONE; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* determine the new type of side pane */ - type = gtk_toggle_action_get_active (action) ? THUNAR_TYPE_SHORTCUTS_PANE : G_TYPE_NONE; -G_GNUC_END_IGNORE_DEPRECATIONS + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - /* install the new sidepane */ - thunar_window_install_sidepane (window, type); + g_object_get (window->preferences, "last-side-pane", &last_side_pane, NULL); + shortcuts_checked = exo_str_is_equal (last_side_pane, g_type_name (THUNAR_TYPE_SHORTCUTS_PANE)); + g_free (last_side_pane); - /* check if we actually installed anything */ - if (G_LIKELY (type != G_TYPE_NONE)) - { -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* reset the state of the tree pane action (without firing the handler) */ - other_action = gtk_action_group_get_action (window->action_group, "view-side-pane-tree"); - g_signal_handlers_block_by_func (G_OBJECT (other_action), thunar_window_action_tree_changed, window); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (other_action), FALSE); - g_signal_handlers_unblock_by_func (G_OBJECT (other_action), thunar_window_action_tree_changed, window); -G_GNUC_END_IGNORE_DEPRECATIONS - } + if (shortcuts_checked) + type = G_TYPE_NONE; + else + type = THUNAR_TYPE_SHORTCUTS_PANE; + + thunar_window_install_sidepane (window, type); } static void -thunar_window_action_tree_changed (GtkToggleAction *action, - ThunarWindow *window) +thunar_window_action_tree_changed (ThunarWindow *window) { - GtkAction *other_action; - GType type; + gchar *last_side_pane; + gboolean tree_view_checked; + GType type = G_TYPE_NONE; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* determine the new type of side pane */ - type = gtk_toggle_action_get_active (action) ? THUNAR_TYPE_TREE_PANE : G_TYPE_NONE; -G_GNUC_END_IGNORE_DEPRECATIONS + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - /* install the new sidepane */ - thunar_window_install_sidepane (window, type); + g_object_get (window->preferences, "last-side-pane", &last_side_pane, NULL); + tree_view_checked = exo_str_is_equal (last_side_pane, g_type_name (THUNAR_TYPE_TREE_PANE)); + g_free (last_side_pane); - /* check if we actually installed anything */ - if (G_LIKELY (type != G_TYPE_NONE)) - { -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* reset the state of the shortcuts pane action (without firing the handler) */ - other_action = gtk_action_group_get_action (window->action_group, "view-side-pane-shortcuts"); - g_signal_handlers_block_by_func (G_OBJECT (other_action), thunar_window_action_shortcuts_changed, window); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (other_action), FALSE); - g_signal_handlers_unblock_by_func (G_OBJECT (other_action), thunar_window_action_shortcuts_changed, window); -G_GNUC_END_IGNORE_DEPRECATIONS - } + if (tree_view_checked) + type = G_TYPE_NONE; + else + type = THUNAR_TYPE_TREE_PANE; + + thunar_window_install_sidepane (window, type); } static void -thunar_window_action_statusbar_changed (GtkToggleAction *action, - ThunarWindow *window) +thunar_window_action_statusbar_changed (ThunarWindow *window) { - gboolean active; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_TOGGLE_ACTION (action)); + gboolean last_statusbar_visible; + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - /* determine the new state of the action */ - active = gtk_toggle_action_get_active (action); -G_GNUC_END_IGNORE_DEPRECATIONS + g_object_get (window->preferences, "last-statusbar-visible", &last_statusbar_visible, NULL); /* check if we should drop the statusbar */ - if (!active && window->statusbar != NULL) + if (!last_statusbar_visible && window->statusbar != NULL) { /* just get rid of the statusbar */ gtk_widget_destroy (window->statusbar); window->statusbar = NULL; } - else if (active && window->statusbar == NULL) + else if (last_statusbar_visible && window->statusbar == NULL) { /* setup a new statusbar */ window->statusbar = thunar_statusbar_new (); @@ -2869,91 +2977,54 @@ G_GNUC_END_IGNORE_DEPRECATIONS thunar_window_binding_create (window, window->view, "statusbar-text", window->statusbar, "text", G_BINDING_SYNC_CREATE); } - /* remember the setting */ - if (gtk_widget_get_visible (GTK_WIDGET (window))) - g_object_set (G_OBJECT (window->preferences), "last-statusbar-visible", active, NULL); + g_object_set (G_OBJECT (window->preferences), "last-statusbar-visible", !last_statusbar_visible, NULL); } static void -thunar_window_action_menubar_changed (GtkToggleAction *action, - ThunarWindow *window) +thunar_window_action_menubar_changed (ThunarWindow *window) { - gboolean active; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_TOGGLE_ACTION (action)); + gboolean last_menubar_visible; + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - /* determine the new state of the action */ - active = gtk_toggle_action_get_active (action); -G_GNUC_END_IGNORE_DEPRECATIONS + g_object_get (window->preferences, "last-menubar-visible", &last_menubar_visible, NULL); - /* show or hide the bar */ - gtk_widget_set_visible (window->menubar, active); + gtk_widget_set_visible (window->menubar, !last_menubar_visible); - /* remember the setting */ - if (gtk_widget_get_visible (GTK_WIDGET (window))) - g_object_set (G_OBJECT (window->preferences), "last-menubar-visible", active, NULL); + g_object_set (G_OBJECT (window->preferences), "last-menubar-visible", !last_menubar_visible, NULL); } static void -thunar_window_action_zoom_in (GtkAction *action, - ThunarWindow *window) +thunar_window_action_detailed_view (ThunarWindow *window) { - gboolean result; - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS - _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - - /* increase the zoom level */ - g_signal_emit (G_OBJECT (window), window_signals[ZOOM_IN], 0, &result); + thunar_window_action_view_changed (window, THUNAR_TYPE_DETAILS_VIEW); } static void -thunar_window_action_zoom_out (GtkAction *action, - ThunarWindow *window) +thunar_window_action_icon_view (ThunarWindow *window) { - gboolean result; - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS - _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - - /* decrease the zoom level */ - g_signal_emit (G_OBJECT (window), window_signals[ZOOM_OUT], 0, &result); + thunar_window_action_view_changed (window, THUNAR_TYPE_ICON_VIEW); } static void -thunar_window_action_zoom_reset (GtkAction *action, - ThunarWindow *window) +thunar_window_action_compact_view (ThunarWindow *window) { - gboolean result; - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS - _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - - /* reset zoom level */ - g_signal_emit (G_OBJECT (window), window_signals[ZOOM_RESET], 0, &result); + thunar_window_action_view_changed (window, THUNAR_TYPE_COMPACT_VIEW); } static void -thunar_window_action_view_changed (GtkRadioAction *action, - GtkRadioAction *current, - ThunarWindow *window) +thunar_window_action_view_changed (ThunarWindow *window, + GType view_type) { ThunarFile *file = NULL; ThunarFile *current_directory = NULL; @@ -2975,17 +3046,8 @@ thunar_window_action_view_changed (GtkRadioAction *action, /* remember the file selection */ selected_files = thunar_g_file_list_copy (thunar_component_get_selected_files (THUNAR_COMPONENT (old_view))); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* update the UI (else GtkUIManager will crash on merging) */ - gtk_ui_manager_ensure_update (window->ui_manager); -G_GNUC_END_IGNORE_DEPRECATIONS } - - /* determine the new type of view */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - window->view_type = view_index2type (gtk_radio_action_get_current_value (action)); -G_GNUC_END_IGNORE_DEPRECATIONS + window->view_type = view_type; /* always open a new directory */ if (current_directory == NULL && window->current_directory != NULL) @@ -3017,7 +3079,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS thunar_g_file_list_free (selected_files); /* remember the setting */ - if (gtk_widget_get_visible (GTK_WIDGET (window))) + if (gtk_widget_get_visible (GTK_WIDGET (window)) && window->view_type != G_TYPE_NONE) g_object_set (G_OBJECT (window->preferences), "last-view", g_type_name (window->view_type), NULL); /* release the file references */ @@ -3030,8 +3092,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS static void -thunar_window_action_go_up (GtkAction *action, - ThunarWindow *window) +thunar_window_action_go_up (ThunarWindow *window) { ThunarFile *parent; GError *error = NULL; @@ -3052,8 +3113,7 @@ thunar_window_action_go_up (GtkAction *action, static void -thunar_window_action_open_home (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_home (ThunarWindow *window) { GFile *home; ThunarFile *home_file; @@ -3086,8 +3146,7 @@ thunar_window_action_open_home (GtkAction *action, static gboolean -thunar_window_open_user_folder (GtkAction *action, - ThunarWindow *window, +thunar_window_open_user_folder (ThunarWindow *window, GUserDirectory thunar_user_dir, const gchar *default_name) { @@ -3180,24 +3239,17 @@ thunar_window_open_user_folder (GtkAction *action, static void -thunar_window_action_open_desktop (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_desktop (ThunarWindow *window) { -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - thunar_window_open_user_folder (action, window, - G_USER_DIRECTORY_DESKTOP, - "Desktop"); + thunar_window_open_user_folder (window, G_USER_DIRECTORY_DESKTOP, "Desktop"); } static void -thunar_window_action_open_computer (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_computer (ThunarWindow *window) { GFile *computer; ThunarFile *computer_file; @@ -3230,8 +3282,7 @@ thunar_window_action_open_computer (GtkAction *action, static void -thunar_window_action_open_templates (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_templates (ThunarWindow *window) { GtkWidget *dialog; GtkWidget *button; @@ -3242,14 +3293,9 @@ thunar_window_action_open_templates (GtkAction *action, gboolean show_about_templates; gboolean success; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - success = thunar_window_open_user_folder (action,window, - G_USER_DIRECTORY_TEMPLATES, - "Templates"); + success = thunar_window_open_user_folder (window, G_USER_DIRECTORY_TEMPLATES, "Templates"); /* check whether we should display the "About Templates" dialog */ g_object_get (G_OBJECT (window->preferences), @@ -3315,8 +3361,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS static void -thunar_window_action_open_file_system (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_file_system (ThunarWindow *window) { GFile *root; ThunarFile *root_file; @@ -3349,16 +3394,12 @@ thunar_window_action_open_file_system (GtkAction *action, static void -thunar_window_action_open_trash (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_trash (ThunarWindow *window) { GFile *trash_bin; ThunarFile *trash_bin_file; GError *error = NULL; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); /* determine the path to the trash bin */ @@ -3386,16 +3427,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS static void -thunar_window_action_open_network (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_network (ThunarWindow *window) { ThunarFile *network_file; GError *error = NULL; GFile *network; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_ACTION (action)); -G_GNUC_END_IGNORE_DEPRECATIONS _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); /* determine the network root location */ @@ -3464,34 +3501,36 @@ thunar_window_poke_location_finish (ThunarBrowser *browser, static void -thunar_window_action_open_bookmark (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_bookmark (GtkWidget *menu_item) { ThunarFile *local_file; GFile *remote_file; + GtkWindow *window; /* try to open the local file */ - local_file = g_object_get_data (G_OBJECT (action), I_("thunar-file")); + local_file = g_object_get_data (G_OBJECT (menu_item), I_("thunar-file")); + window = g_object_get_data (G_OBJECT (menu_item), I_("thunar-window")); if (local_file != NULL) { - thunar_window_set_current_directory (window, local_file); + thunar_window_set_current_directory (THUNAR_WINDOW (window), local_file); + g_object_unref (local_file); return; } - /* try to the remote file */ - remote_file = g_object_get_data (G_OBJECT (action), I_("location-file")); + /* try to poke remote files */ + remote_file = g_object_get_data (G_OBJECT (menu_item), I_("location-file")); if (remote_file != NULL) { - thunar_browser_poke_location (THUNAR_BROWSER (window), remote_file, window, + thunar_browser_poke_location (THUNAR_BROWSER (window), remote_file, THUNAR_WINDOW (window), thunar_window_poke_location_finish, NULL); + g_object_unref (remote_file); } } static void -thunar_window_action_open_location (GtkAction *action, - ThunarWindow *window) +thunar_window_action_open_location (ThunarWindow *window) { /* just use the "start-open-location" callback */ thunar_window_start_open_location (window, NULL); @@ -3500,8 +3539,7 @@ thunar_window_action_open_location (GtkAction *action, static void -thunar_window_action_contents (GtkAction *action, - ThunarWindow *window) +thunar_window_action_contents (ThunarWindow *window) { /* display the documentation index */ xfce_dialog_show_help (GTK_WINDOW (window), "thunar", NULL, NULL); @@ -3510,8 +3548,7 @@ thunar_window_action_contents (GtkAction *action, static void -thunar_window_action_about (GtkAction *action, - ThunarWindow *window) +thunar_window_action_about (ThunarWindow *window) { /* just popup the about dialog */ thunar_dialogs_show_about (GTK_WINDOW (window), PACKAGE_NAME, @@ -3522,22 +3559,31 @@ thunar_window_action_about (GtkAction *action, static void -thunar_window_action_show_hidden (GtkToggleAction *action, - ThunarWindow *window) +thunar_window_action_show_hidden (ThunarWindow *window) { -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - _thunar_return_if_fail (GTK_IS_TOGGLE_ACTION (action)); _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); - /* just emit the "notify" signal for the "show-hidden" - * signal and the view will automatically sync its state. - */ - g_object_notify (G_OBJECT (window), "show-hidden"); + window->show_hidden = !window->show_hidden; + gtk_container_foreach (GTK_CONTAINER (window->notebook), (GtkCallback) (void (*)(void)) thunar_view_set_show_hidden, GINT_TO_POINTER (window->show_hidden)); + thunar_side_pane_set_show_hidden (THUNAR_SIDE_PANE (window->sidepane), window->show_hidden); - if (gtk_widget_get_visible (GTK_WIDGET (window))) - g_object_set (G_OBJECT (window->preferences), "last-show-hidden", - gtk_toggle_action_get_active (action), NULL); -G_GNUC_END_IGNORE_DEPRECATIONS + g_object_set (G_OBJECT (window->preferences), "last-show-hidden", window->show_hidden, NULL); + +} + + + +static void +thunar_window_action_open_file_menu (ThunarWindow *window) +{ + GtkWidget *file_menu; + gboolean ret; + + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + file_menu = gtk_container_get_children (GTK_CONTAINER (window->menubar))->data; + g_signal_emit_by_name (file_menu, "button-press-event", NULL, &ret); + gtk_menu_shell_select_first (GTK_MENU_SHELL (window->menubar), TRUE); } @@ -3546,22 +3592,15 @@ static void thunar_window_current_directory_changed (ThunarFile *current_directory, ThunarWindow *window) { - GtkAction *action; gboolean show_full_path; gchar *parse_name = NULL; const gchar *name; + gboolean ret; _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); _thunar_return_if_fail (THUNAR_IS_FILE (current_directory)); _thunar_return_if_fail (window->current_directory == current_directory); -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* update the "Empty Trash" action */ - action = gtk_action_group_get_action (window->action_group, "empty-trash"); - gtk_action_set_sensitive (action, (thunar_file_get_item_count (current_directory) > 0)); - gtk_action_set_visible (action, (thunar_file_is_root (current_directory) && thunar_file_is_trashed (current_directory))); -G_GNUC_END_IGNORE_DEPRECATIONS - /* get name of directory or full path */ g_object_get (G_OBJECT (window->preferences), "misc-full-path-in-title", &show_full_path, NULL); if (G_UNLIKELY (show_full_path)) @@ -3575,6 +3614,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS /* set window icon */ thunar_window_update_window_icon (window); + + /* update the window menu. E.g. relevant for functional shortcuts after startup, + * and for keyboard navigation in the window menu */ + for (GList *lp = gtk_container_get_children (GTK_CONTAINER (window->menubar)); lp != NULL; lp = lp->next) + g_signal_emit_by_name (lp->data, "button-press-event", NULL, &ret); } @@ -3810,8 +3854,6 @@ thunar_window_device_pre_unmount (ThunarDeviceMonitor *device_monitor, GFile *root_file, ThunarWindow *window) { - GtkAction *action; - _thunar_return_if_fail (THUNAR_IS_DEVICE_MONITOR (device_monitor)); _thunar_return_if_fail (window->device_monitor == device_monitor); _thunar_return_if_fail (THUNAR_IS_DEVICE (device)); @@ -3826,12 +3868,8 @@ thunar_window_device_pre_unmount (ThunarDeviceMonitor *device_monitor, if (g_file_equal (thunar_file_get_file (window->current_directory), root_file) || thunar_file_is_gfile_ancestor (window->current_directory, root_file)) { -G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* change to the home folder */ - action = gtk_action_group_get_action (window->action_group, "open-home"); - if (G_LIKELY (action != NULL)) - gtk_action_activate (action); -G_GNUC_END_IGNORE_DEPRECATIONS + thunar_window_action_open_home (window); } } @@ -3870,7 +3908,6 @@ thunar_window_merge_idle (gpointer user_data) /* merge custom preferences from the providers */ THUNAR_THREADS_ENTER thunar_window_merge_custom_preferences (window); - thunar_window_merge_go_actions (window); THUNAR_THREADS_LEAVE thunar_window_bookmark_merge (window); @@ -3979,10 +4016,6 @@ thunar_window_set_zoom_level (ThunarWindow *window, /* notify listeners */ g_object_notify (G_OBJECT (window), "zoom-level"); } - - /* update the "Zoom In" and "Zoom Out" actions */ - thunar_gtk_action_group_set_action_sensitive (window->action_group, "zoom-in", (zoom_level < THUNAR_ZOOM_N_LEVELS - 1)); - thunar_gtk_action_group_set_action_sensitive (window->action_group, "zoom-out", (zoom_level > 0)); } @@ -4015,9 +4048,8 @@ void thunar_window_set_current_directory (ThunarWindow *window, ThunarFile *current_directory) { - GType type; - GtkAction *action; - gchar *type_name; + GType type; + gchar *type_name; _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); _thunar_return_if_fail (current_directory == NULL || THUNAR_IS_FILE (current_directory)); @@ -4050,39 +4082,36 @@ thunar_window_set_current_directory (ThunarWindow *window, /* determine the default view */ g_object_get (G_OBJECT (window->preferences), "default-view", &type_name, NULL); type = g_type_from_name (type_name); + g_free (type_name); /* determine the last selected view if the last selected view preference is not selected */ - if (g_type_is_a (type, G_TYPE_NONE)) + if (g_type_is_a (type, G_TYPE_NONE) || g_type_is_a (type, G_TYPE_INVALID)) { g_object_get (G_OBJECT (window->preferences), "last-view", &type_name, NULL); type = g_type_from_name (type_name); + g_free (type_name); } -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - /* activate the selected view */ - action = gtk_action_group_get_action (window->action_group, "view-as-icons"); - g_signal_handlers_block_by_func (action, thunar_window_action_view_changed, window); - gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), view_type2index (g_type_is_a (type, THUNAR_TYPE_VIEW) ? type : THUNAR_TYPE_ICON_VIEW)); - thunar_window_action_view_changed (GTK_RADIO_ACTION (action), GTK_RADIO_ACTION (action), window); -G_GNUC_END_IGNORE_DEPRECATIONS - g_signal_handlers_unblock_by_func (action, thunar_window_action_view_changed, window); + /* fallback, in case nothing was set */ + if (g_type_is_a (type, G_TYPE_NONE) || g_type_is_a (type, G_TYPE_INVALID)) + type = THUNAR_TYPE_ICON_VIEW; + + thunar_window_action_view_changed (window, type); } /* update window icon and title */ thunar_window_current_directory_changed (current_directory, window); - /* grab the focus to the main view */ if (G_LIKELY (window->view != NULL)) - gtk_widget_grab_focus (window->view); - } - - /* enable the 'Open new window' action if we have a valid directory */ - thunar_gtk_action_group_set_action_sensitive (window->action_group, "new-window", (current_directory != NULL)); - thunar_gtk_action_group_set_action_sensitive (window->action_group, "new-tab", (current_directory != NULL)); + { + /* grab the focus to the main view */ + gtk_widget_grab_focus (window->view); + } /* enable the 'Up' action if possible for the new directory */ thunar_gtk_action_group_set_action_sensitive (window->action_group, "open-parent", (current_directory != NULL && thunar_file_has_parent (current_directory))); + } /* tell everybody that we have a new "current-directory", * we do this first so other widgets display the new @@ -4207,6 +4236,53 @@ thunar_window_set_directories (ThunarWindow *window, +/** + * thunar_window_get_action_entry: + * @window : Instance of a #ThunarWindow + * @action : #ThunarWindowAction for which the #XfceGtkActionEntry is requested + * + * returns a reference to the requested #XfceGtkActionEntry + * + * Return value: (transfer none): The reference to the #XfceGtkActionEntry + **/ +const XfceGtkActionEntry* +thunar_window_get_action_entry (ThunarWindow *window, + ThunarWindowAction action) +{ + return get_action_entry (action); +} + + + +/** + * thunar_window_append_menu_item: + * @window : Instance of a #ThunarWindow + * @menu : #GtkMenuShell to which the item should be added + * @action : #ThunarWindowAction to select which item should be added + * + * Adds the selected, widget specific #GtkMenuItem to the passed #GtkMenuShell + * + * Return value: (transfer none): The added #GtkMenuItem + **/ +void +thunar_window_append_menu_item (ThunarWindow *window, + GtkMenuShell *menu, + ThunarWindowAction action) +{ + GtkWidget *item; + + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (action), G_OBJECT (window), menu); + + if (action == THUNAR_WINDOW_ACTION_ZOOM_IN) + gtk_widget_set_sensitive (item, G_LIKELY (window->zoom_level < THUNAR_ZOOM_N_LEVELS - 1)); + if (action == THUNAR_WINDOW_ACTION_ZOOM_OUT) + gtk_widget_set_sensitive (item, G_LIKELY (window->zoom_level > 0)); +} + + + /** * thunar_window_get_launcher: * @window : a #ThunarWindow instance. diff --git a/thunar/thunar-window.h b/thunar/thunar-window.h index 27cb3b45..947e08b7 100644 --- a/thunar/thunar-window.h +++ b/thunar/thunar-window.h @@ -24,6 +24,8 @@ #include #include +#include + G_BEGIN_DECLS; typedef struct _ThunarWindowClass ThunarWindowClass; @@ -36,33 +38,88 @@ typedef struct _ThunarWindow ThunarWindow; #define THUNAR_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_WINDOW)) #define THUNAR_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_WINDOW, ThunarWindowClass)) -GType thunar_window_get_type (void) G_GNUC_CONST; - -ThunarFile *thunar_window_get_current_directory (ThunarWindow *window); -void thunar_window_set_current_directory (ThunarWindow *window, - ThunarFile *current_directory); - -void thunar_window_scroll_to_file (ThunarWindow *window, - ThunarFile *file, - gboolean select, - gboolean use_align, - gfloat row_align, - gfloat col_align); +/* #XfceGtkActionEntrys provided by this widget */ +typedef enum +{ + THUNAR_WINDOW_ACTION_FILE_MENU, + THUNAR_WINDOW_ACTION_NEW_TAB, + THUNAR_WINDOW_ACTION_NEW_WINDOW, + THUNAR_WINDOW_ACTION_DETACH_TAB, + THUNAR_WINDOW_ACTION_CLOSE_TAB, + THUNAR_WINDOW_ACTION_CLOSE_WINDOW, + THUNAR_WINDOW_ACTION_CLOSE_ALL_WINDOWS, + THUNAR_WINDOW_ACTION_EDIT_MENU, + THUNAR_WINDOW_ACTION_PREFERENCES, + THUNAR_WINDOW_ACTION_VIEW_MENU, + THUNAR_WINDOW_ACTION_RELOAD, + THUNAR_WINDOW_ACTION_RELOAD_ALT, + THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_MENU, + THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_PATHBAR, + THUNAR_WINDOW_ACTION_VIEW_LOCATION_SELECTOR_TOOLBAR, + THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_MENU, + THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_SHORTCUTS, + THUNAR_WINDOW_ACTION_VIEW_SIDE_PANE_TREE, + THUNAR_WINDOW_ACTION_TOGGLE_SIDE_PANE, + THUNAR_WINDOW_ACTION_VIEW_STATUSBAR, + THUNAR_WINDOW_ACTION_VIEW_MENUBAR, + THUNAR_WINDOW_ACTION_SHOW_HIDDEN, + THUNAR_WINDOW_ACTION_ZOOM_IN, + THUNAR_WINDOW_ACTION_ZOOM_IN_ALT, + THUNAR_WINDOW_ACTION_ZOOM_OUT, + THUNAR_WINDOW_ACTION_ZOOM_RESET, + THUNAR_WINDOW_ACTION_VIEW_AS_ICONS, + THUNAR_WINDOW_ACTION_VIEW_AS_DETAILED_LIST, + THUNAR_WINDOW_ACTION_VIEW_AS_COMPACT_LIST, + THUNAR_WINDOW_ACTION_GO_MENU, + THUNAR_WINDOW_ACTION_OPEN_PARENT, + THUNAR_WINDOW_ACTION_BACK, + THUNAR_WINDOW_ACTION_BACK_ALT, + THUNAR_WINDOW_ACTION_FORWARD, + THUNAR_WINDOW_ACTION_OPEN_FILE_SYSTEM, + THUNAR_WINDOW_ACTION_OPEN_HOME, + THUNAR_WINDOW_ACTION_OPEN_DESKTOP, + THUNAR_WINDOW_ACTION_OPEN_COMPUTER, + THUNAR_WINDOW_ACTION_OPEN_TRASH, + THUNAR_WINDOW_ACTION_OPEN_LOCATION, + THUNAR_WINDOW_ACTION_OPEN_LOCATION_ALT, + THUNAR_WINDOW_ACTION_OPEN_TEMPLATES, + THUNAR_WINDOW_ACTION_OPEN_NETWORK, + THUNAR_WINDOW_ACTION_HELP_MENU, + THUNAR_WINDOW_ACTION_CONTENTS, + THUNAR_WINDOW_ACTION_ABOUT, + THUNAR_WINDOW_ACTION_SWITCH_PREV_TAB, + THUNAR_WINDOW_ACTION_SWITCH_NEXT_TAB, -gchar **thunar_window_get_directories (ThunarWindow *window, - gint *active_page); -gboolean thunar_window_set_directories (ThunarWindow *window, - gchar **uris, - gint active_page); -void thunar_window_update_directories (ThunarWindow *window, - ThunarFile *old_directory, - ThunarFile *new_directory); -void thunar_window_notebook_insert (ThunarWindow *window, - ThunarFile *directory); -gboolean thunar_window_has_shortcut_sidepane (ThunarWindow *window); -GtkWidget* thunar_window_get_sidepane (ThunarWindow *window); -ThunarLauncher* thunar_window_get_launcher (ThunarWindow *window); +} ThunarWindowAction; +GType thunar_window_get_type (void) G_GNUC_CONST; +ThunarFile *thunar_window_get_current_directory (ThunarWindow *window); +void thunar_window_set_current_directory (ThunarWindow *window, + ThunarFile *current_directory); +void thunar_window_scroll_to_file (ThunarWindow *window, + ThunarFile *file, + gboolean select, + gboolean use_align, + gfloat row_align, + gfloat col_align); +gchar **thunar_window_get_directories (ThunarWindow *window, + gint *active_page); +gboolean thunar_window_set_directories (ThunarWindow *window, + gchar **uris, + gint active_page); +void thunar_window_update_directories (ThunarWindow *window, + ThunarFile *old_directory, + ThunarFile *new_directory); +void thunar_window_notebook_insert (ThunarWindow *window, + ThunarFile *directory); +gboolean thunar_window_has_shortcut_sidepane (ThunarWindow *window); +GtkWidget* thunar_window_get_sidepane (ThunarWindow *window); +void thunar_window_append_menu_item (ThunarWindow *window, + GtkMenuShell *menu, + ThunarWindowAction action); +ThunarLauncher* thunar_window_get_launcher (ThunarWindow *window); +const XfceGtkActionEntry* thunar_window_get_action_entry (ThunarWindow *window, + ThunarWindowAction action); G_END_DECLS; #endif /* !__THUNAR_WINDOW_H__ */ -- cgit v1.2.1