Python gi.repository.Gtk 模块,SearchEntry() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用gi.repository.Gtk.SearchEntry()

项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_search_entry_grab_focus( # pylint: disable=no-self-use
            self, search_entry):
        '''
        Signal handler called when the search entry grabs focus

        :param search_entry: The search entry
        :type search_entry: Gtk.SearchEntry object
        '''
        if _ARGS.debug:
            sys.stdout.write(
                'on_search_entry_grab_focus() search_entry = %s\n'
                %repr(search_entry))
        search_entry.grab_focus_without_selecting()
        # The default signal handler would again select the contents
        # of the search entry. Therefore, we must prevent the default
        # signal handler from running:
        GObject.signal_stop_emission_by_name(search_entry, 'grab-focus')
        return True
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self, window, search_button, *args):
        self.search_entry = Gtk.SearchEntry()
        self.search_list = args[0]
        self.search_button = search_button
        self.window = window
        self.generate()
        self.search_button.connect("toggled", self.toggle)
        self.window.connect("key-press-event", self.__on_key_press)
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_search_entry_search_changed(self, search_entry):
        '''
        Signal handler for changed text in the search entry

        :param widget: The search entry
        :type widget: Gtk.SearchEntry object
        '''
        query_string = search_entry.get_text()
        if _ARGS.debug:
            sys.stdout.write(
                'on_search_entry_search_changed() query_string = %s\n'
                %query_string)
        if not self._search_bar.get_search_mode():
            # If the text in the search entry changes while
            # the search bar is invisible, ignore it.
            return
        self._query_string = query_string
        if self._candidates_invalid:
            if _ARGS.debug:
                sys.stdout.write(
                    'on_search_entry_search_changed() '
                    + 'self._candidates_invalid = %s\n'
                    %self._candidates_invalid)
            return
        self._candidates_invalid = True
        self._clear_flowbox()
        self._busy_start()
        GLib.idle_add(self._fill_flowbox_with_search_results)
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_font_search_entry_search_changed(self, search_entry):
        '''
        Signal handler for changed text in the font search entry

        :param widget: The search entry
        :type widget: Gtk.SearchEntry object
        '''
        filter_text = search_entry.get_text()
        if _ARGS.debug:
            sys.stdout.write(
                'on_font_search_entry_search_changed() filter_text = %s\n'
                %filter_text)
        self._fill_listbox_font(filter_text)
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_font_button_clicked(self, dummy_button):
        '''
        The font button in the header bar has been clicked

        :param dummy_button: The font button
        :type dummy_button: Gtk.Button object
        '''
        if _ARGS.debug:
            sys.stdout.write(
                'on_font_button_clicked()\n')
        self._font_popover = Gtk.Popover()
        self._font_popover.set_relative_to(self._font_button)
        self._font_popover.set_position(Gtk.PositionType.BOTTOM)
        self._font_popover.set_vexpand(True)
        font_popover_vbox = Gtk.VBox()
        margin = 12
        font_popover_vbox.set_margin_start(margin)
        font_popover_vbox.set_margin_end(margin)
        font_popover_vbox.set_margin_top(margin)
        font_popover_vbox.set_margin_bottom(margin)
        font_popover_vbox.set_spacing(margin)
        font_popover_label = Gtk.Label()
        font_popover_label.set_text(_('Set Font'))
        font_popover_label.set_visible(True)
        font_popover_label.set_halign(Gtk.Align.FILL)
        font_popover_vbox.pack_start(
            font_popover_label, False, False, 0)
        font_popover_search_entry = Gtk.SearchEntry()
        font_popover_search_entry.set_can_focus(True)
        font_popover_search_entry.set_visible(True)
        font_popover_search_entry.set_halign(Gtk.Align.FILL)
        font_popover_search_entry.set_hexpand(False)
        font_popover_search_entry.set_vexpand(False)
        font_popover_search_entry.connect(
            'search_changed', self.on_font_search_entry_search_changed)
        font_popover_vbox.pack_start(
            font_popover_search_entry, False, False, 0)
        self._font_popover_scroll = Gtk.ScrolledWindow()
        self._fill_listbox_font('')
        font_popover_vbox.pack_start(
            self._font_popover_scroll, True, True, 0)
        self._font_popover.add(font_popover_vbox)
        if GTK_VERSION >= (3, 22, 0):
            self._font_popover.popup()
        self._font_popover.show_all()
项目:nautilus-folder-icons    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def _build_content(self):
        """"Setup window content widges."""
        container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        # Search bar
        self._search_bar = Gtk.SearchBar()
        self._search_bar.set_show_close_button(True)

        self._search_btn.bind_property("active",
                                       self._search_bar,
                                       "search-mode-enabled",
                                       1)

        self._search_entry = Gtk.SearchEntry()
        self._search_entry.set_width_chars(60)
        self._search_entry.connect("search-changed", self._on_search)
        self._search_bar.add(self._search_entry)
        self._search_bar.connect_entry(self._search_entry)

        container.pack_start(self._search_bar, False, False, 0)

        # Preview image
        self._preview = Image()
        self._default_icon = get_default_icon(self._folders[0])
        self._preview.set_icon(self._default_icon)

        scrolled = Gtk.ScrolledWindow()
        scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)

        self._flowbox.connect("child-activated", self._do_select)
        self._flowbox.connect("selected-children-changed",
                              self._on_update_preview)
        self._flowbox.set_valign(Gtk.Align.START)
        self._flowbox.set_row_spacing(0)
        self._flowbox.set_activate_on_single_click(False)
        self._flowbox.set_min_children_per_line(4)
        self._flowbox.set_max_children_per_line(12)
        self._flowbox.set_selection_mode(Gtk.SelectionMode.SINGLE)

        scrolled.add(self._flowbox)

        container.pack_start(self._preview, False, False, 0)
        container.pack_start(scrolled, True, True, 0)

        self.add(container)