def notify(self, string): if HAVE_NOTIFY: n = pynotify.Notification(APP_NAME, string, 'battery-caution') n.set_urgency(pynotify.URGENCY_CRITICAL) n.attach_to_widget(self) n.show() else: rox.info(string)
def activate(entry): expr = entry.get_text() frame = selected_frame() try: info(` eval(expr, frame.f_locals, frame.f_globals) `) except: type, value = sys.exc_info()[:2] brief = "".join(traceback.format_exception_only(type, value)) alert(brief) entry.grab_focus()
def warn_if_not_visible(self, memo): if memo.hidden: return for iter in self.visible: m = self.visible.get_value(iter, MEMO) if m is memo: return rox.info("This memo has been added, but is not shown in the main " "window. Use Show All from the popup menu to see it.\n\n" "You can use the Options window to control when memos " "are shown in the main window.")
def setup_home(): xsession = os.path.expanduser('~/.xsession') xinitrc = os.path.expanduser('~/.xinitrc') backup(xsession, os.path.expanduser('~/xsession.old')) backup(xinitrc, os.path.expanduser('~/xinitrc.old')) create_session_script(xsession) os.symlink(xsession, xinitrc) rox.info(_("OK, now logout by your usual method and when " "you log in again, I should be your session manager.\n" "Note: you may need to select 'Default' as your " "desktop type after entering your user name on the " "login screen."))
def export_stylesheet_and_key(self): dir = os.path.dirname(os.path.abspath(self.pathname)) stylesheet = os.path.join(dir, 'interface.xsl') if not os.path.exists(stylesheet): shutil.copyfile(stylesheet_src, stylesheet) rox.info("I have saved a stylesheet as '%s'. You should upload " "this to your web-server in the same directory as the feed file. " "This allows browsers to display the feed nicely." % stylesheet) if os.path.abspath(self.pathname).endswith('/feed.xml'): # Probably the feed's URL is the directory, so we'll get the key from the parent. dir = os.path.dirname(dir) exported = signing.export_key(dir, self.key) if exported: rox.info("I have exported your public key as '%s'. You should upload " "this to your web-server in the same directory as the feed file. " "This allows people to check the signature on your feed." % exported)
def save_to_file_in_entry(self): """Call this when the user clicks on an OK button you provide.""" uri = self.entry.get_text() path = get_local_path(escape(uri)) if path: if not self.confirm_new_path(path): return try: self.set_sensitive(False) try: self.document.save_to_file(path) finally: self.set_sensitive(True) self.set_uri(uri) self.save_done() except: _report_save_error() else: rox.info(_("Drag the icon to a directory viewer\n" "(or enter a full pathname)"))
def save_to_file_in_entry(self): """Call this when the user clicks on an OK button you provide.""" uri = self.entry.get_text() path = get_local_path(escape(uri)) if path: if not self.confirm_new_path(path): return try: self.set_sensitive(False) try: self.document.save_to_file(path) finally: self.set_sensitive(True) self.set_uri(uri) self.save_done() except: _report_save_error() else: rox.info( _("Drag the icon to a directory viewer\n" "(or enter a full pathname)"))
def setup_login(): try: session_dirs = ['/etc/X11/sessions', '/etc/dm/Sessions', '/etc/X11/dm/Sessions', '/usr/share/xsessions', '/opt/kde3/share/apps/kdm/sessions'] # TODO: more guesses about where KDE is installed, /opt/kde3 # works for SuSE 9.2 for d in session_dirs: if os.path.isdir(d): session_dir = d break else: rox.croak(_('I wanted to install a rox.desktop file in your ' "session directory, but I couldn't find one! I tried " "these places (defaults for gdm2, at least):\n\n") + '\n'.join(session_dirs)) iskde=(session_dir.find('kde')>=0) if not os.path.isdir('/usr/local/sbin'): rox.croak(_('/usr/local/sbin directory is missing! I want to ' 'install the rox-session script there... Please create it ' 'and try again.')) desktop_path = os.path.join(session_dir, 'rox.desktop') session_path = '/usr/local/sbin/rox-session' maker = su.SuProxyMaker('I need permission to create these files:\n' + desktop_path + '\n' + session_path) yield maker.blocker root = maker.get_root() q = root.open(desktop_path, 'w') yield q stream = q.result if iskde: dtype='XSession' else: dtype='Application' q = root.write(stream, """[Desktop Entry]\n Encoding=UTF-8 Name=ROX Comment=This session logs you into the ROX desktop Exec=/usr/local/sbin/rox-session Type=%s """ % dtype) yield q q = root.close(stream) yield q q = root.open(session_path, 'w') yield q stream = q.result q = root.write(stream, get_session_script()) yield q q = root.close(stream) yield q q = root.chmod(session_path, 0755) yield q rox.info(_("OK, now logout by your usual method, and choose ROX from " "the session menu on your login screen just after entering your " "user name (but before entering your password).")) rox.toplevel_unref() except: rox.toplevel_unref() raise
def alarm(self): self.clear_timer() if dbus_notify.is_available(): dbus_notify.timer() else: info(_('Memo : Time is up!'))
import rox from rox import basedir, filer import constants # Find Choices directory... path = basedir.save_config_path(constants.site, 'ROX-Session', 'AutoStart') rox.info( _('Symlink any applications you want run on login into this ' 'directory')) filer.open_dir(path)