mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-18 14:26:24 +00:00
Code refactoring.
Sync preferences_dialog.glade from trunk.
This commit is contained in:
parent
53934ec8d8
commit
ca5306bd2d
File diff suppressed because it is too large
Load Diff
@ -229,7 +229,7 @@ class ListView:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def add_column(self, header, render, col_types, hidden, position,
|
def add_column(self, header, renderer, col_types, hidden, position,
|
||||||
status_field, sortid, text=0, value=0, function=None):
|
status_field, sortid, text=0, value=0, function=None):
|
||||||
"""Adds a column to the ListView"""
|
"""Adds a column to the ListView"""
|
||||||
# Add the column types to liststore_columns
|
# Add the column types to liststore_columns
|
||||||
@ -257,24 +257,43 @@ class ListView:
|
|||||||
# Create a new list with the added column
|
# Create a new list with the added column
|
||||||
self.create_new_liststore()
|
self.create_new_liststore()
|
||||||
|
|
||||||
if type(render) is gtk.CellRendererText:
|
if type(renderer) is not tuple and type(renderer) is not list:
|
||||||
# Check to see if this is a function column or not
|
renderer = [renderer]
|
||||||
if function is None:
|
|
||||||
# Not a function column, so lets treat it as a regular text col
|
column = gtk.TreeViewColumn(header)
|
||||||
column = gtk.TreeViewColumn(header, render,
|
for render in renderer:
|
||||||
text=self.columns[header].column_indices[text])
|
if type(render) is gtk.CellRendererText:
|
||||||
else:
|
# Check to see if this is a function column or not
|
||||||
# This is a function column
|
if function is None:
|
||||||
column = gtk.TreeViewColumn(header)
|
# Not a function column, so lets treat it as a regular
|
||||||
column.pack_start(render, True)
|
# text col
|
||||||
if len(self.columns[header].column_indices) > 1:
|
column.pack_start(render)
|
||||||
column.set_cell_data_func(render, function,
|
column.add_attribute(render, "text",
|
||||||
tuple(self.columns[header].column_indices))
|
self.columns[header].column_indices[text])
|
||||||
else:
|
else:
|
||||||
column.set_cell_data_func(render, function,
|
# This is a function column
|
||||||
|
column.pack_start(render, True)
|
||||||
|
if len(self.columns[header].column_indices) > 1:
|
||||||
|
column.set_cell_data_func(render, function,
|
||||||
|
tuple(self.columns[header].column_indices))
|
||||||
|
else:
|
||||||
|
column.set_cell_data_func(render, function,
|
||||||
self.columns[header].column_indices[0])
|
self.columns[header].column_indices[0])
|
||||||
else:
|
elif type(render) is gtk.CellRendererProgress:
|
||||||
column = gtk.TreeViewColumn(header, render)
|
# This is a progress column
|
||||||
|
column.pack_start(render)
|
||||||
|
column.add_attribute(render, "text",
|
||||||
|
self.columns[header].column_indices[text])
|
||||||
|
column.add_attribute(render, "value",
|
||||||
|
self.columns[header].column_indices[value])
|
||||||
|
|
||||||
|
elif type(render) is gtk.CellRendererPixbuf:
|
||||||
|
# This is a pixbuf column
|
||||||
|
column.pack_start(render, expand=False)
|
||||||
|
column.add_attribute(render, "pixbuf",
|
||||||
|
self.columns[header].column_indices[pixbuf])
|
||||||
|
else:
|
||||||
|
column.pack_start(render)
|
||||||
|
|
||||||
column.set_sort_column_id(self.columns[header].column_indices[sortid])
|
column.set_sort_column_id(self.columns[header].column_indices[sortid])
|
||||||
column.set_clickable(True)
|
column.set_clickable(True)
|
||||||
@ -318,95 +337,29 @@ class ListView:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add_progress_column(self, header, col_type=[float,str], hidden=False,
|
def add_progress_column(self, header, col_types=[float, str],
|
||||||
|
sortid=0,
|
||||||
|
hidden=False,
|
||||||
position=None,
|
position=None,
|
||||||
get_function=None,
|
|
||||||
status_field=None):
|
status_field=None):
|
||||||
# For the progress value
|
"""Add a progress column to the listview."""
|
||||||
self.liststore_columns.append(float)
|
|
||||||
# For the text
|
|
||||||
self.liststore_columns.append(str)
|
|
||||||
column_indices = [len(self.liststore_columns) - 2,
|
|
||||||
len(self.liststore_columns) - 1]
|
|
||||||
# Add to the index list so we know the order of the visible columns.
|
|
||||||
if position is not None:
|
|
||||||
self.column_index.insert(position, header)
|
|
||||||
else:
|
|
||||||
self.column_index.append(header)
|
|
||||||
# Create a new column object and add it to the list
|
|
||||||
self.columns[header] = self.ListViewColumn(header, column_indices)
|
|
||||||
|
|
||||||
self.columns[header].status_field = status_field
|
|
||||||
# Create new list with the added columns
|
|
||||||
self.create_new_liststore()
|
|
||||||
|
|
||||||
render = gtk.CellRendererProgress()
|
render = gtk.CellRendererProgress()
|
||||||
column = gtk.TreeViewColumn(header, render,
|
self.add_column(header, render, col_types, hidden, position,
|
||||||
value=self.columns[header].column_indices[0],
|
status_field, sortid, value=0, text=1)
|
||||||
text=self.columns[header].column_indices[1])
|
|
||||||
column.set_clickable(True)
|
|
||||||
column.set_sort_column_id(self.columns[header].column_indices[0])
|
|
||||||
column.set_resizable(True)
|
|
||||||
column.set_expand(False)
|
|
||||||
column.set_min_width(10)
|
|
||||||
column.set_reorderable(True)
|
|
||||||
column.set_visible(not hidden)
|
|
||||||
if position is not None:
|
|
||||||
self.treeview.insert_column(column, position)
|
|
||||||
else:
|
|
||||||
self.treeview.append_column(column)
|
|
||||||
# Set hidden in the column
|
|
||||||
self.columns[header].hidden = hidden
|
|
||||||
self.columns[header].column = column
|
|
||||||
# Re-create the menu item because of the new column
|
|
||||||
self.create_checklist_menu()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add_texticon_column(self, header, hidden=False, position=None,
|
def add_texticon_column(self, header, col_types=[gtk.gdk.Pixbuf, str],
|
||||||
get_function=None,
|
sortid=0,
|
||||||
|
hidden=False,
|
||||||
|
position=None,
|
||||||
status_field=None):
|
status_field=None):
|
||||||
# For icon
|
"""Adds a texticon column to the listview."""
|
||||||
self.liststore_columns.append(gtk.gdk.Pixbuf)
|
render1 = gtk.CellRendererPixbuf()
|
||||||
# For text
|
render2 = gtk.CellRendererText()
|
||||||
self.liststore_columns.append(str)
|
|
||||||
column_indices = [len(self.liststore_columns) - 2,
|
|
||||||
len(self.liststore_columns) - 1]
|
|
||||||
|
|
||||||
# Add to the index list so we know the order of the visible columns.
|
self.add_column(header, (render1, render2), col_types, hidden,
|
||||||
if position is not None:
|
position, status_field, sortid, text=1, pixbuf=0)
|
||||||
self.column_index.insert(position, header)
|
|
||||||
else:
|
|
||||||
self.column_index.append(header)
|
|
||||||
|
|
||||||
self.columns[header] = self.ListViewColumn(header, column_indices)
|
|
||||||
self.columns[header].status_field = status_field
|
|
||||||
# Create new list with the added columns
|
|
||||||
self.create_new_liststore()
|
|
||||||
|
|
||||||
column = gtk.TreeViewColumn(header)
|
|
||||||
column.set_clickable(True)
|
|
||||||
column.set_resizable(True)
|
|
||||||
column.set_expand(False)
|
|
||||||
column.set_min_width(10)
|
|
||||||
column.set_reorderable(True)
|
|
||||||
render = gtk.CellRendererPixbuf()
|
|
||||||
column.pack_start(render, expand=False)
|
|
||||||
column.add_attribute(render, 'pixbuf',
|
|
||||||
self.columns[header].column_indices[0])
|
|
||||||
render = gtk.CellRendererText()
|
|
||||||
column.pack_start(render, expand=True)
|
|
||||||
column.add_attribute(render, 'text',
|
|
||||||
self.columns[header].column_indices[1])
|
|
||||||
column.set_visible(not hidden)
|
|
||||||
if position is not None:
|
|
||||||
self.treeview.insert_column(column, position)
|
|
||||||
else:
|
|
||||||
self.treeview.append_column(column)
|
|
||||||
# Set hidden in the column
|
|
||||||
self.columns[header].hidden = hidden
|
|
||||||
self.columns[header].column = column
|
|
||||||
# Re-create the menu item because of the new column
|
|
||||||
self.create_checklist_menu()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user