Skip to content

Commit

Permalink
context menu: Make individual menu item visibility configurable in pr…
Browse files Browse the repository at this point in the history
…eferences,

and eliminate the simple/complex menu option.
  • Loading branch information
mtwebster committed Nov 7, 2019
1 parent c799639 commit 6b249b3
Show file tree
Hide file tree
Showing 11 changed files with 1,098 additions and 67 deletions.
4 changes: 2 additions & 2 deletions gresources/nemo-directory-view-ui.xml
Expand Up @@ -183,7 +183,7 @@
<menuitem name="Unpin File" action="Unpin File"/>
<menuitem name="Create Link" action="Create Link"/>
<menuitem name="Rename" action="Rename"/>
<menu action="CopyToMenu">
<menu name="CopyToMenu" action="CopyToMenu">
<menuitem name="Copy to next pane" action="Copy to next pane"/>
<menuitem name="Copy to Home" action="Copy to Home"/>
<menuitem name="Copy to Desktop" action="Copy to Desktop"/>
Expand All @@ -193,7 +193,7 @@
<separator/>
<menuitem name="Browse for copy to" action="BrowseCopyTo"/>
</menu>
<menu action="MoveToMenu">
<menu name="MoveToMenu" action="MoveToMenu">
<menuitem name="Move to next pane" action="Move to next pane"/>
<menuitem name="Copy to Home" action="Move to Home"/>
<menuitem name="Copy to Desktop" action="Move to Desktop"/>
Expand Down
835 changes: 816 additions & 19 deletions gresources/nemo-file-management-properties.glade

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion gresources/nemo-shell-ui.xml
Expand Up @@ -50,7 +50,6 @@
<separator/>
<placeholder name="Extension Actions"/>
<separator/>
<menuitem name="Show Full Context Menu" action="ShowFullContextMenu"/>
<menuitem name="Plugins" action="NemoPluginManager"/>
<menuitem name="Preferences" action="Preferences"/>
</menu>
Expand Down
2 changes: 2 additions & 0 deletions libnemo-private/nemo-global-preferences.c
Expand Up @@ -299,6 +299,7 @@ nemo_global_preferences_init (void)
nemo_desktop_preferences = g_settings_new("org.nemo.desktop");
nemo_tree_sidebar_preferences = g_settings_new("org.nemo.sidebar-panels.tree");
nemo_plugin_preferences = g_settings_new("org.nemo.plugins");
nemo_menu_config_preferences = g_settings_new("org.nemo.preferences.menu-config");
gnome_lockdown_preferences = g_settings_new("org.cinnamon.desktop.lockdown");
gnome_background_preferences = g_settings_new("org.cinnamon.desktop.background");
gnome_media_handling_preferences = g_settings_new("org.cinnamon.desktop.media-handling");
Expand Down Expand Up @@ -326,6 +327,7 @@ nemo_global_preferences_finalize (void)
g_object_unref (nemo_desktop_preferences);
g_object_unref (nemo_tree_sidebar_preferences);
g_object_unref (nemo_plugin_preferences);
g_object_unref (nemo_menu_config_preferences);
g_object_unref (gnome_lockdown_preferences);
g_object_unref (gnome_background_preferences);
g_object_unref (gnome_media_handling_preferences);
Expand Down
3 changes: 1 addition & 2 deletions libnemo-private/nemo-global-preferences.h
Expand Up @@ -131,8 +131,6 @@ typedef enum

#define NEMO_PREFERENCES_SIDEBAR_BOOKMARK_BREAKPOINT "sidebar-bookmark-breakpoint"

#define NEMO_PREFERENCES_CONTEXT_MENUS_SHOW_ALL_ACTIONS "context-menus-show-all-actions"

