From 2d21dffdee541e18f1e6dd30b05ede40c3b75bfc Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 22:19:19 +0100 Subject: [PATCH 1/9] Fixed Nemo's naming of "home" on the pathbar from "Home" to the users name, prevents weird issues like seeing /home/Home/Desktop not /home/ikey/Desktop --- src/nemo-pathbar.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nemo-pathbar.c b/src/nemo-pathbar.c index 949fd3836..a5a19a24c 100644 --- a/src/nemo-pathbar.c +++ b/src/nemo-pathbar.c @@ -1269,8 +1269,13 @@ get_dir_name (ButtonData *button_data) { if (button_data->type == DESKTOP_BUTTON) { return _("Desktop"); + /* + } + * originally this would look like /home/Home/Desktop in the pathbar. + * I can see the logic, when you're only staying in $HOME, i.e. Home/Desktop + * but when you've come from a directory further up it just looks wrong. * } else if (button_data->type == HOME_BUTTON) { - return _("Home"); + return _("Home");*/ } else { return button_data->dir_name; } From 82d3c6936f89a5ef9c205c35ebcc51f0e4284f63 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 22:29:55 +0100 Subject: [PATCH 2/9] Remove the use of symbolic icons in Nemo (integrate with GTK Icon Theme better) --- src/nemo-location-entry.c | 4 +- src/nemo-notebook.c | 2 +- src/nemo-places-sidebar.c | 2 +- src/nemo-progress-ui-handler.c | 2 +- src/nemo-search-bar.c | 2 +- src/nemo-window-menus.c | 4 +- src/nemo-window-menus.c.orig | 1406 ++++++++++++++++++++++++++++++++ 7 files changed, 1414 insertions(+), 8 deletions(-) create mode 100644 src/nemo-window-menus.c.orig diff --git a/src/nemo-location-entry.c b/src/nemo-location-entry.c index 89973d289..167af19c5 100644 --- a/src/nemo-location-entry.c +++ b/src/nemo-location-entry.c @@ -385,12 +385,12 @@ nemo_location_entry_set_secondary_action (NemoLocationEntry *entry, case NEMO_LOCATION_ENTRY_ACTION_CLEAR: gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, - "edit-clear-symbolic"); + "edit-clear"); break; case NEMO_LOCATION_ENTRY_ACTION_GOTO: gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, - "go-next-symbolic"); + "go-next"); break; default: g_assert_not_reached (); diff --git a/src/nemo-notebook.c b/src/nemo-notebook.c index 8153660be..cb6ca3545 100644 --- a/src/nemo-notebook.c +++ b/src/nemo-notebook.c @@ -366,7 +366,7 @@ build_tab_label (NemoNotebook *nb, NemoWindowSlot *slot) gtk_widget_set_name (close_button, "nemo-tab-close-button"); - image = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU); + image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_MENU); gtk_widget_set_tooltip_text (close_button, _("Close tab")); g_signal_connect_object (close_button, "clicked", G_CALLBACK (close_button_clicked_cb), slot, 0); diff --git a/src/nemo-places-sidebar.c b/src/nemo-places-sidebar.c index d9a30ee2d..b8eb1fffe 100644 --- a/src/nemo-places-sidebar.c +++ b/src/nemo-places-sidebar.c @@ -222,7 +222,7 @@ get_eject_icon (NemoPlacesSidebar *sidebar, icon_theme = gtk_icon_theme_get_default (); icon_size = nemo_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); - icon = g_themed_icon_new_with_default_fallbacks ("media-eject-symbolic"); + icon = g_themed_icon_new_with_default_fallbacks ("media-eject"); icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon, icon_size, 0); style = gtk_widget_get_style_context (GTK_WIDGET (sidebar)); diff --git a/src/nemo-progress-ui-handler.c b/src/nemo-progress-ui-handler.c index 3481911a3..84223ea31 100644 --- a/src/nemo-progress-ui-handler.c +++ b/src/nemo-progress-ui-handler.c @@ -130,7 +130,7 @@ progress_ui_handler_ensure_status_icon (NemoProgressUIHandler *self) return; } - icon = g_themed_icon_new_with_default_fallbacks ("system-file-manager-symbolic"); + icon = g_themed_icon_new_with_default_fallbacks ("system-file-manager"); status_icon = gtk_status_icon_new_from_gicon (icon); g_signal_connect (status_icon, "activate", (GCallback) status_icon_activate_cb, diff --git a/src/nemo-search-bar.c b/src/nemo-search-bar.c index 25e018970..c11c8fcc8 100644 --- a/src/nemo-search-bar.c +++ b/src/nemo-search-bar.c @@ -163,7 +163,7 @@ nemo_search_bar_init (NemoSearchBar *bar) bar->details->entry = gtk_entry_new (); gtk_entry_set_icon_from_icon_name (GTK_ENTRY (bar->details->entry), GTK_ENTRY_ICON_SECONDARY, - "edit-find-symbolic"); + "edit-find"); gtk_container_add (GTK_CONTAINER (align), bar->details->entry); g_signal_connect (bar->details->entry, "activate", diff --git a/src/nemo-window-menus.c b/src/nemo-window-menus.c index 826b4aef3..181a516f0 100644 --- a/src/nemo-window-menus.c +++ b/src/nemo-window-menus.c @@ -1019,7 +1019,7 @@ static const GtkToggleActionEntry main_toggle_entries[] = { /* tooltip */ N_("Change the visibility of this window's statusbar"), NULL, /* is_active */ TRUE }, - /* name, stock id */ { "Search", "edit-find-symbolic", + /* name, stock id */ { "Search", "edit-find", /* label, accelerator */ N_("_Search for Files..."), "f", /* tooltip */ N_("Search documents and folders by name"), NULL, @@ -1093,7 +1093,7 @@ nemo_window_create_toolbar_action_group (NemoWindow *window) _("Search documents and folders by name"), NULL)); gtk_action_group_add_action (action_group, action); - gtk_action_set_icon_name (GTK_ACTION (action), "edit-find-symbolic"); + gtk_action_set_icon_name (GTK_ACTION (action), "edit-find"); gtk_action_set_is_important (GTK_ACTION (action), TRUE); g_object_unref (action); diff --git a/src/nemo-window-menus.c.orig b/src/nemo-window-menus.c.orig new file mode 100644 index 000000000..826b4aef3 --- /dev/null +++ b/src/nemo-window-menus.c.orig @@ -0,0 +1,1406 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* + * Nemo + * + * Copyright (C) 2000, 2001 Eazel, Inc. + * + * Nemo is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * Nemo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: John Sullivan + */ + +/* nemo-window-menus.h - implementation of nemo window menu operations, + * split into separate file just for convenience. + */ +#include + +#include + +#include "nemo-actions.h" +#include "nemo-application.h" +#include "nemo-connect-server-dialog.h" +#include "nemo-file-management-properties.h" +#include "nemo-navigation-action.h" +#include "nemo-notebook.h" +#include "nemo-window-manage-views.h" +#include "nemo-window-bookmarks.h" +#include "nemo-window-private.h" +#include "nemo-desktop-window.h" +#include "nemo-search-bar.h" +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MENU_PATH_EXTENSION_ACTIONS "/MenuBar/File/Extension Actions" +#define POPUP_PATH_EXTENSION_ACTIONS "/background/Before Zoom Items/Extension Actions" + +#define NETWORK_URI "network:" +#define COMPUTER_URI "computer:" +#define BURN_CD_URI "burn:" + +static void +action_close_window_slot_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + NemoWindowSlot *slot; + + window = NEMO_WINDOW (user_data); + slot = nemo_window_get_active_slot (window); + + nemo_window_pane_slot_close (slot->pane, slot); +} + +static void +action_connect_to_server_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window = NEMO_WINDOW (user_data); + GtkWidget *dialog; + + dialog = nemo_connect_server_dialog_new (window); + + gtk_widget_show (dialog); +} + +static void +action_stop_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + NemoWindowSlot *slot; + + window = NEMO_WINDOW (user_data); + slot = nemo_window_get_active_slot (window); + + nemo_window_slot_stop_loading (slot); +} + +#ifdef TEXT_CHANGE_UNDO +static void +action_undo_callback (GtkAction *action, + gpointer user_data) +{ + NemoApplication *app; + + app = nemo_application_get_singleton (); + nemo_undo_manager_undo (app->undo_manager); +} +#endif + +static void +action_home_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + NemoWindowSlot *slot; + + window = NEMO_WINDOW (user_data); + slot = nemo_window_get_active_slot (window); + + nemo_window_slot_go_home (slot, + nemo_event_should_open_in_new_tab ()); +} + +static void +action_go_to_computer_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + NemoWindowSlot *slot; + GFile *computer; + + window = NEMO_WINDOW (user_data); + slot = nemo_window_get_active_slot (window); + + computer = g_file_new_for_uri (COMPUTER_URI); + nemo_window_slot_go_to (slot, + computer, + nemo_event_should_open_in_new_tab ()); + g_object_unref (computer); +} + +static void +action_go_to_network_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + NemoWindowSlot *slot; + GFile *network; + + window = NEMO_WINDOW (user_data); + slot = nemo_window_get_active_slot (window); + + network = g_file_new_for_uri (NETWORK_URI); + nemo_window_slot_go_to (slot, + network, + nemo_event_should_open_in_new_tab ()); + g_object_unref (network); +} + +static void +action_go_to_templates_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + NemoWindowSlot *slot; + char *path; + GFile *location; + + window = NEMO_WINDOW (user_data); + slot = nemo_window_get_active_slot (window); + + path = nemo_get_templates_directory (); + location = g_file_new_for_path (path); + g_free (path); + nemo_window_slot_go_to (slot, + location, + nemo_event_should_open_in_new_tab ()); + g_object_unref (location); +} + +static void +action_go_to_trash_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + NemoWindowSlot *slot; + GFile *trash; + + window = NEMO_WINDOW (user_data); + slot = nemo_window_get_active_slot (window); + + trash = g_file_new_for_uri ("trash:///"); + nemo_window_slot_go_to (slot, + trash, + nemo_event_should_open_in_new_tab ()); + g_object_unref (trash); +} + +static void +action_reload_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindowSlot *slot; + + slot = nemo_window_get_active_slot (NEMO_WINDOW (user_data)); + nemo_window_slot_reload (slot); +} + +static NemoView * +get_current_view (NemoWindow *window) +{ + NemoWindowSlot *slot; + NemoView *view; + + slot = nemo_window_get_active_slot (window); + view = nemo_window_slot_get_current_view (slot); + + return view; +} + +static void +action_zoom_in_callback (GtkAction *action, + gpointer user_data) +{ + + nemo_view_bump_zoom_level (get_current_view (user_data), 1); +} + +static void +action_zoom_out_callback (GtkAction *action, + gpointer user_data) +{ + nemo_view_bump_zoom_level (get_current_view (user_data), -1); +} + +static void +action_zoom_normal_callback (GtkAction *action, + gpointer user_data) +{ + nemo_view_restore_default_zoom_level (get_current_view (user_data)); +} + +static void +action_show_hidden_files_callback (GtkAction *action, + gpointer callback_data) +{ + NemoWindow *window; + NemoWindowShowHiddenFilesMode mode; + + window = NEMO_WINDOW (callback_data); + + if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) { + mode = NEMO_WINDOW_SHOW_HIDDEN_FILES_ENABLE; + } else { + mode = NEMO_WINDOW_SHOW_HIDDEN_FILES_DISABLE; + } + + nemo_window_set_hidden_files_mode (window, mode); +} + +static void +show_hidden_files_preference_callback (gpointer callback_data) +{ + NemoWindow *window; + GtkAction *action; + + window = NEMO_WINDOW (callback_data); + + if (window->details->show_hidden_files_mode == NEMO_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { + action = gtk_action_group_get_action (nemo_window_get_main_action_group (window), + NEMO_ACTION_SHOW_HIDDEN_FILES); + + /* update button */ + g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_HIDDEN_FILES)); + g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window); + + /* inform views */ + nemo_window_set_hidden_files_mode (window, NEMO_WINDOW_SHOW_HIDDEN_FILES_DEFAULT); + + } +} + +static void +action_preferences_callback (GtkAction *action, + gpointer user_data) +{ + GtkWindow *window; + + window = GTK_WINDOW (user_data); + + nemo_file_management_properties_dialog_show (window); +} + +static void +action_about_nemo_callback (GtkAction *action, + gpointer user_data) +{ + const gchar *license[] = { + N_("Nemo is free software; you can redistribute it and/or modify " + "it under the terms of the GNU General Public License as published by " + "the Free Software Foundation; either version 2 of the License, or " + "(at your option) any later version."), + N_("Nemo is distributed in the hope that it will be useful, " + "but WITHOUT ANY WARRANTY; without even the implied warranty of " + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " + "GNU General Public License for more details."), + N_("You should have received a copy of the GNU General Public License " + "along with Nemo; if not, write to the Free Software Foundation, Inc., " + "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA") + }; + gchar *license_trans, *copyright_str; + GDateTime *date; + + license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]), + _(license[2]), NULL); + + date = g_date_time_new_now_local (); + + gtk_show_about_dialog (GTK_WINDOW (user_data), + "program-name", _("Nemo"), + "version", VERSION, + "comments", _("Nemo lets you organize " + "files and folders, both on " + "your computer and online."), + "license", license_trans, + "wrap-license", TRUE, + "logo-icon-name", "nemo", + NULL); + + g_free (license_trans); + g_free (copyright_str); + g_date_time_unref (date); +} + +static void +action_up_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window = user_data; + NemoWindowSlot *slot; + + slot = nemo_window_get_active_slot (window); + nemo_window_slot_go_up (slot, FALSE, nemo_event_should_open_in_new_tab ()); +} + +static void +action_nemo_manual_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + GError *error; + GtkWidget *dialog; + const char* helpuri; + const char* name = gtk_action_get_name (action); + + error = NULL; + window = NEMO_WINDOW (user_data); + + if (g_str_equal (name, "NemoHelpSearch")) { + helpuri = "help:gnome-help/files-search"; + } else if (g_str_equal (name,"NemoHelpSort")) { + helpuri = "help:gnome-help/files-sort"; + } else if (g_str_equal (name, "NemoHelpLost")) { + helpuri = "help:gnome-help/files-lost"; + } else if (g_str_equal (name, "NemoHelpShare")) { + helpuri = "help:gnome-help/files-share"; + } else { + helpuri = "help:gnome-help/files"; + } + + if (NEMO_IS_DESKTOP_WINDOW (window)) { + nemo_launch_application_from_command (gtk_window_get_screen (GTK_WINDOW (window)), "gnome-help", FALSE, NULL); + } else { + gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)), + helpuri, + gtk_get_current_event_time (), &error); + } + + if (error) { + dialog = gtk_message_dialog_new (GTK_WINDOW (window), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("There was an error displaying help: \n%s"), + error->message); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (gtk_widget_destroy), + NULL); + + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + gtk_widget_show (dialog); + g_error_free (error); + } +} + +static void +menu_item_select_cb (GtkMenuItem *proxy, + NemoWindow *window) +{ + GtkAction *action; + char *message; + + action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)); + g_return_if_fail (action != NULL); + + g_object_get (G_OBJECT (action), "tooltip", &message, NULL); + if (message) { + gtk_statusbar_push (GTK_STATUSBAR (window->details->statusbar), + window->details->help_message_cid, message); + g_free (message); + } +} + +static void +menu_item_deselect_cb (GtkMenuItem *proxy, + NemoWindow *window) +{ + gtk_statusbar_pop (GTK_STATUSBAR (window->details->statusbar), + window->details->help_message_cid); +} + +static void +disconnect_proxy_cb (GtkUIManager *manager, + GtkAction *action, + GtkWidget *proxy, + NemoWindow *window) +{ + if (GTK_IS_MENU_ITEM (proxy)) { + g_signal_handlers_disconnect_by_func + (proxy, G_CALLBACK (menu_item_select_cb), window); + g_signal_handlers_disconnect_by_func + (proxy, G_CALLBACK (menu_item_deselect_cb), window); + } +} + +static void +trash_state_changed_cb (NemoTrashMonitor *monitor, + gboolean state, + NemoWindow *window) +{ + GtkActionGroup *action_group; + GtkAction *action; + GIcon *gicon; + + action_group = nemo_window_get_main_action_group (window); + action = gtk_action_group_get_action (action_group, "Go to Trash"); + + gicon = nemo_trash_monitor_get_icon (); + + if (gicon) { + g_object_set (action, "gicon", gicon, NULL); + g_object_unref (gicon); + } +} + +static void +nemo_window_initialize_trash_icon_monitor (NemoWindow *window) +{ + NemoTrashMonitor *monitor; + + monitor = nemo_trash_monitor_get (); + + trash_state_changed_cb (monitor, TRUE, window); + + g_signal_connect (monitor, "trash_state_changed", + G_CALLBACK (trash_state_changed_cb), window); +} + +#define MENU_ITEM_MAX_WIDTH_CHARS 32 + +enum { + SIDEBAR_PLACES, + SIDEBAR_TREE +}; + +static void +action_close_all_windows_callback (GtkAction *action, + gpointer user_data) +{ + nemo_application_close_all_windows (nemo_application_get_singleton ()); +} + +static void +action_back_callback (GtkAction *action, + gpointer user_data) +{ + nemo_window_back_or_forward (NEMO_WINDOW (user_data), + TRUE, 0, nemo_event_should_open_in_new_tab ()); +} + +static void +action_forward_callback (GtkAction *action, + gpointer user_data) +{ + nemo_window_back_or_forward (NEMO_WINDOW (user_data), + FALSE, 0, nemo_event_should_open_in_new_tab ()); +} + +static void +action_split_view_switch_next_pane_callback(GtkAction *action, + gpointer user_data) +{ + nemo_window_pane_grab_focus (nemo_window_get_next_pane (NEMO_WINDOW (user_data))); +} + +static void +action_split_view_same_location_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + NemoWindowPane *next_pane; + GFile *location; + + window = NEMO_WINDOW (user_data); + next_pane = nemo_window_get_next_pane (window); + + if (!next_pane) { + return; + } + location = nemo_window_slot_get_location (next_pane->active_slot); + if (location) { + nemo_window_slot_go_to (nemo_window_get_active_slot (window), location, FALSE); + g_object_unref (location); + } +} + +static void +action_show_hide_sidebar_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + + window = NEMO_WINDOW (user_data); + + if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) { + nemo_window_show_sidebar (window); + } else { + nemo_window_hide_sidebar (window); + } +} + +static void +action_split_view_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + gboolean is_active; + + window = NEMO_WINDOW (user_data); + + is_active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); + if (is_active != nemo_window_split_view_showing (window)) { + NemoWindowSlot *slot; + + if (is_active) { + nemo_window_split_view_on (window); + } else { + nemo_window_split_view_off (window); + } + + slot = nemo_window_get_active_slot (window); + if (slot != NULL) { + nemo_view_update_menus (slot->content_view); + } + } +} + +static void +nemo_window_update_split_view_actions_sensitivity (NemoWindow *window) +{ + GtkActionGroup *action_group; + GtkAction *action; + gboolean have_multiple_panes; + gboolean next_pane_is_in_same_location; + GFile *active_pane_location; + GFile *next_pane_location; + NemoWindowPane *next_pane; + NemoWindowSlot *active_slot; + + active_slot = nemo_window_get_active_slot (window); + action_group = nemo_window_get_main_action_group (window); + + /* collect information */ + have_multiple_panes = nemo_window_split_view_showing (window); + if (active_slot != NULL) { + active_pane_location = nemo_window_slot_get_location (active_slot); + } else { + active_pane_location = NULL; + } + + next_pane = nemo_window_get_next_pane (window); + if (next_pane && next_pane->active_slot) { + next_pane_location = nemo_window_slot_get_location (next_pane->active_slot); + next_pane_is_in_same_location = (active_pane_location && next_pane_location && + g_file_equal (active_pane_location, next_pane_location)); + } else { + next_pane_location = NULL; + next_pane_is_in_same_location = FALSE; + } + + /* switch to next pane */ + action = gtk_action_group_get_action (action_group, "SplitViewNextPane"); + gtk_action_set_sensitive (action, have_multiple_panes); + + /* same location */ + action = gtk_action_group_get_action (action_group, "SplitViewSameLocation"); + gtk_action_set_sensitive (action, have_multiple_panes && !next_pane_is_in_same_location); + + /* clean up */ + g_clear_object (&active_pane_location); + g_clear_object (&next_pane_location); +} + +/* TODO: bind all of this with g_settings_bind and GBinding */ +static guint +sidebar_id_to_value (const gchar *sidebar_id) +{ + guint retval = SIDEBAR_PLACES; + + if (g_strcmp0 (sidebar_id, NEMO_WINDOW_SIDEBAR_TREE) == 0) + retval = SIDEBAR_TREE; + + return retval; +} + +void +nemo_window_update_show_hide_menu_items (NemoWindow *window) +{ + GtkActionGroup *action_group; + GtkAction *action; + guint current_value; + + action_group = nemo_window_get_main_action_group (window); + + action = gtk_action_group_get_action (action_group, + NEMO_ACTION_SHOW_HIDE_EXTRA_PANE); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + nemo_window_split_view_showing (window)); + nemo_window_update_split_view_actions_sensitivity (window); + + action = gtk_action_group_get_action (action_group, + "Sidebar Places"); + current_value = sidebar_id_to_value (window->details->sidebar_id); + gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), current_value); +} + +static void +action_add_bookmark_callback (GtkAction *action, + gpointer user_data) +{ + nemo_window_add_bookmark_for_current_location (NEMO_WINDOW (user_data)); +} + +static void +action_edit_bookmarks_callback (GtkAction *action, + gpointer user_data) +{ + nemo_window_edit_bookmarks (NEMO_WINDOW (user_data)); +} + +static void +connect_proxy_cb (GtkActionGroup *action_group, + GtkAction *action, + GtkWidget *proxy, + NemoWindow *window) +{ + GtkLabel *label; + + if (!GTK_IS_MENU_ITEM (proxy)) + return; + + label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy))); + + gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); + gtk_label_set_max_width_chars (label, MENU_ITEM_MAX_WIDTH_CHARS); + + g_signal_connect (proxy, "select", + G_CALLBACK (menu_item_select_cb), window); + g_signal_connect (proxy, "deselect", + G_CALLBACK (menu_item_deselect_cb), window); +} + +static const char* icon_entries[] = { + "/MenuBar/Other Menus/Go/Home", + "/MenuBar/Other Menus/Go/Computer", + "/MenuBar/Other Menus/Go/Go to Templates", + "/MenuBar/Other Menus/Go/Go to Trash", + "/MenuBar/Other Menus/Go/Go to Network", + "/MenuBar/Other Menus/Go/Go to Location" +}; + +/** + * refresh_go_menu: + * + * Refresh list of bookmarks at end of Go menu to match centralized history list. + * @window: The NemoWindow whose Go menu will be refreshed. + **/ +static void +nemo_window_initialize_go_menu (NemoWindow *window) +{ + GtkUIManager *ui_manager; + GtkWidget *menuitem; + int i; + + ui_manager = nemo_window_get_ui_manager (NEMO_WINDOW (window)); + + for (i = 0; i < G_N_ELEMENTS (icon_entries); i++) { + menuitem = gtk_ui_manager_get_widget ( + ui_manager, + icon_entries[i]); + + gtk_image_menu_item_set_always_show_image ( + GTK_IMAGE_MENU_ITEM (menuitem), TRUE); + } +} + +static void +action_new_window_callback (GtkAction *action, + gpointer user_data) +{ + NemoApplication *application; + NemoWindow *current_window, *new_window; + + current_window = NEMO_WINDOW (user_data); + application = nemo_application_get_singleton (); + + new_window = nemo_application_create_window ( + application, + gtk_window_get_screen (GTK_WINDOW (current_window))); + nemo_window_slot_go_home (nemo_window_get_active_slot (new_window), FALSE); +} + +static void +action_new_tab_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window; + + window = NEMO_WINDOW (user_data); + nemo_window_new_tab (window); +} + +static void +action_go_to_location_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindow *window = user_data; + NemoWindowPane *pane; + + pane = nemo_window_get_active_pane (window); + nemo_window_pane_ensure_location_bar (pane); +} + +static void +action_tabs_previous_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindowPane *pane; + NemoWindow *window = user_data; + + pane = nemo_window_get_active_pane (window); + nemo_notebook_set_current_page_relative (NEMO_NOTEBOOK (pane->notebook), -1); +} + +static void +action_tabs_next_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindowPane *pane; + NemoWindow *window = user_data; + + pane = nemo_window_get_active_pane (window); + nemo_notebook_set_current_page_relative (NEMO_NOTEBOOK (pane->notebook), 1); +} + +static void +action_tabs_move_left_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindowPane *pane; + NemoWindow *window = user_data; + + pane = nemo_window_get_active_pane (window); + nemo_notebook_reorder_current_child_relative (NEMO_NOTEBOOK (pane->notebook), -1); +} + +static void +action_tabs_move_right_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindowPane *pane; + NemoWindow *window = user_data; + + pane = nemo_window_get_active_pane (window); + nemo_notebook_reorder_current_child_relative (NEMO_NOTEBOOK (pane->notebook), 1); +} + +static void +action_tab_change_action_activate_callback (GtkAction *action, + gpointer user_data) +{ + NemoWindowPane *pane; + NemoWindow *window = user_data; + GtkNotebook *notebook; + int num; + + pane = nemo_window_get_active_pane (window); + notebook = GTK_NOTEBOOK (pane->notebook); + + num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action), "num")); + if (num < gtk_notebook_get_n_pages (notebook)) { + gtk_notebook_set_current_page (notebook, num); + } +} + +static void +sidebar_radio_entry_changed_cb (GtkAction *action, + GtkRadioAction *current, + gpointer user_data) +{ + gint current_value; + + current_value = gtk_radio_action_get_current_value (current); + + if (current_value == SIDEBAR_PLACES) { + g_settings_set_string (nemo_window_state, + NEMO_WINDOW_STATE_SIDE_PANE_VIEW, + NEMO_WINDOW_SIDEBAR_PLACES); + } else if (current_value == SIDEBAR_TREE) { + g_settings_set_string (nemo_window_state, + NEMO_WINDOW_STATE_SIDE_PANE_VIEW, + NEMO_WINDOW_SIDEBAR_TREE); + } +} + +static const GtkActionEntry main_entries[] = { + /* name, stock id, label */ { "File", NULL, N_("_File") }, + /* name, stock id, label */ { "Edit", NULL, N_("_Edit") }, + /* name, stock id, label */ { "View", NULL, N_("_View") }, + /* name, stock id, label */ { "Help", NULL, N_("_Help") }, + /* name, stock id */ { "Close", GTK_STOCK_CLOSE, + /* label, accelerator */ N_("_Close"), "W", + /* tooltip */ N_("Close this folder"), + G_CALLBACK (action_close_window_slot_callback) }, + { "Preferences", GTK_STOCK_PREFERENCES, + N_("Prefere_nces"), + NULL, N_("Edit Nemo preferences"), + G_CALLBACK (action_preferences_callback) }, +#ifdef TEXT_CHANGE_UNDO + /* name, stock id, label */ { "Undo", NULL, N_("_Undo"), + "Z", N_("Undo the last text change"), + G_CALLBACK (action_undo_callback) }, +#endif + /* name, stock id, label */ { "Up", GTK_STOCK_GO_UP, N_("Open _Parent"), + "Up", N_("Open the parent folder"), + G_CALLBACK (action_up_callback) }, + /* name, stock id, label */ { "UpAccel", NULL, "UpAccel", + "", NULL, + G_CALLBACK (action_up_callback) }, + /* name, stock id */ { "Stop", GTK_STOCK_STOP, + /* label, accelerator */ N_("_Stop"), NULL, + /* tooltip */ N_("Stop loading the current location"), + G_CALLBACK (action_stop_callback) }, + /* name, stock id */ { "Reload", GTK_STOCK_REFRESH, + /* label, accelerator */ N_("_Reload"), "R", + /* tooltip */ N_("Reload the current location"), + G_CALLBACK (action_reload_callback) }, + /* name, stock id */ { "NemoHelp", GTK_STOCK_HELP, + /* label, accelerator */ N_("_All Topics"), "F1", + /* tooltip */ N_("Display Nemo help"), + G_CALLBACK (action_nemo_manual_callback) }, + /* name, stock id */ { "NemoHelpSearch", NULL, + /* label, accelerator */ N_("Search for files"), NULL, + /* tooltip */ N_("Locate files based on file name and type. Save your searches for later use."), + G_CALLBACK (action_nemo_manual_callback) }, + /* name, stock id */ { "NemoHelpSort", NULL, + /* label, accelerator */ N_("Sort files and folders"), NULL, + /* tooltip */ N_("Arrange files by name, size, type, or when they were changed."), + G_CALLBACK (action_nemo_manual_callback) }, + /* name, stock id */ { "NemoHelpLost", NULL, + /* label, accelerator */ N_("Find a lost file"), NULL, + /* tooltip */ N_("Follow these tips if you can't find a file you created or downloaded."), + G_CALLBACK (action_nemo_manual_callback) }, + /* name, stock id */ { "NemoHelpShare", NULL, + /* label, accelerator */ N_("Share and transfer files"), NULL, + /* tooltip */ N_("Easily transfer files to your contacts and devices from the file manager."), + G_CALLBACK (action_nemo_manual_callback) }, + /* name, stock id */ { "About Nemo", GTK_STOCK_ABOUT, + /* label, accelerator */ N_("_About"), NULL, + /* tooltip */ N_("Display credits for the creators of Nemo"), + G_CALLBACK (action_about_nemo_callback) }, + /* name, stock id */ { "Zoom In", GTK_STOCK_ZOOM_IN, + /* label, accelerator */ N_("Zoom _In"), "plus", + /* tooltip */ N_("Increase the view size"), + G_CALLBACK (action_zoom_in_callback) }, + /* name, stock id */ { "ZoomInAccel", NULL, + /* label, accelerator */ "ZoomInAccel", "equal", + /* tooltip */ NULL, + G_CALLBACK (action_zoom_in_callback) }, + /* name, stock id */ { "ZoomInAccel2", NULL, + /* label, accelerator */ "ZoomInAccel2", "KP_Add", + /* tooltip */ NULL, + G_CALLBACK (action_zoom_in_callback) }, + /* name, stock id */ { "Zoom Out", GTK_STOCK_ZOOM_OUT, + /* label, accelerator */ N_("Zoom _Out"), "minus", + /* tooltip */ N_("Decrease the view size"), + G_CALLBACK (action_zoom_out_callback) }, + /* name, stock id */ { "ZoomOutAccel", NULL, + /* label, accelerator */ "ZoomOutAccel", "KP_Subtract", + /* tooltip */ NULL, + G_CALLBACK (action_zoom_out_callback) }, + /* name, stock id */ { "Zoom Normal", GTK_STOCK_ZOOM_100, + /* label, accelerator */ N_("Normal Si_ze"), "0", + /* tooltip */ N_("Use the normal view size"), + G_CALLBACK (action_zoom_normal_callback) }, + /* name, stock id */ { "Connect to Server", NULL, + /* label, accelerator */ N_("Connect to _Server..."), NULL, + /* tooltip */ N_("Connect to a remote computer or shared disk"), + G_CALLBACK (action_connect_to_server_callback) }, + /* name, stock id */ { "Home", NEMO_ICON_HOME, + /* label, accelerator */ N_("_Home"), "Home", + /* tooltip */ N_("Open your personal folder"), + G_CALLBACK (action_home_callback) }, + /* name, stock id */ { "Go to Computer", NEMO_ICON_COMPUTER, + /* label, accelerator */ N_("_Computer"), NULL, + /* tooltip */ N_("Browse all local and remote disks and folders accessible from this computer"), + G_CALLBACK (action_go_to_computer_callback) }, + /* name, stock id */ { "Go to Network", NEMO_ICON_NETWORK, + /* label, accelerator */ N_("_Network"), NULL, + /* tooltip */ N_("Browse bookmarked and local network locations"), + G_CALLBACK (action_go_to_network_callback) }, + /* name, stock id */ { "Go to Templates", NEMO_ICON_TEMPLATE, + /* label, accelerator */ N_("T_emplates"), NULL, + /* tooltip */ N_("Open your personal templates folder"), + G_CALLBACK (action_go_to_templates_callback) }, + /* name, stock id */ { "Go to Trash", NEMO_ICON_TRASH, + /* label, accelerator */ N_("_Trash"), NULL, + /* tooltip */ N_("Open your personal trash folder"), + G_CALLBACK (action_go_to_trash_callback) }, + /* name, stock id, label */ { "Go", NULL, N_("_Go") }, + /* name, stock id, label */ { "Bookmarks", NULL, N_("_Bookmarks") }, + /* name, stock id, label */ { "Tabs", NULL, N_("_Tabs") }, + /* name, stock id, label */ { "New Window", "window-new", N_("New _Window"), + "N", N_("Open another Nemo window for the displayed location"), + G_CALLBACK (action_new_window_callback) }, + /* name, stock id, label */ { "New Tab", "tab-new", N_("New _Tab"), + "T", N_("Open another tab for the displayed location"), + G_CALLBACK (action_new_tab_callback) }, + /* name, stock id, label */ { "Close All Windows", NULL, N_("Close _All Windows"), + "Q", N_("Close all Navigation windows"), + G_CALLBACK (action_close_all_windows_callback) }, + /* name, stock id, label */ { NEMO_ACTION_BACK, GTK_STOCK_GO_BACK, N_("_Back"), + "Left", N_("Go to the previous visited location"), + G_CALLBACK (action_back_callback) }, + /* name, stock id, label */ { NEMO_ACTION_FORWARD, GTK_STOCK_GO_FORWARD, N_("_Forward"), + "Right", N_("Go to the next visited location"), + G_CALLBACK (action_forward_callback) }, + /* name, stock id, label */ { "Go to Location", NULL, N_("_Location..."), + "L", N_("Specify a location to open"), + G_CALLBACK (action_go_to_location_callback) }, + /* name, stock id, label */ { "SplitViewNextPane", NULL, N_("S_witch to Other Pane"), + "F6", N_("Move focus to the other pane in a split view window"), + G_CALLBACK (action_split_view_switch_next_pane_callback) }, + /* name, stock id, label */ { "SplitViewSameLocation", NULL, N_("Sa_me Location as Other Pane"), + NULL, N_("Go to the same location as in the extra pane"), + G_CALLBACK (action_split_view_same_location_callback) }, + /* name, stock id, label */ { "Add Bookmark", GTK_STOCK_ADD, N_("_Add Bookmark"), + "d", N_("Add a bookmark for the current location to this menu"), + G_CALLBACK (action_add_bookmark_callback) }, + /* name, stock id, label */ { "Edit Bookmarks", NULL, N_("_Edit Bookmarks..."), + "b", N_("Display a window that allows editing the bookmarks in this menu"), + G_CALLBACK (action_edit_bookmarks_callback) }, + { "TabsPrevious", NULL, N_("_Previous Tab"), "Page_Up", + N_("Activate previous tab"), + G_CALLBACK (action_tabs_previous_callback) }, + { "TabsNext", NULL, N_("_Next Tab"), "Page_Down", + N_("Activate next tab"), + G_CALLBACK (action_tabs_next_callback) }, + { "TabsMoveLeft", NULL, N_("Move Tab _Left"), "Page_Up", + N_("Move current tab to left"), + G_CALLBACK (action_tabs_move_left_callback) }, + { "TabsMoveRight", NULL, N_("Move Tab _Right"), "Page_Down", + N_("Move current tab to right"), + G_CALLBACK (action_tabs_move_right_callback) }, + { "Sidebar List", NULL, N_("Sidebar") } +}; + +static const GtkToggleActionEntry main_toggle_entries[] = { + /* name, stock id */ { "Show Hidden Files", NULL, + /* label, accelerator */ N_("Show _Hidden Files"), "H", + /* tooltip */ N_("Toggle the display of hidden files in the current window"), + G_CALLBACK (action_show_hidden_files_callback), + TRUE }, + /* name, stock id */ { "Show Hide Toolbar", NULL, + /* label, accelerator */ N_("_Main Toolbar"), NULL, + /* tooltip */ N_("Change the visibility of this window's main toolbar"), + NULL, + /* is_active */ TRUE }, + /* name, stock id */ { "Show Hide Sidebar", NULL, + /* label, accelerator */ N_("_Show Sidebar"), "F9", + /* tooltip */ N_("Change the visibility of this window's side pane"), + G_CALLBACK (action_show_hide_sidebar_callback), + /* is_active */ TRUE }, + /* name, stock id */ { "Show Hide Statusbar", NULL, + /* label, accelerator */ N_("St_atusbar"), NULL, + /* tooltip */ N_("Change the visibility of this window's statusbar"), + NULL, + /* is_active */ TRUE }, + /* name, stock id */ { "Search", "edit-find-symbolic", + /* label, accelerator */ N_("_Search for Files..."), "f", + /* tooltip */ N_("Search documents and folders by name"), + NULL, + /* is_active */ FALSE }, + /* name, stock id */ { NEMO_ACTION_SHOW_HIDE_EXTRA_PANE, NULL, + /* label, accelerator */ N_("E_xtra Pane"), "F3", + /* tooltip */ N_("Open an extra folder view side-by-side"), + G_CALLBACK (action_split_view_callback), + /* is_active */ FALSE }, + /* name, stock id */ { "Show Hide Location Entry", NULL, + /* label, accelerator */ N_("Loca_tion entry"), "l", + /* tooltip */ N_("Change the visibility of this window's location entry"), + NULL, + /* is_active */ TRUE }, +}; + +static const GtkRadioActionEntry main_radio_entries[] = { + { "Sidebar Places", NULL, + N_("Places"), NULL, N_("Select Places as the default sidebar"), + SIDEBAR_PLACES }, + { "Sidebar Tree", NULL, + N_("Tree"), NULL, N_("Select Tree as the default sidebar"), + SIDEBAR_TREE } +}; + +GtkActionGroup * +nemo_window_create_toolbar_action_group (NemoWindow *window) +{ + NemoNavigationState *navigation_state; + GtkActionGroup *action_group; + GtkAction *action; + + action_group = gtk_action_group_new ("ToolbarActions"); + gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); + + action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, + "name", NEMO_ACTION_BACK, + "label", _("_Back"), + "stock_id", GTK_STOCK_GO_BACK, + "tooltip", _("Go to the previous visited location"), + "arrow-tooltip", _("Back history"), + "window", window, + "direction", NEMO_NAVIGATION_DIRECTION_BACK, + "sensitive", FALSE, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (action_back_callback), window); + gtk_action_group_add_action (action_group, action); + + g_object_unref (action); + + action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, + "name", NEMO_ACTION_FORWARD, + "label", _("_Forward"), + "stock_id", GTK_STOCK_GO_FORWARD, + "tooltip", _("Go to the next visited location"), + "arrow-tooltip", _("Forward history"), + "window", window, + "direction", NEMO_NAVIGATION_DIRECTION_FORWARD, + "sensitive", FALSE, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (action_forward_callback), window); + gtk_action_group_add_action (action_group, action); + + g_object_unref (action); + + action = GTK_ACTION + (gtk_toggle_action_new (NEMO_ACTION_SEARCH, + _("Search"), + _("Search documents and folders by name"), + NULL)); + gtk_action_group_add_action (action_group, action); + gtk_action_set_icon_name (GTK_ACTION (action), "edit-find-symbolic"); + gtk_action_set_is_important (GTK_ACTION (action), TRUE); + + g_object_unref (action); + + navigation_state = nemo_window_get_navigation_state (window); + nemo_navigation_state_add_group (navigation_state, action_group); + + return action_group; +} + +static void +window_menus_set_bindings (NemoWindow *window) +{ + GtkActionGroup *action_group; + GtkAction *action; + + action_group = nemo_window_get_main_action_group (window); + + action = gtk_action_group_get_action (action_group, + NEMO_ACTION_SHOW_HIDE_TOOLBAR); + + g_settings_bind (nemo_window_state, + NEMO_WINDOW_STATE_START_WITH_TOOLBAR, + action, + "active", + G_SETTINGS_BIND_DEFAULT); + + action = gtk_action_group_get_action (action_group, + NEMO_ACTION_SHOW_HIDE_STATUSBAR); + + g_settings_bind (nemo_window_state, + NEMO_WINDOW_STATE_START_WITH_STATUS_BAR, + action, + "active", + G_SETTINGS_BIND_DEFAULT); + + action = gtk_action_group_get_action (action_group, + NEMO_ACTION_SHOW_HIDE_SIDEBAR); + + g_settings_bind (nemo_window_state, + NEMO_WINDOW_STATE_START_WITH_SIDEBAR, + action, + "active", + G_SETTINGS_BIND_DEFAULT); + + action = gtk_action_group_get_action (action_group, + NEMO_ACTION_SHOW_HIDE_LOCATION_ENTRY); + + g_settings_bind (nemo_preferences, + NEMO_PREFERENCES_SHOW_LOCATION_ENTRY, + action, + "active", + G_SETTINGS_BIND_DEFAULT); +} + +void +nemo_window_initialize_actions (NemoWindow *window) +{ + GtkActionGroup *action_group; + const gchar *nav_state_actions[] = { + NEMO_ACTION_BACK, NEMO_ACTION_FORWARD, + NEMO_ACTION_SEARCH, NULL + }; + + action_group = nemo_window_get_main_action_group (window); + window->details->nav_state = nemo_navigation_state_new (action_group, + nav_state_actions); + + window_menus_set_bindings (window); + nemo_window_update_show_hide_menu_items (window); + + g_signal_connect (window, "loading_uri", + G_CALLBACK (nemo_window_update_split_view_actions_sensitivity), + NULL); +} + +/** + * nemo_window_initialize_menus + * + * Create and install the set of menus for this window. + * @window: A recently-created NemoWindow. + */ +void +nemo_window_initialize_menus (NemoWindow *window) +{ + GtkActionGroup *action_group; + GtkUIManager *ui_manager; + GtkAction *action; + gint i; + + window->details->ui_manager = gtk_ui_manager_new (); + ui_manager = window->details->ui_manager; + + /* shell actions */ + action_group = gtk_action_group_new ("ShellActions"); + gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); + window->details->main_action_group = action_group; + gtk_action_group_add_actions (action_group, + main_entries, G_N_ELEMENTS (main_entries), + window); + gtk_action_group_add_toggle_actions (action_group, + main_toggle_entries, G_N_ELEMENTS (main_toggle_entries), + window); + gtk_action_group_add_radio_actions (action_group, + main_radio_entries, G_N_ELEMENTS (main_radio_entries), + 0, G_CALLBACK (sidebar_radio_entry_changed_cb), + window); + + action = gtk_action_group_get_action (action_group, NEMO_ACTION_UP); + g_object_set (action, "short_label", _("_Up"), NULL); + + action = gtk_action_group_get_action (action_group, NEMO_ACTION_HOME); + g_object_set (action, "short_label", _("_Home"), NULL); + + action = gtk_action_group_get_action (action_group, NEMO_ACTION_SHOW_HIDDEN_FILES); + g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_HIDDEN_FILES)); + g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window); + + + g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_HIDDEN_FILES, + G_CALLBACK(show_hidden_files_preference_callback), + window); + + /* Alt+N for the first 10 tabs */ + for (i = 0; i < 10; ++i) { + gchar action_name[80]; + gchar accelerator[80]; + + snprintf(action_name, sizeof (action_name), "Tab%d", i); + action = gtk_action_new (action_name, NULL, NULL, NULL); + g_object_set_data (G_OBJECT (action), "num", GINT_TO_POINTER (i)); + g_signal_connect (action, "activate", + G_CALLBACK (action_tab_change_action_activate_callback), window); + snprintf(accelerator, sizeof (accelerator), "%d", (i+1)%10); + gtk_action_group_add_action_with_accel (action_group, action, accelerator); + g_object_unref (action); + gtk_ui_manager_add_ui (ui_manager, + gtk_ui_manager_new_merge_id (ui_manager), + "/", + action_name, + action_name, + GTK_UI_MANAGER_ACCELERATOR, + FALSE); + + } + + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + g_object_unref (action_group); /* owned by ui_manager */ + + gtk_window_add_accel_group (GTK_WINDOW (window), + gtk_ui_manager_get_accel_group (ui_manager)); + + g_signal_connect (ui_manager, "connect_proxy", + G_CALLBACK (connect_proxy_cb), window); + g_signal_connect (ui_manager, "disconnect_proxy", + G_CALLBACK (disconnect_proxy_cb), window); + + /* add the UI */ + gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nemo/nemo-shell-ui.xml", NULL); + + nemo_window_initialize_trash_icon_monitor (window); + nemo_window_initialize_go_menu (window); +} + +void +nemo_window_finalize_menus (NemoWindow *window) +{ + NemoTrashMonitor *monitor; + + monitor = nemo_trash_monitor_get (); + + g_signal_handlers_disconnect_by_func (monitor, + trash_state_changed_cb, window); + + g_signal_handlers_disconnect_by_func (nemo_preferences, + show_hidden_files_preference_callback, window); +} + +static GList * +get_extension_menus (NemoWindow *window) +{ + NemoWindowSlot *slot; + GList *providers; + GList *items; + GList *l; + + providers = nemo_module_get_extensions_for_type (NEMO_TYPE_MENU_PROVIDER); + items = NULL; + + slot = nemo_window_get_active_slot (window); + + for (l = providers; l != NULL; l = l->next) { + NemoMenuProvider *provider; + GList *file_items; + + provider = NEMO_MENU_PROVIDER (l->data); + file_items = nemo_menu_provider_get_background_items (provider, + GTK_WIDGET (window), + slot->viewed_file); + items = g_list_concat (items, file_items); + } + + nemo_module_extension_list_free (providers); + + return items; +} + +static void +add_extension_menu_items (NemoWindow *window, + guint merge_id, + GtkActionGroup *action_group, + GList *menu_items, + const char *subdirectory) +{ + GtkUIManager *ui_manager; + GList *l; + + ui_manager = window->details->ui_manager; + + for (l = menu_items; l; l = l->next) { + NemoMenuItem *item; + NemoMenu *menu; + GtkAction *action; + char *path; + + item = NEMO_MENU_ITEM (l->data); + + g_object_get (item, "menu", &menu, NULL); + + action = nemo_action_from_menu_item (item); + gtk_action_group_add_action_with_accel (action_group, action, NULL); + + path = g_build_path ("/", POPUP_PATH_EXTENSION_ACTIONS, subdirectory, NULL); + gtk_ui_manager_add_ui (ui_manager, + merge_id, + path, + gtk_action_get_name (action), + gtk_action_get_name (action), + (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, + FALSE); + g_free (path); + + path = g_build_path ("/", MENU_PATH_EXTENSION_ACTIONS, subdirectory, NULL); + gtk_ui_manager_add_ui (ui_manager, + merge_id, + path, + gtk_action_get_name (action), + gtk_action_get_name (action), + (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, + FALSE); + g_free (path); + + /* recursively fill the menu */ + if (menu != NULL) { + char *subdir; + GList *children; + + children = nemo_menu_get_items (menu); + + subdir = g_build_path ("/", subdirectory, "/", gtk_action_get_name (action), NULL); + add_extension_menu_items (window, + merge_id, + action_group, + children, + subdir); + + nemo_menu_item_list_free (children); + g_free (subdir); + } + } +} + +void +nemo_window_load_extension_menus (NemoWindow *window) +{ + GtkActionGroup *action_group; + GList *items; + guint merge_id; + + if (window->details->extensions_menu_merge_id != 0) { + gtk_ui_manager_remove_ui (window->details->ui_manager, + window->details->extensions_menu_merge_id); + window->details->extensions_menu_merge_id = 0; + } + + if (window->details->extensions_menu_action_group != NULL) { + gtk_ui_manager_remove_action_group (window->details->ui_manager, + window->details->extensions_menu_action_group); + window->details->extensions_menu_action_group = NULL; + } + + merge_id = gtk_ui_manager_new_merge_id (window->details->ui_manager); + window->details->extensions_menu_merge_id = merge_id; + action_group = gtk_action_group_new ("ExtensionsMenuGroup"); + window->details->extensions_menu_action_group = action_group; + gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); + gtk_ui_manager_insert_action_group (window->details->ui_manager, action_group, 0); + g_object_unref (action_group); /* owned by ui manager */ + + items = get_extension_menus (window); + + if (items != NULL) { + add_extension_menu_items (window, merge_id, action_group, items, ""); + + g_list_foreach (items, (GFunc) g_object_unref, NULL); + g_list_free (items); + } +} From da127d4bf5c2ac57851bbbacbbaa1da4aa8e7551 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 22:31:15 +0100 Subject: [PATCH 3/9] Removed .orig file (left over from patching, accident) --- src/nemo-window-menus.c.orig | 1406 ---------------------------------- 1 file changed, 1406 deletions(-) delete mode 100644 src/nemo-window-menus.c.orig diff --git a/src/nemo-window-menus.c.orig b/src/nemo-window-menus.c.orig deleted file mode 100644 index 826b4aef3..000000000 --- a/src/nemo-window-menus.c.orig +++ /dev/null @@ -1,1406 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nemo - * - * Copyright (C) 2000, 2001 Eazel, Inc. - * - * Nemo is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nemo is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: John Sullivan - */ - -/* nemo-window-menus.h - implementation of nemo window menu operations, - * split into separate file just for convenience. - */ -#include - -#include - -#include "nemo-actions.h" -#include "nemo-application.h" -#include "nemo-connect-server-dialog.h" -#include "nemo-file-management-properties.h" -#include "nemo-navigation-action.h" -#include "nemo-notebook.h" -#include "nemo-window-manage-views.h" -#include "nemo-window-bookmarks.h" -#include "nemo-window-private.h" -#include "nemo-desktop-window.h" -#include "nemo-search-bar.h" -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MENU_PATH_EXTENSION_ACTIONS "/MenuBar/File/Extension Actions" -#define POPUP_PATH_EXTENSION_ACTIONS "/background/Before Zoom Items/Extension Actions" - -#define NETWORK_URI "network:" -#define COMPUTER_URI "computer:" -#define BURN_CD_URI "burn:" - -static void -action_close_window_slot_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - NemoWindowSlot *slot; - - window = NEMO_WINDOW (user_data); - slot = nemo_window_get_active_slot (window); - - nemo_window_pane_slot_close (slot->pane, slot); -} - -static void -action_connect_to_server_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window = NEMO_WINDOW (user_data); - GtkWidget *dialog; - - dialog = nemo_connect_server_dialog_new (window); - - gtk_widget_show (dialog); -} - -static void -action_stop_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - NemoWindowSlot *slot; - - window = NEMO_WINDOW (user_data); - slot = nemo_window_get_active_slot (window); - - nemo_window_slot_stop_loading (slot); -} - -#ifdef TEXT_CHANGE_UNDO -static void -action_undo_callback (GtkAction *action, - gpointer user_data) -{ - NemoApplication *app; - - app = nemo_application_get_singleton (); - nemo_undo_manager_undo (app->undo_manager); -} -#endif - -static void -action_home_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - NemoWindowSlot *slot; - - window = NEMO_WINDOW (user_data); - slot = nemo_window_get_active_slot (window); - - nemo_window_slot_go_home (slot, - nemo_event_should_open_in_new_tab ()); -} - -static void -action_go_to_computer_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - NemoWindowSlot *slot; - GFile *computer; - - window = NEMO_WINDOW (user_data); - slot = nemo_window_get_active_slot (window); - - computer = g_file_new_for_uri (COMPUTER_URI); - nemo_window_slot_go_to (slot, - computer, - nemo_event_should_open_in_new_tab ()); - g_object_unref (computer); -} - -static void -action_go_to_network_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - NemoWindowSlot *slot; - GFile *network; - - window = NEMO_WINDOW (user_data); - slot = nemo_window_get_active_slot (window); - - network = g_file_new_for_uri (NETWORK_URI); - nemo_window_slot_go_to (slot, - network, - nemo_event_should_open_in_new_tab ()); - g_object_unref (network); -} - -static void -action_go_to_templates_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - NemoWindowSlot *slot; - char *path; - GFile *location; - - window = NEMO_WINDOW (user_data); - slot = nemo_window_get_active_slot (window); - - path = nemo_get_templates_directory (); - location = g_file_new_for_path (path); - g_free (path); - nemo_window_slot_go_to (slot, - location, - nemo_event_should_open_in_new_tab ()); - g_object_unref (location); -} - -static void -action_go_to_trash_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - NemoWindowSlot *slot; - GFile *trash; - - window = NEMO_WINDOW (user_data); - slot = nemo_window_get_active_slot (window); - - trash = g_file_new_for_uri ("trash:///"); - nemo_window_slot_go_to (slot, - trash, - nemo_event_should_open_in_new_tab ()); - g_object_unref (trash); -} - -static void -action_reload_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindowSlot *slot; - - slot = nemo_window_get_active_slot (NEMO_WINDOW (user_data)); - nemo_window_slot_reload (slot); -} - -static NemoView * -get_current_view (NemoWindow *window) -{ - NemoWindowSlot *slot; - NemoView *view; - - slot = nemo_window_get_active_slot (window); - view = nemo_window_slot_get_current_view (slot); - - return view; -} - -static void -action_zoom_in_callback (GtkAction *action, - gpointer user_data) -{ - - nemo_view_bump_zoom_level (get_current_view (user_data), 1); -} - -static void -action_zoom_out_callback (GtkAction *action, - gpointer user_data) -{ - nemo_view_bump_zoom_level (get_current_view (user_data), -1); -} - -static void -action_zoom_normal_callback (GtkAction *action, - gpointer user_data) -{ - nemo_view_restore_default_zoom_level (get_current_view (user_data)); -} - -static void -action_show_hidden_files_callback (GtkAction *action, - gpointer callback_data) -{ - NemoWindow *window; - NemoWindowShowHiddenFilesMode mode; - - window = NEMO_WINDOW (callback_data); - - if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) { - mode = NEMO_WINDOW_SHOW_HIDDEN_FILES_ENABLE; - } else { - mode = NEMO_WINDOW_SHOW_HIDDEN_FILES_DISABLE; - } - - nemo_window_set_hidden_files_mode (window, mode); -} - -static void -show_hidden_files_preference_callback (gpointer callback_data) -{ - NemoWindow *window; - GtkAction *action; - - window = NEMO_WINDOW (callback_data); - - if (window->details->show_hidden_files_mode == NEMO_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { - action = gtk_action_group_get_action (nemo_window_get_main_action_group (window), - NEMO_ACTION_SHOW_HIDDEN_FILES); - - /* update button */ - g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), - g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_HIDDEN_FILES)); - g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window); - - /* inform views */ - nemo_window_set_hidden_files_mode (window, NEMO_WINDOW_SHOW_HIDDEN_FILES_DEFAULT); - - } -} - -static void -action_preferences_callback (GtkAction *action, - gpointer user_data) -{ - GtkWindow *window; - - window = GTK_WINDOW (user_data); - - nemo_file_management_properties_dialog_show (window); -} - -static void -action_about_nemo_callback (GtkAction *action, - gpointer user_data) -{ - const gchar *license[] = { - N_("Nemo is free software; you can redistribute it and/or modify " - "it under the terms of the GNU General Public License as published by " - "the Free Software Foundation; either version 2 of the License, or " - "(at your option) any later version."), - N_("Nemo is distributed in the hope that it will be useful, " - "but WITHOUT ANY WARRANTY; without even the implied warranty of " - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " - "GNU General Public License for more details."), - N_("You should have received a copy of the GNU General Public License " - "along with Nemo; if not, write to the Free Software Foundation, Inc., " - "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA") - }; - gchar *license_trans, *copyright_str; - GDateTime *date; - - license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]), - _(license[2]), NULL); - - date = g_date_time_new_now_local (); - - gtk_show_about_dialog (GTK_WINDOW (user_data), - "program-name", _("Nemo"), - "version", VERSION, - "comments", _("Nemo lets you organize " - "files and folders, both on " - "your computer and online."), - "license", license_trans, - "wrap-license", TRUE, - "logo-icon-name", "nemo", - NULL); - - g_free (license_trans); - g_free (copyright_str); - g_date_time_unref (date); -} - -static void -action_up_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window = user_data; - NemoWindowSlot *slot; - - slot = nemo_window_get_active_slot (window); - nemo_window_slot_go_up (slot, FALSE, nemo_event_should_open_in_new_tab ()); -} - -static void -action_nemo_manual_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - GError *error; - GtkWidget *dialog; - const char* helpuri; - const char* name = gtk_action_get_name (action); - - error = NULL; - window = NEMO_WINDOW (user_data); - - if (g_str_equal (name, "NemoHelpSearch")) { - helpuri = "help:gnome-help/files-search"; - } else if (g_str_equal (name,"NemoHelpSort")) { - helpuri = "help:gnome-help/files-sort"; - } else if (g_str_equal (name, "NemoHelpLost")) { - helpuri = "help:gnome-help/files-lost"; - } else if (g_str_equal (name, "NemoHelpShare")) { - helpuri = "help:gnome-help/files-share"; - } else { - helpuri = "help:gnome-help/files"; - } - - if (NEMO_IS_DESKTOP_WINDOW (window)) { - nemo_launch_application_from_command (gtk_window_get_screen (GTK_WINDOW (window)), "gnome-help", FALSE, NULL); - } else { - gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)), - helpuri, - gtk_get_current_event_time (), &error); - } - - if (error) { - dialog = gtk_message_dialog_new (GTK_WINDOW (window), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("There was an error displaying help: \n%s"), - error->message); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (gtk_widget_destroy), - NULL); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - gtk_widget_show (dialog); - g_error_free (error); - } -} - -static void -menu_item_select_cb (GtkMenuItem *proxy, - NemoWindow *window) -{ - GtkAction *action; - char *message; - - action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)); - g_return_if_fail (action != NULL); - - g_object_get (G_OBJECT (action), "tooltip", &message, NULL); - if (message) { - gtk_statusbar_push (GTK_STATUSBAR (window->details->statusbar), - window->details->help_message_cid, message); - g_free (message); - } -} - -static void -menu_item_deselect_cb (GtkMenuItem *proxy, - NemoWindow *window) -{ - gtk_statusbar_pop (GTK_STATUSBAR (window->details->statusbar), - window->details->help_message_cid); -} - -static void -disconnect_proxy_cb (GtkUIManager *manager, - GtkAction *action, - GtkWidget *proxy, - NemoWindow *window) -{ - if (GTK_IS_MENU_ITEM (proxy)) { - g_signal_handlers_disconnect_by_func - (proxy, G_CALLBACK (menu_item_select_cb), window); - g_signal_handlers_disconnect_by_func - (proxy, G_CALLBACK (menu_item_deselect_cb), window); - } -} - -static void -trash_state_changed_cb (NemoTrashMonitor *monitor, - gboolean state, - NemoWindow *window) -{ - GtkActionGroup *action_group; - GtkAction *action; - GIcon *gicon; - - action_group = nemo_window_get_main_action_group (window); - action = gtk_action_group_get_action (action_group, "Go to Trash"); - - gicon = nemo_trash_monitor_get_icon (); - - if (gicon) { - g_object_set (action, "gicon", gicon, NULL); - g_object_unref (gicon); - } -} - -static void -nemo_window_initialize_trash_icon_monitor (NemoWindow *window) -{ - NemoTrashMonitor *monitor; - - monitor = nemo_trash_monitor_get (); - - trash_state_changed_cb (monitor, TRUE, window); - - g_signal_connect (monitor, "trash_state_changed", - G_CALLBACK (trash_state_changed_cb), window); -} - -#define MENU_ITEM_MAX_WIDTH_CHARS 32 - -enum { - SIDEBAR_PLACES, - SIDEBAR_TREE -}; - -static void -action_close_all_windows_callback (GtkAction *action, - gpointer user_data) -{ - nemo_application_close_all_windows (nemo_application_get_singleton ()); -} - -static void -action_back_callback (GtkAction *action, - gpointer user_data) -{ - nemo_window_back_or_forward (NEMO_WINDOW (user_data), - TRUE, 0, nemo_event_should_open_in_new_tab ()); -} - -static void -action_forward_callback (GtkAction *action, - gpointer user_data) -{ - nemo_window_back_or_forward (NEMO_WINDOW (user_data), - FALSE, 0, nemo_event_should_open_in_new_tab ()); -} - -static void -action_split_view_switch_next_pane_callback(GtkAction *action, - gpointer user_data) -{ - nemo_window_pane_grab_focus (nemo_window_get_next_pane (NEMO_WINDOW (user_data))); -} - -static void -action_split_view_same_location_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - NemoWindowPane *next_pane; - GFile *location; - - window = NEMO_WINDOW (user_data); - next_pane = nemo_window_get_next_pane (window); - - if (!next_pane) { - return; - } - location = nemo_window_slot_get_location (next_pane->active_slot); - if (location) { - nemo_window_slot_go_to (nemo_window_get_active_slot (window), location, FALSE); - g_object_unref (location); - } -} - -static void -action_show_hide_sidebar_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - - window = NEMO_WINDOW (user_data); - - if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) { - nemo_window_show_sidebar (window); - } else { - nemo_window_hide_sidebar (window); - } -} - -static void -action_split_view_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - gboolean is_active; - - window = NEMO_WINDOW (user_data); - - is_active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); - if (is_active != nemo_window_split_view_showing (window)) { - NemoWindowSlot *slot; - - if (is_active) { - nemo_window_split_view_on (window); - } else { - nemo_window_split_view_off (window); - } - - slot = nemo_window_get_active_slot (window); - if (slot != NULL) { - nemo_view_update_menus (slot->content_view); - } - } -} - -static void -nemo_window_update_split_view_actions_sensitivity (NemoWindow *window) -{ - GtkActionGroup *action_group; - GtkAction *action; - gboolean have_multiple_panes; - gboolean next_pane_is_in_same_location; - GFile *active_pane_location; - GFile *next_pane_location; - NemoWindowPane *next_pane; - NemoWindowSlot *active_slot; - - active_slot = nemo_window_get_active_slot (window); - action_group = nemo_window_get_main_action_group (window); - - /* collect information */ - have_multiple_panes = nemo_window_split_view_showing (window); - if (active_slot != NULL) { - active_pane_location = nemo_window_slot_get_location (active_slot); - } else { - active_pane_location = NULL; - } - - next_pane = nemo_window_get_next_pane (window); - if (next_pane && next_pane->active_slot) { - next_pane_location = nemo_window_slot_get_location (next_pane->active_slot); - next_pane_is_in_same_location = (active_pane_location && next_pane_location && - g_file_equal (active_pane_location, next_pane_location)); - } else { - next_pane_location = NULL; - next_pane_is_in_same_location = FALSE; - } - - /* switch to next pane */ - action = gtk_action_group_get_action (action_group, "SplitViewNextPane"); - gtk_action_set_sensitive (action, have_multiple_panes); - - /* same location */ - action = gtk_action_group_get_action (action_group, "SplitViewSameLocation"); - gtk_action_set_sensitive (action, have_multiple_panes && !next_pane_is_in_same_location); - - /* clean up */ - g_clear_object (&active_pane_location); - g_clear_object (&next_pane_location); -} - -/* TODO: bind all of this with g_settings_bind and GBinding */ -static guint -sidebar_id_to_value (const gchar *sidebar_id) -{ - guint retval = SIDEBAR_PLACES; - - if (g_strcmp0 (sidebar_id, NEMO_WINDOW_SIDEBAR_TREE) == 0) - retval = SIDEBAR_TREE; - - return retval; -} - -void -nemo_window_update_show_hide_menu_items (NemoWindow *window) -{ - GtkActionGroup *action_group; - GtkAction *action; - guint current_value; - - action_group = nemo_window_get_main_action_group (window); - - action = gtk_action_group_get_action (action_group, - NEMO_ACTION_SHOW_HIDE_EXTRA_PANE); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), - nemo_window_split_view_showing (window)); - nemo_window_update_split_view_actions_sensitivity (window); - - action = gtk_action_group_get_action (action_group, - "Sidebar Places"); - current_value = sidebar_id_to_value (window->details->sidebar_id); - gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), current_value); -} - -static void -action_add_bookmark_callback (GtkAction *action, - gpointer user_data) -{ - nemo_window_add_bookmark_for_current_location (NEMO_WINDOW (user_data)); -} - -static void -action_edit_bookmarks_callback (GtkAction *action, - gpointer user_data) -{ - nemo_window_edit_bookmarks (NEMO_WINDOW (user_data)); -} - -static void -connect_proxy_cb (GtkActionGroup *action_group, - GtkAction *action, - GtkWidget *proxy, - NemoWindow *window) -{ - GtkLabel *label; - - if (!GTK_IS_MENU_ITEM (proxy)) - return; - - label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy))); - - gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END); - gtk_label_set_max_width_chars (label, MENU_ITEM_MAX_WIDTH_CHARS); - - g_signal_connect (proxy, "select", - G_CALLBACK (menu_item_select_cb), window); - g_signal_connect (proxy, "deselect", - G_CALLBACK (menu_item_deselect_cb), window); -} - -static const char* icon_entries[] = { - "/MenuBar/Other Menus/Go/Home", - "/MenuBar/Other Menus/Go/Computer", - "/MenuBar/Other Menus/Go/Go to Templates", - "/MenuBar/Other Menus/Go/Go to Trash", - "/MenuBar/Other Menus/Go/Go to Network", - "/MenuBar/Other Menus/Go/Go to Location" -}; - -/** - * refresh_go_menu: - * - * Refresh list of bookmarks at end of Go menu to match centralized history list. - * @window: The NemoWindow whose Go menu will be refreshed. - **/ -static void -nemo_window_initialize_go_menu (NemoWindow *window) -{ - GtkUIManager *ui_manager; - GtkWidget *menuitem; - int i; - - ui_manager = nemo_window_get_ui_manager (NEMO_WINDOW (window)); - - for (i = 0; i < G_N_ELEMENTS (icon_entries); i++) { - menuitem = gtk_ui_manager_get_widget ( - ui_manager, - icon_entries[i]); - - gtk_image_menu_item_set_always_show_image ( - GTK_IMAGE_MENU_ITEM (menuitem), TRUE); - } -} - -static void -action_new_window_callback (GtkAction *action, - gpointer user_data) -{ - NemoApplication *application; - NemoWindow *current_window, *new_window; - - current_window = NEMO_WINDOW (user_data); - application = nemo_application_get_singleton (); - - new_window = nemo_application_create_window ( - application, - gtk_window_get_screen (GTK_WINDOW (current_window))); - nemo_window_slot_go_home (nemo_window_get_active_slot (new_window), FALSE); -} - -static void -action_new_tab_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window; - - window = NEMO_WINDOW (user_data); - nemo_window_new_tab (window); -} - -static void -action_go_to_location_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindow *window = user_data; - NemoWindowPane *pane; - - pane = nemo_window_get_active_pane (window); - nemo_window_pane_ensure_location_bar (pane); -} - -static void -action_tabs_previous_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindowPane *pane; - NemoWindow *window = user_data; - - pane = nemo_window_get_active_pane (window); - nemo_notebook_set_current_page_relative (NEMO_NOTEBOOK (pane->notebook), -1); -} - -static void -action_tabs_next_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindowPane *pane; - NemoWindow *window = user_data; - - pane = nemo_window_get_active_pane (window); - nemo_notebook_set_current_page_relative (NEMO_NOTEBOOK (pane->notebook), 1); -} - -static void -action_tabs_move_left_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindowPane *pane; - NemoWindow *window = user_data; - - pane = nemo_window_get_active_pane (window); - nemo_notebook_reorder_current_child_relative (NEMO_NOTEBOOK (pane->notebook), -1); -} - -static void -action_tabs_move_right_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindowPane *pane; - NemoWindow *window = user_data; - - pane = nemo_window_get_active_pane (window); - nemo_notebook_reorder_current_child_relative (NEMO_NOTEBOOK (pane->notebook), 1); -} - -static void -action_tab_change_action_activate_callback (GtkAction *action, - gpointer user_data) -{ - NemoWindowPane *pane; - NemoWindow *window = user_data; - GtkNotebook *notebook; - int num; - - pane = nemo_window_get_active_pane (window); - notebook = GTK_NOTEBOOK (pane->notebook); - - num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action), "num")); - if (num < gtk_notebook_get_n_pages (notebook)) { - gtk_notebook_set_current_page (notebook, num); - } -} - -static void -sidebar_radio_entry_changed_cb (GtkAction *action, - GtkRadioAction *current, - gpointer user_data) -{ - gint current_value; - - current_value = gtk_radio_action_get_current_value (current); - - if (current_value == SIDEBAR_PLACES) { - g_settings_set_string (nemo_window_state, - NEMO_WINDOW_STATE_SIDE_PANE_VIEW, - NEMO_WINDOW_SIDEBAR_PLACES); - } else if (current_value == SIDEBAR_TREE) { - g_settings_set_string (nemo_window_state, - NEMO_WINDOW_STATE_SIDE_PANE_VIEW, - NEMO_WINDOW_SIDEBAR_TREE); - } -} - -static const GtkActionEntry main_entries[] = { - /* name, stock id, label */ { "File", NULL, N_("_File") }, - /* name, stock id, label */ { "Edit", NULL, N_("_Edit") }, - /* name, stock id, label */ { "View", NULL, N_("_View") }, - /* name, stock id, label */ { "Help", NULL, N_("_Help") }, - /* name, stock id */ { "Close", GTK_STOCK_CLOSE, - /* label, accelerator */ N_("_Close"), "W", - /* tooltip */ N_("Close this folder"), - G_CALLBACK (action_close_window_slot_callback) }, - { "Preferences", GTK_STOCK_PREFERENCES, - N_("Prefere_nces"), - NULL, N_("Edit Nemo preferences"), - G_CALLBACK (action_preferences_callback) }, -#ifdef TEXT_CHANGE_UNDO - /* name, stock id, label */ { "Undo", NULL, N_("_Undo"), - "Z", N_("Undo the last text change"), - G_CALLBACK (action_undo_callback) }, -#endif - /* name, stock id, label */ { "Up", GTK_STOCK_GO_UP, N_("Open _Parent"), - "Up", N_("Open the parent folder"), - G_CALLBACK (action_up_callback) }, - /* name, stock id, label */ { "UpAccel", NULL, "UpAccel", - "", NULL, - G_CALLBACK (action_up_callback) }, - /* name, stock id */ { "Stop", GTK_STOCK_STOP, - /* label, accelerator */ N_("_Stop"), NULL, - /* tooltip */ N_("Stop loading the current location"), - G_CALLBACK (action_stop_callback) }, - /* name, stock id */ { "Reload", GTK_STOCK_REFRESH, - /* label, accelerator */ N_("_Reload"), "R", - /* tooltip */ N_("Reload the current location"), - G_CALLBACK (action_reload_callback) }, - /* name, stock id */ { "NemoHelp", GTK_STOCK_HELP, - /* label, accelerator */ N_("_All Topics"), "F1", - /* tooltip */ N_("Display Nemo help"), - G_CALLBACK (action_nemo_manual_callback) }, - /* name, stock id */ { "NemoHelpSearch", NULL, - /* label, accelerator */ N_("Search for files"), NULL, - /* tooltip */ N_("Locate files based on file name and type. Save your searches for later use."), - G_CALLBACK (action_nemo_manual_callback) }, - /* name, stock id */ { "NemoHelpSort", NULL, - /* label, accelerator */ N_("Sort files and folders"), NULL, - /* tooltip */ N_("Arrange files by name, size, type, or when they were changed."), - G_CALLBACK (action_nemo_manual_callback) }, - /* name, stock id */ { "NemoHelpLost", NULL, - /* label, accelerator */ N_("Find a lost file"), NULL, - /* tooltip */ N_("Follow these tips if you can't find a file you created or downloaded."), - G_CALLBACK (action_nemo_manual_callback) }, - /* name, stock id */ { "NemoHelpShare", NULL, - /* label, accelerator */ N_("Share and transfer files"), NULL, - /* tooltip */ N_("Easily transfer files to your contacts and devices from the file manager."), - G_CALLBACK (action_nemo_manual_callback) }, - /* name, stock id */ { "About Nemo", GTK_STOCK_ABOUT, - /* label, accelerator */ N_("_About"), NULL, - /* tooltip */ N_("Display credits for the creators of Nemo"), - G_CALLBACK (action_about_nemo_callback) }, - /* name, stock id */ { "Zoom In", GTK_STOCK_ZOOM_IN, - /* label, accelerator */ N_("Zoom _In"), "plus", - /* tooltip */ N_("Increase the view size"), - G_CALLBACK (action_zoom_in_callback) }, - /* name, stock id */ { "ZoomInAccel", NULL, - /* label, accelerator */ "ZoomInAccel", "equal", - /* tooltip */ NULL, - G_CALLBACK (action_zoom_in_callback) }, - /* name, stock id */ { "ZoomInAccel2", NULL, - /* label, accelerator */ "ZoomInAccel2", "KP_Add", - /* tooltip */ NULL, - G_CALLBACK (action_zoom_in_callback) }, - /* name, stock id */ { "Zoom Out", GTK_STOCK_ZOOM_OUT, - /* label, accelerator */ N_("Zoom _Out"), "minus", - /* tooltip */ N_("Decrease the view size"), - G_CALLBACK (action_zoom_out_callback) }, - /* name, stock id */ { "ZoomOutAccel", NULL, - /* label, accelerator */ "ZoomOutAccel", "KP_Subtract", - /* tooltip */ NULL, - G_CALLBACK (action_zoom_out_callback) }, - /* name, stock id */ { "Zoom Normal", GTK_STOCK_ZOOM_100, - /* label, accelerator */ N_("Normal Si_ze"), "0", - /* tooltip */ N_("Use the normal view size"), - G_CALLBACK (action_zoom_normal_callback) }, - /* name, stock id */ { "Connect to Server", NULL, - /* label, accelerator */ N_("Connect to _Server..."), NULL, - /* tooltip */ N_("Connect to a remote computer or shared disk"), - G_CALLBACK (action_connect_to_server_callback) }, - /* name, stock id */ { "Home", NEMO_ICON_HOME, - /* label, accelerator */ N_("_Home"), "Home", - /* tooltip */ N_("Open your personal folder"), - G_CALLBACK (action_home_callback) }, - /* name, stock id */ { "Go to Computer", NEMO_ICON_COMPUTER, - /* label, accelerator */ N_("_Computer"), NULL, - /* tooltip */ N_("Browse all local and remote disks and folders accessible from this computer"), - G_CALLBACK (action_go_to_computer_callback) }, - /* name, stock id */ { "Go to Network", NEMO_ICON_NETWORK, - /* label, accelerator */ N_("_Network"), NULL, - /* tooltip */ N_("Browse bookmarked and local network locations"), - G_CALLBACK (action_go_to_network_callback) }, - /* name, stock id */ { "Go to Templates", NEMO_ICON_TEMPLATE, - /* label, accelerator */ N_("T_emplates"), NULL, - /* tooltip */ N_("Open your personal templates folder"), - G_CALLBACK (action_go_to_templates_callback) }, - /* name, stock id */ { "Go to Trash", NEMO_ICON_TRASH, - /* label, accelerator */ N_("_Trash"), NULL, - /* tooltip */ N_("Open your personal trash folder"), - G_CALLBACK (action_go_to_trash_callback) }, - /* name, stock id, label */ { "Go", NULL, N_("_Go") }, - /* name, stock id, label */ { "Bookmarks", NULL, N_("_Bookmarks") }, - /* name, stock id, label */ { "Tabs", NULL, N_("_Tabs") }, - /* name, stock id, label */ { "New Window", "window-new", N_("New _Window"), - "N", N_("Open another Nemo window for the displayed location"), - G_CALLBACK (action_new_window_callback) }, - /* name, stock id, label */ { "New Tab", "tab-new", N_("New _Tab"), - "T", N_("Open another tab for the displayed location"), - G_CALLBACK (action_new_tab_callback) }, - /* name, stock id, label */ { "Close All Windows", NULL, N_("Close _All Windows"), - "Q", N_("Close all Navigation windows"), - G_CALLBACK (action_close_all_windows_callback) }, - /* name, stock id, label */ { NEMO_ACTION_BACK, GTK_STOCK_GO_BACK, N_("_Back"), - "Left", N_("Go to the previous visited location"), - G_CALLBACK (action_back_callback) }, - /* name, stock id, label */ { NEMO_ACTION_FORWARD, GTK_STOCK_GO_FORWARD, N_("_Forward"), - "Right", N_("Go to the next visited location"), - G_CALLBACK (action_forward_callback) }, - /* name, stock id, label */ { "Go to Location", NULL, N_("_Location..."), - "L", N_("Specify a location to open"), - G_CALLBACK (action_go_to_location_callback) }, - /* name, stock id, label */ { "SplitViewNextPane", NULL, N_("S_witch to Other Pane"), - "F6", N_("Move focus to the other pane in a split view window"), - G_CALLBACK (action_split_view_switch_next_pane_callback) }, - /* name, stock id, label */ { "SplitViewSameLocation", NULL, N_("Sa_me Location as Other Pane"), - NULL, N_("Go to the same location as in the extra pane"), - G_CALLBACK (action_split_view_same_location_callback) }, - /* name, stock id, label */ { "Add Bookmark", GTK_STOCK_ADD, N_("_Add Bookmark"), - "d", N_("Add a bookmark for the current location to this menu"), - G_CALLBACK (action_add_bookmark_callback) }, - /* name, stock id, label */ { "Edit Bookmarks", NULL, N_("_Edit Bookmarks..."), - "b", N_("Display a window that allows editing the bookmarks in this menu"), - G_CALLBACK (action_edit_bookmarks_callback) }, - { "TabsPrevious", NULL, N_("_Previous Tab"), "Page_Up", - N_("Activate previous tab"), - G_CALLBACK (action_tabs_previous_callback) }, - { "TabsNext", NULL, N_("_Next Tab"), "Page_Down", - N_("Activate next tab"), - G_CALLBACK (action_tabs_next_callback) }, - { "TabsMoveLeft", NULL, N_("Move Tab _Left"), "Page_Up", - N_("Move current tab to left"), - G_CALLBACK (action_tabs_move_left_callback) }, - { "TabsMoveRight", NULL, N_("Move Tab _Right"), "Page_Down", - N_("Move current tab to right"), - G_CALLBACK (action_tabs_move_right_callback) }, - { "Sidebar List", NULL, N_("Sidebar") } -}; - -static const GtkToggleActionEntry main_toggle_entries[] = { - /* name, stock id */ { "Show Hidden Files", NULL, - /* label, accelerator */ N_("Show _Hidden Files"), "H", - /* tooltip */ N_("Toggle the display of hidden files in the current window"), - G_CALLBACK (action_show_hidden_files_callback), - TRUE }, - /* name, stock id */ { "Show Hide Toolbar", NULL, - /* label, accelerator */ N_("_Main Toolbar"), NULL, - /* tooltip */ N_("Change the visibility of this window's main toolbar"), - NULL, - /* is_active */ TRUE }, - /* name, stock id */ { "Show Hide Sidebar", NULL, - /* label, accelerator */ N_("_Show Sidebar"), "F9", - /* tooltip */ N_("Change the visibility of this window's side pane"), - G_CALLBACK (action_show_hide_sidebar_callback), - /* is_active */ TRUE }, - /* name, stock id */ { "Show Hide Statusbar", NULL, - /* label, accelerator */ N_("St_atusbar"), NULL, - /* tooltip */ N_("Change the visibility of this window's statusbar"), - NULL, - /* is_active */ TRUE }, - /* name, stock id */ { "Search", "edit-find-symbolic", - /* label, accelerator */ N_("_Search for Files..."), "f", - /* tooltip */ N_("Search documents and folders by name"), - NULL, - /* is_active */ FALSE }, - /* name, stock id */ { NEMO_ACTION_SHOW_HIDE_EXTRA_PANE, NULL, - /* label, accelerator */ N_("E_xtra Pane"), "F3", - /* tooltip */ N_("Open an extra folder view side-by-side"), - G_CALLBACK (action_split_view_callback), - /* is_active */ FALSE }, - /* name, stock id */ { "Show Hide Location Entry", NULL, - /* label, accelerator */ N_("Loca_tion entry"), "l", - /* tooltip */ N_("Change the visibility of this window's location entry"), - NULL, - /* is_active */ TRUE }, -}; - -static const GtkRadioActionEntry main_radio_entries[] = { - { "Sidebar Places", NULL, - N_("Places"), NULL, N_("Select Places as the default sidebar"), - SIDEBAR_PLACES }, - { "Sidebar Tree", NULL, - N_("Tree"), NULL, N_("Select Tree as the default sidebar"), - SIDEBAR_TREE } -}; - -GtkActionGroup * -nemo_window_create_toolbar_action_group (NemoWindow *window) -{ - NemoNavigationState *navigation_state; - GtkActionGroup *action_group; - GtkAction *action; - - action_group = gtk_action_group_new ("ToolbarActions"); - gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); - - action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, - "name", NEMO_ACTION_BACK, - "label", _("_Back"), - "stock_id", GTK_STOCK_GO_BACK, - "tooltip", _("Go to the previous visited location"), - "arrow-tooltip", _("Back history"), - "window", window, - "direction", NEMO_NAVIGATION_DIRECTION_BACK, - "sensitive", FALSE, - NULL); - g_signal_connect (action, "activate", - G_CALLBACK (action_back_callback), window); - gtk_action_group_add_action (action_group, action); - - g_object_unref (action); - - action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, - "name", NEMO_ACTION_FORWARD, - "label", _("_Forward"), - "stock_id", GTK_STOCK_GO_FORWARD, - "tooltip", _("Go to the next visited location"), - "arrow-tooltip", _("Forward history"), - "window", window, - "direction", NEMO_NAVIGATION_DIRECTION_FORWARD, - "sensitive", FALSE, - NULL); - g_signal_connect (action, "activate", - G_CALLBACK (action_forward_callback), window); - gtk_action_group_add_action (action_group, action); - - g_object_unref (action); - - action = GTK_ACTION - (gtk_toggle_action_new (NEMO_ACTION_SEARCH, - _("Search"), - _("Search documents and folders by name"), - NULL)); - gtk_action_group_add_action (action_group, action); - gtk_action_set_icon_name (GTK_ACTION (action), "edit-find-symbolic"); - gtk_action_set_is_important (GTK_ACTION (action), TRUE); - - g_object_unref (action); - - navigation_state = nemo_window_get_navigation_state (window); - nemo_navigation_state_add_group (navigation_state, action_group); - - return action_group; -} - -static void -window_menus_set_bindings (NemoWindow *window) -{ - GtkActionGroup *action_group; - GtkAction *action; - - action_group = nemo_window_get_main_action_group (window); - - action = gtk_action_group_get_action (action_group, - NEMO_ACTION_SHOW_HIDE_TOOLBAR); - - g_settings_bind (nemo_window_state, - NEMO_WINDOW_STATE_START_WITH_TOOLBAR, - action, - "active", - G_SETTINGS_BIND_DEFAULT); - - action = gtk_action_group_get_action (action_group, - NEMO_ACTION_SHOW_HIDE_STATUSBAR); - - g_settings_bind (nemo_window_state, - NEMO_WINDOW_STATE_START_WITH_STATUS_BAR, - action, - "active", - G_SETTINGS_BIND_DEFAULT); - - action = gtk_action_group_get_action (action_group, - NEMO_ACTION_SHOW_HIDE_SIDEBAR); - - g_settings_bind (nemo_window_state, - NEMO_WINDOW_STATE_START_WITH_SIDEBAR, - action, - "active", - G_SETTINGS_BIND_DEFAULT); - - action = gtk_action_group_get_action (action_group, - NEMO_ACTION_SHOW_HIDE_LOCATION_ENTRY); - - g_settings_bind (nemo_preferences, - NEMO_PREFERENCES_SHOW_LOCATION_ENTRY, - action, - "active", - G_SETTINGS_BIND_DEFAULT); -} - -void -nemo_window_initialize_actions (NemoWindow *window) -{ - GtkActionGroup *action_group; - const gchar *nav_state_actions[] = { - NEMO_ACTION_BACK, NEMO_ACTION_FORWARD, - NEMO_ACTION_SEARCH, NULL - }; - - action_group = nemo_window_get_main_action_group (window); - window->details->nav_state = nemo_navigation_state_new (action_group, - nav_state_actions); - - window_menus_set_bindings (window); - nemo_window_update_show_hide_menu_items (window); - - g_signal_connect (window, "loading_uri", - G_CALLBACK (nemo_window_update_split_view_actions_sensitivity), - NULL); -} - -/** - * nemo_window_initialize_menus - * - * Create and install the set of menus for this window. - * @window: A recently-created NemoWindow. - */ -void -nemo_window_initialize_menus (NemoWindow *window) -{ - GtkActionGroup *action_group; - GtkUIManager *ui_manager; - GtkAction *action; - gint i; - - window->details->ui_manager = gtk_ui_manager_new (); - ui_manager = window->details->ui_manager; - - /* shell actions */ - action_group = gtk_action_group_new ("ShellActions"); - gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); - window->details->main_action_group = action_group; - gtk_action_group_add_actions (action_group, - main_entries, G_N_ELEMENTS (main_entries), - window); - gtk_action_group_add_toggle_actions (action_group, - main_toggle_entries, G_N_ELEMENTS (main_toggle_entries), - window); - gtk_action_group_add_radio_actions (action_group, - main_radio_entries, G_N_ELEMENTS (main_radio_entries), - 0, G_CALLBACK (sidebar_radio_entry_changed_cb), - window); - - action = gtk_action_group_get_action (action_group, NEMO_ACTION_UP); - g_object_set (action, "short_label", _("_Up"), NULL); - - action = gtk_action_group_get_action (action_group, NEMO_ACTION_HOME); - g_object_set (action, "short_label", _("_Home"), NULL); - - action = gtk_action_group_get_action (action_group, NEMO_ACTION_SHOW_HIDDEN_FILES); - g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), - g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_HIDDEN_FILES)); - g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window); - - - g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_HIDDEN_FILES, - G_CALLBACK(show_hidden_files_preference_callback), - window); - - /* Alt+N for the first 10 tabs */ - for (i = 0; i < 10; ++i) { - gchar action_name[80]; - gchar accelerator[80]; - - snprintf(action_name, sizeof (action_name), "Tab%d", i); - action = gtk_action_new (action_name, NULL, NULL, NULL); - g_object_set_data (G_OBJECT (action), "num", GINT_TO_POINTER (i)); - g_signal_connect (action, "activate", - G_CALLBACK (action_tab_change_action_activate_callback), window); - snprintf(accelerator, sizeof (accelerator), "%d", (i+1)%10); - gtk_action_group_add_action_with_accel (action_group, action, accelerator); - g_object_unref (action); - gtk_ui_manager_add_ui (ui_manager, - gtk_ui_manager_new_merge_id (ui_manager), - "/", - action_name, - action_name, - GTK_UI_MANAGER_ACCELERATOR, - FALSE); - - } - - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - g_object_unref (action_group); /* owned by ui_manager */ - - gtk_window_add_accel_group (GTK_WINDOW (window), - gtk_ui_manager_get_accel_group (ui_manager)); - - g_signal_connect (ui_manager, "connect_proxy", - G_CALLBACK (connect_proxy_cb), window); - g_signal_connect (ui_manager, "disconnect_proxy", - G_CALLBACK (disconnect_proxy_cb), window); - - /* add the UI */ - gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nemo/nemo-shell-ui.xml", NULL); - - nemo_window_initialize_trash_icon_monitor (window); - nemo_window_initialize_go_menu (window); -} - -void -nemo_window_finalize_menus (NemoWindow *window) -{ - NemoTrashMonitor *monitor; - - monitor = nemo_trash_monitor_get (); - - g_signal_handlers_disconnect_by_func (monitor, - trash_state_changed_cb, window); - - g_signal_handlers_disconnect_by_func (nemo_preferences, - show_hidden_files_preference_callback, window); -} - -static GList * -get_extension_menus (NemoWindow *window) -{ - NemoWindowSlot *slot; - GList *providers; - GList *items; - GList *l; - - providers = nemo_module_get_extensions_for_type (NEMO_TYPE_MENU_PROVIDER); - items = NULL; - - slot = nemo_window_get_active_slot (window); - - for (l = providers; l != NULL; l = l->next) { - NemoMenuProvider *provider; - GList *file_items; - - provider = NEMO_MENU_PROVIDER (l->data); - file_items = nemo_menu_provider_get_background_items (provider, - GTK_WIDGET (window), - slot->viewed_file); - items = g_list_concat (items, file_items); - } - - nemo_module_extension_list_free (providers); - - return items; -} - -static void -add_extension_menu_items (NemoWindow *window, - guint merge_id, - GtkActionGroup *action_group, - GList *menu_items, - const char *subdirectory) -{ - GtkUIManager *ui_manager; - GList *l; - - ui_manager = window->details->ui_manager; - - for (l = menu_items; l; l = l->next) { - NemoMenuItem *item; - NemoMenu *menu; - GtkAction *action; - char *path; - - item = NEMO_MENU_ITEM (l->data); - - g_object_get (item, "menu", &menu, NULL); - - action = nemo_action_from_menu_item (item); - gtk_action_group_add_action_with_accel (action_group, action, NULL); - - path = g_build_path ("/", POPUP_PATH_EXTENSION_ACTIONS, subdirectory, NULL); - gtk_ui_manager_add_ui (ui_manager, - merge_id, - path, - gtk_action_get_name (action), - gtk_action_get_name (action), - (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, - FALSE); - g_free (path); - - path = g_build_path ("/", MENU_PATH_EXTENSION_ACTIONS, subdirectory, NULL); - gtk_ui_manager_add_ui (ui_manager, - merge_id, - path, - gtk_action_get_name (action), - gtk_action_get_name (action), - (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, - FALSE); - g_free (path); - - /* recursively fill the menu */ - if (menu != NULL) { - char *subdir; - GList *children; - - children = nemo_menu_get_items (menu); - - subdir = g_build_path ("/", subdirectory, "/", gtk_action_get_name (action), NULL); - add_extension_menu_items (window, - merge_id, - action_group, - children, - subdir); - - nemo_menu_item_list_free (children); - g_free (subdir); - } - } -} - -void -nemo_window_load_extension_menus (NemoWindow *window) -{ - GtkActionGroup *action_group; - GList *items; - guint merge_id; - - if (window->details->extensions_menu_merge_id != 0) { - gtk_ui_manager_remove_ui (window->details->ui_manager, - window->details->extensions_menu_merge_id); - window->details->extensions_menu_merge_id = 0; - } - - if (window->details->extensions_menu_action_group != NULL) { - gtk_ui_manager_remove_action_group (window->details->ui_manager, - window->details->extensions_menu_action_group); - window->details->extensions_menu_action_group = NULL; - } - - merge_id = gtk_ui_manager_new_merge_id (window->details->ui_manager); - window->details->extensions_menu_merge_id = merge_id; - action_group = gtk_action_group_new ("ExtensionsMenuGroup"); - window->details->extensions_menu_action_group = action_group; - gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); - gtk_ui_manager_insert_action_group (window->details->ui_manager, action_group, 0); - g_object_unref (action_group); /* owned by ui manager */ - - items = get_extension_menus (window); - - if (items != NULL) { - add_extension_menu_items (window, merge_id, action_group, items, ""); - - g_list_foreach (items, (GFunc) g_object_unref, NULL); - g_list_free (items); - } -} From 992b0f335e8df3ef83b359c7922b8f2cc472f440 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 22:37:54 +0100 Subject: [PATCH 4/9] Add support for all XDG user directory icons in the pathbar, fix icon for hard drive --- libnemo-private/nemo-icon-names.h | 2 +- src/nemo-pathbar.c | 67 ++++++++++++++++++++++++++++++- src/nemo-pathbar.h | 9 +++++ 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/libnemo-private/nemo-icon-names.h b/libnemo-private/nemo-icon-names.h index b5dfdbede..ab34861a4 100644 --- a/libnemo-private/nemo-icon-names.h +++ b/libnemo-private/nemo-icon-names.h @@ -4,7 +4,7 @@ /* Icons for places */ #define NEMO_ICON_COMPUTER "computer" #define NEMO_ICON_DESKTOP "user-desktop" -#define NEMO_ICON_FILESYSTEM "drive-harddisk-system" +#define NEMO_ICON_FILESYSTEM "drive-harddisk" #define NEMO_ICON_FOLDER "folder" #define NEMO_ICON_FOLDER_REMOTE "folder-remote" #define NEMO_ICON_HOME "user-home" diff --git a/src/nemo-pathbar.c b/src/nemo-pathbar.c index a5a19a24c..a1758ca12 100644 --- a/src/nemo-pathbar.c +++ b/src/nemo-pathbar.c @@ -51,6 +51,7 @@ typedef enum { HOME_BUTTON, DESKTOP_BUTTON, MOUNT_BUTTON, + XDG_BUTTON, DEFAULT_LOCATION_BUTTON, } ButtonType; @@ -79,6 +80,8 @@ struct _ButtonData /* custom icon */ GdkPixbuf *custom_icon; + char *xdg_icon; + /* flag to indicate its the base folder in the URI */ gboolean is_base_dir; @@ -92,6 +95,7 @@ struct _ButtonData G_DEFINE_TYPE (NemoPathBar, nemo_path_bar, GTK_TYPE_CONTAINER); +static GFile* get_xdg_dir (GUserDirectory dir); static void nemo_path_bar_scroll_up (NemoPathBar *path_bar); static void nemo_path_bar_scroll_down (NemoPathBar *path_bar); static void nemo_path_bar_stop_scrolling (NemoPathBar *path_bar); @@ -256,6 +260,25 @@ nemo_path_bar_slider_drag_leave (GtkWidget *widget, } } +/** + * Utility function. Return a GFile for the "special directory" if it exists, or NULL + * Ripped from nemo-file.c (nemo_file_is_user_special_directory) and slightly modified + */ +static GFile* +get_xdg_dir (GUserDirectory dir) { + + const gchar *special_dir; + + special_dir = g_get_user_special_dir (dir); + + if (special_dir) { + return g_file_new_for_path (special_dir); + } else { + return NULL; + } + +} + static void nemo_path_bar_init (NemoPathBar *path_bar) { @@ -274,6 +297,14 @@ nemo_path_bar_init (NemoPathBar *path_bar) g_free (p); path_bar->home_path = g_file_new_for_path (g_get_home_dir ()); path_bar->root_path = g_file_new_for_path ("/"); + path_bar->xdg_documents_path = get_xdg_dir (G_USER_DIRECTORY_DOCUMENTS); + path_bar->xdg_download_path = get_xdg_dir (G_USER_DIRECTORY_DOWNLOAD); + path_bar->xdg_music_path = get_xdg_dir (G_USER_DIRECTORY_MUSIC); + path_bar->xdg_pictures_path = get_xdg_dir (G_USER_DIRECTORY_PICTURES); + path_bar->xdg_public_path = get_xdg_dir (G_USER_DIRECTORY_PUBLIC_SHARE); + path_bar->xdg_templates_path = get_xdg_dir (G_USER_DIRECTORY_TEMPLATES); + path_bar->xdg_videos_path = get_xdg_dir (G_USER_DIRECTORY_VIDEOS); + desktop_is_home = g_file_equal (path_bar->home_path, path_bar->desktop_path); g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_DESKTOP_IS_HOME_DIR, @@ -336,6 +367,13 @@ nemo_path_bar_finalize (GObject *object) g_clear_object (&path_bar->root_path); g_clear_object (&path_bar->home_path); g_clear_object (&path_bar->desktop_path); + g_clear_object (&path_bar->xdg_documents_path); + g_clear_object (&path_bar->xdg_download_path); + g_clear_object (&path_bar->xdg_music_path); + g_clear_object (&path_bar->xdg_pictures_path); + g_clear_object (&path_bar->xdg_public_path); + g_clear_object (&path_bar->xdg_templates_path); + g_clear_object (&path_bar->xdg_videos_path); g_signal_handlers_disconnect_by_func (nemo_trash_monitor_get (), trash_state_changed_cb, path_bar); @@ -1231,14 +1269,15 @@ get_type_icon_info (ButtonData *button_data) case DESKTOP_BUTTON: return nemo_icon_info_lookup_from_name (NEMO_ICON_DESKTOP, NEMO_PATH_BAR_ICON_SIZE); - + case XDG_BUTTON: + return nemo_icon_info_lookup_from_name (button_data->xdg_icon, + NEMO_PATH_BAR_ICON_SIZE); case NORMAL_BUTTON: if (button_data->is_base_dir) { return nemo_file_get_icon (button_data->file, NEMO_PATH_BAR_ICON_SIZE, NEMO_FILE_ICON_FLAGS_NONE); } - default: return NULL; } @@ -1254,6 +1293,9 @@ button_data_free (ButtonData *button_data) if (button_data->custom_icon) { g_object_unref (button_data->custom_icon); } + if (button_data->type == XDG_BUTTON) { + g_free (button_data->xdg_icon); + } if (button_data->file != NULL) { g_signal_handler_disconnect (button_data->file, button_data->file_changed_signal_id); @@ -1465,6 +1507,27 @@ setup_button_type (ButtonData *button_data, } else { button_data->type = NORMAL_BUTTON; } + } else if (path_bar->xdg_documents_path != NULL && g_file_equal (location, path_bar->xdg_documents_path)) { + button_data->type = XDG_BUTTON; + button_data->xdg_icon = g_strdup (NEMO_ICON_FOLDER_DOCUMENTS); + } else if (path_bar->xdg_download_path != NULL && g_file_equal (location, path_bar->xdg_download_path)) { + button_data->type = XDG_BUTTON; + button_data->xdg_icon = g_strdup (NEMO_ICON_FOLDER_DOWNLOAD); + } else if (path_bar->xdg_music_path != NULL && g_file_equal (location, path_bar->xdg_music_path)) { + button_data->type = XDG_BUTTON; + button_data->xdg_icon = g_strdup (NEMO_ICON_FOLDER_MUSIC); + } else if (path_bar->xdg_pictures_path != NULL && g_file_equal (location, path_bar->xdg_pictures_path)) { + button_data->type = XDG_BUTTON; + button_data->xdg_icon = g_strdup (NEMO_ICON_FOLDER_PICTURES); + } else if (path_bar->xdg_templates_path != NULL && g_file_equal (location, path_bar->xdg_templates_path)) { + button_data->type = XDG_BUTTON; + button_data->xdg_icon = g_strdup (NEMO_ICON_FOLDER_TEMPLATES); + } else if (path_bar->xdg_videos_path != NULL && g_file_equal (location, path_bar->xdg_videos_path)) { + button_data->type = XDG_BUTTON; + button_data->xdg_icon = g_strdup (NEMO_ICON_FOLDER_VIDEOS); + } else if (path_bar->xdg_public_path != NULL && g_file_equal (location, path_bar->xdg_public_path)) { + button_data->type = XDG_BUTTON; + button_data->xdg_icon = g_strdup (NEMO_ICON_FOLDER_PUBLIC_SHARE); } else if (setup_file_path_mounted_mount (location, button_data)) { /* already setup */ } else { diff --git a/src/nemo-pathbar.h b/src/nemo-pathbar.h index c9e055b03..de32c8269 100644 --- a/src/nemo-pathbar.h +++ b/src/nemo-pathbar.h @@ -45,6 +45,15 @@ struct _NemoPathBar GFile *home_path; GFile *desktop_path; + /** XDG Dirs */ + GFile *xdg_documents_path; + GFile *xdg_download_path; + GFile *xdg_music_path; + GFile *xdg_pictures_path; + GFile *xdg_public_path; + GFile *xdg_templates_path; + GFile *xdg_videos_path; + GFile *current_path; gpointer current_button_data; From a64853f03d16ccab583c0510e99ac3dc73e51ebb Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 22:46:10 +0100 Subject: [PATCH 5/9] Allow Nemo to use gnome-desktop-item-edit for "Create Launcher" --- src/nemo-actions.h | 2 ++ src/nemo-desktop-icon-view-ui.xml | 1 + src/nemo-desktop-icon-view.c | 31 +++++++++++++++++++++++++++++++ src/nemo-directory-view-ui.xml | 1 + src/nemo-view.c | 27 +++++++++++++++++++++++++++ 5 files changed, 62 insertions(+) diff --git a/src/nemo-actions.h b/src/nemo-actions.h index e9deec4d7..d3ec21270 100644 --- a/src/nemo-actions.h +++ b/src/nemo-actions.h @@ -115,6 +115,8 @@ #define NEMO_ACTION_LOCATION_STOP_VOLUME "Location Stop Volume" #define NEMO_ACTION_LOCATION_POLL "Location Poll" #define NEMO_ACTION_SCRIPTS "Scripts" +#define NEMO_ACTION_NEW_LAUNCHER "New Launcher" +#define NEMO_ACTION_NEW_LAUNCHER_DESKTOP "New Launcher" #define NEMO_ACTION_NEW_DOCUMENTS "New Documents" #define NEMO_ACTION_NEW_EMPTY_DOCUMENT "New Empty Document" #define NEMO_ACTION_EMPTY_TRASH_CONDITIONAL "Empty Trash Conditional" diff --git a/src/nemo-desktop-icon-view-ui.xml b/src/nemo-desktop-icon-view-ui.xml index 9735b0c01..d437801de 100644 --- a/src/nemo-desktop-icon-view-ui.xml +++ b/src/nemo-desktop-icon-view-ui.xml @@ -4,6 +4,7 @@ + diff --git a/src/nemo-desktop-icon-view.c b/src/nemo-desktop-icon-view.c index e4d220f0c..947fd81b0 100644 --- a/src/nemo-desktop-icon-view.c +++ b/src/nemo-desktop-icon-view.c @@ -666,6 +666,23 @@ action_empty_trash_conditional_callback (GtkAction *action, nemo_file_operations_empty_trash (GTK_WIDGET (data)); } +static void +action_new_launcher_callback (GtkAction *action, gpointer data) +{ + char *desktop_directory; + + g_assert (NEMO_IS_VIEW (data)); + + desktop_directory = nemo_get_desktop_directory (); + + nemo_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)), + "gnome-desktop-item-edit", + FALSE, + "--create-new", desktop_directory, NULL); + g_free (desktop_directory); + +} + static gboolean trash_link_is_selection (NemoView *view) { @@ -709,6 +726,13 @@ real_update_menus (NemoView *view) desktop_view = NEMO_DESKTOP_ICON_VIEW (view); + + /* New Launcher */ + action = gtk_action_group_get_action (desktop_view->details->desktop_action_group, + NEMO_ACTION_NEW_LAUNCHER_DESKTOP); + gtk_action_set_visible (action, + TRUE); + /* Empty Trash */ include_empty_trash = trash_link_is_selection (view); action = gtk_action_group_get_action (desktop_view->details->desktop_action_group, @@ -726,6 +750,13 @@ real_update_menus (NemoView *view) static const GtkActionEntry desktop_view_entries[] = { /* name, stock id */ + { "New Launcher Desktop", NULL, + /* label, accelerator */ + N_("Create L_auncher..."), NULL, + /* tooltip */ + N_("Create a new launcher"), + G_CALLBACK (action_new_launcher_callback) }, + /* name, stock id */ { "Change Background", NULL, /* label, accelerator */ N_("Change Desktop _Background"), NULL, diff --git a/src/nemo-directory-view-ui.xml b/src/nemo-directory-view-ui.xml index 30dc7e200..e477dd8c4 100644 --- a/src/nemo-directory-view-ui.xml +++ b/src/nemo-directory-view-ui.xml @@ -98,6 +98,7 @@ + diff --git a/src/nemo-view.c b/src/nemo-view.c index 1852f7733..a496acf89 100644 --- a/src/nemo-view.c +++ b/src/nemo-view.c @@ -2034,6 +2034,29 @@ action_new_empty_file_callback (GtkAction *action, nemo_view_new_file (NEMO_VIEW (callback_data), NULL, NULL); } +static void +action_new_launcher_callback (GtkAction *action, + gpointer callback_data) +{ + char *parent_uri; + NemoView *view; + GtkWindow *window; + + g_assert (NEMO_IS_VIEW (callback_data)); + + view = NEMO_VIEW (callback_data); + + parent_uri = nemo_view_get_backing_uri (view); + + window = nemo_view_get_containing_window (view); + nemo_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (view)), + "gnome-desktop-item-edit", + FALSE, + "--create-new", parent_uri, NULL); + + g_free (parent_uri); +} + static void action_properties_callback (GtkAction *action, gpointer callback_data) @@ -6964,6 +6987,10 @@ static const GtkActionEntry directory_view_entries[] = { /* label, accelerator */ N_("_Empty Document"), NULL, /* tooltip */ N_("Create a new empty document inside this folder"), G_CALLBACK (action_new_empty_file_callback) }, + /* name, stock id */ { "New Launcher", NULL, + /* label, accelerator */ N_("Create L_auncher..."), NULL, + /* tooltip */ N_("Create a new launcher"), + G_CALLBACK (action_new_launcher_callback) }, /* name, stock id */ { "Open", NULL, /* label, accelerator */ N_("_Open"), "o", /* tooltip */ N_("Open the selected item in this window"), From d7fb288ce3cebd815695a23f93434da9270fdb1c Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 23:12:53 +0100 Subject: [PATCH 6/9] Restore toolbar actions as seen in GNOME 2 --- libnemo-private/nemo-global-preferences.h | 7 + libnemo-private/nemo.convert | 7 + libnemo-private/org.gnome.nemo.gschema.xml.in | 35 ++++ src/nemo-actions.h | 2 + src/nemo-file-management-properties.c | 33 ++++ src/nemo-file-management-properties.ui | 181 +++++++++++++++++- src/nemo-navigation-action.c | 10 + src/nemo-navigation-action.h | 8 +- src/nemo-toolbar-ui.xml | 7 +- src/nemo-toolbar.c | 71 ++++++- src/nemo-toolbar.h | 1 + src/nemo-tree-sidebar.c | 9 +- src/nemo-window-menus.c | 103 ++++++++-- src/nemo-window-pane.c | 9 +- src/nemo-window.c | 5 +- 15 files changed, 468 insertions(+), 20 deletions(-) diff --git a/libnemo-private/nemo-global-preferences.h b/libnemo-private/nemo-global-preferences.h index 0b0d1dd94..de67c0093 100644 --- a/libnemo-private/nemo-global-preferences.h +++ b/libnemo-private/nemo-global-preferences.h @@ -78,6 +78,13 @@ typedef enum #define NEMO_PREFERENCES_NEW_TAB_POSITION "tabs-open-position" #define NEMO_PREFERENCES_SHOW_LOCATION_ENTRY "show-location-entry" +#define NEMO_PREFERENCES_SHOW_UP_ICON_TOOLBAR "show-up-icon-toolbar" +#define NEMO_PREFERENCES_SHOW_EDIT_ICON_TOOLBAR "show-edit-icon-toolbar" +#define NEMO_PREFERENCES_SHOW_RELOAD_ICON_TOOLBAR "show-reload-icon-toolbar" +#define NEMO_PREFERENCES_SHOW_HOME_ICON_TOOLBAR "show-home-icon-toolbar" +#define NEMO_PREFERENCES_SHOW_COMPUTER_ICON_TOOLBAR "show-computer-icon-toolbar" +#define NEMO_PREFERENCES_SHOW_SEARCH_ICON_TOOLBAR "show-search-icon-toolbar" +#define NEMO_PREFERENCES_SHOW_LABEL_SEARCH_ICON_TOOLBAR "show-label-search-icon-toolbar" /* Which views should be displayed for new windows */ #define NEMO_WINDOW_STATE_START_WITH_STATUS_BAR "start-with-status-bar" diff --git a/libnemo-private/nemo.convert b/libnemo-private/nemo.convert index e4a2ac83c..39b542b10 100644 --- a/libnemo-private/nemo.convert +++ b/libnemo-private/nemo.convert @@ -2,6 +2,13 @@ tabs-open-position = /desktop/gnome/file_views/tabs_open_position always-use-browser = /apps/nemo/preferences/always_use_browser always-use-location-entry = /apps/nemo/preferences/always_use_location_entry +show-up-icon-toolbar = /apps/nemo/preferences/show-up-icon-toolbar +show-edit-icon-toolbar = /apps/nemo/preferences/show-edit-icon-toolbar +show-reload-icon-toolbar = /apps/nemo/preferences/show-reload-icon-toolbar +show-home-icon-toolbar = /apps/nemo/preferences/show-home-icon-toolbar +show-computer-icon-toolbar = /apps/nemo/preferences/show-computer-icon-toolbar +show-search-icon-toolbar = /apps/nemo/preferences/show-search-icon-toolbar +show-label-search-icon-toolbar = /apps/nemo/preferences/show-label-search-icon-toolbar confirm-trash = /apps/nemo/preferences/confirm_trash enable-delete = /apps/nemo/preferences/enable_delete show-icon-text = /apps/nemo/preferences/show_icon_text diff --git a/libnemo-private/org.gnome.nemo.gschema.xml.in b/libnemo-private/org.gnome.nemo.gschema.xml.in index 4118c927f..6aa0bf43d 100644 --- a/libnemo-private/org.gnome.nemo.gschema.xml.in +++ b/libnemo-private/org.gnome.nemo.gschema.xml.in @@ -82,6 +82,41 @@ <_summary>Show the location entry by default <_description>If set to true, then Nemo browser windows will show a textual input entry for the location toolbar. + + false + Show Up button in nemo toolbar + If set to true, then Nemo browser windows will show the button. + + + false + Show refresh button in nemo toolbar + If set to true, then Nemo browser windows will show the button. + + + false + Show toggle button location entry/pathbar + If set to true, then Nemo browser windows will show the button. + + + false + Show Home button in nemo toolbar + If set to true, then Nemo browser windows will show the button. + + + false + Show Computer button in nemo toolbar + If set to true, then Nemo browser windows will show the button. + + + true + Show Search button in nemo toolbar + If set to true, then Nemo browser windows will show the button. + + + true + Show the Search button label in nemo toolbar + If set to true, then Nemo browser windows will show the Search label button. + true <_summary>Whether to ask for confirmation when deleting files, or emptying Trash diff --git a/src/nemo-actions.h b/src/nemo-actions.h index d3ec21270..9c9bdef4a 100644 --- a/src/nemo-actions.h +++ b/src/nemo-actions.h @@ -29,6 +29,7 @@ #define NEMO_ACTION_STOP "Stop" #define NEMO_ACTION_RELOAD "Reload" #define NEMO_ACTION_BACK "Back" +#define NEMO_ACTION_COMPUTER "Computer" #define NEMO_ACTION_UP "Up" #define NEMO_ACTION_UP_ACCEL "UpAccel" #define NEMO_ACTION_UP_ACCEL "UpAccel" @@ -44,6 +45,7 @@ #define NEMO_ACTION_GO_HOME "Home" #define NEMO_ACTION_ADD_BOOKMARK "Add Bookmark" #define NEMO_ACTION_EDIT_BOOKMARKS "Edit Bookmarks" +#define NEMO_ACTION_EDIT "Edit" #define NEMO_ACTION_HOME "Home" #define NEMO_ACTION_ZOOM_IN "Zoom In" #define NEMO_ACTION_ZOOM_OUT "Zoom Out" diff --git a/src/nemo-file-management-properties.c b/src/nemo-file-management-properties.c index cee0d0877..d1ae5f4ba 100644 --- a/src/nemo-file-management-properties.c +++ b/src/nemo-file-management-properties.c @@ -63,6 +63,15 @@ #define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET "hidden_files_checkbutton" #define NEMO_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET "treeview_folders_checkbutton" +#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_UP_ICON_TOOLBAR_WIDGET "show_up_icon_toolbar_checkbutton" +#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_RELOAD_ICON_TOOLBAR_WIDGET "show_reload_icon_toolbar_checkbutton" +#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_EDIT_ICON_TOOLBAR_WIDGET "show_edit_icon_toolbar_checkbutton" +#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_HOME_ICON_TOOLBAR_WIDGET "show_home_icon_toolbar_checkbutton" +#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_COMPUTER_ICON_TOOLBAR_WIDGET "show_computer_icon_toolbar_checkbutton" +#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_SEARCH_ICON_TOOLBAR_WIDGET "show_search_icon_toolbar_checkbutton" +#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_LABEL_SEARCH_ICON_TOOLBAR_WIDGET "show_label_search_icon_toolbar_checkbutton" + + /* int enums */ #define NEMO_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET "preview_image_size_combobox" @@ -721,6 +730,30 @@ nemo_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *wi 4); create_date_format_menu (builder); + + /* nemo patch */ + bind_builder_bool (builder, nemo_preferences, + NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_UP_ICON_TOOLBAR_WIDGET, + NEMO_PREFERENCES_SHOW_UP_ICON_TOOLBAR); + bind_builder_bool (builder, nemo_preferences, + NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_RELOAD_ICON_TOOLBAR_WIDGET, + NEMO_PREFERENCES_SHOW_RELOAD_ICON_TOOLBAR); + bind_builder_bool (builder, nemo_preferences, + NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_EDIT_ICON_TOOLBAR_WIDGET, + NEMO_PREFERENCES_SHOW_EDIT_ICON_TOOLBAR); + bind_builder_bool (builder, nemo_preferences, + NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_HOME_ICON_TOOLBAR_WIDGET, + NEMO_PREFERENCES_SHOW_HOME_ICON_TOOLBAR); + bind_builder_bool (builder, nemo_preferences, + NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_COMPUTER_ICON_TOOLBAR_WIDGET, + NEMO_PREFERENCES_SHOW_COMPUTER_ICON_TOOLBAR); + bind_builder_bool (builder, nemo_preferences, + NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_SEARCH_ICON_TOOLBAR_WIDGET, + NEMO_PREFERENCES_SHOW_SEARCH_ICON_TOOLBAR); + bind_builder_bool (builder, nemo_preferences, + NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_LABEL_SEARCH_ICON_TOOLBAR_WIDGET, + NEMO_PREFERENCES_SHOW_LABEL_SEARCH_ICON_TOOLBAR); + /* setup preferences */ bind_builder_bool (builder, nemo_icon_view_preferences, NEMO_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET, diff --git a/src/nemo-file-management-properties.ui b/src/nemo-file-management-properties.ui index ce058f43d..ef739264d 100644 --- a/src/nemo-file-management-properties.ui +++ b/src/nemo-file-management-properties.ui @@ -603,7 +603,7 @@ 1 - + False True @@ -1607,6 +1607,185 @@ False + + + True + False + 12 + vertical + 18 + + + True + False + vertical + 6 + + + True + False + 0 + <b>Options</b> + True + + + False + False + 0 + + + + + True + False + 12 + + + True + False + vertical + 6 + + + Show up icon + True + True + False + False + True + True + + + False + False + 0 + + + + + Show refresh icon + True + True + False + False + True + True + + + False + False + 1 + + + + + Show toggle button location bar/bar path + True + True + False + False + True + True + + + False + False + 2 + + + + + Show home icon + True + True + False + False + True + True + + + False + False + 3 + + + + + Show computer icon + True + True + False + False + True + True + + + False + False + 4 + + + + + Show search icon + True + True + False + False + True + True + + + False + False + 5 + + + + + Show label on search icon (need to restart nemo) + True + True + False + False + True + True + + + False + False + 6 + + + + + + + False + True + 1 + + + + + False + True + 5 + + + + + + + True + False + Toolbar + + + 2 + False + + False diff --git a/src/nemo-navigation-action.c b/src/nemo-navigation-action.c index d97607b43..84b184948 100644 --- a/src/nemo-navigation-action.c +++ b/src/nemo-navigation-action.c @@ -149,6 +149,16 @@ show_menu (NemoNavigationAction *self, case NEMO_NAVIGATION_DIRECTION_BACK: fill_menu (window, menu, TRUE); break; + case NEMO_NAVIGATION_DIRECTION_UP: + return; + case NEMO_NAVIGATION_DIRECTION_RELOAD: + return; + case NEMO_NAVIGATION_DIRECTION_HOME: + return; + case NEMO_NAVIGATION_DIRECTION_COMPUTER: + return; + case NEMO_NAVIGATION_DIRECTION_EDIT: + return; default: g_assert_not_reached (); break; diff --git a/src/nemo-navigation-action.h b/src/nemo-navigation-action.h index db438ccc9..d0f4e2bb2 100644 --- a/src/nemo-navigation-action.h +++ b/src/nemo-navigation-action.h @@ -47,7 +47,13 @@ typedef struct NemoNavigationActionPrivate NemoNavigationActionPrivate; typedef enum { NEMO_NAVIGATION_DIRECTION_BACK, - NEMO_NAVIGATION_DIRECTION_FORWARD + NEMO_NAVIGATION_DIRECTION_FORWARD, + NEMO_NAVIGATION_DIRECTION_UP, + NEMO_NAVIGATION_DIRECTION_RELOAD, + NEMO_NAVIGATION_DIRECTION_HOME, + NEMO_NAVIGATION_DIRECTION_COMPUTER, + NEMO_NAVIGATION_DIRECTION_EDIT + } NemoNavigationDirection; struct _NemoNavigationAction diff --git a/src/nemo-toolbar-ui.xml b/src/nemo-toolbar-ui.xml index 42c88e7cc..904c0cbf8 100644 --- a/src/nemo-toolbar-ui.xml +++ b/src/nemo-toolbar-ui.xml @@ -2,6 +2,11 @@ + + + + + - \ No newline at end of file + diff --git a/src/nemo-toolbar.c b/src/nemo-toolbar.c index 06b2c8138..0acc861cb 100644 --- a/src/nemo-toolbar.c +++ b/src/nemo-toolbar.c @@ -64,6 +64,10 @@ G_DEFINE_TYPE (NemoToolbar, nemo_toolbar, GTK_TYPE_BOX); static void toolbar_update_appearance (NemoToolbar *self) { + GtkAction *action; + GtkWidget *widgetitem; + gboolean icon_toolbar; + gboolean show_location_entry; show_location_entry = self->priv->show_location_entry || @@ -79,6 +83,37 @@ toolbar_update_appearance (NemoToolbar *self) gtk_widget_set_visible (self->priv->search_bar, self->priv->show_search_bar); + + + widgetitem = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Up"); + icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_UP_ICON_TOOLBAR); + if ( icon_toolbar == FALSE ) { gtk_widget_hide (widgetitem); } + else {gtk_widget_show (widgetitem);} + + widgetitem = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Reload"); + icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_RELOAD_ICON_TOOLBAR); + if ( icon_toolbar == FALSE ) { gtk_widget_hide (widgetitem); } + else {gtk_widget_show (widgetitem);} + + widgetitem = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Edit"); + icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_EDIT_ICON_TOOLBAR); + if ( icon_toolbar == FALSE ) { gtk_widget_hide (widgetitem); } + else {gtk_widget_show (widgetitem);} + + widgetitem = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Home"); + icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_HOME_ICON_TOOLBAR); + if ( icon_toolbar == FALSE ) { gtk_widget_hide (widgetitem); } + else {gtk_widget_show (widgetitem);} + + widgetitem = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Computer"); + icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_COMPUTER_ICON_TOOLBAR); + if ( icon_toolbar == FALSE ) { gtk_widget_hide (widgetitem); } + else {gtk_widget_show (widgetitem);} + + widgetitem = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Search"); + icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_SEARCH_ICON_TOOLBAR); + if ( icon_toolbar == FALSE ) { gtk_widget_hide (widgetitem); } + else {gtk_widget_show (widgetitem);} } static void @@ -101,7 +136,8 @@ nemo_toolbar_constructed (GObject *obj) toolbar = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar"); self->priv->toolbar = toolbar; - gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR); + /** Remove this, should be up to the user what the icon size is. + gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR); */ context = gtk_widget_get_style_context (toolbar); gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR); @@ -127,7 +163,8 @@ nemo_toolbar_constructed (GObject *obj) item = gtk_tool_item_new (); gtk_tool_item_set_expand (item, TRUE); gtk_container_add (GTK_CONTAINER (item), vbox); - gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, 0); + /* append to the end of the toolbar so navigation buttons are at the beginning */ + gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, -1); gtk_widget_show (GTK_WIDGET (item)); /* search bar */ @@ -138,7 +175,31 @@ nemo_toolbar_constructed (GObject *obj) "changed::" NEMO_PREFERENCES_SHOW_LOCATION_ENTRY, G_CALLBACK (toolbar_update_appearance), self); + /* nemo patch */ + g_signal_connect_swapped (nemo_preferences, + "changed::" NEMO_PREFERENCES_SHOW_UP_ICON_TOOLBAR, + G_CALLBACK (toolbar_update_appearance), self); + g_signal_connect_swapped (nemo_preferences, + "changed::" NEMO_PREFERENCES_SHOW_EDIT_ICON_TOOLBAR, + G_CALLBACK (toolbar_update_appearance), self); + g_signal_connect_swapped (nemo_preferences, + "changed::" NEMO_PREFERENCES_SHOW_RELOAD_ICON_TOOLBAR, + G_CALLBACK (toolbar_update_appearance), self); + g_signal_connect_swapped (nemo_preferences, + "changed::" NEMO_PREFERENCES_SHOW_HOME_ICON_TOOLBAR, + G_CALLBACK (toolbar_update_appearance), self); + g_signal_connect_swapped (nemo_preferences, + "changed::" NEMO_PREFERENCES_SHOW_COMPUTER_ICON_TOOLBAR, + G_CALLBACK (toolbar_update_appearance), self); + g_signal_connect_swapped (nemo_preferences, + "changed::" NEMO_PREFERENCES_SHOW_SEARCH_ICON_TOOLBAR, + G_CALLBACK (toolbar_update_appearance), self); + g_signal_connect_swapped (nemo_preferences, + "changed::" NEMO_PREFERENCES_SHOW_LABEL_SEARCH_ICON_TOOLBAR, + G_CALLBACK (toolbar_update_appearance), self); + toolbar_update_appearance (self); + } static void @@ -282,6 +343,12 @@ nemo_toolbar_get_search_bar (NemoToolbar *self) return self->priv->search_bar; } +GtkWidget * +nemo_toolbar_get_show_location_entry (NemoToolbar *self) +{ + return self->priv->show_location_entry; +} + void nemo_toolbar_set_show_main_bar (NemoToolbar *self, gboolean show_main_bar) diff --git a/src/nemo-toolbar.h b/src/nemo-toolbar.h index 9d3799c1b..7aaa7fbb8 100644 --- a/src/nemo-toolbar.h +++ b/src/nemo-toolbar.h @@ -64,6 +64,7 @@ GType nemo_toolbar_get_type (void); GtkWidget *nemo_toolbar_new (GtkActionGroup *action_group); +GtkWidget *nemo_toolbar_get_show_location_entry (NemoToolbar *self); GtkWidget *nemo_toolbar_get_path_bar (NemoToolbar *self); GtkWidget *nemo_toolbar_get_location_bar (NemoToolbar *self); GtkWidget *nemo_toolbar_get_search_bar (NemoToolbar *self); diff --git a/src/nemo-tree-sidebar.c b/src/nemo-tree-sidebar.c index 8fed86d3c..6fe94c30c 100644 --- a/src/nemo-tree-sidebar.c +++ b/src/nemo-tree-sidebar.c @@ -1333,7 +1333,12 @@ create_tree (FMTreeView *view) (view->details->child_model, "row_loaded", G_CALLBACK (row_loaded_callback), view, G_CONNECT_AFTER); - home_uri = nemo_get_home_directory_uri (); +#ifdef NOT_YET_USABLE /* Do we really want this? */ + icon = g_themed_icon_new (NEMO_ICON_COMPUTER); + fm_tree_model_add_root_uri (view->details->child_model, "computer:///", _("Computer"), icon, NULL); + g_object_unref (icon); +#endif + home_uri = nemo_get_home_directory_uri (); icon = g_themed_icon_new (NEMO_ICON_HOME); fm_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home"), icon, NULL); g_object_unref (icon); @@ -1343,7 +1348,7 @@ create_tree (FMTreeView *view) g_object_unref (icon); #ifdef NOT_YET_USABLE /* Do we really want this? */ icon = g_themed_icon_new (NEMO_ICON_NETWORK); - fm_tree_model_add_root_uri (view->details->child_model, "network:///", _("Network Neighbourhood"), icon, NULL); + fm_tree_model_add_root_uri (view->details->child_model, "network:///", _("Network"), icon, NULL); g_object_unref (icon); #endif diff --git a/src/nemo-window-menus.c b/src/nemo-window-menus.c index 181a516f0..7aa8b7fc8 100644 --- a/src/nemo-window-menus.c +++ b/src/nemo-window-menus.c @@ -1048,6 +1048,8 @@ static const GtkRadioActionEntry main_radio_entries[] = { GtkActionGroup * nemo_window_create_toolbar_action_group (NemoWindow *window) { + gboolean show_label_search_icon_toolbar; + NemoNavigationState *navigation_state; GtkActionGroup *action_group; GtkAction *action; @@ -1087,16 +1089,92 @@ nemo_window_create_toolbar_action_group (NemoWindow *window) g_object_unref (action); - action = GTK_ACTION - (gtk_toggle_action_new (NEMO_ACTION_SEARCH, - _("Search"), - _("Search documents and folders by name"), - NULL)); - gtk_action_group_add_action (action_group, action); - gtk_action_set_icon_name (GTK_ACTION (action), "edit-find"); - gtk_action_set_is_important (GTK_ACTION (action), TRUE); - - g_object_unref (action); + /** + * Nemo 2.30/2.32 type actions + */ + action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, + "name", NEMO_ACTION_UP, + "label", _("_Up"), + "stock_id", GTK_STOCK_GO_UP, + "tooltip", _("Go to parent folder"), + "arrow-tooltip", _("Forward history"), + "window", window, + "direction", NEMO_NAVIGATION_DIRECTION_UP, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (action_up_callback), window); + gtk_action_group_add_action (action_group, action); + + g_object_unref (action); + + action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, + "name", NEMO_ACTION_RELOAD, + "label", _("_Reload"), + "stock_id", GTK_STOCK_REFRESH, + "tooltip", _("Reload the current location"), + "window", window, + "direction", NEMO_NAVIGATION_DIRECTION_RELOAD, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (action_reload_callback), window); + gtk_action_group_add_action (action_group, action); + + g_object_unref (action); + + action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, + "name", NEMO_ACTION_HOME, + "label", _("_Home"), + "stock_id", GTK_STOCK_HOME, + "tooltip", _("Go to home directory"), + "window", window, + "direction", NEMO_NAVIGATION_DIRECTION_HOME, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (action_home_callback), window); + gtk_action_group_add_action (action_group, action); + + g_object_unref (action); + + action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, + "name", NEMO_ACTION_COMPUTER, + "label", _("_Computer"), + "stock_id", GTK_STOCK_HARDDISK, + "tooltip", _("Go to Computer"), + "window", window, + "direction", NEMO_NAVIGATION_DIRECTION_COMPUTER, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (action_go_to_computer_callback), window); + gtk_action_group_add_action (action_group, action); + + g_object_unref (action); + + action = g_object_new (NEMO_TYPE_NAVIGATION_ACTION, + "name", NEMO_ACTION_EDIT, + "label", _("Location"), + "stock_id", GTK_STOCK_EDIT, + "tooltip", _("Toggle Location bar / Path bar"), + "window", window, + "direction", NEMO_NAVIGATION_DIRECTION_EDIT, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (action_go_to_location_callback), window); + gtk_action_group_add_action (action_group, action); + + g_object_unref (action); + + action = GTK_ACTION (gtk_toggle_action_new (NEMO_ACTION_SEARCH, + _("Search"),_("Search documents and folders by name"), + NULL)); + + gtk_action_group_add_action (action_group, action); + gtk_action_set_icon_name (GTK_ACTION (action), "edit-find"); + + + show_label_search_icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_LABEL_SEARCH_ICON_TOOLBAR); + gtk_action_set_is_important (GTK_ACTION (action), show_label_search_icon_toolbar); + + g_object_unref (action); navigation_state = nemo_window_get_navigation_state (window); nemo_navigation_state_add_group (navigation_state, action_group); @@ -1154,7 +1232,7 @@ nemo_window_initialize_actions (NemoWindow *window) { GtkActionGroup *action_group; const gchar *nav_state_actions[] = { - NEMO_ACTION_BACK, NEMO_ACTION_FORWARD, + NEMO_ACTION_BACK, NEMO_ACTION_FORWARD, NEMO_ACTION_UP, NEMO_ACTION_RELOAD, NEMO_ACTION_COMPUTER, NEMO_ACTION_HOME, NEMO_ACTION_EDIT, NEMO_ACTION_SEARCH, NULL }; @@ -1208,6 +1286,9 @@ nemo_window_initialize_menus (NemoWindow *window) action = gtk_action_group_get_action (action_group, NEMO_ACTION_HOME); g_object_set (action, "short_label", _("_Home"), NULL); + action = gtk_action_group_get_action (action_group, NEMO_ACTION_EDIT); + g_object_set (action, "short_label", _("_Location"), NULL); + action = gtk_action_group_get_action (action_group, NEMO_ACTION_SHOW_HIDDEN_FILES); g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), diff --git a/src/nemo-window-pane.c b/src/nemo-window-pane.c index 9c37e5fc5..809de58b7 100644 --- a/src/nemo-window-pane.c +++ b/src/nemo-window-pane.c @@ -1048,10 +1048,17 @@ nemo_window_pane_grab_focus (NemoWindowPane *pane) void nemo_window_pane_ensure_location_bar (NemoWindowPane *pane) { + gboolean fl_active; remember_focus_widget (pane); nemo_toolbar_set_show_main_bar (NEMO_TOOLBAR (pane->tool_bar), TRUE); - nemo_toolbar_set_show_location_entry (NEMO_TOOLBAR (pane->tool_bar), TRUE); + + fl_active = nemo_toolbar_get_show_location_entry (NEMO_TOOLBAR (pane->tool_bar)); + if (fl_active) { + nemo_toolbar_set_show_location_entry (NEMO_TOOLBAR (pane->tool_bar), FALSE); + } else { + nemo_toolbar_set_show_location_entry (NEMO_TOOLBAR (pane->tool_bar), TRUE); + } if (!g_settings_get_boolean (nemo_window_state, NEMO_WINDOW_STATE_START_WITH_TOOLBAR)) { diff --git a/src/nemo-window.c b/src/nemo-window.c index 50a06e896..3fa4e5f3f 100644 --- a/src/nemo-window.c +++ b/src/nemo-window.c @@ -2055,6 +2055,7 @@ nemo_window_split_view_on (NemoWindow *window) void nemo_window_split_view_off (NemoWindow *window) { + gboolean show_label_search_icon_toolbar; NemoWindowPane *pane, *active_pane; GList *l, *next; @@ -2074,7 +2075,9 @@ nemo_window_split_view_off (NemoWindow *window) active_pane->action_group); nemo_window_update_show_hide_menu_items (window); - window_set_search_action_text (window, TRUE); + + show_label_search_icon_toolbar = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_LABEL_SEARCH_ICON_TOOLBAR); + window_set_search_action_text (window, show_label_search_icon_toolbar); } gboolean From 0e33a6cf990806302e7fab16a3cb03950d7f06f3 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 23:20:32 +0100 Subject: [PATCH 7/9] Use one unified toolbar for both panes (i.e. F3 extra pane) placed under menubar --- src/nemo-window-pane.c | 15 +++++++++++++-- src/nemo-window-private.h | 3 +++ src/nemo-window.c | 25 +++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/nemo-window-pane.c b/src/nemo-window-pane.c index 809de58b7..38415a46d 100644 --- a/src/nemo-window-pane.c +++ b/src/nemo-window-pane.c @@ -45,6 +45,9 @@ #define DEBUG_FLAG NEMO_DEBUG_WINDOW #include +// For: NEMO_IS_DESKTOP_WINDOW +#include "nemo-desktop-window.h" + enum { PROP_WINDOW = 1, NUM_PROPERTIES @@ -746,9 +749,10 @@ nemo_window_pane_constructed (GObject *obj) g_signal_connect (pane->action_group, "pre-activate", G_CALLBACK (toolbar_action_group_activated_callback), pane); - gtk_box_pack_start (GTK_BOX (pane), + /* Pack to windows hbox (under the menu */ + gtk_box_pack_start (GTK_BOX (window->details->toolbar_holder), pane->tool_bar, - FALSE, FALSE, 0); + TRUE, TRUE, 0); /* start as non-active */ nemo_window_pane_set_active (pane, FALSE); @@ -828,6 +832,13 @@ nemo_window_pane_constructed (GObject *obj) */ gtk_widget_set_size_request (GTK_WIDGET (pane), 60, 60); + /* + * If we're on the desktop we need to make sure the toolbar can never show + */ + if (NEMO_IS_DESKTOP_WINDOW(window)) { + gtk_widget_hide (GTK_WIDGET (window->details->toolbar_holder)); + } + /* we can unref the size group now */ g_object_unref (header_size_group); } diff --git a/src/nemo-window-private.h b/src/nemo-window-private.h index 416da11c2..ffcfee5ca 100644 --- a/src/nemo-window-private.h +++ b/src/nemo-window-private.h @@ -90,6 +90,9 @@ struct NemoWindowDetails /* Toolbar */ GtkWidget *toolbar; + /* Toolbar holder */ + GtkWidget *toolbar_holder; + guint extensions_toolbar_merge_id; GtkActionGroup *extensions_toolbar_action_group; diff --git a/src/nemo-window.c b/src/nemo-window.c index 3fa4e5f3f..1ef3449fc 100644 --- a/src/nemo-window.c +++ b/src/nemo-window.c @@ -535,6 +535,7 @@ nemo_window_constructed (GObject *self) GtkWidget *statusbar; GtkWidget *hpaned; GtkWidget *vbox; + GtkWidget *toolbar_holder; NemoWindowPane *pane; NemoWindowSlot *slot; NemoApplication *application; @@ -564,6 +565,12 @@ nemo_window_constructed (GObject *self) gtk_widget_show (menu); gtk_container_add (GTK_CONTAINER (grid), menu); + /* Set up the toolbar place holder */ + toolbar_holder = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + gtk_container_add (GTK_CONTAINER (grid), toolbar_holder); + gtk_widget_show (toolbar_holder); + window->details->toolbar_holder = toolbar_holder; + /* Register to menu provider extension signal managing menu updates */ g_signal_connect_object (nemo_signaller_get_current (), "popup_menu_changed", G_CALLBACK (nemo_window_load_extension_menus), window, G_CONNECT_SWAPPED); @@ -837,6 +844,10 @@ nemo_window_close_pane (NemoWindow *window, window->details->active_pane = NULL; } + /* Required really. Destroying the NemoWindowPane still leaves behind the toolbar. + * This kills it off. Do it before we call gtk_widget_destroy for safety. */ + gtk_container_remove (GTK_CONTAINER (window->details->toolbar_holder), GTK_WIDGET (pane->tool_bar)); + window->details->panes = g_list_remove (window->details->panes, pane); gtk_widget_destroy (GTK_WIDGET (pane)); @@ -888,7 +899,6 @@ void nemo_window_set_active_slot (NemoWindow *window, NemoWindowSlot *new_slot) { NemoWindowSlot *old_slot; - g_assert (NEMO_IS_WINDOW (window)); DEBUG ("Setting new slot %p as active", new_slot); @@ -911,7 +921,7 @@ nemo_window_set_active_slot (NemoWindow *window, NemoWindowSlot *new_slot) if (old_slot->content_view != NULL) { nemo_window_disconnect_content_view (window, old_slot->content_view); } - + gtk_widget_hide (GTK_WIDGET (old_slot->pane->tool_bar)); /* inform slot & view */ g_signal_emit_by_name (old_slot, "inactive"); } @@ -935,6 +945,14 @@ nemo_window_set_active_slot (NemoWindow *window, NemoWindowSlot *new_slot) nemo_window_connect_content_view (window, new_slot->content_view); } + // Show active toolbar + gboolean show_toolbar; + show_toolbar = g_settings_get_boolean (nemo_window_state, NEMO_WINDOW_STATE_START_WITH_TOOLBAR); + + if ( show_toolbar) { + gtk_widget_show (GTK_WIDGET (new_slot->pane->tool_bar)); + } + /* inform slot & view */ g_signal_emit_by_name (new_slot, "active"); } @@ -1775,6 +1793,9 @@ create_extra_pane (NemoWindow *window) gtk_paned_pack2 (paned, GTK_WIDGET (pane), TRUE, FALSE); } + /* Ensure the toolbar doesn't pop itself into existence (double toolbars suck.) */ + gtk_widget_hide (pane->tool_bar); + /* slot */ slot = nemo_window_pane_open_slot (NEMO_WINDOW_PANE (pane), NEMO_WINDOW_OPEN_SLOT_APPEND); From 845a2f1e597f853540b6caab7b152be6a759a58b Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 23:29:39 +0100 Subject: [PATCH 8/9] Improve toolbar's default layout (buttons left navbar center search far right) --- src/nemo-toolbar-ui.xml | 3 +++ src/nemo-toolbar.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/nemo-toolbar-ui.xml b/src/nemo-toolbar-ui.xml index 904c0cbf8..577e41f6b 100644 --- a/src/nemo-toolbar-ui.xml +++ b/src/nemo-toolbar-ui.xml @@ -4,9 +4,12 @@ + + + diff --git a/src/nemo-toolbar.c b/src/nemo-toolbar.c index 0acc861cb..85fb73f3b 100644 --- a/src/nemo-toolbar.c +++ b/src/nemo-toolbar.c @@ -124,6 +124,8 @@ nemo_toolbar_constructed (GObject *obj) GtkWidget *vbox, *toolbar, *search; GtkStyleContext *context; + GtkWidget *sep_space; + G_OBJECT_CLASS (nemo_toolbar_parent_class)->constructed (obj); gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (self)), @@ -142,6 +144,10 @@ nemo_toolbar_constructed (GObject *obj) context = gtk_widget_get_style_context (toolbar); gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR); + sep_space = gtk_ui_manager_get_widget(self->priv->ui_manager, "/Toolbar/BeforeSearch"); + gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (sep_space), FALSE); + gtk_tool_item_set_expand (GTK_SEPARATOR_TOOL_ITEM (sep_space), TRUE); + search = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Search"); gtk_style_context_add_class (gtk_widget_get_style_context (search), GTK_STYLE_CLASS_RAISED); gtk_widget_set_name (search, "nemo-search-button"); @@ -164,7 +170,7 @@ nemo_toolbar_constructed (GObject *obj) gtk_tool_item_set_expand (item, TRUE); gtk_container_add (GTK_CONTAINER (item), vbox); /* append to the end of the toolbar so navigation buttons are at the beginning */ - gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, -1); + gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, 8); gtk_widget_show (GTK_WIDGET (item)); /* search bar */ From b9721f83f4b9a4d4452739baa30b534eb7471a9c Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 10 Aug 2012 23:35:44 +0100 Subject: [PATCH 9/9] That is without a shadow of a doubt the single-most fugly icon I have ever encountered. Changed it to system-file-manager instead. --- src/nemo-window-menus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nemo-window-menus.c b/src/nemo-window-menus.c index 7aa8b7fc8..20b80a478 100644 --- a/src/nemo-window-menus.c +++ b/src/nemo-window-menus.c @@ -337,7 +337,7 @@ action_about_nemo_callback (GtkAction *action, "your computer and online."), "license", license_trans, "wrap-license", TRUE, - "logo-icon-name", "nemo", + "logo-icon-name", "system-file-manager", NULL); g_free (license_trans);