Replace deprecated signals
authorPhilip Chimento <philip.chimento@gmail.com>
Sat, 25 Aug 2012 19:04:04 +0000 (21:04 +0200)
committerPhilip Chimento <philip.chimento@gmail.com>
Sat, 25 Aug 2012 19:04:04 +0000 (21:04 +0200)
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.

libchimara/pager.c
libchimara/pager.h
libchimara/window.c

index c620bacaaf24bba76a0049b39e1fdd85c0ab56cb..c04553fe135bdea0af9b16610968ec81b1d69498 100644 (file)
@@ -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; 
index 59188732dc9afdec306acd620619d0c389949ef7..9bcbb6344c6ec22d466cead72f935972016b9197 100644 (file)
@@ -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
index fb7311e7280a09f0c1300fa026630a2221fcb1c3..7bef6d0b2fd5bbc922f615cd6352bc65ec7fe429 100644 (file)
@@ -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);