Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
3a097e6e
Commit
3a097e6e
authored
Feb 28, 2019
by
Ulrich Sibiller
Committed by
Mike Gabriel
Mar 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nxdialog: use gtk3 instead of gtk2
parent
2aa575f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
28 deletions
+35
-28
nxdialog
nxdialog/nxdialog
+35
-28
No files found.
nxdialog/nxdialog
View file @
3a097e6e
...
...
@@ -30,6 +30,7 @@
# - added missing docstrings
# - pylint improvements
# - removed neatx entry from the pulldoww menu
# - use PyGObject instead of PyGtk and thus Gtk3
"""nxdialog program for handling dialog display."""
...
...
@@ -41,10 +42,10 @@ import os
import
signal
import
sys
import
g
tk
import
pygtk
pygtk
.
require
(
"2.0"
)
import
g
i
gi
.
require_version
(
'Gtk'
,
'3.0'
)
# pylint: disable=wrong-import-position
from
gi.repository
import
Gtk
,
Gdk
,
GdkX11
PROGRAM
=
"nxdialog"
...
...
@@ -95,58 +96,62 @@ class PullDownMenu(object):
def
show
(
self
):
""" Shows popup and returns result. """
win
=
gtk
.
gdk
.
window_foreign_new
(
self
.
window_id
)
display
=
Gdk
.
Display
.
get_default
()
win
=
GdkX11
.
X11Window
.
foreign_new_for_display
(
display
,
self
.
window_id
)
menu
=
g
tk
.
Menu
()
menu
=
G
tk
.
Menu
()
menu
.
connect
(
"deactivate"
,
self
.
menu_deactivate
)
# TODO: Show title item in bold font
title
=
g
tk
.
MenuItem
(
label
=
"Session control"
)
title
=
G
tk
.
MenuItem
(
label
=
"Session control"
)
title
.
set_sensitive
(
False
)
menu
.
append
(
title
)
disconnect
=
g
tk
.
MenuItem
(
label
=
DISCONNECT_TEXT
)
disconnect
=
G
tk
.
MenuItem
(
label
=
DISCONNECT_TEXT
)
disconnect
.
connect
(
"activate"
,
self
.
item_activate
,
DISCONNECT
)
menu
.
append
(
disconnect
)
terminate
=
g
tk
.
MenuItem
(
label
=
TERMINATE_TEXT
)
terminate
=
G
tk
.
MenuItem
(
label
=
TERMINATE_TEXT
)
terminate
.
connect
(
"activate"
,
self
.
item_activate
,
TERMINATE
)
menu
.
append
(
terminate
)
menu
.
append
(
g
tk
.
SeparatorMenuItem
())
menu
.
append
(
G
tk
.
SeparatorMenuItem
())
cancel
=
g
tk
.
MenuItem
(
label
=
CANCEL_TEXT
)
cancel
=
G
tk
.
MenuItem
(
label
=
CANCEL_TEXT
)
menu
.
append
(
cancel
)
menu
.
show_all
()
menu
.
popup
(
parent_menu_shell
=
None
,
parent_menu_item
=
None
,
func
=
self
.
pos_menu
,
data
=
win
,
button
=
0
,
activate_time
=
g
tk
.
get_current_event_time
())
button
=
0
,
activate_time
=
G
tk
.
get_current_event_time
())
g
tk
.
main
()
G
tk
.
main
()
return
self
.
result
def
item_activate
(
self
,
_
,
result
):
""" called when a menu item is selected """
self
.
result
=
result
g
tk
.
main_quit
()
G
tk
.
main_quit
()
@staticmethod
def
menu_deactivate
(
_
):
""" called when menu is deactivated """
g
tk
.
main_quit
()
G
tk
.
main_quit
()
@staticmethod
def
pos_menu
(
menu
,
parent
):
def
pos_menu
(
menu
,
_xpos
,
_ypos
,
*
data
):
""" Positions menu at the top center of the parent window. """
parent
=
data
[
0
]
# Get parent geometry and origin
(
_
,
_
,
win_width
,
_
,
_
)
=
parent
.
get_geometry
()
(
win_x
,
win_y
)
=
parent
.
get_origin
()
_
,
_
,
win_width
,
_
=
parent
.
get_geometry
()
_
,
win_x
,
win_y
=
parent
.
get_origin
()
# Calculate width of menu
(
menu_width
,
_
)
=
menu
.
size_request
()
#menu_width = menu.get_preferred_width().natural_width
menu_width
=
menu
.
get_allocated_width
()
# Calculate center
center_x
=
win_x
+
((
win_width
-
menu_width
)
/
2
)
...
...
@@ -164,12 +169,13 @@ def show_yes_no_suspend_box(title, text):
@return: Choosen action
"""
dlg
=
gtk
.
MessageDialog
(
type
=
gtk
.
MESSAGE_QUESTION
,
flags
=
gtk
.
DIALOG_MODAL
)
dlg
=
Gtk
.
MessageDialog
(
type
=
Gtk
.
MessageType
.
QUESTION
,
flags
=
Gtk
.
DialogFlags
.
MODAL
)
dlg
.
set_title
(
title
)
dlg
.
set_markup
(
text
)
dlg
.
add_button
(
DISCONNECT_TEXT
,
DISCONNECT
)
dlg
.
add_button
(
TERMINATE_TEXT
,
TERMINATE
)
dlg
.
add_button
(
CANCEL_TEXT
,
gtk
.
RESPONSE_
CANCEL
)
dlg
.
add_button
(
CANCEL_TEXT
,
Gtk
.
ResponseType
.
CANCEL
)
res
=
dlg
.
run
()
...
...
@@ -190,11 +196,12 @@ def show_yes_no_box(title, text):
@return: Choosen action
"""
dlg
=
gtk
.
MessageDialog
(
type
=
gtk
.
MESSAGE_QUESTION
,
flags
=
gtk
.
DIALOG_MODAL
)
dlg
=
Gtk
.
MessageDialog
(
type
=
Gtk
.
MessageType
.
QUESTION
,
flags
=
Gtk
.
DialogFlags
.
MODAL
)
dlg
.
set_title
(
title
)
dlg
.
set_markup
(
text
)
dlg
.
add_button
(
YES_TEXT
,
TERMINATE
)
dlg
.
add_button
(
NO_TEXT
,
gtk
.
RESPONSE_
CANCEL
)
dlg
.
add_button
(
NO_TEXT
,
Gtk
.
ResponseType
.
CANCEL
)
res
=
dlg
.
run
()
...
...
@@ -241,8 +248,8 @@ def show_simple_message_box(icon, title, text):
@param text: Message box text
"""
dlg
=
gtk
.
MessageDialog
(
type
=
icon
,
flags
=
gtk
.
DIALOG_
MODAL
,
buttons
=
gtk
.
BUTTONS_
OK
)
dlg
=
Gtk
.
MessageDialog
(
type
=
icon
,
flags
=
Gtk
.
DialogFlags
.
MODAL
,
buttons
=
Gtk
.
ButtonsType
.
OK
)
dlg
.
set_title
(
title
)
dlg
.
set_markup
(
text
)
dlg
.
run
()
...
...
@@ -304,7 +311,7 @@ class NxDialogProgram(object):
default: info) [currently unimplemented]"
),
optparse
.
make_option
(
"--local"
,
action
=
"store_true"
,
dest
=
"local"
,
help
=
"specify that proxy mode is used
\
[currently unimplemented]"
),
[currently unimplemented]"
),
optparse
.
make_option
(
"--allowmultiple"
,
action
=
"store_true"
,
dest
=
"allowmultiple"
,
help
=
"allow launching more than one dialog with
\
...
...
@@ -349,11 +356,11 @@ class NxDialogProgram(object):
if
dlgtype
==
DLG_TYPE_OK
:
show_simple_message_box
(
gtk
.
MESSAGE_
INFO
,
message_caption
,
message_text
)
Gtk
.
MessageType
.
INFO
,
message_caption
,
message_text
)
elif
dlgtype
in
(
DLG_TYPE_ERROR
,
DLG_TYPE_PANIC
):
show_simple_message_box
(
gtk
.
MESSAGE_
ERROR
,
message_caption
,
message_text
)
Gtk
.
MessageType
.
ERROR
,
message_caption
,
message_text
)
elif
dlgtype
==
DLG_TYPE_PULLDOWN
:
handle_session_action
(
self
.
options
.
agentpid
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment