Fixed Glk to Gdk color bug
authorMarijn van Vliet <marijn.vanvliet@med.kuleuven.be>
Sat, 17 Apr 2010 15:13:22 +0000 (15:13 +0000)
committerMarijn van Vliet <marijn.vanvliet@med.kuleuven.be>
Sat, 17 Apr 2010 15:13:22 +0000 (15:13 +0000)
git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@230 ddfedd41-794f-dd11-ae45-00112f111e67

configure.ac
libchimara/graphics.c
libchimara/style.c
libchimara/style.h
libchimara/window.c
player/CoSv3.blb [new file with mode: 0644]
player/anchor.z8 [new file with mode: 0644]
tests/style.css
tests/styletest.c

index 9b0ebb0f7c7c176a14819b74538f278493c93446..18e630a32b9f5662bbed6a78493f6a01405047dc 100644 (file)
@@ -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)
index 21fcd09067937b6820d33069877f6d798758033b..5735bcb34614cb68896a54c774b6f221b9dfb0cf 100644 (file)
@@ -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);
index 8c6ca121bfc3d1756d30a4923b62708c45380881..7147d53f9bc7ea5e1b19d53b4574579ee0365501 100644 (file)
@@ -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 */
index 6c74222551750fb3193c1ea56c427dadea413613..5c2778b16c31f2e60b84dde7f237ade4ed3772ef 100644 (file)
@@ -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;
index 02f1e5ceb0e58d47ee8dca4abbf96d4e1e5f4cde..af470566ccd734bf72eaba9b0b45983039287bc0 100644 (file)
@@ -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 (file)
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 (file)
index 0000000..3e99a47
Binary files /dev/null and b/player/anchor.z8 differ
index 6597f996aba5c27e71f5b0fc381c272024fbb36b..2504e9f0d0d53c3a6fcacb58729ba0e25c334e5a 100644 (file)
@@ -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;
+}
index 8165e448383f3b4fe4a139b14d4aa7828d6d51c9..0ed73cc248999f2282f669d28240ce743da79d90 100644 (file)
@@ -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