Remove cancel button from progress dialogs

svn: r16699
This commit is contained in:
Nick Hall 2011-02-22 18:19:08 +00:00
parent 6080ccf3df
commit 1331f4d964

View File

@ -43,7 +43,7 @@ import gtk
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.ggettext import sgettext as _ from gen.ggettext import sgettext as _
from gen.lib import Tag from gen.lib import Tag
from gen.db import DbTxn, DbTransactionCancel from gen.db import DbTxn
from gui.dbguielement import DbGUIElement from gui.dbguielement import DbGUIElement
from ListModel import ListModel, NOSORT, COLOR, INTEGER from ListModel import ListModel, NOSORT, COLOR, INTEGER
import const import const
@ -264,21 +264,14 @@ class Tags(DbGUIElement):
popup_time=2) popup_time=2)
status = progressdlg.LongOpStatus(msg=_("Adding Tags"), status = progressdlg.LongOpStatus(msg=_("Adding Tags"),
total_steps=len(selected), total_steps=len(selected),
interval=len(selected)//20, interval=len(selected)//20)
can_cancel=True)
pmon.add_op(status) pmon.add_op(status)
tag = self.db.get_tag_from_handle(tag_handle) tag = self.db.get_tag_from_handle(tag_handle)
msg = _('Tag Selection (%s)') % tag.get_name() msg = _('Tag Selection (%s)') % tag.get_name()
try:
with DbTxn(msg, self.db) as trans: with DbTxn(msg, self.db) as trans:
for object_handle in selected: for object_handle in selected:
status.heartbeat() status.heartbeat()
if status.should_cancel():
raise DbTransactionCancel("User requests cancelation "
"of the transaction.")
view.add_tag(trans, object_handle, tag_handle) view.add_tag(trans, object_handle, tag_handle)
except DbTransactionCancel:
pass
status.end() status.end()
def cb_menu_position(menu, button): def cb_menu_position(menu, button):
@ -327,29 +320,30 @@ class OrganizeTagsDialog(object):
break break
# Save changed priority values # Save changed priority values
try: if self.__priorities_changed():
with DbTxn(_('Change Tag Priority'), self.db) as trans: with DbTxn(_('Change Tag Priority'), self.db) as trans:
if not self.__change_tag_priority(trans): self.__change_tag_priority(trans)
raise DbTransactionCancel("There was nothing to change.")
except DbTransactionCancel:
pass
self.top.destroy() self.top.destroy()
def __priorities_changed(self):
"""
Return True if the tag priorities have changed else return False.
"""
priorities = [row[0] for row in self.namemodel.model]
return priorities != range(len(self.namemodel.model))
def __change_tag_priority(self, trans): def __change_tag_priority(self, trans):
""" """
Change the priority of the tags. The order of the list corresponds to Change the priority of the tags. The order of the list corresponds to
the priority of the tags. The top tag in the list is the highest the priority of the tags. The top tag in the list is the highest
priority tag. priority tag.
""" """
changed = False
for new_priority, row in enumerate(self.namemodel.model): for new_priority, row in enumerate(self.namemodel.model):
if row[0] != new_priority: if row[0] != new_priority:
changed = True
tag = self.db.get_tag_from_handle(row[1]) tag = self.db.get_tag_from_handle(row[1])
tag.set_priority(new_priority) tag.set_priority(new_priority)
self.db.commit_tag(tag, trans) self.db.commit_tag(tag, trans)
return changed
def _populate_model(self): def _populate_model(self):
""" """
@ -505,18 +499,13 @@ class OrganizeTagsDialog(object):
popup_time=2) popup_time=2)
status = progressdlg.LongOpStatus(msg=_("Removing Tags"), status = progressdlg.LongOpStatus(msg=_("Removing Tags"),
total_steps=len(links), total_steps=len(links),
interval=len(links)//20, interval=len(links)//20)
can_cancel=True)
pmon.add_op(status) pmon.add_op(status)
msg = _('Delete Tag (%s)') % tag_name msg = _('Delete Tag (%s)') % tag_name
try:
with DbTxn(msg, self.db) as trans: with DbTxn(msg, self.db) as trans:
for classname, handle in links: for classname, handle in links:
status.heartbeat() status.heartbeat()
if status.should_cancel():
raise DbTransactionCancel("User requests "
"cancelation of the transaction.")
obj = fnc[classname][0](handle) # get from handle obj = fnc[classname][0](handle) # get from handle
obj.remove_tag(tag_handle) obj.remove_tag(tag_handle)
fnc[classname][1](obj, trans) # commit fnc[classname][1](obj, trans) # commit
@ -524,8 +513,6 @@ class OrganizeTagsDialog(object):
self.db.remove_tag(tag_handle, trans) self.db.remove_tag(tag_handle, trans)
self.__change_tag_priority(trans) self.__change_tag_priority(trans)
store.remove(iter_) store.remove(iter_)
except DbTransactionCancel:
pass
status.end() status.end()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------