summaryrefslogtreecommitdiff
path: root/src/bookmarks
diff options
context:
space:
mode:
authorAlexander Mikhaylenko <alexm@gnome.org>2019-10-06 16:23:37 +0500
committerAlexander Mikhaylenko <alexm@gnome.org>2019-10-06 14:19:33 +0000
commite81041298a27324582dd339a38300f0a1958e6c4 (patch)
tree252037fdb8125adcc119c977cbc1fb3f1a24a4d3 /src/bookmarks
parent4af85583a2a0dea48ef41d8cd4ba8f33c07fdf7f (diff)
downloadepiphany-e81041298a27324582dd339a38300f0a1958e6c4.tar.gz
Ensure tag scrolled window has correct size
Specify min-children-per-line so that its natural height always matches content, and make bookmarks dialog unresizable so that it follows the flowbox height. Since scrollbar minimum height is larger than one row of tags, explicitly hide scrollbar when there are less than 3 tags, i.e. when there is only one row.
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmark-properties-grid.c20
-rw-r--r--src/bookmarks/ephy-bookmark-row.c1
2 files changed, 21 insertions, 0 deletions
diff --git a/src/bookmarks/ephy-bookmark-properties-grid.c b/src/bookmarks/ephy-bookmark-properties-grid.c
index 8a229b80c..1a4333ee8 100644
--- a/src/bookmarks/ephy-bookmark-properties-grid.c
+++ b/src/bookmarks/ephy-bookmark-properties-grid.c
@@ -48,6 +48,7 @@ struct _EphyBookmarkPropertiesGrid {
GtkWidget *address_entry;
GtkWidget *popover_tags_label;
GtkWidget *tags_box;
+ GtkWidget *tags_scrolled_window;
GtkWidget *add_tag_entry;
GtkWidget *add_tag_button;
GtkWidget *remove_bookmark_button;
@@ -92,6 +93,21 @@ flow_box_sort_func (GtkFlowBoxChild *child1,
}
static void
+update_tags_scrollbar (EphyBookmarkPropertiesGrid *self)
+{
+ g_autoptr (GList) children = NULL;
+ gint n_tags;
+
+ children = gtk_container_get_children (GTK_CONTAINER (self->tags_box));
+ n_tags = g_list_length (children);
+
+ g_object_set (self->tags_scrolled_window,
+ "vscrollbar-policy",
+ (n_tags > 3) ? GTK_POLICY_AUTOMATIC : GTK_POLICY_NEVER,
+ NULL);
+}
+
+static void
ephy_bookmark_properties_grid_tags_box_child_activated_cb (EphyBookmarkPropertiesGrid *self,
GtkFlowBoxChild *child,
GtkFlowBox *flow_box)
@@ -138,6 +154,7 @@ ephy_bookmark_properties_grid_tag_widget_button_clicked_cb (EphyBookmarkProperti
flow_box_child = gtk_widget_get_parent (box);
gtk_widget_destroy (flow_box_child);
+ update_tags_scrollbar (self);
}
static GtkWidget *
@@ -227,6 +244,7 @@ ephy_bookmarks_properties_grid_actions_add_tag (GSimpleAction *action,
/* Create a new widget for the new tag */
widget = ephy_bookmark_properties_grid_create_tag_widget (self, text, TRUE);
gtk_flow_box_insert (GTK_FLOW_BOX (self->tags_box), widget, -1);
+ update_tags_scrollbar (self);
/* Empty entry and disable button's action until new text is inserted */
gtk_entry_set_text (GTK_ENTRY (self->add_tag_entry), "");
@@ -406,6 +424,7 @@ ephy_bookmark_properties_grid_constructed (GObject *object)
widget = ephy_bookmark_properties_grid_create_tag_widget (self, tag, selected);
gtk_flow_box_insert (GTK_FLOW_BOX (self->tags_box), widget, -1);
}
+ update_tags_scrollbar (self);
g_signal_connect_object (self->tags_box, "child-activated",
G_CALLBACK (ephy_bookmark_properties_grid_tags_box_child_activated_cb),
@@ -470,6 +489,7 @@ ephy_bookmark_properties_grid_class_init (EphyBookmarkPropertiesGridClass *klass
gtk_widget_class_bind_template_child (widget_class, EphyBookmarkPropertiesGrid, address_entry);
gtk_widget_class_bind_template_child (widget_class, EphyBookmarkPropertiesGrid, popover_tags_label);
gtk_widget_class_bind_template_child (widget_class, EphyBookmarkPropertiesGrid, tags_box);
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkPropertiesGrid, tags_scrolled_window);
gtk_widget_class_bind_template_child (widget_class, EphyBookmarkPropertiesGrid, add_tag_entry);
gtk_widget_class_bind_template_child (widget_class, EphyBookmarkPropertiesGrid, add_tag_button);
gtk_widget_class_bind_template_child (widget_class, EphyBookmarkPropertiesGrid, remove_bookmark_button);
diff --git a/src/bookmarks/ephy-bookmark-row.c b/src/bookmarks/ephy-bookmark-row.c
index fe4979276..db79b4d5e 100644
--- a/src/bookmarks/ephy-bookmark-row.c
+++ b/src/bookmarks/ephy-bookmark-row.c
@@ -61,6 +61,7 @@ ephy_bookmark_row_button_clicked_cb (EphyBookmarkRow *row,
"title", _("Bookmark Properties"),
"transient-for", GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (row))),
"use-header-bar", TRUE,
+ "resizable", FALSE,
"modal", TRUE,
NULL);