Пример #1
0
 def on_change_icon_size(self, event):
     """Handles the value change of icon_size dropbox"""
     tools.debug_output(
         __name__, 'on_change_icon_size',
         'Preference - General - change icon size: ' + str(event), 1)
     tools.debug_output(
         __name__, 'on_change_icon_size', 'New icon size is set to: ' +
         str(self.ui__cb_iconsizes.GetValue()) + 'px', 1)
     ini.write_single_ini_value(
         'General', 'icon_size',
         self.ui__cb_iconsizes.GetValue())  # update preference value
Пример #2
0
 def on_change_transparency(self, event):
     """Handles the value change of transparency dropbox"""
     tools.debug_output(
         __name__, 'on_change_transparency',
         'Preference - General - change transparency: ' + str(event), 1)
     tools.debug_output(
         __name__, 'on_change_transparency',
         'New transparency value is set to: ' +
         str(self.ui__cb_transparency.GetValue()), 1)
     ini.write_single_ini_value(
         'General', 'transparency',
         self.ui__cb_transparency.GetValue())  # update preference value
Пример #3
0
 def prefs_general_toggle_hide_ui(self, event):
     """Toggle the general pref: hide_ui"""
     tools.debug_output(__name__, 'prefs_general_toggle_hide_ui',
                        'Preference - General - Hide UI: ' + str(event), 1)
     if self.cb_enable_hide_ui.GetValue() is True:
         tools.debug_output(__name__, 'prefs_general_toggle_hide_ui',
                            'Enabled', 1)
         ini.write_single_ini_value('General',
                                    'hide_ui_after_command_execution',
                                    "True")  # update preference value
     else:
         tools.debug_output(__name__, 'prefs_general_toggle_hide_ui',
                            'Disabled', 1)
         ini.write_single_ini_value('General',
                                    'hide_ui_after_command_execution',
                                    "False")  # update preference value
Пример #4
0
    def on_plugin_checkbox_change(self, event):
        """Triggered if a checkbox state is changing and writes the new state to ini"""
        btn = event.GetEventObject().GetLabel()  # button label
        value = event.GetEventObject().GetValue()  # button value
        ui_element = event.GetEventObject()  # object itself

        if value is True:
            check_requirements = requirements.check_plugin_requirements(
                btn
            )  # check if requirements for this plugin are fulfilled, otherwise enabling doesnt make sense
            if check_requirements is True:
                tools.debug_output(__name__, 'on_plugin_checkbox_change',
                                   'Enabled Plugin: ' + btn, 1)
                ini.write_single_ini_value('Plugins', 'plugin_' + btn, 'True')
            else:
                tools.debug_output(
                    __name__, 'on_plugin_checkbox_change',
                    'Can not enable plugin: ' + btn +
                    ' due to missing requirements', 3)
                ui_element.SetValue(False)
                ini.write_single_ini_value('Plugins', 'plugin_' + btn, 'False')
                wx.MessageBox(
                    'Plugin can not be enabled because of missing requirements',
                    'Error', wx.OK | wx.ICON_WARNING)

        else:
            tools.debug_output(__name__, 'on_plugin_checkbox_change',
                               'Disabled Plugin: ' + btn, 1)
            ini.write_single_ini_value('Plugins', 'plugin_' + btn, 'False')
def execute_internet_search(main_window, command, parameter):
    """Plugin: Internet-Search - Execute the actual internet search call"""
    tools.debug_output(__name__, 'execute_internet_search', 'starting', 1)

    # get tuple position of command
    index = TRIGGER.index(command)

    # get url based on tuple index
    remote_url = URLS[index] + parameter

    if (
            len(parameter) == 0
    ):  # if so searchphrase/parameter was supplied - open the main url (Issue #22)
        tools.debug_output(__name__, 'execute_internet_search',
                           'No searchphrase supplied, trunc to main-url',
                           1)  # Issue #22
        remote_url = tools.trunc_at(remote_url, "/")

    ## open the URL
    webbrowser.open(remote_url)

    ## update usage-statistics
    tools.debug_output(__name__, 'execute_internet_search',
                       'Updating statistics (plugin_executed)', 1)
    current_plugin_executed_count = ini.read_single_ini_value(
        'Statistics', 'plugin_executed')  # get current value from ini
    ini.write_single_ini_value('Statistics', 'plugin_executed',
                               int(current_plugin_executed_count) +
                               1)  # update ini +1

    # reset the UI
    main_window.reset_ui()

    ## if enabled in ini - hide the UI after executing the command
    cur_ini_value_for_hide_ui_after_command_execution = ini.read_single_ini_value(
        'General',
        'hide_ui_after_command_execution')  # get current value from ini
    if cur_ini_value_for_hide_ui_after_command_execution == 'True':
        main_window.tbicon.execute_tray_icon_left_click()
