[tepl] TabLabel: overridable tooltip
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] TabLabel: overridable tooltip
- Date: Sat, 12 Aug 2017 13:17:50 +0000 (UTC)
commit 5131ad587479183ded954f3a145b3ba1e438890f
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Aug 11 19:34:05 2017 +0200
TabLabel: overridable tooltip
docs/reference/tepl-3.0-sections.txt | 3 ++-
tepl/tepl-tab-label.c | 31 +++++++++++++++++++++++++++++++
tepl/tepl-tab-label.h | 12 ++++++++++++
3 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index c446504..7d1b597 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -480,8 +480,10 @@ tepl_tab_group_get_type
<SECTION>
<FILE>tab-label</FILE>
TeplTabLabel
+TeplTabLabelClass
tepl_tab_label_new
tepl_tab_label_get_tab
+tepl_tab_label_update_tooltip
<SUBSECTION Standard>
TEPL_IS_TAB_LABEL
TEPL_IS_TAB_LABEL_CLASS
@@ -489,7 +491,6 @@ TEPL_TAB_LABEL
TEPL_TAB_LABEL_CLASS
TEPL_TAB_LABEL_GET_CLASS
TEPL_TYPE_TAB_LABEL
-TeplTabLabelClass
TeplTabLabelPrivate
tepl_tab_label_get_type
</SECTION>
diff --git a/tepl/tepl-tab-label.c b/tepl/tepl-tab-label.c
index 3c49b09..f003dfe 100644
--- a/tepl/tepl-tab-label.c
+++ b/tepl/tepl-tab-label.c
@@ -36,6 +36,7 @@
* - a #GtkLabel with the #TeplBuffer:tepl-short-title.
* - a close button, when clicked the #TeplTab #TeplTab::close-request signal is
* emitted.
+ * - a customizable tooltip.
*/
struct _TeplTabLabelPrivate
@@ -212,6 +213,12 @@ tepl_tab_label_dispose (GObject *object)
G_OBJECT_CLASS (tepl_tab_label_parent_class)->dispose (object);
}
+static gchar *
+tepl_tab_label_get_tooltip_markup_default (TeplTabLabel *tab_label)
+{
+ return NULL;
+}
+
static void
tepl_tab_label_class_init (TeplTabLabelClass *klass)
{
@@ -221,6 +228,8 @@ tepl_tab_label_class_init (TeplTabLabelClass *klass)
object_class->set_property = tepl_tab_label_set_property;
object_class->dispose = tepl_tab_label_dispose;
+ klass->get_tooltip_markup = tepl_tab_label_get_tooltip_markup_default;
+
/**
* TeplTabLabel:tab:
*
@@ -312,3 +321,25 @@ tepl_tab_label_get_tab (TeplTabLabel *tab_label)
return tab_label->priv->tab;
}
+
+/**
+ * tepl_tab_label_update_tooltip:
+ * @tab_label: a #TeplTabLabel.
+ *
+ * Asks #TeplTabLabel to update its tooltip. The ::get_tooltip_markup virtual
+ * function is called and the result is set with
+ * gtk_widget_set_tooltip_markup().
+ *
+ * Since: 3.0
+ */
+void
+tepl_tab_label_update_tooltip (TeplTabLabel *tab_label)
+{
+ gchar *tooltip_markup;
+
+ g_return_if_fail (TEPL_IS_TAB_LABEL (tab_label));
+
+ tooltip_markup = TEPL_TAB_LABEL_GET_CLASS (tab_label)->get_tooltip_markup (tab_label);
+ gtk_widget_set_tooltip_markup (GTK_WIDGET (tab_label), tooltip_markup);
+ g_free (tooltip_markup);
+}
diff --git a/tepl/tepl-tab-label.h b/tepl/tepl-tab-label.h
index 0edb2e5..ffe42af 100644
--- a/tepl/tepl-tab-label.h
+++ b/tepl/tepl-tab-label.h
@@ -46,10 +46,20 @@ struct _TeplTabLabel
TeplTabLabelPrivate *priv;
};
+/**
+ * TeplTabLabelClass:
+ * @parent_class: The parent class.
+ * @get_tooltip_markup: Virtual function pointer to create the tooltip markup
+ * string. %NULL must be returned if no tooltip is wanted. The result is
+ * intended to be used as an argument to gtk_widget_set_tooltip_markup().
+ */
struct _TeplTabLabelClass
{
GtkGridClass parent_class;
+ gchar * (* get_tooltip_markup) (TeplTabLabel *tab_label);
+
+ /*< private >*/
gpointer padding[12];
};
@@ -59,6 +69,8 @@ GtkWidget * tepl_tab_label_new (TeplTab *tab);
TeplTab * tepl_tab_label_get_tab (TeplTabLabel *tab_label);
+void tepl_tab_label_update_tooltip (TeplTabLabel *tab_label);
+
G_END_DECLS
#endif /* TEPL_TAB_LABEL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]