[libhandy/tabs: 9/62] Secondary icon && uint -> int
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/tabs: 9/62] Secondary icon && uint -> int
- Date: Sat, 12 Sep 2020 19:27:43 +0000 (UTC)
commit aaebebe2a1f900dc2de741b0b44ae05a2851f0b1
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Sep 4 21:58:30 2020 +0500
Secondary icon && uint -> int
src/hdy-tab-bar.c | 2 +-
src/hdy-tab-box-private.h | 2 +-
src/hdy-tab-box.c | 20 ++--
src/hdy-tab-view-private.h | 2 +-
src/hdy-tab-view.c | 209 ++++++++++++++++++++++++++-----------
src/hdy-tab-view.h | 24 +++--
src/hdy-tab.c | 71 +++++++++++--
src/hdy-tab.ui | 23 +++-
src/themes/Adwaita-dark.css | 8 ++
src/themes/Adwaita.css | 8 ++
src/themes/HighContrast.css | 8 ++
src/themes/HighContrastInverse.css | 8 ++
src/themes/_Adwaita-base.scss | 7 ++
src/themes/_fallback-base.scss | 6 ++
src/themes/_shared-base.scss | 14 +++
src/themes/fallback.css | 2 +
src/themes/shared.css | 4 +
17 files changed, 326 insertions(+), 92 deletions(-)
---
diff --git a/src/hdy-tab-bar.c b/src/hdy-tab-bar.c
index d307de48..3a9500ec 100644
--- a/src/hdy-tab-bar.c
+++ b/src/hdy-tab-bar.c
@@ -67,7 +67,7 @@ static GParamSpec *props[LAST_PROP];
static void
update_autohide_cb (HdyTabBar *self)
{
- guint n_tabs = 0, n_pinned_tabs = 0;
+ gint n_tabs = 0, n_pinned_tabs = 0;
gboolean is_dragging;
if (!self->view) {
diff --git a/src/hdy-tab-box-private.h b/src/hdy-tab-box-private.h
index 8f5ac06a..294b7eac 100644
--- a/src/hdy-tab-box-private.h
+++ b/src/hdy-tab-box-private.h
@@ -28,7 +28,7 @@ void hdy_tab_box_set_block_scrolling (HdyTabBox *self,
void hdy_tab_box_add_page (HdyTabBox *self,
HdyTabPage *page,
- guint position);
+ gint position);
void hdy_tab_box_remove_page (HdyTabBox *self,
HdyTabPage *page);
void hdy_tab_box_select_page (HdyTabBox *self,
diff --git a/src/hdy-tab-box.c b/src/hdy-tab-box.c
index 0fe15f4e..eab12d4e 100644
--- a/src/hdy-tab-box.c
+++ b/src/hdy-tab-box.c
@@ -121,7 +121,7 @@ struct _HdyTabBox
gint reorder_x;
gint reorder_y;
- guint reorder_index;
+ gint reorder_index;
gint reorder_window_x;
gboolean continue_reorder;
gboolean indirect_reordering;
@@ -138,7 +138,7 @@ struct _HdyTabBox
gint64 drag_autoscroll_prev_time;
HdyTabPage *detached_page;
- guint detached_index;
+ gint detached_index;
TabInfo *reorder_placeholder;
HdyTabPage *placeholder_page;
gboolean can_remove_placeholder;
@@ -1048,7 +1048,7 @@ animate_reorder_offset (HdyTabBox *self,
static void
reset_reorder_animations (HdyTabBox *self)
{
- guint i, original_index;
+ gint i, original_index;
GList *l;
if (!hdy_get_enable_animations (GTK_WIDGET (self)))
@@ -1073,10 +1073,10 @@ reset_reorder_animations (HdyTabBox *self)
static void
reorder_page (HdyTabBox *self,
HdyTabPage *page,
- guint index)
+ gint index)
{
GList *link;
- guint original_index;
+ gint original_index;
TabInfo *info, *dest_tab;
gboolean is_rtl;
@@ -1125,7 +1125,7 @@ reorder_page (HdyTabBox *self,
if (hdy_get_enable_animations (GTK_WIDGET (self)) &&
gtk_widget_get_mapped (GTK_WIDGET (self))) {
- guint i;
+ gint i;
if (self->reorder_index > original_index)
for (i = 0; i < self->reorder_index - original_index; i++) {
@@ -1156,7 +1156,7 @@ update_dragging (HdyTabBox *self)
{
gboolean is_rtl, after_selected, found_index;
gint x;
- guint i = 0;
+ gint i = 0;
GList *l;
if (!self->dragging)
@@ -1328,7 +1328,7 @@ end_dragging (HdyTabBox *self)
dest_tab = g_list_nth_data (self->tabs, self->reorder_index);
if (!self->indirect_reordering) {
- guint index;
+ gint index;
gdk_seat_ungrab (self->drag_seat);
self->drag_seat = NULL;
@@ -1431,7 +1431,7 @@ create_tab_info (HdyTabBox *self,
static void
add_page (HdyTabBox *self,
HdyTabPage *page,
- guint position)
+ gint position)
{
TabInfo *info;
GList *l;
@@ -3290,7 +3290,7 @@ hdy_tab_box_set_block_scrolling (HdyTabBox *self,
void
hdy_tab_box_add_page (HdyTabBox *self,
HdyTabPage *page,
- guint position)
+ gint position)
{
add_page (self, page, position);
}
diff --git a/src/hdy-tab-view-private.h b/src/hdy-tab-view-private.h
index 6ffce07e..f62c2a61 100644
--- a/src/hdy-tab-view-private.h
+++ b/src/hdy-tab-view-private.h
@@ -21,6 +21,6 @@ void hdy_tab_view_detach_page (HdyTabView *self,
HdyTabPage *page);
void hdy_tab_view_attach_page (HdyTabView *self,
HdyTabPage *page,
- guint position);
+ gint position);
G_END_DECLS
diff --git a/src/hdy-tab-view.c b/src/hdy-tab-view.c
index 80cac047..e616b36d 100644
--- a/src/hdy-tab-view.c
+++ b/src/hdy-tab-view.c
@@ -17,7 +17,7 @@ static const GtkTargetEntry dst_targets [] = {
* SECTION:hdy-tab-view
* @short_description: TBD
* @title: HdyTabView
- * @See_also: #HdyTabBar
+ * @See_also: #HdyTabBar, #HdyTabViewGroup
*
* TBD
*
@@ -36,6 +36,7 @@ struct _HdyTabPage
GIcon *icon;
gboolean loading;
GIcon *secondary_icon;
+ gboolean secondary_icon_activatable;
gboolean needs_attention;
};
@@ -51,6 +52,7 @@ enum {
PAGE_PROP_ICON,
PAGE_PROP_LOADING,
PAGE_PROP_SECONDARY_ICON,
+ PAGE_PROP_SECONDARY_ICON_ACTIVATABLE,
PAGE_PROP_NEEDS_ATTENTION,
LAST_PAGE_PROP
};
@@ -64,8 +66,8 @@ struct _HdyTabView
GtkStack *stack;
GListStore *pages;
- guint n_pages;
- guint n_pinned_pages;
+ gint n_pages;
+ gint n_pinned_pages;
HdyTabPage *selected_page;
GIcon *default_icon;
GMenuModel *menu_model;
@@ -98,6 +100,7 @@ enum {
SIGNAL_PAGE_UNPINNED,
SIGNAL_SETUP_MENU,
SIGNAL_CREATE_WINDOW,
+ SIGNAL_SECONDARY_ICON_ACTIVATED,
SIGNAL_SELECT_PAGE,
SIGNAL_REORDER_PAGE,
SIGNAL_LAST_SIGNAL,
@@ -201,6 +204,10 @@ hdy_tab_page_get_property (GObject *object,
g_value_set_object (value, hdy_tab_page_get_secondary_icon (self));
break;
+ case PAGE_PROP_SECONDARY_ICON_ACTIVATABLE:
+ g_value_set_boolean (value, hdy_tab_page_get_secondary_icon_activatable (self));
+ break;
+
case PAGE_PROP_NEEDS_ATTENTION:
g_value_set_boolean (value, hdy_tab_page_get_needs_attention (self));
break;
@@ -243,6 +250,10 @@ hdy_tab_page_set_property (GObject *object,
hdy_tab_page_set_secondary_icon (self, g_value_get_object (value));
break;
+ case PAGE_PROP_SECONDARY_ICON_ACTIVATABLE:
+ hdy_tab_page_set_secondary_icon_activatable (self, g_value_get_boolean (value));
+ break;
+
case PAGE_PROP_NEEDS_ATTENTION:
hdy_tab_page_set_needs_attention (self, g_value_get_boolean (value));
break;
@@ -374,6 +385,20 @@ hdy_tab_page_class_init (HdyTabPageClass *klass)
G_TYPE_ICON,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * HdyTabPage:secondary-icon-activatable:
+ *
+ * TBD
+ *
+ * Since: 1.2
+ */
+ page_props[PAGE_PROP_SECONDARY_ICON_ACTIVATABLE] =
+ g_param_spec_boolean ("secondary-icon-activatable",
+ _("Secondary Icon Activatable"),
+ _("Secondary Icon Activatable"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
/**
* HdyTabPage:needs-attention:
*
@@ -423,7 +448,7 @@ set_is_dragging (HdyTabView *self,
static void
set_n_pages (HdyTabView *self,
- guint n_pages)
+ gint n_pages)
{
if (n_pages == self->n_pages)
return;
@@ -435,7 +460,7 @@ set_n_pages (HdyTabView *self,
static void
set_n_pinned_pages (HdyTabView *self,
- guint n_pinned_pages)
+ gint n_pinned_pages)
{
if (n_pinned_pages == self->n_pinned_pages)
return;
@@ -464,7 +489,7 @@ check_close_window (HdyTabView *self)
static void
attach_page (HdyTabView *self,
HdyTabPage *page,
- guint position)
+ gint position)
{
gboolean pinned = hdy_tab_page_get_pinned (page);
GtkWidget *content = hdy_tab_page_get_content (page);
@@ -490,7 +515,7 @@ static void
detach_page (HdyTabView *self,
HdyTabPage *page)
{
- guint pos = hdy_tab_view_get_page_position (self, page);
+ gint pos = hdy_tab_view_get_page_position (self, page);
if (page == self->selected_page)
if (!hdy_tab_view_select_next_page (self))
@@ -513,7 +538,7 @@ detach_page (HdyTabView *self,
static HdyTabPage *
insert_page (HdyTabView *self,
GtkWidget *content,
- guint position,
+ gint position,
gboolean pinned)
{
HdyTabPage *page;
@@ -716,11 +741,11 @@ hdy_tab_view_get_property (GObject *object,
switch (prop_id) {
case PROP_N_PAGES:
- g_value_set_uint (value, hdy_tab_view_get_n_pages (self));
+ g_value_set_int (value, hdy_tab_view_get_n_pages (self));
break;
case PROP_N_PINNED_PAGES:
- g_value_set_uint (value, hdy_tab_view_get_n_pinned_pages (self));
+ g_value_set_int (value, hdy_tab_view_get_n_pinned_pages (self));
break;
case PROP_IS_DRAGGING:
@@ -794,11 +819,11 @@ hdy_tab_view_class_init (HdyTabViewClass *klass)
* Since: 1.2
*/
props[PROP_N_PAGES] =
- g_param_spec_uint ("n-pages",
- _("Number of Pages"),
- _("Number of Pages"),
- 0, G_MAXUINT, 0,
- G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
+ g_param_spec_int ("n-pages",
+ _("Number of Pages"),
+ _("Number of Pages"),
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
/**
* HdyTabView:n-pinned-pages:
@@ -808,11 +833,11 @@ hdy_tab_view_class_init (HdyTabViewClass *klass)
* Since: 1.2
*/
props[PROP_N_PINNED_PAGES] =
- g_param_spec_uint ("n-pinned-pages",
- _("Number of Pinned Pages"),
- _("Number of Pinned Pages"),
- 0, G_MAXUINT, 0,
- G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
+ g_param_spec_int ("n-pinned-pages",
+ _("Number of Pinned Pages"),
+ _("Number of Pinned Pages"),
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
/**
* HdyTabView:is-dragging:
@@ -904,7 +929,7 @@ hdy_tab_view_class_init (HdyTabViewClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE,
2,
- HDY_TYPE_TAB_PAGE, G_TYPE_UINT);
+ HDY_TYPE_TAB_PAGE, G_TYPE_INT);
/**
* HdyTabView::page-removed:
@@ -943,7 +968,7 @@ hdy_tab_view_class_init (HdyTabViewClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE,
2,
- HDY_TYPE_TAB_PAGE, G_TYPE_UINT);
+ HDY_TYPE_TAB_PAGE, G_TYPE_INT);
/**
* HdyTabView::page-pinned:
@@ -1022,6 +1047,25 @@ hdy_tab_view_class_init (HdyTabViewClass *klass)
HDY_TYPE_TAB_VIEW,
0);
+ /**
+ * HdyTabView::secondary-icon-activated:
+ * @self: a #HdyTabView
+ * @page: TBD
+ *
+ * TBD
+ *
+ * Since: 1.2
+ */
+ signals[SIGNAL_SECONDARY_ICON_ACTIVATED] =
+ g_signal_new ("secondary-icon-activated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ HDY_TYPE_TAB_PAGE);
+
signals[SIGNAL_SELECT_PAGE] =
g_signal_new ("select-page",
G_TYPE_FROM_CLASS (klass),
@@ -1361,6 +1405,49 @@ hdy_tab_page_set_secondary_icon (HdyTabPage *self,
g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_SECONDARY_ICON]);
}
+/**
+ * hdy_tab_page_get_secondary_icon_activatable:
+ * @self: a #HdyTabPage
+ *
+ * TBD
+ *
+ * Returns: TBD
+ *
+ * Since: 1.2
+ */
+gboolean
+hdy_tab_page_get_secondary_icon_activatable (HdyTabPage *self)
+{
+ g_return_val_if_fail (HDY_IS_TAB_PAGE (self), FALSE);
+
+ return self->secondary_icon_activatable;
+}
+
+/**
+ * hdy_tab_page_set_secondary_icon_activatable:
+ * @self: a #HdyTabPage
+ * @activatable: TBD
+ *
+ * TBD
+ *
+ * Since: 1.2
+ */
+void
+hdy_tab_page_set_secondary_icon_activatable (HdyTabPage *self,
+ gboolean activatable)
+{
+ g_return_if_fail (HDY_IS_TAB_PAGE (self));
+
+ activatable = !!activatable;
+
+ if (self->secondary_icon_activatable == activatable)
+ return;
+
+ self->secondary_icon_activatable = activatable;
+
+ g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_SECONDARY_ICON_ACTIVATABLE]);
+}
+
/**
* hdy_tab_page_get_needs_attention:
* @self: a #HdyTabPage
@@ -1429,7 +1516,7 @@ hdy_tab_view_new (void)
*
* Since: 1.2
*/
-guint
+gint
hdy_tab_view_get_n_pages (HdyTabView *self)
{
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), 0);
@@ -1447,7 +1534,7 @@ hdy_tab_view_get_n_pages (HdyTabView *self)
*
* Since: 1.2
*/
-guint
+gint
hdy_tab_view_get_n_pinned_pages (HdyTabView *self)
{
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), 0);
@@ -1565,7 +1652,7 @@ gboolean
hdy_tab_view_select_previous_page (HdyTabView *self)
{
HdyTabPage *page;
- guint pos;
+ gint pos;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
@@ -1598,7 +1685,7 @@ gboolean
hdy_tab_view_select_next_page (HdyTabView *self)
{
HdyTabPage *page;
- guint pos;
+ gint pos;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
@@ -1631,7 +1718,7 @@ gboolean
hdy_tab_view_select_first_page (HdyTabView *self)
{
HdyTabPage *page;
- guint pos;
+ gint pos;
gboolean pinned;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
@@ -1670,7 +1757,7 @@ gboolean
hdy_tab_view_select_last_page (HdyTabView *self)
{
HdyTabPage *page;
- guint pos;
+ gint pos;
gboolean pinned;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
@@ -1884,7 +1971,7 @@ hdy_tab_view_set_page_pinned (HdyTabView *self,
HdyTabPage *page,
gboolean pinned)
{
- guint pos;
+ gint pos;
g_return_if_fail (HDY_IS_TAB_VIEW (self));
g_return_if_fail (HDY_IS_TAB_PAGE (page));
@@ -1901,7 +1988,7 @@ hdy_tab_view_set_page_pinned (HdyTabView *self,
pos = self->n_pinned_pages;
if (!pinned)
- pos--;
+ pos--;
g_list_store_insert (self->pages, pos, page);
@@ -1938,13 +2025,13 @@ HdyTabPage *
hdy_tab_view_get_page (HdyTabView *self,
GtkWidget *content)
{
- guint i;
+ gint i;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (content), NULL);
for (i = 0; i < self->n_pages; i++) {
- HdyTabPage *page = g_list_model_get_item (G_LIST_MODEL (self->pages), i);
+ HdyTabPage *page = g_list_model_get_item (G_LIST_MODEL (self->pages), (guint) i);
if (hdy_tab_page_get_content (page) == content)
return page;
@@ -1966,12 +2053,13 @@ hdy_tab_view_get_page (HdyTabView *self,
*/
HdyTabPage *
hdy_tab_view_get_nth_page (HdyTabView *self,
- guint position)
+ gint position)
{
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), NULL);
- g_return_val_if_fail (position <= self->n_pages, NULL);
+ g_return_val_if_fail (position >= 0, NULL);
+ g_return_val_if_fail (position < self->n_pages, NULL);
- return g_list_model_get_item (G_LIST_MODEL (self->pages), position);
+ return g_list_model_get_item (G_LIST_MODEL (self->pages), (guint) position);
}
/**
@@ -1985,14 +2073,14 @@ hdy_tab_view_get_nth_page (HdyTabView *self,
*
* Since: 1.2
*/
-guint
+gint
hdy_tab_view_get_page_position (HdyTabView *self,
HdyTabPage *page)
{
- guint i;
+ gint i;
- g_return_val_if_fail (HDY_IS_TAB_VIEW (self), 0);
- g_return_val_if_fail (HDY_IS_TAB_PAGE (page), 0);
+ g_return_val_if_fail (HDY_IS_TAB_VIEW (self), -1);
+ g_return_val_if_fail (HDY_IS_TAB_PAGE (page), -1);
for (i = 0; i < self->n_pages; i++) {
HdyTabPage *p = hdy_tab_view_get_nth_page (self, i);
@@ -2001,7 +2089,7 @@ hdy_tab_view_get_page_position (HdyTabView *self,
return i;
}
- return 0;
+ return -1;
}
/**
@@ -2019,10 +2107,11 @@ hdy_tab_view_get_page_position (HdyTabView *self,
HdyTabPage *
hdy_tab_view_insert (HdyTabView *self,
GtkWidget *content,
- guint position)
+ gint position)
{
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);
return insert_page (self, content, position, FALSE);
@@ -2085,10 +2174,11 @@ hdy_tab_view_append (HdyTabView *self,
HdyTabPage *
hdy_tab_view_insert_pinned (HdyTabView *self,
GtkWidget *content,
- guint position)
+ gint position)
{
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);
return insert_page (self, content, position, TRUE);
@@ -2168,7 +2258,7 @@ hdy_tab_view_close_page (HdyTabView *self,
/**
* hdy_tab_view_close_pages:
* @self: a #HdyTabView
- * @pages: (element-type HdyTabPage) (transfer full): TBD
+ * @pages: (element-type HdyTabPage) (transfer container): TBD
*
* TBD
*
@@ -2226,12 +2316,12 @@ hdy_tab_view_close_other_pages (HdyTabView *self,
HdyTabPage *page)
{
GSList *pages = NULL;
- guint i;
+ gint i;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
g_return_val_if_fail (HDY_IS_TAB_PAGE (page), FALSE);
- for (i = self->n_pinned_pages; i < self->n_pages; i++) {
+ for (i = self->n_pages - 1; i >= self->n_pinned_pages; i--) {
HdyTabPage *p = hdy_tab_view_get_nth_page (self, i);
if (p == page)
@@ -2240,8 +2330,6 @@ hdy_tab_view_close_other_pages (HdyTabView *self,
pages = g_slist_prepend (pages, p);
}
- pages = g_slist_reverse (pages);
-
return hdy_tab_view_close_pages (self, pages);
}
@@ -2261,21 +2349,19 @@ hdy_tab_view_close_pages_before (HdyTabView *self,
HdyTabPage *page)
{
GSList *pages = NULL;
- guint pos, i;
+ gint pos, i;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
g_return_val_if_fail (HDY_IS_TAB_PAGE (page), FALSE);
pos = hdy_tab_view_get_page_position (self, page);
- for (i = self->n_pinned_pages; i < pos; i++) {
+ for (i = pos - 1; i >= self->n_pinned_pages; i--) {
HdyTabPage *p = hdy_tab_view_get_nth_page (self, i);
pages = g_slist_prepend (pages, p);
}
- pages = g_slist_reverse (pages);
-
return hdy_tab_view_close_pages (self, pages);
}
@@ -2295,7 +2381,7 @@ hdy_tab_view_close_pages_after (HdyTabView *self,
HdyTabPage *page)
{
GSList *pages = NULL;
- guint pos, i;
+ gint pos, i;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
g_return_val_if_fail (HDY_IS_TAB_PAGE (page), FALSE);
@@ -2329,12 +2415,13 @@ hdy_tab_view_close_pages_after (HdyTabView *self,
gboolean
hdy_tab_view_reorder_page (HdyTabView *self,
HdyTabPage *page,
- guint position)
+ gint position)
{
- guint original_pos, pinned;
+ gint original_pos, pinned;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
g_return_val_if_fail (HDY_IS_TAB_PAGE (page), FALSE);
+ g_return_val_if_fail (position >= 0, FALSE);
pinned = hdy_tab_page_get_pinned (page);
@@ -2376,7 +2463,7 @@ hdy_tab_view_reorder_backward (HdyTabView *self,
HdyTabPage *page)
{
gboolean pinned;
- guint pos, first;
+ gint pos, first;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
g_return_val_if_fail (HDY_IS_TAB_PAGE (page), FALSE);
@@ -2408,7 +2495,7 @@ hdy_tab_view_reorder_forward (HdyTabView *self,
HdyTabPage *page)
{
gboolean pinned;
- guint pos, last;
+ gint pos, last;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
g_return_val_if_fail (HDY_IS_TAB_PAGE (page), FALSE);
@@ -2440,7 +2527,7 @@ hdy_tab_view_reorder_first (HdyTabView *self,
HdyTabPage *page)
{
gboolean pinned;
- guint pos;
+ gint pos;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
g_return_val_if_fail (HDY_IS_TAB_PAGE (page), FALSE);
@@ -2467,7 +2554,7 @@ hdy_tab_view_reorder_last (HdyTabView *self,
HdyTabPage *page)
{
gboolean pinned;
- guint pos;
+ gint pos;
g_return_val_if_fail (HDY_IS_TAB_VIEW (self), FALSE);
g_return_val_if_fail (HDY_IS_TAB_PAGE (page), FALSE);
@@ -2491,10 +2578,11 @@ hdy_tab_view_detach_page (HdyTabView *self,
void
hdy_tab_view_attach_page (HdyTabView *self,
HdyTabPage *page,
- guint position)
+ gint position)
{
g_return_if_fail (HDY_IS_TAB_VIEW (self));
g_return_if_fail (HDY_IS_TAB_PAGE (page));
+ g_return_if_fail (position >= 0);
g_return_if_fail (position <= self->n_pages);
attach_page (self, page, position);
@@ -2517,11 +2605,12 @@ void
hdy_tab_view_transfer_page (HdyTabView *self,
HdyTabPage *page,
HdyTabView *other_view,
- guint position)
+ gint position)
{
g_return_if_fail (HDY_IS_TAB_VIEW (self));
g_return_if_fail (HDY_IS_TAB_PAGE (page));
g_return_if_fail (HDY_IS_TAB_VIEW (other_view));
+ g_return_if_fail (position >= 0);
g_return_if_fail (position <= other_view->n_pages);
hdy_tab_view_detach_page (self, page);
diff --git a/src/hdy-tab-view.h b/src/hdy-tab-view.h
index 0d725fb6..37609f4e 100644
--- a/src/hdy-tab-view.h
+++ b/src/hdy-tab-view.h
@@ -60,6 +60,12 @@ HDY_AVAILABLE_IN_ALL
void hdy_tab_page_set_secondary_icon (HdyTabPage *self,
GIcon *secondary_icon);
+HDY_AVAILABLE_IN_ALL
+gboolean hdy_tab_page_get_secondary_icon_activatable (HdyTabPage *self);
+HDY_AVAILABLE_IN_ALL
+void hdy_tab_page_set_secondary_icon_activatable (HdyTabPage *self,
+ gboolean activatable);
+
HDY_AVAILABLE_IN_ALL
gboolean hdy_tab_page_get_needs_attention (HdyTabPage *self);
HDY_AVAILABLE_IN_ALL
@@ -75,9 +81,9 @@ HDY_AVAILABLE_IN_ALL
HdyTabView *hdy_tab_view_new (void);
HDY_AVAILABLE_IN_ALL
-guint hdy_tab_view_get_n_pages (HdyTabView *self);
+gint hdy_tab_view_get_n_pages (HdyTabView *self);
HDY_AVAILABLE_IN_ALL
-guint hdy_tab_view_get_n_pinned_pages (HdyTabView *self);
+gint hdy_tab_view_get_n_pinned_pages (HdyTabView *self);
HDY_AVAILABLE_IN_ALL
gboolean hdy_tab_view_get_is_dragging (HdyTabView *self);
@@ -129,16 +135,16 @@ HdyTabPage *hdy_tab_view_get_page (HdyTabView *self,
HDY_AVAILABLE_IN_ALL
HdyTabPage *hdy_tab_view_get_nth_page (HdyTabView *self,
- guint position);
+ gint position);
HDY_AVAILABLE_IN_ALL
-guint hdy_tab_view_get_page_position (HdyTabView *self,
- HdyTabPage *page);
+gint hdy_tab_view_get_page_position (HdyTabView *self,
+ HdyTabPage *page);
HDY_AVAILABLE_IN_ALL
HdyTabPage *hdy_tab_view_insert (HdyTabView *self,
GtkWidget *content,
- guint position);
+ gint position);
HDY_AVAILABLE_IN_ALL
HdyTabPage *hdy_tab_view_prepend (HdyTabView *self,
GtkWidget *content);
@@ -149,7 +155,7 @@ HdyTabPage *hdy_tab_view_append (HdyTabView *self,
HDY_AVAILABLE_IN_ALL
HdyTabPage *hdy_tab_view_insert_pinned (HdyTabView *self,
GtkWidget *content,
- guint position);
+ gint position);
HDY_AVAILABLE_IN_ALL
HdyTabPage *hdy_tab_view_prepend_pinned (HdyTabView *self,
GtkWidget *content);
@@ -176,7 +182,7 @@ gboolean hdy_tab_view_close_pages_after (HdyTabView *self,
HDY_AVAILABLE_IN_ALL
gboolean hdy_tab_view_reorder_page (HdyTabView *self,
HdyTabPage *page,
- guint position);
+ gint position);
HDY_AVAILABLE_IN_ALL
gboolean hdy_tab_view_reorder_backward (HdyTabView *self,
HdyTabPage *page);
@@ -194,7 +200,7 @@ HDY_AVAILABLE_IN_ALL
void hdy_tab_view_transfer_page (HdyTabView *self,
HdyTabPage *page,
HdyTabView *other_view,
- guint position);
+ gint position);
HDY_AVAILABLE_IN_ALL
GListModel *hdy_tab_view_get_pages (HdyTabView *self);
diff --git a/src/hdy-tab.c b/src/hdy-tab.c
index 22221472..993aa960 100644
--- a/src/hdy-tab.c
+++ b/src/hdy-tab.c
@@ -15,13 +15,15 @@ struct _HdyTab
GtkContainer parent_instance;
GtkLabel *title;
- GtkImage *icon;
- GtkImage *pinned_icon;
GtkStack *stack;
GtkStack *icon_stack;
- GtkStack *pinned_icon_stack;
+ GtkImage *icon;
GtkImage *secondary_icon;
+ GtkButton *secondary_icon_btn;
+ GtkStack *pinned_icon_stack;
+ GtkImage *pinned_icon;
GtkImage *pinned_secondary_icon;
+ GtkButton *pinned_secondary_icon_btn;
GtkWidget *child;
GdkWindow *window;
@@ -56,6 +58,19 @@ enum {
static GParamSpec *props[LAST_PROP];
+static inline void
+set_style_class (GtkWidget *widget,
+ const gchar *style_class,
+ gboolean enabled)
+{
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+
+ if (enabled)
+ gtk_style_context_add_class (context, style_class);
+ else
+ gtk_style_context_remove_class (context, style_class);
+}
+
static void
update_state (HdyTab *self)
{
@@ -100,7 +115,7 @@ update_icon (HdyTab *self)
gtk_stack_set_visible_child_name (self->icon_stack, name);
gtk_image_set_from_gicon (self->secondary_icon, secondary_gicon, GTK_ICON_SIZE_BUTTON);
- gtk_widget_set_visible (GTK_WIDGET (self->secondary_icon), secondary_gicon != NULL);
+ gtk_widget_set_visible (GTK_WIDGET (self->secondary_icon_btn), secondary_gicon != NULL);
if (gicon)
gtk_image_set_from_gicon (self->pinned_icon, gicon, GTK_ICON_SIZE_BUTTON);
@@ -114,6 +129,16 @@ update_icon (HdyTab *self)
gtk_stack_set_visible_child_name (self->pinned_icon_stack, pinned_name);
}
+static void
+update_secondary_icon (HdyTab *self)
+{
+ gboolean activatable = self->page && hdy_tab_page_get_secondary_icon_activatable (self->page);
+ gboolean clickable = activatable && (self->selected || !self->pinned);
+
+ set_style_class (GTK_WIDGET (self->secondary_icon_btn), "clickable", clickable);
+ set_style_class (GTK_WIDGET (self->pinned_secondary_icon_btn), "clickable", clickable);
+}
+
static void
update_needs_attention (HdyTab *self)
{
@@ -157,6 +182,26 @@ close_clicked_cb (HdyTab *self)
g_idle_add ((GSourceFunc) close_idle_cb, self);
}
+static void
+secondary_icon_clicked_cb (HdyTab *self)
+{
+ gboolean clickable;
+
+ if (!self->page)
+ return;
+
+ clickable = hdy_tab_page_get_secondary_icon_activatable (self->page) &&
+ (self->selected || !self->pinned);
+
+ if (!clickable) {
+ hdy_tab_view_set_selected_page (self->view, self->page);
+
+ return;
+ }
+
+ g_signal_emit_by_name (self->view, "secondary-icon-activated", self->page);
+}
+
static void
hdy_tab_measure (GtkWidget *widget,
GtkOrientation orientation,
@@ -484,6 +529,7 @@ hdy_tab_set_property (GObject *object,
case PROP_PINNED:
self->pinned = g_value_get_boolean (value);
+ update_secondary_icon (self);
break;
case PROP_DRAGGING:
@@ -596,14 +642,17 @@ hdy_tab_class_init (HdyTabClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/sm/puri/handy/ui/hdy-tab.ui");
gtk_widget_class_bind_template_child (widget_class, HdyTab, title);
- gtk_widget_class_bind_template_child (widget_class, HdyTab, icon);
- gtk_widget_class_bind_template_child (widget_class, HdyTab, pinned_icon);
gtk_widget_class_bind_template_child (widget_class, HdyTab, stack);
gtk_widget_class_bind_template_child (widget_class, HdyTab, icon_stack);
- gtk_widget_class_bind_template_child (widget_class, HdyTab, pinned_icon_stack);
+ gtk_widget_class_bind_template_child (widget_class, HdyTab, icon);
gtk_widget_class_bind_template_child (widget_class, HdyTab, secondary_icon);
+ gtk_widget_class_bind_template_child (widget_class, HdyTab, secondary_icon_btn);
+ gtk_widget_class_bind_template_child (widget_class, HdyTab, pinned_icon_stack);
+ gtk_widget_class_bind_template_child (widget_class, HdyTab, pinned_icon);
gtk_widget_class_bind_template_child (widget_class, HdyTab, pinned_secondary_icon);
+ gtk_widget_class_bind_template_child (widget_class, HdyTab, pinned_secondary_icon_btn);
gtk_widget_class_bind_template_callback (widget_class, close_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, secondary_icon_clicked_cb);
gtk_widget_class_set_css_name (widget_class, "tab");
}
@@ -638,6 +687,7 @@ hdy_tab_set_page (HdyTab *self,
if (self->page) {
g_signal_handlers_disconnect_by_func (self->page, update_tooltip, self);
g_signal_handlers_disconnect_by_func (self->page, update_icon, self);
+ g_signal_handlers_disconnect_by_func (self->page, update_secondary_icon, self);
g_signal_handlers_disconnect_by_func (self->page, update_needs_attention, self);
g_signal_handlers_disconnect_by_func (self->page, update_loading, self);
g_clear_pointer (&self->selected_binding, g_binding_unbind);
@@ -650,6 +700,7 @@ hdy_tab_set_page (HdyTab *self,
update_state (self);
update_tooltip (self);
update_icon (self);
+ update_secondary_icon (self);
update_needs_attention (self);
update_loading (self);
@@ -665,12 +716,15 @@ hdy_tab_set_page (HdyTab *self,
g_signal_connect_object (self->page, "notify::secondary-icon",
G_CALLBACK (update_icon), self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->page, "notify::secondary-icon-activatable",
+ G_CALLBACK (update_secondary_icon), self,
+ G_CONNECT_SWAPPED);
g_signal_connect_object (self->page, "notify::needs-attention",
G_CALLBACK (update_needs_attention), self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->page, "notify::loading",
G_CALLBACK (update_loading), self,
- G_CONNECT_SWAPPED);
+ G_CONNECT_SWAPPED);
if (!self->dragging)
self->selected_binding = g_object_bind_property (self->page, "selected",
@@ -760,6 +814,7 @@ hdy_tab_set_selected (HdyTab *self,
self->selected = selected;
update_state (self);
+ update_secondary_icon (self);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SELECTED]);
}
diff --git a/src/hdy-tab.ui b/src/hdy-tab.ui
index ade27591..37f7148a 100644
--- a/src/hdy-tab.ui
+++ b/src/hdy-tab.ui
@@ -82,13 +82,22 @@
</packing>
</child>
<child>
- <object class="GtkImage" id="secondary_icon">
+ <object class="GtkButton" id="secondary_icon_btn">
<property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="valign">center</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
+ <signal name="clicked" handler="secondary_icon_clicked_cb" swapped="true"/>
<style>
+ <class name="flat"/>
<class name="tab-secondary-icon"/>
</style>
+ <child>
+ <object class="GtkImage" id="secondary_icon">
+ <property name="visible">True</property>
+ </object>
+ </child>
</object>
<packing>
<property name="pack-type">end</property>
@@ -119,17 +128,27 @@
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="active">True</property>
+ <property name="halign">center</property>
</object>
<packing>
<property name="name">spinner</property>
</packing>
</child>
<child>
- <object class="GtkImage" id="pinned_secondary_icon">
+ <object class="GtkButton" id="pinned_secondary_icon_btn">
<property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="secondary_icon_clicked_cb" swapped="true"/>
<style>
+ <class name="flat"/>
<class name="tab-secondary-icon"/>
</style>
+ <child>
+ <object class="GtkImage" id="pinned_secondary_icon">
+ <property name="visible">True</property>
+ </object>
+ </child>
</object>
<packing>
<property name="name">secondary-icon</property>
diff --git a/src/themes/Adwaita-dark.css b/src/themes/Adwaita-dark.css
index fc06c643..3529a15f 100644
--- a/src/themes/Adwaita-dark.css
+++ b/src/themes/Adwaita-dark.css
@@ -73,6 +73,8 @@ avatar.contrasted { color: #fff; }
viewswitchertitle viewswitcher { margin-left: 12px; margin-right: 12px; }
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
+
/*************************** Check and Radio buttons * */
popover.combo list { min-width: 200px; }
@@ -80,6 +82,10 @@ window.csd.unified:not(.solid-csd) headerbar { border-radius: 0; }
.windowhandle, .windowhandle * { -GtkWidget-window-dragging: true; }
+tabbar .tab-secondary-icon { padding: 0; margin: 0; min-width: 20px; min-height: 20px; border-radius: 99px; }
+
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
+
popover.combo { padding: 0px; }
popover.combo list { border-style: none; background-color: transparent; }
@@ -240,6 +246,8 @@ tabbar tab.needs-attention { background-image: radial-gradient(ellipse at bottom
tabbar tab .tab-contents { padding: 6px; }
+tabbar tab .tab-secondary-icon { padding: 0; min-width: 20px; min-height: 20px; border-radius: 10px; }
+
tabbar tab .tab-close-button { margin: 0; padding: 0; border-radius: 9999px; }
tabbar tab .tab-close-button:not(:hover) { border-color: transparent; }
diff --git a/src/themes/Adwaita.css b/src/themes/Adwaita.css
index 618f3a7c..ac1c53e7 100644
--- a/src/themes/Adwaita.css
+++ b/src/themes/Adwaita.css
@@ -73,6 +73,8 @@ avatar.contrasted { color: #fff; }
viewswitchertitle viewswitcher { margin-left: 12px; margin-right: 12px; }
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
+
/*************************** Check and Radio buttons * */
popover.combo list { min-width: 200px; }
@@ -80,6 +82,10 @@ window.csd.unified:not(.solid-csd) headerbar { border-radius: 0; }
.windowhandle, .windowhandle * { -GtkWidget-window-dragging: true; }
+tabbar .tab-secondary-icon { padding: 0; margin: 0; min-width: 20px; min-height: 20px; border-radius: 99px; }
+
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
+
popover.combo { padding: 0px; }
popover.combo list { border-style: none; background-color: transparent; }
@@ -240,6 +246,8 @@ tabbar tab.needs-attention { background-image: radial-gradient(ellipse at bottom
tabbar tab .tab-contents { padding: 6px; }
+tabbar tab .tab-secondary-icon { padding: 0; min-width: 20px; min-height: 20px; border-radius: 10px; }
+
tabbar tab .tab-close-button { margin: 0; padding: 0; border-radius: 9999px; }
tabbar tab .tab-close-button:not(:hover) { border-color: transparent; }
diff --git a/src/themes/HighContrast.css b/src/themes/HighContrast.css
index 704593d7..748bf0ce 100644
--- a/src/themes/HighContrast.css
+++ b/src/themes/HighContrast.css
@@ -73,6 +73,8 @@ avatar.contrasted { color: #fff; }
viewswitchertitle viewswitcher { margin-left: 12px; margin-right: 12px; }
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
+
/*************************** Check and Radio buttons * */
popover.combo list { min-width: 200px; }
@@ -80,6 +82,10 @@ window.csd.unified:not(.solid-csd) headerbar { border-radius: 0; }
.windowhandle, .windowhandle * { -GtkWidget-window-dragging: true; }
+tabbar .tab-secondary-icon { padding: 0; margin: 0; min-width: 20px; min-height: 20px; border-radius: 99px; }
+
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
+
popover.combo { padding: 0px; }
popover.combo list { border-style: none; background-color: transparent; }
@@ -240,6 +246,8 @@ tabbar tab.needs-attention { background-image: radial-gradient(ellipse at bottom
tabbar tab .tab-contents { padding: 6px; }
+tabbar tab .tab-secondary-icon { padding: 0; min-width: 20px; min-height: 20px; border-radius: 10px; }
+
tabbar tab .tab-close-button { margin: 0; padding: 0; border-radius: 9999px; }
tabbar tab .tab-close-button:not(:hover) { border-color: transparent; }
diff --git a/src/themes/HighContrastInverse.css b/src/themes/HighContrastInverse.css
index 39ff160e..a29f8123 100644
--- a/src/themes/HighContrastInverse.css
+++ b/src/themes/HighContrastInverse.css
@@ -73,6 +73,8 @@ avatar.contrasted { color: #fff; }
viewswitchertitle viewswitcher { margin-left: 12px; margin-right: 12px; }
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
+
/*************************** Check and Radio buttons * */
popover.combo list { min-width: 200px; }
@@ -80,6 +82,10 @@ window.csd.unified:not(.solid-csd) headerbar { border-radius: 0; }
.windowhandle, .windowhandle * { -GtkWidget-window-dragging: true; }
+tabbar .tab-secondary-icon { padding: 0; margin: 0; min-width: 20px; min-height: 20px; border-radius: 99px; }
+
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
+
popover.combo { padding: 0px; }
popover.combo list { border-style: none; background-color: transparent; }
@@ -240,6 +246,8 @@ tabbar tab.needs-attention { background-image: radial-gradient(ellipse at bottom
tabbar tab .tab-contents { padding: 6px; }
+tabbar tab .tab-secondary-icon { padding: 0; min-width: 20px; min-height: 20px; border-radius: 10px; }
+
tabbar tab .tab-close-button { margin: 0; padding: 0; border-radius: 9999px; }
tabbar tab .tab-close-button:not(:hover) { border-color: transparent; }
diff --git a/src/themes/_Adwaita-base.scss b/src/themes/_Adwaita-base.scss
index 5d6e3bdb..fe4dec2a 100644
--- a/src/themes/_Adwaita-base.scss
+++ b/src/themes/_Adwaita-base.scss
@@ -496,6 +496,13 @@ tabbar {
padding: 6px;
}
+ .tab-secondary-icon {
+ padding: 0;
+ min-width: 20px;
+ min-height: 20px;
+ border-radius: 10px;
+ }
+
.tab-close-button {
margin: 0;
padding: 0;
diff --git a/src/themes/_fallback-base.scss b/src/themes/_fallback-base.scss
index b821d956..f671059e 100644
--- a/src/themes/_fallback-base.scss
+++ b/src/themes/_fallback-base.scss
@@ -144,3 +144,9 @@ viewswitchertitle viewswitcher {
margin-left: 12px;
margin-right: 12px;
}
+
+tabbar .tab-secondary-icon:not(.clickable) {
+ background: none;
+ box-shadow: none;
+ border-color: transparent;
+}
diff --git a/src/themes/_shared-base.scss b/src/themes/_shared-base.scss
index 6fec1a0a..c3509fa5 100644
--- a/src/themes/_shared-base.scss
+++ b/src/themes/_shared-base.scss
@@ -19,3 +19,17 @@ window.csd.unified:not(.solid-csd) {
-GtkWidget-window-dragging: true;
}
}
+
+tabbar .tab-secondary-icon {
+ padding: 0;
+ margin: 0;
+ min-width: 20px;
+ min-height: 20px;
+ border-radius: 99px;
+
+ &:not(.clickable) {
+ background: none;
+ box-shadow: none;
+ border-color: transparent;
+ }
+}
diff --git a/src/themes/fallback.css b/src/themes/fallback.css
index 8c1d89b1..b8758d80 100644
--- a/src/themes/fallback.css
+++ b/src/themes/fallback.css
@@ -72,3 +72,5 @@ avatar.color14 { background-image: linear-gradient(#c0bfbc, #6e6d71); color: #d8
avatar.contrasted { color: #fff; }
viewswitchertitle viewswitcher { margin-left: 12px; margin-right: 12px; }
+
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
diff --git a/src/themes/shared.css b/src/themes/shared.css
index 66f9ea88..f5f2eb59 100644
--- a/src/themes/shared.css
+++ b/src/themes/shared.css
@@ -4,3 +4,7 @@ popover.combo list { min-width: 200px; }
window.csd.unified:not(.solid-csd) headerbar { border-radius: 0; }
.windowhandle, .windowhandle * { -GtkWidget-window-dragging: true; }
+
+tabbar .tab-secondary-icon { padding: 0; margin: 0; min-width: 20px; min-height: 20px; border-radius: 99px; }
+
+tabbar .tab-secondary-icon:not(.clickable) { background: none; box-shadow: none; border-color: transparent; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]