Merge branch 'wip/exalm/text-handles' into 'master'

texthandle: Add a contents css node

Closes #3475

See merge request GNOME/gtk!3511
This commit is contained in:
Matthias Clasen 2021-05-04 21:40:48 +00:00
commit a3cccbeb53

View File

@ -17,7 +17,8 @@
#include "config.h" #include "config.h"
#include "gtkcssnumbervalueprivate.h" #include "gtkbinlayout.h"
#include "gtkgizmoprivate.h"
#include "gtkprivatetypebuiltins.h" #include "gtkprivatetypebuiltins.h"
#include "gtktexthandleprivate.h" #include "gtktexthandleprivate.h"
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
@ -47,6 +48,7 @@ struct _GtkTextHandle
GskRenderer *renderer; GskRenderer *renderer;
GtkEventController *controller; GtkEventController *controller;
GtkWidget *controller_widget; GtkWidget *controller_widget;
GtkWidget *contents;
GdkRectangle pointing_to; GdkRectangle pointing_to;
GtkBorder border; GtkBorder border;
@ -221,6 +223,8 @@ gtk_text_handle_snapshot (GtkWidget *widget,
snapshot, snapshot,
gtk_widget_get_width (widget), gtk_widget_get_width (widget),
gtk_widget_get_height (widget)); gtk_widget_get_height (widget));
GTK_WIDGET_CLASS (gtk_text_handle_parent_class)->snapshot (widget, snapshot);
} }
static void static void
@ -322,18 +326,13 @@ gtk_text_handle_unmap (GtkWidget *widget)
} }
static void static void
gtk_text_handle_measure (GtkWidget *widget, gtk_text_handle_dispose (GObject *object)
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{ {
*natural = 0; GtkTextHandle *handle = GTK_TEXT_HANDLE (object);
*minimum = 0;
*minimum_baseline = -1; g_clear_pointer (&handle->contents, gtk_widget_unparent);
*natural_baseline = -1;
G_OBJECT_CLASS (gtk_text_handle_parent_class)->dispose (object);
} }
static void static void
@ -342,12 +341,13 @@ gtk_text_handle_class_init (GtkTextHandleClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_text_handle_dispose;
widget_class->snapshot = gtk_text_handle_snapshot; widget_class->snapshot = gtk_text_handle_snapshot;
widget_class->realize = gtk_text_handle_realize; widget_class->realize = gtk_text_handle_realize;
widget_class->unrealize = gtk_text_handle_unrealize; widget_class->unrealize = gtk_text_handle_unrealize;
widget_class->map = gtk_text_handle_map; widget_class->map = gtk_text_handle_map;
widget_class->unmap = gtk_text_handle_unmap; widget_class->unmap = gtk_text_handle_unmap;
widget_class->measure = gtk_text_handle_measure;
signals[HANDLE_DRAGGED] = signals[HANDLE_DRAGGED] =
g_signal_new (I_("handle-dragged"), g_signal_new (I_("handle-dragged"),
@ -373,6 +373,7 @@ gtk_text_handle_class_init (GtkTextHandleClass *klass)
G_TYPE_NONE, 0, G_TYPE_NONE); G_TYPE_NONE, 0, G_TYPE_NONE);
gtk_widget_class_set_css_name (widget_class, I_("cursor-handle")); gtk_widget_class_set_css_name (widget_class, I_("cursor-handle"));
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
} }
/* Relative to pointing_to x/y */ /* Relative to pointing_to x/y */
@ -507,6 +508,10 @@ gtk_text_handle_update_for_role (GtkTextHandle *handle)
static void static void
gtk_text_handle_init (GtkTextHandle *handle) gtk_text_handle_init (GtkTextHandle *handle)
{ {
handle->contents = gtk_gizmo_new ("contents", NULL, NULL, NULL, NULL, NULL, NULL);
gtk_widget_set_can_target (handle->contents, FALSE);
gtk_widget_set_parent (handle->contents, GTK_WIDGET (handle));
gtk_text_handle_update_for_role (handle); gtk_text_handle_update_for_role (handle);
} }