Compare commits
5 Commits
amolenaar/
...
tooltip-wi
Author | SHA1 | Date | |
---|---|---|---|
|
07959e50ad | ||
|
b72de7e067 | ||
|
a8df66f4fc | ||
|
4148764f10 | ||
|
1ec51a6b92 |
@@ -60,12 +60,19 @@ gtk_native_default_check_resize (GtkNative *self)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_native_default_set_tooltip (GtkNative *self,
|
||||||
|
GtkNative *tooltip)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_native_default_init (GtkNativeInterface *iface)
|
gtk_native_default_init (GtkNativeInterface *iface)
|
||||||
{
|
{
|
||||||
iface->get_renderer = gtk_native_default_get_renderer;
|
iface->get_renderer = gtk_native_default_get_renderer;
|
||||||
iface->get_surface_transform = gtk_native_default_get_surface_transform;
|
iface->get_surface_transform = gtk_native_default_get_surface_transform;
|
||||||
iface->check_resize = gtk_native_default_check_resize;
|
iface->check_resize = gtk_native_default_check_resize;
|
||||||
|
iface->set_tooltip = gtk_native_default_set_tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,3 +156,14 @@ gtk_native_get_for_surface (GdkSurface *surface)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_native_set_tooltip (GtkNative *self,
|
||||||
|
GtkNative *tooltip)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_NATIVE (self));
|
||||||
|
g_return_if_fail (tooltip == NULL || GTK_IS_NATIVE (tooltip));
|
||||||
|
|
||||||
|
GTK_NATIVE_GET_IFACE (self)->set_tooltip (self, tooltip);
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -53,6 +53,9 @@ struct _GtkNativeInterface
|
|||||||
int *y);
|
int *y);
|
||||||
|
|
||||||
void (* check_resize) (GtkNative *self);
|
void (* check_resize) (GtkNative *self);
|
||||||
|
|
||||||
|
void (* set_tooltip) (GtkNative *self,
|
||||||
|
GtkNative *tooltip);
|
||||||
};
|
};
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
@@ -67,6 +70,10 @@ GdkSurface *gtk_native_get_surface (GtkNative *self);
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GskRenderer *gtk_native_get_renderer (GtkNative *self);
|
GskRenderer *gtk_native_get_renderer (GtkNative *self);
|
||||||
|
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
void gtk_native_set_tooltip (GtkNative *self,
|
||||||
|
GtkNative *tooltip);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_NATIVE_H__ */
|
#endif /* __GTK_NATIVE_H__ */
|
||||||
|
@@ -156,6 +156,8 @@ typedef struct {
|
|||||||
GtkCssNode *arrow_node;
|
GtkCssNode *arrow_node;
|
||||||
GskRenderNode *arrow_render_node;
|
GskRenderNode *arrow_render_node;
|
||||||
|
|
||||||
|
GtkNative *tooltip;
|
||||||
|
|
||||||
GdkPopupLayout *layout;
|
GdkPopupLayout *layout;
|
||||||
GdkRectangle final_rect;
|
GdkRectangle final_rect;
|
||||||
GtkPositionType final_position;
|
GtkPositionType final_position;
|
||||||
@@ -231,6 +233,16 @@ gtk_popover_native_get_surface_transform (GtkNative *native,
|
|||||||
_gtk_css_number_value_get (style->size->padding_top, 100);
|
_gtk_css_number_value_get (style->size->padding_top, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_popover_native_set_tooltip (GtkNative *native,
|
||||||
|
GtkNative *tooltip)
|
||||||
|
{
|
||||||
|
GtkPopover *popover = GTK_POPOVER (native);
|
||||||
|
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
|
||||||
|
|
||||||
|
priv->tooltip = tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_gravity_facing_north (GdkGravity gravity)
|
is_gravity_facing_north (GdkGravity gravity)
|
||||||
{
|
{
|
||||||
@@ -1420,6 +1432,9 @@ gtk_popover_size_allocate (GtkWidget *widget,
|
|||||||
gtk_popover_update_shape (popover);
|
gtk_popover_update_shape (popover);
|
||||||
g_clear_pointer (&priv->arrow_render_node, gsk_render_node_unref);
|
g_clear_pointer (&priv->arrow_render_node, gsk_render_node_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priv->tooltip && gtk_widget_get_visible (GTK_WIDGET (priv->tooltip)))
|
||||||
|
gtk_native_check_resize (priv->tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1890,6 +1905,7 @@ gtk_popover_native_interface_init (GtkNativeInterface *iface)
|
|||||||
iface->get_renderer = gtk_popover_native_get_renderer;
|
iface->get_renderer = gtk_popover_native_get_renderer;
|
||||||
iface->get_surface_transform = gtk_popover_native_get_surface_transform;
|
iface->get_surface_transform = gtk_popover_native_get_surface_transform;
|
||||||
iface->check_resize = gtk_popover_native_check_resize;
|
iface->check_resize = gtk_popover_native_check_resize;
|
||||||
|
iface->set_tooltip = gtk_popover_native_set_tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkBuildableIface *parent_buildable_iface;
|
static GtkBuildableIface *parent_buildable_iface;
|
||||||
|
@@ -191,13 +191,6 @@ surface_state_changed (GtkWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
surface_size_changed (GtkWidget *widget,
|
|
||||||
guint width,
|
|
||||||
guint height)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
surface_render (GdkSurface *surface,
|
surface_render (GdkSurface *surface,
|
||||||
cairo_region_t *region,
|
cairo_region_t *region,
|
||||||
@@ -228,7 +221,6 @@ gtk_tooltip_window_realize (GtkWidget *widget)
|
|||||||
gdk_surface_set_widget (window->surface, widget);
|
gdk_surface_set_widget (window->surface, widget);
|
||||||
|
|
||||||
g_signal_connect_swapped (window->surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
|
g_signal_connect_swapped (window->surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
|
||||||
g_signal_connect_swapped (window->surface, "size-changed", G_CALLBACK (surface_size_changed), widget);
|
|
||||||
g_signal_connect (window->surface, "render", G_CALLBACK (surface_render), widget);
|
g_signal_connect (window->surface, "render", G_CALLBACK (surface_render), widget);
|
||||||
g_signal_connect (window->surface, "event", G_CALLBACK (surface_event), widget);
|
g_signal_connect (window->surface, "event", G_CALLBACK (surface_event), widget);
|
||||||
|
|
||||||
@@ -248,7 +240,6 @@ gtk_tooltip_window_unrealize (GtkWidget *widget)
|
|||||||
g_clear_object (&window->renderer);
|
g_clear_object (&window->renderer);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (window->surface, surface_state_changed, widget);
|
g_signal_handlers_disconnect_by_func (window->surface, surface_state_changed, widget);
|
||||||
g_signal_handlers_disconnect_by_func (window->surface, surface_size_changed, widget);
|
|
||||||
g_signal_handlers_disconnect_by_func (window->surface, surface_render, widget);
|
g_signal_handlers_disconnect_by_func (window->surface, surface_render, widget);
|
||||||
g_signal_handlers_disconnect_by_func (window->surface, surface_event, widget);
|
g_signal_handlers_disconnect_by_func (window->surface, surface_event, widget);
|
||||||
gdk_surface_set_widget (window->surface, NULL);
|
gdk_surface_set_widget (window->surface, NULL);
|
||||||
@@ -364,12 +355,6 @@ gtk_tooltip_window_hide (GtkWidget *widget)
|
|||||||
gtk_widget_unmap (widget);
|
gtk_widget_unmap (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void size_changed (GtkWidget *widget,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
int baseline,
|
|
||||||
GtkTooltipWindow *window);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_tooltip_window_dispose (GObject *object)
|
gtk_tooltip_window_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
@@ -377,7 +362,7 @@ gtk_tooltip_window_dispose (GObject *object)
|
|||||||
|
|
||||||
if (window->relative_to)
|
if (window->relative_to)
|
||||||
{
|
{
|
||||||
g_signal_handlers_disconnect_by_func (window->relative_to, size_changed, window);
|
gtk_native_set_tooltip (GTK_NATIVE (window->relative_to), NULL);
|
||||||
gtk_widget_unparent (GTK_WIDGET (window));
|
gtk_widget_unparent (GTK_WIDGET (window));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,16 +517,6 @@ gtk_tooltip_window_set_custom_widget (GtkTooltipWindow *window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
size_changed (GtkWidget *widget,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
int baseline,
|
|
||||||
GtkTooltipWindow *window)
|
|
||||||
{
|
|
||||||
gtk_native_check_resize (GTK_NATIVE (window));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_tooltip_window_set_relative_to (GtkTooltipWindow *window,
|
gtk_tooltip_window_set_relative_to (GtkTooltipWindow *window,
|
||||||
GtkWidget *relative_to)
|
GtkWidget *relative_to)
|
||||||
@@ -555,7 +530,7 @@ gtk_tooltip_window_set_relative_to (GtkTooltipWindow *window,
|
|||||||
|
|
||||||
if (window->relative_to)
|
if (window->relative_to)
|
||||||
{
|
{
|
||||||
g_signal_handlers_disconnect_by_func (window->relative_to, size_changed, window);
|
gtk_native_set_tooltip (GTK_NATIVE (window->relative_to), NULL);
|
||||||
gtk_widget_unparent (GTK_WIDGET (window));
|
gtk_widget_unparent (GTK_WIDGET (window));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,9 +538,7 @@ gtk_tooltip_window_set_relative_to (GtkTooltipWindow *window,
|
|||||||
|
|
||||||
if (window->relative_to)
|
if (window->relative_to)
|
||||||
{
|
{
|
||||||
g_signal_connect (window->relative_to, "size-allocate", G_CALLBACK (size_changed), window);
|
gtk_native_set_tooltip (GTK_NATIVE (relative_to), GTK_NATIVE (window));
|
||||||
gtk_css_node_set_parent (gtk_widget_get_css_node (GTK_WIDGET (window)),
|
|
||||||
gtk_widget_get_css_node (relative_to));
|
|
||||||
gtk_widget_set_parent (GTK_WIDGET (window), relative_to);
|
gtk_widget_set_parent (GTK_WIDGET (window), relative_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -267,6 +267,8 @@ typedef struct
|
|||||||
GdkToplevelLayout *layout;
|
GdkToplevelLayout *layout;
|
||||||
|
|
||||||
GdkCursor *resize_cursor;
|
GdkCursor *resize_cursor;
|
||||||
|
|
||||||
|
GtkNative *tooltip;
|
||||||
} GtkWindowPrivate;
|
} GtkWindowPrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -2130,6 +2132,16 @@ gtk_window_native_get_renderer (GtkNative *native)
|
|||||||
return priv->renderer;
|
return priv->renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_window_native_set_tooltip (GtkNative *native,
|
||||||
|
GtkNative *tooltip)
|
||||||
|
{
|
||||||
|
GtkWindow *self = GTK_WINDOW (native);
|
||||||
|
GtkWindowPrivate *priv = gtk_window_get_instance_private (self);
|
||||||
|
|
||||||
|
priv->tooltip = tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
static GtkConstraintSolver *
|
static GtkConstraintSolver *
|
||||||
gtk_window_root_get_constraint_solver (GtkRoot *root)
|
gtk_window_root_get_constraint_solver (GtkRoot *root)
|
||||||
{
|
{
|
||||||
@@ -2222,6 +2234,7 @@ gtk_window_native_interface_init (GtkNativeInterface *iface)
|
|||||||
iface->get_renderer = gtk_window_native_get_renderer;
|
iface->get_renderer = gtk_window_native_get_renderer;
|
||||||
iface->get_surface_transform = gtk_window_native_get_surface_transform;
|
iface->get_surface_transform = gtk_window_native_get_surface_transform;
|
||||||
iface->check_resize = gtk_window_native_check_resize;
|
iface->check_resize = gtk_window_native_check_resize;
|
||||||
|
iface->set_tooltip = gtk_window_native_set_tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -5080,13 +5093,15 @@ gtk_window_size_allocate (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkWindow *window = GTK_WINDOW (widget);
|
GtkWindow *window = GTK_WINDOW (widget);
|
||||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||||
GtkWidget *child = priv->child;
|
|
||||||
GtkAllocation child_allocation;
|
GtkAllocation child_allocation;
|
||||||
|
|
||||||
_gtk_window_set_allocation (window, width, height, &child_allocation);
|
_gtk_window_set_allocation (window, width, height, &child_allocation);
|
||||||
|
|
||||||
if (child && gtk_widget_get_visible (child))
|
if (priv->child && gtk_widget_get_visible (priv->child))
|
||||||
gtk_widget_size_allocate (child, &child_allocation, -1);
|
gtk_widget_size_allocate (priv->child, &child_allocation, -1);
|
||||||
|
|
||||||
|
if (priv->tooltip && gtk_widget_get_visible (GTK_WIDGET (priv->tooltip)))
|
||||||
|
gtk_native_check_resize (priv->tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
Reference in New Issue
Block a user