diff options
author | Benjamin Otte <otte@redhat.com> | 2018-03-20 23:55:20 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-03-21 00:43:28 +0100 |
commit | a1898d678bc6d052a15d7862b36f8a8fb5aaf311 (patch) | |
tree | 64a76f44f70a7985984403f97dceb3bdcd6ffe2f /tests | |
parent | d6ba10bacfca2e60ebe1480fd10cc0a6c18f19b3 (diff) | |
download | gtk+-a1898d678bc6d052a15d7862b36f8a8fb5aaf311.tar.gz |
surface: Remove gdk_surface_scroll()
It's yet another fancy way to call gdk_surface_invalidate_region().
Also remove the one testgtk test that was still using it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testgtk.c | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/tests/testgtk.c b/tests/testgtk.c index 01f2f409f3..b4982e02b2 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -6910,160 +6910,6 @@ create_snapshot (GtkWidget *widget) } /* - * Test scrolling - */ - -static int scroll_test_pos = 0.0; - -static void -scroll_test_draw (GtkDrawingArea *darea, - cairo_t *cr, - int width, - int height, - gpointer adjustment) -{ - gint i,j; - gint imin, imax, jmin, jmax; - GdkRectangle clip; - - gdk_cairo_get_clip_rectangle (cr, &clip); - - imin = (clip.x) / 10; - imax = (clip.x + clip.width + 9) / 10; - - jmin = ((int)gtk_adjustment_get_value (adjustment) + clip.y) / 10; - jmax = ((int)gtk_adjustment_get_value (adjustment) + clip.y + clip.height + 9) / 10; - - for (i=imin; i<imax; i++) - for (j=jmin; j<jmax; j++) - if ((i+j) % 2) - cairo_rectangle (cr, 10*i, 10*j - (int)gtk_adjustment_get_value (adjustment), 1+i%10, 1+j%10); - - cairo_fill (cr); -} - -static void -scroll_test_scroll (GtkEventControllerScroll *scroll, - double dx, - double dy, - GtkAdjustment *adjustment) -{ - gdouble new_value; - - new_value = gtk_adjustment_get_value (adjustment) + dy * gtk_adjustment_get_page_increment (adjustment) / 2; - new_value = CLAMP (new_value, gtk_adjustment_get_lower (adjustment), gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_page_size (adjustment)); - gtk_adjustment_set_value (adjustment, new_value); -} - -static void -scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event, - GtkAdjustment *adjustment) -{ - GtkAllocation allocation; - - gtk_widget_get_allocation (widget, &allocation); - gtk_adjustment_configure (adjustment, - gtk_adjustment_get_value (adjustment), - gtk_adjustment_get_lower (adjustment), - gtk_adjustment_get_upper (adjustment), - 0.1 * allocation.height, - 0.9 * allocation.height, - allocation.height); -} - -static void -scroll_test_adjustment_changed (GtkAdjustment *adjustment, GtkWidget *widget) -{ - GdkSurface *window; - gint dy; - - dy = scroll_test_pos - (int)gtk_adjustment_get_value (adjustment); - scroll_test_pos = gtk_adjustment_get_value (adjustment); - - if (!gtk_widget_is_drawable (widget)) - return; - - window = gtk_widget_get_surface (widget); - gdk_surface_scroll (window, 0, dy); -} - - -void -create_scroll_test (GtkWidget *widget) -{ - static GtkWidget *window = NULL; - GtkWidget *content_area; - GtkWidget *hbox; - GtkWidget *drawing_area; - GtkWidget *scrollbar; - GtkAdjustment *adjustment; - GtkEventController *controller; - - if (!window) - { - window = gtk_dialog_new (); - - gtk_window_set_display (GTK_WINDOW (window), - gtk_widget_get_display (widget)); - - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_widget_destroyed), - &window); - - content_area = gtk_dialog_get_content_area (GTK_DIALOG (window)); - - gtk_window_set_title (GTK_WINDOW (window), "Scroll Test"); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (content_area), hbox); - gtk_widget_show (hbox); - - adjustment = gtk_adjustment_new (0.0, 0.0, 1000.0, 1.0, 180.0, 200.0); - scroll_test_pos = 0.0; - - drawing_area = gtk_drawing_area_new (); - gtk_widget_set_hexpand (drawing_area, TRUE); - gtk_widget_set_vexpand (drawing_area, TRUE); - gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (drawing_area), 200); - gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (drawing_area), 200); - gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), - scroll_test_draw, - adjustment, - g_object_unref); - gtk_box_pack_start (GTK_BOX (hbox), drawing_area); - gtk_widget_show (drawing_area); - - scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjustment); - gtk_box_pack_start (GTK_BOX (hbox), scrollbar); - gtk_widget_show (scrollbar); - - g_signal_connect (drawing_area, "configure_event", - G_CALLBACK (scroll_test_configure), adjustment); - controller = gtk_event_controller_scroll_new (drawing_area, GTK_EVENT_CONTROLLER_SCROLL_VERTICAL); - g_object_set_data_full (G_OBJECT (drawing_area), "scroll", controller, g_object_unref); - g_signal_connect (controller, "scroll", G_CALLBACK (scroll_test_scroll), adjustment); - - g_signal_connect (adjustment, "value_changed", - G_CALLBACK (scroll_test_adjustment_changed), - drawing_area); - - /* .. And create some buttons */ - - gtk_dialog_add_button (GTK_DIALOG (window), - "Quit", - GTK_RESPONSE_CLOSE); - g_signal_connect_swapped (window, "response", - G_CALLBACK (gtk_widget_destroy), - window); - } - - if (!gtk_widget_get_visible (window)) - gtk_widget_show (window); - else - gtk_widget_destroy (window); -} - -/* * Timeout Test */ @@ -7774,7 +7620,6 @@ struct { { "spinbutton", create_spins }, { "statusbar", create_statusbar }, { "test mainloop", create_mainloop, TRUE }, - { "test scrolling", create_scroll_test }, { "test timeout", create_timeout_test }, { "toggle buttons", create_toggle_buttons }, { "tooltips", create_tooltips }, |