From: Philip Chimento Date: Sat, 25 Aug 2012 19:04:04 +0000 (+0200) Subject: Replace deprecated signals X-Git-Tag: v0.9~25 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=7f5205d4bee2fbc2ca2b9e26b961d37b2d656c55;p=projects%2Fchimara%2Fchimara.git Replace deprecated signals The 'size-request' and 'expose-event' signals now don't exist anymore. 'expose-event' is simply replaced by 'draw'. We used 'size-request' in a slightly different way than it was supposed to be: connecting a handler after the default 'size-request' handler run, ensured that the handler was run after the GtkTextView finished validating text positions, so we could scroll the text view to the end after printing text to it. Luckily, 'size-allocate' works the same way in GTK 3. --- diff --git a/libchimara/pager.c b/libchimara/pager.c index c620bac..c04553f 100644 --- a/libchimara/pager.c +++ b/libchimara/pager.c @@ -104,24 +104,20 @@ pager_on_key_press_event(GtkTextView *textview, GdkEventKey *event, winid_t win) 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 */ } @@ -129,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; diff --git a/libchimara/pager.h b/libchimara/pager.h index 5918873..9bcbb63 100644 --- a/libchimara/pager.h +++ b/libchimara/pager.h @@ -5,10 +5,10 @@ #include "glk.h" #include "window.h" -G_GNUC_INTERNAL gboolean pager_on_expose(GtkTextView *textview, GdkEventExpose *event, winid_t win); +G_GNUC_INTERNAL gboolean pager_on_draw(GtkTextView *textview, cairo_t *cr, winid_t win); G_GNUC_INTERNAL gboolean pager_on_key_press_event(GtkTextView *textview, GdkEventKey *event, winid_t win); G_GNUC_INTERNAL void pager_after_adjustment_changed(GtkAdjustment *adj, winid_t win); -G_GNUC_INTERNAL void pager_after_size_request(GtkTextView *textview, GtkRequisition *requisition, winid_t win); +G_GNUC_INTERNAL void pager_after_size_allocate(GtkTextView *textview, GdkRectangle *allocation, winid_t win); G_GNUC_INTERNAL void pager_update(winid_t win); #endif diff --git a/libchimara/window.c b/libchimara/window.c index fb7311e..7bef6d0 100644 --- a/libchimara/window.c +++ b/libchimara/window.c @@ -565,8 +565,8 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, /* Connect signal handlers */ /* Pager */ - g_signal_connect_after( textview, "size-request", G_CALLBACK(pager_after_size_request), win ); - win->pager_expose_handler = g_signal_connect_after( textview, "expose-event", G_CALLBACK(pager_on_expose), win ); + g_signal_connect_after( textview, "size-allocate", G_CALLBACK(pager_after_size_allocate), win ); + win->pager_expose_handler = g_signal_connect_after( textview, "draw", G_CALLBACK(pager_on_draw), win ); g_signal_handler_block(textview, win->pager_expose_handler); win->pager_keypress_handler = g_signal_connect( textview, "key-press-event", G_CALLBACK(pager_on_key_press_event), win ); g_signal_handler_block(textview, win->pager_keypress_handler);