Esempio n. 1
0
    def __init__(self, plugin, mainbox, controllers):
        super(Toolbar, self).__init__()

        self.plugin = plugin
        self.mainbox = mainbox
        cl = CoverLocale()

        ui_file = rb.find_plugin_file(plugin, self.ui)

        # create the toolbar
        builder = Gtk.Builder()
        builder.set_translation_domain(cl.Locale.LOCALE_DOMAIN)
        print (ui_file)
        builder.add_from_file(ui_file)

        # assign the controllers to the buttons
        for button, controller in controllers.items():
            if button != 'search':
                builder.get_object(button).controller = controller

        if not webkit_support():
            # button = builder.get_object('flowview_button')
            #button.set_visible(False)
            separator = builder.get_object('properties_separator')
            if separator:
                separator.set_visible(False)

        # workaround to translate the search entry tooltips
        cl.switch_locale(cl.Locale.RB)
        search_entry = SearchEntry(has_popup=True)
        search_entry.show_all()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        # add it to the ui
        align = builder.get_object('entry_search_alignment')
        align.add(search_entry)

        # assign the controller
        search_entry.controller = controllers['search']

        Theme(self.plugin).connect('theme_changed', self._theme_changed,
                                   controllers)

        self.builder = builder.get_object('toolbar')

        # now theme the toolbar including child objects such as the button popups
        style_context = self.builder.get_style_context()
        style_context.add_class(Gtk.STYLE_CLASS_TOOLBAR)

        view_button = builder.get_object(ToolbarObject.VIEW)
        view_button.set_visible(not self.plugin.using_headerbar)
    def __init__(self, plugin, mainbox, controllers):
        super(Toolbar, self).__init__()

        self.plugin = plugin
        self.mainbox = mainbox
        cl = CoverLocale()

        ui_file = rb.find_plugin_file(plugin, self.ui)

        # create the toolbar
        builder = Gtk.Builder()
        builder.set_translation_domain(cl.Locale.LOCALE_DOMAIN)

        builder.add_from_file(ui_file)

        # assign the controllers to the buttons
        for button, controller in controllers.items():
            if button != 'search':
                builder.get_object(button).controller = controller

        if not webkit_support():
            button = builder.get_object('iconview_button')
            button.set_visible(False)
            button = builder.get_object('flowview_button')
            button.set_visible(False)
            separator = builder.get_object('properties_separator')
            if separator:
                separator.set_visible(False)

        # workaround to translate the search entry tooltips
        cl.switch_locale(cl.Locale.RB)
        search_entry = SearchEntry(has_popup=True)
        search_entry.show_all()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        # add it to the ui
        align = builder.get_object('entry_search_alignment')
        align.add(search_entry)

        # assign the controller
        search_entry.controller = controllers['search']

        Theme(self.plugin).connect('theme_changed', self._theme_changed,
            controllers)

        self.builder = builder.get_object('main_box')