mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 03:10:09 +00:00
fontchooser: Fix smooth scrolling in the scale and the preview entry
This commit is contained in:
parent
33f9a1263c
commit
1859fe8dcf
@ -412,7 +412,7 @@ cursor_changed_cb (GtkTreeView *treeview,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
zoom_preview_cb (GtkWidget *scrolled_window,
|
||||
resize_by_scroll_cb (GtkWidget *scrolled_window,
|
||||
GdkEventScroll *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
@ -428,6 +428,15 @@ zoom_preview_cb (GtkWidget *scrolled_window,
|
||||
gtk_adjustment_set_value (adj,
|
||||
gtk_adjustment_get_value (adj) -
|
||||
gtk_adjustment_get_step_increment (adj));
|
||||
else if (event->direction == GDK_SCROLL_SMOOTH && event->delta_x != 0.0)
|
||||
gtk_adjustment_set_value (adj,
|
||||
gtk_adjustment_get_value (adj) +
|
||||
gtk_adjustment_get_step_increment (adj) * event->delta_x);
|
||||
else if (event->direction == GDK_SCROLL_SMOOTH && event->delta_y != 0.0)
|
||||
gtk_adjustment_set_value (adj,
|
||||
gtk_adjustment_get_value (adj) -
|
||||
gtk_adjustment_get_step_increment (adj) * event->delta_y);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -490,7 +499,7 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass)
|
||||
gtk_widget_class_bind_callback (widget_class, cursor_changed_cb);
|
||||
gtk_widget_class_bind_callback (widget_class, row_activated_cb);
|
||||
gtk_widget_class_bind_callback (widget_class, gtk_font_chooser_widget_set_cell_size);
|
||||
gtk_widget_class_bind_callback (widget_class, zoom_preview_cb);
|
||||
gtk_widget_class_bind_callback (widget_class, resize_by_scroll_cb);
|
||||
gtk_widget_class_bind_callback (widget_class, row_deleted_cb);
|
||||
gtk_widget_class_bind_callback (widget_class, row_inserted_cb);
|
||||
gtk_widget_class_bind_callback (widget_class, row_deleted_cb);
|
||||
@ -515,6 +524,7 @@ gtk_font_chooser_widget_init (GtkFontChooserWidget *fontchooser)
|
||||
/* Set default preview text */
|
||||
gtk_entry_set_text (GTK_ENTRY (priv->preview),
|
||||
pango_language_get_sample_string (NULL));
|
||||
gtk_widget_add_events (priv->preview, GDK_SCROLL_MASK);
|
||||
|
||||
/* Set the upper values of the spin/scale with G_MAXINT / PANGO_SCALE */
|
||||
gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->size_spin),
|
||||
|
@ -140,7 +140,7 @@
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="text">Sample string goes here</property>
|
||||
<signal name="scroll-event" handler="zoom_preview_cb" swapped="no"/>
|
||||
<signal name="scroll-event" handler="resize_by_scroll_cb" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
@ -156,7 +156,7 @@
|
||||
<property name="hexpand">True</property>
|
||||
<property name="adjustment">slider_adjustment</property>
|
||||
<property name="digits">0</property>
|
||||
<signal name="scroll-event" handler="zoom_preview_cb" swapped="no"/>
|
||||
<signal name="scroll-event" handler="resize_by_scroll_cb" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
|
Loading…
Reference in New Issue
Block a user