Improve busy cursor code for Gtk3

svn: r20224
This commit is contained in:
Nick Hall 2012-08-16 18:39:21 +00:00
parent 7b1d5c3859
commit b7ab76bcf6
13 changed files with 40 additions and 39 deletions

View File

@ -97,7 +97,7 @@ class DbLoader(CLIDbLoader):
_LOG.error(str(msg) +"\n" + exc) _LOG.error(str(msg) +"\n" + exc)
def _begin_progress(self): def _begin_progress(self):
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.uistate.progress.show() self.uistate.progress.show()
self.uistate.pulse_progressbar(0) self.uistate.pulse_progressbar(0)
@ -105,7 +105,7 @@ class DbLoader(CLIDbLoader):
self.uistate.pulse_progressbar(value) self.uistate.pulse_progressbar(value)
def _end_progress(self): def _end_progress(self):
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
self.uistate.progress.hide() self.uistate.progress.hide()
def import_file(self): def import_file(self):

View File

@ -373,10 +373,13 @@ class DisplayState(Callback):
'Note': _("No active note"), 'Note': _("No active note"),
} }
BUSY_CURSOR = Gdk.Cursor.new(Gdk.CursorType.WATCH)
def __init__(self, window, status, progress, warnbtn, uimanager, def __init__(self, window, status, progress, warnbtn, uimanager,
progress_monitor, viewmanager=None): progress_monitor, viewmanager=None):
self.busy = False self.busy = False
self.cursor = None
self.viewmanager = viewmanager self.viewmanager = viewmanager
self.uimanager = uimanager self.uimanager = uimanager
self.progress_monitor = progress_monitor self.progress_monitor = progress_monitor
@ -518,10 +521,10 @@ class DisplayState(Callback):
else: else:
self.busy = value self.busy = value
if value: if value:
self.window.get_root_window().set_cursor(Gdk.Cursor.new( self.cursor = self.window.get_window().get_cursor()
Gdk.CursorType.WATCH)) self.window.get_window().set_cursor(self.BUSY_CURSOR)
else: else:
self.window.get_root_window().set_cursor(None) self.window.get_window().set_cursor(self.cursor)
process_pending_events() process_pending_events()
def set_open_widget(self, widget): def set_open_widget(self, widget):

View File

@ -106,9 +106,9 @@ class SidebarFilter(DbGUIElement):
pass pass
def clicked(self, obj): def clicked(self, obj):
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.clicked_func() self.clicked_func()
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
def clicked_func(self): def clicked_func(self):
pass pass

View File

@ -637,11 +637,11 @@ class ExportAssistant(Gtk.Assistant, ManagedWindow) :
page.set_child_visible(True) page.set_child_visible(True)
self.show_all() self.show_all()
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.set_busy_cursor(1) self.set_busy_cursor(1)
def post_save(self): def post_save(self):
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
self.set_busy_cursor(0) self.set_busy_cursor(0)
self.progressbar.hide() self.progressbar.hide()
self.writestarted = False self.writestarted = False

View File

@ -1021,14 +1021,14 @@ class ViewManager(CLIManager):
Backup the current file as a backup file. Backup the current file as a backup file.
""" """
if self.dbstate.db.has_changed: if self.dbstate.db.has_changed:
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.uistate.progress.show() self.uistate.progress.show()
self.uistate.push_message(self.dbstate, _("Autobackup...")) self.uistate.push_message(self.dbstate, _("Autobackup..."))
try: try:
backup(self.dbstate.db) backup(self.dbstate.db)
except DbException, msg: except DbException, msg:
ErrorDialog(_("Error saving backup data"), msg) ErrorDialog(_("Error saving backup data"), msg)
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
self.uistate.progress.hide() self.uistate.progress.hide()
def abort(self, obj=None): def abort(self, obj=None):
@ -1373,8 +1373,6 @@ class ViewManager(CLIManager):
self.dbstate.db.undo_history_callback = self.undo_history_update self.dbstate.db.undo_history_callback = self.undo_history_update
self.undo_history_close() self.undo_history_close()
self.uistate.window.get_root_window().set_cursor(None)
def _post_load_newdb(self, filename, filetype, title=None): def _post_load_newdb(self, filename, filetype, title=None):
""" """
The method called after load of a new database. The method called after load of a new database.
@ -1572,7 +1570,7 @@ class ViewManager(CLIManager):
yes_no = question.run() yes_no = question.run()
if not yes_no: if not yes_no:
return return
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.pulse_progressbar(0) self.pulse_progressbar(0)
self.uistate.progress.show() self.uistate.progress.show()
self.uistate.push_message(self.dbstate, _("Making backup...")) self.uistate.push_message(self.dbstate, _("Making backup..."))
@ -1589,7 +1587,7 @@ class ViewManager(CLIManager):
callback=self.pulse_progressbar), callback=self.pulse_progressbar),
strip_photos=0, compress=1) strip_photos=0, compress=1)
writer.write(filename) writer.write(filename)
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
self.uistate.progress.hide() self.uistate.progress.hide()
filename = get_unicode_path_from_env_var(filename) filename = get_unicode_path_from_env_var(filename)
self.uistate.push_message(self.dbstate, _("Backup saved to '%s'") % filename) self.uistate.push_message(self.dbstate, _("Backup saved to '%s'") % filename)
@ -1685,17 +1683,17 @@ class ViewManager(CLIManager):
""" """
Calls the undo function on the database Calls the undo function on the database
""" """
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.dbstate.db.undo() self.dbstate.db.undo()
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
def redo(self, obj): def redo(self, obj):
""" """
Calls the redo function on the database Calls the redo function on the database
""" """
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.dbstate.db.redo() self.dbstate.db.redo()
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
def undo_history(self, obj): def undo_history(self, obj):
""" """

