Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!2145
This commit is contained in:
Matthias Clasen 2020-06-24 19:50:37 +00:00
commit ba1944ded2
4 changed files with 102 additions and 133 deletions

View File

@ -12,22 +12,48 @@
static GtkTreeModel *
create_completion_model (void)
{
const char *strings[] = {
"GNOME",
"gnominious",
"Gnomonic projection",
"Gnosophy",
"total",
"totally",
"toto",
"tottery",
"totterer",
"Totten trust",
"Tottenham hotspurs",
"totipotent",
"totipotency",
"totemism",
"totem pole",
"Totara",
"totalizer",
"totalizator",
"totalitarianism",
"total parenteral nutrition",
"total eclipse",
"Totipresence",
"Totipalmi",
"zombie",
"aæx",
"aæy",
"aæz",
NULL
};
int i;
GtkListStore *store;
GtkTreeIter iter;
store = gtk_list_store_new (1, G_TYPE_STRING);
/* Append one word */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "GNOME", -1);
/* Append another word */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "total", -1);
/* And another word */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "totally", -1);
for (i = 0; strings[i]; i++)
{
/* Append one word */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, strings[i], -1);
}
return GTK_TREE_MODEL (store);
}
@ -81,6 +107,9 @@ do_entry_completion (GtkWidget *do_widget)
/* Use model column 0 as the text column */
gtk_entry_completion_set_text_column (completion, 0);
gtk_entry_completion_set_inline_completion (completion, TRUE);
gtk_entry_completion_set_inline_selection (completion, TRUE);
}
if (!gtk_widget_get_visible (window))

View File

