forked from AuroraMiddleware/gtk
Merge branch 'emoji-chooser-fixes' into 'master'
Emoji chooser fixes See merge request GNOME/gtk!816
This commit is contained in:
commit
96cce3ae23
@ -153,11 +153,9 @@ populate_recent_section (GtkEmojiChooser *chooser)
|
|||||||
empty = FALSE;
|
empty = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty)
|
gtk_widget_set_visible (chooser->recent.box, !empty);
|
||||||
{
|
gtk_widget_set_sensitive (chooser->recent.button, !empty);
|
||||||
gtk_widget_show (chooser->recent.box);
|
|
||||||
gtk_widget_set_sensitive (chooser->recent.button, TRUE);
|
|
||||||
}
|
|
||||||
g_variant_unref (variant);
|
g_variant_unref (variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,9 +456,6 @@ populate_emoji_chooser (gpointer data)
|
|||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We scroll to the top on show, so check the right button for the 1st time */
|
|
||||||
gtk_widget_set_state_flags (chooser->recent.button, GTK_STATE_FLAG_CHECKED, FALSE);
|
|
||||||
|
|
||||||
g_variant_iter_free (chooser->iter);
|
g_variant_iter_free (chooser->iter);
|
||||||
chooser->iter = NULL;
|
chooser->iter = NULL;
|
||||||
chooser->box = NULL;
|
chooser->box = NULL;
|
||||||
@ -496,6 +491,9 @@ adj_value_changed (GtkAdjustment *adj,
|
|||||||
EmojiSection const *section = sections[i];
|
EmojiSection const *section = sections[i];
|
||||||
GtkAllocation alloc;
|
GtkAllocation alloc;
|
||||||
|
|
||||||
|
if (!gtk_widget_get_visible (section->box))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (section->heading)
|
if (section->heading)
|
||||||
gtk_widget_get_allocation (section->heading, &alloc);
|
gtk_widget_get_allocation (section->heading, &alloc);
|
||||||
else
|
else
|
||||||
@ -611,6 +609,13 @@ search_changed (GtkEntry *entry,
|
|||||||
update_headings (chooser);
|
update_headings (chooser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
stop_search (GtkEntry *entry,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
gtk_popover_popdown (GTK_POPOVER (data));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_section (GtkEmojiChooser *chooser,
|
setup_section (GtkEmojiChooser *chooser,
|
||||||
EmojiSection *section,
|
EmojiSection *section,
|
||||||
@ -693,6 +698,7 @@ gtk_emoji_chooser_show (GtkWidget *widget)
|
|||||||
|
|
||||||
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window));
|
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window));
|
||||||
gtk_adjustment_set_value (adj, 0);
|
gtk_adjustment_set_value (adj, 0);
|
||||||
|
adj_value_changed (adj, chooser);
|
||||||
|
|
||||||
gtk_editable_set_text (GTK_EDITABLE (chooser->search_entry), "");
|
gtk_editable_set_text (GTK_EDITABLE (chooser->search_entry), "");
|
||||||
}
|
}
|
||||||
@ -761,6 +767,7 @@ gtk_emoji_chooser_class_init (GtkEmojiChooserClass *klass)
|
|||||||
|
|
||||||
gtk_widget_class_bind_template_callback (widget_class, emoji_activated);
|
gtk_widget_class_bind_template_callback (widget_class, emoji_activated);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, search_changed);
|
gtk_widget_class_bind_template_callback (widget_class, search_changed);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, stop_search);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, pressed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, pressed_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, long_pressed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, long_pressed_cb);
|
||||||
}
|
}
|
||||||
|
@ -3447,42 +3447,19 @@ gtk_entry_enter_text (GtkEntry *entry,
|
|||||||
gtk_text_enter_text (GTK_TEXT (priv->text), text);
|
gtk_text_enter_text (GTK_TEXT (priv->text), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_entry_insert_emoji (GtkEntry *entry)
|
|
||||||
{
|
|
||||||
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
|
|
||||||
GtkWidget *chooser;
|
|
||||||
GdkRectangle rect;
|
|
||||||
|
|
||||||
if (gtk_widget_get_ancestor (GTK_WIDGET (entry), GTK_TYPE_EMOJI_CHOOSER) != NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
chooser = GTK_WIDGET (g_object_get_data (G_OBJECT (entry), "gtk-emoji-chooser"));
|
|
||||||
if (!chooser)
|
|
||||||
{
|
|
||||||
chooser = gtk_emoji_chooser_new ();
|
|
||||||
g_object_set_data (G_OBJECT (entry), "gtk-emoji-chooser", chooser);
|
|
||||||
|
|
||||||
gtk_popover_set_relative_to (GTK_POPOVER (chooser), GTK_WIDGET (entry));
|
|
||||||
if (priv->show_emoji_icon)
|
|
||||||
{
|
|
||||||
gtk_entry_get_icon_area (entry, GTK_ENTRY_ICON_SECONDARY, &rect);
|
|
||||||
gtk_popover_set_pointing_to (GTK_POPOVER (chooser), &rect);
|
|
||||||
}
|
|
||||||
g_signal_connect_swapped (chooser, "emoji-picked", G_CALLBACK (gtk_entry_enter_text), entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_popover_popup (GTK_POPOVER (chooser));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pick_emoji (GtkEntry *entry,
|
pick_emoji (GtkEntry *entry,
|
||||||
int icon,
|
int icon,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
|
||||||
|
|
||||||
|
if (gtk_widget_get_ancestor (GTK_WIDGET (entry), GTK_TYPE_EMOJI_CHOOSER) != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (icon == GTK_ENTRY_ICON_SECONDARY)
|
if (icon == GTK_ENTRY_ICON_SECONDARY)
|
||||||
gtk_entry_insert_emoji (entry);
|
g_signal_emit_by_name (priv->text, "insert-emoji");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkSearchEntry" id="search_entry">
|
<object class="GtkSearchEntry" id="search_entry">
|
||||||
<signal name="search-changed" handler="search_changed"/>
|
<signal name="search-changed" handler="search_changed"/>
|
||||||
|
<signal name="stop-search" handler="stop_search"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
Loading…
Reference in New Issue
Block a user