[gnome-mines/wip/theming-support] Make sure icons get redrawn on theme change
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mines/wip/theming-support] Make sure icons get redrawn on theme change
- Date: Wed, 7 Jan 2015 20:36:15 +0000 (UTC)
commit 1dcfab6a3b8d2826e79c53f44b6e32f0179e8ac5
Author: Robert Roth <robert roth off gmail com>
Date: Wed Jan 7 22:35:59 2015 +0200
Make sure icons get redrawn on theme change
src/gnome-mines.vala | 2 ++
src/minefield-view.vala | 7 +++++++
src/theme-selector-dialog.vala | 11 ++++++++---
src/tile.vala | 10 ++++++++++
4 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index 5ba3ded..ac7db3e 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -147,6 +147,8 @@ public class Mines : Gtk.Application
if (theme_dialog != null)
theme_dialog.queue_draw ();
+ if (minefield_view != null)
+ minefield_view.refresh ();
}
protected override void startup ()
diff --git a/src/minefield-view.vala b/src/minefield-view.vala
index b3982b5..861d7e5 100644
--- a/src/minefield-view.vala
+++ b/src/minefield-view.vala
@@ -590,6 +590,13 @@ public class MinefieldView : Gtk.Grid
return true;
}
+ public void refresh()
+ {
+ for (int i = 0; i < _minefield.width; i++)
+ for (int j = 0; j < _minefield.height; j++)
+ mines[i,j].refresh_icon ();
+ }
+
public override bool key_release_event (Gdk.EventKey event)
{
if (event.keyval != Gdk.Key.space)
diff --git a/src/theme-selector-dialog.vala b/src/theme-selector-dialog.vala
index 6b1e9f6..ce5c588 100644
--- a/src/theme-selector-dialog.vala
+++ b/src/theme-selector-dialog.vala
@@ -52,8 +52,8 @@ public class ThemeSelectorDialog : Gtk.Dialog
return themes;
}
- private Gtk.Widget create_preview_widget () {
- var view = new MinefieldView (settings);
+ private Gtk.Widget create_preview_widget (out MinefieldView view) {
+ view = new MinefieldView (settings);
view.minefield = new PreviewField ();
var frame = new Gtk.AspectFrame (null, 0.5f, 0.5f, 1.0f, false);
@@ -65,6 +65,8 @@ public class ThemeSelectorDialog : Gtk.Dialog
public ThemeSelectorDialog ( )
{
+ MinefieldView minefield;
+
title = _("Select theme");
var overlay = new Gtk.Overlay ();
@@ -99,18 +101,21 @@ public class ThemeSelectorDialog : Gtk.Dialog
}
}
+ overlay.add (create_preview_widget (out minefield));
+
next.clicked.connect (() => {
switch_theme_preview (++current_index, themes);
update_sensitivities (themes, current_index);
+ minefield.refresh ();
});
previous.clicked.connect (() => {
switch_theme_preview (--current_index, themes);
update_sensitivities (themes, current_index);
+ minefield.refresh ();
});
update_sensitivities (themes, current_index);
- overlay.add (create_preview_widget ());
overlay.show_all ();
set_size_request (320, 300);
diff --git a/src/tile.vala b/src/tile.vala
index 0f5bac6..d003b6a 100644
--- a/src/tile.vala
+++ b/src/tile.vala
@@ -20,6 +20,16 @@ public class Tile : Gtk.Button
get { return _column; }
}
+ public void refresh_icon()
+ {
+ string name;
+ Gtk.IconSize size;
+ scaling_image.get_icon_name (out name, out size);
+ scaling_image.clear ();
+ scaling_image.set_from_icon_name (name, size);
+ scaling_image.set_pixel_size (get_allocated_height ()/3*2);
+ }
+
public Tile (int prow, int pcol)
{
_row = prow;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]