From fa9b85fcb7a5263016994b36111052234ca2c930 Mon Sep 17 00:00:00 2001 From: Jeremy Bicha Date: Tue, 30 Jul 2013 12:55:44 -0400 Subject: drop .pc/ and debian/patches/ directories --- .pc/.quilt_patches | 1 - .pc/.quilt_series | 1 - .pc/.version | 1 - .pc/applied-patches | 3 - .pc/default-icon-colour.patch/lib/main.vala | 754 --------------------- .../tests/Makefile.am | 19 - .../tests/main.vala | 675 ------------------ .pc/relax-test-missing-ibus.patch/tests/main.vala | 675 ------------------ debian/patches/default-icon-colour.patch | 10 - debian/patches/disable-experimental-non-null.patch | 68 -- debian/patches/relax-test-missing-ibus.patch | 11 - debian/patches/series | 3 - 12 files changed, 2221 deletions(-) delete mode 100644 .pc/.quilt_patches delete mode 100644 .pc/.quilt_series delete mode 100644 .pc/.version delete mode 100644 .pc/applied-patches delete mode 100644 .pc/default-icon-colour.patch/lib/main.vala delete mode 100644 .pc/disable-experimental-non-null.patch/tests/Makefile.am delete mode 100644 .pc/disable-experimental-non-null.patch/tests/main.vala delete mode 100644 .pc/relax-test-missing-ibus.patch/tests/main.vala delete mode 100644 debian/patches/default-icon-colour.patch delete mode 100644 debian/patches/disable-experimental-non-null.patch delete mode 100644 debian/patches/relax-test-missing-ibus.patch delete mode 100644 debian/patches/series diff --git a/.pc/.quilt_patches b/.pc/.quilt_patches deleted file mode 100644 index 6857a8d4..00000000 --- a/.pc/.quilt_patches +++ /dev/null @@ -1 +0,0 @@ -debian/patches diff --git a/.pc/.quilt_series b/.pc/.quilt_series deleted file mode 100644 index c2067066..00000000 --- a/.pc/.quilt_series +++ /dev/null @@ -1 +0,0 @@ -series diff --git a/.pc/.version b/.pc/.version deleted file mode 100644 index 0cfbf088..00000000 --- a/.pc/.version +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/.pc/applied-patches b/.pc/applied-patches deleted file mode 100644 index 2a60b05c..00000000 --- a/.pc/applied-patches +++ /dev/null @@ -1,3 +0,0 @@ -default-icon-colour.patch -disable-experimental-non-null.patch -relax-test-missing-ibus.patch diff --git a/.pc/default-icon-colour.patch/lib/main.vala b/.pc/default-icon-colour.patch/lib/main.vala deleted file mode 100644 index 9ce6ca3b..00000000 --- a/.pc/default-icon-colour.patch/lib/main.vala +++ /dev/null @@ -1,754 +0,0 @@ -[DBus (name = "com.canonical.indicator.keyboard")] -public class Indicator.Keyboard.Service : Object { - - private bool use_gtk; - private bool use_bamf; - private MainLoop? loop; - private Settings indicator_settings; - private Settings source_settings; - private Settings per_window_settings; - private Gnome.XkbInfo xkb_info; - private IBus.Bus? ibus; - private Bamf.Matcher? matcher; - private Gee.HashMap? window_sources; - - private SimpleActionGroup? action_group; - private SimpleAction? indicator_action; - private MenuModel? menu_model; - private Menu? sources_menu; - - private Icon?[]? icons; - private string[]? icon_strings; - private int[]? icon_string_uniques; - private uint[]? icon_string_subscripts; - - [DBus (visible = false)] - public Service (ref unowned string[] args) { - Bus.own_name (BusType.SESSION, - "com.canonical.indicator.keyboard", - BusNameOwnerFlags.ALLOW_REPLACEMENT | ("--force" in args ? BusNameOwnerFlags.REPLACE : 0), - this.handle_bus_acquired, - null, - this.handle_name_lost); - - this.use_gtk = "--use-gtk" in args; - this.use_bamf = "--use-bamf" in args; - - if (this.use_gtk) { - this.use_gtk = Gtk.init_check (ref args); - } else { - Gdk.init (ref args); - } - - this.indicator_settings = new Settings ("com.canonical.indicator.keyboard"); - this.indicator_settings.changed["visible"].connect (this.handle_changed_visible); - - this.source_settings = new Settings ("org.gnome.desktop.input-sources"); - this.source_settings.changed["current"].connect (this.handle_changed_current); - this.source_settings.changed["sources"].connect (this.handle_changed_sources); - - this.per_window_settings = new Settings ("org.gnome.libgnomekbd.desktop"); - this.per_window_settings.changed["group-per-window"].connect (this.handle_changed_group_per_window); - - this.xkb_info = new Gnome.XkbInfo (); - - migrate_keyboard_layouts (); - - update_window_sources (); - - this.loop = new MainLoop (); - ((!) this.loop).run (); - } - - [DBus (visible = false)] - private IBus.Bus get_ibus () { - if (this.ibus == null) { - IBus.init (); - this.ibus = new IBus.Bus (); - } - - return (!) this.ibus; - } - - [DBus (visible = false)] - private void migrate_keyboard_layouts () { - if (!this.indicator_settings.get_boolean ("migrated")) { - var builder = new VariantBuilder (new VariantType ("a(ss)")); - var length = 0; - - var layout_settings = new Settings ("org.gnome.libgnomekbd.keyboard"); - var layouts = layout_settings.get_strv ("layouts"); - - foreach (var layout in layouts) { - var source = layout; - - source = source.replace (" ", "+"); - source = source.replace ("\t", "+"); - - builder.add ("(ss)", "xkb", source); - length++; - } - - var engines = get_ibus ().list_active_engines (); - - foreach (var engine in engines) { - if (length == 0 || engine.name.has_prefix ("xkb")) { - var source = "us"; - string? layout = engine.get_layout (); - string? variant = engine.get_layout_variant (); - - if (layout != null && ((!) layout).length == 0) { - layout = null; - } - - if (variant != null && ((!) variant).length == 0) { - variant = null; - } - - if (layout != null && variant != null) { - source = @"$((!) layout)+$((!) variant)"; - } else if (layout != null) { - source = (!) layout; - } - - builder.add ("(ss)", "xkb", source); - length++; - } - - if (!engine.name.has_prefix ("xkb")) { - builder.add ("(ss)", "ibus", engine.name); - length++; - } - } - - this.source_settings.set_value ("sources", builder.end ()); - - this.indicator_settings.set_boolean ("migrated", true); - } - } - - [DBus (visible = false)] - private void update_window_sources () { - if (this.use_bamf) { - var group_per_window = this.per_window_settings.get_boolean ("group-per-window"); - - if (group_per_window != (this.window_sources != null)) { - if (group_per_window) { - this.window_sources = new Gee.HashMap (); - this.matcher = Bamf.Matcher.get_default (); - ((!) this.matcher).active_window_changed.connect (this.handle_active_window_changed); - } else { - ((!) this.matcher).active_window_changed.disconnect (this.handle_active_window_changed); - this.matcher = null; - this.window_sources = null; - } - } - } - } - - [DBus (visible = false)] - private void handle_changed_group_per_window (string key) { - update_window_sources (); - } - - [DBus (visible = false)] - private void handle_active_window_changed (Bamf.View? old_view, Bamf.View? new_view) { - if (old_view != null) { - ((!) this.window_sources)[((!) old_view).path] = this.source_settings.get_uint ("current"); - } - - if (new_view != null) { - if (!((!) this.window_sources).has_key (((!) new_view).path)) { - var default_group = this.per_window_settings.get_int ("default-group"); - - if (default_group >= 0) { - this.source_settings.set_uint ("current", (uint) default_group); - } - } else { - this.source_settings.set_uint ("current", ((!) this.window_sources)[((!) new_view).path]); - } - } - } - - [DBus (visible = false)] - private Gtk.StyleContext? get_style_context () { - Gtk.StyleContext? context = null; - - if (this.use_gtk) { - Gdk.Screen? screen = Gdk.Screen.get_default (); - - if (screen != null) { - context = new Gtk.StyleContext (); - ((!) context).set_screen ((!) screen); - - var path = new Gtk.WidgetPath (); - path.append_type (typeof (Gtk.MenuItem)); - ((!) context).set_path (path); - } - } - - return context; - } - - [DBus (visible = false)] - protected virtual Icon? create_icon (string? text, uint subscript) { - Icon? icon = null; - - var style = get_style_context (); - - if (style != null) { - const int W = 22; - const int H = 22; - const int w = 20; - const int h = 20; - const double R = 2.0; - const double TEXT_SIZE = 12.0; - const double SUBSCRIPT_SIZE = 8.0; - - Pango.FontDescription description; - var colour = ((!) style).get_color (Gtk.StateFlags.NORMAL); - ((!) style).get (Gtk.StateFlags.NORMAL, Gtk.STYLE_PROPERTY_FONT, out description); - - var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, W, H); - var context = new Cairo.Context (surface); - - context.translate (0.5 * (W - w), 0.5 * (H - h)); - - context.new_sub_path (); - context.arc (R, R, R, Math.PI, -0.5 * Math.PI); - context.arc (w - R, R, R, -0.5 * Math.PI, 0); - context.arc (w - R, h - R, R, 0, 0.5 * Math.PI); - context.arc (R, h - R, R, 0.5 * Math.PI, Math.PI); - context.close_path (); - - context.set_source_rgba (colour.red, colour.green, colour.blue, colour.alpha); - context.fill (); - context.set_operator (Cairo.Operator.CLEAR); - - if (text != null) { - var text_layout = Pango.cairo_create_layout (context); - text_layout.set_alignment (Pango.Alignment.CENTER); - description.set_absolute_size (Pango.units_from_double (TEXT_SIZE)); - text_layout.set_font_description (description); - text_layout.set_text ((!) text, -1); - Pango.cairo_update_layout (context, text_layout); - int text_width; - int text_height; - text_layout.get_pixel_size (out text_width, out text_height); - - if (subscript > 0) { - var subscript_layout = Pango.cairo_create_layout (context); - subscript_layout.set_alignment (Pango.Alignment.CENTER); - description.set_absolute_size (Pango.units_from_double (SUBSCRIPT_SIZE)); - subscript_layout.set_font_description (description); - subscript_layout.set_text (@"$subscript", -1); - Pango.cairo_update_layout (context, subscript_layout); - int subscript_width; - int subscript_height; - subscript_layout.get_pixel_size (out subscript_width, out subscript_height); - - context.save (); - context.translate ((w - (text_width + subscript_width)) / 2, (h - text_height) / 2); - Pango.cairo_layout_path (context, text_layout); - context.fill (); - context.restore (); - - context.save (); - context.translate ((w + (text_width - subscript_width)) / 2, (h + text_height) / 2 - subscript_height); - Pango.cairo_layout_path (context, subscript_layout); - context.fill (); - context.restore (); - } else { - context.save (); - context.translate ((w - text_width) / 2, (h - text_height) / 2); - Pango.cairo_layout_path (context, text_layout); - context.fill (); - context.restore (); - } - } - - var buffer = new ByteArray (); - - surface.write_to_png_stream ((data) => { - buffer.append (data); - return Cairo.Status.SUCCESS; - }); - - icon = new BytesIcon (ByteArray.free_to_bytes ((owned) buffer)); - } - - return icon; - } - - [DBus (visible = false)] - private string get_icon_string (uint index) { - string? icon_string = null; - - if (this.icon_strings == null) { - var array = this.source_settings.get_value ("sources"); - this.icon_strings = new string[array.n_children ()]; - } - - if (index < ((!) this.icon_strings).length) { - icon_string = this.icon_strings[index]; - - if (icon_string == null) { - var array = this.source_settings.get_value ("sources"); - - string type; - string name; - - array.get_child (index, "(ss)", out type, out name); - - if (type == "xkb") { - string? short_name; - - this.xkb_info.get_layout_info (name, null, out short_name, null, null); - - if (short_name != null) { - this.icon_strings[index] = get_abbreviation ((!) short_name); - icon_string = this.icon_strings[index]; - } - } - } - } - - if (icon_string == null) { - icon_string = ""; - } - - return (!) icon_string; - } - - [DBus (visible = false)] - private bool is_icon_string_unique (uint index) { - bool icon_string_unique = true; - - if (this.icon_string_uniques == null) { - var array = this.source_settings.get_value ("sources"); - this.icon_string_uniques = new int[array.n_children ()]; - - for (var i = 0; i < ((!) this.icon_string_uniques).length; i++) { - this.icon_string_uniques[i] = -1; - } - } - - if (index < ((!) this.icon_string_uniques).length) { - if (this.icon_string_uniques[index] == -1) { - this.icon_string_uniques[index] = 1; - - var icon_string = get_icon_string (index); - - for (var i = 0; i < ((!) this.icon_string_uniques).length && this.icon_string_uniques[index] == 1; i++) { - if (i != index && get_icon_string (i) == icon_string) { - this.icon_string_uniques[index] = 0; - } - } - } - - icon_string_unique = this.icon_string_uniques[index] != 0; - } - - return icon_string_unique; - } - - [DBus (visible = false)] - private uint get_icon_string_subscript (uint index) { - uint icon_string_subscript = 0; - - if (this.icon_string_subscripts == null) { - var array = this.source_settings.get_value ("sources"); - this.icon_string_subscripts = new uint[array.n_children ()]; - } - - if (index < ((!) this.icon_string_subscripts).length) { - icon_string_subscript = this.icon_string_subscripts[index]; - - if (icon_string_subscript == 0) { - this.icon_string_subscripts[index] = 1; - - for (var i = (int) index - 1; i >= 0 && this.icon_string_subscripts[index] == 1; i--) { - if (get_icon_string (i) == get_icon_string (index)) { - this.icon_string_subscripts[index] = get_icon_string_subscript (i) + 1; - } - } - - icon_string_subscript = this.icon_string_subscripts[index]; - } - } - - return icon_string_subscript; - } - - [DBus (visible = false)] - private Icon? get_icon (uint index) { - Icon? icon = null; - - if (this.icons == null) { - var array = this.source_settings.get_value ("sources"); - this.icons = new Icon?[array.n_children ()]; - } - - if (index < ((!) this.icons).length) { - icon = this.icons[index]; - - if (icon == null) { - var array = this.source_settings.get_value ("sources"); - - string type; - string name; - - array.get_child (index, "(ss)", out type, out name); - - if (type == "xkb") { - var icon_string = get_icon_string (index); - var icon_unique = is_icon_string_unique (index); - var icon_subscript = get_icon_string_subscript (index); - - if (icon_string.get_char () != '\0') { - string icon_name; - - if (icon_unique) { - icon_name = @"indicator-keyboard-$((!) icon_string)"; - } else { - icon_name = @"indicator-keyboard-$((!) icon_string)-$icon_subscript"; - } - - if (this.use_gtk) { - var icon_theme = Gtk.IconTheme.get_default (); - Gtk.IconInfo? icon_info = icon_theme.lookup_icon (icon_name, 22, 0); - - if (icon_info != null) { - try { - this.icons[index] = Icon.new_for_string (((!) icon_info).get_filename ()); - } catch (Error error) { - this.icons[index] = null; - } - } - } else { - this.icons[index] = new ThemedIcon (icon_name); - } - } - - if (this.icons[index] == null) { - if (icon_unique) { - this.icons[index] = create_icon (icon_string, 0); - } else { - this.icons[index] = create_icon (icon_string, icon_subscript); - } - } - } else if (type == "ibus") { - var names = new string[2]; - names[0] = name; - - var engines = get_ibus ().get_engines_by_names (names); - - if (engines.length > 0) { - var engine = engines[0]; - - try { - this.icons[index] = Icon.new_for_string (engine.get_icon ()); - } catch (Error error) { - warning ("error: %s", error.message); - } - } - } - - icon = this.icons[index]; - } - } - - return icon; - } - - [DBus (visible = false)] - protected virtual SimpleActionGroup create_action_group (Action root_action) { - var group = new SimpleActionGroup (); - - group.insert (root_action); - group.insert (this.source_settings.create_action ("current")); - - var action = new SimpleAction ("map", null); - action.activate.connect (this.handle_activate_map); - group.insert (action); - - action = new SimpleAction ("chart", null); - action.activate.connect (this.handle_activate_chart); - group.insert (action); - - action = new SimpleAction ("settings", null); - action.activate.connect (this.handle_activate_settings); - group.insert (action); - - return group; - } - - [DBus (visible = false)] - private void update_indicator_action () { - var visible = this.indicator_settings.get_boolean ("visible"); - var current = this.source_settings.get_uint ("current"); - var icon = get_icon (current); - Variant state; - - if (icon != null) { - state = new Variant.parsed ("{ 'visible' : <%b>, 'icon' : %v }", visible, ((!) icon).serialize ()); - } else { - state = new Variant.parsed ("{ 'visible' : <%b> }", visible); - } - - get_indicator_action ().set_state (state); - } - - [DBus (visible = false)] - private SimpleAction get_indicator_action () { - if (this.indicator_action == null) { - var state = new Variant.parsed ("{ 'visible' : }"); - this.indicator_action = new SimpleAction.stateful ("indicator", null, state); - update_indicator_action (); - } - - return (!) this.indicator_action; - } - - [DBus (visible = false)] - public SimpleActionGroup get_action_group () { - if (this.action_group == null) { - this.action_group = create_action_group (get_indicator_action ()); - } - - return (!) this.action_group; - } - - [DBus (visible = false)] - protected virtual MenuModel create_menu_model (MenuModel section_menu) { - var menu = new Menu (); - - var submenu = new Menu (); - - submenu.append_section (null, section_menu); - - var section = new Menu (); - section.append (_ ("Character Map"), "indicator.map"); - section.append (_ ("Keyboard Layout Chart"), "indicator.chart"); - section.append (_ ("Text Entry Settings..."), "indicator.settings"); - submenu.append_section (null, section); - - var indicator = new MenuItem.submenu ("x", submenu); - indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root"); - indicator.set_detailed_action ("indicator.indicator"); - menu.append_item (indicator); - - return menu; - } - - [DBus (visible = false)] - private string get_display_name (string layout) { - string? language = Xkl.get_language_name (layout); - string? country = Xkl.get_country_name (layout); - var has_language = language != null && ((!) language).get_char () != '\0'; - var has_country = country != null && ((!) country).get_char () != '\0'; - - if (has_language && has_country) { - return @"$((!) language) ($((!) country))"; - } else if (has_language) { - return (!) language; - } else if (has_country) { - return (!) country; - } else { - return ""; - } - } - - [DBus (visible = false)] - private void update_sources_menu () { - if (this.sources_menu != null) { - var menu = get_sources_menu (); - - while (menu.get_n_items () > 0) - menu.remove (0); - - VariantIter iter; - string type; - string name; - - this.source_settings.get ("sources", "a(ss)", out iter); - - for (var i = 0; iter.next ("(ss)", out type, out name); i++) { - if (type == "xkb") { - string? display_name; - string? layout_name; - - this.xkb_info.get_layout_info (name, out display_name, null, out layout_name, null); - - if (display_name != null) { - name = (!) display_name; - } else if (layout_name != null) { - name = get_display_name ((!) layout_name); - } - } - else if (type == "ibus") { - var names = new string[2]; - names[0] = name; - - var engines = get_ibus ().get_engines_by_names (names); - - if (engines.length > 0) { - var engine = engines[0]; - string? language = engine.get_language (); - string? display_name = engine.get_longname (); - - if (language != null) { - language = Xkl.get_language_name ((!) language); - } - - if (language != null && display_name != null) { - name = @"$((!) language) ($((!) display_name))"; - } else if (language != null) { - name = (!) language; - } else if (display_name != null) { - name = (!) display_name; - } - } - } - - var menu_item = new MenuItem (name, "indicator.current"); - menu_item.set_attribute (Menu.ATTRIBUTE_TARGET, "u", i); - - var icon = get_icon (i); - if (icon != null) { - menu_item.set_icon ((!) icon); - } - - menu.append_item (menu_item); - } - } else { - get_sources_menu (); - } - } - - [DBus (visible = false)] - private Menu get_sources_menu () { - if (this.sources_menu == null) { - this.sources_menu = new Menu (); - update_sources_menu (); - } - - return (!) this.sources_menu; - } - - [DBus (visible = false)] - public MenuModel get_menu_model () { - if (this.menu_model == null) { - this.menu_model = create_menu_model (get_sources_menu ()); - } - - return (!) this.menu_model; - } - - [DBus (visible = false)] - private void handle_changed_visible (string key) { - update_indicator_action (); - } - - [DBus (visible = false)] - private void handle_changed_current (string key) { - update_indicator_action (); - } - - [DBus (visible = false)] - private void handle_changed_sources (string key) { - this.icon_string_subscripts = null; - this.icon_string_uniques = null; - this.icon_strings = null; - this.icons = null; - - update_sources_menu (); - update_indicator_action (); - } - - [DBus (visible = false)] - private void handle_activate_map (Variant? parameter) { - try { - Process.spawn_command_line_async ("gucharmap"); - } catch (SpawnError error) { - warning ("error: %s", error.message); - } - } - - [DBus (visible = false)] - private void handle_activate_chart (Variant? parameter) { - var layout = "us"; - string? variant = null; - - var current = this.source_settings.get_uint ("current"); - var array = this.source_settings.get_value ("sources"); - - if (current < array.n_children ()) { - string type; - string name; - - array.get_child (current, "(ss)", out type, out name); - - if (type == "xkb") { - this.xkb_info.get_layout_info (name, null, null, out layout, out variant); - } else if (type == "ibus") { - var names = new string[2]; - names[0] = name; - - var engines = get_ibus ().get_engines_by_names (names); - - if (engines.length > 0) { - var engine = engines[0]; - - layout = engine.get_layout (); - variant = engine.get_layout_variant (); - } - } - } - - try { - string command; - - if (variant != null && ((!) variant).get_char () != '\0') { - command = @"gkbd-keyboard-display -l \"$layout\t$((!) variant)\""; - } else { - command = @"gkbd-keyboard-display -l $layout"; - } - - Process.spawn_command_line_async (command); - } catch (SpawnError error) { - warning ("error: %s", error.message); - } - } - - [DBus (visible = false)] - private void handle_activate_settings (Variant? parameter) { - try { - Process.spawn_command_line_async ("gnome-control-center region layouts"); - } catch (SpawnError error) { - warning ("error: %s", error.message); - } - } - - [DBus (visible = false)] - private void handle_bus_acquired (DBusConnection connection, string name) { - try { - connection.export_action_group ("/com/canonical/indicator/keyboard", get_action_group ()); - connection.export_menu_model ("/com/canonical/indicator/keyboard/desktop", get_menu_model ()); - } catch (Error error) { - warning ("error: %s", error.message); - } - } - - [DBus (visible = false)] - private void handle_name_lost (DBusConnection? connection, string name) { - ((!) this.loop).quit (); - this.loop = null; - } - - [DBus (visible = false)] - public static int main (string[] args) { - new Service (ref args); - return 0; - } -} diff --git a/.pc/disable-experimental-non-null.patch/tests/Makefile.am b/.pc/disable-experimental-non-null.patch/tests/Makefile.am deleted file mode 100644 index c05fd4b5..00000000 --- a/.pc/disable-experimental-non-null.patch/tests/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -SUBDIRS = autopilot -TESTS = indicator-keyboard-test - -check_PROGRAMS = indicator-keyboard-tests - -AM_CFLAGS = -w -AM_LDFLAGS = -lm -AM_VALAFLAGS = --enable-experimental-non-null \ - --metadatadir $(top_srcdir)/deps \ - --vapidir $(top_srcdir)/deps - -indicator_keyboard_tests_SOURCES = main.vala \ - config.vala -indicator_keyboard_tests_VALAFLAGS = $(AM_VALAFLAGS) \ - --pkg gio-2.0 -indicator_keyboard_tests_CFLAGS = $(AM_CFLAGS) \ - $(GIO_CFLAGS) -indicator_keyboard_tests_LDFLAGS = $(AM_LDFLAGS) \ - $(GIO_LIBS) diff --git a/.pc/disable-experimental-non-null.patch/tests/main.vala b/.pc/disable-experimental-non-null.patch/tests/main.vala deleted file mode 100644 index 1a23b46f..00000000 --- a/.pc/disable-experimental-non-null.patch/tests/main.vala +++ /dev/null @@ -1,675 +0,0 @@ -const int TIMEOUT_S = 1; -const int TIMEOUT_MS = 1000; - -[DBus (name = "com.canonical.indicator.keyboard.test")] -public class Service : Object { - - [DBus (visible = false)] - private string? _command; - - [DBus (visible = false)] - public string? command { - get { return _command; } - } - - public void execute (string command) { - this._command = command; - - var pspec = this.get_class ().find_property ("command"); - - if (pspec != null) { - this.notify["command"] ((!) pspec); - } - } -} - -struct Fixture { - TestDBus? bus; - uint service_name; - DBusConnection? connection; - Service? service; - uint object_name; -} - -static void start_service (Fixture *fixture) { - if (fixture.connection != null) { - try { - fixture.service = new Service (); - fixture.object_name = ((!) fixture.connection).register_object ("/com/canonical/indicator/keyboard/test", fixture.service); - } catch (IOError error) { - fixture.connection = null; - fixture.service = null; - fixture.object_name = 0; - - Test.message ("error: %s", error.message); - Test.fail (); - } - } -} - -static void begin_test (void *data) { - var fixture = (Fixture *) data; - - fixture.bus = new TestDBus (TestDBusFlags.NONE); - ((!) fixture.bus).add_service_dir (SERVICE_DIR); - ((!) fixture.bus).up (); - - var loop = new MainLoop (null, false); - - fixture.service_name = Bus.own_name (BusType.SESSION, - "com.canonical.indicator.keyboard.test", - BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE, - (connection, name) => { - if (loop.is_running ()) { - fixture.connection = connection; - - start_service (fixture); - - loop.quit (); - } - }, - null, - (connection, name) => { - if (loop.is_running ()) { - fixture.connection = null; - fixture.service = null; - fixture.object_name = 0; - - loop.quit (); - } - }); - - loop.run (); - - if (fixture.connection == null) { - Test.message ("error: Unable to connect to com.canonical.indicator.keyboard.test."); - Test.fail (); - } -} - -static void end_test (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name != 0) { - ((!) fixture.connection).unregister_object (fixture.object_name); - fixture.object_name = 0; - } - - if (fixture.service_name != 0) { - Bus.unown_name (fixture.service_name); - fixture.service_name = 0; - } - - fixture.service = null; - fixture.connection = null; - - if (fixture.bus != null) { - ((!) fixture.bus).down (); - fixture.bus = null; - } -} - -static void test_activate_input_source (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var current = 0; - var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = action_group.action_state_changed["current"].connect ((action, state) => { - loop.quit (); - }); - - action_group.list_actions (); - action_group.activate_action ("current", new Variant.uint32 (2)); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("current"); - var current = ((!) state).get_uint32 (); - assert (current == 2); - - try { - string output; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); - assert (strcmp (output, "uint32 2\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } -} - -static void test_activate_character_map (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { - loop.quit (); - }); - - action_group.activate_action ("map", null); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - ((!) fixture.service).disconnect (signal_name); - - assert (strcmp ((!) ((!) fixture.service).command, "'gucharmap '") == 0); -} - -static void test_activate_keyboard_layout_chart (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var current = 1; - var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { - loop.quit (); - }); - - action_group.activate_action ("chart", null); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - ((!) fixture.service).disconnect (signal_name); - - assert (strcmp ((!) ((!) fixture.service).command, "'gkbd-keyboard-display -l ca\teng'") == 0); -} - -static void test_activate_text_entry_settings (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { - loop.quit (); - }); - - action_group.activate_action ("settings", null); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - ((!) fixture.service).disconnect (signal_name); - - assert (strcmp ((!) ((!) fixture.service).command, "'gnome-control-center region layouts'") == 0); -} - -static void test_migration (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var migrated = false; - var sources = "[('xkb', 'us')]"; - var layouts = "['us', 'ca\teng', 'epo']"; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - try { - var cancellable = new Cancellable (); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; }); - - var dbus_proxy = new DBusProxy.sync ((!) fixture.connection, - DBusProxyFlags.NONE, - null, - "org.freedesktop.DBus", - "/", - "org.freedesktop.DBus", - cancellable); - - Source.remove (source); - - if (cancellable.is_cancelled ()) { - Test.message ("error: Unable to connect to org.freedesktop.DBus."); - Test.fail (); - return; - } - - dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS); - } catch (Error error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - try { - string sources; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources); - assert (strcmp (sources, "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo')]\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } -} - -static void test_no_migration (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var migrated = true; - var sources = "[('xkb', 'us')]"; - var layouts = "['us', 'ca\teng', 'epo']"; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - try { - var cancellable = new Cancellable (); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; }); - - var dbus_proxy = new DBusProxy.sync ((!) fixture.connection, - DBusProxyFlags.NONE, - null, - "org.freedesktop.DBus", - "/", - "org.freedesktop.DBus", - cancellable); - - Source.remove (source); - - if (cancellable.is_cancelled ()) { - Test.message ("error: Unable to connect to org.freedesktop.DBus."); - Test.fail (); - return; - } - - dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS); - } catch (Error error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - try { - string sources; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources); - assert (strcmp (sources, "[('xkb', 'us')]\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } -} - -static void test_update_visible (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - bool visible; - - try { - visible = true; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = action_group.action_added["indicator"].connect ((action) => { - loop.quit (); - }); - - action_group.list_actions (); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("indicator"); - assert (((!) state).lookup ("visible", "b", out visible)); - assert (visible); - - loop = new MainLoop (null, false); - signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => { - loop.quit (); - }); - - try { - visible = false; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("indicator"); - assert (((!) state).lookup ("visible", "b", out visible)); - assert (!visible); - - loop = new MainLoop (null, false); - signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => { - loop.quit (); - }); - - try { - visible = true; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("indicator"); - assert (((!) state).lookup ("visible", "b", out visible)); - assert (visible); -} - -static void test_update_input_source (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var current = 0; - var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = action_group.action_state_changed["current"].connect ((action, state) => { - loop.quit (); - }); - - action_group.list_actions (); - - try { - var current = 1; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("current"); - var current = ((!) state).get_uint32 (); - assert (current == 1); - - try { - string output; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); - assert (strcmp (output, "uint32 1\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - loop = new MainLoop (null, false); - signal_name = action_group.action_state_changed["current"].connect ((action, state) => { - loop.quit (); - }); - - try { - current = 0; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("current"); - current = ((!) state).get_uint32 (); - assert (current == 0); - - try { - string output; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); - assert (strcmp (output, "uint32 0\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } -} - -static void test_update_input_sources (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var current = 0; - var sources = "[('xkb', 'us')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var menu_model = DBusMenuModel.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard/desktop"); - var loop = new MainLoop (null, false); - var signal_name = menu_model.items_changed.connect ((position, removed, added) => { - loop.quit (); - }); - - menu_model.get_n_items (); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - menu_model.disconnect (signal_name); - - var menu = menu_model.get_item_link (0, Menu.LINK_SUBMENU); - loop = new MainLoop (null, false); - signal_name = menu.items_changed.connect ((position, removed, added) => { - loop.quit (); - }); - - menu.get_n_items (); - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - menu.disconnect (signal_name); - - var section = menu.get_item_link (0, Menu.LINK_SECTION); - loop = new MainLoop (null, false); - signal_name = section.items_changed.connect ((position, removed, added) => { - loop.quit (); - }); - - section.get_n_items (); - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - section.disconnect (signal_name); - - string label; - - assert (section.get_n_items () == 1); - section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "English (US)") == 0); - - loop = new MainLoop (null, false); - signal_name = section.items_changed.connect ((position, removed, added) => { - if (section.get_n_items () == 4) { - loop.quit (); - } - }); - - try { - var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - section.disconnect (signal_name); - - assert (section.get_n_items () == 4); - section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "English (US)") == 0); - section.get_item_attribute (1, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "English (Canada)") == 0); - section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "Esperanto") == 0); - section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "Pinyin") == 0); -} - -public int main (string[] args) { - Environment.set_variable ("DCONF_PROFILE", DCONF_PROFILE, true); - Environment.set_variable ("LC_ALL", "C", true); - - Test.init (ref args, null); - - var suite = new TestSuite ("indicator-keyboard"); - - suite.add (new TestCase ("activate-input-source", begin_test, test_activate_input_source, end_test, sizeof (Fixture))); - suite.add (new TestCase ("activate-character-map", begin_test, test_activate_character_map, end_test, sizeof (Fixture))); - suite.add (new TestCase ("activate-keyboard-layout-chart", begin_test, test_activate_keyboard_layout_chart, end_test, sizeof (Fixture))); - suite.add (new TestCase ("activate-text-entry-settings", begin_test, test_activate_text_entry_settings, end_test, sizeof (Fixture))); - suite.add (new TestCase ("migration", begin_test, test_migration, end_test, sizeof (Fixture))); - suite.add (new TestCase ("no-migration", begin_test, test_no_migration, end_test, sizeof (Fixture))); - suite.add (new TestCase ("update-visible", begin_test, test_update_visible, end_test, sizeof (Fixture))); - suite.add (new TestCase ("update-input-source", begin_test, test_update_input_source, end_test, sizeof (Fixture))); - suite.add (new TestCase ("update-input-sources", begin_test, test_update_input_sources, end_test, sizeof (Fixture))); - - TestSuite.get_root ().add_suite (suite); - - return Test.run (); -} diff --git a/.pc/relax-test-missing-ibus.patch/tests/main.vala b/.pc/relax-test-missing-ibus.patch/tests/main.vala deleted file mode 100644 index 4e121fcd..00000000 --- a/.pc/relax-test-missing-ibus.patch/tests/main.vala +++ /dev/null @@ -1,675 +0,0 @@ -const int TIMEOUT_S = 1; -const int TIMEOUT_MS = 1000; - -[DBus (name = "com.canonical.indicator.keyboard.test")] -public class Service : Object { - - [DBus (visible = false)] - private string? _command; - - [DBus (visible = false)] - public string? command { - get { return _command; } - } - - public void execute (string command) { - this._command = command; - - var pspec = this.get_class ().find_property ("command"); - - if (pspec != null) { - this.notify["command"] ((!) pspec); - } - } -} - -struct Fixture { - TestDBus? bus; - uint service_name; - DBusConnection? connection; - Service? service; - uint object_name; -} - -static void start_service (Fixture *fixture) { - if (fixture.connection != null) { - try { - fixture.service = new Service (); - fixture.object_name = ((!) fixture.connection).register_object ("/com/canonical/indicator/keyboard/test", fixture.service); - } catch (IOError error) { - fixture.connection = null; - fixture.service = null; - fixture.object_name = 0; - - Test.message ("error: %s", error.message); - Test.fail (); - } - } -} - -static void begin_test (void *data) { - var fixture = (Fixture *) data; - - fixture.bus = new TestDBus (TestDBusFlags.NONE); - ((!) fixture.bus).add_service_dir (SERVICE_DIR); - ((!) fixture.bus).up (); - - var loop = new MainLoop (null, false); - - fixture.service_name = Bus.own_name (BusType.SESSION, - "com.canonical.indicator.keyboard.test", - BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE, - (connection, name) => { - if (loop.is_running ()) { - fixture.connection = connection; - - start_service (fixture); - - loop.quit (); - } - }, - null, - (connection, name) => { - if (loop.is_running ()) { - fixture.connection = null; - fixture.service = null; - fixture.object_name = 0; - - loop.quit (); - } - }); - - loop.run (); - - if (fixture.connection == null) { - Test.message ("error: Unable to connect to com.canonical.indicator.keyboard.test."); - Test.fail (); - } -} - -static void end_test (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name != 0) { - ((!) fixture.connection).unregister_object (fixture.object_name); - fixture.object_name = 0; - } - - if (fixture.service_name != 0) { - Bus.unown_name (fixture.service_name); - fixture.service_name = 0; - } - - fixture.service = null; - fixture.connection = null; - - if (fixture.bus != null) { - ((!) fixture.bus).down (); - fixture.bus = null; - } -} - -static void test_activate_input_source (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var current = 0; - var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = action_group.action_state_changed["current"].connect ((action, state) => { - loop.quit (); - }); - - action_group.list_actions (); - action_group.activate_action ("current", new Variant.uint32 (2)); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("current"); - var current = state.get_uint32 (); - assert (current == 2); - - try { - string output; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); - assert (strcmp (output, "uint32 2\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } -} - -static void test_activate_character_map (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { - loop.quit (); - }); - - action_group.activate_action ("map", null); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - ((!) fixture.service).disconnect (signal_name); - - assert (strcmp ((!) ((!) fixture.service).command, "'gucharmap '") == 0); -} - -static void test_activate_keyboard_layout_chart (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var current = 1; - var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { - loop.quit (); - }); - - action_group.activate_action ("chart", null); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - ((!) fixture.service).disconnect (signal_name); - - assert (strcmp ((!) ((!) fixture.service).command, "'gkbd-keyboard-display -l ca\teng'") == 0); -} - -static void test_activate_text_entry_settings (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { - loop.quit (); - }); - - action_group.activate_action ("settings", null); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - ((!) fixture.service).disconnect (signal_name); - - assert (strcmp ((!) ((!) fixture.service).command, "'gnome-control-center region layouts'") == 0); -} - -static void test_migration (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var migrated = false; - var sources = "[('xkb', 'us')]"; - var layouts = "['us', 'ca\teng', 'epo']"; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - try { - var cancellable = new Cancellable (); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; }); - - var dbus_proxy = new DBusProxy.sync ((!) fixture.connection, - DBusProxyFlags.NONE, - null, - "org.freedesktop.DBus", - "/", - "org.freedesktop.DBus", - cancellable); - - Source.remove (source); - - if (cancellable.is_cancelled ()) { - Test.message ("error: Unable to connect to org.freedesktop.DBus."); - Test.fail (); - return; - } - - dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS); - } catch (Error error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - try { - string sources; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources); - assert (strcmp (sources, "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo')]\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } -} - -static void test_no_migration (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var migrated = true; - var sources = "[('xkb', 'us')]"; - var layouts = "['us', 'ca\teng', 'epo']"; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - try { - var cancellable = new Cancellable (); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; }); - - var dbus_proxy = new DBusProxy.sync ((!) fixture.connection, - DBusProxyFlags.NONE, - null, - "org.freedesktop.DBus", - "/", - "org.freedesktop.DBus", - cancellable); - - Source.remove (source); - - if (cancellable.is_cancelled ()) { - Test.message ("error: Unable to connect to org.freedesktop.DBus."); - Test.fail (); - return; - } - - dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS); - } catch (Error error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - try { - string sources; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources); - assert (strcmp (sources, "[('xkb', 'us')]\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } -} - -static void test_update_visible (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - bool visible; - - try { - visible = true; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = action_group.action_added["indicator"].connect ((action) => { - loop.quit (); - }); - - action_group.list_actions (); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("indicator"); - assert (state.lookup ("visible", "b", out visible)); - assert (visible); - - loop = new MainLoop (null, false); - signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => { - loop.quit (); - }); - - try { - visible = false; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("indicator"); - assert (state.lookup ("visible", "b", out visible)); - assert (!visible); - - loop = new MainLoop (null, false); - signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => { - loop.quit (); - }); - - try { - visible = true; - Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("indicator"); - assert (state.lookup ("visible", "b", out visible)); - assert (visible); -} - -static void test_update_input_source (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var current = 0; - var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var action_group = DBusActionGroup.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard"); - var loop = new MainLoop (null, false); - var signal_name = action_group.action_state_changed["current"].connect ((action, state) => { - loop.quit (); - }); - - action_group.list_actions (); - - try { - var current = 1; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("current"); - var current = state.get_uint32 (); - assert (current == 1); - - try { - string output; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); - assert (strcmp (output, "uint32 1\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - loop = new MainLoop (null, false); - signal_name = action_group.action_state_changed["current"].connect ((action, state) => { - loop.quit (); - }); - - try { - current = 0; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("current"); - current = state.get_uint32 (); - assert (current == 0); - - try { - string output; - Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); - assert (strcmp (output, "uint32 0\n") == 0); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } -} - -static void test_update_input_sources (void *data) { - var fixture = (Fixture *) data; - - if (fixture.object_name == 0) { - Test.message ("error: Test fixture not initialized."); - Test.fail (); - return; - } - - try { - var current = 0; - var sources = "[('xkb', 'us')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - var menu_model = DBusMenuModel.get ((!) fixture.connection, - "com.canonical.indicator.keyboard", - "/com/canonical/indicator/keyboard/desktop"); - var loop = new MainLoop (null, false); - var signal_name = menu_model.items_changed.connect ((position, removed, added) => { - loop.quit (); - }); - - menu_model.get_n_items (); - - var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - menu_model.disconnect (signal_name); - - var menu = menu_model.get_item_link (0, Menu.LINK_SUBMENU); - loop = new MainLoop (null, false); - signal_name = menu.items_changed.connect ((position, removed, added) => { - loop.quit (); - }); - - menu.get_n_items (); - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - menu.disconnect (signal_name); - - var section = menu.get_item_link (0, Menu.LINK_SECTION); - loop = new MainLoop (null, false); - signal_name = section.items_changed.connect ((position, removed, added) => { - loop.quit (); - }); - - section.get_n_items (); - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - section.disconnect (signal_name); - - string label; - - assert (section.get_n_items () == 1); - section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "English (US)") == 0); - - loop = new MainLoop (null, false); - signal_name = section.items_changed.connect ((position, removed, added) => { - if (section.get_n_items () == 4) { - loop.quit (); - } - }); - - try { - var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; - Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); - } catch (SpawnError error) { - Test.message ("error: %s", error.message); - Test.fail (); - return; - } - - source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); - loop.run (); - Source.remove (source); - section.disconnect (signal_name); - - assert (section.get_n_items () == 4); - section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "English (US)") == 0); - section.get_item_attribute (1, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "English (Canada)") == 0); - section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "Esperanto") == 0); - section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "Pinyin") == 0); -} - -public int main (string[] args) { - Environment.set_variable ("DCONF_PROFILE", DCONF_PROFILE, true); - Environment.set_variable ("LC_ALL", "C", true); - - Test.init (ref args, null); - - var suite = new TestSuite ("indicator-keyboard"); - - suite.add (new TestCase ("activate-input-source", begin_test, test_activate_input_source, end_test, sizeof (Fixture))); - suite.add (new TestCase ("activate-character-map", begin_test, test_activate_character_map, end_test, sizeof (Fixture))); - suite.add (new TestCase ("activate-keyboard-layout-chart", begin_test, test_activate_keyboard_layout_chart, end_test, sizeof (Fixture))); - suite.add (new TestCase ("activate-text-entry-settings", begin_test, test_activate_text_entry_settings, end_test, sizeof (Fixture))); - suite.add (new TestCase ("migration", begin_test, test_migration, end_test, sizeof (Fixture))); - suite.add (new TestCase ("no-migration", begin_test, test_no_migration, end_test, sizeof (Fixture))); - suite.add (new TestCase ("update-visible", begin_test, test_update_visible, end_test, sizeof (Fixture))); - suite.add (new TestCase ("update-input-source", begin_test, test_update_input_source, end_test, sizeof (Fixture))); - suite.add (new TestCase ("update-input-sources", begin_test, test_update_input_sources, end_test, sizeof (Fixture))); - - TestSuite.get_root ().add_suite (suite); - - return Test.run (); -} diff --git a/debian/patches/default-icon-colour.patch b/debian/patches/default-icon-colour.patch deleted file mode 100644 index e916f0a2..00000000 --- a/debian/patches/default-icon-colour.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/lib/main.vala -+++ b/lib/main.vala -@@ -207,6 +207,7 @@ - - Pango.FontDescription description; - var colour = ((!) style).get_color (Gtk.StateFlags.NORMAL); -+ colour = { 0.5, 0.5, 0.5, 1.0 }; - ((!) style).get (Gtk.StateFlags.NORMAL, Gtk.STYLE_PROPERTY_FONT, out description); - - var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, W, H); diff --git a/debian/patches/disable-experimental-non-null.patch b/debian/patches/disable-experimental-non-null.patch deleted file mode 100644 index 2d434a0d..00000000 --- a/debian/patches/disable-experimental-non-null.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -5,8 +5,7 @@ - - AM_CFLAGS = -w - AM_LDFLAGS = -lm --AM_VALAFLAGS = --enable-experimental-non-null \ -- --metadatadir $(top_srcdir)/deps \ -+AM_VALAFLAGS = --metadatadir $(top_srcdir)/deps \ - --vapidir $(top_srcdir)/deps - - indicator_keyboard_tests_SOURCES = main.vala \ ---- a/tests/main.vala -+++ b/tests/main.vala -@@ -146,7 +146,7 @@ - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("current"); -- var current = ((!) state).get_uint32 (); -+ var current = state.get_uint32 (); - assert (current == 2); - - try { -@@ -410,7 +410,7 @@ - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("indicator"); -- assert (((!) state).lookup ("visible", "b", out visible)); -+ assert (state.lookup ("visible", "b", out visible)); - assert (visible); - - loop = new MainLoop (null, false); -@@ -433,7 +433,7 @@ - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("indicator"); -- assert (((!) state).lookup ("visible", "b", out visible)); -+ assert (state.lookup ("visible", "b", out visible)); - assert (!visible); - - loop = new MainLoop (null, false); -@@ -456,7 +456,7 @@ - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("indicator"); -- assert (((!) state).lookup ("visible", "b", out visible)); -+ assert (state.lookup ("visible", "b", out visible)); - assert (visible); - } - -@@ -505,7 +505,7 @@ - action_group.disconnect (signal_name); - - var state = action_group.get_action_state ("current"); -- var current = ((!) state).get_uint32 (); -+ var current = state.get_uint32 (); - assert (current == 1); - - try { -@@ -538,7 +538,7 @@ - action_group.disconnect (signal_name); - - state = action_group.get_action_state ("current"); -- current = ((!) state).get_uint32 (); -+ current = state.get_uint32 (); - assert (current == 0); - - try { diff --git a/debian/patches/relax-test-missing-ibus.patch b/debian/patches/relax-test-missing-ibus.patch deleted file mode 100644 index 5b384579..00000000 --- a/debian/patches/relax-test-missing-ibus.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/tests/main.vala -+++ b/tests/main.vala -@@ -648,7 +648,7 @@ - section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label); - assert (strcmp (label, "Esperanto") == 0); - section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label); -- assert (strcmp (label, "Pinyin") == 0); -+ assert (label.ascii_casecmp ("Pinyin") == 0); - } - - public int main (string[] args) { diff --git a/debian/patches/series b/debian/patches/series deleted file mode 100644 index 2a60b05c..00000000 --- a/debian/patches/series +++ /dev/null @@ -1,3 +0,0 @@ -default-icon-colour.patch -disable-experimental-non-null.patch -relax-test-missing-ibus.patch -- cgit v1.2.3