Esempio n. 1
0
 def on_response(dialog, responseId, callback=callback):
     response = False
     if responseId == gtk.RESPONSE_YES:
         response = True
     callback(response)
     alwaysPrompt = dialog.checkbox.get_active()
     if alwaysPrompt == False:
         setattr(GlobalSettings.get(), prefName, alwaysPrompt)
         GlobalSettings.get().save()
Esempio n. 2
0
 def on_response(dialog, responseId, callback=callback):
   response = False
   if responseId == gtk.RESPONSE_YES:
     response = True
   callback(response)
   alwaysPrompt = dialog.checkbox.get_active()
   if alwaysPrompt == False:
     setattr(GlobalSettings.get(), prefName, alwaysPrompt)
     GlobalSettings.get().save()
Esempio n. 3
0
    def __init__(self):
        self.host = Globals.FTP_HOST
        self.port = Globals.FTP_PORT
        self.user = Globals.FTP_USER
        self.pw = Globals.FTP_PASSWORD
        self.submitThread = None

        buttons = (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL,
                   gtk.RESPONSE_CANCEL)

        dia = gtk.Dialog("Submit Error", None, 0, buttons)

        #username field
        usernameLabel = gtk.Label("Username")
        self.nameEntry = gtk.Entry()
        self.nameEntry.set_max_length(50)
        try:
            self.nameEntry.set_text(GlobalSettings.get().username)
        except:
            pass

        #comment field
        self.textbuffer = gtk.TextBuffer(table=None)
        self.textbuffer.set_text("Please describe the error or issue here.")
        textview = gtk.TextView(self.textbuffer)
        buffer = textview.get_buffer()
        textview.set_editable(True)
        textview.set_cursor_visible(True)
        textview.set_wrap_mode(gtk.WRAP_WORD)
        textview.show()

        # create a new scrolled window.
        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_border_width(10)
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        #scrolled_window.set_size_request(300, 350)
        scrolled_window.add_with_viewport(textview)
        scrolled_window.show()

        #put them in a nice little table
        table = gtk.Table(4, 2, True)
        table.attach(usernameLabel, 0, 1, 0, 1)
        table.attach(self.nameEntry, 1, 2, 0, 1)
        table.attach(scrolled_window, 0, 2, 1, 4)

        dia.vbox.pack_start(table, True, True, 0)

        self.nameEntry.set_text(GlobalSettings.get().username)

        dia.show_all()

        #connect the handler:
        dia.connect("response", self.on_response)
        self.dia = dia
Esempio n. 4
0
  def __init__(self):    
    self.host = Globals.FTP_HOST
    self.port = Globals.FTP_PORT
    self.user = Globals.FTP_USER
    self.pw   = Globals.FTP_PASSWORD
    self.submitThread = None
    
    buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
    
    dia = gtk.Dialog("Submit Error", None, 0, buttons)

    #username field
    usernameLabel = gtk.Label("Username")
    self.nameEntry = gtk.Entry()
    self.nameEntry.set_max_length(50)
    try:
      self.nameEntry.set_text(GlobalSettings.get().username)
    except:
      pass

    #comment field
    self.textbuffer = gtk.TextBuffer(table=None)
    self.textbuffer.set_text("Please describe the error or issue here.")
    textview = gtk.TextView(self.textbuffer)
    buffer=textview.get_buffer()
    textview.set_editable(True)
    textview.set_cursor_visible(True)
    textview.set_wrap_mode(gtk.WRAP_WORD)
    textview.show()
    
    # create a new scrolled window.
    scrolled_window = gtk.ScrolledWindow()
    scrolled_window.set_border_width(10)
    scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    #scrolled_window.set_size_request(300, 350)
    scrolled_window.add_with_viewport(textview)
    scrolled_window.show()

    #put them in a nice little table
    table = gtk.Table(4, 2, True)
    table.attach(usernameLabel, 0, 1, 0, 1)
    table.attach(self.nameEntry, 1, 2, 0, 1)
    table.attach(scrolled_window, 0, 2, 1, 4)

    dia.vbox.pack_start(table, True, True, 0)

    self.nameEntry.set_text(GlobalSettings.get().username)

    dia.show_all()

    #connect the handler:
    dia.connect("response", self.on_response)
    self.dia = dia
Esempio n. 5
0
 def on_login_failure(self, err=None, text=None):
     """Called anytime login fails for any reason.
 @param err:  the failure
 @type  err:  Failure, Exception, or str
 @param text:  error message from the bank
 @type  text:  str"""
     if not self.startupDeferred:
         return
     log_ex(err, "Login failed", [BadLoginPasswordError])
     self.loginInProgress = False
     if not self.isLoggedIn:
         #dont automatically log in if we failed last time:
         GlobalSettings.get().save_password = False
         GlobalSettings.get().save()
         self._trigger_event("login_failure", err, text)
