Make it possible to show private icon in displaytabs

Enable this already in Attribute and SrcAttribute 


svn: r22427
This commit is contained in:
Benny Malengier 2013-05-27 09:35:31 +00:00
parent 0a8c9bc2e2
commit 188587bbaf
18 changed files with 137 additions and 90 deletions

View File

@ -35,7 +35,7 @@ from .childmodel import ChildModel
# Then import tab classes
from .grampstab import GrampsTab
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
from .addrembedlist import AddrEmbedList
from .attrembedlist import AttrEmbedList
from .backreflist import BackRefList

View File

@ -42,7 +42,7 @@ from gramps.gen.lib import Address
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .addressmodel import AddressModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -70,12 +70,12 @@ class AddrEmbedList(EmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Date'), 0, 150, 1, -1),
(_('Street'), 1, 225, 0, -1),
(_('Locality'), 2, 100, 0, -1),
(_('City'), 3, 100, 0, -1),
(_('State/County'), 4, 100, 0, -1),
(_('Country'), 5, 75, 0, -1),
(_('Date'), 0, 150, MARKUP_COL, -1, None),
(_('Street'), 1, 225, TEXT_COL, -1, None),
(_('Locality'), 2, 100, TEXT_COL, -1, None),
(_('City'), 3, 100, TEXT_COL, -1, None),
(_('State/County'), 4, 100, TEXT_COL, -1, None),
(_('Country'), 5, 75, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data):

View File

@ -38,7 +38,7 @@ from gramps.gen.lib import Attribute
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .attrmodel import AttrModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -47,7 +47,7 @@ from .embeddedlist import EmbeddedList
#-------------------------------------------------------------------------
class AttrEmbedList(EmbeddedList):
_HANDLE_COL = 2
_HANDLE_COL = 3
_DND_TYPE = DdTargets.ATTRIBUTE
_MSG = {
@ -61,8 +61,9 @@ class AttrEmbedList(EmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Type'), 0, 250, 0, -1),
(_('Value'), 1, 200, 0, -1),
(_('Type'), 0, 250, TEXT_COL, -1, None),
(_('Value'), 1, 200, TEXT_COL, -1, None),
(_('Private'), 2, 30, ICON_COL, -1, 'gramps-lock')
]
def __init__(self, dbstate, uistate, track, data):
@ -90,7 +91,7 @@ class AttrEmbedList(EmbeddedList):
return self.data
def column_order(self):
return ((1, 0), (1, 1))
return ((1, 2), (1, 0), (1, 1))
def add_button_clicked(self, obj):
pname = ''

View File

@ -42,11 +42,12 @@ from gi.repository import Gtk
class AttrModel(Gtk.ListStore):
def __init__(self, attr_list, db):
Gtk.ListStore.__init__(self, str, str, object)
Gtk.ListStore.__init__(self, str, str, bool, object)
self.db = db
for attr in attr_list:
self.append(row=[
str(attr.get_type()),
attr.get_value(),
attr.get_privacy(),
attr,
])

View File

@ -44,7 +44,7 @@ from gi.repository import Gtk
#-------------------------------------------------------------------------
from gramps.gen.errors import WindowActiveError
from ...widgets import SimpleButton
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -58,9 +58,9 @@ class BackRefList(EmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Type'), 0, 100, 0, -1),
(_('ID'), 1, 75, 0, -1),
(_('Name'), 2, 250, 0, -1),
(_('Type'), 0, 100, TEXT_COL, -1, None),
(_('ID'), 1, 75, TEXT_COL, -1, None),
(_('Name'), 2, 250, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, obj, refmodel, callback=None):

View File

@ -49,7 +49,7 @@ from gramps.gen.lib import Source, Citation
from ...dbguielement import DbGUIElement
from ...selectors import SelectorFactory
from .citationrefmodel import CitationRefModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
from ...ddtargets import DdTargets
#-------------------------------------------------------------------------
@ -80,10 +80,10 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Title'), 0, 200, 0, -1),
(_('Author'), 1, 125, 0, -1),
(_('Page'), 2, 100, 0, -1),
(_('ID'), 3, 75, 0, -1),
(_('Title'), 0, 200, TEXT_COL, -1, None),
(_('Author'), 1, 125, TEXT_COL, -1, None),
(_('Page'), 2, 100, TEXT_COL, -1, None),
(_('ID'), 3, 75, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data, callertitle=None):

View File

@ -52,6 +52,16 @@ from gi.repository import Pango
from ...utils import is_right_click
from .buttontab import ButtonTab
#----------------------------------------------------------------
#
# Constants
#
#----------------------------------------------------------------
TEXT_COL = 0
MARKUP_COL = 1
ICON_COL = 2
#-------------------------------------------------------------------------
#
# Classes
@ -80,6 +90,8 @@ class EmbeddedList(ButtonTab):
self.changed = False
self.model = None
self.build_model = build_model
#renderer for pixbuf
self.pb_renderer = None
# handle the selection
self.tree.set_hover_selection(True)
@ -88,6 +100,7 @@ class EmbeddedList(ButtonTab):
self.track_ref_for_deletion("selection")
# build the columns
self.col_icons = {}
self.columns = []
self.build_columns()
@ -470,19 +483,35 @@ class EmbeddedList(ButtonTab):
# assign it to the column name. The text value is extracted
# from the model column specified in pair[1]
name = self._column_names[pair[1]][0]
renderer = Gtk.CellRendererText()
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
if self._column_names[pair[1]][3] == 0:
column = Gtk.TreeViewColumn(name, renderer, text=pair[1])
col_icon = self._column_names[pair[1]][5]
if (self._column_names[pair[1]][3] in [TEXT_COL, MARKUP_COL]):
renderer = Gtk.CellRendererText()
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
if self._column_names[pair[1]][3] == 0:
column = Gtk.TreeViewColumn(name, renderer, text=pair[1])
else:
column = Gtk.TreeViewColumn(name, renderer, markup=pair[1])
if not self._column_names[pair[1]][4] == -1:
#apply weight attribute
column.add_attribute(renderer, "weight",
self._column_names[pair[1]][4])
elif self._column_names[pair[1]][3] == ICON_COL:
self.col_icons[pair[1]] = col_icon
self.pb_renderer = Gtk.CellRendererPixbuf()
column = Gtk.TreeViewColumn(name, self.pb_renderer)
column.set_cell_data_func(self.pb_renderer, self.icon_func, pair[1])
else:
column = Gtk.TreeViewColumn(name, renderer, markup=pair[1])
if not self._column_names[pair[1]][4] == -1:
#apply weight attribute
column.add_attribute(renderer, "weight",
self._column_names[pair[1]][4])
# insert the colum into the tree
column.set_resizable(True)
raise NotImplementedError, 'Unknown column type'
if col_icon is not None:
image = Gtk.Image()
image.set_from_stock(col_icon, Gtk.IconSize.MENU)
image.set_tooltip_text(name)
image.show()
column.set_widget(image)
column.set_resizable(False)
else:
# insert the colum into the tree
column.set_resizable(True)
column.set_clickable(True)
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
#column.set_min_width(self._column_names[pair[1]][2])
@ -493,6 +522,18 @@ class EmbeddedList(ButtonTab):
self.tree.append_column(column)
self.track_ref_for_deletion("columns")
def icon_func(self, column, renderer, model, iter_, col_num):
'''
Set the stock icon property of the cell renderer. We use a cell data
function because there is a problem returning None from a model.
'''
stock_id = model.get_value(iter_, col_num)
if stock_id == '' or stock_id == False:
stock_id = None
elif stock_id == True:
stock_id = self.col_icons[col_num]
renderer.set_property('stock_id', stock_id)
def construct_model(self):
"""
Method that creates the model using the passed build_model parameter

View File

@ -39,6 +39,7 @@ from gi.repository import GObject
from gramps.gen.lib import Event, EventRef, EventRoleType, EventType
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .embeddedlist import TEXT_COL, MARKUP_COL, ICON_COL
from .groupembeddedlist import GroupEmbeddedList
from .eventrefmodel import EventRefModel
from ...dbguielement import DbGUIElement
@ -72,18 +73,19 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Description'), -1, 240, 0, EventRefModel.COL_FONTWEIGHT[0]),
(_('Type'), EventRefModel.COL_TYPE[0], 100, 0,
EventRefModel.COL_FONTWEIGHT[0]),
(_('ID'), EventRefModel.COL_GID[0], 60, 0,
EventRefModel.COL_FONTWEIGHT[0]),
(_('Date'), EventRefModel.COL_SORTDATE[0], 150, 1, -1),
(_('Place'), EventRefModel.COL_PLACE[0], 150, 0, -1),
(_('Role'), EventRefModel.COL_ROLE[0], 80, 0, -1),
(_('Description'), -1, 240, TEXT_COL,
EventRefModel.COL_FONTWEIGHT[0], None),
(_('Type'), EventRefModel.COL_TYPE[0], 100, TEXT_COL,
EventRefModel.COL_FONTWEIGHT[0], None),
(_('ID'), EventRefModel.COL_GID[0], 60, TEXT_COL,
EventRefModel.COL_FONTWEIGHT[0], None),
(_('Date'), EventRefModel.COL_SORTDATE[0], 150, MARKUP_COL, -1, None),
(_('Place'), EventRefModel.COL_PLACE[0], 150, TEXT_COL, -1, None),
(_('Role'), EventRefModel.COL_ROLE[0], 80, TEXT_COL, -1, None),
None,
None,
None,
(_('Age'), EventRefModel.COL_SORTAGE[0], 60, 0, -1),
(_('Age'), EventRefModel.COL_SORTAGE[0], 60, TEXT_COL, -1, None),
None
]

View File

@ -47,7 +47,7 @@ from gi.repository import GObject
#
#-------------------------------------------------------------------------
from ...utils import is_right_click
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#

View File

@ -37,7 +37,7 @@ from gi.repository import GObject
from gramps.gen.lib import LdsOrd
from gramps.gen.errors import WindowActiveError
from .ldsmodel import LdsModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -60,11 +60,11 @@ class LdsEmbedList(EmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Type'), 0, 150, 0, -1),
(_('Date'), 1, 150, 1, -1),
(_('Status'), 3, 75, 0, -1),
(_('Temple'), 2, 200, 0, -1),
(_('Place'), 3, 100, 0, -1),
(_('Type'), 0, 150, TEXT_COL, -1, None),
(_('Date'), 1, 150, MARKUP_COL, -1, None),
(_('Status'), 3, 75, TEXT_COL, -1, None),
(_('Temple'), 2, 200, TEXT_COL, -1, None),
(_('Place'), 3, 100, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data):

View File

@ -38,7 +38,7 @@ from gramps.gen.lib import Location
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .locationmodel import LocationModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -53,12 +53,12 @@ class LocationEmbedList(EmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Street'), 0, 150, 0, -1),
(_('Locality'), 1, 100, 0, -1),
(_('City'), 2, 100, 0, -1),
(_('County'), 3, 100, 0, -1),
(_('State'), 4, 100, 0, -1),
(_('Country'), 5, 75, 0, -1),
(_('Street'), 0, 150, TEXT_COL, -1, None),
(_('Locality'), 1, 100, TEXT_COL, -1, None),
(_('City'), 2, 100, TEXT_COL, -1, None),
(_('County'), 3, 100, TEXT_COL, -1, None),
(_('State'), 4, 100, TEXT_COL, -1, None),
(_('Country'), 5, 75, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data):

View File

@ -46,6 +46,7 @@ from gramps.gen.lib import Name, Surname
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .namemodel import NameModel
from .embeddedlist import TEXT_COL, MARKUP_COL, ICON_COL
from .groupembeddedlist import GroupEmbeddedList
#-------------------------------------------------------------------------
@ -70,13 +71,13 @@ class NameEmbedList(GroupEmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Name'), -1, 250, 0, NameModel.COL_FONTWEIGHT[0]),
(_('Type'), NameModel.COL_TYPE[0], 100, 0, -1),
(_('Name'), -1, 250, TEXT_COL, NameModel.COL_FONTWEIGHT[0], None),
(_('Type'), NameModel.COL_TYPE[0], 100, TEXT_COL, -1, None),
None,
None,
(_('Group As'), NameModel.COL_GROUPAS[0],100, 0, -1),
(_('Source'), NameModel.COL_HASSOURCE[0],60, 0, -1),
(_('Notes Preview'), NameModel.COL_NOTEPREVIEW[0], 250, 0, -1),
(_('Group As'), NameModel.COL_GROUPAS[0],100, TEXT_COL, -1, None),
(_('Source'), NameModel.COL_HASSOURCE[0],60, TEXT_COL, -1, None),
(_('Notes Preview'), NameModel.COL_NOTEPREVIEW[0], 250, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data, person, callback):

View File

@ -45,7 +45,7 @@ from gramps.gen.lib import Note
from ...dbguielement import DbGUIElement
from ...selectors import SelectorFactory
from .notemodel import NoteModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
from ...ddtargets import DdTargets
#-------------------------------------------------------------------------
@ -75,8 +75,8 @@ class NoteTab(EmbeddedList, DbGUIElement):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Type'), 0, 100, 0, -1),
(_('Preview'), 1, 200, 0, -1),
(_('Type'), 0, 100, TEXT_COL, -1, None),
(_('Preview'), 1, 200, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data, callertitle=None,

View File

@ -38,7 +38,7 @@ from gramps.gen.lib import PersonRef
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .personrefmodel import PersonRefModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -61,9 +61,9 @@ class PersonRefEmbedList(EmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text
_column_names = [
(_('Name'), 0, 250, 0, -1),
(_('ID'), 1, 100, 0, -1),
(_('Association'), 2, 100, 0, -1),
(_('Name'), 0, 250, TEXT_COL, -1, None),
(_('ID'), 1, 100, TEXT_COL, -1, None),
(_('Association'), 2, 100, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data):

View File

@ -40,7 +40,7 @@ from ...selectors import SelectorFactory
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .reporefmodel import RepoRefModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -65,10 +65,10 @@ class RepoEmbedList(EmbeddedList, DbGUIElement):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('ID'), 0, 75, 0, -1),
(_('Title'), 1, 200, 0, -1),
(_('Call Number'), 2, 125, 0, -1),
(_('Type'), 3, 100, 0, -1),
(_('ID'), 0, 75, TEXT_COL, -1, None),
(_('Title'), 1, 200, TEXT_COL, -1, None),
(_('Call Number'), 2, 125, TEXT_COL, -1, None),
(_('Type'), 3, 100, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, obj):

View File

@ -38,7 +38,7 @@ from gramps.gen.lib import SrcAttribute
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .attrmodel import AttrModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -47,7 +47,7 @@ from .embeddedlist import EmbeddedList
#-------------------------------------------------------------------------
class SrcAttrEmbedList(EmbeddedList):
_HANDLE_COL = 2
_HANDLE_COL = 3
_DND_TYPE = DdTargets.SRCATTRIBUTE
_MSG = {
@ -59,10 +59,11 @@ class SrcAttrEmbedList(EmbeddedList):
}
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
# (name, sortcol in model, width, markup/text, weigth_col, icon
_column_names = [
(_('Type'), 0, 250, 0, -1),
(_('Value'), 1, 200, 0, -1),
(_('Type'), 0, 250, TEXT_COL, -1, None),
(_('Value'), 1, 200, TEXT_COL, -1, None),
(_('Private'), 2, 30, ICON_COL, -1, 'gramps-lock')
]
def __init__(self, dbstate, uistate, track, data):
@ -90,7 +91,7 @@ class SrcAttrEmbedList(EmbeddedList):
return self.data
def column_order(self):
return ((1, 0), (1, 1))
return ((1, 2), (1, 0), (1, 1))
def add_button_clicked(self, obj):
pname = ''

View File

@ -47,7 +47,7 @@ _ENTER = Gdk.keyval_from_name("Enter")
#
#-------------------------------------------------------------------------
from .surnamemodel import SurnameModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
from ...ddtargets import DdTargets
from gramps.gen.lib import Surname, NameOriginType
from gramps.gen.constfunc import conv_to_unicode
@ -73,9 +73,9 @@ class SurnameTab(EmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text
_column_names = [
(_('Prefix'), -1, 150, 0, -1),
(_('Surname'), -1, 250, 0, -1),
(_('Connector'), -1, 100, 0, -1),
(_('Prefix'), -1, 150, TEXT_COL, -1, None),
(_('Surname'), -1, 250, TEXT_COL, -1, None),
(_('Connector'), -1, 100, TEXT_COL, -1, None),
]
_column_combo = (_('Origin'), -1, 150, 3) # name, sort, width, modelcol
_column_toggle = (_('Name|Primary'), -1, 80, 4)

View File

@ -39,7 +39,7 @@ from gramps.gen.lib import Url
from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets
from .webmodel import WebModel
from .embeddedlist import EmbeddedList
from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
#
@ -63,9 +63,9 @@ class WebEmbedList(EmbeddedList):
#index = column in model. Value =
# (name, sortcol in model, width, markup/text, weigth_col
_column_names = [
(_('Type') , 0, 100, 0, -1),
(_('Path') , 1, 200, 0, -1),
(_('Description'), 2, 150, 0, -1),
(_('Type') , 0, 100, TEXT_COL, -1, None),
(_('Path') , 1, 200, TEXT_COL, -1, None),
(_('Description'), 2, 150, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data):