[gnome-mines/wip/theming-support] Moved tile class out of the minefield-view
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mines/wip/theming-support] Moved tile class out of the minefield-view
- Date: Sat, 3 Jan 2015 20:39:04 +0000 (UTC)
commit 64e318b50412277639d48233131dd455dd1df237
Author: Robert Roth <robert roth off gmail com>
Date: Sat Jan 3 19:50:34 2015 +0200
Moved tile class out of the minefield-view
src/Makefile.am | 3 +-
src/minefield-view.vala | 70 -----------------------------------------------
src/tile.vala | 70 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 71 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 166c088..43bdc4d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,8 @@ gnome_mines_SOURCES = \
history.vala \
minefield.vala \
minefield-view.vala \
- score-dialog.vala
+ score-dialog.vala \
+ tile.vala
gnome_mines_CFLAGS = \
-DVERSION=\"$(VERSION)\" \
diff --git a/src/minefield-view.vala b/src/minefield-view.vala
index 4cd73e6..3c6f4a4 100644
--- a/src/minefield-view.vala
+++ b/src/minefield-view.vala
@@ -90,76 +90,6 @@ private class Position : Object
}
}
-private class Tile : Gtk.Button
-{
- private int _row;
- private int _column;
- public signal void tile_mouse_over (int x, int y);
- public signal void tile_pressed (int x, int y, Gdk.EventButton event);
- public signal void tile_released (int x, int y, Gdk.EventButton event);
- private static string[] IMAGE_CLASSES = {"mine", "flag", "maybe", "overmine",
- "exploded", "1mines", "2mines",
- "3mines", "4mines", "5mines",
- "6mines", "7mines", "8mines"};
- private Gtk.Image scaling_image;
-
- public int row
- {
- get { return _row; }
- }
- public int column
- {
- get { return _column; }
- }
-
- public Tile (int prow, int pcol)
- {
- _row = prow;
- _column = pcol;
- scaling_image = new Gtk.Image ();
- can_focus = false;
- add_class ("tile");
- set_image (scaling_image);
- enter_notify_event.connect ( (event) =>
- {
- tile_mouse_over (prow, pcol);
- return false;
- } );
- size_allocate.connect ( (allocation) =>
- {
- scaling_image.set_pixel_size (allocation.height/3*2);
- } );
- button_press_event.connect ( (event) =>
- {
- tile_pressed (prow, pcol, event);
- return false;
- } );
- button_release_event.connect ( (event) =>
- {
- tile_released (prow, pcol, event);
- return false;
- } );
- }
-
- public void add_class (string style_class)
- {
- get_style_context ().add_class (style_class);
- if (style_class in IMAGE_CLASSES) {
- scaling_image.set_from_icon_name (style_class, Gtk.IconSize.DND);
- scaling_image.set_pixel_size (get_allocated_height ()/3*2);
- }
- }
-
- public void remove_class (string style_class)
- {
- get_style_context ().remove_class (style_class);
- if (style_class in IMAGE_CLASSES) {
- scaling_image = new Gtk.Image ();
- set_image (scaling_image);
- }
- }
-}
-
public class MinefieldView : Gtk.Grid
{
private Settings settings;
diff --git a/src/tile.vala b/src/tile.vala
new file mode 100644
index 0000000..0f5bac6
--- /dev/null
+++ b/src/tile.vala
@@ -0,0 +1,70 @@
+public class Tile : Gtk.Button
+{
+ private int _row;
+ private int _column;
+ public signal void tile_mouse_over (int x, int y);
+ public signal void tile_pressed (int x, int y, Gdk.EventButton event);
+ public signal void tile_released (int x, int y, Gdk.EventButton event);
+ private static string[] IMAGE_CLASSES = {"mine", "flag", "maybe", "overmine",
+ "exploded", "1mines", "2mines",
+ "3mines", "4mines", "5mines",
+ "6mines", "7mines", "8mines"};
+ private Gtk.Image scaling_image;
+
+ public int row
+ {
+ get { return _row; }
+ }
+ public int column
+ {
+ get { return _column; }
+ }
+
+ public Tile (int prow, int pcol)
+ {
+ _row = prow;
+ _column = pcol;
+ scaling_image = new Gtk.Image ();
+ can_focus = false;
+ add_class ("tile");
+ set_image (scaling_image);
+ enter_notify_event.connect ( (event) =>
+ {
+ tile_mouse_over (prow, pcol);
+ return false;
+ } );
+ size_allocate.connect ( (allocation) =>
+ {
+ scaling_image.set_pixel_size (allocation.height/3*2);
+ } );
+ button_press_event.connect ( (event) =>
+ {
+ tile_pressed (prow, pcol, event);
+ return false;
+ } );
+ button_release_event.connect ( (event) =>
+ {
+ tile_released (prow, pcol, event);
+ return false;
+ } );
+ }
+
+ public void add_class (string style_class)
+ {
+ get_style_context ().add_class (style_class);
+ if (style_class in IMAGE_CLASSES) {
+ scaling_image.set_from_icon_name (style_class, Gtk.IconSize.DND);
+ scaling_image.set_pixel_size (get_allocated_height ()/3*2);
+ }
+ }
+
+ public void remove_class (string style_class)
+ {
+ get_style_context ().remove_class (style_class);
+ if (style_class in IMAGE_CLASSES) {
+ scaling_image = new Gtk.Image ();
+ set_image (scaling_image);
+ }
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]