Пример #6
0
def execute_password_generation(main_window):
    """Handles the actual password generation process"""
    tools.debug_output(__name__, 'execute_password_generation', 'started', 1)
    dlg = wx.TextEntryDialog(None, 'Please insert desired password length', 'Password Generator', '8')
    ret = dlg.ShowModal()
    if ret == wx.ID_OK:
        tools.debug_output(__name__, 'execute_password_generation', 'Password length set to: '+dlg.GetValue(), 1)
        try:
            password_length = int(dlg.GetValue())
            if password_length < 8:
                password_length = 8
                wx.MessageBox('Forced minimal password length 8', 'Password Generator', wx.OK | wx.ICON_WARNING)

            dial = wx.MessageDialog(None, 'Should the password be memorable?', 'Password Generator', wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
            pw_type = dial.ShowModal()

            single_generated_password = ''
            generated_passwords = ''

            if pw_type == wx.ID_YES:
                tools.debug_output(__name__, 'execute_password_generation', 'User selected memorable password type', 1)

                for x in range(0, 5): # generate 5 memorizable passwords
                    tools.debug_output(__name__, 'execute_password_generation', 'Generating memorable password '+str(x), 1)
                    single_generated_password = make_pseudo_word(syllables=password_length, add_number=False)
                    single_generated_password = single_generated_password[0:password_length] # substring to correct length
                    generated_passwords = generated_passwords+single_generated_password+'\n'

                ## add xkcd style pw_type
                xkcd = generate_xkcd_password()
                generated_passwords = generated_passwords+'\n\nXKCD (936) like:\n'+xkcd

            else:
                tools.debug_output(__name__, 'execute_password_generation', 'User selected default password type', 1)

                for x in range(0, 5): # generate 5 default passwords
                    tools.debug_output(__name__, 'execute_password_generation', 'Generating general password '+str(x), 1)

                    chars = string.ascii_letters + string.digits + '!@#$%^&*()'
                    random.seed = (os.urandom(1024))

                    single_generated_password = ''.join(random.choice(chars) for i in range(password_length))
                    generated_passwords = generated_passwords+single_generated_password+'\n'

            ## output the passwords
            wx.MessageBox('Choose from the following:\n\n'+generated_passwords, 'Password Generator', wx.OK | wx.ICON_INFORMATION)

            ## update usage-statistics
            tools.debug_output(__name__, 'execute_password_generation', 'Updating statistics (plugin_executed)', 1)
            current_plugin_executed_count = ini.read_single_ini_value('Statistics', 'plugin_executed') # get current value from ini
            ini.write_single_ini_value('Statistics', 'plugin_executed', int(current_plugin_executed_count)+1) # update ini +1

        except ValueError:
            tools.debug_output(__name__, 'execute', 'Password length entered by user was not a number', 3)
            wx.MessageBox('Length was not a number', 'Password Generator', wx.OK | wx.ICON_WARNING)

    else:
        tools.debug_output(__name__, 'execute', 'Password length definition canceld by user', 2)

    ## reset the UI
    main_window.reset_ui()

    ## if enabled in ini - hide the UI after executing the command
    cur_ini_value_for_hide_ui_after_command_execution = ini.read_single_ini_value('General', 'hide_ui_after_command_execution') # get current value from ini
    if cur_ini_value_for_hide_ui_after_command_execution == 'True':
        main_window.tbicon.execute_tray_icon_left_click()