[nautilus/gtk4-preparation-trunk: 6/64] pathbar: Move current location menu to discrete button
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gtk4-preparation-trunk: 6/64] pathbar: Move current location menu to discrete button
- Date: Thu, 23 Dec 2021 02:10:15 +0000 (UTC)
commit 07973ed61c9258ae15a45dca0c454c873f0fb65f
Author: António Fernandes <antoniof gnome org>
Date: Fri Nov 26 14:24:24 2021 +0000
pathbar: Move current location menu to discrete button
This should address discoverability concerns and follows latest design.
src/nautilus-pathbar.c | 54 +++++++++++++++++-------------------
src/resources/css/Adwaita.css | 17 ++++++++----
src/resources/ui/nautilus-toolbar.ui | 3 --
3 files changed, 37 insertions(+), 37 deletions(-)
---
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 4d8bf618a..d761dcad6 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -73,7 +73,6 @@ typedef struct
GtkWidget *image;
GtkWidget *label;
GtkWidget *separator;
- GtkWidget *disclosure_arrow;
GtkWidget *container;
NautilusPathBar *path_bar;
@@ -101,6 +100,7 @@ struct _NautilusPathBar
NautilusFile *context_menu_file;
GtkPopover *current_view_menu_popover;
+ GtkWidget *current_view_menu_button;
GtkPopover *button_menu_popover;
GMenu *current_view_menu;
GMenu *extensions_section;
@@ -214,6 +214,15 @@ on_adjustment_changed (GtkAdjustment *adjustment)
gtk_adjustment_set_value (adjustment, gtk_adjustment_get_upper (adjustment));
}
+static gboolean
+bind_current_view_menu_model_to_popover (NautilusPathBar *self)
+{
+ gtk_popover_bind_model (self->current_view_menu_popover,
+ G_MENU_MODEL (self->current_view_menu),
+ NULL);
+ return G_SOURCE_REMOVE;
+}
+
static void
nautilus_path_bar_init (NautilusPathBar *self)
{
@@ -235,6 +244,12 @@ nautilus_path_bar_init (NautilusPathBar *self)
self->buttons_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (self->scrolled), self->buttons_box);
+ self->current_view_menu_button = gtk_menu_button_new ();
+ gtk_button_set_child (GTK_BUTTON (self->current_view_menu_button),
+ gtk_image_new_from_icon_name ("view-more-symbolic",
+ GTK_ICON_SIZE_MENU));
+ gtk_box_append (GTK_BOX (self), self->current_view_menu_button);
+
builder = gtk_builder_new ();
/* Add context menu for pathbar buttons */
@@ -264,8 +279,16 @@ nautilus_path_bar_init (NautilusPathBar *self)
g_object_unref (builder);
+ gtk_menu_button_set_popover (GTK_MENU_BUTTON (self->current_view_menu_button),
+ GTK_WIDGET (self->current_view_menu_popover));
+ bind_current_view_menu_model_to_popover (self);
+
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)),
+ "linked");
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)),
"nautilus-path-bar");
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self->buttons_box)),
+ "path-buttons-box");
/* Action group */
self->action_group = G_ACTION_GROUP (g_simple_action_group_new ());
@@ -459,13 +482,13 @@ nautilus_path_bar_set_templates_menu (NautilusPathBar *self,
{
/* Workaround to avoid leaking duplicated GtkStack pages each time the
* templates menu is set. Unbinding the model is the only way to clear
- * all children. For that reason, we need to rebind the popover before
- * it is shown again.
+ * all children. After that's done, on idle, we rebind it.
* See https://gitlab.gnome.org/GNOME/nautilus/-/issues/1705 */
gtk_popover_bind_model (self->current_view_menu_popover, NULL, NULL);
}
nautilus_gmenu_set_from_model (self->templates_submenu, menu);
+ g_idle_add ((GSourceFunc) bind_current_view_menu_model_to_popover, self);
}
/* Changes the icons wherever it is needed */
@@ -564,14 +587,6 @@ button_clicked_cb (GtkButton *button,
{
if (g_file_equal (button_data->path, self->current_path))
{
- /* Workaround to avoid leaking duplicated GtkStack pages each time the
- * templates menu is set. Unbinding the model is the only way to clear
- * all children. For that reason, we need to rebind the popover before
- * it is shown again.
- * See https://gitlab.gnome.org/GNOME/nautilus/-/issues/1705 */
- gtk_popover_bind_model (self->current_view_menu_popover,
- G_MENU_MODEL (self->current_view_menu),
- NULL);
gtk_popover_popup (self->current_view_menu_popover);
}
else
@@ -699,14 +714,6 @@ on_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
{
if (g_file_equal (button_data->path, self->current_path))
{
- /* Workaround to avoid leaking duplicated GtkStack pages each time the
- * templates menu is set. Unbinding the model is the only way to clear
- * all children. For that reason, we need to rebind the popover before
- * it is shown again.
- * See https://gitlab.gnome.org/GNOME/nautilus/-/issues/1705 */
- gtk_popover_bind_model (self->current_view_menu_popover,
- G_MENU_MODEL (self->current_view_menu),
- NULL);
gtk_popover_popup (self->current_view_menu_popover);
}
else
@@ -1097,15 +1104,12 @@ make_button_data (NautilusPathBar *self,
case OTHER_LOCATIONS_BUTTON:
{
button_data->label = gtk_label_new (NULL);
- button_data->disclosure_arrow = gtk_image_new_from_icon_name ("pan-down-symbolic",
- GTK_ICON_SIZE_MENU);
child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
button_data->container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_append (GTK_BOX (button_data->container), button_data->button);
gtk_box_append (GTK_BOX (child), button_data->image);
gtk_box_append (GTK_BOX (child), button_data->label);
- gtk_box_append (GTK_BOX (child), button_data->disclosure_arrow);
}
break;
@@ -1119,23 +1123,17 @@ make_button_data (NautilusPathBar *self,
gtk_style_context_add_class (gtk_widget_get_style_context (separator_label), "dim-label");
button_data->label = gtk_label_new (NULL);
child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
- button_data->disclosure_arrow = gtk_image_new_from_icon_name ("pan-down-symbolic",
- GTK_ICON_SIZE_MENU);
button_data->container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_append (GTK_BOX (button_data->container), separator_label);
gtk_box_append (GTK_BOX (button_data->container), button_data->button);
gtk_box_append (GTK_BOX (child), button_data->label);
- gtk_box_append (GTK_BOX (child), button_data->disclosure_arrow);
}
break;
}
- gtk_widget_set_no_show_all (button_data->disclosure_arrow, TRUE);
if (current_dir)
{
- gtk_widget_show (button_data->disclosure_arrow);
- gtk_popover_set_relative_to (self->current_view_menu_popover, button_data->button);
gtk_style_context_add_class (gtk_widget_get_style_context (button_data->button),
"current-dir");
}
diff --git a/src/resources/css/Adwaita.css b/src/resources/css/Adwaita.css
index d417367c3..2be30bf6b 100644
--- a/src/resources/css/Adwaita.css
+++ b/src/resources/css/Adwaita.css
@@ -50,27 +50,32 @@
/* Path bar */
-.path-bar-box {
- border-radius: 5px;
+.nautilus-path-bar scrolledwindow {
+ border-radius: 5px 0px 0px 5px;
border: 1px @borders solid;
+ border-right-width: 0px;
background-color: @theme_bg_color;
}
-.nautilus-path-bar button {
+.nautilus-path-bar > button,
+.path-buttons-box button {
+ margin: 0px;
+}
+
+.path-buttons-box button {
background-image: none;
box-shadow: none;
border-radius: 7px;
border-width: 0px;
- margin: 0px;
-gtk-icon-shadow: none;
}
-.nautilus-path-bar button:not(.current-dir):not(:backdrop):hover {
+.path-buttons-box button:not(.current-dir):not(:backdrop):hover {
background: alpha(@theme_fg_color, 0.15);
box-shadow: inset 0 0 0 2px @theme_bg_color;
}
-.nautilus-path-bar button:not(.current-dir):not(:backdrop):hover * {
+.path-buttons-box button:not(.current-dir):not(:backdrop):hover * {
opacity: 1;
}
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index 359f80aec..09145eac3 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -443,9 +443,6 @@
<object class="GtkBox" id="path_bar_container">
<property name="can_focus">False</property>
<property name="valign">center</property>
- <style>
- <class name="path-bar-box"/>
- </style>
</object>
<packing>
<property name="name">pathbar</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]