aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2015-02-18 10:52:18 -0500
committerWilliam Hua <william.hua@canonical.com>2015-02-18 10:52:18 -0500
commita8721bcb87bef4c18e501cf559af35926d11c0eb (patch)
tree8c2e4ea57c465e0f89618ac46e11b745159476da /lib
parent603fdf817fbecbc184853ca4a4a078a2e7072fde (diff)
downloadayatana-indicator-keyboard-a8721bcb87bef4c18e501cf559af35926d11c0eb.tar.gz
ayatana-indicator-keyboard-a8721bcb87bef4c18e501cf559af35926d11c0eb.tar.bz2
ayatana-indicator-keyboard-a8721bcb87bef4c18e501cf559af35926d11c0eb.zip
Remove (!) when possible.
Diffstat (limited to 'lib')
-rw-r--r--lib/ibus-menu.vala22
-rw-r--r--lib/main.vala70
-rw-r--r--lib/source.vala8
3 files changed, 61 insertions, 39 deletions
diff --git a/lib/ibus-menu.vala b/lib/ibus-menu.vala
index 62bd88e8..a74782ed 100644
--- a/lib/ibus-menu.vala
+++ b/lib/ibus-menu.vala
@@ -154,26 +154,30 @@ public class Indicator.Keyboard.IBusMenu : MenuModel {
/* Create a single action for all radio properties. */
if (action_map != null && radio_name == null) {
radio_counter++;
- radio_name = @"-private-radio-$radio_counter";
- radio_action = new SimpleAction.stateful ((!) radio_name, VariantType.STRING, new Variant.string (""));
- ((!) radio_action).activate.connect ((parameter) => {
- ((!) radio_action).change_state (parameter);
+ var name = @"-private-radio-$radio_counter";
+ var action = new SimpleAction.stateful (name, VariantType.STRING, new Variant.string (""));
+
+ action.activate.connect ((parameter) => {
+ action.change_state (parameter);
});
- ((!) radio_action).change_state.connect ((value) => {
+ action.change_state.connect ((value) => {
if (value != null) {
var key = ((!) value).get_string ();
if (radio_properties.has_key (key)) {
- ((!) radio_action).set_state ((!) value);
+ action.set_state ((!) value);
activate (radio_properties[key], IBus.PropState.CHECKED);
}
}
});
- ((!) action_map).add_action ((!) radio_action);
- names.add ((!) radio_name);
+ ((!) action_map).add_action (action);
+ names.add (name);
+
+ radio_name = name;
+ radio_action = action;
}
radio_properties[property.key] = property;
@@ -195,7 +199,7 @@ public class Indicator.Keyboard.IBusMenu : MenuModel {
private void append_menu_property (IBus.Property property) {
if (property.prop_type == IBus.PropType.MENU) {
- var submenu = new IBusMenu (action_map, ((!) property).sub_props);
+ var submenu = new IBusMenu (action_map, property.sub_props);
submenu.activate.connect ((property, state) => { activate (property, state); });
menu.append_submenu (get_label (property), submenu);
}
diff --git a/lib/main.vala b/lib/main.vala
index ab33a84a..94a7f9ab 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -174,8 +174,10 @@ public class Indicator.Keyboard.Service : Object {
private IBus.Bus get_ibus () {
if (ibus == null) {
IBus.init ();
- ibus = new IBus.Bus ();
- ((!) ibus).connected.connect (() => {
+
+ var proxy = new IBus.Bus ();
+
+ proxy.connected.connect (() => {
if (desktop_menu != null) {
get_desktop_menu ().set_sources (get_sources ());
}
@@ -192,6 +194,8 @@ public class Indicator.Keyboard.Service : Object {
update_indicator_action ();
}
});
+
+ ibus = proxy;
}
return (!) ibus;
@@ -205,9 +209,9 @@ public class Indicator.Keyboard.Service : Object {
var path = "/org/freedesktop/IBus/Panel";
try {
- ibus_panel = connection.get_proxy_sync (name, path);
+ var proxy = connection.get_proxy_sync<IBusPanel> (name, path);
- ((!) ibus_panel).properties_registered.connect ((variant) => {
+ proxy.properties_registered.connect ((variant) => {
var properties = new IBus.PropList ();
properties.deserialize (variant);
@@ -215,7 +219,7 @@ public class Indicator.Keyboard.Service : Object {
handle_properties_registered ((!) (properties as IBus.PropList));
}
});
- ((!) ibus_panel).property_updated.connect ((variant) => {
+ proxy.property_updated.connect ((variant) => {
var type = IBus.PropType.NORMAL;
var state = IBus.PropState.INCONSISTENT;
var text = new IBus.Text.from_static_string ("");
@@ -226,6 +230,8 @@ public class Indicator.Keyboard.Service : Object {
handle_property_updated ((!) (property as IBus.Property));
}
});
+
+ ibus_panel = proxy;
} catch (IOError error) {
warning ("error: %s", error.message);
}
@@ -241,8 +247,9 @@ public class Indicator.Keyboard.Service : Object {
if (is_fcitx_active ()) {
try {
- fcitx = new Fcitx.InputMethod (BusType.SESSION, DBusProxyFlags.NONE, 0);
- ((!) fcitx).notify["current-im"].connect ((pspec) => { handle_changed_current ("current"); });
+ var proxy = new Fcitx.InputMethod (BusType.SESSION, DBusProxyFlags.NONE, 0);
+ proxy.notify["current-im"].connect ((pspec) => { handle_changed_current ("current"); });
+ fcitx = proxy;
} catch (Error error) {
warning ("error: %s", error.message);
}
@@ -255,8 +262,9 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
public void up () {
if (loop == null) {
- loop = new MainLoop ();
- ((!) loop).run ();
+ var main_loop = new MainLoop ();
+ loop = main_loop;
+ main_loop.run ();
}
}
@@ -330,9 +338,7 @@ public class Indicator.Keyboard.Service : Object {
}
if (layouts.length > 0) {
- source = layouts[0];
- source = ((!) source).replace (" ", "+");
- source = ((!) source).replace ("\t", "+");
+ source = layouts[0].replace (" ", "+").replace ("\t", "+");
}
}
}
@@ -852,9 +858,10 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private Action get_active_action () {
if (active_action == null) {
- active_action = new SimpleAction.stateful ("active", VariantType.UINT32, new Variant.uint32 (get_current ()));
- ((!) active_action).activate.connect ((parameter) => { ((!) active_action).change_state (parameter); });
- ((!) active_action).change_state.connect (handle_changed_active);
+ var action = new SimpleAction.stateful ("active", VariantType.UINT32, new Variant.uint32 (get_current ()));
+ action.activate.connect ((parameter) => { action.change_state (parameter); });
+ action.change_state.connect (handle_changed_active);
+ active_action = action;
}
return (!) active_action;
@@ -1019,9 +1026,10 @@ public class Indicator.Keyboard.Service : Object {
}
}
- desktop_menu = new IndicatorMenu (get_action_group (), options);
- ((!) desktop_menu).set_sources (get_sources ());
- ((!) desktop_menu).activate.connect ((property, state) => {
+ var menu = new IndicatorMenu (get_action_group (), options);
+
+ menu.set_sources (get_sources ());
+ menu.activate.connect ((property, state) => {
var panel = get_ibus_panel ();
if (panel != null) {
@@ -1032,6 +1040,8 @@ public class Indicator.Keyboard.Service : Object {
}
}
});
+
+ desktop_menu = menu;
}
return (!) desktop_menu;
@@ -1043,8 +1053,9 @@ public class Indicator.Keyboard.Service : Object {
var options = IndicatorMenu.Options.DCONF |
IndicatorMenu.Options.XKB;
- desktop_greeter_menu = new IndicatorMenu (get_action_group (), options);
- ((!) desktop_greeter_menu).set_sources (get_sources ());
+ var menu = new IndicatorMenu (get_action_group (), options);
+ menu.set_sources (get_sources ());
+ desktop_greeter_menu = menu;
}
return (!) desktop_greeter_menu;
@@ -1055,8 +1066,9 @@ public class Indicator.Keyboard.Service : Object {
if (desktop_lockscreen_menu == null) {
var options = IndicatorMenu.Options.XKB;
- desktop_lockscreen_menu = new IndicatorMenu (get_action_group (), options);
- ((!) desktop_lockscreen_menu).set_sources (get_sources ());
+ var menu = new IndicatorMenu (get_action_group (), options);
+ menu.set_sources (get_sources ());
+ desktop_lockscreen_menu = menu;
}
return (!) desktop_lockscreen_menu;
@@ -1139,8 +1151,9 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void handle_unity_greeter_name_appeared (DBusConnection connection, string name, string name_owner) {
try {
- unity_greeter = Bus.get_proxy_sync (BusType.SESSION, name, "/list");
- ((!) unity_greeter).entry_selected.connect (handle_entry_selected);
+ var greeter = Bus.get_proxy_sync<UnityGreeter> (BusType.SESSION, name, "/list");
+ greeter.entry_selected.connect (handle_entry_selected);
+ unity_greeter = greeter;
} catch (IOError error) {
warning ("error: %s", error.message);
}
@@ -1168,8 +1181,9 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void handle_unity_name_appeared (DBusConnection connection, string name, string name_owner) {
try {
- unity_session = Bus.get_proxy_sync (BusType.SESSION, name, "/com/canonical/Unity/Session");
- ((!) unity_session).locked.connect (() => {
+ var session = Bus.get_proxy_sync<UnitySession> (BusType.SESSION, name, "/com/canonical/Unity/Session");
+
+ session.locked.connect (() => {
var sources = get_sources ();
if (sources.length > 0) {
@@ -1185,9 +1199,11 @@ public class Indicator.Keyboard.Service : Object {
}
}
});
- ((!) unity_session).unlocked.connect (() => {
+ session.unlocked.connect (() => {
get_active_action ().change_state (new Variant.uint32 (get_current ()));
});
+
+ unity_session = session;
} catch (IOError error) {
warning ("error: %s", error.message);
}
diff --git a/lib/source.vala b/lib/source.vala
index f73b4b69..38a628c1 100644
--- a/lib/source.vala
+++ b/lib/source.vala
@@ -335,12 +335,14 @@ public class Indicator.Keyboard.Source : Object {
Gdk.Screen? screen = Gdk.Screen.get_default ();
if (screen != null) {
- context = new Gtk.StyleContext ();
- ((!) context).set_screen ((!) screen);
+ var style_context = new Gtk.StyleContext ();
+ style_context.set_screen ((!) screen);
var path = new Gtk.WidgetPath ();
path.append_type (typeof (Gtk.MenuItem));
- ((!) context).set_path (path);
+ style_context.set_path (path);
+
+ context = style_context;
}
}