[libhandy/tabs: 43/62] Fix + more docs + less signals
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/tabs: 43/62] Fix + more docs + less signals
- Date: Sat, 12 Sep 2020 19:27:44 +0000 (UTC)
commit 004870f975966b94eb6b7fcfbbd51a71eb8aa065
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Sep 10 21:30:13 2020 +0500
Fix + more docs + less signals
src/hdy-tab-bar.c | 57 +++++++++++++++++-----------
src/hdy-tab-view.c | 109 ++---------------------------------------------------
src/hdy-tab-view.h | 3 --
3 files changed, 39 insertions(+), 130 deletions(-)
---
diff --git a/src/hdy-tab-bar.c b/src/hdy-tab-bar.c
index 110e5b17..59a2611c 100644
--- a/src/hdy-tab-bar.c
+++ b/src/hdy-tab-bar.c
@@ -120,31 +120,46 @@ notify_selected_page_cb (HdyTabBar *self)
}
static void
-page_pinned_cb (HdyTabBar *self,
- HdyTabPage *page)
+notify_pinned_cb (HdyTabPage *page,
+ GParamSpec *pspec,
+ HdyTabBar *self)
{
- gboolean should_focus = hdy_tab_box_is_page_focused (self->scroll_box, page);
+ HdyTabBox *from, *to;
+ gboolean should_focus;
- hdy_tab_box_remove_page (self->scroll_box, page);
- hdy_tab_box_add_page (self->pinned_box, page,
- hdy_tab_view_get_n_pinned_pages (self->view));
+ if (hdy_tab_page_get_pinned (page)) {
+ from = self->scroll_box;
+ to = self->pinned_box;
+ } else {
+ from = self->pinned_box;
+ to = self->scroll_box;
+ }
+
+ should_focus = hdy_tab_box_is_page_focused (from, page);
+
+ hdy_tab_box_remove_page (from, page);
+ hdy_tab_box_add_page (to, page, hdy_tab_view_get_n_pinned_pages (self->view));
if (should_focus)
- hdy_tab_box_try_focus_selected_tab (self->pinned_box);
+ hdy_tab_box_try_focus_selected_tab (to);
}
static void
-page_unpinned_cb (HdyTabBar *self,
- HdyTabPage *page)
+page_added_cb (HdyTabBar *self,
+ HdyTabPage *page,
+ gint position)
{
- gboolean should_focus = hdy_tab_box_is_page_focused (self->pinned_box, page);
-
- hdy_tab_box_remove_page (self->pinned_box, page);
- hdy_tab_box_add_page (self->scroll_box, page,
- hdy_tab_view_get_n_pinned_pages (self->view));
+ g_signal_connect_object (page, "notify::pinned",
+ G_CALLBACK (notify_pinned_cb), self,
+ 0);
+}
- if (should_focus)
- hdy_tab_box_try_focus_selected_tab (self->scroll_box);
+static void
+page_removed_cb (HdyTabBox *self,
+ HdyTabPage *page,
+ gint position)
+{
+ g_signal_handlers_disconnect_by_func (page, notify_pinned_cb, self);
}
static void
@@ -581,8 +596,6 @@ hdy_tab_bar_set_view (HdyTabBar *self,
if (self->view) {
g_signal_handlers_disconnect_by_func (self->view, update_autohide_cb, self);
g_signal_handlers_disconnect_by_func (self->view, notify_selected_page_cb, self);
- g_signal_handlers_disconnect_by_func (self->view, page_pinned_cb, self);
- g_signal_handlers_disconnect_by_func (self->view, page_unpinned_cb, self);
}
g_set_object (&self->view, view);
@@ -600,11 +613,11 @@ hdy_tab_bar_set_view (HdyTabBar *self,
g_signal_connect_object (self->view, "notify::selected-page",
G_CALLBACK (notify_selected_page_cb), self,
G_CONNECT_SWAPPED);
- g_signal_connect_object (self->view, "page-pinned",
- G_CALLBACK (page_pinned_cb), self,
+ g_signal_connect_object (self->view, "page-added",
+ G_CALLBACK (page_added_cb), self,
G_CONNECT_SWAPPED);
- g_signal_connect_object (self->view, "page-unpinned",
- G_CALLBACK (page_unpinned_cb), self,
+ g_signal_connect_object (self->view, "page-removed",
+ G_CALLBACK (page_removed_cb), self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->view, "destroy",
G_CALLBACK (view_destroy_cb), self,
diff --git a/src/hdy-tab-view.c b/src/hdy-tab-view.c
index 0ec1cc2a..2357fdc3 100644
--- a/src/hdy-tab-view.c
+++ b/src/hdy-tab-view.c
@@ -101,8 +101,6 @@ enum {
SIGNAL_PAGE_ADDED,
SIGNAL_PAGE_REMOVED,
SIGNAL_PAGE_REORDERED,
- SIGNAL_PAGE_PINNED,
- SIGNAL_PAGE_UNPINNED,
SIGNAL_CLOSE_PAGE,
SIGNAL_SETUP_MENU,
SIGNAL_CREATE_WINDOW,
@@ -1022,9 +1020,9 @@ hdy_tab_view_class_init (HdyTabViewClass *klass)
* HdyTabView::page-reordered:
* @self: a #HdyTabView
* @page: a page of @self
- * @position: TBD
+ * @position: the position @page was moved to, starting at 0
*
- * TBD
+ * This signal is emitted after @page has been reordered to @position.
*
* Since: 1.2
*/
@@ -1038,44 +1036,6 @@ hdy_tab_view_class_init (HdyTabViewClass *klass)
2,
HDY_TYPE_TAB_PAGE, G_TYPE_INT);
- /**
- * HdyTabView::page-pinned:
- * @self: a #HdyTabView
- * @page: a page of @self
- *
- * TBD
- *
- * Since: 1.2
- */
- signals[SIGNAL_PAGE_PINNED] =
- g_signal_new ("page-pinned",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- HDY_TYPE_TAB_PAGE);
-
- /**
- * HdyTabView::page-unpinned:
- * @self: a #HdyTabView
- * @page: a page of @self
- *
- * TBD
- *
- * Since: 1.2
- */
- signals[SIGNAL_PAGE_UNPINNED] =
- g_signal_new ("page-unpinned",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- HDY_TYPE_TAB_PAGE);
-
/**
* HdyTabView::close-page:
* @self: a #HdyTabView
@@ -2067,62 +2027,6 @@ hdy_tab_view_set_group (HdyTabView *self,
GSList *group)
{
g_return_if_fail (HDY_IS_TAB_VIEW (self));
-
- if (g_slist_find (group, self))
- return;
-
- if (self->group) {
- GSList *l;
-
- self->group = g_slist_remove (self->group, self);
-
- for (l = self->group; l; l = l->next) {
- HdyTabView *view = l->data;
-
- view->group = self->group;
- }
- }
-
- self->group = g_slist_prepend (group, self);
-
- if (group) {
- GSList *l;
-
- for (l = group; l; l = l->next) {
- HdyTabView *view = l->data;
-
- view->group = self->group;
- }
- }
-}
-
-/**
- * hdy_tab_view_join_group:
- * @self: a #HdyTabView
- * @source: TBD
- *
- * TBD doesn't work
- *
- * Since: 1.2
- */
-void
-hdy_tab_view_join_group (HdyTabView *self,
- HdyTabView *source)
-{
- g_return_if_fail (HDY_IS_TAB_VIEW (self));
- g_return_if_fail (source == NULL || HDY_IS_TAB_VIEW (source));
-
- if (source) {
- GSList *group = hdy_tab_view_get_group (source);
-
- if (!group) {
- hdy_tab_view_set_group (source, NULL);
- group = hdy_tab_view_get_group (source);
- }
-
- hdy_tab_view_set_group (self, group);
- } else
- hdy_tab_view_set_group (self, NULL);
}
/**
@@ -2148,7 +2052,7 @@ hdy_tab_view_join_group (HdyTabView *self,
* following order:
*
* 1. #HdyTabPage:secondary-icon
- * 2. A spinner if #HdyTabPage::loading is %TRUE
+ * 2. A spinner if #HdyTabPage:loading is %TRUE
* 3. #HdyTabPage:icon
* 4. #HdyTabView:default-icon
*
@@ -2183,8 +2087,6 @@ hdy_tab_view_set_page_pinned (HdyTabView *self,
g_list_store_insert (self->pages, pos, page);
- set_page_pinned (page, pinned);
-
if (pinned)
pos++;
@@ -2195,10 +2097,7 @@ hdy_tab_view_set_page_pinned (HdyTabView *self,
set_n_pinned_pages (self, pos);
- if (pinned)
- g_signal_emit (self, signals[SIGNAL_PAGE_PINNED], 0, page);
- else
- g_signal_emit (self, signals[SIGNAL_PAGE_UNPINNED], 0, page);
+ set_page_pinned (page, pinned);
}
/**
diff --git a/src/hdy-tab-view.h b/src/hdy-tab-view.h
index ee1e6e1f..7deb99f5 100644
--- a/src/hdy-tab-view.h
+++ b/src/hdy-tab-view.h
@@ -120,9 +120,6 @@ GSList *hdy_tab_view_get_group (HdyTabView *self);
HDY_AVAILABLE_IN_ALL
void hdy_tab_view_set_group (HdyTabView *self,
GSList *group);
-HDY_AVAILABLE_IN_ALL
-void hdy_tab_view_join_group (HdyTabView *self,
- HdyTabView *source);
HDY_AVAILABLE_IN_ALL
void hdy_tab_view_set_page_pinned (HdyTabView *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]