Esempio n. 1
0
 def test_set_indicator_keymaps_variants(self, mock_execute, mock_set_list):
     misc.set_indicator_keymaps('sv')
     self.assertEqual(mock_execute.call_count, 1)
     self.assertEqual(mock_execute.call_args[0][0], 'setxkbmap')
     self.assertEqual(mock_set_list.call_count, 1)
     self.assertEqual(mock_set_list.call_args[0][0],
                      'org.gnome.libgnomekbd.keyboard')
     self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
     self.assertIn('se\tdvorak', mock_set_list.call_args[0][2])
Esempio n. 2
0
 def test_set_indicator_keymaps_variants(self, mock_execute, mock_set_list):
     misc.set_indicator_keymaps('sv')
     self.assertEqual(mock_execute.call_count, 1)
     self.assertEqual(mock_execute.call_args[0][0], 'setxkbmap')
     self.assertEqual(mock_set_list.call_count, 1)
     self.assertEqual(
         mock_set_list.call_args[0][0], 'org.gnome.libgnomekbd.keyboard')
     self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
     self.assertIn('se\tdvorak', mock_set_list.call_args[0][2])
Esempio n. 3
0
 def test_set_indicator_keymaps_french(self, mock_execute, mock_set_list):
     misc.set_indicator_keymaps('fr')
     self.assertEqual(mock_execute.call_count, 1)
     self.assertEqual(mock_execute.call_args[0][0], 'setxkbmap')
     self.assertEqual(mock_set_list.call_count, 1)
     self.assertEqual(mock_set_list.call_args[0][0],
                      'org.gnome.libgnomekbd.keyboard')
     self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
     self.assertEqual('fr\toss', mock_set_list.call_args[0][2][0])
     self.assertEqual(len(mock_set_list.call_args[0][2]), 4)
Esempio n. 4
0
 def test_set_indicator_keymaps_ta(self, mock_execute, mock_set_list):
     misc.set_indicator_keymaps('ta')
     self.assertEqual(mock_execute.call_count, 1)
     self.assertEqual(mock_execute.call_args[0][0], 'setxkbmap')
     self.assertEqual(mock_set_list.call_count, 1)
     self.assertEqual(
         mock_set_list.call_args[0][0], 'org.gnome.libgnomekbd.keyboard')
     self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
     self.assertIn('lk\ttam_unicode', mock_set_list.call_args[0][2])
     self.assertGreaterEqual(len(mock_set_list.call_args[0][2]), 2)
Esempio n. 5
0
 def test_set_indicator_keymaps_french(self, mock_execute, mock_set_list):
     misc.set_indicator_keymaps('fr')
     self.assertEqual(mock_execute.call_count, 1)
     self.assertEqual(mock_execute.call_args[0][0], 'setxkbmap')
     self.assertEqual(mock_set_list.call_count, 1)
     self.assertEqual(
         mock_set_list.call_args[0][0], 'org.gnome.libgnomekbd.keyboard')
     self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
     self.assertEqual('fr\toss', mock_set_list.call_args[0][2][0])
     self.assertEqual(len(mock_set_list.call_args[0][2]), 4)
 def test_set_indicator_keymaps(self, mock_set_list):
     misc.set_indicator_keymaps('en_US.UTF-8')
     self.assertEqual(mock_set_list.call_count, 1)
     self.assertEqual(mock_set_list.call_args[0][0],
         '/desktop/gnome/peripherals/keyboard/kbd/layouts')
     self.assertEqual(mock_set_list.call_args[0][1], 'string')
     self.assertIn('us', mock_set_list.call_args[0][2])
     self.assertIn('gb', mock_set_list.call_args[0][2])
     self.assertIn('gb\tintl', mock_set_list.call_args[0][2])
     self.assertIn('gb\tmac', mock_set_list.call_args[0][2])
Esempio n. 7
0
 def test_set_indicator_keymaps_simplified_chinese(self, mock_execute,
                                                   mock_set_list):
     misc.set_indicator_keymaps('zh_CN')
     self.assertEqual(mock_execute.call_count, 1)
     self.assertEqual(mock_execute.call_args[0][0], 'setxkbmap')
     self.assertEqual(mock_set_list.call_count, 1)
     self.assertEqual(mock_set_list.call_args[0][0],
                      'org.gnome.libgnomekbd.keyboard')
     self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
     self.assertEqual('cn', mock_set_list.call_args[0][2][0])
     self.assertEqual(len(mock_set_list.call_args[0][2]), 1)
Esempio n. 8
0
 def test_set_indicator_keymaps_simplified_chinese(self, mock_execute,
                                                   mock_set_list):
     misc.set_indicator_keymaps('zh_CN')
     self.assertEqual(mock_execute.call_count, 1)
     self.assertEqual(mock_execute.call_args[0][0], 'setxkbmap')
     self.assertEqual(mock_set_list.call_count, 1)
     self.assertEqual(
         mock_set_list.call_args[0][0], 'org.gnome.libgnomekbd.keyboard')
     self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
     self.assertEqual('cn', mock_set_list.call_args[0][2][0])
     self.assertEqual(len(mock_set_list.call_args[0][2]), 1)
