[nautilus/path-bar-templates-and-extensions: 8/8] pathbar: Extend button menu with extensions and templates
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/path-bar-templates-and-extensions: 8/8] pathbar: Extend button menu with extensions and templates
- Date: Thu, 19 Jul 2018 14:20:44 +0000 (UTC)
commit c3de87acca9fbf1262003f76d24bd18145037dbd
Author: Carlos Soriano <csoriano redhat com>
Date: Thu Jul 19 16:08:12 2018 +0200
pathbar: Extend button menu with extensions and templates
One of the benefits of the new menu on the path bar buttons is that we
show the background menu.
This was the intended design since the start, but we didn't come to
finalize it earlier on.
Now with the 3.30 approaching, this work implements that.
Closes https://gitlab.gnome.org/GNOME/nautilus/issues/405
src/nautilus-files-view.c | 185 ++++++++++++++++++----
src/nautilus-pathbar.c | 89 ++++++++++-
src/nautilus-pathbar.h | 6 +-
src/nautilus-toolbar.c | 23 ++-
src/nautilus-view.c | 59 +++++++
src/nautilus-view.h | 23 ++-
src/nautilus-window-slot.c | 125 ++++++++++++++-
src/nautilus-window-slot.h | 4 +
src/resources/ui/nautilus-pathbar-context-menu.ui | 168 +++++---------------
9 files changed, 523 insertions(+), 159 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 192f7616f..05051b1f6 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -144,6 +144,8 @@ enum
PROP_SELECTION,
PROP_LOCATION,
PROP_SEARCH_QUERY,
+ PROP_EXTENSIONS_BACKGROUND_MENU,
+ PROP_TEMPLATES_MENU,
NUM_PROPERTIES
};
@@ -262,6 +264,10 @@ typedef struct
GtkWidget *zoom_controls_box;
GtkWidget *zoom_level_label;
+ /* Exposed menus, for the path bar etc. */
+ GMenu *extensions_background_menu;
+ GMenu *templates_menu;
+
gulong stop_signal_handler;
gulong reload_signal_handler;
@@ -689,6 +695,98 @@ nautilus_files_view_get_toolbar_menu_sections (NautilusView *view)
return priv->toolbar_menu_sections;
}
+static GMenu*
+nautilus_files_view_get_templates_menu (NautilusView *self)
+{
+ GMenu *menu;
+
+ g_object_get (self, "templates-menu", &menu, NULL);
+
+ return menu;
+}
+
+static GMenu*
+nautilus_files_view_get_extensions_background_menu (NautilusView *self)
+{
+ GMenu *menu;
+
+ g_object_get (self, "extensions-background-menu", &menu, NULL);
+
+ return menu;
+}
+
+static GMenu*
+real_get_extensions_background_menu (NautilusView *view)
+{
+ NautilusFilesViewPrivate *priv;
+
+ g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
+
+ priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
+
+ return priv->extensions_background_menu;
+}
+
+static GMenu*
+real_get_templates_menu (NautilusView *view)
+{
+ NautilusFilesViewPrivate *priv;
+
+ g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
+
+ priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
+
+ return priv->templates_menu;
+}
+
+static void
+nautilus_files_view_set_templates_menu (NautilusView *self,
+ GMenu *menu)
+{
+ g_object_set (self, "templates-menu", menu, NULL);
+}
+
+static void
+nautilus_files_view_set_extensions_background_menu (NautilusView *self,
+ GMenu *menu)
+{
+ g_object_set (self, "extensions-background-menu", menu, NULL);
+}
+
+static void
+real_set_extensions_background_menu (NautilusView *view,
+ GMenu *menu)
+{
+ NautilusFilesViewPrivate *priv;
+
+ g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
+
+ priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
+
+ if (priv->extensions_background_menu != NULL)
+ {
+ g_clear_object (&priv->extensions_background_menu);
+ }
+ priv->extensions_background_menu = menu;
+}
+
+static void
+real_set_templates_menu (NautilusView *view,
+ GMenu *menu)
+{
+ NautilusFilesViewPrivate *priv;
+
+ g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
+
+ priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
+
+ if (priv->templates_menu != NULL)
+ {
+ g_clear_object (&priv->extensions_background_menu);
+ }
+ priv->templates_menu = menu;
+}
+
static gboolean
showing_trash_directory (NautilusFilesView *view)
{
@@ -3204,6 +3302,8 @@ nautilus_files_view_finalize (GObject *object)
g_clear_object (&priv->selection_menu);
g_clear_object (&priv->toolbar_menu_sections->zoom_section);
g_clear_object (&priv->toolbar_menu_sections->extended_section);
+ g_clear_object (&priv->extensions_background_menu);
+ g_clear_object (&priv->templates_menu);
g_clear_object (&priv->rename_file_controller);
g_clear_object (&priv->new_folder_controller);
g_clear_object (&priv->compress_controller);
@@ -4960,49 +5060,42 @@ build_menu_for_extension_menu_items (NautilusFilesView *view,
return gmenu;
}
-static void
-add_extension_menu_items (NautilusFilesView *view,
- const gchar *extension_prefix,
- GList *menu_items,
- GMenu *insertion_menu)
-{
- GMenu *menu;
-
- menu = build_menu_for_extension_menu_items (view, extension_prefix, menu_items);
- nautilus_gmenu_merge (insertion_menu,
- menu,
- "extensions",
- FALSE);
-
- g_object_unref (menu);
-}
-
static void
update_extensions_menus (NautilusFilesView *view)
{
NautilusFilesViewPrivate *priv;
GList *selection_items, *background_items;
+ g_autoptr (GMenu) background_menu = NULL;
+ g_autoptr (GMenu) selection_menu = NULL;
priv = nautilus_files_view_get_instance_private (view);
selection_items = get_extension_selection_menu_items (view);
if (selection_items != NULL)
{
- add_extension_menu_items (view,
- "selection",
- selection_items,
- priv->selection_menu);
+ selection_menu = build_menu_for_extension_menu_items (view, "extensions",
+ selection_items);
+
+ nautilus_gmenu_merge (priv->selection_menu,
+ selection_menu,
+ "extensions",
+ FALSE);
nautilus_menu_item_list_free (selection_items);
}
background_items = get_extension_background_menu_items (view);
if (background_items != NULL)
{
- add_extension_menu_items (view,
- "background",
- background_items,
- priv->background_menu);
+ background_menu = build_menu_for_extension_menu_items (view, "extensions",
+ background_items);
+
+ nautilus_gmenu_merge (priv->background_menu,
+ background_menu,
+ "background",
+ FALSE);
nautilus_menu_item_list_free (background_items);
}
+
+ nautilus_view_set_extensions_background_menu (NAUTILUS_VIEW (view), background_menu);
}
static char *
@@ -5707,7 +5800,7 @@ update_templates_menu (NautilusFilesView *view)
NautilusFilesViewPrivate *priv;
GList *sorted_copy, *node;
NautilusDirectory *directory;
- GMenu *submenu;
+ g_autoptr (GMenu) submenu = NULL;
char *uri;
char *templates_directory_uri;
@@ -5748,9 +5841,10 @@ update_templates_menu (NautilusFilesView *view)
submenu,
"templates-submenu",
FALSE);
- g_object_unref (submenu);
}
+ nautilus_view_set_templates_menu (NAUTILUS_VIEW (view), submenu);
+
nautilus_directory_unref (directory);
priv->templates_present = submenu != NULL;
@@ -8937,8 +9031,25 @@ nautilus_files_view_get_property (GObject *object,
}
break;
+ case PROP_EXTENSIONS_BACKGROUND_MENU:
+ {
+ g_value_set_object (value,
+ real_get_extensions_background_menu (NAUTILUS_VIEW (view)));
+ }
+ break;
+
+ case PROP_TEMPLATES_MENU:
+ {
+ g_value_set_object (value,
+ real_get_templates_menu (NAUTILUS_VIEW (view)));
+ }
+ break;
+
default:
+ {
g_assert_not_reached ();
+ }
+ break;
}
}
@@ -8994,6 +9105,20 @@ nautilus_files_view_set_property (GObject *object,
}
break;
+ case PROP_EXTENSIONS_BACKGROUND_MENU:
+ {
+ real_set_extensions_background_menu (NAUTILUS_VIEW (directory_view),
+ g_value_get_object (value));
+ }
+ break;
+
+ case PROP_TEMPLATES_MENU:
+ {
+ real_set_templates_menu (NAUTILUS_VIEW (directory_view),
+ g_value_get_object (value));
+ }
+ break;
+
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -9353,6 +9478,10 @@ nautilus_files_view_iface_init (NautilusViewInterface *iface)
iface->is_searching = nautilus_files_view_is_searching;
iface->is_loading = nautilus_files_view_is_loading;
iface->get_view_id = nautilus_files_view_get_view_id;
+ iface->get_templates_menu = nautilus_files_view_get_templates_menu;
+ iface->set_templates_menu = nautilus_files_view_set_templates_menu;
+ iface->get_extensions_background_menu = nautilus_files_view_get_extensions_background_menu;
+ iface->set_extensions_background_menu = nautilus_files_view_set_extensions_background_menu;
}
static void
@@ -9477,6 +9606,8 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
g_object_class_override_property (oclass, PROP_LOCATION, "location");
g_object_class_override_property (oclass, PROP_SELECTION, "selection");
g_object_class_override_property (oclass, PROP_SEARCH_QUERY, "search-query");
+ g_object_class_override_property (oclass, PROP_EXTENSIONS_BACKGROUND_MENU, "extensions-background-menu");
+ g_object_class_override_property (oclass, PROP_TEMPLATES_MENU, "templates-menu");
}
static void
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 6e1cc1cf7..69ba92662 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -106,7 +106,10 @@ typedef struct
unsigned int drag_slider_timeout;
gboolean drag_slider_timeout_for_up_button;
- GtkPopover *current_view_menu;
+ GtkPopover *current_view_menu_popover;
+ GMenu *current_view_menu;
+ GMenu *extensions_background_menu;
+ GMenu *templates_menu;
GtkGesture *up_slider_button_long_press_gesture;
GtkGesture *down_slider_button_long_press_gesture;
@@ -235,7 +238,9 @@ nautilus_path_bar_init (NautilusPathBar *self)
/* Context menu */
builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-pathbar-context-menu.ui");
- priv->current_view_menu = g_object_ref (GTK_POPOVER (gtk_builder_get_object (builder, "menu_popover"))),
+ priv->current_view_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder,
"current-view-menu")));
+ priv->current_view_menu_popover = GTK_POPOVER (gtk_popover_new_from_model (NULL,
+ G_MENU_MODEL
(priv->current_view_menu)));
g_object_unref (builder);
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
@@ -313,6 +318,7 @@ nautilus_path_bar_finalize (GObject *object)
}
g_list_free (priv->button_list);
+ g_clear_object (&priv->current_view_menu);
G_OBJECT_CLASS (nautilus_path_bar_parent_class)->finalize (object);
}
@@ -1220,6 +1226,81 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
gtk_container_class_handle_border_width (container_class);
}
+static void
+update_current_view_menu (NautilusPathBar *self)
+{
+ NautilusPathBarPrivate *priv;
+
+ priv = nautilus_path_bar_get_instance_private (self);
+ if (priv->extensions_background_menu != NULL)
+ {
+ nautilus_gmenu_merge (priv->current_view_menu,
+ priv->extensions_background_menu,
+ "extensions",
+ TRUE);
+ }
+
+ if (priv->templates_menu != NULL)
+ {
+ nautilus_gmenu_merge (priv->current_view_menu, priv->templates_menu,
+ "templates-submenu", TRUE);
+ }
+}
+
+static void
+reset_current_view_menu (NautilusPathBar *self)
+{
+ NautilusPathBarPrivate *priv;
+ g_autoptr (GtkBuilder) builder = NULL;
+
+ priv = nautilus_path_bar_get_instance_private (self);
+
+ g_clear_object (&priv->current_view_menu);
+ builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-pathbar-context-menu.ui");
+ priv->current_view_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder,
+ "current-view-menu")));
+ gtk_popover_bind_model (priv->current_view_menu_popover,
+ G_MENU_MODEL (priv->current_view_menu), NULL);
+}
+
+void
+nautilus_path_bar_set_extensions_background_menu (NautilusPathBar *self,
+ GMenu *menu)
+{
+ NautilusPathBarPrivate *priv;
+
+ g_return_if_fail (NAUTILUS_IS_PATH_BAR (self));
+
+ priv = nautilus_path_bar_get_instance_private (self);
+ reset_current_view_menu (self);
+ g_clear_object (&priv->extensions_background_menu);
+ if (menu != NULL)
+ {
+ priv->extensions_background_menu = g_object_ref (menu);
+ }
+
+ update_current_view_menu (self);
+}
+
+void
+nautilus_path_bar_set_templates_menu (NautilusPathBar *self,
+ GMenu *menu)
+{
+ NautilusPathBarPrivate *priv;
+
+ g_return_if_fail (NAUTILUS_IS_PATH_BAR (self));
+
+ priv = nautilus_path_bar_get_instance_private (self);
+ reset_current_view_menu (self);
+ g_clear_object (&priv->templates_menu);
+ if (menu != NULL)
+ {
+ priv->templates_menu = g_object_ref (menu);
+ }
+
+ update_current_view_menu (self);
+}
+
static void
nautilus_path_bar_scroll_down (NautilusPathBar *self)
{
@@ -1567,7 +1648,7 @@ button_clicked_cb (GtkWidget *button,
{
if (g_file_equal (button_data->path, priv->current_path))
{
- gtk_popover_popup (priv->current_view_menu);
+ gtk_popover_popup (priv->current_view_menu_popover);
}
else
{
@@ -2005,7 +2086,7 @@ make_button_data (NautilusPathBar *self,
if (current_dir)
{
gtk_widget_show (button_data->disclosure_arrow);
- gtk_popover_set_relative_to (priv->current_view_menu, button_data->button);
+ gtk_popover_set_relative_to (priv->current_view_menu_popover, button_data->button);
}
if (button_data->label != NULL)
diff --git a/src/nautilus-pathbar.h b/src/nautilus-pathbar.h
index 814d7dd55..be422b4b8 100644
--- a/src/nautilus-pathbar.h
+++ b/src/nautilus-pathbar.h
@@ -34,4 +34,8 @@ struct _NautilusPathBarClass
GFile *location,
GtkPlacesOpenFlags flags);
};
-void nautilus_path_bar_set_path (NautilusPathBar *self, GFile *file);
\ No newline at end of file
+void nautilus_path_bar_set_path (NautilusPathBar *self, GFile *file);
+void nautilus_path_bar_set_extensions_background_menu (NautilusPathBar *self,
+ GMenu *menu);
+void nautilus_path_bar_set_templates_menu (NautilusPathBar *self,
+ GMenu *menu);
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 03dd73588..4664ae54a 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -1233,6 +1233,24 @@ container_remove_all_children (GtkContainer *container)
g_list_free (children);
}
+static void
+slot_on_extensions_background_menu_changed (NautilusToolbar *self,
+ GParamSpec *param,
+ NautilusWindowSlot *slot)
+{
+ nautilus_path_bar_set_extensions_background_menu (NAUTILUS_PATH_BAR (self->path_bar),
+ nautilus_window_slot_get_extensions_background_menu
(slot));
+}
+
+static void
+slot_on_templates_menu_changed (NautilusToolbar *self,
+ GParamSpec *param,
+ NautilusWindowSlot *slot)
+{
+ nautilus_path_bar_set_templates_menu (NAUTILUS_PATH_BAR (self->path_bar),
+ nautilus_window_slot_get_templates_menu (slot));
+}
+
static void
on_slot_toolbar_menu_sections_changed (NautilusToolbar *self,
GParamSpec *param,
@@ -1344,7 +1362,10 @@ nautilus_toolbar_set_window_slot (NautilusToolbar *self,
on_slot_toolbar_menu_sections_changed (self, NULL, self->window_slot);
g_signal_connect_swapped (self->window_slot, "notify::toolbar-menu-sections",
G_CALLBACK (on_slot_toolbar_menu_sections_changed), self);
-
+ g_signal_connect_swapped (self->window_slot, "notify::extensions-background-menu",
+ G_CALLBACK (slot_on_extensions_background_menu_changed), self);
+ g_signal_connect_swapped (self->window_slot, "notify::templates-menu",
+ G_CALLBACK (slot_on_templates_menu_changed), self);
g_signal_connect_swapped (window_slot, "notify::searching",
G_CALLBACK (toolbar_update_appearance), self);
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 6f2fa4698..e9213e769 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -83,6 +83,29 @@ nautilus_view_default_init (NautilusViewInterface *iface)
"The search query being performed on the view",
NAUTILUS_TYPE_QUERY,
G_PARAM_READWRITE));
+
+ /**
+ * NautilusView::extensions-background-menu:
+ *
+ * Menu for the background click of extensions
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("extensions-background-menu",
+ "Menu for the background click of extensions",
+ "Menu for the background click of extensions",
+ G_TYPE_MENU,
+ G_PARAM_READWRITE));
+ /**
+ * NautilusView::templates-menu:
+ *
+ * Menu of templates
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("templates-menu",
+ "Menu of templates",
+ "Menu of templates",
+ G_TYPE_MENU,
+ G_PARAM_READWRITE));
}
/**
@@ -148,6 +171,42 @@ nautilus_view_get_toolbar_menu_sections (NautilusView *view)
return NAUTILUS_VIEW_GET_IFACE (view)->get_toolbar_menu_sections (view);
}
+GMenu *
+nautilus_view_get_extensions_background_menu (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_extensions_background_menu, NULL);
+
+ return NAUTILUS_VIEW_GET_IFACE (view)->get_extensions_background_menu (view);
+}
+
+/* Protected */
+void
+nautilus_view_set_extensions_background_menu (NautilusView *view,
+ GMenu *menu)
+{
+ g_return_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->set_extensions_background_menu);
+
+ NAUTILUS_VIEW_GET_IFACE (view)->set_extensions_background_menu (view, menu);
+}
+
+GMenu *
+nautilus_view_get_templates_menu (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_templates_menu, NULL);
+
+ return NAUTILUS_VIEW_GET_IFACE (view)->get_templates_menu (view);
+}
+
+/* Protected */
+void
+nautilus_view_set_templates_menu (NautilusView *view,
+ GMenu *menu)
+{
+ g_return_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->set_templates_menu);
+
+ NAUTILUS_VIEW_GET_IFACE (view)->set_templates_menu (view, menu);
+}
+
/**
* nautilus_view_get_search_query:
* @view: a #NautilusView
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 56452ef89..16bd471d2 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -50,6 +50,20 @@ struct _NautilusViewInterface
*/
NautilusToolbarMenuSections * (*get_toolbar_menu_sections) (NautilusView *view);
+ /*
+ * Returns the menu for the background click of extensions.
+ */
+ GMenu * (*get_extensions_background_menu) (NautilusView *view);
+
+ void (*set_extensions_background_menu) (NautilusView *view,
+ GMenu *menu);
+ /*
+ * Returns the menu for templates.
+ */
+ GMenu * (*get_templates_menu) (NautilusView *view);
+
+ void (*set_templates_menu) (NautilusView *view,
+ GMenu *menu);
/* Current location of the view */
GFile* (*get_location) (NautilusView *view);
void (*set_location) (NautilusView *view,
@@ -97,4 +111,11 @@ gboolean nautilus_view_is_loading (Nautilus
gboolean nautilus_view_is_searching (NautilusView *view);
-G_END_DECLS
\ No newline at end of file
+void nautilus_view_set_templates_menu (NautilusView *view,
+ GMenu *menu);
+GMenu* nautilus_view_get_templates_menu (NautilusView *view);
+void nautilus_view_set_extensions_background_menu (NautilusView *view,
+ GMenu *menu);
+GMenu* nautilus_view_get_extensions_background_menu (NautilusView *view);
+
+G_END_DECLS
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index a2b0402ac..e56175b0c 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -54,6 +54,8 @@ enum
PROP_WINDOW,
PROP_ICON,
PROP_TOOLBAR_MENU_SECTIONS,
+ PROP_EXTENSIONS_BACKGROUND_MENU,
+ PROP_TEMPLATES_MENU,
PROP_LOADING,
PROP_SEARCHING,
PROP_SELECTION,
@@ -124,9 +126,15 @@ typedef struct
gboolean tried_mount;
gint view_mode_before_search;
+ /* Menus */
+ GMenu *extensions_background_menu;
+ GMenu *templates_menu;
+
/* View bindings */
GBinding *searching_binding;
GBinding *selection_binding;
+ GBinding *extensions_background_menu_binding;
+ GBinding *templates_menu_binding;
gboolean searching;
GList *selection;
} NautilusWindowSlotPrivate;
@@ -159,6 +167,12 @@ static void trash_state_changed_cb (NautilusTrashMonitor *monitor,
gboolean is_empty,
gpointer user_data);
static void update_search_information (NautilusWindowSlot *self);
+static void real_set_extensions_background_menu (NautilusWindowSlot *self,
+ GMenu *menu);
+static GMenu* real_get_extensions_background_menu (NautilusWindowSlot *self);
+static void real_set_templates_menu (NautilusWindowSlot *self,
+ GMenu *menu);
+static GMenu* real_get_templates_menu (NautilusWindowSlot *self);
void
nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
@@ -726,6 +740,26 @@ nautilus_window_slot_set_selection (NautilusWindowSlot *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTION]);
}
+static void
+real_set_extensions_background_menu (NautilusWindowSlot *self,
+ GMenu *menu)
+{
+ NautilusWindowSlotPrivate *priv;
+ priv = nautilus_window_slot_get_instance_private (self);
+
+ priv->extensions_background_menu = menu != NULL ? g_object_ref (menu) : NULL;
+}
+
+static void
+real_set_templates_menu (NautilusWindowSlot *self,
+ GMenu *menu)
+{
+ NautilusWindowSlotPrivate *priv;
+ priv = nautilus_window_slot_get_instance_private (self);
+
+ priv->templates_menu = menu != NULL ? g_object_ref (menu) : NULL;
+}
+
static void
nautilus_window_slot_set_property (GObject *object,
guint property_id,
@@ -760,6 +794,18 @@ nautilus_window_slot_set_property (GObject *object,
}
break;
+ case PROP_EXTENSIONS_BACKGROUND_MENU:
+ {
+ real_set_extensions_background_menu (self, g_value_get_object (value));
+ }
+ break;
+
+ case PROP_TEMPLATES_MENU:
+ {
+ real_set_templates_menu (self, g_value_get_object (value));
+ }
+ break;
+
case PROP_SELECTION:
{
nautilus_window_slot_set_selection (self, g_value_get_pointer (value));
@@ -774,6 +820,44 @@ nautilus_window_slot_set_property (GObject *object,
}
}
+static GMenu*
+real_get_extensions_background_menu (NautilusWindowSlot *self)
+{
+ NautilusWindowSlotPrivate *priv;
+
+ priv = nautilus_window_slot_get_instance_private (self);
+ return priv->extensions_background_menu;
+}
+
+GMenu*
+nautilus_window_slot_get_extensions_background_menu (NautilusWindowSlot *self)
+{
+ GMenu *menu = NULL;
+
+ g_object_get (self, "extensions-background-menu", &menu, NULL);
+
+ return menu;
+}
+
+static GMenu*
+real_get_templates_menu (NautilusWindowSlot *self)
+{
+ NautilusWindowSlotPrivate *priv;
+
+ priv = nautilus_window_slot_get_instance_private (self);
+ return priv->templates_menu;
+}
+
+GMenu*
+nautilus_window_slot_get_templates_menu (NautilusWindowSlot *self)
+{
+ GMenu *menu = NULL;
+
+ g_object_get (self, "templates-menu", &menu, NULL);
+
+ return menu;
+}
+
static void
nautilus_window_slot_get_property (GObject *object,
guint property_id,
@@ -807,7 +891,19 @@ nautilus_window_slot_get_property (GObject *object,
case PROP_TOOLBAR_MENU_SECTIONS:
{
- g_value_set_pointer (value, nautilus_window_slot_get_toolbar_menu_sections (self));
+ g_value_set_object (value, nautilus_window_slot_get_toolbar_menu_sections (self));
+ }
+ break;
+
+ case PROP_EXTENSIONS_BACKGROUND_MENU:
+ {
+ g_value_set_object (value, real_get_extensions_background_menu (self));
+ }
+ break;
+
+ case PROP_TEMPLATES_MENU:
+ {
+ g_value_set_object (value, real_get_templates_menu (self));
}
break;
@@ -2879,6 +2975,8 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
{
g_binding_unbind (priv->searching_binding);
g_binding_unbind (priv->selection_binding);
+ g_binding_unbind (priv->extensions_background_menu_binding);
+ g_binding_unbind (priv->templates_menu_binding);
widget = GTK_WIDGET (priv->content_view);
gtk_widget_destroy (widget);
g_object_unref (priv->content_view);
@@ -2900,8 +2998,16 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
priv->selection_binding = g_object_bind_property (priv->content_view, "selection",
self, "selection",
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+ priv->extensions_background_menu_binding = g_object_bind_property (priv->content_view,
"extensions-background-menu",
+ self,
"extensions-background-menu",
+ G_BINDING_DEFAULT |
G_BINDING_SYNC_CREATE);
+ priv->templates_menu_binding = g_object_bind_property (priv->content_view, "templates-menu",
+ self, "templates-menu",
+ G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TOOLBAR_MENU_SECTIONS]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EXTENSIONS_BACKGROUND_MENU]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TEMPLATES_MENU]);
}
done:
@@ -2957,6 +3063,9 @@ nautilus_window_slot_dispose (GObject *object)
g_clear_pointer (&priv->searching_binding, g_binding_unbind);
g_clear_pointer (&priv->selection_binding, g_binding_unbind);
+ g_clear_pointer (&priv->extensions_background_menu_binding, g_binding_unbind);
+ g_clear_pointer (&priv->templates_menu_binding, g_binding_unbind);
+
if (priv->content_view)
{
gtk_widget_destroy (GTK_WIDGET (priv->content_view));
@@ -3095,6 +3204,20 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
"The menu sections to add to the toolbar menu for this slot",
G_PARAM_READABLE);
+ properties[PROP_EXTENSIONS_BACKGROUND_MENU] =
+ g_param_spec_object ("extensions-background-menu",
+ "Background menu of extensions",
+ "Proxy property from the view for the background menu for extensions",
+ G_TYPE_MENU,
+ G_PARAM_READWRITE);
+
+ properties[PROP_TEMPLATES_MENU] =
+ g_param_spec_object ("templates-menu",
+ "Templates menu",
+ "Proxy property from the view for the templates menu",
+ G_TYPE_MENU,
+ G_PARAM_READWRITE);
+
properties[PROP_LOCATION] =
g_param_spec_object ("location",
"Current location visible on the slot",
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index 883da5762..6c6e46bda 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -100,6 +100,10 @@ GIcon* nautilus_window_slot_get_icon (NautilusWindowSlot *
NautilusToolbarMenuSections * nautilus_window_slot_get_toolbar_menu_sections (NautilusWindowSlot *slot);
+GMenu* nautilus_window_slot_get_templates_menu (NautilusWindowSlot *self);
+
+GMenu* nautilus_window_slot_get_extensions_background_menu (NautilusWindowSlot *self);
+
gboolean nautilus_window_slot_get_active (NautilusWindowSlot *slot);
void nautilus_window_slot_set_active (NautilusWindowSlot *slot,
diff --git a/src/resources/ui/nautilus-pathbar-context-menu.ui
b/src/resources/ui/nautilus-pathbar-context-menu.ui
index 85c1c033e..e42527673 100644
--- a/src/resources/ui/nautilus-pathbar-context-menu.ui
+++ b/src/resources/ui/nautilus-pathbar-context-menu.ui
@@ -1,128 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
- <requires lib="gtk+" version="3.20"/>
- <object class="GtkPopoverMenu" id="menu_popover">
- <property name="can_focus">False</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_left">10</property>
- <property name="margin_right">10</property>
- <property name="margin_top">10</property>
- <property name="margin_bottom">10</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">view.new-folder</property>
- <property name="text" translatable="yes">New Folder…</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">view.bookmark</property>
- <property name="text" translatable="yes">Add to Bookmarks</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">view.star</property>
- <property name="text" translatable="yes">Star</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">view.paste</property>
- <property name="text" translatable="yes">Paste</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">view.select-all</property>
- <property name="text" translatable="yes">Select All</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">6</property>
- </packing>
- </child>
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">view.current-directory-properties</property>
- <property name="text" translatable="yes">Properties</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">7</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="submenu">main</property>
- </packing>
- </child>
- </object>
+ <menu id="current-view-menu">
+ <item>
+ <attribute name="label" translatable="yes">New _Folder…</attribute>
+ <attribute name="action">view.new-folder</attribute>
+ </item>
+ <submenu>
+ <attribute name="id">templates-submenu</attribute>
+ <attribute name="label" translatable="yes">New _Document</attribute>
+ <attribute name="action">view.new-document</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </submenu>
+ <item>
+ <attribute name="label" translatable="yes">Add to _Bookmarks</attribute>
+ <attribute name="action">view.bookmark</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes" context="menu item" comments="Marks a file as starred
(starred)">Star</attribute>
+ <attribute name="action">view.star</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes" context="menu item" comments="Unmarks a file as starred
(starred)">Unstar</attribute>
+ <attribute name="action">view.unstar</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </item>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Paste</attribute>
+ <attribute name="action">view.paste</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Select _All</attribute>
+ <attribute name="action">view.select-all</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">P_roperties</attribute>
+ <attribute name="action">view.current-directory-properties</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </item>
+ </section>
+ <section>
+ <attribute name="id">extensions</attribute>
+ </section>
+ </menu>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]