@ -1351,23 +1351,24 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
{
gint len;
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
if (completion->changed_id > 0)
g_signal_handler_block (text, completion->changed_id);
if (completion->insert_text_id > 0)
g_signal_handler_block (text, completion->insert_text_id);
g_signal_handler_block (buffer, completion->insert_text_id);
gtk_editable_set_text (GTK_EDITABLE (completion->entry), new_text);
len = strlen (completion->completion_prefix);
len = g_utf8_strlen (completion->completion_prefix, -1);
gtk_editable_select_region (GTK_EDITABLE (completion->entry), len, -1);
if (completion->changed_id > 0)
g_signal_handler_unblock (text, completion->changed_id);
if (completion->insert_text_id > 0)
g_signal_handler_unblock (text, completion->insert_text_id);
g_signal_handler_unblock (buffer, completion->insert_text_id);
}
static gboolean
@ -1403,9 +1404,10 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
gboolean done;
gchar *prefix;
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
if (completion->insert_text_id > 0)
g_signal_handler_block (text, completion->insert_text_id);
g_signal_handler_block (buffer, completion->insert_text_id);
prefix = gtk_entry_completion_compute_prefix (completion,
gtk_editable_get_text (GTK_EDITABLE (completion->entry)));
@ -1418,7 +1420,7 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
}
if (completion->insert_text_id > 0)
g_signal_handler_unblock (text, completion->insert_text_id);
g_signal_handler_unblock (buffer, completion->insert_text_id);
}
/**
@ -1859,10 +1861,7 @@ gtk_entry_completion_key_pressed (GtkEventControllerKey *controller,
keypress_completion_out:
if (completion->inline_selection)
{
g_free (completion->completion_prefix);
completion->completion_prefix = NULL;
}
g_clear_pointer (&completion->completion_prefix, g_free);
return retval;
}
@ -1873,8 +1872,7 @@ keypress_completion_out:
gtk_entry_reset_im_context (GTK_ENTRY (widget));
_gtk_entry_completion_popdown (completion);
g_free (completion->completion_prefix);
completion->completion_prefix = NULL;
g_clear_pointer (&completion->completion_prefix, g_free);
return FALSE;
}
@ -1925,12 +1923,13 @@ keypress_completion_out:
retval = FALSE;
}
g_free (completion->completion_prefix);
completion->completion_prefix = NULL;
g_clear_pointer (&completion->completion_prefix, g_free);
return retval;
}
g_clear_pointer (&completion->completion_prefix, g_free);
return FALSE;
}
@ -2014,11 +2013,11 @@ text_focus_out (GtkEntryCompletion *completion)
}
static void
completion_insert_text_callback (GtkText *entry,
const gchar *text,
gint length,
gint position,
GtkEntryCompletion *completion)
completion_inserted_text_callback (GtkEntryBuffer *buffer,
guint position,
const char *text,
guint length,
GtkEntryCompletion *completion)
{
if (!completion->inline_completion)
return;
@ -2041,6 +2040,7 @@ connect_completion_signals (GtkEntryCompletion *completion)
{
GtkEventController *controller;
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
controller = completion->entry_key_controller = gtk_event_controller_key_new ();
gtk_event_controller_set_name (controller, "gtk-entry-completion");
@ -2055,10 +2055,10 @@ connect_completion_signals (GtkEntryCompletion *completion)
completion->changed_id =
g_signal_connect (text, "changed", G_CALLBACK (gtk_entry_completion_changed), completion);
completion->insert_text_id =
g_signal_connect (text, "insert-text", G_CALLBACK (completion_insert_text_callback), completion);
g_signal_connect (text, "notify", G_CALLBACK (clear_completion_callback), completion);
g_signal_connect_swapped (text, "activate", G_CALLBACK (accept_completion_callback), completion);
completion->insert_text_id =
g_signal_connect (buffer, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
g_signal_connect (text, "notify", G_CALLBACK (clear_completion_callback), completion);
g_signal_connect_swapped (text, "activate", G_CALLBACK (accept_completion_callback), completion);
}
static void
@ -2095,6 +2095,7 @@ static void
disconnect_completion_signals (GtkEntryCompletion *completion)
{
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_key_controller);
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_focus_controller);
@ -2106,12 +2107,11 @@ disconnect_completion_signals (GtkEntryCompletion *completion)
completion->changed_id = 0;
}
if (completion->insert_text_id > 0 &&
g_signal_handler_is_connected (text, completion->insert_text_id))
g_signal_handler_is_connected (buffer, completion->insert_text_id))
{
g_signal_handler_disconnect (text, completion->insert_text_id);
g_signal_handler_disconnect (buffer, completion->insert_text_id);
completion->insert_text_id = 0;
}
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (completion_insert_text_callback), completion);
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (clear_completion_callback), completion);
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (accept_completion_callback), completion);
}

View File

@ -649,6 +649,7 @@ gtk_public_headers = files([
'gtkstackswitcher.h',
'gtkstatusbar.h',
'gtkstringfilter.h',
'gtkstringlist.h',
'gtkstringsorter.h',
'gtkstylecontext.h',
'gtkstyleprovider.h',

View File

@ -2812,103 +2812,42 @@ cursor_draw (GtkDrawingArea *darea,
}
static const gchar *cursor_names[] = {
"all-scroll",
"arrow",
"bd_double_arrow",
"boat",
"bottom_left_corner",
"bottom_right_corner",
"bottom_side",
"bottom_tee",
"box_spiral",
"center_ptr",
"circle",
"clock",
"coffee_mug",
"copy",
"cross",
"crossed_circle",
"cross_reverse",
"crosshair",
"diamond_cross",
"dnd-ask",
"dnd-copy",
"dnd-link",
"dnd-move",
"dnd-none",
"dot",
"dotbox",
"double_arrow",
"draft_large",
"draft_small",
"draped_box",
"exchange",
"fd_double_arrow",
"fleur",
"gobbler",
"gumby",
"grab",
"grabbing",
"hand",
"hand1",
"hand2",
"heart",
"h_double_arrow",
"help",
"icon",
"iron_cross",
"left_ptr",
"left_ptr_help",
"left_ptr_watch",
"left_side",
"left_tee",
"leftbutton",
"link",
"ll_angle",
"lr_angle",
"man",
"middlebutton",
"mouse",
"move",
"pencil",
"pirate",
"plus",
"question_arrow",
"right_ptr",
"right_side",
"right_tee",
"rightbutton",
"rtl_logo",
"sailboat",
"sb_down_arrow",
"sb_h_double_arrow",
"sb_left_arrow",
"sb_right_arrow",
"sb_up_arrow",
"sb_v_double_arrow",
"shuttle",
"sizing",
"spider",
"spraycan",
"star",
"target",
"tcross",
"top_left_arrow",
"top_left_corner",
"top_right_corner",
"top_side",
"top_tee",
"trek",
"ul_angle",
"umbrella",
"ur_angle",
"v_double_arrow",
"vertical-text",
"watch",
"X_cursor",
"xterm",
"zoom-in",
"zoom-out"
"none",
"default",
"help",
"pointer",
"context-menu",
"progress",
"wait",
"cell",
"crosshair",
"text",
"vertical-text",
"alias",
"copy",
"no-drop",
"move",
"not-allowed",
"grab",
"grabbing",
"all-scroll",
"col-resize",
"row-resize",
"n-resize",
"e-resize",
"s-resize",
"w-resize",
"ne-resize",
"nw-resize",
"sw-resize",
"se-resize",
"ew-resize",
"ns-resize",
"nesw-resize",
"nwse-resize",
"zoom-in",
"zoom-out",
NULL
};
static GtkTreeModel *