[gnome-games] mahjongg: Remove deprecated GdkColor usage
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] mahjongg: Remove deprecated GdkColor usage
- Date: Sun, 5 Feb 2012 06:52:18 +0000 (UTC)
commit a590fc0a3c9a16963418beb5317528374ba0d56a
Author: Robert Ancell <robert ancell canonical com>
Date: Sun Feb 5 17:38:32 2012 +1100
mahjongg: Remove deprecated GdkColor usage
mahjongg/src/Makefile.am | 1 +
mahjongg/src/fixes.vapi | 5 +++++
mahjongg/src/game-view.vala | 7 ++++---
mahjongg/src/mahjongg.vala | 9 +++++----
4 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/mahjongg/src/Makefile.am b/mahjongg/src/Makefile.am
index b05ff08..9e279da 100644
--- a/mahjongg/src/Makefile.am
+++ b/mahjongg/src/Makefile.am
@@ -2,6 +2,7 @@ bin_PROGRAMS = mahjongg
mahjongg_SOURCES = \
config.vapi \
+ fixes.vapi \
game.vala \
game-view.vala \
mahjongg.vala \
diff --git a/mahjongg/src/fixes.vapi b/mahjongg/src/fixes.vapi
new file mode 100644
index 0000000..07e8c2f
--- /dev/null
+++ b/mahjongg/src/fixes.vapi
@@ -0,0 +1,5 @@
+namespace Gtk
+{
+ /* See https://bugzilla.gnome.org/show_bug.cgi?id=669386 */
+ void color_button_get_rgba (Gtk.ColorButton button, out Gdk.RGBA rgba);
+}
diff --git a/mahjongg/src/game-view.vala b/mahjongg/src/game-view.vala
index 9197b2e..78f6145 100644
--- a/mahjongg/src/game-view.vala
+++ b/mahjongg/src/game-view.vala
@@ -1,6 +1,6 @@
public class GameView : Gtk.DrawingArea
{
- public Gdk.Color background_color;
+ public Gdk.RGBA background_color;
private Cairo.Pattern? tile_pattern = null;
private int tile_pattern_width = 0;
private int tile_pattern_height = 0;
@@ -46,7 +46,8 @@ public class GameView : Gtk.DrawingArea
public void set_background (string? colour)
{
- if (colour == null || !Gdk.Color.parse (colour, out background_color))
+ background_color = Gdk.RGBA ();
+ if (colour == null || !background_color.parse (colour))
background_color.red = background_color.green = background_color.blue = 0;
queue_draw ();
}
@@ -210,7 +211,7 @@ public class GameView : Gtk.DrawingArea
if (game == null)
return false;
- Gdk.cairo_set_source_color (cr, background_color);
+ Gdk.cairo_set_source_rgba (cr, background_color);
cr.paint ();
draw_game (cr);
diff --git a/mahjongg/src/mahjongg.vala b/mahjongg/src/mahjongg.vala
index 13a1250..0b66199 100644
--- a/mahjongg/src/mahjongg.vala
+++ b/mahjongg/src/mahjongg.vala
@@ -228,9 +228,10 @@ public class Mahjongg : Gtk.Application
private void background_changed_cb (Gtk.ColorButton widget)
{
- Gdk.Color colour;
- widget.get_color (out colour);
- settings.set_string ("bgcolour", "#%04x%04x%04x".printf (colour.red, colour.green, colour.blue));
+ Gdk.RGBA colour;
+ /* See https://bugzilla.gnome.org/show_bug.cgi?id=669386 */
+ Gtk.color_button_get_rgba (widget, out colour);
+ settings.set_string ("bgcolour", "#%04x%04x%04x".printf ((int) (colour.red * 65536 + 0.5), (int) (colour.green * 65536 + 0.5), (int) (colour.blue * 65536 + 0.5)));
}
private void map_changed_cb (Gtk.ComboBox widget)
@@ -415,7 +416,7 @@ public class Mahjongg : Gtk.Application
grid.attach (label, 0, 0, 1, 1);
var widget = new Gtk.ColorButton ();
- widget.set_color (game_view.background_color);
+ widget.set_rgba (game_view.background_color);
widget.color_set.connect (background_changed_cb);
widget.set_hexpand (true);
grid.attach (widget, 1, 0, 1, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]