From f66172451d5da713b2c947dcb2e175528abe57e9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 Nov 2021 18:37:33 -0500 Subject: [PATCH 1/4] textview: Respect editability for Emoji Switch the Emoji chooser keybinding to use the action, so that disabling the action has the desired effect. --- gtk/gtktextview.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index db23e9ad86..f576aaf748 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -1863,13 +1863,13 @@ gtk_text_view_class_init (GtkTextViewClass *klass) NULL); /* Emoji */ - gtk_widget_class_add_binding_signal (widget_class, + gtk_widget_class_add_binding_action (widget_class, GDK_KEY_period, GDK_CONTROL_MASK, - "insert-emoji", + "misc.insert-emoji", NULL); - gtk_widget_class_add_binding_signal (widget_class, + gtk_widget_class_add_binding_action (widget_class, GDK_KEY_semicolon, GDK_CONTROL_MASK, - "insert-emoji", + "misc.insert-emoji", NULL); /* Caret mode */ From e0deacd2368b9776cebe9955e7788cfad56af553 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 Nov 2021 18:38:33 -0500 Subject: [PATCH 2/4] inspector: Make dropdowns bigger If there's enough values to warrant scrolling, the dropdown was much too small for comfort. --- gtk/inspector/prop-editor.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c index 247cfc8c03..822e0ef722 100644 --- a/gtk/inspector/prop-editor.c +++ b/gtk/inspector/prop-editor.c @@ -221,7 +221,7 @@ static void int_modified (GtkAdjustment *adj, ObjectProperty *p) { GValue val = G_VALUE_INIT; - + g_value_init (&val, G_TYPE_INT); g_value_set_int (&val, (int) gtk_adjustment_get_value (adj)); set_property_value (p->obj, p->spec, &val); @@ -250,7 +250,7 @@ static void uint_modified (GtkAdjustment *adj, ObjectProperty *p) { GValue val = G_VALUE_INIT; - + g_value_init (&val, G_TYPE_UINT); g_value_set_uint (&val, (guint) gtk_adjustment_get_value (adj)); set_property_value (p->obj, p->spec, &val); @@ -280,7 +280,7 @@ static void float_modified (GtkAdjustment *adj, ObjectProperty *p) { GValue val = G_VALUE_INIT; - + g_value_init (&val, G_TYPE_FLOAT); g_value_set_float (&val, (float) gtk_adjustment_get_value (adj)); set_property_value (p->obj, p->spec, &val); @@ -310,7 +310,7 @@ static void double_modified (GtkAdjustment *adj, ObjectProperty *p) { GValue val = G_VALUE_INIT; - + g_value_init (&val, G_TYPE_DOUBLE); g_value_set_double (&val, gtk_adjustment_get_value (adj)); set_property_value (p->obj, p->spec, &val); @@ -340,7 +340,7 @@ static void string_modified (GtkEntry *entry, ObjectProperty *p) { GValue val = G_VALUE_INIT; - + g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, gtk_editable_get_text (GTK_EDITABLE (entry))); set_property_value (p->obj, p->spec, &val); @@ -1072,7 +1072,12 @@ property_editor (GObject *object, } if (j >= 10) - g_object_set (sw, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL); + { + g_object_set (sw, + "vscrollbar-policy", GTK_POLICY_AUTOMATIC, + "min-content-height", 250, + NULL); + } g_type_class_unref (fclass); @@ -1208,7 +1213,7 @@ gtk_cell_layout_get_model (GtkCellLayout *layout) return gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_tree_view_column_get_tree_view (GTK_TREE_VIEW_COLUMN (layout)))); else if (GTK_IS_ICON_VIEW (layout)) return gtk_icon_view_get_model (GTK_ICON_VIEW (layout)); - else if (GTK_IS_COMBO_BOX (layout)) + else if (GTK_IS_COMBO_BOX (layout)) return gtk_combo_box_get_model (GTK_COMBO_BOX (layout)); else return NULL; @@ -1350,7 +1355,7 @@ attribute_editor (GObject *object, { area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (layout)); col = gtk_cell_area_attribute_get_column (area, - GTK_CELL_RENDERER (object), + GTK_CELL_RENDERER (object), self->name); model = gtk_cell_layout_get_model (GTK_CELL_LAYOUT (layout)); } @@ -1702,7 +1707,7 @@ set_property (GObject *object, default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); break; - } + } } static void From b3b0321620ae3a76b893c8b8bc84b8025fb2280f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 Nov 2021 19:44:26 -0500 Subject: [PATCH 3/4] textview: Avoid misplacing the Emoji chooser When the iter is at the end of the buffer, gtk_text_view_get_iter_location returns a rectangle with width 0, which in turn makes gdk_rectangle_intersect return FALSE. Avoid that by always giving the rectangle non-empty dimensions. Fixes: #4503 --- gtk/gtktextview.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index f576aaf748..c1b83eb9b3 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -10012,6 +10012,10 @@ gtk_text_view_insert_emoji (GtkTextView *text_view) gtk_text_buffer_get_insert (buffer)); gtk_text_view_get_iter_location (text_view, &iter, (GdkRectangle *) &rect); + + rect.width = MAX (rect.width, 1); + rect.height = MAX (rect.height, 1); + gtk_text_view_buffer_to_window_coords (text_view, GTK_TEXT_WINDOW_TEXT, rect.x, rect.y, &rect.x, &rect.y); _text_window_to_widget_coords (text_view, &rect.x, &rect.y); From 5a42ccc57557d966d55dfadd7f0f624a901cd370 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 Nov 2021 19:51:22 -0500 Subject: [PATCH 4/4] docs: Clarify a sentence in the migration guide Make it clear that we are giving examples of no-longer existing APIs here. Fixes: #4479 --- docs/reference/gtk/migrating-3to4.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/gtk/migrating-3to4.md b/docs/reference/gtk/migrating-3to4.md index fcb3af5d76..068b97212a 100644 --- a/docs/reference/gtk/migrating-3to4.md +++ b/docs/reference/gtk/migrating-3to4.md @@ -410,8 +410,8 @@ have been removed. Update your code accordingly. Any APIs that deal with global (or root) coordinates have been removed in GTK 4, since not all backends support them. You should replace your use of such APIs with surface-relative equivalents. -Examples of this are `gdk_surface_get_origin()`, `gdk_surface_move()` -or `gdk_event_get_root_coords()`. +Examples of such removed APIs are `gdk_window_get_origin()`, +`gdk_window_move()` or `gdk_event_get_root_coords()`. ### Adapt to `GdkKeymap` API changes