aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-07 16:36:15 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-07 16:36:15 +0200
commit5c09159aed997498d2f59f8d4025811f363586c0 (patch)
tree7d4cf52ab84c93176b0032f8e9ddddfe24bdd3dd
parent1fc5c689ed63b2c053ed223453d22c5559c706d6 (diff)
parent420754489ea3275002736ca1986da13ca959bd11 (diff)
downloadnx-libs-5c09159aed997498d2f59f8d4025811f363586c0.tar.gz
nx-libs-5c09159aed997498d2f59f8d4025811f363586c0.tar.bz2
nx-libs-5c09159aed997498d2f59f8d4025811f363586c0.zip
Merge branch 'uli42-pr/pylint_fixes' into 3.6.x
Attributes GH PR #1002: https://github.com/ArcticaProject/nx-libs/pull/1002
-rwxr-xr-xnxdialog/bin/nxdialog61
1 files changed, 35 insertions, 26 deletions
diff --git a/nxdialog/bin/nxdialog b/nxdialog/bin/nxdialog
index a455e75b5..ab0dbf17f 100755
--- a/nxdialog/bin/nxdialog
+++ b/nxdialog/bin/nxdialog
@@ -38,7 +38,7 @@
# - removed neatx entry from the pulldoww menu
# - use PyGObject instead of PyGtk and thus Gtk3
# - replace optparse by argparse
-# - make code compatible to python2 and python3.
+# - make code compatible to python2 and python3.
"""nxdialog program for handling dialog display."""
@@ -47,7 +47,10 @@
#
# Examples:
# nxdialog --dialog yesno --message "message text" --caption "message title" --parent 0
-# nxdialog --dialog pulldown --message "message text" --caption "message title" --window 0x123456 --parent 0
+# nxdialog --dialog pulldown --message "message text" --caption "message title" \
+# --window 0x123456 --parent 0
+#
+# pylint: disable=fixme, broad-except
from __future__ import print_function
@@ -155,6 +158,7 @@ class PullDownMenu(object):
Gtk.main_quit()
@staticmethod
+ # pylint: disable=unused-argument
def pos_menu(menu, _xpos, _ypos, *data):
""" Positions menu at the top center of the parent window. """
parent = data[0]
@@ -330,6 +334,34 @@ class NxDialogProgram(object):
return parser.parse_args()
+ def show_dialog(self, message_caption, message_text):
+ """ Show the dialog or exit with failure if not implemented. """
+ dlgtype = self.options.dialog_type
+ if dlgtype == DLG_TYPE_OK:
+ show_simple_message_box(
+ Gtk.MessageType.INFO, message_caption, message_text)
+
+ elif dlgtype in (DLG_TYPE_ERROR, DLG_TYPE_PANIC):
+ show_simple_message_box(
+ Gtk.MessageType.ERROR, message_caption, message_text)
+
+ elif dlgtype == DLG_TYPE_PULLDOWN:
+ handle_session_action(self.options.agentpid,
+ PullDownMenu(self.options.window).show())
+
+ elif dlgtype == DLG_TYPE_YESNOSUSPEND:
+ handle_session_action(self.options.agentpid,
+ show_yes_no_suspend_box(message_caption, message_text))
+
+ elif dlgtype == DLG_TYPE_YESNO:
+ handle_session_action(self.options.agentpid,
+ show_yes_no_box(message_caption, message_text))
+
+ else:
+ # TODO: Implement all dialog types
+ sys.stderr.write("Dialog type '%s' not implemented" % (dlgtype))
+ sys.exit(EXIT_FAILURE)
+
def run(self):
""" Disconnect/terminate NX session upon user's request. """
@@ -366,30 +398,7 @@ class NxDialogProgram(object):
if self.options.display:
os.environ["DISPLAY"] = self.options.display
- if dlgtype == DLG_TYPE_OK:
- show_simple_message_box(
- Gtk.MessageType.INFO, message_caption, message_text)
-
- elif dlgtype in (DLG_TYPE_ERROR, DLG_TYPE_PANIC):
- show_simple_message_box(
- Gtk.MessageType.ERROR, message_caption, message_text)
-
- elif dlgtype == DLG_TYPE_PULLDOWN:
- handle_session_action(self.options.agentpid,
- PullDownMenu(self.options.window).show())
-
- elif dlgtype == DLG_TYPE_YESNOSUSPEND:
- handle_session_action(self.options.agentpid,
- show_yes_no_suspend_box(message_caption, message_text))
-
- elif dlgtype == DLG_TYPE_YESNO:
- handle_session_action(self.options.agentpid,
- show_yes_no_box(message_caption, message_text))
-
- else:
- # TODO: Implement all dialog types
- sys.stderr.write("Dialog type '%s' not implemented" % (dlgtype))
- sys.exit(EXIT_FAILURE)
+ self.show_dialog(message_caption, message_text)
NxDialogProgram().main()