mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 19:44:52 +00:00
Add ability to set columns as not visible by default by setting the kwarg default to False when adding the column
This commit is contained in:
parent
b93477c41e
commit
3c3b68e2cc
1 changed files with 37 additions and 40 deletions
|
@ -432,7 +432,7 @@ class ListView:
|
|||
|
||||
def add_column(self, header, render, col_types, hidden, position,
|
||||
status_field, sortid, text=0, value=0, pixbuf=0, function=None,
|
||||
column_type=None, sort_func=None):
|
||||
column_type=None, sort_func=None, default=True):
|
||||
"""Adds a column to the ListView"""
|
||||
# Add the column types to liststore_columns
|
||||
column_indices = []
|
||||
|
@ -510,10 +510,12 @@ class ListView:
|
|||
self.on_treeview_header_right_clicked)
|
||||
|
||||
# Check for loaded state and apply
|
||||
column_in_state = False
|
||||
if self.state != None:
|
||||
for column_state in self.state:
|
||||
if header == column_state.name:
|
||||
# We found a loaded state
|
||||
column_in_state = True
|
||||
if column_state.width > 0:
|
||||
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
||||
column.set_fixed_width(column_state.width)
|
||||
|
@ -522,7 +524,13 @@ class ListView:
|
|||
self.model_filter.set_sort_column_id(column_state.sort, column_state.sort_order)
|
||||
column.set_visible(column_state.visible)
|
||||
position = column_state.position
|
||||
|
||||
break
|
||||
|
||||
# Set this column to not visible if its not in the state and
|
||||
# its not supposed to be shown by default
|
||||
if not column_in_state and not default and not hidden:
|
||||
column.set_visible(False)
|
||||
|
||||
if position is not None:
|
||||
self.treeview.insert_column(column, position)
|
||||
else:
|
||||
|
@ -536,75 +544,64 @@ class ListView:
|
|||
|
||||
return True
|
||||
|
||||
def add_text_column(self, header, col_type=str, hidden=False,
|
||||
position=None,
|
||||
status_field=None,
|
||||
sortid=0,
|
||||
column_type="text",
|
||||
sort_func=None):
|
||||
def add_text_column(self, header, col_type=str, hidden=False, position=None,
|
||||
status_field=None, sortid=0, column_type="text",
|
||||
sort_func=None, default=True):
|
||||
"""Add a text column to the listview. Only the header name is required.
|
||||
"""
|
||||
render = gtk.CellRendererText()
|
||||
self.add_column(header, render, col_type, hidden, position,
|
||||
status_field, sortid, column_type=column_type, sort_func=sort_func)
|
||||
status_field, sortid, column_type=column_type,
|
||||
sort_func=sort_func, default=default)
|
||||
|
||||
return True
|
||||
|
||||
def add_bool_column(self, header, col_type=bool, hidden=False,
|
||||
position=None,
|
||||
status_field=None,
|
||||
sortid=0,
|
||||
column_type="bool"):
|
||||
|
||||
position=None, status_field=None, sortid=0,
|
||||
column_type="bool", default=True):
|
||||
"""Add a bool column to the listview"""
|
||||
render = gtk.CellRendererToggle()
|
||||
self.add_column(header, render, col_type, hidden, position,
|
||||
status_field, sortid, column_type=column_type)
|
||||
status_field, sortid, column_type=column_type,
|
||||
default=default)
|
||||
|
||||
def add_func_column(self, header, function, col_types, sortid=0,
|
||||
hidden=False, position=None, status_field=None,
|
||||
column_type="func", sort_func=None):
|
||||
hidden=False, position=None, status_field=None,
|
||||
column_type="func", sort_func=None, default=True):
|
||||
"""Add a function column to the listview. Need a header name, the
|
||||
function and the column types."""
|
||||
|
||||
render = gtk.CellRendererText()
|
||||
self.add_column(header, render, col_types, hidden, position,
|
||||
status_field, sortid, column_type=column_type,
|
||||
function=function, sort_func=sort_func)
|
||||
status_field, sortid, column_type=column_type,
|
||||
function=function, sort_func=sort_func, default=default)
|
||||
|
||||
return True
|
||||
|
||||
def add_progress_column(self, header, col_types=[float, str],
|
||||
sortid=0,
|
||||
hidden=False,
|
||||
position=None,
|
||||
status_field=None,
|
||||
function=None,
|
||||
column_type="progress"):
|
||||
def add_progress_column(self, header, col_types=[float, str], sortid=0,
|
||||
hidden=False, position=None, status_field=None,
|
||||
function=None, column_type="progress",
|
||||
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)
|
||||
status_field, sortid, function=function,
|
||||
column_type=column_type, value=0, text=1,
|
||||
default=default)
|
||||
|
||||
return True
|
||||
|
||||
def add_texticon_column(self, header, col_types=[str, str],
|
||||
sortid=1,
|
||||
hidden=False,
|
||||
position=None,
|
||||
status_field=None,
|
||||
column_type="texticon",
|
||||
function=None):
|
||||
def add_texticon_column(self, header, col_types=[str, str], sortid=1,
|
||||
hidden=False, position=None, status_field=None,
|
||||
column_type="texticon", function=None,
|
||||
default=True):
|
||||
"""Adds a texticon column to the listview."""
|
||||
render1 = gtk.CellRendererPixbuf()
|
||||
render2 = gtk.CellRendererText()
|
||||
|
||||
self.add_column(header, (render1, render2), col_types, hidden,
|
||||
position, status_field, sortid,
|
||||
column_type=column_type, function=function,
|
||||
pixbuf=0, text=1)
|
||||
self.add_column(header, (render1, render2), col_types, hidden, position,
|
||||
status_field, sortid, column_type=column_type,
|
||||
function=function, pixbuf=0, text=1, default=default)
|
||||
|
||||
return True
|
||||
|
|
Loading…
Add table
Reference in a new issue