aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/main.vala32
-rw-r--r--lib/source.vala13
2 files changed, 31 insertions, 14 deletions
diff --git a/lib/main.vala b/lib/main.vala
index d16022e9..f012ecb0 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -59,6 +59,26 @@ public class Indicator.Keyboard.Service : Object {
if (use_gtk) {
use_gtk = Gtk.init_check (ref args);
+
+ Gtk.IconTheme? icon_theme = Gtk.IconTheme.get_default ();
+
+ if (icon_theme != null) {
+ ((!) icon_theme).changed.connect (() => {
+ if (sources != null) {
+ foreach (var source in (!) sources) {
+ source.icon = null;
+ }
+ }
+
+ if (sources_menu != null) {
+ update_sources_menu ();
+ }
+
+ if (indicator_action != null) {
+ update_indicator_action ();
+ }
+ });
+ }
} else {
Gdk.init (ref args);
}
@@ -513,16 +533,22 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void handle_focused_window_changed (uint window_id, string app_id, uint stage) {
- ((!) window_sources)[focused_window_id] = source_settings.get_uint ("current");
+ var old_current = source_settings.get_uint ("current");
+
+ ((!) window_sources)[focused_window_id] = old_current;
if (!(((!) window_sources).has_key (window_id))) {
var default_group = per_window_settings.get_int ("default-group");
- if (default_group >= 0) {
+ if (default_group >= 0 && default_group != old_current) {
source_settings.set_uint ("current", (uint) default_group);
}
} else {
- source_settings.set_uint ("current", ((!) window_sources)[window_id]);
+ var current = ((!) window_sources)[window_id];
+
+ if (current != old_current) {
+ source_settings.set_uint ("current", current);
+ }
}
focused_window_id = window_id;
diff --git a/lib/source.vala b/lib/source.vala
index 1ee2650a..5fe7157d 100644
--- a/lib/source.vala
+++ b/lib/source.vala
@@ -51,7 +51,7 @@ public class Indicator.Keyboard.Source : Object {
public Icon? icon {
get { if (_icon == null) { _icon = _get_icon (); } return _icon; }
- private set { _icon = value; }
+ set { _icon = value; }
}
public uint subscript {
@@ -424,16 +424,7 @@ public class Indicator.Keyboard.Source : Object {
Gtk.IconInfo? icon_info = icon_theme.lookup_icon (icon_name, 22, 0);
if (icon_info != null) {
- string? file_name = ((!) icon_info).get_filename ();
- var has_file_name = file_name != null && ((!) file_name).get_char () != '\0';
-
- if (has_file_name) {
- try {
- icon = Icon.new_for_string ((!) file_name);
- } catch (Error error) {
- warning ("error: %s", error.message);
- }
- }
+ icon = new ThemedIcon (icon_name);
}
} else {
icon = new ThemedIcon (icon_name);