start_paging(winid_t win)
{
win->currently_paging = TRUE;
- g_signal_handler_unblock(win->widget, win->pager_expose_handler);
+ gtk_widget_show(win->pager);
g_signal_handler_unblock(win->widget, win->pager_keypress_handler);
}
stop_paging(winid_t win)
{
win->currently_paging = FALSE;
- g_signal_handler_block(win->widget, win->pager_expose_handler);
+ gtk_widget_hide(win->pager);
g_signal_handler_block(win->widget, win->pager_keypress_handler);
}
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) );
+ GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(win->scrolledwindow) );
gdouble page_size, upper, lower, value;
g_object_get(adj,
"page-size", &page_size,
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 draw event has run */
-gboolean
-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);
-
- int winwidth = gtk_widget_get_allocated_width( GTK_WIDGET(textview) );
- int winheight = gtk_widget_get_allocated_height( GTK_WIDGET(textview) );
-
- /* Draw the 'more' tag */
- cairo_move_to(cr, winwidth - promptwidth, winheight - promptheight);
- pango_cairo_show_layout(cr, win->pager_layout);
-
- return FALSE; /* Propagate event further */
-}
-
/* Check whether paging should be done. This function is called after the
* textview has finished validating text positions. */
void
/* Scroll past text already read by user. This is automatic scrolling, so disable the pager_ajustment_handler
* first, that acts on the belief the scolling is performed by the user. */
- GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(win->frame));
+ GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(win->scrolledwindow));
g_signal_handler_block(adj, win->pager_adjustment_handler);
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(win->widget));
GtkTextMark *pager_position = gtk_text_buffer_get_mark(buffer, "pager_position");
g_hash_table_destroy(win->hyperlinks);
g_free(win->current_hyperlink);
- if(win->pager_layout)
- g_object_unref(win->pager_layout);
if(win->backing_store)
cairo_surface_destroy(win->backing_store);
case wintype_TextBuffer:
{
+ GtkWidget *overlay = gtk_overlay_new();
GtkWidget *scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
GtkWidget *textview = gtk_text_view_new();
+ GtkWidget *pager = gtk_button_new_with_label("More");
+ GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON);
GtkTextBuffer *textbuffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(textview) );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
-
+
+ gtk_button_set_image( GTK_BUTTON(pager), image );
+ gtk_widget_set_halign(pager, GTK_ALIGN_END);
+ gtk_widget_set_valign(pager, GTK_ALIGN_END);
+ gtk_widget_set_no_show_all(pager, TRUE);
+
gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW(textview), GTK_WRAP_WORD_CHAR );
gtk_text_view_set_editable( GTK_TEXT_VIEW(textview), FALSE );
gtk_text_view_set_pixels_inside_wrap( GTK_TEXT_VIEW(textview), 3 );
gtk_text_view_set_right_margin( GTK_TEXT_VIEW(textview), 20 );
gtk_container_add( GTK_CONTAINER(scrolledwindow), textview );
- gtk_widget_show_all(scrolledwindow);
+ gtk_container_add( GTK_CONTAINER(overlay), scrolledwindow );
+ gtk_overlay_add_overlay( GTK_OVERLAY(overlay), pager );
+ gtk_widget_show_all(overlay);
win->widget = textview;
- win->frame = scrolledwindow;
-
+ win->scrolledwindow = scrolledwindow;
+ win->pager = pager;
+ win->frame = overlay;
+
/* Create the styles available to the window stream */
style_init_textbuffer(textbuffer);
- style_init_more_prompt(win);
gtk_widget_modify_font( textview, get_current_font(wintype) );
-
+
/* Determine the size of a "0" character in pixels */
PangoLayout *zero = gtk_widget_create_pango_layout(textview, "0");
pango_layout_set_font_description( zero, get_current_font(wintype) );
/* Pager */
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);
GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolledwindow));
/* "frame" is the widget that is the child of the ChimaraGlk container, such
as a scroll window. It may be the same as "widget". */
GtkWidget *frame;
+ /* In text buffer windows, the scrolled window and the pager are extra
+ widgets that are neither "widget" nor "frame" */
+ GtkWidget *scrolledwindow;
+ GtkWidget *pager;
/* Width and height of the window's size units, in pixels */
int unit_width;
int unit_height;
gulong shutdown_keypress_handler;
gulong button_press_event_handler;
gulong size_allocate_handler;
- gulong pager_expose_handler;
gulong pager_keypress_handler;
gulong pager_adjustment_handler;
/* Window buffer */