def setup(): box = g.MessageDialog(None, g.DIALOG_MODAL, g.MESSAGE_QUESTION, g.BUTTONS_CANCEL, _('Do you want to make ROX a choice ' 'on your login screen (affects all users and ' 'requires the root password), or do you ' 'just want to set the session for your current ' 'user?\n\n' 'If you know the root password and use ' 'a graphical display manager such as gdm or kdm, ' 'you should probably choose that option.')) add_button(box, g.STOCK_HOME, _('Setup for user'), 1) add_button(box, g.STOCK_YES, _('Add to login'), 2) box.set_default_response(2) box.set_position(g.WIN_POS_CENTER) resp = box.run() box.destroy() if resp == 1: setup_home() elif resp == 2: tasks.Task(setup_login()) rox.toplevel_ref() rox.mainloop()
def report_patherror(message, path): """Display a <Cancel>/<Retry>/<Examine> dialog. This will raise an OSError exception if the user selects Cancel, or will return successfully if the user chooses to retry.""" from rox import g, filer, toplevel_ref, toplevel_unref, ButtonMixed toplevel_ref() box = g.MessageDialog(None, 0, g.MESSAGE_QUESTION, g.BUTTONS_CANCEL, message) button = ButtonMixed(g.STOCK_REDO, _('Retry')) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, g.RESPONSE_OK) button = ButtonMixed(g.STOCK_JUMP_TO, _('Examine')) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, g.RESPONSE_APPLY) box.set_position(g.WIN_POS_CENTER) box.set_title(_('Error:')) box.set_default_response(g.RESPONSE_APPLY) while 1: resp = box.run() if resp != g.RESPONSE_APPLY: break filerpath = os.path.normpath(path) filer.show_file(filerpath) box.destroy() toplevel_unref() if resp != g.RESPONSE_OK: raise OSError, message
def rox_process_died(status): global rox_pid rox_pid = None box = g.MessageDialog(parent = None, flags = 0, type = g.MESSAGE_QUESTION, buttons = 0, message_format = _("ROX-Filer has terminated (crashed?)." "You should probably try to restart it.")) for stock, label, response in [ (g.STOCK_NO, _("Do nothing"), 0), (g.STOCK_EXECUTE, _("Run Xterm"), 1), (g.STOCK_REFRESH, _("_Restart"), 2)]: button = rox.ButtonMixed(stock, label) button.set_flags(g.CAN_DEFAULT) box.add_action_widget(button, response) button.show() box.set_default_response(2) r = box.run() box.destroy() if r == 2: run_rox_process() elif r == 1: os.spawnlp(os.P_NOWAIT, 'xterm', 'xterm')
def setup_with_confirm(): box = g.MessageDialog(None, 0, g.MESSAGE_QUESTION, g.BUTTONS_CANCEL, _('ROX-Session does not appear to be managing ' 'your session. Would you like to set it up now?\n\n' 'If you think it should already be set up, click on ' 'Help.')) box.add_button(g.STOCK_HELP, g.RESPONSE_HELP) add_button(box, g.STOCK_YES, _('Set up ROX'), g.RESPONSE_OK) box.set_position(g.WIN_POS_CENTER) box.set_title(_('Set up ROX-Session')) box.set_default_response(g.RESPONSE_OK) resp = box.run() box.destroy() if resp == int(g.RESPONSE_OK): setup() elif resp == int(g.RESPONSE_HELP): troubleshoot()
def delete(b): sel = self.list.get_selection() memos = [] for iter in memo_list: if sel.iter_is_selected(iter): m = memo_list.get_memo_by_iter(iter) memos.append(m) if not memos: rox.alert(_('You need to select some memos first!')) return l = len(memos) if l == 1: message = _("Really delete memo '%s'?") % memos[0].brief else: message = _('Really delete %d memos?') % l box = g.MessageDialog(None, 0, g.MESSAGE_QUESTION, g.BUTTONS_CANCEL, message) if rox.confirm(message, g.STOCK_DELETE): for m in memos: memo_list.delete(m, update=0) memo_list.notify_changed()
def show_exception(type, value, tb, auto_details = False): """Display this exception in an error box. The user has the options of ignoring the error, quitting the application and examining the exception in more detail. See also rox.report_exception().""" QUIT = 1 DETAILS = 2 SAVE = 3 brief = ''.join(traceback.format_exception_only(type, value)) toplevel_ref() box = g.MessageDialog(None, 0, g.MESSAGE_ERROR, g.BUTTONS_NONE, brief) if not auto_details: button = ButtonMixed(g.STOCK_ZOOM_IN, _('_Details')) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, DETAILS) box.add_button(g.STOCK_HELP, g.RESPONSE_HELP) box.add_button(g.STOCK_OK, g.RESPONSE_OK) box.set_default_response(g.RESPONSE_OK) box.set_position(g.WIN_POS_CENTER) box.set_title(_('Error')) box.show() if tb: bug_report = 'Traceback (most recent call last):\n' + \ ''.join(traceback.format_stack(tb.tb_frame.f_back) + traceback.format_tb(tb) + traceback.format_exception_only(type, value)) else: bug_report = 'No stack trace.' while 1: if auto_details: resp = DETAILS auto_details = False else: resp = box.run() if resp == int(g.RESPONSE_OK) or resp == int(g.RESPONSE_DELETE_EVENT): break if resp == SAVE: global savebox if savebox: savebox.destroy() def destroy(box): global savebox # For pychecker savebox = None from saving import StringSaver savebox = StringSaver(bug_report, 'BugReport') savebox.connect('destroy', destroy) savebox.show() continue if resp == QUIT: sys.exit(1) elif resp == int(g.RESPONSE_HELP): _show_debug_help() continue assert resp == DETAILS box.set_response_sensitive(DETAILS, False) button = ButtonMixed(g.STOCK_SAVE, _('_Bug Report')) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, SAVE) box.action_area.set_child_secondary(button, True) button = ButtonMixed(g.STOCK_QUIT, _('Forced Quit')) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, QUIT) box.action_area.set_child_secondary(button, True) if tb: ee = ExceptionExplorer(tb) box.vbox.pack_start(ee) ee.show() else: no_trace = g.Label('No traceback object!') box.vbox.pack_start(no_trace) no_trace.show() box.destroy() toplevel_unref()