enum
{
NEMO_DEFAULT_FOLDER_VIEWER_ICON_VIEW,
Expand Down Expand Up @@ -286,6 +284,7 @@ GSettings *nemo_desktop_preferences;
GSettings *nemo_tree_sidebar_preferences;
GSettings *nemo_window_state;
GSettings *nemo_plugin_preferences;
GSettings *nemo_menu_config_preferences;
GSettings *gnome_lockdown_preferences;
GSettings *gnome_background_preferences;
GSettings *gnome_media_handling_preferences;
Expand Down
123 changes: 118 additions & 5 deletions libnemo-private/org.nemo.gschema.xml
Expand Up @@ -330,11 +330,6 @@
<summary>Whether to list places in the Move To/Copy To menus</summary>
<description>If set to true, places will be listed in the MoveTo/CopyTo menus</description>
</key>
<key name="context-menus-show-all-actions" type="b">
<default>false</default>
<summary>Whether to show all available actions in context menus</summary>
<description>If set to true, all actions are visible. Otherwise nemo shows a simplified version of what is present in the menubar.</description>
</key>
<key name="tooltips-on-desktop" type="b">
<default>false</default>
<summary>Show tooltips for desktop items</summary>
Expand Down Expand Up @@ -679,4 +674,122 @@
<description>List of script files you do -not- want loaded. This maintains the behavior of an installed script being enabled by default.</description>
</key>
</schema>

<schema id="org.nemo.preferences.menu-config" path="/org/nemo/preferences/menu-config/" gettext-domain="nemo">
<!-- Selection -->
<key name="selection-menu-open" type="b">
<default>true</default>
<summary>Show the selection context menu's Open item.</summary>
</key>
<key name="selection-menu-open-in-new-tab" type="b">
<default>true</default>
<summary>Show the selection context menu's Open in New Tab item.</summary>
</key>
<key name="selection-menu-open-in-new-window" type="b">
<default>true</default>
<summary>Show the selection context menu's Open in New Window item.</summary>
</key>
<key name="selection-menu-scripts" type="b">
<default>true</default>
<summary>Show the selection context menu's Scripts submenu.</summary>
</key>
<key name="selection-menu-cut" type="b">
<default>true</default>
<summary>Show the selection context menu's Cut item.</summary>
</key>
<key name="selection-menu-copy" type="b">
<default>true</default>
<summary>Show the selection context menu's Copy item.</summary>
</key>
<key name="selection-menu-paste" type="b">
<default>true</default>
<summary>Show the selection context menu's Paste item.</summary>
</key>
<key name="selection-menu-duplicate" type="b">
<default>false</default>
<summary>Show the selection context menu's Duplicate item.</summary>
</key>
<key name="selection-menu-pin" type="b">
<default>true</default>
<summary>Show the selection context menu's Pin/Unpin item.</summary>
</key>
<key name="selection-menu-make-link" type="b">
<default>false</default>
<summary>Show the selection context menu's Create Link item.</summary>
</key>
<key name="selection-menu-rename" type="b">
<default>true</default>
<summary>Show the selection context menu's Rename item.</summary>
</key>
<key name="selection-menu-copy-to" type="b">
<default>false</default>
<summary>Show the selection context menu's Copy To submenu.</summary>
</key>
<key name="selection-menu-move-to" type="b">
<default>false</default>
<summary>Show the selection context menu's Move To submenu.</summary>
</key>
<key name="selection-menu-open-in-terminal" type="b">
<default>true</default>
<summary>Show the selection context menu's Open in Terminal item.</summary>
</key>
<key name="selection-menu-open-as-root" type="b">
<default>true</default>
<summary>Show the selection context menu's Open As Root item.</summary>
</key>
<key name="selection-menu-move-to-trash" type="b">
<default>true</default>
<summary>Show the selection context menu's Move to Trash item.</summary>
</key>
<key name="selection-menu-properties" type="b">
<default>true</default>
<summary>Show the selection context menu's Properties item.</summary>
</key>

<!-- Background -->
<key name="background-menu-create-new-folder" type="b">
<default>true</default>
<summary>Show the background context menu's Create New Folder item.</summary>
</key>
<key name="background-menu-scripts" type="b">
<default>true</default>
<summary>Show the background context menu's Scripts submenu.</summary>
</key>
<key name="background-menu-open-in-terminal" type="b">
<default>true</default>
<summary>Show the background context menu's Open in Terminal item.</summary>
</key>
<key name="background-menu-open-as-root" type="b">
<default>true</default>
<summary>Show the background context menu's Open as Root item.</summary>
</key>
<key name="background-menu-show-hidden-files" type="b">
<default>true</default>
<summary>Show the background context menu's Show Hidden Files item.</summary>
</key>
<key name="background-menu-paste" type="b">
<default>true</default>
<summary>Show the background context menu's Paste item.</summary>
</key>
<key name="background-menu-properties" type="b">
<default>true</default>
<summary>Show the background context menu's Properties item.</summary>
</key>

<!-- Icon View -->
<key name="iconview-menu-arrange-items" type="b">
<default>true</default>
<summary>Show the background context menu's Arrange Items submenu (icon view only).</summary>
</key>
<key name="iconview-menu-organize-by-name" type="b">
<default>true</default>
<summary>Show the background context menu's Organize by Name item (icon view only).</summary>
</key>

<!-- Desktop (new) -->
<key name="desktop-menu-customize" type="b">
<default>true</default>
<summary>Show the background context menu's Customize item (new-style desktop only).</summary>
</key>
</schema>
</schemalist>
107 changes: 107 additions & 0 deletions src/nemo-actions.h
Expand Up @@ -26,6 +26,8 @@
#ifndef NEMO_ACTIONS_H
#define NEMO_ACTIONS_H

#include <glib.h>

#define NEMO_ACTION_STOP "Stop"
#define NEMO_ACTION_RELOAD "Reload"
#define NEMO_ACTION_BACK "Back"
Expand Down Expand Up @@ -88,6 +90,8 @@
#define NEMO_ACTION_MOVE_TO_DESKTOP "Move to Desktop"
#define NEMO_ACTION_BROWSE_MOVE_TO "BrowseMoveTo"
#define NEMO_ACTION_BROWSE_COPY_TO "BrowseCopyTo"
#define NEMO_ACTION_COPY_TO_MENU "CopyToMenu"
#define NEMO_ACTION_MOVE_TO_MENU "MoveToMenu"
#define NEMO_ACTION_LOCATION_PASTE_FILES_INTO "LocationPasteFilesInto"
#define NEMO_ACTION_RENAME "Rename"
#define NEMO_ACTION_DUPLICATE "Duplicate"
Expand Down Expand Up @@ -152,5 +156,108 @@

#define NEMO_ACTION_PIN_FILE "Pin File"
#define NEMO_ACTION_UNPIN_FILE "Unpin File"
#define NEMO_ACTION_DESKTOP_OVERLAY "Desktop Overlay"

typedef struct
{
const gchar *action_name; // The action's name
const gchar *config_widget_name; // The builder id of the corresponding toggle in preferences
// Can be null if the action's should be tied to another
// action's visibility.
const gchar *ui_path; // The xml path of the item from the ui file
const gchar *settings_key;; // The gsettings key corresponding to the menu item's visibility.
} ConfigurableMenuItemInfo;

static const ConfigurableMenuItemInfo CONFIGURABLE_MENU_ITEM_INFO [] = {
// Selection
{ NEMO_ACTION_OPEN, "selection_menu__open_check",
"/selection/Open Placeholder/Open", "selection-menu-open" },

{ NEMO_ACTION_OPEN_IN_NEW_TAB, "selection_menu__open_in_new_tab_check",
"/selection/Open Placeholder/OpenInNewTab", "selection-menu-open-in-new-tab" },

{ NEMO_ACTION_OPEN_ALTERNATE, "selection_menu__open_in_new_window_check",
"/selection/Open Placeholder/OpenAlternate", "selection-menu-open-in-new-window" },

{ NEMO_ACTION_SCRIPTS, "selection_menu__scripts_check",
"/selection/Open Placeholder/Scripts", "selection-menu-scripts" },

{ NEMO_ACTION_CUT, "selection_menu__cut_check",
"/selection/File Clipboard Actions/Cut", "selection-menu-cut" },

{ NEMO_ACTION_COPY, "selection_menu__copy_check",
"/selection/File Clipboard Actions/Copy", "selection-menu-copy" },

{ NEMO_ACTION_PASTE_FILES_INTO, "selection_menu__paste_check",
"/selection/File Clipboard Actions/Paste Files Into", "selection-menu-paste" },

{ NEMO_ACTION_DUPLICATE, "selection_menu__duplicate_check",
"/selection/File Clipboard Actions/Duplicate", "selection-menu-duplicate" },

{ NEMO_ACTION_PIN_FILE, "selection_menu__pin_check",
"/selection/File Actions/Pin File", "selection-menu-pin" },
{ NEMO_ACTION_UNPIN_FILE, NULL,
"/selection/File Actions/Unpin File", "selection-menu-pin" },

{ NEMO_ACTION_CREATE_LINK, "selection_menu__make_link_check",
"/selection/File Actions/Create Link", "selection-menu-make-link" },

{ NEMO_ACTION_RENAME, "selection_menu__rename_check",
"/selection/File Actions/Rename", "selection-menu-rename" },

{ NEMO_ACTION_COPY_TO_MENU, "selection_menu__copy_to_check",
"/selection/File Actions/CopyToMenu", "selection-menu-copy-to" },

{ NEMO_ACTION_MOVE_TO_MENU, "selection_menu__move_to_check",
"/selection/File Actions/MoveToMenu", "selection-menu-move-to" },

{ NEMO_ACTION_OPEN_IN_TERMINAL, "selection_menu__open_in_terminal_check",
"/selection/OpenInTerminal", "selection-menu-open-in-terminal" },

{ NEMO_ACTION_OPEN_AS_ROOT, "selection_menu__open_as_root_check",
"/selection/OpenAsRoot", "selection-menu-open-as-root" },

{ NEMO_ACTION_TRASH, "selection_menu__move_to_trash_check",
"/selection/Dangerous File Actions/Trash", "selection-menu-move-to-trash" },

{ NEMO_ACTION_PROPERTIES, "selection_menu__properties_check",
"/selection/Properties", "selection-menu-properties" },

// Background

{ NEMO_ACTION_NEW_FOLDER, "background_menu__create_new_folder_check",
"/background/Before Zoom Items/New Object Items/New Folder", "background-menu-create-new-folder" },

{ NEMO_ACTION_SCRIPTS, "background_menu__scripts_check",
"/background/Before Zoom Items/New Object Items/Scripts", "background-menu-scripts" },

{ NEMO_ACTION_OPEN_IN_TERMINAL, "background_menu__open_in_terminal_check",
"/background/Before Zoom Items/OpenInTerminal", "background-menu-open-in-terminal" },

{ NEMO_ACTION_OPEN_AS_ROOT, "background_menu__open_as_root_check",
"/background/Before Zoom Items/OpenAsRoot", "background-menu-open-as-root" },

{ NEMO_ACTION_SHOW_HIDDEN_FILES, "background_menu__show_hidden_files_check",
"/background/Before Zoom Items/Show Hidden Files", "background-menu-show-hidden-files" },

{ NEMO_ACTION_PASTE, "background_menu__paste_check",
"/background/Before Zoom Items/File Clipboard Actions/Paste", "background-menu-paste" },

{ NEMO_ACTION_PROPERTIES, "background_menu__properties_check",
"/background/Folder Items Placeholder/Properties", "background-menu-properties" },

// Icon View (merged with background)
{ NEMO_ACTION_ARRANGE_ITEMS, "iconview_menu__arrange_items_check",
"/background/Before Zoom Items/View Items/Arrange Items", "iconview-menu-arrange-items" },

{ NEMO_ACTION_CLEAN_UP, "iconview_menu__organize_by_name_check",
"/background/Before Zoom Items/View Items/Clean Up", "iconview-menu-organize-by-name" },

// Desktop (new)
{ NEMO_ACTION_DESKTOP_OVERLAY, "desktop_menu__customize_check",
"/background/Before Zoom Items/View Items/Desktop Overlay", "desktop-menu-customize" },
};

#define CONFIGURABLE_MENU_ITEM_COUNT (G_N_ELEMENTS (CONFIGURABLE_MENU_ITEM_INFO))

#endif /* NEMO_ACTIONS_H */
20 changes: 20 additions & 0 deletions src/nemo-file-management-properties.c
Expand Up @@ -41,6 +41,7 @@
#include <libnemo-private/nemo-module.h>

#include "nemo-plugin-manager.h"
#include "nemo-actions.h"

/* string enum preferences */
#define NEMO_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET "default_view_combobox"
Expand Down Expand Up @@ -726,6 +727,23 @@ bind_builder_radio (GtkBuilder *builder,
}
}

