[libhandy/tabs: 10/62] Consistent positioning
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/tabs: 10/62] Consistent positioning
- Date: Sat, 12 Sep 2020 19:27:43 +0000 (UTC)
commit 94d0300b3d5f41386cee04e24e516edfaa0bfdd2
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Sep 4 22:40:44 2020 +0500
Consistent positioning
src/hdy-tab-box.c | 11 ++++++++---
src/hdy-tab-view.c | 17 +++++------------
2 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/hdy-tab-box.c b/src/hdy-tab-box.c
index eab12d4e..ed85cc9d 100644
--- a/src/hdy-tab-box.c
+++ b/src/hdy-tab-box.c
@@ -432,6 +432,9 @@ resize_animation_done_cb (gpointer user_data)
{
HdyTabBox *self = HDY_TAB_BOX (user_data);
+ self->end_padding = 0;
+ gtk_widget_queue_resize (GTK_WIDGET (self));
+
g_clear_object (&self->resize_animation);
}
@@ -1777,6 +1780,7 @@ do_drag_drop (HdyTabBox *self,
GdkAtom target, tab_target;
HdyTabBox *source_tab_box;
HdyTabPage *page;
+ gint offset;
target = gtk_drag_dest_find_target (GTK_WIDGET (self), context, NULL);
tab_target = gdk_atom_intern_static_string ("HDY_TAB");
@@ -1790,6 +1794,7 @@ do_drag_drop (HdyTabBox *self,
return GDK_EVENT_PROPAGATE;
page = source_tab_box->detached_page;
+ offset = (self->pinned ? 0 : hdy_tab_view_get_n_pinned_pages (self->view));
if (self->reorder_placeholder) {
replace_placeholder (self, page);
@@ -1797,11 +1802,11 @@ do_drag_drop (HdyTabBox *self,
g_signal_handlers_block_by_func (self->view, add_page, self);
- hdy_tab_view_attach_page (self->view, page, self->reorder_index);
+ hdy_tab_view_attach_page (self->view, page, self->reorder_index + offset);
g_signal_handlers_unblock_by_func (self->view, add_page, self);
} else {
- hdy_tab_view_attach_page (self->view, page, self->reorder_index);
+ hdy_tab_view_attach_page (self->view, page, self->reorder_index + offset);
}
source_tab_box->detached_page = NULL;
@@ -2718,7 +2723,7 @@ hdy_tab_box_drag_begin (GtkWidget *widget,
update_hover (self);
gtk_widget_hide (GTK_WIDGET (detached_tab->tab));
- self->detached_index = g_list_index (self->tabs, detached_tab);
+ self->detached_index = hdy_tab_view_get_page_position (self->view, detached_tab->page);
hdy_tab_view_start_drag (self->view);
hdy_tab_view_detach_page (self->view, self->detached_page);
diff --git a/src/hdy-tab-view.c b/src/hdy-tab-view.c
index e616b36d..5649fc82 100644
--- a/src/hdy-tab-view.c
+++ b/src/hdy-tab-view.c
@@ -494,9 +494,6 @@ attach_page (HdyTabView *self,
gboolean pinned = hdy_tab_page_get_pinned (page);
GtkWidget *content = hdy_tab_page_get_content (page);
- if (!pinned)
- position += self->n_pinned_pages;
-
g_list_store_insert (self->pages, position, page);
gtk_container_add (GTK_CONTAINER (self->stack), content);
@@ -541,11 +538,7 @@ insert_page (HdyTabView *self,
gint position,
gboolean pinned)
{
- HdyTabPage *page;
-
- g_assert (position <= self->n_pages);
-
- page = g_object_new (HDY_TYPE_TAB_PAGE, "content", content, NULL);
+ HdyTabPage *page = g_object_new (HDY_TYPE_TAB_PAGE, "content", content, NULL);
set_page_pinned (page, pinned);
@@ -2111,7 +2104,7 @@ hdy_tab_view_insert (HdyTabView *self,
{
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (content), NULL);
- g_return_val_if_fail (position >= 0, NULL);
+ g_return_val_if_fail (position >= self->n_pinned_pages, NULL);
g_return_val_if_fail (position <= self->n_pages, NULL);
return insert_page (self, content, position, FALSE);
@@ -2135,7 +2128,7 @@ hdy_tab_view_prepend (HdyTabView *self,
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (content), NULL);
- return insert_page (self, content, 0, FALSE);
+ return insert_page (self, content, self->n_pinned_pages, FALSE);
}
/**
@@ -2156,7 +2149,7 @@ hdy_tab_view_append (HdyTabView *self,
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (content), NULL);
- return insert_page (self, content, self->n_pages - self->n_pinned_pages, FALSE);
+ return insert_page (self, content, self->n_pages, FALSE);
}
/**
@@ -2179,7 +2172,7 @@ hdy_tab_view_insert_pinned (HdyTabView *self,
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (content), NULL);
g_return_val_if_fail (position >= 0, NULL);
- g_return_val_if_fail (position <= self->n_pages, NULL);
+ g_return_val_if_fail (position <= self->n_pinned_pages, NULL);
return insert_page (self, content, position, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]