Esempio n. 6
0
 def show_preference_prompt(self, text, title, callback, prefName, defaultResponse=True):
   """A shortcut for dialogs where we say 'Are you sure you want to X?'"""
   #return immediately if there is a saved setting
   alwaysPrompt = getattr(GlobalSettings.get(), prefName, True)
   if alwaysPrompt == False:
     callback(defaultResponse)
     return
   
   #otherwise, define the callback for when the user is finished with the prompt
   def on_response(dialog, responseId, callback=callback):
     response = False
     if responseId == gtk.RESPONSE_YES:
       response = True
     callback(response)
     alwaysPrompt = dialog.checkbox.get_active()
     if alwaysPrompt == False:
       setattr(GlobalSettings.get(), prefName, alwaysPrompt)
       GlobalSettings.get().save()
       
   #then make the dialog
   dia = self.show_msgbox(text, title, on_response, (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO))
   dia.checkbox = gtk.CheckButton("Always ask?")
   dia.checkbox.set_active(True)
   dia.checkbox.show()
   dia.vbox.pack_end(dia.checkbox)
   dia.set_modal(True)
Esempio n. 7
0
    def show_preference_prompt(self,
                               text,
                               title,
                               callback,
                               prefName,
                               defaultResponse=True):
        """A shortcut for dialogs where we say 'Are you sure you want to X?'"""
        #return immediately if there is a saved setting
        alwaysPrompt = getattr(GlobalSettings.get(), prefName, True)
        if alwaysPrompt == False:
            callback(defaultResponse)
            return

        #otherwise, define the callback for when the user is finished with the prompt
        def on_response(dialog, responseId, callback=callback):
            response = False
            if responseId == gtk.RESPONSE_YES:
                response = True
            callback(response)
            alwaysPrompt = dialog.checkbox.get_active()
            if alwaysPrompt == False:
                setattr(GlobalSettings.get(), prefName, alwaysPrompt)
                GlobalSettings.get().save()

        #then make the dialog
        dia = self.show_msgbox(
            text, title, on_response,
            (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO))
        dia.checkbox = gtk.CheckButton("Always ask?")
        dia.checkbox.set_active(True)
        dia.checkbox.show()
        dia.vbox.pack_end(dia.checkbox)
        dia.set_modal(True)
Esempio n. 8
0
 def start(self):
   self.dia.show_all()
   self.nameEntry.grab_focus()
   if not self.started:
     self.started = True
     #just log in right away if we're saving the password and username anyway:
     if GlobalSettings.get().save_password:
       self.on_response(self.dia, gtk.RESPONSE_OK)
Esempio n. 9
0
 def start(self):
     self.dia.show_all()
     self.nameEntry.grab_focus()
     if not self.started:
         self.started = True
         #just log in right away if we're saving the password and username anyway:
         if GlobalSettings.get().save_password:
             self.on_response(self.dia, gtk.RESPONSE_OK)
Esempio n. 10
0
 def on_login_success(self, bankApp, loginMessage=None):
   log_msg("Bank login succeeded!\nBank Welcome Message:  %s" % (loginMessage), 2)
   #save all this information to the settings files if necessary:
   settings = GlobalSettings.get()
   settings.save_password = self.savePass
   if not settings.save_password:
     self.username = ""
     self.password = ""
   settings.username = self.username
   settings.password = self.password
   settings.save()
Esempio n. 11
0
 def on_login_success(self, bankApp, loginMessage=None):
     log_msg(
         "Bank login succeeded!\nBank Welcome Message:  %s" %
         (loginMessage), 2)
     #save all this information to the settings files if necessary:
     settings = GlobalSettings.get()
     settings.save_password = self.savePass
     if not settings.save_password:
         self.username = ""
         self.password = ""
     settings.username = self.username
     settings.password = self.password
     settings.save()
Esempio n. 12
0
 def on_login_success(self, bankApp, text):
   #show the server message if there was any:
   if text:
     GUIController.get().show_msgbox(text, "Server Notice")
   #save all this information to the settings files if necessary:
   settings = GlobalSettings.get()
   settings.save_password = self.savePassCheck.get_active()
   if not settings.save_password:
     self.username = ""
     self.password = ""
   settings.username = self.username
   settings.password = self.password
   settings.save()
   self.succeeded = True
   self.dia.destroy()
Esempio n. 13
0
 def on_login_success(self, bankApp, text):
     #show the server message if there was any:
     if text:
         GUIController.get().show_msgbox(text, "Server Notice")
     #save all this information to the settings files if necessary:
     settings = GlobalSettings.get()
     settings.save_password = self.savePassCheck.get_active()
     if not settings.save_password:
         self.username = ""
         self.password = ""
     settings.username = self.username
     settings.password = self.password
     settings.save()
     self.succeeded = True
     self.dia.destroy()
