Removed ListColors, and incorporated it into Sorter
svn: r1045
This commit is contained in:
parent
22add25c53
commit
b07b287d36
@ -51,7 +51,7 @@ from Date import *
|
||||
|
||||
import const
|
||||
import Utils
|
||||
import ListColors
|
||||
import Sorter
|
||||
|
||||
from intl import gettext
|
||||
_ = gettext
|
||||
@ -289,13 +289,13 @@ def loadConfig(call):
|
||||
if en == None:
|
||||
en = 0
|
||||
|
||||
ListColors.set_enable(en)
|
||||
Sorter.set_enable(en)
|
||||
|
||||
ListColors.oddfg = get_config_color(ODDFGCOLOR,(0,0,0))
|
||||
ListColors.oddbg = get_config_color(ODDBGCOLOR,(0xffff,0xffff,0xffff))
|
||||
ListColors.evenfg = get_config_color(EVENFGCOLOR,(0,0,0))
|
||||
ListColors.evenbg = get_config_color(EVENBGCOLOR,(0xffff,0xffff,0xffff))
|
||||
ListColors.ancestorfg = get_config_color(ANCESTORFGCOLOR,(0,0,0))
|
||||
Sorter.oddfg = get_config_color(ODDFGCOLOR,(0,0,0))
|
||||
Sorter.oddbg = get_config_color(ODDBGCOLOR,(0xffff,0xffff,0xffff))
|
||||
Sorter.evenfg = get_config_color(EVENFGCOLOR,(0,0,0))
|
||||
Sorter.evenbg = get_config_color(EVENBGCOLOR,(0xffff,0xffff,0xffff))
|
||||
Sorter.ancestorfg = get_config_color(ANCESTORFGCOLOR,(0,0,0))
|
||||
|
||||
if paper_preference == None:
|
||||
paper_preference = "Letter"
|
||||
@ -774,31 +774,26 @@ class GrampsPreferences:
|
||||
self.top.get_widget("resemail").set_text(cemail)
|
||||
|
||||
cwidget = self.top.get_widget(ODDFGCOLOR)
|
||||
cwidget.set_i16(ListColors.oddfg[0],ListColors.oddfg[1],\
|
||||
ListColors.oddfg[2],0xffff)
|
||||
cwidget.set_i16(Sorter.oddfg[0],Sorter.oddfg[1],Sorter.oddfg[2],0xffff)
|
||||
|
||||
cwidget = self.top.get_widget(ODDBGCOLOR)
|
||||
cwidget.set_i16(ListColors.oddbg[0],ListColors.oddbg[1],\
|
||||
ListColors.oddbg[2],0xffff)
|
||||
cwidget.set_i16(Sorter.oddbg[0],Sorter.oddbg[1],Sorter.oddbg[2],0xffff)
|
||||
|
||||
cwidget = self.top.get_widget(EVENFGCOLOR)
|
||||
cwidget.set_i16(ListColors.evenfg[0],ListColors.evenfg[1],\
|
||||
ListColors.evenfg[2],0xffff)
|
||||
cwidget.set_i16(Sorter.evenfg[0],Sorter.evenfg[1],Sorter.evenfg[2],0xffff)
|
||||
|
||||
cwidget = self.top.get_widget(EVENBGCOLOR)
|
||||
cwidget.set_i16(ListColors.evenbg[0],ListColors.evenbg[1],\
|
||||
ListColors.evenbg[2],0xffff)
|
||||
cwidget.set_i16(Sorter.evenbg[0],Sorter.evenbg[1],Sorter.evenbg[2],0xffff)
|
||||
|
||||
cwidget = self.top.get_widget(ANCESTORFGCOLOR)
|
||||
cwidget.set_i16(ListColors.ancestorfg[0],ListColors.ancestorfg[1],\
|
||||
ListColors.ancestorfg[2],0xffff)
|
||||
cwidget.set_i16(Sorter.ancestorfg[0],Sorter.ancestorfg[1],Sorter.ancestorfg[2],0xffff)
|
||||
|
||||
self.top.get_widget("enableColors").set_active(ListColors.get_enable())
|
||||
self.top.get_widget(ODDFGCOLOR).set_sensitive(ListColors.get_enable())
|
||||
self.top.get_widget(ODDBGCOLOR).set_sensitive(ListColors.get_enable())
|
||||
self.top.get_widget(EVENBGCOLOR).set_sensitive(ListColors.get_enable())
|
||||
self.top.get_widget(EVENFGCOLOR).set_sensitive(ListColors.get_enable())
|
||||
self.top.get_widget(ANCESTORFGCOLOR).set_sensitive(ListColors.get_enable())
|
||||
self.top.get_widget("enableColors").set_active(Sorter.get_enable())
|
||||
self.top.get_widget(ODDFGCOLOR).set_sensitive(Sorter.get_enable())
|
||||
self.top.get_widget(ODDBGCOLOR).set_sensitive(Sorter.get_enable())
|
||||
self.top.get_widget(EVENBGCOLOR).set_sensitive(Sorter.get_enable())
|
||||
self.top.get_widget(EVENFGCOLOR).set_sensitive(Sorter.get_enable())
|
||||
self.top.get_widget(ANCESTORFGCOLOR).set_sensitive(Sorter.get_enable())
|
||||
|
||||
self.top.get_widget("dbdir").gtk_entry().set_text(db_dir)
|
||||
self.top.get_widget("repdir").gtk_entry().set_text(report_dir)
|
||||
@ -1049,20 +1044,20 @@ class GrampsPreferences:
|
||||
phone = self.top.get_widget("resphone").get_text()
|
||||
email = self.top.get_widget("resemail").get_text()
|
||||
|
||||
ListColors.set_enable(self.top.get_widget("enableColors").get_active())
|
||||
set_bool("/gramps/color/enableColors",ListColors.get_enable())
|
||||
Sorter.set_enable(self.top.get_widget("enableColors").get_active())
|
||||
set_bool("/gramps/color/enableColors",Sorter.get_enable())
|
||||
|
||||
ListColors.oddfg = self.top.get_widget(ODDFGCOLOR).get_i16()
|
||||
ListColors.oddbg = self.top.get_widget(ODDBGCOLOR).get_i16()
|
||||
ListColors.evenfg = self.top.get_widget(EVENFGCOLOR).get_i16()
|
||||
ListColors.evenbg = self.top.get_widget(EVENBGCOLOR).get_i16()
|
||||
ListColors.ancestorfg = self.top.get_widget(ANCESTORFGCOLOR).get_i16()
|
||||
Sorter.oddfg = self.top.get_widget(ODDFGCOLOR).get_i16()
|
||||
Sorter.oddbg = self.top.get_widget(ODDBGCOLOR).get_i16()
|
||||
Sorter.evenfg = self.top.get_widget(EVENFGCOLOR).get_i16()
|
||||
Sorter.evenbg = self.top.get_widget(EVENBGCOLOR).get_i16()
|
||||
Sorter.ancestorfg = self.top.get_widget(ANCESTORFGCOLOR).get_i16()
|
||||
|
||||
save_config_color(ODDFGCOLOR,ListColors.oddfg)
|
||||
save_config_color(ODDBGCOLOR,ListColors.oddbg)
|
||||
save_config_color(EVENFGCOLOR,ListColors.evenfg)
|
||||
save_config_color(EVENBGCOLOR,ListColors.evenbg)
|
||||
save_config_color(ANCESTORFGCOLOR,ListColors.ancestorfg)
|
||||
save_config_color(ODDFGCOLOR,Sorter.oddfg)
|
||||
save_config_color(ODDBGCOLOR,Sorter.oddbg)
|
||||
save_config_color(EVENFGCOLOR,Sorter.evenfg)
|
||||
save_config_color(EVENBGCOLOR,Sorter.evenbg)
|
||||
save_config_color(ANCESTORFGCOLOR,Sorter.ancestorfg)
|
||||
|
||||
set_string("/gramps/researcher/name",name)
|
||||
set_string("/gramps/researcher/addr",addr)
|
||||
|
@ -1,71 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
_enable = 0
|
||||
oddbg = (0xffff,0xffff,0xffff)
|
||||
evenbg = (0xffff,0xffff,0xffff)
|
||||
oddfg = (0,0,0)
|
||||
evenfg = (0,0,0)
|
||||
ancestorfg = (0,0,0)
|
||||
|
||||
def to_signed(a):
|
||||
if a & 0x8000:
|
||||
return a - 0x10000
|
||||
else:
|
||||
return a
|
||||
|
||||
class ColorList:
|
||||
def __init__(self,clist,increment):
|
||||
self.index = 0
|
||||
self.modval = 2*increment
|
||||
self.increment = increment
|
||||
self.clist = clist
|
||||
self.color_ok = 1
|
||||
try:
|
||||
cmap = clist.get_colormap()
|
||||
self.oddbg = cmap.alloc(to_signed(oddbg[0]),to_signed(oddbg[1]),to_signed(oddbg[2]))
|
||||
self.oddfg = cmap.alloc(to_signed(oddfg[0]),to_signed(oddfg[1]),to_signed(oddfg[2]))
|
||||
self.evenbg = cmap.alloc(to_signed(evenbg[0]),to_signed(evenbg[1]),to_signed(evenbg[2]))
|
||||
self.evenfg = cmap.alloc(to_signed(evenfg[0]),to_signed(evenfg[1]),to_signed(evenfg[2]))
|
||||
except OverflowError:
|
||||
self.color_ok = 0
|
||||
|
||||
def add(self,list):
|
||||
self.clist.append(list)
|
||||
if _enable and self.color_ok:
|
||||
if self.index % self.modval < self.increment:
|
||||
self.clist.set_background(self.index,self.oddbg)
|
||||
self.clist.set_foreground(self.index,self.oddfg)
|
||||
else:
|
||||
self.clist.set_background(self.index,self.evenbg)
|
||||
self.clist.set_foreground(self.index,self.evenfg)
|
||||
self.index = self.index + 1
|
||||
|
||||
def add_with_data(self,list,data):
|
||||
self.add(list)
|
||||
self.clist.set_row_data(self.index-1,data)
|
||||
|
||||
def set_enable(val):
|
||||
global _enable
|
||||
|
||||
_enable = val
|
||||
|
||||
def get_enable():
|
||||
return _enable
|
@ -38,7 +38,6 @@ import GTK
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import GrampsCfg
|
||||
import ListColors
|
||||
|
||||
class Sorter:
|
||||
|
||||
@ -92,25 +91,25 @@ class Sorter:
|
||||
self.clist.freeze()
|
||||
self.clist.sort()
|
||||
self.clist.sort()
|
||||
if ListColors.get_enable():
|
||||
if _enable:
|
||||
try:
|
||||
loddbg = ListColors.oddbg
|
||||
loddfg = ListColors.oddfg
|
||||
levenbg = ListColors.evenbg
|
||||
levenfg = ListColors.evenfg
|
||||
loddbg = oddbg
|
||||
loddfg = oddfg
|
||||
levenbg = evenbg
|
||||
levenfg = evenfg
|
||||
|
||||
cmap = self.clist.get_colormap()
|
||||
oddbg = cmap.alloc(loddbg[0],loddbg[1],loddbg[2])
|
||||
oddfg = cmap.alloc(loddfg[0],loddfg[1],loddfg[2])
|
||||
evenbg = cmap.alloc(levenbg[0],levenbg[1],levenbg[2])
|
||||
evenfg = cmap.alloc(levenfg[0],levenfg[1],levenfg[2])
|
||||
toddbg = cmap.alloc(loddbg[0],loddbg[1],loddbg[2])
|
||||
toddfg = cmap.alloc(loddfg[0],loddfg[1],loddfg[2])
|
||||
tevenbg = cmap.alloc(levenbg[0],levenbg[1],levenbg[2])
|
||||
tevenfg = cmap.alloc(levenfg[0],levenfg[1],levenfg[2])
|
||||
rows = self.clist.rows
|
||||
for i in range(0,rows,2):
|
||||
self.clist.set_background(i,oddbg)
|
||||
self.clist.set_foreground(i,oddfg)
|
||||
self.clist.set_background(i,toddbg)
|
||||
self.clist.set_foreground(i,toddfg)
|
||||
if i != rows:
|
||||
self.clist.set_background(i+1,evenbg)
|
||||
self.clist.set_foreground(i+1,evenfg)
|
||||
self.clist.set_background(i+1,tevenbg)
|
||||
self.clist.set_foreground(i+1,tevenfg)
|
||||
except OverflowError:
|
||||
pass
|
||||
self.clist.thaw()
|
||||
@ -171,3 +170,29 @@ class ChildSorter(Sorter):
|
||||
"""
|
||||
Sorter.change_sort(self,column,change)
|
||||
self.clist.set_reorderable(self.col == 0)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Color management
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_enable = 0
|
||||
oddbg = (0xffff,0xffff,0xffff)
|
||||
evenbg = (0xffff,0xffff,0xffff)
|
||||
oddfg = (0,0,0)
|
||||
evenfg = (0,0,0)
|
||||
ancestorfg = (0,0,0)
|
||||
|
||||
def to_signed(a):
|
||||
if a & 0x8000:
|
||||
return a - 0x10000
|
||||
else:
|
||||
return a
|
||||
|
||||
def set_enable(val):
|
||||
global _enable
|
||||
_enable = val
|
||||
|
||||
def get_enable():
|
||||
return _enable
|
||||
|
@ -21,7 +21,6 @@
|
||||
import libglade
|
||||
import gtk
|
||||
import Utils
|
||||
import ListColors
|
||||
import const
|
||||
|
||||
from TextDoc import *
|
||||
@ -61,15 +60,18 @@ class StyleListDisplay:
|
||||
self.list.clear()
|
||||
|
||||
self.list.set_data("i",0)
|
||||
box = ListColors.ColorList(self.list,1)
|
||||
sheet = self.sheetlist.get_style_sheet("default")
|
||||
box.add_with_data(["default"],("default",sheet))
|
||||
self.list.append(["default"])
|
||||
self.list.set_row_data(0,("default",sheet))
|
||||
|
||||
index = 1
|
||||
for style in self.sheetlist.get_style_names():
|
||||
if style == "default":
|
||||
continue
|
||||
sheet = self.sheetlist.get_style_sheet(style)
|
||||
box.add_with_data([style],(style,sheet))
|
||||
self.list.append([style])
|
||||
self.list.set_row_data(index,(style,sheet))
|
||||
index = index + 1
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user