Skip to content

Commit

Permalink
remove GdkColormap (causes coloring issue!)
Browse files Browse the repository at this point in the history
This removes the legacy data type and functions but causes drawing issues:
The different colors vanish and are sort of black-ish, but still
readable.

But in other code I have seen, the colormap was just deleted and the
rest around it was kept.
Like here: https://mail.gnome.org/archives/commits-list/2010-December/msg06118.html

-	colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
-	if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
-		gdk_cairo_set_source_color (cr, &bg_color);
-	}
+	gdk_cairo_set_source_color (cr, &bg_color);

I am lacking something like the set_source_color function though, but I
think it is better to have some sort-of working code without legacy
functions than doing workarounds in gtk2 at the moment.

Ah, and I chose to ignore the win32 code, because who cares.
  • Loading branch information
VanNostrand committed Feb 13, 2024
1 parent d668c96 commit 771279c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/krell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1787,13 +1787,9 @@ gkrellm_make_overlay_button(GkrellmPanel *p, void (*func)(), void *data,
else /* Make a default frame. */
{
GdkColor gray0, gray1;
GdkColormap *cmap;

cmap = gdk_colormap_get_system();
gdk_color_parse("gray65", &gray0);
gdk_color_parse("gray100", &gray1);
gdk_colormap_alloc_color(cmap, &gray0, FALSE, TRUE);
gdk_colormap_alloc_color(cmap, &gray1, FALSE, TRUE);

gdk_gc_set_foreground(_GK.draw1_GC, &gray1);
gdk_draw_line(pixmap, _GK.draw1_GC, 0, 0, w - 1, 0);
Expand All @@ -1810,9 +1806,6 @@ gkrellm_make_overlay_button(GkrellmPanel *p, void (*func)(), void *data,
gdk_draw_rectangle(mask, _GK.bit1_GC, TRUE, 0, 0, w, 2 * h);
gdk_draw_rectangle(mask, _GK.bit0_GC, TRUE, 1, 1, w - 2, h - 2);
gdk_draw_rectangle(mask, _GK.bit0_GC, TRUE, 1, h + 1, w - 2, h - 2);

gdk_colormap_free_colors(cmap, &gray0, 1);
gdk_colormap_free_colors(cmap, &gray1, 1);
}

d = gkrellm_create_decal_pixmap(p, pixmap, mask, 2, NULL, x, y);
Expand Down
27 changes: 20 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,10 @@ setup_fonts()
void
gkrellm_map_color_string(gchar *color_string, GdkColor *color)
{
static GdkColormap *colormap;

if (colormap == NULL)
colormap = gtk_widget_get_colormap(top_window);
if (color->red || color->green || color->blue)
gdk_colormap_free_colors(colormap, color, 1);
if (!color_string)
color_string = "black";

gdk_color_parse(color_string, color);
gdk_colormap_alloc_color(colormap, color, FALSE, TRUE);
}

static void
Expand Down Expand Up @@ -248,6 +242,25 @@ setup_colors()
bit_color.pixel = 0;
gdk_gc_set_foreground(_GK.bit0_GC, &bit_color);
g_object_unref(G_OBJECT(dummy_bitmap));
/*
// TODO: use GdkRGBA bit_color; but what is replacing GdkColor.pixel??
GdkColor bit_color;
GdkWindow *window = gtk_widget_get_window(top_window);
int width = 16;
int height = 16;
cairo_content_t content = cairo_surface_get_content (window);
_GK.bit0_GC = gdk_window_create_similar_surface (window, content, width, height);
bit_color.pixel = 1;
gdk_gc_set_foreground(_GK.bit1_GC, &bit_color);
_GK.bit0_GC = gdk_window_create_similar_surface (window, content, width, height);
bit_color.pixel = 0;
gdk_gc_set_foreground(_GK.bit0_GC, &bit_color);
*/
}
}

Expand Down

0 comments on commit 771279c

Please sign in to comment.