From b7ab76bcf61597a1909264a7bec1e8766b5e87dc Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Thu, 16 Aug 2012 18:39:21 +0000 Subject: [PATCH] Improve busy cursor code for Gtk3 svn: r20224 --- src/gui/dbloader.py | 4 ++-- src/gui/displaystate.py | 9 ++++++--- src/gui/filters/sidebar/_sidebarfilter.py | 4 ++-- src/gui/plug/export/_exportassistant.py | 4 ++-- src/gui/viewmanager.py | 18 ++++++++---------- src/gui/views/listview.py | 12 ++++++------ src/plugins/lib/maps/geography.py | 4 ++-- src/plugins/tool/mediamanager.py | 4 ++-- src/plugins/tool/rebuild.py | 4 ++-- src/plugins/tool/rebuildrefmap.py | 4 ++-- src/plugins/tool/removeunused.py | 4 ++-- src/plugins/tool/verify.py | 4 ++-- src/plugins/view/familyview.py | 4 ++-- 13 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/gui/dbloader.py b/src/gui/dbloader.py index b77e19f99..e4900cd59 100644 --- a/src/gui/dbloader.py +++ b/src/gui/dbloader.py @@ -97,7 +97,7 @@ class DbLoader(CLIDbLoader): _LOG.error(str(msg) +"\n" + exc) def _begin_progress(self): - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) self.uistate.progress.show() self.uistate.pulse_progressbar(0) @@ -105,7 +105,7 @@ class DbLoader(CLIDbLoader): self.uistate.pulse_progressbar(value) def _end_progress(self): - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) self.uistate.progress.hide() def import_file(self): diff --git a/src/gui/displaystate.py b/src/gui/displaystate.py index 0ce4c67b1..b7d2e7a20 100644 --- a/src/gui/displaystate.py +++ b/src/gui/displaystate.py @@ -373,10 +373,13 @@ class DisplayState(Callback): 'Note': _("No active note"), } + BUSY_CURSOR = Gdk.Cursor.new(Gdk.CursorType.WATCH) + def __init__(self, window, status, progress, warnbtn, uimanager, progress_monitor, viewmanager=None): self.busy = False + self.cursor = None self.viewmanager = viewmanager self.uimanager = uimanager self.progress_monitor = progress_monitor @@ -518,10 +521,10 @@ class DisplayState(Callback): else: self.busy = value if value: - self.window.get_root_window().set_cursor(Gdk.Cursor.new( - Gdk.CursorType.WATCH)) + self.cursor = self.window.get_window().get_cursor() + self.window.get_window().set_cursor(self.BUSY_CURSOR) else: - self.window.get_root_window().set_cursor(None) + self.window.get_window().set_cursor(self.cursor) process_pending_events() def set_open_widget(self, widget): diff --git a/src/gui/filters/sidebar/_sidebarfilter.py b/src/gui/filters/sidebar/_sidebarfilter.py index b2c52ff3f..5a57b3eab 100644 --- a/src/gui/filters/sidebar/_sidebarfilter.py +++ b/src/gui/filters/sidebar/_sidebarfilter.py @@ -106,9 +106,9 @@ class SidebarFilter(DbGUIElement): pass def clicked(self, obj): - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) self.clicked_func() - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) def clicked_func(self): pass diff --git a/src/gui/plug/export/_exportassistant.py b/src/gui/plug/export/_exportassistant.py index fbbd6368d..85627b093 100644 --- a/src/gui/plug/export/_exportassistant.py +++ b/src/gui/plug/export/_exportassistant.py @@ -637,11 +637,11 @@ class ExportAssistant(Gtk.Assistant, ManagedWindow) : page.set_child_visible(True) self.show_all() - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) self.set_busy_cursor(1) def post_save(self): - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) self.set_busy_cursor(0) self.progressbar.hide() self.writestarted = False diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py index 31742668c..4648e0cf8 100644 --- a/src/gui/viewmanager.py +++ b/src/gui/viewmanager.py @@ -1021,14 +1021,14 @@ class ViewManager(CLIManager): Backup the current file as a backup file. """ if self.dbstate.db.has_changed: - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) self.uistate.progress.show() self.uistate.push_message(self.dbstate, _("Autobackup...")) try: backup(self.dbstate.db) except DbException, msg: ErrorDialog(_("Error saving backup data"), msg) - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) self.uistate.progress.hide() def abort(self, obj=None): @@ -1373,8 +1373,6 @@ class ViewManager(CLIManager): self.dbstate.db.undo_history_callback = self.undo_history_update self.undo_history_close() - self.uistate.window.get_root_window().set_cursor(None) - def _post_load_newdb(self, filename, filetype, title=None): """ The method called after load of a new database. @@ -1572,7 +1570,7 @@ class ViewManager(CLIManager): yes_no = question.run() if not yes_no: return - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) self.pulse_progressbar(0) self.uistate.progress.show() self.uistate.push_message(self.dbstate, _("Making backup...")) @@ -1589,7 +1587,7 @@ class ViewManager(CLIManager): callback=self.pulse_progressbar), strip_photos=0, compress=1) writer.write(filename) - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) self.uistate.progress.hide() filename = get_unicode_path_from_env_var(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 """ - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) self.dbstate.db.undo() - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) def redo(self, obj): """ Calls the redo function on the database """ - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) self.dbstate.db.redo() - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) def undo_history(self, obj): """ diff --git a/src/gui/views/listview.py b/src/gui/views/listview.py index 29ab9f6f3..9f5ea3634 100644 --- a/src/gui/views/listview.py +++ b/src/gui/views/listview.py @@ -523,7 +523,7 @@ class ListView(NavigationView): prompt = q.run() if not prompt: - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) for handle in self.selected_handles(): (query, is_used, object) = self.remove_object_from_handle(handle) @@ -539,15 +539,15 @@ class ListView(NavigationView): #descr = object.get_description() #if descr == "": descr = object.get_gramps_id() - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) QuestionDialog(_('Delete %s?') % descr, msg, _('_Delete Item'), query.query_response) - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) else: query.query_response() if not prompt: - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) def blist(self, store, path, iter, sel_list): '''GtkTreeSelectionForeachFunc @@ -585,7 +585,7 @@ class ListView(NavigationView): obj A TreeViewColumn object of the column clicked 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...")) cput = time.clock() same_col = False @@ -628,7 +628,7 @@ class ListView(NavigationView): search_col = self.column_order()[data][1] 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 ' + str(time.clock() - cput) + ' sec') diff --git a/src/plugins/lib/maps/geography.py b/src/plugins/lib/maps/geography.py index b7e97f69f..1fefefd86 100644 --- a/src/plugins/lib/maps/geography.py +++ b/src/plugins/lib/maps/geography.py @@ -323,7 +323,7 @@ class GeoGraphyView(OsmGps, NavigationView): """ found = False mark_selected = [] - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) for mark in self.sort: # as we are not precise with our hand, reduce the precision # depending on the zoom. @@ -364,7 +364,7 @@ class GeoGraphyView(OsmGps, NavigationView): found = True if found: 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): """ diff --git a/src/plugins/tool/mediamanager.py b/src/plugins/tool/mediamanager.py index 517fbbac0..297f4a607 100644 --- a/src/plugins/tool/mediamanager.py +++ b/src/plugins/tool/mediamanager.py @@ -182,14 +182,14 @@ class MediaMan(tool.Tool): """ Code to run prior to the batch op. """ - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) self.uistate.progress.show() def post_run(self): """ Code to run after to the batch op. """ - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) self.uistate.progress.hide() #------------------------------------------------------------------------ diff --git a/src/plugins/tool/rebuild.py b/src/plugins/tool/rebuild.py index e4a4822b4..0714ff977 100644 --- a/src/plugins/tool/rebuild.py +++ b/src/plugins/tool/rebuild.py @@ -72,7 +72,7 @@ class Rebuild(tool.Tool, UpdateCallback): if uistate: self.callback = uistate.pulse_progressbar - uistate.set_busy_cursor(1) + uistate.set_busy_cursor(True) uistate.progress.show() uistate.push_message(dbstate, _("Rebuilding secondary indexes...")) @@ -81,7 +81,7 @@ class Rebuild(tool.Tool, UpdateCallback): self.db.rebuild_secondary(self.update) self.reset() - uistate.set_busy_cursor(0) + uistate.set_busy_cursor(False) uistate.progress.hide() OkDialog(_("Secondary indexes rebuilt"), _('All secondary indexes have been rebuilt.'), diff --git a/src/plugins/tool/rebuildrefmap.py b/src/plugins/tool/rebuildrefmap.py index ffb348d51..5e5cd26b1 100644 --- a/src/plugins/tool/rebuildrefmap.py +++ b/src/plugins/tool/rebuildrefmap.py @@ -73,7 +73,7 @@ class RebuildRefMap(tool.Tool, UpdateCallback): self.db.disable_signals() if uistate: self.callback = uistate.pulse_progressbar - uistate.set_busy_cursor(1) + uistate.set_busy_cursor(True) uistate.progress.show() uistate.push_message(dbstate, _("Rebuilding reference maps...")) else: @@ -86,7 +86,7 @@ class RebuildRefMap(tool.Tool, UpdateCallback): self.reset() if uistate: - uistate.set_busy_cursor(0) + uistate.set_busy_cursor(False) uistate.progress.hide() OkDialog(_("Reference maps rebuilt"), _('All reference maps have been rebuilt.'), diff --git a/src/plugins/tool/removeunused.py b/src/plugins/tool/removeunused.py index 9138ad9c4..827f46736 100644 --- a/src/plugins/tool/removeunused.py +++ b/src/plugins/tool/removeunused.py @@ -237,7 +237,7 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback): for item in self.sensitive_list: 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.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.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.reset() diff --git a/src/plugins/tool/verify.py b/src/plugins/tool/verify.py index 21733969b..0a7c957a7 100644 --- a/src/plugins/tool/verify.py +++ b/src/plugins/tool/verify.py @@ -321,7 +321,7 @@ class Verify(tool.Tool, ManagedWindow, UpdateCallback): except WindowActiveError: 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.window.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) try: @@ -332,7 +332,7 @@ class Verify(tool.Tool, ManagedWindow, UpdateCallback): self.run_tool(cli=False) self.uistate.progress.hide() - self.uistate.window.get_window().set_cursor(None) + self.uistate.set_busy_cursor(False) try: self.window.get_window().set_cursor(None) self.vr.window.get_window().set_cursor(None) diff --git a/src/plugins/view/familyview.py b/src/plugins/view/familyview.py index 0e12b244e..8cd3fc1dd 100644 --- a/src/plugins/view/familyview.py +++ b/src/plugins/view/familyview.py @@ -259,11 +259,11 @@ class FamilyView(ListView): q = QuestionDialog2(_('Delete %s?') % _('family'), msg, _('_Delete Item'), _('Cancel')) if q.run(): - self.uistate.set_busy_cursor(1) + self.uistate.set_busy_cursor(True) map(self.dbstate.db.remove_family_relationships, self.selected_handles()) self.build_tree() - self.uistate.set_busy_cursor(0) + self.uistate.set_busy_cursor(False) def edit(self, obj): for handle in self.selected_handles():