mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
5d05daaed0
Add buttons to cycle through samples.
66 lines
2.5 KiB
Plaintext
66 lines
2.5 KiB
Plaintext
--- demos/gtk-demo/font_features.c
|
|
+++ demos/gtk-demo/font_features.c
|
|
@@ -434,7 +434,7 @@ static void
|
|
update_display (void)
|
|
{
|
|
GString *s;
|
|
- const char *text;
|
|
+ char *text;
|
|
gboolean has_feature;
|
|
GtkTreeIter iter;
|
|
GtkTreeModel *model;
|
|
@@ -452,8 +452,12 @@ update_display (void)
|
|
gboolean do_waterfall;
|
|
GString *waterfall;
|
|
char *palette;
|
|
+ GtkTextBuffer *buffer;
|
|
+ GtkTextIter start_iter, end_iter;
|
|
|
|
- text = gtk_editable_get_text (GTK_EDITABLE (demo->the_entry));
|
|
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry));
|
|
+ gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);
|
|
+ text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE);
|
|
text_len = strlen (text);
|
|
|
|
do_waterfall = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (demo->waterfall_toggle));
|
|
@@ -631,6 +635,8 @@ update_display (void)
|
|
pango2_font_description_free (desc);
|
|
g_free (features);
|
|
pango2_attr_list_unref (attrs);
|
|
+
|
|
+ g_free (text);
|
|
}
|
|
|
|
static Pango2Font *
|
|
@@ -1603,8 +1609,12 @@ font_features_toggle_edit (void)
|
|
{
|
|
if (strcmp (gtk_stack_get_visible_child_name (GTK_STACK (demo->stack)), "entry") != 0)
|
|
{
|
|
+ GtkTextBuffer *buffer;
|
|
+ GtkTextIter start, end;
|
|
g_free (demo->text);
|
|
- demo->text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (demo->the_entry)));
|
|
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry));
|
|
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
|
|
+ demo->text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
|
gtk_stack_set_visible_child_name (GTK_STACK (demo->stack), "entry");
|
|
gtk_widget_grab_focus (demo->the_entry);
|
|
gtk_adjustment_set_value (gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (demo->swin)), 0);
|
|
@@ -1632,7 +1642,7 @@ entry_key_press (GtkEventController *controller,
|
|
{
|
|
if (keyval == GDK_KEY_Escape)
|
|
{
|
|
- gtk_editable_set_text (GTK_EDITABLE (entry), demo->text);
|
|
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry)), demo->text, -1);
|
|
return GDK_EVENT_STOP;
|
|
}
|
|
|
|
@@ -1701,7 +1711,6 @@ do_font_features (GtkWidget *do_widget)
|
|
basic_value_changed (demo->line_height_adjustment, demo->line_height_entry);
|
|
|
|
controller = gtk_event_controller_key_new ();
|
|
- g_object_set_data_full (G_OBJECT (demo->the_entry), "controller", g_object_ref (controller), g_object_unref);
|
|
g_signal_connect (controller, "key-pressed", G_CALLBACK (entry_key_press), demo->the_entry);
|
|
gtk_widget_add_controller (demo->the_entry, controller);
|
|
|