def test_main(self): TreeViewColumn(title="foo") area = Gtk.CellAreaBox() tvc = TreeViewColumn(cell_area=area) self.assertEqual(tvc.get_area(), area)
def apply_model(self, destination_object, vm_list, selection_trigger=None, activation_trigger=None): if isinstance(destination_object, Gtk.ComboBox): list_store = Gtk.ListStore(int, str, GdkPixbuf.Pixbuf, str) for entry_no, display_name in zip(itertools.count(), sorted(self._entries)): entry = self._entries[display_name] if entry['api_name'] in vm_list: list_store.append([ entry_no, display_name, entry['icon'], entry['api_name'], ]) destination_object.set_model(list_store) destination_object.set_id_column(1) icon_column = Gtk.CellRendererPixbuf() destination_object.pack_start(icon_column, False) destination_object.add_attribute(icon_column, "pixbuf", 2) destination_object.set_entry_text_column(1) if destination_object.get_has_entry(): entry_box = destination_object.get_child() area = Gtk.CellAreaBox() area.pack_start(icon_column, False, False, False) area.add_attribute(icon_column, "pixbuf", 2) completion = Gtk.EntryCompletion.new_with_area(area) completion.set_inline_selection(True) completion.set_inline_completion(True) completion.set_popup_completion(True) completion.set_popup_single_match(False) completion.set_model(list_store) completion.set_text_column(1) entry_box.set_completion(completion) if activation_trigger: entry_box.connect("activate", lambda entry: self._entry_activate( activation_trigger, destination_object, entry, vm_list)) # A Combo with an entry has a text column already text_column = destination_object.get_cells()[0] destination_object.reorder(text_column, 1) else: entry_box = None text_column = Gtk.CellRendererText() destination_object.pack_start(text_column, False) destination_object.add_attribute(text_column, "text", 1) changed_function = lambda combo: self._combo_change( selection_trigger, combo, entry_box, vm_list) destination_object.connect("changed", changed_function) changed_function(destination_object) else: raise TypeError( "Only expecting Gtk.ComboBox objects to want our model.")
def apply_model(self, destination_object, vm_filter_list=None, selection_trigger=None, activation_trigger=None): if isinstance(destination_object, Gtk.ComboBox): list_store = Gtk.ListStore(int, str, GdkPixbuf.Pixbuf) exclusions = [] for vm_name in sorted(self._entries.iterkeys()): entry = self._entries[vm_name] matches = True if vm_filter_list: for vm_filter in vm_filter_list: if not vm_filter.matches(entry['vm']): matches = False break if matches: list_store.append([entry['qid'], vm_name, entry['icon']]) else: exclusions += [vm_name] destination_object.set_model(list_store) destination_object.set_id_column(1) icon_column = Gtk.CellRendererPixbuf() destination_object.pack_start(icon_column, False) destination_object.add_attribute(icon_column, "pixbuf", 2) destination_object.set_entry_text_column(1) if destination_object.get_has_entry(): entry_box = destination_object.get_child() area = Gtk.CellAreaBox() area.pack_start(icon_column, False, False, False) area.add_attribute(icon_column, "pixbuf", 2) completion = Gtk.EntryCompletion.new_with_area(area) completion.set_inline_selection(True) completion.set_inline_completion(True) completion.set_popup_completion(True) completion.set_popup_single_match(False) completion.set_model(list_store) completion.set_text_column(1) entry_box.set_completion(completion) if activation_trigger: entry_box.connect( "activate", lambda entry: self._entry_activate( activation_trigger, destination_object, entry, exclusions)) # A Combo with an entry has a text column already text_column = destination_object.get_cells()[0] destination_object.reorder(text_column, 1) else: entry_box = None text_column = Gtk.CellRendererText() destination_object.pack_start(text_column, False) destination_object.add_attribute(text_column, "text", 1) changed_function = lambda combo: self._combo_change( selection_trigger, combo, entry_box, exclusions) destination_object.connect("changed", changed_function) changed_function(destination_object) else: raise TypeError( "Only expecting Gtk.ComboBox objects to want our model.")