Remember last sort column, handle photo descriptions better

svn: r554
This commit is contained in:
Don Allingham 2001-11-06 15:50:42 +00:00
parent ca7c1d5fe8
commit e9f302f13d
9 changed files with 255 additions and 180 deletions

View File

@ -63,6 +63,7 @@ class AddMediaObject:
self.description = self.glade.get_widget("photoDescription")
self.image = self.glade.get_widget("image")
self.update = update
self.temp_name = ""
self.glade.signal_autoconnect({
"on_savephoto_clicked" : self.on_savephoto_clicked,
@ -104,6 +105,15 @@ class AddMediaObject:
def on_name_changed(self,obj):
filename = self.glade.get_widget("fname").get_text()
basename = os.path.basename(filename)
(root,ext) = os.path.splitext(basename)
old_title = self.description.get_text()
if old_title == "" or old_title == self.temp_name:
self.description.set_text(root)
self.temp_name = root
if os.path.isfile(filename):
type = utils.get_mime_type(filename)
if type[0:5] == "image":

View File

@ -793,7 +793,21 @@ def get_config_color(name,defval):
return defval
else:
return (r,g,b)
def get_sort_cols(name,col,dir):
c = get_int("/gramps/sort/%s_col" % name)
if c == None:
c = col
d = get_int("/gramps/sort/%s_dir" % name)
if d == None:
d = dir
return (c,d)
def save_sort_cols(name,col,dir):
set_int("/gramps/sort/%s_col" % name, col)
set_int("/gramps/sort/%s_dir" % name, dir)
sync()
#-------------------------------------------------------------------------
#
#

View File

@ -81,6 +81,7 @@ class ImageSelect:
self.image = self.glade.get_widget("image")
self.description = self.glade.get_widget("photoDescription")
self.external = self.glade.get_widget("private")
self.temp_name = ""
self.glade.signal_autoconnect({
"on_savephoto_clicked" : self.on_savephoto_clicked,
@ -99,6 +100,15 @@ class ImageSelect:
#-------------------------------------------------------------------------
def on_name_changed(self, obj):
filename = self.fname.get_text()
basename = os.path.basename(filename)
(root,ext) = os.path.splitext(basename)
old_title = self.description.get_text()
if old_title == "" or old_title == self.temp_name:
self.description.set_text(root)
self.temp_name = root
if os.path.isfile(filename):
type = utils.get_mime_type(filename)
if type[0:5] == "image":
@ -114,7 +124,7 @@ class ImageSelect:
#-------------------------------------------------------------------------
def on_savephoto_clicked(self, obj):
filename = self.glade.get_widget("photosel").get_full_path(0)
description = self.glade.get_widget("photoDescription").get_text()
description = self.description.get_text()
if os.path.exists(filename) == 0:
GnomeErrorDialog(_("That is not a valid file name."));

View File

@ -51,8 +51,6 @@ class MediaView:
self.sort_arrow = [self.mdescr_arrow, self.mid_arrow,
self.mtype_arrow, self.mpath_arrow]
self.sort_map = [5,1,2,3,-1]
self.sort_col = 5
self.sort_dir = GTK.SORT_ASCENDING
self.media_list.connect('click-column',self.click_column)
self.mid_arrow.hide()
@ -76,6 +74,24 @@ class MediaView:
self.media_list.set_column_visibility(5,0)
self.media_list.connect('button-press-event',self.on_button_press_event)
# Restore the previous sort column
self.sort_col,self.sort_dir = Config.get_sort_cols("media",0,GTK.SORT_ASCENDING)
self.media_list.set_sort_type(self.sort_dir)
self.media_list.set_sort_column(self.sort_map[self.sort_col])
self.set_arrow(self.sort_col)
def set_arrow(self,column):
for a in self.sort_arrow:
a.hide()
a = self.sort_arrow[column]
a.show()
if self.sort_dir == GTK.SORT_ASCENDING:
a.set(GTK.ARROW_DOWN,2)
else:
a.set(GTK.ARROW_UP,2)
def click_column(self,obj,column):
new_col = self.sort_map[column]
@ -95,19 +111,12 @@ class MediaView:
else:
self.sort_dir = GTK.SORT_ASCENDING
for a in self.sort_arrow:
a.hide()
a = self.sort_arrow[column]
a.show()
if self.sort_dir == GTK.SORT_ASCENDING:
a.set(GTK.ARROW_DOWN,2)
else:
a.set(GTK.ARROW_UP,2)
self.set_arrow(column)
obj.set_sort_type(self.sort_dir)
obj.set_sort_column(new_col)
self.sort_col = new_col
self.sort_col = column
Config.save_sort_cols("media",self.sort_col,self.sort_dir)
obj.sort()
if data:
row = obj.find_row_from_data(data)

View File

@ -45,12 +45,9 @@ class PlaceView:
self.country_arrow = glade.get_widget("country_arrow")
self.update_display= update
self.place_arrows = [ self.place_arrow, self.place_id_arrow, self.parish_arrow,
self.city_arrow, self.county_arrow, self.state_arrow,
self.country_arrow ]
self.sort_column = 0
self.sort_direct = GTK.SORT_ASCENDING
self.sort_arrow = [ self.place_arrow, self.place_id_arrow, self.parish_arrow,
self.city_arrow, self.county_arrow, self.state_arrow,
self.country_arrow ]
self.place_list.set_column_visibility(7,0)
self.place_list.set_column_visibility(8,0)
@ -59,12 +56,17 @@ class PlaceView:
self.place_list.set_column_visibility(11,0)
self.place_list.set_column_visibility(12,0)
self.place_list.set_column_visibility(13,0)
self.place_list.set_sort_column(self.sort_column+7)
self.place_list.set_sort_type(self.sort_direct)
self.place_list.connect('button-press-event',self.on_button_press_event)
self.place_list.connect('select-row',self.select_row)
self.active = None
# Restore the previous sort column
self.sort_col,self.sort_dir = Config.get_sort_cols("place",0,GTK.SORT_ASCENDING)
self.place_list.set_sort_column(self.sort_col+7)
self.place_list.set_sort_type(self.sort_dir)
self.set_arrow(self.sort_col)
def load_places(self):
if len(self.place_list.selection) == 0:
current_row = 0
@ -126,6 +128,17 @@ class PlaceView:
EditPlace.EditPlace(self.active,self.db,
self.update_display_after_edit)
def set_arrow(self,column):
for a in self.sort_arrow:
a.hide()
a = self.sort_arrow[column]
a.show()
if self.sort_dir == GTK.SORT_ASCENDING:
a.set(GTK.ARROW_DOWN,2)
else:
a.set(GTK.ARROW_UP,2)
def on_click_column(self,obj,column):
obj.freeze()
if len(obj.selection):
@ -133,23 +146,22 @@ class PlaceView:
else:
sel = None
for a in self.place_arrows:
for a in self.sort_arrow:
a.hide()
arrow = self.place_arrows[column]
if self.sort_column == column:
arrow = self.sort_arrow[column]
if self.sort_col == column:
if self.sort_direct == GTK.SORT_DESCENDING:
self.sort_direct = GTK.SORT_ASCENDING
arrow.set(GTK.ARROW_DOWN,2)
else:
self.sort_direct = GTK.SORT_DESCENDING
arrow.set(GTK.ARROW_UP,2)
else:
self.sort_direct = GTK.SORT_ASCENDING
arrow.set(GTK.ARROW_DOWN,2)
self.sort_column = column
self.sort_col = column
self.set_arrow(column)
self.place_list.set_sort_type(self.sort_direct)
self.place_list.set_sort_column(self.sort_column + 7)
arrow.show()
self.place_list.set_sort_column(self.sort_col + 7)
Config.save_sort_cols("place",self.sort_col,self.sort_direct)
self.place_list.sort()
if sel:
self.place_list.moveto(self.place_list.find_row_from_data(sel))

View File

@ -66,11 +66,26 @@ class SourceView:
self.id_arrow.hide()
self.author_arrow.hide()
self.sort_map = [3,1,4,-1]
self.sort_dir = GTK.SORT_ASCENDING
self.sort_col = 3
self.sort_arrow = [self.title_arrow, self.id_arrow, self.author_arrow]
self.source_list.connect('click-column',self.click_column)
self.sort_col,self.sort_dir = Config.get_sort_cols("source",3,GTK.SORT_ASCENDING)
self.source_list.set_sort_type(self.sort_dir)
self.source_list.set_sort_column(self.sort_map[self.sort_col])
self.set_arrow(self.sort_col)
def set_arrow(self,column):
for a in self.sort_arrow:
a.hide()
a = self.sort_arrow[column]
a.show()
if self.sort_dir == GTK.SORT_ASCENDING:
a.set(GTK.ARROW_DOWN,2)
else:
a.set(GTK.ARROW_UP,2)
def click_column(self,obj,column):
new_col = self.sort_map[column]
@ -90,19 +105,12 @@ class SourceView:
else:
self.sort_dir = GTK.SORT_ASCENDING
for a in self.sort_arrow:
a.hide()
a = self.sort_arrow[column]
a.show()
if self.sort_dir == GTK.SORT_ASCENDING:
a.set(GTK.ARROW_DOWN,2)
else:
a.set(GTK.ARROW_UP,2)
self.set_arrow(column)
obj.set_sort_type(self.sort_dir)
obj.set_sort_column(new_col)
self.sort_col = new_col
Config.save_sort_cols("source",self.sort_col,self.sort_dir)
obj.sort()
if data:
row = obj.find_row_from_data(data)

View File

@ -3339,32 +3339,6 @@
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label271</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label272</name>
@ -3573,32 +3547,6 @@
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label266</name>
<label>Description</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0</yalign>
<xpad>0</xpad>
<ypad>2</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>5</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label265</name>
@ -3703,6 +3651,58 @@
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label266</name>
<label>Description</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0</yalign>
<xpad>0</xpad>
<ypad>2</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>5</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label271</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
</widget>
</widget>
</widget>

View File

@ -111,7 +111,7 @@ deathArrow = None
dateArrow = None
merge_button = None
sort_column = 5
sort_column = 0
sort_direct = SORT_ASCENDING
DataFilter = Filter.Filter("")
c_birth_order = 0
@ -156,7 +156,6 @@ def find_goto_to(person):
#-------------------------------------------------------------------------
def on_merge_activate(obj):
"""Calls up the merge dialog for the selection"""
page = notebook.get_current_page()
if page == 0:
if len(person_list.selection) != 2:
@ -729,39 +728,42 @@ def on_person_list_select_row(obj,row,b,c):
# orientation, and then call apply_filter to redraw the list
#
#-------------------------------------------------------------------------
def on_person_list_click_column(obj,column):
if column == 0:
change_sort(5,nameArrow)
elif column == 1:
change_sort(1,idArrow)
elif column == 2:
change_sort(2,genderArrow)
elif column == 3:
change_sort(6,dateArrow)
elif column == 4:
change_sort(7,deathArrow)
else:
return
sort_person_list()
if id2col.has_key(active_person):
row = person_list.find_row_from_data(id2col[active_person])
person_list.moveto(row)
change_sort(column)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def change_sort(column,arrow):
global sort_direct
global sort_column
col_map = [ 5, 1, 2, 6, 7 ]
for a in [ nameArrow, genderArrow, deathArrow, dateArrow, idArrow ]:
def set_sort_arrow(column,direct):
col_arr = [ nameArrow, idArrow, genderArrow, dateArrow, deathArrow]
arrow = col_arr[column]
for a in col_arr:
if arrow != a:
a.hide()
arrow.show()
if direct == SORT_ASCENDING:
arrow.set(GTK.ARROW_DOWN,2)
else:
arrow.set(GTK.ARROW_UP,2)
def change_sort(column):
global sort_direct
global sort_column
col_arr = [ nameArrow, idArrow, genderArrow, dateArrow, deathArrow]
arrow = col_arr[column]
for a in col_arr:
if arrow != a:
a.hide()
arrow.show()
if sort_column == column:
if sort_direct == SORT_DESCENDING:
sort_direct = SORT_ASCENDING
@ -773,8 +775,15 @@ def change_sort(column,arrow):
sort_direct = SORT_ASCENDING
arrow.set(GTK.ARROW_DOWN,2)
sort_column = column
person_list.set_sort_column(col_map[column])
person_list.set_sort_type(sort_direct)
person_list.set_sort_column(sort_column)
sort_person_list()
if id2col.has_key(active_person):
row = person_list.find_row_from_data(id2col[active_person])
person_list.moveto(row)
Config.save_sort_cols("person",sort_column,sort_direct)
#-------------------------------------------------------------------------
#
@ -1855,6 +1864,7 @@ def main(arg):
global topWindow, preview, merge_button
global nameArrow, dateArrow, deathArrow, idArrow, genderArrow
global cNameArrow, cDateArrow
global sort_column, sort_direct
rc_parse(const.gtkrcFile)
database = RelDataBase()
@ -1864,6 +1874,8 @@ def main(arg):
Filter.load_filters(const.filtersDir)
Filter.load_filters(os.path.expanduser("~/.gramps/filters"))
(sort_column,sort_direct) = Config.get_sort_cols("person",sort_column,sort_direct)
gtop = libglade.GladeXML(const.gladeFile, "gramps")
Plugins.build_report_menu(gtop.get_widget("reports_menu"),menu_report)
@ -1896,9 +1908,6 @@ def main(arg):
person_list.set_column_visibility(5,0)
person_list.set_column_visibility(6,0)
person_list.set_column_visibility(7,0)
person_list.set_sort_column(sort_column)
person_list.set_sort_type(sort_direct)
fw = gtop.get_widget('filter')
filter_list.set_menu(Filter.build_filter_menu(on_filter_name_changed,fw))
@ -1908,6 +1917,9 @@ def main(arg):
topWindow.set_icon(GtkPixmap(topWindow,const.icon))
person_list.column_titles_active()
set_sort_arrow(sort_column,sort_direct)
Config.loadConfig(full_update)
gtop.signal_autoconnect({
"delete_event" : delete_event,
@ -1986,7 +1998,6 @@ def main(arg):
"on_writing_extensions_activate" : on_writing_extensions_activate,
})
Config.loadConfig(full_update)
person_list.set_column_visibility(1,Config.id_visible)
notebook.set_show_tabs(Config.usetabs)

View File

@ -232,7 +232,7 @@
<widget>
<class>GtkLabel</class>
<name>label118</name>
<label>Description</label>
<label>Title</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
@ -502,58 +502,6 @@
<row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<widget>
<class>GtkLabel</class>
<name>label126</name>
<label>Description</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>5</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label128</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label129</name>
@ -609,9 +557,10 @@
<widget>
<class>GtkLabel</class>
<name>description</name>
<width>350</width>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>True</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
@ -636,7 +585,7 @@
<class>GtkLabel</class>
<name>path</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
@ -836,6 +785,58 @@
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label126</name>
<label>Title</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0</yalign>
<xpad>5</xpad>
<ypad>5</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label128</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0</yalign>
<xpad>0</xpad>
<ypad>5</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
</widget>
</widget>
</widget>
@ -1683,7 +1684,7 @@
<widget>
<class>GtkLabel</class>
<name>label148</name>
<label>Description</label>
<label>Title</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>