Esempio n. 14
0
  def show_settings_cb(self, widget=None):
    #TODO: global and core settings creating and manipulating fake Application ojects, and settings are currently generally stupid.  Change to a global settings obj
    apps = {}
    #create a fake Application wrapper for global settings: 
    globalSettingsObj = GlobalSettings.get()
    apps[globalSettingsObj.settingsName] = globalSettingsObj.app
    coreSettingsObj = CoreSettings.get()
    apps[coreSettingsObj.settingsName] = coreSettingsObj.app
    
    realApplications = [self.torApp, self.btApp]
#    #currently no ff settings... really should use introspection, but everything is about to change
#    if System.IS_WINDOWS:
#      realApplications.append(self.ffApp)
    for app in realApplications:
      apps[app.get_settings_name()] = app
    self.show_settings(apps)
Esempio n. 15
0
    def show_settings_cb(self, widget=None):
        #TODO: global and core settings creating and manipulating fake Application ojects, and settings are currently generally stupid.  Change to a global settings obj
        apps = {}
        #create a fake Application wrapper for global settings:
        globalSettingsObj = GlobalSettings.get()
        apps[globalSettingsObj.settingsName] = globalSettingsObj.app
        coreSettingsObj = CoreSettings.get()
        apps[coreSettingsObj.settingsName] = coreSettingsObj.app

        realApplications = [self.torApp, self.btApp]
        #    #currently no ff settings... really should use introspection, but everything is about to change
        #    if System.IS_WINDOWS:
        #      realApplications.append(self.ffApp)
        for app in realApplications:
            apps[app.get_settings_name()] = app
        self.show_settings(apps)
Esempio n. 16
0
    def do_verification_prompt(self, callback):
        #global config stores the last user that logged in (and his password)
        settings = GlobalSettings.get()

        def make_textpad():
            editWindow = self.stdscr.derwin(1, curses.COLS - startX,
                                            startY + 1, startX)
            editWindow.clear()
            textpad = curses.textpad.Textbox(editWindow)
            return textpad, editWindow

        #just directly login:
        self.username = str(settings.username)
        self.password = str(settings.password)
        self.savePass = settings.save_password
        startY = 1
        startX = 0
        while not self.username or not self.password:
            self.stdscr.addstr(
                startY, startX,
                'Enter your username- use emacs bindings (ctrl-g to enter).')
            curses.curs_set(1)
            self.stdscr.refresh()
            textpad, win = make_textpad()
            #TODO: this should be in a thread
            self.username = textpad.edit().rstrip()
            win.clear()
            self.stdscr.addstr(
                startY, startX,
                'Enter your password- use emacs bindings (ctrl-g to enter).')
            textpad, win = make_textpad()
            win.clear()
            self.stdscr.refresh()
            self.password = textpad.edit().rstrip()
            #check that the username is possibly valid:
            if not Globals.USERNAME_REGEX.match(self.username):
                log_msg(
                    "Usernames can only contain A-Z, a-z, 0-9, -, _, and spaces in the middle",
                    0)
                self.username = None

        curses.curs_set(0)
        callback(self.username, self.password)
Esempio n. 17
0
 def do_verification_prompt(self, callback):
   #global config stores the last user that logged in (and his password)
   settings = GlobalSettings.get()
   
   def make_textpad():
     editWindow = self.stdscr.derwin(1, curses.COLS-startX, startY + 1, startX)
     editWindow.clear()
     textpad = curses.textpad.Textbox(editWindow)
     return textpad, editWindow
     
   #just directly login:
   self.username = str(settings.username)
   self.password = str(settings.password)
   self.savePass = settings.save_password
   startY = 1
   startX = 0
   while not self.username or not self.password:
     self.stdscr.addstr(startY, startX, 'Enter your username- use emacs bindings (ctrl-g to enter).')
     curses.curs_set(1)
     self.stdscr.refresh()
     textpad, win = make_textpad()
     #TODO: this should be in a thread
     self.username = textpad.edit().rstrip()
     win.clear()
     self.stdscr.addstr(startY, startX, 'Enter your password- use emacs bindings (ctrl-g to enter).')
     textpad, win = make_textpad()
     win.clear()
     self.stdscr.refresh()
     self.password = textpad.edit().rstrip()
     #check that the username is possibly valid:
     if not Globals.USERNAME_REGEX.match(self.username):
       log_msg("Usernames can only contain A-Z, a-z, 0-9, -, _, and spaces in the middle", 0)
       self.username = None
   
   curses.curs_set(0)
   callback(self.username, self.password)