Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
pg mr
gajim
Commits
3ded70a5
Commit
3ded70a5
authored
Jun 23, 2019
by
Daniel Brötzmann
Committed by
Philipp Hörist
Jun 25, 2019
Browse files
XML Console: Inherit from Gtk.ApplicationWindow and code formatting
parent
800c5919
Changes
3
Hide whitespace changes
Inline
Side-by-side
gajim/app_actions.py
View file @
3ded70a5
...
...
@@ -34,7 +34,6 @@
from
gajim.gtk.start_chat
import
StartChatDialog
from
gajim.gtk.add_contact
import
AddNewContactWindow
from
gajim.gtk.single_message
import
SingleMessageWindow
from
gajim.gtk.xml_console
import
XMLConsoleWindow
from
gajim.gtk.about
import
AboutDialog
from
gajim.gtk.privacy_list
import
PrivacyListsWindow
from
gajim.gtk.bookmarks
import
ManageBookmarksWindow
...
...
@@ -45,7 +44,7 @@
from
gajim.gtk.proxies
import
ManageProxies
from
gajim.gtk.discovery
import
ServiceDiscoveryWindow
from
gajim.gtk.blocking
import
BlockingList
from
gajim.gtk.xml_console
import
XMLConsoleWindow
# General Actions
...
...
@@ -245,11 +244,11 @@ def on_server_info(action, param):
def
on_xml_console
(
action
,
param
):
account
=
param
.
get_string
()
if
'xml_console'
in
interface
.
instances
[
account
]:
interface
.
instances
[
account
][
'xml_console'
].
present
()
window
=
app
.
get_app_window
(
XMLConsoleWindow
,
account
)
if
window
is
None
:
XMLConsoleWindow
(
account
)
else
:
interface
.
instances
[
account
][
'xml_console'
]
=
\
XMLConsoleWindow
(
account
)
window
.
present
()
def
on_manage_proxies
(
action
,
param
):
...
...
gajim/data/gui/xml_console_window.ui
View file @
3ded70a5
...
...
@@ -84,7 +84,7 @@
<property
name=
"halign"
>
start
</property>
<property
name=
"valign"
>
center
</property>
<property
name=
"active"
>
True
</property>
<signal
name=
"notify::active"
handler=
"on_enable"
swapped=
"no"
/>
<signal
name=
"notify::active"
handler=
"
_
on_enable"
swapped=
"no"
/>
</object>
</child>
</object>
...
...
@@ -96,7 +96,7 @@
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"selection_mode"
>
none
</property>
<signal
name=
"row-activated"
handler=
"on_row_activated"
swapped=
"no"
/>
<signal
name=
"row-activated"
handler=
"
_
on_row_activated"
swapped=
"no"
/>
<child>
<object
class=
"GtkListBoxRow"
>
<property
name=
"visible"
>
True
</property>
...
...
gajim/gtk/xml_console.py
View file @
3ded70a5
...
...
@@ -37,9 +37,16 @@
UNDECLARED
=
'http://www.gajim.org/xmlns/undeclared'
class
XMLConsoleWindow
(
Gtk
.
Window
):
class
XMLConsoleWindow
(
Gtk
.
Application
Window
):
def
__init__
(
self
,
account
):
Gtk
.
Window
.
__init__
(
self
)
Gtk
.
ApplicationWindow
.
__init__
(
self
)
self
.
set_application
(
app
.
app
)
self
.
set_position
(
Gtk
.
WindowPosition
.
CENTER
)
self
.
set_default_size
(
600
,
600
)
self
.
set_resizable
(
True
)
self
.
set_show_menubar
(
False
)
self
.
set_name
(
'XMLConsoleWindow'
)
self
.
account
=
account
self
.
enabled
=
True
self
.
presence
=
True
...
...
@@ -52,47 +59,48 @@ def __init__(self, account):
self
.
last_stanza
=
None
self
.
_ui
=
get_builder
(
'xml_console_window.ui'
)
self
.
set_titlebar
(
self
.
_ui
.
headerbar
)
jid
=
app
.
get_jid_from_account
(
account
)
self
.
set_titlebar
(
self
.
_ui
.
headerbar
)
self
.
_ui
.
headerbar
.
set_subtitle
(
jid
)
self
.
set_default_size
(
600
,
600
)
self
.
add
(
self
.
_ui
.
box
)
self
.
_ui
.
paned
.
set_position
(
self
.
_ui
.
paned
.
get_property
(
'max-position'
))
button
=
get_image_button
(
'edit-clear-all-symbolic'
,
_
(
'Clear'
))
button
.
connect
(
'clicked'
,
self
.
on_clear
)
button
.
connect
(
'clicked'
,
self
.
_
on_clear
)
self
.
_ui
.
actionbar
.
pack_start
(
button
)
button
=
get_image_button
(
'applications-system-symbolic'
,
_
(
'Filter'
))
button
.
connect
(
'clicked'
,
self
.
on_filter_options
)
button
.
connect
(
'clicked'
,
self
.
_
on_filter_options
)
self
.
_ui
.
actionbar
.
pack_start
(
button
)
button
=
get_image_button
(
'document-edit-symbolic'
,
_
(
'XML Input'
),
toggle
=
True
)
button
.
connect
(
'toggled'
,
self
.
on_input
)
button
.
connect
(
'toggled'
,
self
.
_
on_input
)
self
.
_ui
.
actionbar
.
pack_start
(
button
)
button
=
get_image_button
(
'insert-text-symbolic'
,
_
(
'Paste Last Input'
))
button
.
connect
(
'clicked'
,
self
.
on_paste_last
)
button
.
connect
(
'clicked'
,
self
.
_
on_paste_last
)
self
.
_ui
.
actionbar
.
pack_start
(
button
)
button
=
get_image_button
(
'mail-send-symbolic'
,
_
(
'Send'
))
button
.
connect
(
'clicked'
,
self
.
on_send
)
button
.
connect
(
'clicked'
,
self
.
_
on_send
)
self
.
_ui
.
actionbar
.
pack_end
(
button
)
self
.
_ui
.
actionbar
.
pack_start
(
self
.
_ui
.
menubutton
)
self
.
create_tags
()
self
.
_
create_tags
()
self
.
show_all
()
self
.
_ui
.
scrolled_input
.
hide
()
self
.
_ui
.
menubutton
.
hide
()
self
.
connect
(
"
destroy
"
,
self
.
on_destroy
)
self
.
connect
(
'key_press_event'
,
self
.
on_key_press_event
)
self
.
connect
(
'
destroy
'
,
self
.
_
on_destroy
)
self
.
connect
(
'key_press_event'
,
self
.
_
on_key_press_event
)
self
.
_ui
.
connect_signals
(
self
)
app
.
ged
.
register_event_handler
(
...
...
@@ -100,7 +108,7 @@ def __init__(self, account):
app
.
ged
.
register_event_handler
(
'stanza-sent'
,
ged
.
GUI1
,
self
.
_nec_stanza_sent
)
def
create_tags
(
self
):
def
_
create_tags
(
self
):
buffer_
=
self
.
_ui
.
textview
.
get_buffer
()
in_color
=
app
.
css_config
.
get_value
(
'.gajim-incoming-nickname'
,
StyleAttr
.
COLOR
)
...
...
@@ -117,18 +125,18 @@ def create_tags(self):
for
tag_name
in
tags
:
buffer_
.
create_tag
(
tag_name
)
def
on_key_press_event
(
self
,
widget
,
event
):
def
_
on_key_press_event
(
self
,
widget
,
event
):
if
event
.
keyval
==
Gdk
.
KEY_Escape
:
self
.
destroy
()
if
(
event
.
get_state
()
&
Gdk
.
ModifierType
.
CONTROL_MASK
and
event
.
keyval
==
Gdk
.
KEY_Return
or
event
.
keyval
==
Gdk
.
KEY_KP_Enter
):
self
.
on_send
()
self
.
_
on_send
()
if
(
event
.
get_state
()
&
Gdk
.
ModifierType
.
CONTROL_MASK
and
event
.
keyval
==
Gdk
.
KEY_Up
):
self
.
on_paste_last
()
self
.
_
on_paste_last
()
def
on_row_activated
(
self
,
listbox
,
row
):
def
_
on_row_activated
(
self
,
listbox
,
row
):
text
=
row
.
get_child
().
get_text
()
input_text
=
None
if
text
==
'Presence'
:
...
...
@@ -154,12 +162,12 @@ def on_row_activated(self, listbox, row):
buffer_
.
set_text
(
input_text
)
self
.
_ui
.
input_entry
.
grab_focus
()
def
on_send
(
self
,
*
args
):
def
_
on_send
(
self
,
*
args
):
if
not
app
.
account_is_connected
(
self
.
account
):
#
i
f offline or connecting
#
I
f offline or connecting
ErrorDialog
(
_
(
'Connection not available'
),
_
(
'Please make sure you are connected with
"%s"
.'
)
%
_
(
'Please make sure you are connected with
\'
%s
\'
.'
)
%
self
.
account
)
return
buffer_
=
self
.
_ui
.
input_entry
.
get_buffer
()
...
...
@@ -177,13 +185,13 @@ def on_send(self, *args):
self
.
last_stanza
=
stanza
buffer_
.
set_text
(
''
)
def
on_paste_last
(
self
,
*
args
):
def
_
on_paste_last
(
self
,
*
args
):
buffer_
=
self
.
_ui
.
input_entry
.
get_buffer
()
if
buffer_
is
not
None
and
self
.
last_stanza
is
not
None
:
buffer_
.
set_text
(
self
.
last_stanza
)
self
.
_ui
.
input_entry
.
grab_focus
()
def
on_input
(
self
,
button
,
*
args
):
def
_
on_input
(
self
,
button
,
*
args
):
if
button
.
get_active
():
self
.
_ui
.
paned
.
get_child2
().
show
()
self
.
_ui
.
menubutton
.
show
()
...
...
@@ -192,55 +200,54 @@ def on_input(self, button, *args):
self
.
_ui
.
paned
.
get_child2
().
hide
()
self
.
_ui
.
menubutton
.
hide
()
def
on_filter_options
(
self
,
*
args
):
def
_
on_filter_options
(
self
,
*
args
):
if
self
.
filter_dialog
:
self
.
filter_dialog
.
present
()
return
options
=
[
Setting
(
SettingKind
.
SWITCH
,
'Presence'
,
SettingType
.
VALUE
,
self
.
presence
,
callback
=
self
.
on_option
,
data
=
'presence'
),
callback
=
self
.
_
on_option
,
data
=
'presence'
),
Setting
(
SettingKind
.
SWITCH
,
'Message'
,
SettingType
.
VALUE
,
self
.
message
,
callback
=
self
.
on_option
,
data
=
'message'
),
callback
=
self
.
_
on_option
,
data
=
'message'
),
Setting
(
SettingKind
.
SWITCH
,
'I
q
'
,
SettingType
.
VALUE
,
self
.
iq
,
callback
=
self
.
on_option
,
data
=
'iq'
),
Setting
(
SettingKind
.
SWITCH
,
'I
Q
'
,
SettingType
.
VALUE
,
self
.
iq
,
callback
=
self
.
_
on_option
,
data
=
'iq'
),
Setting
(
SettingKind
.
SWITCH
,
'Stream
\n
Management'
,
Setting
(
SettingKind
.
SWITCH
,
'Stream
Management'
,
SettingType
.
VALUE
,
self
.
stream
,
callback
=
self
.
on_option
,
data
=
'stream'
),
callback
=
self
.
_
on_option
,
data
=
'stream'
),
Setting
(
SettingKind
.
SWITCH
,
'In'
,
SettingType
.
VALUE
,
self
.
incoming
,
callback
=
self
.
on_option
,
data
=
'incoming'
),
callback
=
self
.
_
on_option
,
data
=
'incoming'
),
Setting
(
SettingKind
.
SWITCH
,
'Out'
,
SettingType
.
VALUE
,
self
.
outgoing
,
callback
=
self
.
on_option
,
data
=
'outgoing'
),
callback
=
self
.
_
on_option
,
data
=
'outgoing'
),
]
self
.
filter_dialog
=
SettingsDialog
(
self
,
'Filter'
,
Gtk
.
DialogFlags
.
DESTROY_WITH_PARENT
,
options
,
self
.
account
)
self
.
filter_dialog
.
connect
(
'destroy'
,
self
.
on_filter_destroyed
)
self
.
filter_dialog
.
connect
(
'destroy'
,
self
.
_
on_filter_destroyed
)
def
on_filter_destroyed
(
self
,
win
):
def
_
on_filter_destroyed
(
self
,
win
):
self
.
filter_dialog
=
None
def
on_clear
(
self
,
*
args
):
def
_
on_clear
(
self
,
*
args
):
self
.
_ui
.
textview
.
get_buffer
().
set_text
(
''
)
def
on_destroy
(
self
,
*
args
):
del
app
.
interface
.
instances
[
self
.
account
][
'xml_console'
]
def
_on_destroy
(
self
,
*
args
):
app
.
ged
.
remove_event_handler
(
'stanza-received'
,
ged
.
GUI1
,
self
.
_nec_stanza_received
)
app
.
ged
.
remove_event_handler
(
'stanza-sent'
,
ged
.
GUI1
,
self
.
_nec_stanza_sent
)
def
on_enable
(
self
,
switch
,
param
):
def
_
on_enable
(
self
,
switch
,
param
):
self
.
enabled
=
switch
.
get_active
()
def
on_option
(
self
,
value
,
data
):
def
_
on_option
(
self
,
value
,
data
):
setattr
(
self
,
data
,
value
)
value
=
not
value
table
=
self
.
_ui
.
textview
.
get_buffer
().
get_tag_table
()
...
...
@@ -255,15 +262,15 @@ def on_option(self, value, data):
def
_nec_stanza_received
(
self
,
obj
):
if
obj
.
conn
.
name
!=
self
.
account
:
return
self
.
print_stanza
(
obj
.
stanza_str
,
'incoming'
)
self
.
_
print_stanza
(
obj
.
stanza_str
,
'incoming'
)
def
_nec_stanza_sent
(
self
,
obj
):
if
obj
.
conn
.
name
!=
self
.
account
:
return
self
.
print_stanza
(
obj
.
stanza_str
,
'outgoing'
)
self
.
_
print_stanza
(
obj
.
stanza_str
,
'outgoing'
)
def
print_stanza
(
self
,
stanza
,
kind
):
#
k
ind must be 'incoming' or 'outgoing'
def
_
print_stanza
(
self
,
stanza
,
kind
):
#
K
ind must be 'incoming' or 'outgoing'
if
not
self
.
enabled
:
return
if
not
stanza
:
...
...
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