def parse(current_search_string, main_window): """Parses the input if a core command was entered. Adjusts the UI and calls the needed commands""" tools.debug_output(__name__, 'parse', 'starting', 1) icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value ## Reset status notification back to OK main_window.status_notification_reset() ## Help # if current_search_string == '!help': # opens online documentation of apparat tools.debug_output(__name__, 'parse', 'Case: Help', 1) # show icon for really fast users main_window.ui__bt_command_img = wx.Image( 'gfx/plugins/core/' + icon_size + '/help.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_command.SetBitmap( main_window.ui__bt_command_img.ConvertToBitmap()) main_window.ui__bt_command.SetToolTipString('Open help') main_window.open_app_url() # hide UI 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': tools.debug_output(__name__, 'parse', 'Hide Main UI after executing a command', 1) main_window.tbicon.execute_tray_icon_left_click() main_window.reset_ui() ## Preferences # elif current_search_string == '!preferences' or current_search_string == '!prefs': # opens apparat_launcher preferences tools.debug_output(__name__, 'parse', 'Case: Preferences', 1) # show icon for really fast users main_window.ui__bt_command_img = wx.Image( 'gfx/plugins/core/' + icon_size + '/preferences.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_command.SetBitmap( main_window.ui__bt_command_img.ConvertToBitmap()) main_window.ui__bt_command.SetToolTipString('Open preferences') main_window.open_preference_window() main_window.reset_ui() ## Invalid # else: tools.debug_output(__name__, 'parse', 'Error: Unexpected core plugin command', 3) main_window.status_notification_display_error( 'Unexpected core plugin command') tools.debug_output(__name__, 'parse', 'Finished handling core command', 1)
def parse(main_window): """Prepares the UI for executing the xkill command""" tools.debug_output(__name__, 'parse', 'starting', 1) main_window.status_notification_reset( ) # Reset status notification back to OK main_window.plugin__update_general_ui_information( 'Kill') # update plugin info icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value ## command button & txt main_window.ui__bt_command_img = wx.Image( 'gfx/plugins/kill/' + icon_size + '/kill.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_command.SetBitmap( main_window.ui__bt_command_img.ConvertToBitmap()) main_window.ui__bt_command.SetToolTipString( 'Kill application by selecting a window with your cursor') main_window.ui__txt_command.SetValue('xkill') ## parameter button & txt main_window.ui__bt_parameter.SetToolTipString('Start rampage') main_window.ui__bt_parameter_img = wx.Image( 'gfx/core/' + icon_size + '/execute.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_parameter.SetBitmap( main_window.ui__bt_parameter_img.ConvertToBitmap()) main_window.ui__txt_parameter.SetValue('')
def parse(current_search_string, main_window): """Validates the input and calls the matching sub-function""" tools.debug_output(__name__, 'parse', 'starting', 1) # Reset status notification back to OK main_window.status_notification_reset() icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value if current_search_string.startswith('!goto'): tools.debug_output(__name__, 'parse', 'Case: Goto', 1) prepare_plugin_nautilus_goto(main_window, icon_size) elif current_search_string == ('!recent'): tools.debug_output(__name__, 'parse', 'Case: Recent', 1) prepare_plugin_nautilus_show_recent(main_window, icon_size) elif current_search_string == ('!trash'): tools.debug_output(__name__, 'parse', 'Case: Trash', 1) prepare_plugin_nautilus_open_trash(main_window, icon_size) elif current_search_string == ('!network') or current_search_string == ( '!net'): tools.debug_output(__name__, 'parse', 'Case: Network', 1) prepare_plugin_nautilus_show_network_devices(main_window, icon_size) else: tools.debug_output(__name__, 'parse', 'Error: Unexpected nautilus plugin command', 3) main_window.status_notification_display_error( 'Unexpected nautilus plugin command') tools.debug_output(__name__, 'parse', 'finished', 1)
def parse(current_search_string, main_window): """Validates input and loads the command related sub function""" tools.debug_output(__name__, 'prepare_general', 'starting', 1) ## Reset status notification back to OK main_window.status_notification_reset() icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value ## Selective Screenshot # if current_search_string == "!ss": tools.debug_output(__name__, 'parse', 'Case: Selective Screenshot', 1) prepare_selective_screenshot(main_window, icon_size) ## Full Screenshot # elif current_search_string == "!fs": tools.debug_output(__name__, 'parse', 'Case: Full Screenshot', 1) prepare_full_screenshot(main_window, icon_size) ## Invalid input # else: tools.debug_output(__name__, 'parse', 'Error: Unexpected screenshot plugin command', 3) main_window.status_notification_display_error('Unexpected screenshot plugin command') return
def parse(main_window, current_search_string): """Updates the UI according to the matching internet-search trigger""" tools.debug_output(__name__, 'prepare_internet_search', 'starting', 1) ## Reset status notification back to OK main_window.status_notification_got_distinct_result() icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value ## show searchstring in parameter field if (main_window.ui__txt_command.GetValue() != ''): cur_searchphrase_parameter = current_search_string[ 3:] # remove trigger - example: '!y ' main_window.ui__txt_parameter.SetValue(cur_searchphrase_parameter) ## check if there is NO space after the trigger - abort this function and reset some parts of the UI if (len(current_search_string) >= 4) and (current_search_string[3] != " "): tools.debug_output(__name__, 'parse', 'No space after trigger - should reset icons', 1) main_window.plugin__update_general_ui_information('') main_window.status_notification_display_error('Invalid input') return ## If search-string > 3 - abort - as all the work is already done # if (len(current_search_string) > 3): return # we can stop here - nothing more to do as plugin should be already activated # get tuple position of command index = TRIGGER.index(current_search_string) # get icon-name based on tuple index icon = 'gfx/plugins/search_internet/' + icon_size + '/' + ICONS[index] # get description based on tuple index description = DESCRIPTIONS[index] # update UI with icon and description main_window.ui__bt_command_img = wx.Image(icon, wx.BITMAP_TYPE_PNG) main_window.plugin__update_general_ui_information(description) ## command button main_window.ui__bt_command.Enable(True) main_window.ui__bt_command.SetBitmap( main_window.ui__bt_command_img.ConvertToBitmap()) ## parameter button main_window.ui__bt_parameter_img = wx.Image( 'gfx/core/' + icon_size + '/search.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_parameter.Enable(True) main_window.ui__bt_parameter.SetBitmap( main_window.ui__bt_parameter_img.ConvertToBitmap()) main_window.ui__bt_parameter.SetToolTipString('Search')
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()
def __init__(self, parent): """Inits the statistics tab""" wx.Panel.__init__(self, parent) ## show app start counter cur_ini_value_for_apparat_started = ini.read_single_ini_value( 'Statistics', 'apparat_started') # get current value from ini txt_stats__apparat_started = wx.StaticText( self, -1, "Apparat started:\t\t\t" + cur_ini_value_for_apparat_started, (20, 20)) ## show execute counter cur_ini_value_for_command_executed = ini.read_single_ini_value( 'Statistics', 'command_executed') # get current value from ini txt_stats__command_executed = wx.StaticText( self, -1, "Command executed:\t\t" + cur_ini_value_for_command_executed, (20, 40)) ## show plugin trigger count cur_ini_value_for_plugin_executed = ini.read_single_ini_value( 'Statistics', 'plugin_executed') # get current value from ini txt_stats__plugin_executed = wx.StaticText( self, -1, "Plugins executed:\t\t\t" + cur_ini_value_for_plugin_executed, (20, 60)) ## Layout statistics_sizer = wx.BoxSizer(wx.VERTICAL) # define layout container statistics_sizer.AddSpacer(10) statistics_sizer.Add(txt_stats__apparat_started, 0, wx.ALL, border=10) statistics_sizer.AddSpacer(10) statistics_sizer.Add(txt_stats__command_executed, 0, wx.ALL, border=10) statistics_sizer.AddSpacer(10) statistics_sizer.Add(txt_stats__plugin_executed, 0, wx.ALL, border=10) self.SetSizer(statistics_sizer)
def parse(current_search_string, main_window): """Valides the input and prepares the UI for executing the password command""" tools.debug_output(__name__, 'parse', 'starting', 1) ## Reset status notification back to OK main_window.status_notification_reset() icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value if current_search_string == ('!pw') or current_search_string == ('!password'): tools.debug_output(__name__, 'parse', 'Case: Password Generator', 1) prepare_plugin_passwordgen(main_window, icon_size) else: tools.debug_output(__name__, 'parse', 'Error: Unexpected passwordgen plugin command', 3) main_window.status_notification_display_error('Unexpected passwordgen plugin command') tools.debug_output(__name__, 'parse', 'finished', 1)
def parse(current_search_string, main_window): """Validates the misc command and calls the matching sub function""" tools.debug_output(__name__, 'parse', 'starting', 1) # Reset status notification back to OK main_window.status_notification_reset() icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value if current_search_string.startswith('!open'): tools.debug_output(__name__, 'parse', 'Case: Open', 1) prepare_plugin_misc_open(main_window, icon_size) else: tools.debug_output(__name__, 'parse', 'Error: Unexpected misc plugin command', 3) main_window.status_notification_display_error( 'Unexpected misc plugin command') tools.debug_output(__name__, 'parse', 'finished', 1)
def parse(current_search_string, main_window): """parse""" tools.debug_output(__name__, 'parse', 'starting', 1) main_window.status_notification_reset() # Reset status notification back to OK icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value if current_search_string.startswith("!sh"): tools.debug_output(__name__, 'parse', 'Case: Shell', 1) prepare_plugin_shell(main_window, icon_size) if (len(current_search_string) > 3): if current_search_string.startswith("!sh "): prepare_plugin_shell(main_window, icon_size) else: main_window.plugin__update_general_ui_information('') tools.debug_output(__name__, 'parse', 'Aborting shell', 2) return else: tools.debug_output(__name__, 'parse', 'Error: Unexpected shell plugin command', 3) main_window.status_notification_display_error('Unexpected shell plugin command') return
def parse(current_search_string, main_window): """parse""" tools.debug_output(__name__, 'parse', 'starting with searchstring: '+current_search_string, 1) # Reset status notification back to OK main_window.status_notification_reset() icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value ## Hibernate if current_search_string == '!hibernate' or current_search_string == '!sleep': prepare_plugin_session_hibernate(main_window, icon_size) ## Lock elif current_search_string == '!lock': prepare_plugin_session_lock(main_window, icon_size) ## Logout elif current_search_string == '!logout': prepare_plugin_session_logout(main_window, icon_size) ## Reboot elif current_search_string == '!reboot' or current_search_string == '!restart': prepare_plugin_session_reboot(main_window, icon_size) ## Shutdown elif current_search_string == '!shutdown' or current_search_string == '!halt': prepare_plugin_session_shutdown(main_window, icon_size) ## Screensaver elif current_search_string == '!screensaver' or current_search_string == '!saver': prepare_plugin_session_screensaver(main_window, icon_size) else: tools.debug_output(__name__, 'parse', 'Error: Unexpected session command', 3) main_window.status_notification_display_error('Unexpected session plugin command') return
def search_user_files(main_window, current_search_string): """Search for user files""" tools.debug_output(__name__, 'search_user_files', 'starting', 1) # Reset status notification back to OK main_window.status_notification_reset() icon_size = ini.read_single_ini_value('General', 'icon_size') # get preference value ## reset combobox search_results = [] main_window.ui__cb_search.SetItems(search_results) # update combobox ## update plugin info main_window.plugin__update_general_ui_information('Local Search') ## command button & txt main_window.ui__bt_command_img = wx.Image( 'gfx/plugins/search_local/' + icon_size + '/search.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_command.SetBitmap( main_window.ui__bt_command_img.ConvertToBitmap()) main_window.ui__bt_command.SetToolTipString('Search local user files') main_window.ui__txt_command.SetValue('xdg-open') ## parameter button & txt main_window.ui__bt_parameter_img = wx.Image( 'gfx/core/' + icon_size + '/blank.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_parameter.SetBitmap( main_window.ui__bt_parameter_img.ConvertToBitmap()) main_window.ui__bt_parameter.SetToolTipString('Search local user files') main_window.ui__txt_parameter.SetValue('') if (len(current_search_string) > 4) and current_search_string.startswith('? '): current_search_string = current_search_string[ 2:] # get the real search term without trigger tools.debug_output( __name__, 'search_user_files', 'Searching local files for: ' + current_search_string, 1) root = os.environ['HOME'] pattern = '*' + current_search_string + '*' search_results = [] if (len(current_search_string) > 2): # if search string is long enough tools.debug_output( __name__, 'search_user_files', 'Searching local user files for the following string: ' + current_search_string, 1) exclude = set([ '.cache', '.dbus', '.dropbox', '.dropbox-dist', '.local/share/Trash' ]) # exclude list for file search in home dir for root, dirs, files in os.walk(root): dirs[:] = [d for d in dirs if d not in exclude] for filename in fnmatch.filter(files, pattern): result = os.path.join(root, filename) # append to list search_results.append(result) tools.debug_output( __name__, 'search_user_files', 'Got ' + (str(len(search_results))) + ' Results', 1) ## sort search results search_results = sorted( search_results, key=lambda x: difflib.SequenceMatcher( None, x, current_search_string).ratio(), reverse=True) # better sorting # update result count main_window.ui__txt_result_counter.SetValue( str(len(search_results))) if (len(search_results) > 1): ## command button main_window.ui__bt_command_img = wx.Image( 'gfx/plugins/search_local/' + icon_size + '/files.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_command.SetBitmap( main_window.ui__bt_command_img.ConvertToBitmap()) elif (len(search_results) == 1): ## command button & txt main_window.ui__bt_command_img = wx.Image( 'gfx/plugins/search_local/' + icon_size + '/file.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_command.SetBitmap( main_window.ui__bt_command_img.ConvertToBitmap()) main_window.ui__txt_command.SetValue('xdg-open') ## parameter button & txt main_window.ui__bt_parameter_img = wx.Image( 'gfx/core/' + icon_size + '/execute.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_parameter.SetBitmap( main_window.ui__bt_parameter_img.ConvertToBitmap()) main_window.ui__txt_parameter.SetValue(search_results[0]) else: ## no results main_window.ui__txt_result_counter.SetValue('0') # overwrite ## update application button main_window.ui__bt_command_img = wx.Image( 'gfx/core/' + icon_size + '/blank.png', wx.BITMAP_TYPE_PNG) main_window.ui__bt_command.SetBitmap( main_window.ui__bt_command_img.ConvertToBitmap()) ## update combobox main_window.ui__cb_search.SetItems( search_results) # update combobox else: tools.debug_output(__name__, 'search_user_files', 'aborting search (string too short)', 2) main_window.ui__txt_result_counter.SetValue('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()
def __init__(self, parent): # pylint:disable=too-many-statements """Inits the general tab""" wx.Panel.__init__(self, parent) ## show language ## cur_ini_value_for_language = ini.read_single_ini_value( 'Language', 'lang') # get current value from ini txt_language = wx.StaticText(self, -1, "Language: ", (20, 20)) languages = [cur_ini_value_for_language] combo_box_style = wx.CB_READONLY ui__cb_languages = wx.ComboBox(self, wx.ID_ANY, u'', wx.DefaultPosition, wx.Size(100, 30), languages, style=combo_box_style) ui__cb_languages.SetFont( wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Sans')) ui__cb_languages.SetValue(languages[0]) # line_1 line1 = wx.StaticLine(self, -1, size=(480, 1), style=wx.LI_HORIZONTAL) ## icon sizes ## cur_ini_value_for_iconsize = ini.read_single_ini_value( 'General', 'icon_size') # get current value from ini txt_iconsize = wx.StaticText(self, -1, "Icon Size: ", (20, 20)) available_icon_sizes = ['128', '256'] combo_box_style = wx.CB_READONLY self.ui__cb_iconsizes = wx.ComboBox(self, wx.ID_ANY, u'', wx.DefaultPosition, wx.Size(100, 30), available_icon_sizes, style=combo_box_style) self.ui__cb_iconsizes.SetFont( wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Sans')) self.ui__cb_iconsizes.SetValue(cur_ini_value_for_iconsize) self.ui__cb_iconsizes.Bind(wx.EVT_TEXT, self.on_change_icon_size) # changing # line_2 line2 = wx.StaticLine(self, -1, size=(480, 1), style=wx.LI_HORIZONTAL) ## transparency ## cur_ini_value_for_transparency = ini.read_single_ini_value( 'General', 'transparency') # get current value from ini txt_transparency = wx.StaticText( self, -1, "UI transparency (default 255, needs restart) : ", (20, 20)) available_transparency_values = [ '255', '250', '245', '240', '235', '230', '225', '220', '215', '210', '205', '200' ] combo_box_style = wx.CB_READONLY self.ui__cb_transparency = wx.ComboBox(self, wx.ID_ANY, u'', wx.DefaultPosition, wx.Size(100, 30), available_transparency_values, style=combo_box_style) self.ui__cb_transparency.SetFont( wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Sans')) self.ui__cb_transparency.SetValue(cur_ini_value_for_transparency) self.ui__cb_transparency.Bind(wx.EVT_TEXT, self.on_change_transparency) # changing # line_3 line3 = wx.StaticLine(self, -1, size=(480, 1), style=wx.LI_HORIZONTAL) ## Hide UI ## self.cb_enable_hide_ui = wx.CheckBox( self, -1, 'Hide UI after command execution ', (20, 60)) 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 == "False": self.cb_enable_hide_ui.SetValue(False) else: self.cb_enable_hide_ui.SetValue(True) wx.EVT_CHECKBOX(self, self.cb_enable_hide_ui.GetId(), self.prefs_general_toggle_hide_ui) ## Layout ## general_sizer = wx.BoxSizer(wx.VERTICAL) # define layout container general_sizer.AddSpacer(10) general_sizer.Add(txt_language, 0, wx.ALL, border=10) general_sizer.Add(ui__cb_languages, 0, wx.ALL, border=10) general_sizer.AddSpacer(30) general_sizer.Add(line1, 0, wx.CENTRE) general_sizer.AddSpacer(10) general_sizer.Add(txt_iconsize, 0, wx.ALL, border=10) general_sizer.Add(self.ui__cb_iconsizes, 0, wx.ALL, border=10) general_sizer.AddSpacer(30) general_sizer.Add(line2, 0, wx.CENTRE) general_sizer.AddSpacer(10) general_sizer.Add(txt_transparency, 0, wx.ALL, border=10) general_sizer.Add(self.ui__cb_transparency, 0, wx.ALL, border=10) general_sizer.AddSpacer(30) general_sizer.Add(line3, 0, wx.CENTRE) general_sizer.AddSpacer(10) general_sizer.Add(self.cb_enable_hide_ui, 0, wx.ALL, border=10) self.SetSizer(general_sizer)
def __init__(self, parent): # pylint:disable=too-many-statements, too-many-branches, too-many-locals """Inits the plugin-commands tab""" wx.Panel.__init__(self, parent) # Create a font using wx.FontInfo font = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_NORMAL, False) ## Plugin: core (can not be disabled) ## cb_enable_plugin_core = wx.CheckBox(self, -1, 'Core', (20, 60)) cb_enable_plugin_core.SetLabel('core') cb_enable_plugin_core.SetToolTipString( u'Offers !help !prefs and !preferences.Plugin can not be disabled.' ) cb_enable_plugin_core.SetValue(True) cb_enable_plugin_core.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_click) # changing the checkbox change cb_enable_plugin_core.Enable(False) ## Plugin description txt_plugin_core = wx.StaticText( self, -1, "Offers !help !prefs and !preferences", (20, 40)) txt_plugin_core.SetForegroundColour('#7f8c8d') #txt_plugin_core.SetFont(font) ## Plugin: Kill ## cb_enable_plugin_kill = wx.CheckBox(self, -1, 'Misc', (20, 60)) cb_enable_plugin_kill.SetToolTipString(u'Enable other stuff') cb_enable_plugin_kill.SetLabel('kill') cur_ini_value_for_plugin_kill = ini.read_single_ini_value( 'Plugins', 'plugin_kill') # get current value from ini if cur_ini_value_for_plugin_kill == 'True': cb_enable_plugin_kill.SetValue(True) else: cb_enable_plugin_kill.SetValue(False) cb_enable_plugin_kill.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_kill = wx.StaticText( self, -1, "Kill graphical applications using xkill (requires xkill)", (20, 40)) txt_plugin_kill.SetForegroundColour('#7f8c8d') txt_plugin_kill.SetFont(font) ## Plugin: Misc ## cb_enable_plugin_misc = wx.CheckBox(self, -1, 'Misc', (20, 60)) cb_enable_plugin_misc.SetToolTipString(u'Enable other stuff') cb_enable_plugin_misc.SetLabel('misc') cur_ini_value_for_plugin_misc = ini.read_single_ini_value( 'Plugins', 'plugin_misc') # get current value from ini if cur_ini_value_for_plugin_misc == 'True': cb_enable_plugin_misc.SetValue(True) else: cb_enable_plugin_misc.SetValue(False) cb_enable_plugin_misc.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_misc = wx.StaticText(self, -1, "Enable other stuff", (20, 40)) txt_plugin_misc.SetForegroundColour('#7f8c8d') txt_plugin_misc.SetFont(font) ## Plugin: Nautilus ## cb_enable_plugin_nautilus = wx.CheckBox(self, -1, 'Nautilus', (20, 60)) cb_enable_plugin_nautilus.SetLabel('nautilus') cb_enable_plugin_nautilus.SetToolTipString( u'Enables quick access to some nautilus locations/places') cur_ini_value_for_plugin_nautilus = ini.read_single_ini_value( 'Plugins', 'plugin_nautilus') # get current value from ini if cur_ini_value_for_plugin_nautilus == 'True': cb_enable_plugin_nautilus.SetValue(True) else: cb_enable_plugin_nautilus.SetValue(False) cb_enable_plugin_nautilus.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_nautilus = wx.StaticText( self, -1, "Enables quick access to some nautilus locations/places", (20, 40)) txt_plugin_nautilus.SetForegroundColour('#7f8c8d') txt_plugin_nautilus.SetFont(font) ## Plugin: PasswordGen ## cb_enable_plugin_passwordgen = wx.CheckBox(self, -1, 'Password Generator', (20, 60)) cb_enable_plugin_passwordgen.SetLabel('passwordgen') cb_enable_plugin_passwordgen.SetToolTipString( u'Enables a simple password generator') cur_ini_value_for_plugin_passwordgen = ini.read_single_ini_value( 'Plugins', 'plugin_passwordgen') # get current value from ini if cur_ini_value_for_plugin_passwordgen == 'True': cb_enable_plugin_passwordgen.SetValue(True) else: cb_enable_plugin_passwordgen.SetValue(False) cb_enable_plugin_passwordgen.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_passwordgen = wx.StaticText( self, -1, "Enables a simple password generator", (20, 40)) txt_plugin_passwordgen.SetForegroundColour('#7f8c8d') txt_plugin_passwordgen.SetFont(font) ## Plugin: Screenshot ## cb_enable_plugin_screenshot = wx.CheckBox(self, -1, 'Screenshot', (20, 60)) cb_enable_plugin_screenshot.SetLabel('screenshot') cb_enable_plugin_screenshot.SetToolTipString( u'Enables simple screenshot functions') cur_ini_value_for_plugin_screenshot = ini.read_single_ini_value( 'Plugins', 'plugin_screenshot') # get current value from ini if cur_ini_value_for_plugin_screenshot == 'True': cb_enable_plugin_screenshot.SetValue(True) else: cb_enable_plugin_screenshot.SetValue(False) cb_enable_plugin_screenshot.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_screenshot = wx.StaticText( self, -1, "Enables simple screenshot functions", (20, 40)) txt_plugin_screenshot.SetForegroundColour('#7f8c8d') txt_plugin_screenshot.SetFont(font) ## Plugin: Internet search ## cb_enable_plugin_internet_search = wx.CheckBox(self, -1, 'Internet-Search', (20, 60)) cb_enable_plugin_internet_search.SetLabel('search_internet') cb_enable_plugin_internet_search.SetToolTipString( u'Enables search for several popular web-services') cur_ini_value_for_plugin_search_internet = ini.read_single_ini_value( 'Plugins', 'plugin_search_internet') # get current value from ini if cur_ini_value_for_plugin_search_internet == 'True': cb_enable_plugin_internet_search.SetValue(True) else: cb_enable_plugin_internet_search.SetValue(False) cb_enable_plugin_internet_search.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_internet_search = wx.StaticText( self, -1, "Enables search for several popular web-services", (20, 40)) txt_plugin_internet_search.SetForegroundColour('#7f8c8d') txt_plugin_internet_search.SetFont(font) ## Plugin: Local search ## cb_enable_plugin_local_search = wx.CheckBox(self, -1, 'Local-Search', (20, 60)) cb_enable_plugin_local_search.SetLabel('search_local') cb_enable_plugin_local_search.SetToolTipString( u'Enables search for files and folders in users home directory') cur_ini_value_for_plugin_search_local = ini.read_single_ini_value( 'Plugins', 'plugin_search_local') # get current value from ini if cur_ini_value_for_plugin_search_local == 'True': cb_enable_plugin_local_search.SetValue(True) else: cb_enable_plugin_local_search.SetValue(False) cb_enable_plugin_local_search.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_local_search = wx.StaticText( self, -1, "Enables search for files and folders in users home directory", (20, 40)) txt_plugin_local_search.SetForegroundColour('#7f8c8d') txt_plugin_local_search.SetFont(font) ## Plugin: Session ## cb_enable_plugin_session = wx.CheckBox(self, -1, 'Session', (20, 60)) cb_enable_plugin_session.SetLabel('session') cb_enable_plugin_session.SetToolTipString( u'Enables several session commands') cur_ini_value_for_plugin_session = ini.read_single_ini_value( 'Plugins', 'plugin_session') # get current value from ini if cur_ini_value_for_plugin_session == 'True': cb_enable_plugin_session.SetValue(True) else: cb_enable_plugin_session.SetValue(False) cb_enable_plugin_session.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_session = wx.StaticText(self, -1, "Enables several session commands", (20, 40)) txt_plugin_session.SetForegroundColour('#7f8c8d') txt_plugin_session.SetFont(font) ## Plugin: Shell cb_enable_plugin_shell = wx.CheckBox(self, -1, 'Shell', (20, 60)) cb_enable_plugin_shell.SetLabel('shell') cb_enable_plugin_shell.SetToolTipString( u'Enable executing shell commands') cur_ini_value_for_plugin_shell = ini.read_single_ini_value( 'Plugins', 'plugin_shell') # get current value from ini if cur_ini_value_for_plugin_shell == 'True': cb_enable_plugin_shell.SetValue(True) else: cb_enable_plugin_shell.SetValue(False) cb_enable_plugin_shell.Bind( wx.EVT_CHECKBOX, self.on_plugin_checkbox_change) # changing the checkbox change ## Plugin description txt_plugin_shell = wx.StaticText(self, -1, "Enable executing shell commands", (20, 40)) txt_plugin_shell.SetForegroundColour('#7f8c8d') txt_plugin_shell.SetFont(font) ## Link to plugin commands description wxHyperlinkCtrl = wx.HyperlinkCtrl(self, -1, 'Plugin command details', constants.APP_URL + '#plugins') ## ----------------------- ## Layout ## ----------------------- pref_sizer = wx.BoxSizer(wx.VERTICAL) # define layout container pref_sizer.AddSpacer(10) ## core coreSizer = wx.BoxSizer(wx.HORIZONTAL) coreSizer.Add(cb_enable_plugin_core, 0, wx.ALL, border=10) # status icon button coreSizer.Add(txt_plugin_core, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(coreSizer, 0, wx.EXPAND) ## kill killSizer = wx.BoxSizer(wx.HORIZONTAL) killSizer.Add(cb_enable_plugin_kill, 0, wx.ALL, border=10) # status icon button killSizer.Add(txt_plugin_kill, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(killSizer, 0, wx.EXPAND) ## misc miscSizer = wx.BoxSizer(wx.HORIZONTAL) miscSizer.Add(cb_enable_plugin_misc, 0, wx.ALL, border=10) # status icon button miscSizer.Add(txt_plugin_misc, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(miscSizer, 0, wx.EXPAND) #pref_sizer.AddSpacer(5) ## Nautilus nautilusSizer = wx.BoxSizer(wx.HORIZONTAL) nautilusSizer.Add(cb_enable_plugin_nautilus, 0, wx.ALL, border=10) # status icon button nautilusSizer.Add(txt_plugin_nautilus, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(nautilusSizer, 0, wx.EXPAND) ## PasswordGen passwordgenSizer = wx.BoxSizer(wx.HORIZONTAL) passwordgenSizer.Add(cb_enable_plugin_passwordgen, 0, wx.ALL, border=10) # status icon button passwordgenSizer.Add(txt_plugin_passwordgen, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(passwordgenSizer, 0, wx.EXPAND) ## screenshot screenshotSizer = wx.BoxSizer(wx.HORIZONTAL) screenshotSizer.Add(cb_enable_plugin_screenshot, 0, wx.ALL, border=10) # status icon button screenshotSizer.Add(txt_plugin_screenshot, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(screenshotSizer, 0, wx.EXPAND) ## search internet searchinternetSizer = wx.BoxSizer(wx.HORIZONTAL) searchinternetSizer.Add(cb_enable_plugin_internet_search, 0, wx.ALL, border=10) # status icon button searchinternetSizer.Add(txt_plugin_internet_search, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(searchinternetSizer, 0, wx.EXPAND) ## search local searchlocalSizer = wx.BoxSizer(wx.HORIZONTAL) searchlocalSizer.Add(cb_enable_plugin_local_search, 0, wx.ALL, border=10) # status icon button searchlocalSizer.Add(txt_plugin_local_search, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(searchlocalSizer, 0, wx.EXPAND) ## Session sessionSizer = wx.BoxSizer(wx.HORIZONTAL) sessionSizer.Add(cb_enable_plugin_session, 0, wx.ALL, border=10) # status icon button sessionSizer.Add(txt_plugin_session, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(sessionSizer, 0, wx.EXPAND) ## Shell shellSizer = wx.BoxSizer(wx.HORIZONTAL) shellSizer.Add(cb_enable_plugin_shell, 0, wx.ALL, border=10) # status icon button shellSizer.Add(txt_plugin_shell, 0, wx.ALL, border=10) # preferences icon button pref_sizer.Add(shellSizer, 0, wx.EXPAND) pref_sizer.AddSpacer(10) ## Hyperlink to docs pref_sizer.Add(wxHyperlinkCtrl, 0, wx.ALL, border=10) self.SetSizer(pref_sizer)