View File

@ -523,7 +523,7 @@ class ListView(NavigationView):
prompt = q.run() prompt = q.run()
if not prompt: if not prompt:
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
for handle in self.selected_handles(): for handle in self.selected_handles():
(query, is_used, object) = self.remove_object_from_handle(handle) (query, is_used, object) = self.remove_object_from_handle(handle)
@ -539,15 +539,15 @@ class ListView(NavigationView):
#descr = object.get_description() #descr = object.get_description()
#if descr == "": #if descr == "":
descr = object.get_gramps_id() descr = object.get_gramps_id()
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
QuestionDialog(_('Delete %s?') % descr, msg, QuestionDialog(_('Delete %s?') % descr, msg,
_('_Delete Item'), query.query_response) _('_Delete Item'), query.query_response)
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
else: else:
query.query_response() query.query_response()
if not prompt: if not prompt:
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
def blist(self, store, path, iter, sel_list): def blist(self, store, path, iter, sel_list):
'''GtkTreeSelectionForeachFunc '''GtkTreeSelectionForeachFunc
@ -585,7 +585,7 @@ class ListView(NavigationView):
obj A TreeViewColumn object of the column clicked obj A TreeViewColumn object of the column clicked
data The column index data The column index
""" """
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.uistate.push_message(self.dbstate, _("Column clicked, sorting...")) self.uistate.push_message(self.dbstate, _("Column clicked, sorting..."))
cput = time.clock() cput = time.clock()
same_col = False same_col = False
@ -628,7 +628,7 @@ class ListView(NavigationView):
search_col = self.column_order()[data][1] search_col = self.column_order()[data][1]
self.list.set_search_column(search_col) self.list.set_search_column(search_col)
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
_LOG.debug(' ' + self.__class__.__name__ + ' column_clicked ' + _LOG.debug(' ' + self.__class__.__name__ + ' column_clicked ' +
str(time.clock() - cput) + ' sec') str(time.clock() - cput) + ' sec')

View File

@ -323,7 +323,7 @@ class GeoGraphyView(OsmGps, NavigationView):
""" """
found = False found = False
mark_selected = [] mark_selected = []
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
for mark in self.sort: for mark in self.sort:
# as we are not precise with our hand, reduce the precision # as we are not precise with our hand, reduce the precision
# depending on the zoom. # depending on the zoom.
@ -364,7 +364,7 @@ class GeoGraphyView(OsmGps, NavigationView):
found = True found = True
if found: if found:
self.bubble_message(event, lat, lon, mark_selected) self.bubble_message(event, lat, lon, mark_selected)
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
def bubble_message(self, event, lat, lon, mark): def bubble_message(self, event, lat, lon, mark):
""" """

View File

@ -182,14 +182,14 @@ class MediaMan(tool.Tool):
""" """
Code to run prior to the batch op. Code to run prior to the batch op.
""" """
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
self.uistate.progress.show() self.uistate.progress.show()
def post_run(self): def post_run(self):
""" """
Code to run after to the batch op. Code to run after to the batch op.
""" """
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
self.uistate.progress.hide() self.uistate.progress.hide()
#------------------------------------------------------------------------ #------------------------------------------------------------------------

