示例#1
0
文件: comboentry.py 项目: fuinha/kiwi
    def __init__(self, entry=None):
        """
        Create a new ComboEntry object.
        :param entry: a gtk.Entry subclass to use
        """
        gtk.VBox.__init__(self)
        self._popping_down = False

        if not entry:
            entry = KiwiEntry()

        if isinstance(entry, KiwiEntry):
            entry.set_normal_completion()

        self.hbox = gtk.HBox()
        self.pack_start(gtk.EventBox())
        self.pack_start(self.hbox, expand=False)
        self.pack_start(gtk.EventBox())

        self.mode = ComboMode.UNKNOWN
        self.entry = entry
        self.entry.connect('activate',
                           self._on_entry__activate)
        self.entry.connect('changed',
                           self._on_entry__changed)
        self.entry.connect('scroll-event',
                           self._on_entry__scroll_event)
        self.entry.connect('key-press-event',
                           self._on_entry__key_press_event)
        self.entry.connect('focus-out-event',
                           self._on_entry__focus_out_event)

        self.hbox.pack_start(self.entry, True, True)
        self.hbox.show_all()

        self._button = gtk.ToggleButton()
        self._button.connect('scroll-event', self._on_entry__scroll_event)
        self._button.connect('toggled', self._on_button__toggled)
        self._button.set_focus_on_click(False)
        self.hbox.pack_end(self._button, False, False)
        self._button.show()

        arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_NONE)
        self._button.add(arrow)
        arrow.show()

        self._popup = _ComboEntryPopup(self)
        self._popup.connect('text-selected', self._on_popup__text_selected)
        self._popup.connect('hide', self._on_popup__hide)
        self._popup.set_size_request(-1, 24)

        completion = KiwiEntryCompletion()
        completion.set_popup_window(self._popup)
        completion.set_treeview(self._popup._treeview)
        self.entry.set_completion(completion)
        self.set_model(completion.get_model())
示例#2
0
    def __init__(self, entry=None):
        """
        Create a new ComboEntry object.
        :param entry: a gtk.Entry subclass to use
        """
        gtk.VBox.__init__(self)
        self._popping_down = False

        if not entry:
            entry = KiwiEntry()

        if isinstance(entry, KiwiEntry):
            entry.set_normal_completion()

        self.hbox = gtk.HBox()
        self.pack_start(gtk.EventBox())
        self.pack_start(self.hbox, expand=False)
        self.pack_start(gtk.EventBox())

        self.mode = ComboMode.UNKNOWN
        self.entry = entry
        self.entry.connect('activate', self._on_entry__activate)
        self.entry.connect('changed', self._on_entry__changed)
        self.entry.connect('scroll-event', self._on_entry__scroll_event)
        self.entry.connect('key-press-event', self._on_entry__key_press_event)
        self.entry.connect('focus-out-event', self._on_entry__focus_out_event)

        self.hbox.pack_start(self.entry, True, True)
        self.hbox.show_all()

        self._button = gtk.ToggleButton()
        self._button.connect('scroll-event', self._on_entry__scroll_event)
        self._button.connect('toggled', self._on_button__toggled)
        self._button.set_focus_on_click(False)
        self.hbox.pack_end(self._button, False, False)
        self._button.show()

        arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_NONE)
        self._button.add(arrow)
        arrow.show()

        self._popup = _ComboEntryPopup(self)
        self._popup.connect('text-selected', self._on_popup__text_selected)
        self._popup.connect('hide', self._on_popup__hide)
        self._popup.set_size_request(-1, 24)

        completion = KiwiEntryCompletion()
        completion.set_popup_window(self._popup)
        completion.set_treeview(self._popup._treeview)
        self.entry.set_completion(completion)
        self.set_model(completion.get_model())
