Пример #1
0
    def test_labels_dont_wrap(self):
        # I would love to test whether the actual allocations are all the
        # same height; however, GTK+3.0 does not allow access to the
        # GtkIconViewItem GList.
        if 'UBIQUITY_TEST_INSTALLED' not in os.environ:
            real_method = open
            method = mock.patch('builtins.open')
            mocked_method = method.start()
            mocked_method.side_effect = side_effect_factory(real_method)
            self.addCleanup(method.stop)

        current_language, sorted_choices, language_display_map = \
            i18n.get_languages(0, False)
        w = Gtk.Window()
        # Roughly the size of plugin area.
        w.set_size_request(752, 442)
        w.add(self.gtk.page)
        w.show_all()
        self.gtk.set_language_choices(sorted_choices, language_display_map)
        width = self.gtk.iconview.get_item_width()
        longest_length = 0
        longest = ''
        for choice in sorted_choices:
            length = len(choice)
            if length > longest_length:
                longest_length = length
                longest = choice
        pad = self.gtk.iconview.get_property('item-padding')
        layout = self.gtk.iconview.create_pango_layout(longest)
        self.assertEqual(layout.get_pixel_size()[0] + pad * 2, width)
Пример #2
0
    def test_labels_dont_wrap(self):
        # I would love to test whether the actual allocations are all the
        # same height; however, GTK+3.0 does not allow access to the
        # GtkIconViewItem GList.
        if 'UBIQUITY_TEST_INSTALLED' not in os.environ:
            real_method = open
            method = mock.patch('builtins.open')
            mocked_method = method.start()
            mocked_method.side_effect = side_effect_factory(real_method)
            self.addCleanup(method.stop)

        current_language, sorted_choices, language_display_map = \
            i18n.get_languages(0, False)
        w = Gtk.Window()
        # Roughly the size of plugin area.
        w.set_size_request(752, 442)
        w.add(self.gtk.page)
        w.show_all()
        self.gtk.set_language_choices(sorted_choices, language_display_map)
        width = self.gtk.iconview.get_item_width()
        longest_length = 0
        longest = ''
        for choice in sorted_choices:
            length = len(choice)
            if length > longest_length:
                longest_length = length
                longest = choice
        pad = self.gtk.iconview.get_property('item-padding')
        layout = self.gtk.iconview.create_pango_layout(longest)
        self.assertEqual(layout.get_pixel_size()[0] + pad * 2, width)
Пример #3
0
    def run(self, priority, question):
        if question == 'localechooser/languagelist':
            self.language_question = question
            if self.initial_language is None:
                self.initial_language = self.db.get(question)
            current_language_index = self.value_index(question)
            only_installable = misc.create_bool(self.db.get('ubiquity/only-show-installable-languages'))

            current_language, sorted_choices, language_display_map = \
                i18n.get_languages(current_language_index, only_installable)

            self.ui.set_language_choices(sorted_choices,
                                         language_display_map)
            self.ui.set_language(current_language)
        return Plugin.run(self, priority, question)
Пример #4
0
    def run(self, priority, question):
        if question == "localechooser/languagelist":
            self.language_question = question
            if self.initial_language is None:
                self.initial_language = self.db.get(question)
            current_language_index = self.value_index(question)
            only_installable = misc.create_bool(self.db.get("ubiquity/only-show-installable-languages"))

            current_language, sorted_choices, language_display_map = i18n.get_languages(
                current_language_index, only_installable
            )

            self.ui.set_language_choices(sorted_choices, language_display_map)
            self.ui.set_language(current_language)
        return Plugin.run(self, priority, question)
Пример #5
0
    def run(self, priority, question):
        if question == 'localechooser/languagelist':
            self.language_question = question
            if self.initial_language is None:
                self.initial_language = self.db.get(question)
            #current_language_index = self.value_index(question)
            # edit by kobe
            current_language_index = 1
            only_installable = misc.create_bool(
                self.db.get('ubiquity/only-show-installable-languages'))

            current_language, sorted_choices, language_display_map = \
                i18n.get_languages(current_language_index, only_installable)

            self.ui.set_language_choices(sorted_choices,
                                         language_display_map)
            self.ui.set_language(current_language)
            if len(sorted_choices) == 1:
                self.done = True
                return True
        return plugin.Plugin.run(self, priority, question)