View File

@ -72,7 +72,7 @@ class Rebuild(tool.Tool, UpdateCallback):
if uistate: if uistate:
self.callback = uistate.pulse_progressbar self.callback = uistate.pulse_progressbar
uistate.set_busy_cursor(1) uistate.set_busy_cursor(True)
uistate.progress.show() uistate.progress.show()
uistate.push_message(dbstate, _("Rebuilding secondary indexes...")) uistate.push_message(dbstate, _("Rebuilding secondary indexes..."))
@ -81,7 +81,7 @@ class Rebuild(tool.Tool, UpdateCallback):
self.db.rebuild_secondary(self.update) self.db.rebuild_secondary(self.update)
self.reset() self.reset()
uistate.set_busy_cursor(0) uistate.set_busy_cursor(False)
uistate.progress.hide() uistate.progress.hide()
OkDialog(_("Secondary indexes rebuilt"), OkDialog(_("Secondary indexes rebuilt"),
_('All secondary indexes have been rebuilt.'), _('All secondary indexes have been rebuilt.'),

View File

@ -73,7 +73,7 @@ class RebuildRefMap(tool.Tool, UpdateCallback):
self.db.disable_signals() self.db.disable_signals()
if uistate: if uistate:
self.callback = uistate.pulse_progressbar self.callback = uistate.pulse_progressbar
uistate.set_busy_cursor(1) uistate.set_busy_cursor(True)
uistate.progress.show() uistate.progress.show()
uistate.push_message(dbstate, _("Rebuilding reference maps...")) uistate.push_message(dbstate, _("Rebuilding reference maps..."))
else: else:
@ -86,7 +86,7 @@ class RebuildRefMap(tool.Tool, UpdateCallback):
self.reset() self.reset()
if uistate: if uistate:
uistate.set_busy_cursor(0) uistate.set_busy_cursor(False)
uistate.progress.hide() uistate.progress.hide()
OkDialog(_("Reference maps rebuilt"), OkDialog(_("Reference maps rebuilt"),
_('All reference maps have been rebuilt.'), _('All reference maps have been rebuilt.'),

View File

@ -237,7 +237,7 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
for item in self.sensitive_list: for item in self.sensitive_list:
item.set_sensitive(True) item.set_sensitive(True)
self.uistate.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) self.uistate.set_busy_cursor(True)
self.uistate.progress.show() self.uistate.progress.show()
self.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) self.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
@ -245,7 +245,7 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
self.collect_unused() self.collect_unused()
self.uistate.progress.hide() self.uistate.progress.hide()
self.uistate.window.get_window().set_cursor(None) self.uistate.set_busy_cursor(False)
self.window.get_window().set_cursor(None) self.window.get_window().set_cursor(None)
self.reset() self.reset()

View File

@ -321,7 +321,7 @@ class Verify(tool.Tool, ManagedWindow, UpdateCallback):
except WindowActiveError: except WindowActiveError:
pass pass
self.uistate.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) self.uistate.set_busy_cursor(True)
self.uistate.progress.show() self.uistate.progress.show()
self.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) self.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
try: try:
@ -332,7 +332,7 @@ class Verify(tool.Tool, ManagedWindow, UpdateCallback):
self.run_tool(cli=False) self.run_tool(cli=False)
self.uistate.progress.hide() self.uistate.progress.hide()
self.uistate.window.get_window().set_cursor(None) self.uistate.set_busy_cursor(False)
try: try:
self.window.get_window().set_cursor(None) self.window.get_window().set_cursor(None)
self.vr.window.get_window().set_cursor(None) self.vr.window.get_window().set_cursor(None)

View File

@ -259,11 +259,11 @@ class FamilyView(ListView):
q = QuestionDialog2(_('Delete %s?') % _('family'), msg, q = QuestionDialog2(_('Delete %s?') % _('family'), msg,
_('_Delete Item'), _('Cancel')) _('_Delete Item'), _('Cancel'))
if q.run(): if q.run():
self.uistate.set_busy_cursor(1) self.uistate.set_busy_cursor(True)
map(self.dbstate.db.remove_family_relationships, map(self.dbstate.db.remove_family_relationships,
self.selected_handles()) self.selected_handles())
self.build_tree() self.build_tree()
self.uistate.set_busy_cursor(0) self.uistate.set_busy_cursor(False)
def edit(self, obj): def edit(self, obj):
for handle in self.selected_handles(): for handle in self.selected_handles():