Esempio n. 9
0
    def on_language_selection_changed(self, *args, **kwargs):
        lang = self.get_language()
        self.controller.allow_go_forward(bool(lang))
        if not lang:
            return
        if 'UBIQUITY_GREETER' in os.environ:
            misc.set_indicator_keymaps(lang)
        # strip encoding; we use UTF-8 internally no matter what
        lang = lang.split('.')[0]
        self.controller.translate(lang)
        from gi.repository import Gtk
        ltr = i18n.get_string('default-ltr', lang, 'ubiquity/imported')
        if ltr == 'default:RTL':
            Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL)
        else:
            Gtk.Widget.set_default_direction(Gtk.TextDirection.LTR)

        if self.only:
            # The language page for oem-config doesn't have the fancy greeter.
            return

        # TODO: Cache these.
        release = misc.get_release()
        install_medium = misc.get_install_medium()
        install_medium = i18n.get_string(install_medium, lang)
        # Set the release name (Linux Mint 10.04) and medium (USB or CD) where
        # necessary.
        w = self.try_install_text_label
        text = i18n.get_string(Gtk.Buildable.get_name(w), lang)
        text = text.replace('${RELEASE}', release.name)
        text = text.replace('${MEDIUM}', install_medium)
        w.set_label(text)

        # Big buttons.
        for w in (self.try_ubuntu, self.install_ubuntu):
            text = i18n.get_string(Gtk.Buildable.get_name(w), lang)
            text = text.replace('${RELEASE}', release.name)
            text = text.replace('${MEDIUM}', install_medium)
            w.get_child().set_markup('<span size="x-large">%s</span>' % text)

        # We need to center each button under each image *and* have a homogeous
        # size between the two buttons.
        self.try_ubuntu.set_size_request(-1, -1)
        self.install_ubuntu.set_size_request(-1, -1)
        try_w = self.try_ubuntu.size_request().width
        install_w = self.install_ubuntu.size_request().width
        if try_w > install_w:
            self.try_ubuntu.set_size_request(try_w, -1)
            self.install_ubuntu.set_size_request(try_w, -1)
        elif install_w > try_w:
            self.try_ubuntu.set_size_request(install_w, -1)
            self.install_ubuntu.set_size_request(install_w, -1)

        # Make the forward button a consistent size, regardless of its text.
        install_label = i18n.get_string('install_button', lang)
        next_button = self.controller._wizard.next
        next_label = next_button.get_label()

        next_button.set_size_request(-1, -1)
        next_w = next_button.size_request().width
        next_button.set_label(install_label)
        install_w = next_button.size_request().width
        next_button.set_label(next_label)
        if next_w > install_w:
            next_button.set_size_request(next_w, -1)
        else:
            next_button.set_size_request(install_w, -1)

        self.update_release_notes_label()
        for w in self.page.get_children():
            w.show()
Esempio n. 10
0
    def on_language_selection_changed(self, *args, **kwargs):
        lang = self.get_language()
        self.controller.allow_go_forward(bool(lang))
        if not lang:
            return
        if 'UBIQUITY_GREETER' in os.environ:
            misc.set_indicator_keymaps(lang)
        # strip encoding; we use UTF-8 internally no matter what
        lang = lang.split('.')[0]
        self.controller.translate(lang)
        from gi.repository import Gtk
        ltr = i18n.get_string('default-ltr', lang, 'ubiquity/imported')
        if ltr == 'default:RTL':
            Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL)
        else:
            Gtk.Widget.set_default_direction(Gtk.TextDirection.LTR)

        if self.only:
            # The language page for oem-config doesn't have the fancy greeter.
            return

        # TODO: Cache these.
        release = misc.get_release()
        install_medium = misc.get_install_medium()
        install_medium = i18n.get_string(install_medium, lang)
        # Set the release name (Ubuntu 10.04) and medium (USB or CD) where
        # necessary.
        w = self.try_install_text_label
        text = i18n.get_string(Gtk.Buildable.get_name(w), lang)
        text = text.replace('${RELEASE}', release.name)
        text = text.replace('${MEDIUM}', install_medium)
        w.set_label(text)

        # Big buttons.
        for w in (self.try_ubuntu, self.install_ubuntu):
            text = i18n.get_string(Gtk.Buildable.get_name(w), lang)
            text = text.replace('${RELEASE}', release.name)
            text = text.replace('${MEDIUM}', install_medium)
            w.get_child().set_markup('<span size="x-large">%s</span>' % text)

        # We need to center each button under each image *and* have a homogeous
        # size between the two buttons.
        self.try_ubuntu.set_size_request(-1, -1)
        self.install_ubuntu.set_size_request(-1, -1)
        try_w = self.try_ubuntu.size_request().width
        install_w = self.install_ubuntu.size_request().width
        if try_w > install_w:
            self.try_ubuntu.set_size_request(try_w, -1)
            self.install_ubuntu.set_size_request(try_w, -1)
        elif install_w > try_w:
            self.try_ubuntu.set_size_request(install_w, -1)
            self.install_ubuntu.set_size_request(install_w, -1)

        # Make the forward button a consistent size, regardless of its text.
        install_label = i18n.get_string('install_button', lang)
        next_button = self.controller._wizard.next
        next_label = next_button.get_label()

        next_button.set_size_request(-1, -1)
        next_w = next_button.size_request().width
        next_button.set_label(install_label)
        install_w = next_button.size_request().width
        next_button.set_label(next_label)
        if next_w > install_w:
            next_button.set_size_request(next_w, -1)
        else:
            next_button.set_size_request(install_w, -1)

        self.update_release_notes_label()
        for w in self.page.get_children():
            w.show()
Esempio n. 11
0
 def test_set_indicator_keymaps_unknown(self, mock_execute, mock_set_list):
     misc.set_indicator_keymaps('unknownlanguage')
     self.assertEqual(mock_execute.call_count, 0)
     self.assertEqual(mock_set_list.call_count, 0)
Esempio n. 12
0
 def test_set_indicator_keymaps_unknown(self, mock_execute, mock_set_list):
     misc.set_indicator_keymaps('unknownlanguage')
     self.assertEqual(mock_execute.call_count, 0)
     self.assertEqual(mock_set_list.call_count, 0)