static void
setup_configurable_menu_items (GtkBuilder *builder)
{
gint i;

for (i = 0; i < CONFIGURABLE_MENU_ITEM_COUNT; i++) {
if (CONFIGURABLE_MENU_ITEM_INFO[i].config_widget_name == NULL) {
continue;
}

bind_builder_bool (builder,
nemo_menu_config_preferences,
CONFIGURABLE_MENU_ITEM_INFO[i].config_widget_name,
CONFIGURABLE_MENU_ITEM_INFO[i].settings_key);
}
}

static void
setup_tooltip_items (GtkBuilder *builder)
{
Expand Down Expand Up @@ -1041,6 +1059,8 @@ nemo_file_management_properties_dialog_setup (GtkBuilder *builder,
nemo_file_management_properties_dialog_setup_list_column_page (builder);
nemo_file_management_properties_dialog_setup_plugin_page (builder);

setup_configurable_menu_items (builder);

dialog = GTK_WIDGET (gtk_builder_get_object (builder, "file_management_dialog"));

g_signal_connect (dialog, "delete-event",
Expand Down
2 changes: 1 addition & 1 deletion src/nemo-places-sidebar.c
Expand Up @@ -3506,7 +3506,7 @@ bookmarks_build_popup_menu (NemoPlacesSidebar *sidebar)
gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item);

item = gtk_menu_item_new_with_label (_("Rename..."));
item = gtk_menu_item_new_with_label (_("_Rename…"));
sidebar->popup_menu_rename_item = item;
g_signal_connect (item, "activate",
G_CALLBACK (rename_shortcut_cb), sidebar);
Expand Down

0 comments on commit 6b249b3

Please sign in to comment.