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)
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):

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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):
"""

View File

@ -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')

View File

@ -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):
"""

View File

@ -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()
#------------------------------------------------------------------------

View File

@ -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.'),

View File

@ -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.'),

View File

@ -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()

View File

@ -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)

View File

@ -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():