def __append_directory(self, directory, parent_iter, system, menu_file): if not directory: return iter = self.iter_children(parent_iter) while iter is not None: if self.get_value(iter, self.COLUMN_ID) == directory.get_name(): break iter = self.iter_next(iter) if iter is None: icon = gio.ThemedIcon(str(directory.get_icon()), True) type = directory.get_type() row = (type == adapters.TYPE_ENTRY, type, directory.get_name(), directory.get_display_name(), icon, menu_file, False, False, directory) iter = self.append(parent_iter, row) if system: self.set_value(iter, self.COLUMN_SYSTEM_VISIBLE, True) else: self.set_value(iter, self.COLUMN_USER_VISIBLE, True) for entry in directory: current_type = entry.get_type() if current_type == adapters.TYPE_DIRECTORY: self.__append_directory(entry, iter, system, None) if current_type != adapters.TYPE_ENTRY: continue child_iter = self.iter_children(iter) while child_iter is not None: if self.get_value( child_iter, self.COLUMN_TYPE) == adapters.TYPE_ENTRY and ( self.get_value(child_iter, self.COLUMN_ID) == entry.get_filename()): break child_iter = self.iter_next(child_iter) if child_iter is None: icon = gio.ThemedIcon(str(entry.get_icon()), True) type = entry.get_type() row = (type == adapters.TYPE_ENTRY, type, entry.get_filename(), entry.get_display_name(), icon, None, False, False, entry) child_iter = self.append(iter, row) if system: self.set_value( child_iter, self.COLUMN_SYSTEM_VISIBLE, entry.is_visible(), ) else: self.set_value( child_iter, self.COLUMN_USER_VISIBLE, entry.is_visible(), )
def test_eq(self): self.assertEquals(gio.FileIcon(gio.File('foo.png')), gio.FileIcon(gio.File('foo.png'))) self.assertEquals(gio.ThemedIcon('foo'), gio.ThemedIcon('foo')) self.assertNotEqual(gio.FileIcon(gio.File('foo.png')), gio.FileIcon(gio.File('bar.png'))) self.assertNotEquals(gio.ThemedIcon('foo'), gio.ThemedIcon('bar')) self.assertNotEquals(gio.FileIcon(gio.File('foo.png')), gio.ThemedIcon('foo'))
def create(self, data): t = data['type'] parent_path = data['_parent'] parent_iter = self.get_iter_from_string(parent_path) parent_entry = self.get_value(parent_iter, self.COLUMN_OBJECT) if adapters.TYPE_ENTRY == t: entry = self.menu_editor.createMenuEntry( parent_entry and parent_entry.adaptee or None, data['name'], #genericname = data['name'], comment=data['comment'], command=data['command'], icon=data['icon'], terminal=data['terminal']) elif adapters.TYPE_DIRECTORY == t: entry = self.menu_editor.createMenu( parent_entry and parent_entry.adaptee or None, data['name'], #genericname = data['name'], comment=data['comment'], icon=data['icon'], ) obj = xdg_adapter.factory(entry) icon = gio.ThemedIcon(str(obj.get_icon()), True) #FIXME: this doesn't update the view ??? self.append(parent_iter, (t == adapters.TYPE_DIRECTORY, obj.get_type(), obj.get_display_name(), obj.get_display_name(), icon, None, True, True, obj))
def update(self, data): t = data['type'] # update menu if adapters.TYPE_ENTRY == t: self.menu_editor.editMenuEntry( data['object'].adaptee, name=data['name'], #genericname = data['name'], comment=data['comment'], command=data['command'], icon=data['icon'], terminal=data['terminal']) elif adapters.TYPE_DIRECTORY == t: self.menu_editor.editMenu( data['object'].adaptee, name=data['name'], #genericname = data['name'], comment=data['comment'], icon=data['icon'], ) # update treemodel it = self.get_iter_from_string(data['_path']) obj = self.get_value(it, self.COLUMN_OBJECT) icon = gio.ThemedIcon(str(obj.get_icon()), True) self.set(it, self.COLUMN_ID, obj.get_filename(), self.COLUMN_NAME, obj.get_display_name(), self.COLUMN_ICON, icon)
def test_constructor(self): have_use_default_fallbacks = ('use_default_fallbacks' in gio.ThemedIcon.props.__members__) icon = gio.ThemedIcon('foo') self.assertEquals(['foo'], icon.props.names) self.assert_(not have_use_default_fallbacks or not icon.props.use_default_fallbacks) icon = gio.ThemedIcon(['foo', 'bar', 'baz']) self.assertEquals(['foo', 'bar', 'baz'], icon.props.names) self.assert_(not have_use_default_fallbacks or not icon.props.use_default_fallbacks) icon = gio.ThemedIcon('xxx-yyy-zzz', True) self.assertEquals(['xxx-yyy-zzz', 'xxx-yyy', 'xxx'], icon.props.names) self.assert_(not have_use_default_fallbacks or icon.props.use_default_fallbacks)
def __init__(self, folder): ''' Constructor. GUI ''' self.folder = folder gtk.Window.__init__(self) self.set_modal(True) self.set_default_size(500,200) self.set_title('Share folder through NFS') mainVBox = gtk.VBox(False, 10) mainHBox = gtk.HBox(False, 10) self.fileLabel = gtk.Label('file') infoVBox = gtk.VBox(False, 10) infoVBox.pack_start(gtk.Label('Share this folder through NFS'), False, False, 10) infoVBox.pack_start(self.fileLabel, True, True, 10) image = gtk.image_new_from_gicon(gio.ThemedIcon('folder-remote'),gtk.ICON_SIZE_DIALOG) mainHBox.pack_start(image, False, False, 30) mainHBox.pack_start(infoVBox, True, True, 10) self.shareCheckBtn = gtk.CheckButton('Share this folder') self.writeCheckBtn = gtk.CheckButton('Allow other users to create, update and delete files') mainVBox.set_border_width(10) self.okBtn = gtk.Button('', gtk.STOCK_OK) self.cancelBtn = gtk.Button('', gtk.STOCK_CANCEL) btnBox = gtk.HButtonBox() btnBox.add(self.okBtn) btnBox.add(self.cancelBtn) btnBox.set_layout(gtk.BUTTONBOX_END) btnBox.set_spacing(10) mainVBox.pack_start(mainHBox, True, True) mainVBox.pack_start(self.shareCheckBtn, False, False) mainVBox.pack_start(self.writeCheckBtn, False, False) mainVBox.pack_start(gtk.HSeparator(), False, False) mainVBox.pack_start(btnBox, False, False) self.shareCheckBtn.connect('toggled', self.on_shareCheckBtn_toggled) self.writeCheckBtn.connect('toggled', self.on_writeCheckBtn_toggled) self.okBtn.connect('clicked', self.on_okBtn_clicked) self.cancelBtn.connect('clicked', self.on_cancelBtn_clicked) self.connect('destroy', self.on_cancelBtn_clicked) self.add(mainVBox) self.es = ExportsSharing(self.folder) self.shareCheckBtn.set_active(self.es.isShared()) self.writeCheckBtn.set_active(self.es.isWritable()) self.fileLabel.set_label(self.folder) self.on_cb_toggled()
def test_constructor_illegals(self): self.assertRaises(TypeError, lambda: gio.ThemedIcon(42)) self.assertRaises(TypeError, lambda: gio.ThemedIcon(['foo', 42, 'bar']))
def setUp(self): self.icon = gio.ThemedIcon("open")
def test_hash(self): self.assertEquals(hash(gio.FileIcon(gio.File('foo.png'))), hash(gio.FileIcon(gio.File('foo.png')))) self.assertEquals(hash(gio.ThemedIcon('foo')), hash(gio.ThemedIcon('foo')))