Compare commits
3 Commits
ebassi/fix
...
tooltip_wi
Author | SHA1 | Date | |
---|---|---|---|
|
bab2bf2596 | ||
|
11b4e4a467 | ||
|
1cae0cd54c |
@@ -153,6 +153,35 @@ get_busy (GSimpleAction *action,
|
|||||||
gtk_widget_set_sensitive (window, FALSE);
|
gtk_widget_set_sensitive (window, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
search_button_tooltip_show (GtkWidget *self,
|
||||||
|
GtkTooltip *tooltip)
|
||||||
|
{
|
||||||
|
static int style = 0;
|
||||||
|
|
||||||
|
if (style == 0)
|
||||||
|
{
|
||||||
|
gtk_tooltip_set_css_class (tooltip, "red-tooltip");
|
||||||
|
style++;
|
||||||
|
}
|
||||||
|
else if (style == 1)
|
||||||
|
{
|
||||||
|
gtk_tooltip_set_css_class (tooltip, "yellow-tooltip");
|
||||||
|
style++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
style = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
search_button_tooltip_hide (GtkWidget *self,
|
||||||
|
GtkTooltip *tooltip)
|
||||||
|
{
|
||||||
|
gtk_tooltip_set_css_class (tooltip, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static int current_page = 0;
|
static int current_page = 0;
|
||||||
static gboolean
|
static gboolean
|
||||||
on_page (int i)
|
on_page (int i)
|
||||||
@@ -2221,6 +2250,8 @@ activate (GApplication *app)
|
|||||||
gtk_builder_cscope_add_callback (scope, level_scale_value_changed);
|
gtk_builder_cscope_add_callback (scope, level_scale_value_changed);
|
||||||
gtk_builder_cscope_add_callback (scope, transition_speed_changed);
|
gtk_builder_cscope_add_callback (scope, transition_speed_changed);
|
||||||
gtk_builder_cscope_add_callback (scope, reset_icon_size);
|
gtk_builder_cscope_add_callback (scope, reset_icon_size);
|
||||||
|
gtk_builder_cscope_add_callback (scope, search_button_tooltip_show);
|
||||||
|
gtk_builder_cscope_add_callback (scope, search_button_tooltip_hide);
|
||||||
gtk_builder_set_scope (builder, scope);
|
gtk_builder_set_scope (builder, scope);
|
||||||
g_object_unref (scope);
|
g_object_unref (scope);
|
||||||
if (!gtk_builder_add_from_resource (builder, "/org/gtk/WidgetFactory4/widget-factory.ui", &error))
|
if (!gtk_builder_add_from_resource (builder, "/org/gtk/WidgetFactory4/widget-factory.ui", &error))
|
||||||
|
@@ -6,3 +6,12 @@
|
|||||||
.toolbar {
|
.toolbar {
|
||||||
-gtk-icon-style: symbolic;
|
-gtk-icon-style: symbolic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.red-tooltip {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yellow-tooltip {
|
||||||
|
background-color: yellow;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
@@ -257,7 +257,9 @@
|
|||||||
</object>
|
</object>
|
||||||
<object class="GtkTextBuffer" id="textbuffer1">
|
<object class="GtkTextBuffer" id="textbuffer1">
|
||||||
<property name="tag-table">tags</property>
|
<property name="tag-table">tags</property>
|
||||||
<property name="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
<property name="text">Search button above will display its tooltip in an alternating red, yellow and default style.
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
Nullam fringilla, est ut feugiat ultrices, elit lacus ultricies nibh, id commodo tortor nisi id elit.
|
Nullam fringilla, est ut feugiat ultrices, elit lacus ultricies nibh, id commodo tortor nisi id elit.
|
||||||
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
|
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
|
||||||
Morbi vel elit erat. Maecenas dignissim, dui et pharetra rutrum, tellus lectus rutrum mi, a convallis libero nisi quis tellus.
|
Morbi vel elit erat. Maecenas dignissim, dui et pharetra rutrum, tellus lectus rutrum mi, a convallis libero nisi quis tellus.
|
||||||
@@ -1921,6 +1923,8 @@ microphone-sensitivity-medium-symbolic</property>
|
|||||||
<property name="icon-name">edit-find</property>
|
<property name="icon-name">edit-find</property>
|
||||||
<property name="action-name">win.search</property>
|
<property name="action-name">win.search</property>
|
||||||
<property name="tooltip-text" translatable="1">Search for it</property>
|
<property name="tooltip-text" translatable="1">Search for it</property>
|
||||||
|
<signal name="tooltip-show" handler="search_button_tooltip_show"/>
|
||||||
|
<signal name="tooltip-hide" handler="search_button_tooltip_hide"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@@ -755,6 +755,8 @@ gtk_tooltip_show_tooltip (GdkDisplay *display)
|
|||||||
|
|
||||||
gtk_tooltip_position (tooltip, display, tooltip_widget, device);
|
gtk_tooltip_position (tooltip, display, tooltip_widget, device);
|
||||||
|
|
||||||
|
g_signal_emit_by_name (tooltip_widget, "tooltip-show", tooltip);
|
||||||
|
|
||||||
gtk_widget_set_visible (GTK_WIDGET (tooltip->window), TRUE);
|
gtk_widget_set_visible (GTK_WIDGET (tooltip->window), TRUE);
|
||||||
|
|
||||||
/* Now a tooltip is visible again on the display, make sure browse
|
/* Now a tooltip is visible again on the display, make sure browse
|
||||||
@@ -771,6 +773,8 @@ gtk_tooltip_show_tooltip (GdkDisplay *display)
|
|||||||
static void
|
static void
|
||||||
gtk_tooltip_hide_tooltip (GtkTooltip *tooltip)
|
gtk_tooltip_hide_tooltip (GtkTooltip *tooltip)
|
||||||
{
|
{
|
||||||
|
GtkWidget *tooltip_widget;
|
||||||
|
|
||||||
guint timeout = BROWSE_DISABLE_TIMEOUT;
|
guint timeout = BROWSE_DISABLE_TIMEOUT;
|
||||||
|
|
||||||
if (!tooltip)
|
if (!tooltip)
|
||||||
@@ -785,6 +789,7 @@ gtk_tooltip_hide_tooltip (GtkTooltip *tooltip)
|
|||||||
if (!GTK_TOOLTIP_VISIBLE (tooltip))
|
if (!GTK_TOOLTIP_VISIBLE (tooltip))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
tooltip_widget = tooltip->tooltip_widget;
|
||||||
tooltip->tooltip_widget = NULL;
|
tooltip->tooltip_widget = NULL;
|
||||||
|
|
||||||
/* The tooltip is gone, after (by default, should be configurable) 500ms
|
/* The tooltip is gone, after (by default, should be configurable) 500ms
|
||||||
@@ -801,7 +806,10 @@ gtk_tooltip_hide_tooltip (GtkTooltip *tooltip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tooltip->window)
|
if (tooltip->window)
|
||||||
gtk_widget_set_visible (tooltip->window, FALSE);
|
{
|
||||||
|
gtk_widget_set_visible (tooltip->window, FALSE);
|
||||||
|
g_signal_emit_by_name (tooltip_widget, "tooltip-hide", tooltip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -1065,3 +1073,26 @@ gtk_tooltip_unset_surface (GtkNative *native)
|
|||||||
gtk_tooltip_set_surface (tooltip, NULL);
|
gtk_tooltip_set_surface (tooltip, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_tooltip_set_css_class:
|
||||||
|
* @tooltip: a #GtkTooltip
|
||||||
|
* @css_class: (allow-none): a css class name, or %NULL
|
||||||
|
*
|
||||||
|
* This function allows to add a single css class
|
||||||
|
* to @tooltip window, that means it will remove any
|
||||||
|
* css class previously added by this function before
|
||||||
|
* adding @css_class as the currently active one.
|
||||||
|
*
|
||||||
|
* if %NULL is passed then any active css class (which
|
||||||
|
* was added by this function) will be cleared.
|
||||||
|
*
|
||||||
|
* Since: 4.12
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_tooltip_set_css_class (GtkTooltip *tooltip,
|
||||||
|
const char *css_class)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
|
||||||
|
|
||||||
|
gtk_tooltip_window_set_css_class (GTK_TOOLTIP_WINDOW (tooltip->window), css_class);
|
||||||
|
}
|
||||||
|
@@ -56,6 +56,9 @@ void gtk_tooltip_set_custom (GtkTooltip *tooltip,
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_tooltip_set_tip_area (GtkTooltip *tooltip,
|
void gtk_tooltip_set_tip_area (GtkTooltip *tooltip,
|
||||||
const GdkRectangle *rect);
|
const GdkRectangle *rect);
|
||||||
|
GDK_AVAILABLE_IN_4_12
|
||||||
|
void gtk_tooltip_set_css_class (GtkTooltip *tooltip,
|
||||||
|
const char *css_class);
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTooltip, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTooltip, g_object_unref)
|
||||||
|
|
||||||
|
@@ -59,6 +59,7 @@ struct _GtkTooltipWindow
|
|||||||
GtkWidget *image;
|
GtkWidget *image;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
GtkWidget *custom_widget;
|
GtkWidget *custom_widget;
|
||||||
|
char *css_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkTooltipWindowClass
|
struct _GtkTooltipWindowClass
|
||||||
@@ -392,6 +393,7 @@ static void
|
|||||||
gtk_tooltip_window_init (GtkTooltipWindow *self)
|
gtk_tooltip_window_init (GtkTooltipWindow *self)
|
||||||
{
|
{
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
self->css_class = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -520,3 +522,30 @@ gtk_tooltip_window_position (GtkTooltipWindow *window,
|
|||||||
|
|
||||||
gtk_tooltip_window_relayout (window);
|
gtk_tooltip_window_relayout (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See gtk_tooltip_set_css_class() description */
|
||||||
|
void
|
||||||
|
gtk_tooltip_window_set_css_class (GtkTooltipWindow *window,
|
||||||
|
const char *css_class)
|
||||||
|
{
|
||||||
|
GtkWidget *wid = GTK_WIDGET (window);
|
||||||
|
|
||||||
|
if (g_strcmp0 (window->css_class, css_class) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (css_class)
|
||||||
|
{
|
||||||
|
if (window->css_class)
|
||||||
|
{
|
||||||
|
gtk_widget_remove_css_class (wid, window->css_class);
|
||||||
|
g_free (window->css_class);
|
||||||
|
}
|
||||||
|
window->css_class = g_strdup (css_class);
|
||||||
|
gtk_widget_add_css_class (wid, css_class);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_widget_remove_css_class (wid, window->css_class);
|
||||||
|
g_clear_pointer (&window->css_class, g_free);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -59,6 +59,8 @@ void gtk_tooltip_window_position (GtkTooltipWindo
|
|||||||
GdkAnchorHints anchor_hints,
|
GdkAnchorHints anchor_hints,
|
||||||
int dx,
|
int dx,
|
||||||
int dy);
|
int dy);
|
||||||
|
void gtk_tooltip_window_set_css_class (GtkTooltipWindow *window,
|
||||||
|
const char *css_class);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@@ -502,6 +502,8 @@ enum {
|
|||||||
MOVE_FOCUS,
|
MOVE_FOCUS,
|
||||||
KEYNAV_FAILED,
|
KEYNAV_FAILED,
|
||||||
QUERY_TOOLTIP,
|
QUERY_TOOLTIP,
|
||||||
|
TOOLTIP_SHOW,
|
||||||
|
TOOLTIP_HIDE,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1926,6 +1928,38 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
|||||||
|
|
||||||
gtk_widget_class_set_css_name (klass, I_("widget"));
|
gtk_widget_class_set_css_name (klass, I_("widget"));
|
||||||
klass->priv->accessible_role = GTK_ACCESSIBLE_ROLE_WIDGET;
|
klass->priv->accessible_role = GTK_ACCESSIBLE_ROLE_WIDGET;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkWidget::tooltip-show:
|
||||||
|
* @widget: the object which received the signal.
|
||||||
|
*
|
||||||
|
* Emitted when a tooltip is about to be shown on @widget.
|
||||||
|
*/
|
||||||
|
widget_signals[TOOLTIP_SHOW] =
|
||||||
|
g_signal_new (I_("tooltip-show"),
|
||||||
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
0,
|
||||||
|
NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
GTK_TYPE_TOOLTIP);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkWidget::tooltip-hide:
|
||||||
|
* @widget: the object which received the signal.
|
||||||
|
*
|
||||||
|
* Emitted when a tooltip on @widget has just been hidden.
|
||||||
|
*/
|
||||||
|
widget_signals[TOOLTIP_HIDE] =
|
||||||
|
g_signal_new (I_("tooltip-hide"),
|
||||||
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
0,
|
||||||
|
NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
GTK_TYPE_TOOLTIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user