示例#3
0
    def __init__(self, entry=None):
        """
        Create a new ComboEntry object.
        :param entry: a Gtk.Entry subclass to use
        """
        super(ComboEntry, self).__init__(orientation=Gtk.Orientation.VERTICAL)
        self._popping_down = False

        # This will force both the entry and the button have the same height
        self._sizegroup = Gtk.SizeGroup.new(Gtk.SizeGroupMode.VERTICAL)

        if not entry:
            entry = KiwiEntry()
        self._sizegroup.add_widget(entry)

        if isinstance(entry, KiwiEntry):
            entry.set_normal_completion()

        self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.hbox.set_valign(Gtk.Align.CENTER)
        self.hbox.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED)

        # FIXME: Why are those EventBox here?
        self.pack_start(Gtk.EventBox(), True, True, 0)
        self.pack_start(self.hbox, True, True, 0)
        self.pack_start(Gtk.EventBox(), True, True, 0)

        self.mode = ComboMode.UNKNOWN
        self.entry = entry
        self.entry.connect('activate',
                           self._on_entry__activate)
        self.entry.connect('changed',
                           self._on_entry__changed)
        self.entry.connect('scroll-event',
                           self._on_entry__scroll_event)
        self.entry.connect('key-press-event',
                           self._on_entry__key_press_event)
        self.entry.connect('focus-out-event',
                           self._on_entry__focus_out_event)

        self.hbox.pack_start(self.entry, True, True, 0)
        self.hbox.show_all()

        self._button = Gtk.ToggleButton()
        self._button.set_vexpand_set(True)
        self._button.set_vexpand(False)
        self._button.connect('scroll-event', self._on_entry__scroll_event)
        self._button.connect('toggled', self._on_button__toggled)
        self._button.set_focus_on_click(False)
        self.hbox.pack_end(self._button, False, False, 0)
        self._button.show()
        self._sizegroup.add_widget(self._button)

        arrow = Gtk.Arrow(arrow_type=Gtk.ArrowType.DOWN, shadow_type=Gtk.ShadowType.NONE)
        self._button.add(arrow)
        arrow.show()

        self._popup = _ComboEntryPopup(self)
        self._popup.connect('text-selected', self._on_popup__text_selected)
        self._popup.connect('hide', self._on_popup__hide)
        self._popup.set_size_request(-1, 24)

        completion = KiwiEntryCompletion()
        completion.set_popup_window(self._popup)
        completion.set_treeview(self._popup._treeview)
        self.entry.set_completion(completion)
        self.set_model(completion.get_model())
示例#4
0
    def __init__(self, entry=None):
        """
        Create a new ComboEntry object.
        :param entry: a Gtk.Entry subclass to use
        """
        super(ComboEntry, self).__init__(orientation=Gtk.Orientation.VERTICAL)
        self._popping_down = False

        # This will force both the entry and the button have the same height
        self._sizegroup = Gtk.SizeGroup.new(Gtk.SizeGroupMode.VERTICAL)

        if not entry:
            entry = KiwiEntry()
        self._sizegroup.add_widget(entry)

        if isinstance(entry, KiwiEntry):
            entry.set_normal_completion()

        self.hbox = Gtk.HBox()
        self.hbox.set_valign(Gtk.Align.CENTER)

        # FIXME: Why are those EventBox here?
        self.pack_start(Gtk.EventBox(), True, True, 0)
        self.pack_start(self.hbox, True, True, 0)
        self.pack_start(Gtk.EventBox(), True, True, 0)

        self.mode = ComboMode.UNKNOWN
        self.entry = entry
        self.entry.connect('activate', self._on_entry__activate)
        self.entry.connect('changed', self._on_entry__changed)
        self.entry.connect('scroll-event', self._on_entry__scroll_event)
        self.entry.connect('key-press-event', self._on_entry__key_press_event)
        self.entry.connect('focus-out-event', self._on_entry__focus_out_event)

        self.hbox.pack_start(self.entry, True, True, 0)
        self.hbox.show_all()

        self._button = Gtk.ToggleButton()
        self._button.set_vexpand_set(True)
        self._button.set_vexpand(False)
        self._button.connect('scroll-event', self._on_entry__scroll_event)
        self._button.connect('toggled', self._on_button__toggled)
        self._button.set_focus_on_click(False)
        self.hbox.pack_end(self._button, False, False, 0)
        self._button.show()
        self._sizegroup.add_widget(self._button)

        arrow = Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.NONE)
        self._button.add(arrow)
        arrow.show()

        self._popup = _ComboEntryPopup(self)
        self._popup.connect('text-selected', self._on_popup__text_selected)
        self._popup.connect('hide', self._on_popup__hide)
        self._popup.set_size_request(-1, 24)

        completion = KiwiEntryCompletion()
        completion.set_popup_window(self._popup)
        completion.set_treeview(self._popup._treeview)
        self.entry.set_completion(completion)
        self.set_model(completion.get_model())