X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fpager.c;h=efb941b46f39bb945e82292539e89c5371d09f02;hb=59f3bc1e4f21377c362c1f497fb225711127d7a0;hp=05cf4bf7ddc013af8b0c09d251f37169c381da76;hpb=cde02483d08c75df278b2324d5df4f87b75b0b70;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/pager.c b/libchimara/pager.c index 05cf4bf..efb941b 100644 --- a/libchimara/pager.c +++ b/libchimara/pager.c @@ -34,7 +34,7 @@ move_pager_and_get_scroll_distance(GtkTextView *textview, gint *view_height, gin /* g_printerr("View height = %d\n", visiblerect.height); - g_printerr("End - Pager = %d\n", endpos.y - pagerpos.y); + g_printerr("End - Pager = %d - %d = %d\n", endpos.y, pagerpos.y, endpos.y - pagerpos.y); */ *view_height = visiblerect.height; @@ -81,49 +81,43 @@ gboolean pager_on_key_press_event(GtkTextView *textview, GdkEventKey *event, winid_t win) { GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(win->frame) ); - gdouble step_increment, page_size, upper, lower, value; + gdouble page_size, upper, lower, value; g_object_get(adj, "page-size", &page_size, - "step-increment", &step_increment, "upper", &upper, "lower", &lower, "value", &value, NULL); switch (event->keyval) { - case GDK_space: case GDK_KP_Space: case GDK_Page_Down: case GDK_KP_Page_Down: + case GDK_KEY_space: case GDK_KEY_KP_Space: + case GDK_KEY_Page_Down: case GDK_KEY_KP_Page_Down: + case GDK_KEY_Return: case GDK_KEY_KP_Enter: gtk_adjustment_set_value(adj, CLAMP(value + page_size, lower, upper - page_size)); return TRUE; - case GDK_Page_Up: case GDK_KP_Page_Up: + case GDK_KEY_Page_Up: case GDK_KEY_KP_Page_Up: gtk_adjustment_set_value(adj, CLAMP(value - page_size, lower, upper - page_size)); return TRUE; - case GDK_Return: case GDK_KP_Enter: - gtk_adjustment_set_value(adj, CLAMP(value + step_increment, lower, upper - page_size)); - return TRUE; /* don't handle "up" and "down", they're used for input history */ } return FALSE; /* if the key wasn't handled here, pass it to other handlers */ } -/* Draw the "more" prompt on top of the buffer, after the regular expose event has run */ +/* Draw the "more" prompt on top of the buffer, after the regular draw event has run */ gboolean -pager_on_expose(GtkTextView *textview, GdkEventExpose *event, winid_t win) +pager_on_draw(GtkTextView *textview, cairo_t *cr, winid_t win) { /* Calculate the position of the 'more' tag */ gint promptwidth, promptheight; pango_layout_get_pixel_size(win->pager_layout, &promptwidth, &promptheight); - gint winx, winy, winwidth, winheight; - gdk_window_get_position(event->window, &winx, &winy); - gdk_drawable_get_size(GDK_DRAWABLE(event->window), &winwidth, &winheight); + int winwidth = gtk_widget_get_allocated_width( GTK_WIDGET(textview) ); + int winheight = gtk_widget_get_allocated_height( GTK_WIDGET(textview) ); /* Draw the 'more' tag */ - GdkGC *context = gdk_gc_new(GDK_DRAWABLE(event->window)); - gdk_draw_layout(event->window, context, - winx + winwidth - promptwidth, - winy + winheight - promptheight, - win->pager_layout); + cairo_move_to(cr, winwidth - promptwidth, winheight - promptheight); + pango_cairo_show_layout(cr, win->pager_layout); return FALSE; /* Propagate event further */ } @@ -131,7 +125,7 @@ pager_on_expose(GtkTextView *textview, GdkEventExpose *event, winid_t win) /* Check whether paging should be done. This function is called after the * textview has finished validating text positions. */ void -pager_after_size_request(GtkTextView *textview, GtkRequisition *requisition, winid_t win) +pager_after_size_allocate(GtkTextView *textview, GdkRectangle *allocation, winid_t win) { /* Move the pager to the last visible character in the buffer */ gint view_height, scroll_distance; @@ -163,13 +157,7 @@ pager_after_size_request(GtkTextView *textview, GtkRequisition *requisition, win if(!win->currently_paging) { if(scroll_distance > view_height) { start_paging(win); - /* Seriously... */ - /* COMPAT: */ -#if GTK_CHECK_VERSION(2,14,0) gdk_window_invalidate_rect(gtk_widget_get_window(win->widget), NULL, TRUE); -#else - gdk_window_invalidate_rect(win->widget->window, NULL, TRUE); -#endif } } }