def __create_columns(self): col = gtk.TreeViewColumn(_('Audits')) col.set_expand(True) col.set_resizable(True) col.set_resizable(True) col.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY) rend = gtk.CellRendererPixbuf() col.pack_start(rend, False) col.set_cell_data_func(rend, self.__pix_data_func) rend = gtk.CellRendererText() col.pack_start(rend) col.set_cell_data_func(rend, self.__text_data_func) self.tree.append_column(col) rend = gtk.CellRendererProgress() col = gtk.TreeViewColumn(_('Status'), rend) col.set_expand(False) col.set_resizable(True) col.set_fixed_width(150) col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) col.set_cell_data_func(rend, self.__progress_data_func) self.tree.append_column(col) self.tree.set_rules_hint(True) self.icon_operation = get_pixbuf('operation_small')
def add_progress_column(self, header, col_types=[float, str], sortid=0, hidden=False, position=None, status_field=None, function=None, column_type="progress", sort_func=None, default=True): """Add a progress column to the listview.""" render = gtk.CellRendererProgress() self.add_column(header, render, col_types, hidden, position, status_field, sortid, function=function, column_type=column_type, value=0, text=1, sort_func=sort_func, default=default) return True
def __init__(self, device_engine, transfer_treeview, notebook, disk_usage_progress_bar): self.__queue = Queue() self.__device_engine = device_engine self.__model = TransfertQueueModel() process_queue_thread = ProcessQueueThread(device_engine, self, self.__queue, self.__model) process_queue_thread.add_observer(self.__observe_queue_thread) process_queue_thread.setDaemon(True) process_queue_thread.start() self.__transfer_treeview = transfer_treeview self.__notebook = notebook self.__disk_usage_progress_bar = disk_usage_progress_bar t=TransfertQueueModel if False: col = gtk.TreeViewColumn("object_id", gtk.CellRendererText(), text=t.COL_JOB_ID) transfer_treeview.append_column(col) col = gtk.TreeViewColumn("action", gtk.CellRendererText(), text=t.COL_ACTION) transfer_treeview.append_column(col) col = gtk.TreeViewColumn("description", gtk.CellRendererText(), text=t.COL_DESCRIPTION) transfer_treeview.append_column(col) col = gtk.TreeViewColumn("progress", gtk.CellRendererProgress(), value=t.COL_PROGRESS, text=t.COL_STATUS) transfer_treeview.append_column(col) transfer_treeview.set_model(self.__model) transfer_treeview.get_selection().set_mode( gtk.SELECTION_MULTIPLE)
def __init__(self): self.__gobject_init__() self.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE) self.statuses = { DownloadStatus.RUNNING: gtk.gdk.pixbuf_new_from_file( path.getdatapath('media', 'download_start.png')), DownloadStatus.STOPPED: gtk.gdk.pixbuf_new_from_file( path.getdatapath('media', 'download_stop.png')), DownloadStatus.ERROR: gtk.gdk.pixbuf_new_from_file(path.getdatapath( 'media', 'error.png')), DownloadStatus.FINISHED: gtk.gdk.pixbuf_new_from_file( path.getdatapath('media', 'finished.png')), DownloadStatus.SEEDING: gtk.gdk.pixbuf_new_from_file( path.getdatapath('media', 'finished.png')) } self.types = { DownloadTypes.TORRENT: 'Torrent-Download', DownloadTypes.BASIC: 'Normaler Download', DownloadTypes.OTR_DECODE: 'OTR-Download mit Dekodieren', DownloadTypes.OTR_CUT: 'OTR-Download mit Schneiden' } self.cellrenderer_pixbuf = gtk.CellRendererPixbuf() self.cellrenderer_filename = gtk.CellRendererText() self.cellrenderer_info = gtk.CellRendererText() self.cellrenderer_progress = gtk.CellRendererProgress()
def create_columns(self, col_list): """ Crea las columnas de la lista TODO: Guardar el tamanio de la columna nombre en el config.ini al resizear. """ id_col = 0 for item in col_list: #id_col = col_list.index(item) if item not in ( _("Status"), _("Progress"), _("Host")): #si no es la barra de progreso ni el estado rendererText = gtk.CellRendererText( ) #pide el primer item que ira en la columna (text=0) o segundo, etc... rendererText.set_property("ellipsize", 3) #2= middle, 3 = right, 1 = left column = gtk.TreeViewColumn(item, rendererText, text=id_col) column.set_resizable(True) column.set_expand(True) column.set_min_width(1) if item == "hidden_id_item": #no mostrar columna de id_item column.set_visible(False) column.set_resizable(False) elif item == _("File Name"): rendererText.set_property("ellipsize", 2) rendererText.set_fixed_size(150, -1) #elif item == _("Status Message"): #column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) #column.set_min_width(110) #dont let expand like crazy... elif item == _("Status"): renderPixbuf = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn(None, renderPixbuf) #name = None column.add_attribute(renderPixbuf, 'pixbuf', id_col) column.set_expand(False) column.set_min_width(21) elif item == _("Host"): renderPixbuf = gtk.CellRendererPixbuf() renderPixbuf_2 = gtk.CellRendererPixbuf() renderPixbuf_3 = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn(item) #name = None column.pack_start(renderPixbuf, False) column.pack_start(renderPixbuf_2, False) column.pack_start(renderPixbuf_3, False) column.add_attribute(renderPixbuf, 'pixbuf', id_col) id_col += 1 column.add_attribute(renderPixbuf_2, 'pixbuf', id_col) id_col += 1 column.add_attribute(renderPixbuf_3, 'pixbuf', id_col) column.set_expand(True) column.set_min_width(1) else: #barra de progreso. rendererProgress = gtk.CellRendererProgress() column = gtk.TreeViewColumn(item, rendererProgress) column.add_attribute(rendererProgress, 'value', id_col) #aniadir variable a la barra. column.set_expand(True) column.set_min_width(1) #column.set_sort_column_id(id_col) #ordenar columna #column.set_spacing(25) self.treeView.append_column(column) id_col += 1
def __init__(self): self.glade = gtk.glade.XML(get_resource("torrent_view.glade")) self.window = self.glade.get_widget("torrent_view_window") self.torrentview = self.glade.get_widget("torrent_view") self.glade.signal_autoconnect(self) self.store = gtk.ListStore(int, str, int, str) self.torrentview.set_model(self.store) # Set up columns renderer = gtk.CellRendererText() task_col = gtk.TreeViewColumn('Task', renderer) task_col.add_attribute(renderer, "text", 0) task_col.set_visible(False) self.torrentview.append_column(task_col) name_col = gtk.TreeViewColumn('Name', renderer) name_col.add_attribute(renderer, "text", 1) self.torrentview.append_column(name_col) p_renderer = gtk.CellRendererProgress() progress_col = gtk.TreeViewColumn('Progress', p_renderer) progress_col.add_attribute(p_renderer, "value", 2) self.torrentview.append_column(progress_col) dest_col = gtk.TreeViewColumn('Destination', renderer) dest_col.add_attribute(renderer, "text", 3) self.torrentview.append_column(dest_col)
def __init__(self, downloader): gtk.Window.__init__(self) self.downloader = downloader self.connect('destroy', gtk.main_quit) self.set_title('memusic') self.set_default_size(600, 440) self.set_border_width(5) self.layout = gtk.Table(2, 1, False) self.layout.set_row_spacings(5) self.layout.set_border_width(5) self.add(self.layout) self.notebook = gtk.Notebook() self.layout.attach(self.notebook, 0, 1, 0, 1) self.dl_window = gtk.ScrolledWindow() self.dl_list = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_INT) self.dl_view = gtk.TreeView(self.dl_list) self.dl_col_no = gtk.TreeViewColumn('No', gtk.CellRendererText(), text=0) self.dl_col_no.set_resizable(True) self.dl_view.append_column(self.dl_col_no) #self.dl_col_no.add_attribute(self.dl_col_no_renderer,'text',0) self.dl_col_title = gtk.TreeViewColumn('Title', gtk.CellRendererText(), text=1) self.dl_col_title.set_resizable(True) self.dl_view.append_column(self.dl_col_title) self.dl_col_progress = gtk.TreeViewColumn('Progress', gtk.CellRendererProgress(), value=2) self.dl_view.append_column(self.dl_col_progress) self.dl_window.add(self.dl_view) self.notebook.append_page(self.dl_window, gtk.Label('Downloads')) self.emx_window = gtk.ScrolledWindow() self.emx_view = gtk.TextView() self.emx_window.add(self.emx_view) self.emx_view.set_editable(False) self.emx_view.get_buffer().set_text(self.downloader.read_emx()) self.notebook.append_page(self.emx_window, gtk.Label('EMX file')) self.bclose = gtk.Button() self.bclose_label = gtk.Label('Close') self.bclose_label.set_padding(10, 5) self.bclose.add(self.bclose_label) self.bclose.set_sensitive(False) self.bclose_layout = gtk.HBox() self.layout.attach(self.bclose_layout, 0, 1, 1, 2, yoptions=gtk.SHRINK) self.bclose_layout.pack_end(self.bclose, False, False) self.bclose.connect_object('clicked', gtk.Widget.destroy, self) for t in self.downloader.tracks: self.dl_list.append((t.num, t.title, 0)) self.show_all() self.dl_thread = threading.Thread(target=self.download)
def __init__(self, field_name, treeview=None, attrs=None, window=None): self.field_name = field_name self.attrs = attrs or {} self.renderer = gtk.CellRendererProgress() self.treeview = treeview if not window: window = service.LocalService('gui.main').window self.window = window
def plugin_album(self, songs): win = gtk.Dialog(title='ReplayGain', buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) win.set_default_size(400, 300) win.set_border_width(6) swin = gtk.ScrolledWindow() win.vbox.pack_start(swin) swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) swin.set_shadow_type(gtk.SHADOW_IN) from qltk.views import HintedTreeView model = gtk.ListStore(object, str, int, str, str) view = HintedTreeView(model) swin.add(view) # Create a view of title/progress/gain/peak for each track + album col = gtk.TreeViewColumn('Track', gobject.new(gtk.CellRendererText, ellipsize=pango.ELLIPSIZE_END), text=1) col.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) col.set_expand(True) col.set_fixed_width(120) view.append_column(col) col = gtk.TreeViewColumn('Progress', gtk.CellRendererProgress(), value=2) col.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) view.append_column(col) col = gtk.TreeViewColumn('Gain', gtk.CellRendererText(), text=3) col.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) view.append_column(col) col = gtk.TreeViewColumn('Peak', gtk.CellRendererText(), text=4) col.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) view.append_column(col) for s in songs: model.append([s, s('~tracknumber~title~version'), 0, "-", "-"]) model.append([None, "Full Album", 0, "-", "-"]) win.vbox.show_all() win.present() win.finished = False # kick off the analysis analysis = Analysis(win, view, model) analysis.next_song() # wait for the dialog to be closed while not win.finished: gtk.main_iteration() win.hide() win.destroy()
def __init__(self, view, attrs): super(ProgressBar, self).__init__() self.view = view self.attrs = attrs self.renderer = gtk.CellRendererProgress() orientation = self.orientations.get( self.attrs.get('orientation', 'left_to_right'), gtk.PROGRESS_LEFT_TO_RIGHT) self.renderer.set_property('orientation', orientation)
def _make_view(self, model, title, showProgress, vbox): view = gtk.TreeView(model) view.append_column( gtk.TreeViewColumn(title, gtk.CellRendererText(), text=0)) if showProgress: view.append_column( gtk.TreeViewColumn("Progress", gtk.CellRendererProgress(), value=1)) vbox.pack_start(view)
def _init_tree_view(self): tree_view = self._get_tree_view() column = gtk.TreeViewColumn(_("Description"), gtk.CellRendererText(), text=1) column.set_resizable(True) tree_view.append_column(column) tree_view.append_column(gtk.TreeViewColumn(_("Usage"), gtk.CellRendererProgress(), value=2, text=3)) tree_view.append_column(gtk.TreeViewColumn(_("Active"), gtk.CellRendererToggle(), active=4)) # add filler column tree_view.append_column(gtk.TreeViewColumn()) tree_view.set_model(self._equipment_store)
def __init__(self, field_name, model_name, treeview, attrs=None): super(ProgressBar, self).__init__() self.field_name = field_name self.model_name = model_name self.attrs = attrs or {} self.renderer = gtk.CellRendererProgress() orientation = self.orientations.get(self.attrs.get('orientation', 'left_to_right'), gtk.PROGRESS_LEFT_TO_RIGHT) self.renderer.set_property('orientation', orientation) self.treeview = treeview
def __init__(self, mainw): _ = LLocale()._ self.mainWindow = mainw SecondaryWindow.__init__(self, _("Edenget - Download Queue")) self.window.set_default_size(400, 500) self.window.set_modal(False) mainBox = gtk.VBox() self.window.add(mainBox) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) mainBox.pack_start(sw, True, True, 0) self.tasksList = gtk.ListStore(int, str, int) self.tasksListView = gtk.TreeView(self.tasksList) self.tasksListView.get_selection().set_mode(gtk.SELECTION_MULTIPLE) rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("", rendererText, text=0) column.set_sort_column_id(0) self.tasksListView.append_column(column) rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn(_("File"), rendererText, text=1) column.set_sort_column_id(1) self.tasksListView.append_column(column) column = gtk.TreeViewColumn(_("Progress"), gtk.CellRendererProgress(), value=2) column.set_sort_column_id(2) self.tasksListView.append_column(column) selection = self.tasksListView.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) selection.connect("changed", self.onSelectedTasks) sw.add(self.tasksListView) # Toolbar toolbar = gtk.Toolbar() toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ) #iconw = gtk.Image() #iconw.set_from_stock(gtk.STOCK_DELETE, gtk.ICON_SIZE_LARGE_TOOLBAR) #toolbar.append_item(_("Delete"), "", "Private", iconw, self.onDeleteTask) iconw = gtk.Image() iconw.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_LARGE_TOOLBAR) toolbar.append_item(_("Close"), "", "Private", iconw, lambda w: self.changeVisibility()) mainBox.pack_start(toolbar, False, False, 0)
def __init__(self): vw_views.VTreeView.__init__(self) # Hook all the GUI callbacks in the server. #FIXME make this a callback object in the server self.id_iter = {} # Setup a progress bar renderer self.treeview.remove_column(self.treeview.get_column(3)) col = vw_util.makeColumn("Percent", 3, cell=gtk.CellRendererProgress(), links={"value": 3}) self.treeview.append_column(col)
def InitialiseColumns(treeview, *args): i = 0 cols = [] for c in args: if c[2] == "text": renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(c[0], renderer, text=i) elif c[2] == "colored": renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(c[0], renderer, text=i, foreground=c[3][0], background=c[3][1]) elif c[2] == "edit": renderer = gtk.CellRendererText() renderer.set_property('editable', True) column = gtk.TreeViewColumn(c[0], renderer, text=i) elif c[2] == "combo": renderer = gtk.CellRendererCombo() renderer.set_property('text-column', 0) renderer.set_property('editable', True) column = gtk.TreeViewColumn(c[0], renderer, text=i) elif c[2] == "progress": renderer = gtk.CellRendererProgress() column = gtk.TreeViewColumn(c[0], renderer, value=i) elif c[2] == "toggle": renderer = gtk.CellRendererToggle() column = gtk.TreeViewColumn(c[0], renderer, active=i) else: renderer = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn(c[0], renderer, pixbuf=0) if c[1] == -1: column.set_resizable(False) column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) else: column.set_resizable(True) if c[1] == 0: column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY) else: column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) column.set_fixed_width(c[1]) column.set_min_width(0) if len(c) > 3 and type(c[3]) is not list: column.set_cell_data_func(renderer, c[3]) column.set_reorderable(True) column.set_widget(gtk.Label(c[0])) column.get_widget().show() treeview.append_column(column) cols.append(column) i += 1 return cols
def treeview_widgets(self): self.sort_col_num = 0 self.ttreestore = gtk.TreeStore( str, str, str, str, str, str, str, str, str, str, str, gtk.gdk.Pixbuf, int) self.ttreeview = gtk.TreeView() self.ttreeview.set_rules_hint(True) # TODO - REMOVE FILTER HERE? self.tmodelfilter = self.ttreestore.filter_new() self.tmodelsort = gtk.TreeModelSort(self.tmodelfilter) self.ttreeview.set_model(self.tmodelsort) # multiple selection ts = self.ttreeview.get_selection() self.ttreeview.set_rubber_banding(True) if ts: ts.set_mode(gtk.SELECTION_MULTIPLE) self.ttreeview.connect( 'button_press_event', self.on_treeview_button_pressed) for n in range(1, len(ControlTree.headings)): # Skip first column (cycle point) tvc = gtk.TreeViewColumn(ControlTree.headings[n]) if n == 1: crp = gtk.CellRendererPixbuf() tvc.pack_start(crp, False) tvc.set_attributes(crp, pixbuf=11) if n == 8: # Pack in progress and text cell renderers. prog_cr = gtk.CellRendererProgress() tvc.pack_start(prog_cr, True) tvc.set_cell_data_func(prog_cr, self._set_cell_text_time, n) cr = gtk.CellRendererText() tvc.pack_start(cr, True) if n == 6 or n == 7 or n == 8: tvc.set_cell_data_func(cr, self._set_cell_text_time, n) else: tvc.set_attributes(cr, text=n) tvc.set_resizable(True) tvc.set_clickable(True) self.ttreeview.append_column(tvc) tvc.set_sort_column_id(n - 1) self.tmodelsort.set_sort_func(n - 1, self.sort_column, n - 1) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(self.ttreeview) vbox = gtk.VBox() vbox.pack_start(sw, True) return vbox
def _add_column(self): renderer = gtk.CellRendererProgress() component.get("TorrentView").add_column( header=STATUS_NAME, render=renderer, col_types=str, hidden=False, position=None, status_field=[STATUS_MESSAGE], function=self._render_cell, sortid=0, column_type="progress", )
def make_progress_cell(column, valueNum, textNum=None): column.progressCell = gtk.CellRendererProgress() column.pack_start(column.progressCell, True) def cell_data_progress(column, cell, model, row): value = model.get_value(row, valueNum) if textNum: text = model.get_value(row, textNum) else: text = "%.2f%%" % (value) cell.set_property("value", int(value)) cell.set_property("text", text) column.set_cell_data_func(column.progressCell, cell_data_progress) #this acts as a macro to set a bunch of properties that make this column sortable #column.set_sort_column_id(valueNum) #set properties to make the column interact intuitively. column.set_properties(reorderable=True, expand=False, clickable=True)
def __init__(self, worker, service_col_types, default_service_cols_cb): gtk.HBox.__init__(self) self.worker = worker self.default_service_cols_cb = default_service_cols_cb self.active_row = None self.active_item = None self.model = gtk.ListStore(gtk.gdk.Pixbuf, str, gobject.TYPE_DOUBLE, gobject.TYPE_INT, gobject.TYPE_PYOBJECT, str, gobject.TYPE_BOOLEAN, str, *service_col_types) self.upload_collection = baseobjects.SimpleCollection() self.tv = gtk.TreeView(self.model) self.tv.set_reorderable(True) self.tv.set_headers_visible(False) self.tv.get_selection().set_mode(gtk.SELECTION_MULTIPLE) ##self.tv.connect("row-activated",self.tag_activate) tvc_bitmap = gtk.TreeViewColumn(None, gtk.CellRendererPixbuf(), pixbuf=MODEL_COL_PIXBUF) tvc_text = gtk.TreeViewColumn(None, gtk.CellRendererText(), markup=MODEL_COL_NAME) prog = gtk.CellRendererProgress() tvc_progress = gtk.TreeViewColumn(None, prog, value=MODEL_COL_PROGRESS) ##gtk.CellRendererText self.tv.append_column(tvc_bitmap) self.tv.append_column(tvc_text) self.tv.append_column(tvc_progress) target_list = self.tv.drag_dest_get_target_list() target_list = gtk.target_list_add_uri_targets(target_list, 0) self.tv.enable_model_drag_dest( target_list, gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_COPY) # self.tv.drag_dest_set(gtk.DEST_DEFAULT_ALL, # target_list, # gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.tv.connect("drag-data-received", self.drag_receive_signal) self.tv.add_events(gtk.gdk.BUTTON_MOTION_MASK) self.tv.connect("button-release-event", self.context_menu) scrolled_window = gtk.ScrolledWindow() scrolled_window.add(self.tv) scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.pack_start(scrolled_window)
def __init__(self): self.store = gtk.ListStore(object) super(OperationTree, self).__init__(self.store) # We have only one column with a progress bar # showing a text col = gtk.TreeViewColumn(_('Operation')) col.set_expand(True) col.set_resizable(True) col.set_resizable(True) col.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY) rend = gtk.CellRendererPixbuf() col.pack_start(rend, False) col.set_cell_data_func(rend, self.__pix_data_func) rend = gtk.CellRendererText() col.pack_start(rend) col.set_cell_data_func(rend, self.__text_data_func) self.append_column(col) rend = gtk.CellRendererProgress() col = gtk.TreeViewColumn(_('Status'), rend) col.set_expand(False) col.set_resizable(True) col.set_fixed_width(150) col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) col.set_cell_data_func(rend, self.__progress_data_func) self.append_column(col) self.set_rules_hint(True) self.icon_operation = get_pixbuf('operation_small') self.connect('button-release-event', self.__on_button_release) self.timeout_id = None self.timeout_update()
def build_table(self): # Create File Tree ################## # Name Cell_data_Func Expand Cell Renderer text_cells = [ [_('Name'), FileInfo.file_name, False, gtk.CellRendererText()], [ _('Description'), FileInfo.file_desc, True, gtk.CellRendererText() ], [_('Tags'), FileInfo.file_tags, False, gtk.CellRendererText()], [_('Size'), FileInfo.file_size, False, gtk.CellRendererText()], ['', FileInfo.load_bar, False, gtk.CellRendererProgress()] ] for col_data in text_cells: cell = col_data[3] colName = gtk.TreeViewColumn(col_data[0], cell) colName.set_cell_data_func(cell, col_data[1]) # Should the col expand colName.set_expand(col_data[2]) # Add to tree self.treeview.append_column(colName) # make it searchable by name self.treeview.set_search_column(1) # Allow Multiple Selections self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.treeview.get_selection().connect('changed', self.on_selection_changed) # Put table into scroll window to allow it to scroll self.add_with_viewport(self.treeview)
def __init__(self, navigation): self.navigation = navigation CommonTreeControl.__init__(self, None) self.set_reorderable(False) self.set_headers_visible(True) """column config""" column = gtk.TreeViewColumn("Name", gtk.CellRendererText(), text=self.text[0]) column.set_resizable(True) self.append_column(column) """column config""" column = gtk.TreeViewColumn("Progress", gtk.CellRendererProgress(), text=self.persent[0], value=self.persent[0]) column.set_resizable(True) self.append_column(column) """column config""" column = gtk.TreeViewColumn("Size", gtk.CellRendererText(), text=self.size[0]) column.set_resizable(True) self.append_column(column) """status""" column = gtk.TreeViewColumn("Status", gtk.CellRendererText(), text=self.status[0]) column.set_resizable(True) self.append_column(column) """column config""" column = gtk.TreeViewColumn("Path", gtk.CellRendererText(), text=self.save_to[0]) column.set_resizable(True) column.set_expand(True) self.append_column(column) self.set_type_plain()
def build_display(self): self.col_call = 0 self.col_prog = 1 self.col_stat = 2 self.store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_STRING) self.view = gtk.TreeView(self.store) self.view.set_rules_hint(True) l = [(self.col_call, "Station", gtk.CellRendererText), (self.col_prog, "Progress", gtk.CellRendererProgress), (self.col_stat, "Status", gtk.CellRendererText)] r = gtk.CellRendererText() c = gtk.TreeViewColumn("Station", r, text=self.col_call) c.set_resizable(True) c.set_sort_column_id(self.col_call) self.view.append_column(c) r = gtk.CellRendererProgress() c = gtk.TreeViewColumn("Progress", r, value=self.col_prog) c.set_resizable(True) c.set_sort_column_id(self.col_prog) self.view.append_column(c) r = gtk.CellRendererText() c = gtk.TreeViewColumn("Status", r, text=self.col_stat) c.set_resizable(True) c.set_sort_column_id(self.col_stat) self.view.append_column(c) sw = gtk.ScrolledWindow() sw.add(self.view) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.view.show() return sw
def __init__(self, downmanager): super(DownloadList, self).__init__(model=gtk.ListStore(str, str, str, str, int)) self.set_rules_hint(True) self._data = {} self._downmanager = downmanager columns = [ gtk.TreeViewColumn("Name", gtk.CellRendererText(), text=self.COLUMN_NAME), gtk.TreeViewColumn("Size", gtk.CellRendererText(), text=self.COLUMN_SIZE), gtk.TreeViewColumn("Login", gtk.CellRendererText(), text=self.COLUMN_LOGIN), gtk.TreeViewColumn("State", gtk.CellRendererProgress(), text=self.COLUMN_STATE, value=self.COLUMN_PROGRESS), ] for column in columns: self.append_column(column)
def __init__(self): gtk.TreeView.__init__(self) self.di = {} self.pos = 0 self._model = gtk.ListStore(str, str, int) self.set_model(self._model) renderer_text = gtk.CellRendererText() column_text = gtk.TreeViewColumn(_("Name"), renderer_text, text=0) self.append_column(column_text) renderer_text = gtk.CellRendererText() column_text = gtk.TreeViewColumn(_("State"), renderer_text, text=1) self.append_column(column_text) renderer_progress = gtk.CellRendererProgress() column_progress = gtk.TreeViewColumn(_("Progress"), renderer_progress, value=2) self.append_column(column_progress) self.show_all()
def _create_treeview(self): self.liststore = gtk.ListStore(gobject.TYPE_PYOBJECT, gobject.TYPE_STRING) treeview = gtk.TreeView(model=self.liststore) treeview.set_rules_hint(False) treeview.set_headers_visible(False) self.perc_renderer = gtk.CellRendererProgress() self.match_renderer = TMMatchRenderer(self.view) self.tm_source_renderer = TMSourceColRenderer(self.view) # l10n: match quality column label self.tvc_perc = gtk.TreeViewColumn(_('%'), self.perc_renderer) self.tvc_perc.set_cell_data_func(self.perc_renderer, self._percent_data_func) self.tvc_match = gtk.TreeViewColumn(_('Matches'), self.match_renderer, matchdata=0) self.tvc_match.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) self.tvc_tm_source = gtk.TreeViewColumn(_('TM Source'), self.tm_source_renderer, matchdata=0) self.tvc_tm_source.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) treeview.append_column(self.tvc_perc) treeview.append_column(self.tvc_match) treeview.append_column(self.tvc_tm_source) treeview.set_tooltip_column(1) return treeview
def create_interior(self): self.mainbox = gtk.ScrolledWindow() self.mainbox.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.window.add(self.mainbox) # model creation # URL, recursion_depth, download, processed part, what to download self.model = gtk.ListStore(str, int, bool, float, str) for url, download in (["http://root.cz", True], ["http://slashdot.org", True], ["http://mozilla.org", False]): adj = gtk.Adjustment(value=0, lower=0, upper=10, step_incr=1) self.model.append([url, 0, download, 0.0, "HTML only"]) # the treeview treeview = gtk.TreeView(self.model) # individual columns # URL column col = gtk.TreeViewColumn("URL") treeview.append_column(col) cell = gtk.CellRendererText() col.pack_start(cell, expand=False) col.set_attributes(cell, text=0) col.set_sort_column_id(0) # recursion_depth column col = gtk.TreeViewColumn("Depth") treeview.append_column(col) cell = gtk.CellRendererSpin() cell.set_property("adjustment", gtk.Adjustment(lower=0, upper=10, step_incr=1)) cell.set_property("editable", True) col.pack_start(cell, expand=False) col.set_attributes(cell, text=1) cell.connect('edited', self._recursion_depth_changed, 1) # State col = gtk.TreeViewColumn("State") treeview.insert_column(col, 0) cell = gtk.CellRendererPixbuf() col.pack_start(cell, expand=False) col.set_cell_data_func(cell, self._render_icon) # Download column col = gtk.TreeViewColumn("Download") treeview.append_column(col) cell = gtk.CellRendererToggle() cell.set_property("activatable", True) col.pack_start(cell, expand=False) col.set_attributes(cell, active=2) col.set_sort_column_id(2) cell.connect('toggled', self._download_toggled, 2) # What to download column col = gtk.TreeViewColumn("What") treeview.append_column(col) cell = gtk.CellRendererCombo() cell.set_property("editable", True) # we need a separate model for the combo model = gtk.ListStore(str) for value in ["HTML only", "HTML+CSS", "Everything"]: model.append([value]) cell.set_property("model", model) cell.set_property("text-column", 0) col.pack_start(cell, expand=False) col.set_attributes(cell, text=4) col.set_sort_column_id(4) cell.connect('edited', self._what_to_download_changed, 4) # Progress column col = gtk.TreeViewColumn("Progress") treeview.append_column(col) cell = gtk.CellRendererProgress() col.pack_start(cell, expand=True) col.set_attributes(cell, value=3) col.set_sort_column_id(3) # pack the treeview self.mainbox.add(treeview) # show the box self.mainbox.set_size_request(500, 260) self.mainbox.show() # set up timer self._timer = gobject.timeout_add(200, self._timeout)
def __init__(self, gladefile, app_settings, thread_manager, parser_manager, prop_cont): self._video_bitrate_options = [384, 512, 768, 1024, 1536, 2000] self._log = logging.getLogger("{0}.{1}".format( __name__, self.__class__.__name__)) self.gladefile = gladefile self.window = gtk.glade.XML(self.gladefile) self.main_window = self.window.get_widget('window1') self.about_window = self.window.get_widget('aboutdialog1') self.about_window.set_comments('Version %s' % VERSION) self.about_window.set_name(APP_NAME) self.mainbar1 = self.window.get_widget('menubar1') self.entry1 = self.window.get_widget('entry1') self.button1 = self.window.get_widget('button1') self.button2 = self.window.get_widget('button2') self.toolbutton1 = self.window.get_widget('toolbutton1') self.toolbutton2 = self.window.get_widget('toolbutton2') self.toolbutton3 = self.window.get_widget('toolbutton3') self.toolbutton4 = self.window.get_widget('toolbutton4') self.toolbutton5 = self.window.get_widget('toolbutton5') self.video_bitrate_combobox = self.window.get_widget( "video_bitrate_combobox") self.audio_bitrate_combobox = self.window.get_widget( "audio_bitrate_combobox") bitrate_list = gtk.ListStore(gobject.TYPE_INT) self.video_bitrate_combobox.set_model(bitrate_list) for bitrate in self._video_bitrate_options: bitrate_list.append([bitrate]) if app_settings.vbitrate in self._video_bitrate_options: self.video_bitrate_combobox.set_active( self._video_bitrate_options.index(app_settings.vbitrate)) else: self.video_bitrate_combobox.set_active(0) app_settings.vbitrate = self._video_bitrate_options[0] bitrate_list = gtk.ListStore(gobject.TYPE_INT) self.audio_bitrate_combobox.set_model(bitrate_list) for n in range(1, 13): bitrate_list.append([n * 32]) self.audio_bitrate_combobox.set_active((app_settings.abitrate / 32) - 1) self.combobox = self.window.get_widget('combobox1') self.combobox.set_active(app_settings.format) self.checkbutton1 = self.window.get_widget('checkbutton1') self.checkbutton2 = self.window.get_widget('checkbutton2') self.checkbutton3 = self.window.get_widget('checkbutton3') self.auto_download_check = self.window.get_widget( "auto_download_check") self.resolution_combobox = self.window.get_widget( "resolution_combobox") self.resolution_combobox.set_active(app_settings.output_res) if app_settings.format in VideoItem.VIDEO_FORMATS: self.resolution_combobox.set_sensitive(True) self.video_bitrate_combobox.set_sensitive(True) self.audio_bitrate_combobox.set_sensitive(True) else: self.resolution_combobox.set_sensitive(False) self.video_bitrate_combobox.set_sensitive(False) self.audio_bitrate_combobox.set_sensitive(True) if not app_settings.transcode: if not app_settings.keep_flv_files: app_settings.keep_flv_files = True self.checkbutton3.set_active(True) self.checkbutton3.set_sensitive(False) self.checkbutton1.set_active(False) if app_settings.overwrite: self.checkbutton2.set_active(True) if not app_settings.keep_flv_files: self.checkbutton3.set_active(False) self.auto_download_check.set_active(app_settings.auto_download) self.treeview1 = self.window.get_widget("treeview1") self.column1 = gtk.TreeViewColumn("URL", gtk.CellRendererText(), text=0) self.column1.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) # self.column1.set_min_width (230) self.column1.set_resizable(True) self.column1.set_expand(True) self.column2 = gtk.TreeViewColumn("Name") cell = gtk.CellRendererPixbuf() self.column2.pack_start(cell, False) #self.column2.add_attribute (cell, "pixbuf", 6) cell2 = gtk.CellRendererText() self.column2.pack_start(cell2, False) self.column2.set_cell_data_func(cell, self._cell_render_service) self.column2.set_attributes(cell2, text=1) # self.column2 = gtk.TreeViewColumn ("Name", gtk.CellRendererText(), text=1) self.column2.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.column2.set_min_width(175) self.column2.set_resizable(True) self.column2.set_expand(True) self.column5 = gtk.TreeViewColumn("Speed", gtk.CellRendererText(), text=4) self.column5.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.column5.set_min_width(100) self.column6 = gtk.TreeViewColumn("Size", gtk.CellRendererText(), text=5) self.column6.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.column6.set_min_width(100) self.column3 = gtk.TreeViewColumn("Progress", gtk.CellRendererProgress(), value=2) self.column3.set_min_width(75) self.column4 = gtk.TreeViewColumn("Status", gtk.CellRendererText(), text=3) self.column4.set_min_width(100) self.column4.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.column7 = gtk.TreeViewColumn("Time Left", gtk.CellRendererText(), text=6) self.column7.set_min_width(110) self.column7.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.treeview1.append_column(self.column2) self.treeview1.append_column(self.column6) self.treeview1.append_column(self.column3) self.treeview1.append_column(self.column5) self.treeview1.append_column(self.column7) self.treeview1.append_column(self.column4) self.treeview1.set_model(thread_manager.tree_model) self.folder_chooser = self.window.get_widget("filechooserbutton1") self.folder_chooser.set_current_folder(app_settings.output_dir) self.statusbar = self.window.get_widget("statusbar1") self.speed_statusbar = self.window.get_widget("statusbar2") # self.speed_label = self.window.get_widget ("speedlabel") self.statusbar_context_id = self.statusbar.get_context_id("Statusbar") self.pause_toolbutton = self.window.get_widget("pause_toolbutton") self.sites_window = self.window.get_widget("sites_dialog") self.sites_textview = self.window.get_widget("sites_textview") self.app_settings = app_settings self.thread_manager = thread_manager self.parser_manager = parser_manager self.prop_cont = prop_cont self._treeview_rightclick_event = None gtk.about_dialog_set_url_hook(self.open_site) self.treeview1.connect("button-press-event", self.treeview_right) self.treeview1.connect("cursor-changed", self.treeview_right2) connect_dict = { "on_window1_delete_event": self.quit_app, "on_quit1_activate": self.quit_app, "on_preferences2_activate": self.show_preferences, "on_about1_activate": self.show_about_window, "on_aboutdialog1_response": self.hide_about_window, "on_aboutdialog1_delete_event": self.keep_about_window, "on_sites_activate": self.show_sites_window, "on_close_sites_clicked": self.hide_sites_window, "on_sites_dialog_delete_event": self.keep_sites_window, "on_sites_dialog_response": self.hide_sites_window, "on_checkbutton1_toggled": self.transcode_check, "on_checkbutton2_toggled": self.overwrite_check, "on_checkbutton3_toggled": self.keep_flvs_check, "on_auto_download_check_toggled": self.change_auto_download, "on_video_bitrate_changed": self.change_video_bitrate, "on_resolution_combobox_changed": self.resolution_change, "on_combobox1_changed": self.change_format, "on_toolbutton4_clicked": self.move_up, "on_toolbutton5_clicked": self.move_down, "on_treeview1_cursor_changed": self.select_item, "on_toolbutton3_clicked": self.clear_complete, "on_openfolderbutton_clicked": self.open_video_folder, "on_filechooserbutton1_current_folder_changed": self.change_video_folder, "on_pause_toolbutton_clicked": self.pause_download, "on_toolbutton2_clicked": self.remove, "on_button1_clicked": self.add_video_from_url, "on_toolbutton1_clicked": self.start_process, "on_entry1_activate": self.add_video_from_url, "on_audio_bitrate_changed": self.change_audio_bitrate, } self.window.signal_autoconnect(connect_dict) self.thread_manager.connect("need_ui_refresh", self.unlock_partial_ui) self.thread_manager.connect("speed_progress_update", self.update_speed_statusbar) self.thread_manager.connect("progress_update", self.update_statusbar) # Populate sites_textview with hooks to controller methods when # moving over text and clicking on links self.sites_textview.connect("motion-notify-event", self.sites_textview_motion_notify_event) parser_list = self.parser_manager.get_official_parsers() name_list = [] tmp_dic = {} for parser in parser_list: name_list.append(parser.getType()) tmp_dic[parser.getType()] = parser name_list.sort() textbuffer = self.sites_textview.get_buffer() textbuffer.insert(textbuffer.get_end_iter(), "Supported Sites\n-----------------------\n\n") for i, name in enumerate(name_list): newtag = textbuffer.create_tag("url-tag{0}".format(i)) newtag.set_property("underline", pango.UNDERLINE_SINGLE) newtag.set_property("foreground", "#2750FF") newtag.connect("event", self.sites_textview_link_button_press_event) newtag.set_data("link", tmp_dic[name].domain_str) parser_version = tmp_dic[name].version textbuffer.insert(textbuffer.get_end_iter(), "* ") textbuffer.insert_with_tags_by_name(textbuffer.get_end_iter(), name, newtag.get_property("name")) textbuffer.insert( textbuffer.get_end_iter(), " ({0}/{1}/{2})\n".format(parser_version.month, parser_version.day, parser_version.year))
def __init__(self): Tab.__init__(self) builder = component.get("MainWindow").get_builder() self._name = "Files" self._child_widget = builder.get_object("files_tab") self._tab_label = builder.get_object("files_tab_label") self.listview = builder.get_object("files_listview") # filename, size, progress string, progress value, priority, file index, icon id self.treestore = gtk.TreeStore(str, gobject.TYPE_UINT64, str, float, int, int, str) # We need to store the row that's being edited to prevent updating it until # it's been done editing self._editing_index = None # Filename column self.filename_column_name = _("Filename") column = gtk.TreeViewColumn(self.filename_column_name) render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "stock-id", 6) render = gtk.CellRendererText() render.set_property("editable", True) render.connect("edited", self._on_filename_edited) render.connect("editing-started", self._on_filename_editing_start) render.connect("editing-canceled", self._on_filename_editing_canceled) column.pack_start(render, True) column.add_attribute(render, "text", 0) column.set_sort_column_id(0) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(200) column.set_reorderable(True) self.listview.append_column(column) # Size column column = gtk.TreeViewColumn(_("Size")) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, deluge.ui.gtkui.listview.cell_data_size, 1) column.set_sort_column_id(1) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) column.set_reorderable(True) self.listview.append_column(column) # Progress column column = gtk.TreeViewColumn(_("Progress")) render = gtk.CellRendererProgress() column.pack_start(render) column.set_cell_data_func(render, cell_progress, (2, 3)) column.set_sort_column_id(3) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Priority column column = gtk.TreeViewColumn(_("Priority")) render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.set_cell_data_func(render, cell_priority_icon, 4) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_priority, 4) column.set_sort_column_id(4) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) # Bugfix: Last column needs max_width set to stop scrollbar appearing column.set_max_width(200) column.set_reorderable(True) self.listview.append_column(column) self.listview.set_model(self.treestore) self.listview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.file_menu = builder.get_object("menu_file_tab") self.file_menu_priority_items = [ builder.get_object("menuitem_donotdownload"), builder.get_object("menuitem_normal"), builder.get_object("menuitem_high"), builder.get_object("menuitem_highest"), builder.get_object("menuitem_priority_sep") ] self.localhost_widgets = [ builder.get_object("menuitem_open_file"), builder.get_object("menuitem3") ] self.listview.connect("row-activated", self._on_row_activated) self.listview.connect("key-press-event", self._on_key_press_event) self.listview.connect("button-press-event", self._on_button_press_event) self.listview.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, [('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.listview.enable_model_drag_dest([('text/plain', 0, 0)], gtk.gdk.ACTION_DEFAULT) self.listview.connect("drag_data_get", self._on_drag_data_get_data) self.listview.connect("drag_data_received", self._on_drag_data_received_data) component.get("MainWindow").connect_signals({ "on_menuitem_open_file_activate": self._on_menuitem_open_file_activate, "on_menuitem_donotdownload_activate": self._on_menuitem_donotdownload_activate, "on_menuitem_normal_activate": self._on_menuitem_normal_activate, "on_menuitem_high_activate": self._on_menuitem_high_activate, "on_menuitem_highest_activate": self._on_menuitem_highest_activate, "on_menuitem_expand_all_activate": self._on_menuitem_expand_all_activate }) # Connect to various events from the daemon client.register_event_handler("TorrentFileRenamedEvent", self._on_torrentfilerenamed_event) client.register_event_handler("TorrentFolderRenamedEvent", self._on_torrentfolderrenamed_event) client.register_event_handler("TorrentRemovedEvent", self._on_torrentremoved_event) # Attempt to load state self.load_state() # torrent_id: (filepath, size) self.files_list = {} self.torrent_id = None