From: rodin Date: Sat, 17 Apr 2010 15:13:22 +0000 (+0000) Subject: Fixed Glk to Gdk color bug X-Git-Tag: v0.9~235 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=dfc0e872bf76faa4944a11d0905eca43143182e2;p=projects%2Fchimara%2Fchimara.git Fixed Glk to Gdk color bug --- diff --git a/configure.ac b/configure.ac index 9b0ebb0..18e630a 100644 --- a/configure.ac +++ b/configure.ac @@ -25,8 +25,8 @@ LT_VERSION_INFO="$CHIMARA_CURRENT:$CHIMARA_REVISION:$CHIMARA_AGE" AC_SUBST(LT_VERSION_INFO) ### REQUIREMENTS ############################################################## -GTK_REQUIRED_VERSION=2.12 -GLIB_REQUIRED_VERSION=2.16 +GTK_REQUIRED_VERSION=2.6 +GLIB_REQUIRED_VERSION=2.6 GTK_DOC_REQUIRED_VERSION=1.9 AC_SUBST(GTK_REQUIRED_VERSION) AC_SUBST(GLIB_REQUIRED_VERSION) diff --git a/libchimara/graphics.c b/libchimara/graphics.c index 21fcd09..5735bcb 100644 --- a/libchimara/graphics.c +++ b/libchimara/graphics.c @@ -139,7 +139,6 @@ image_cache_find(struct image_info* to_find) /* Empty cache */ if(link == NULL) { gdk_threads_leave(); - printf("Cache miss for image %d\n", to_find->resource_number); return NULL; } @@ -154,7 +153,6 @@ image_cache_find(struct image_info* to_find) if(info->width == to_find->width && info->height == to_find->height) { /* Prescaled image found */ gdk_threads_leave(); - printf("Exact cache hit for image %d\n", to_find->resource_number); return info; } else if(info->width >= to_find->width && info->height >= to_find->height) { @@ -165,7 +163,6 @@ image_cache_find(struct image_info* to_find) } else { if(!info->scaled) { gdk_threads_leave(); - printf("Exact cache hit for image %d\n", to_find->resource_number); return info; /* Found a match */ } } @@ -174,11 +171,6 @@ image_cache_find(struct image_info* to_find) gdk_threads_leave(); - if(match == NULL) - printf("Cache miss for image %d\n", to_find->resource_number); - else - printf("Approx cache hit for image %d\n", to_find->resource_number); - return match; } @@ -454,14 +446,15 @@ glk_window_fill_rect(winid_t win, glui32 color, glsi32 left, glsi32 top, glui32 VALID_WINDOW(win, return); g_return_if_fail(win->type == wintype_Graphics); - gdk_threads_enter(); GdkPixmap *map; gtk_image_get_pixmap( GTK_IMAGE(win->widget), &map, NULL ); GdkGC *gc = gdk_gc_new(map); - gdk_gc_set_foreground( gc, glkcolor_to_gdkcolor(color) ); + GdkColor gdkcolor; + glkcolor_to_gdkcolor(color, &gdkcolor); + gdk_gc_set_rgb_fg_color(gc, &gdkcolor); gdk_draw_rectangle( GDK_DRAWABLE(map), gc, TRUE, left, top, width, height); gtk_widget_queue_draw(win->widget); g_object_unref(gc); diff --git a/libchimara/style.c b/libchimara/style.c index 8c6ca12..7147d53 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -525,15 +525,12 @@ glkcolor_to_hex(glui32 val, gchar *buffer) } /* Internal function: parses a glk color to a GdkColor */ -GdkColor* -glkcolor_to_gdkcolor(glui32 val) +void +glkcolor_to_gdkcolor(glui32 val, GdkColor *color) { - GdkColor* color = g_new0(GdkColor, 1); - color->red = (val & 0xff0000) >> 16; - color->green = (val & 0x00ff00) >> 8; - color->blue = val & 0x0000ff; - - return color; + color->red = 256 * ((val & 0xff0000) >> 16); + color->green = 256 * ((val & 0x00ff00) >> 8); + color->blue = 256 * (val & 0x0000ff); } /* Internal function: parses a GdkColor to a glk color */ diff --git a/libchimara/style.h b/libchimara/style.h index 6c74222..5c2778b 100644 --- a/libchimara/style.h +++ b/libchimara/style.h @@ -10,7 +10,7 @@ G_GNUC_INTERNAL void style_init(); G_GNUC_INTERNAL PangoFontDescription* get_current_font(guint32 wintype); G_GNUC_INTERNAL GtkTextTag* gtk_text_tag_copy(GtkTextTag *tag); -G_GNUC_INTERNAL GdkColor* glkcolor_to_gdkcolor(glui32 val); +G_GNUC_INTERNAL void glkcolor_to_gdkcolor(glui32 val, GdkColor *color); typedef struct StyleSet { GHashTable *text_grid; diff --git a/libchimara/window.c b/libchimara/window.c index 02f1e5c..af47056 100644 --- a/libchimara/window.c +++ b/libchimara/window.c @@ -568,6 +568,7 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, win->unit_height = 1; win->widget = image; win->frame = image; + win->background_color = 0x00FFFFFF; /* Connect signal handlers */ win->button_press_event_handler = g_signal_connect(image, "button-press-event", G_CALLBACK(on_window_button_press), win); diff --git a/player/CoSv3.blb b/player/CoSv3.blb new file mode 100644 index 0000000..f9421b4 Binary files /dev/null and b/player/CoSv3.blb differ diff --git a/player/anchor.z8 b/player/anchor.z8 new file mode 100644 index 0000000..3e99a47 Binary files /dev/null and b/player/anchor.z8 differ diff --git a/tests/style.css b/tests/style.css index 6597f99..2504e9f 100644 --- a/tests/style.css +++ b/tests/style.css @@ -14,6 +14,7 @@ * input * user1 * user2 + * hyperlink * * Possible style hints: * font-family (string) @@ -73,3 +74,7 @@ buffer.user1 { buffer.user2 { } + +buffer.hyperlink { + color: #ff0000; +} diff --git a/tests/styletest.c b/tests/styletest.c index 8165e44..0ed73cc 100644 --- a/tests/styletest.c +++ b/tests/styletest.c @@ -137,8 +137,11 @@ do_link_test() { void do_mouse_test() { - glk_request_mouse_event(mainwin); + glk_set_window(statuswin); + glk_window_move_cursor(statuswin, 0, 0); + glk_put_string("Click me......\n"); glk_request_mouse_event(statuswin); + glk_set_window(mainwin); } void