From b248c779680a810a22987759e295a67b414841a2 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 5 Feb 2011 09:58:11 +0000 Subject: [PATCH] Gtk3 compatibility: build cleanly with deprecated symbols disabled --- src/Makefile.am | 3 ++- src/bubblegen.c | 32 ++++++++++++++++++++++---------- src/floating_shape.c | 17 ++++++++++++++--- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index a7afc06..58a6533 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,8 @@ bin_PROGRAMS = xcowsay bin_SCRIPTS = xcowfortune xcowdream xcowthink -AM_CFLAGS = $(XCOWSAY_CFLAGS) -Wall +GTK3_CHECK = -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED +AM_CFLAGS = $(XCOWSAY_CFLAGS) -Wall $(GTK3_CHECK) LDADD = $(XCOWSAY_LIBS) xcowsay_SOURCES = xcowsay.c display_cow.c display_cow.h floating_shape.h \ diff --git a/src/bubblegen.c b/src/bubblegen.c index afcbdb1..ff757a4 100644 --- a/src/bubblegen.c +++ b/src/bubblegen.c @@ -61,16 +61,30 @@ typedef struct { typedef enum { NORMAL, THOUGHT } bubble_style_t; +static void get_colour(guint16 r, guint16 g, guint16 b, GdkColor *c) +{ + GdkColormap *colormap; + gboolean ok; + + colormap = gdk_colormap_get_system(); + + c->red = r; + c->green = g; + c->blue = b; + + ok = gdk_colormap_alloc_color(colormap, c, FALSE, TRUE); + g_assert(ok); +} + static void bubble_init_left(bubble_t *b, bubble_style_t style) { GdkColor black, white, bright_green; - GdkColormap *colormap; GdkPoint tip_points[5]; - - colormap = gdk_colormap_get_system(); - gdk_color_black(colormap, &black); - gdk_color_white(colormap, &white); + get_colour(0, 0, 0, &black); + get_colour(0xffff, 0xffff, 0xffff, &white); + get_colour(0, 0xffff, 0, &bright_green); + bright_green.red = 0; bright_green.green = 65535; // Bright green is alpha bright_green.blue = 0; @@ -213,12 +227,10 @@ static void bubble_init_left(bubble_t *b, bubble_style_t style) static void bubble_init_right(bubble_t *b, bubble_style_t style) { GdkColor black, white, bright_green; - GdkColormap *colormap; GdkPoint tip_points[5]; - - colormap = gdk_colormap_get_system(); - gdk_color_black(colormap, &black); - gdk_color_white(colormap, &white); + + get_colour(0, 0, 0, &black); + get_colour(0xffff, 0xffff, 0xffff, &white); bright_green.red = 0; bright_green.green = 65535; // Bright green is alpha diff --git a/src/floating_shape.c b/src/floating_shape.c index 36cbf85..c4ef18a 100644 --- a/src/floating_shape.c +++ b/src/floating_shape.c @@ -1,5 +1,5 @@ /* floating_shape.c -- Low-ish level window creation and management. - * Copyright (C) 2008 Nick Gasson + * Copyright (C) 2008, 2011 Nick Gasson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,11 +44,22 @@ static void get_alpha_mask(float_shape_t *shape) int rowstride, nchannels, x, y; guchar *pixels, *p; bool bright_green, has_alpha; + gboolean ok; colormap = gdk_colormap_get_system(); - gdk_color_black(colormap, &black); - gdk_color_white(colormap, &white); + black.red = 0; + black.green = 0; + black.blue = 0; + ok = gdk_colormap_alloc_color(colormap, &black, FALSE, TRUE); + g_assert(ok); + + white.red = 0xffff; + white.green = 0xffff; + white.blue = 0xffff; + ok = gdk_colormap_alloc_color(colormap, &white, FALSE, TRUE); + g_assert(ok); + shape->mask_bitmap = (GdkDrawable*)gdk_pixmap_new(NULL, shape->width, shape->height, 1); gc = gdk_gc_new(shape->mask_bitmap); -- 2.39.2