From: Marijn van Vliet Date: Sat, 16 Jan 2010 20:48:24 +0000 (+0000) Subject: Hyperlinks now fully supported, also on textgrids. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=c286a5107c4ad1a8ea0448174b20fab3e0928cd3;p=rodin%2Fchimara.git Hyperlinks now fully supported, also on textgrids. Try it with styletest.so git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@211 ddfedd41-794f-dd11-ae45-00112f111e67 --- diff --git a/libchimara/hyperlink.c b/libchimara/hyperlink.c index a2795bd..6a0426a 100644 --- a/libchimara/hyperlink.c +++ b/libchimara/hyperlink.c @@ -56,7 +56,7 @@ glk_set_hyperlink_stream(strid_t str, glui32 linkval) g_return_if_fail(str != NULL); g_return_if_fail(str->type == STREAM_TYPE_WINDOW); g_return_if_fail(str->window != NULL); - g_return_if_fail(str->window->type == wintype_TextBuffer); + g_return_if_fail(str->window->type == wintype_TextBuffer || str->window->type == wintype_TextGrid); flush_window_buffer(str->window); @@ -138,7 +138,7 @@ glk_request_hyperlink_event(winid_t win) { VALID_WINDOW(win, return); g_return_if_fail(win != NULL); - g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid); + g_return_if_fail(win->type == wintype_TextBuffer || win->type == wintype_TextGrid); g_hash_table_foreach(win->hyperlinks, hyperlink_unblock_event_handler, NULL); @@ -156,7 +156,7 @@ glk_cancel_hyperlink_event(winid_t win) { VALID_WINDOW(win, return); g_return_if_fail(win != NULL); - g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid); + g_return_if_fail(win->type == wintype_TextBuffer || win->type == wintype_TextGrid); g_hash_table_foreach(win->hyperlinks, hyperlink_block_event_handler, NULL); } diff --git a/tests/styletest.c b/tests/styletest.c index 3cfd15e..33d7ce4 100644 --- a/tests/styletest.c +++ b/tests/styletest.c @@ -9,6 +9,7 @@ void do_style_test(); void do_link_test(); winid_t mainwin; +winid_t statuswin; void glk_main(void) { @@ -16,6 +17,8 @@ void glk_main(void) mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); if(!mainwin) return; + + statuswin = glk_window_open(mainwin, winmethod_Above | winmethod_Fixed, 3, wintype_TextGrid, 1); glk_set_window(mainwin); @@ -51,6 +54,11 @@ void glk_main(void) glk_put_string("Link 1 was clicked\n"); if(ev.val1 == 2) glk_put_string("Link 2 was clicked\n"); + if(ev.val1 == 3) + glk_put_string("Link 3 was clicked\n"); + if(ev.val1 == 4) + glk_put_string("Link 4 was clicked\n"); + glk_request_line_event(mainwin, buffer, 255, 0); } } @@ -100,12 +108,26 @@ do_style_test() { void do_link_test() { + glk_set_window(mainwin); glk_set_hyperlink(1); glk_put_string("This is link 1\n"); glk_set_hyperlink(2); glk_put_string("This is link 2\n"); glk_set_hyperlink(0); + + glk_set_window(statuswin); + glk_set_hyperlink(3); + glk_window_move_cursor(statuswin, 0, 0); + glk_put_string("This is link 3\n"); + glk_set_hyperlink(4); + glk_window_move_cursor(statuswin, 0, 1); + glk_put_string("This is link 4\n"); + glk_set_hyperlink(0); + glk_request_hyperlink_event(mainwin); + glk_request_hyperlink_event(statuswin); + + glk_set_window(mainwin); } void