From 4d1687c5c1656ad8ed6feb9243165f8fde7b3c25 Mon Sep 17 00:00:00 2001 From: gm10 <13855078+gm10@users.noreply.github.com> Date: Wed, 13 Feb 2019 16:35:53 +0100 Subject: [PATCH] fix indentation bug in add_execute_suggestions, some coding style --- .../mintMenu/plugins/applications.py | 24 ++++++++++--------- .../linuxmint/mintMenu/plugins/terminal.py | 10 ++++---- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 14513f2..f2defc7 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -654,13 +654,16 @@ class pluginclass(object): return commands = user_text.split() cmd = self.verify_command(commands[0]) - if cmd: - text = "%s" % cgi.escape(text) - commands[0] = cmd - if cmd.startswith("xdg-open"): - self.add_suggestion("document-open", _("Try to open %s") % text, None, self.execute_user_input, commands, False) - else: - self.add_suggestion("application-x-executable", _("Run %s") % text, None, self.execute_user_input, commands, False) + if not cmd: + return + text = "%s" % cgi.escape(text) + commands[0] = cmd + if cmd.startswith("xdg-open"): + self.add_suggestion("document-open", _("Try to open %s") % text, + None, self.execute_user_input, commands, False) + else: + self.add_suggestion("application-x-executable", _("Run %s") % text, + None, self.execute_user_input, commands, False) self.applicationsBox.get_children()[-1].grab_focus() def add_apt_filter_results(self, keyword): @@ -1086,10 +1089,9 @@ class pluginclass(object): if hasVte and self.integrated_terminal_enabled: try: IntegratedTerminal(command, - _("mintMenu Integrated Terminal"), - width=self.integrated_terminal_width, - height=self.integrated_terminal_height - ) + _("mintMenu Integrated Terminal"), + width=self.integrated_terminal_width, + height=self.integrated_terminal_height) except Exception as e: print("IntegratedTerminal exception:", e) hasVte = False diff --git a/usr/lib/linuxmint/mintMenu/plugins/terminal.py b/usr/lib/linuxmint/mintMenu/plugins/terminal.py index 45cc71e..849853b 100644 --- a/usr/lib/linuxmint/mintMenu/plugins/terminal.py +++ b/usr/lib/linuxmint/mintMenu/plugins/terminal.py @@ -19,9 +19,9 @@ class IntegratedTerminal(Gtk.Window): self.command = command self.ready = False self.output_handler = self.terminal.connect("cursor-moved", - self.on_cursor_moved) - # apparently Vte.Terminal.spawn_sync() is deprecated in favour of the - # non-existent Vte.Terminal.spawn_async()... + self.on_cursor_moved) + # apparently Vte.Terminal.spawn_sync() is deprecated in favour of + # the non-existent Vte.Terminal.spawn_async()... self.terminal.spawn_sync( Vte.PtyFlags.DEFAULT, # pty_flags cwd or os.environ.get("HOME"), # working_directory @@ -81,11 +81,11 @@ class IntegratedTerminal(Gtk.Window): if not line.lstrip(prefix): # we got a command prompt, exit self.exit() - break + return # the command generated output, show the terminal terminal.disconnect(self.output_handler) self.show_all() - break + return if self.command in line: # this is our command line prefix = line.split(self.command, 1)[0]