Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
565f6012
Commit
565f6012
authored
4 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Refactor ContactInfo
parent
93dc50c4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gajim/data/gui/contact_info.ui
+3
-7
3 additions, 7 deletions
gajim/data/gui/contact_info.ui
gajim/gtk/contact_info.py
+40
-18
40 additions, 18 deletions
gajim/gtk/contact_info.py
with
43 additions
and
25 deletions
gajim/data/gui/contact_info.ui
+
3
−
7
View file @
565f6012
...
...
@@ -490,16 +490,13 @@
<property
name=
"model"
>
groups_model
</property>
<property
name=
"headers-visible"
>
False
</property>
<child
internal-child=
"selection"
>
<object
class=
"GtkTreeSelection"
>
<signal
name=
"changed"
handler=
"_on_group_selection_changed"
swapped=
"no"
/>
</object>
<object
class=
"GtkTreeSelection"
id=
"tree_selection"
/>
</child>
<child>
<object
class=
"GtkTreeViewColumn"
>
<child>
<object
class=
"GtkCellRendererToggle"
>
<object
class=
"GtkCellRendererToggle"
id=
"toggle_renderer"
>
<property
name=
"xpad"
>
12
</property>
<signal
name=
"toggled"
handler=
"_on_group_toggled"
swapped=
"no"
/>
</object>
<attributes>
<attribute
name=
"active"
>
0
</attribute>
...
...
@@ -512,10 +509,9 @@
<property
name=
"title"
translatable=
"yes"
>
column
</property>
<property
name=
"sort-column-id"
>
1
</property>
<child>
<object
class=
"GtkCellRendererText"
>
<object
class=
"GtkCellRendererText"
id=
"text_renderer"
>
<property
name=
"height"
>
42
</property>
<property
name=
"editable"
>
True
</property>
<signal
name=
"edited"
handler=
"_on_group_name_edited"
swapped=
"no"
/>
</object>
<attributes>
<attribute
name=
"text"
>
1
</attribute>
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/contact_info.py
+
40
−
18
View file @
565f6012
...
...
@@ -38,6 +38,7 @@
from
.dialogs
import
DialogButton
from
.sidebar_switcher
import
SideBarSwitcher
from
.util
import
get_builder
from
.util
import
connect_destroy
from
.vcard_grid
import
VCardGrid
log
=
logging
.
getLogger
(
'
gajim.gui.contact_info
'
)
...
...
@@ -92,14 +93,17 @@ def __init__(self, account, contact, page=None, anonymous=False):
self
.
_fill_settings_page
()
self
.
_fill_groups_page
()
self
.
_tasks
=
[]
# pylint: disable=line-too-long
self
.
register_events
([
(
'
time-result-received
'
,
ged
.
GUI1
,
self
.
_set_entity_time
),
(
'
subscribed-presence-received
'
,
ged
.
GUI1
,
self
.
_on_subscribed_presence_received
),
(
'
unsubscribed-presence-received
'
,
ged
.
GUI1
,
self
.
_on_unsubscribed_presence_received
),
])
# pylint: enable=line-too-long
self
.
_load_avatar
()
self
.
_ui
.
contact_name_label
.
set_text
(
contact
.
name
)
if
contact
.
is_pm_contact
:
self
.
_ui
.
role_label
.
set_text
(
get_uf_role
(
contact
.
role
))
...
...
@@ -131,6 +135,16 @@ def __init__(self, account, contact, page=None, anonymous=False):
self
.
connect
(
'
key-press-event
'
,
self
.
_on_key_press
)
self
.
connect
(
'
destroy
'
,
self
.
_on_destroy
)
connect_destroy
(
self
.
_ui
.
tree_selection
,
'
changed
'
,
self
.
_on_group_selection_changed
)
connect_destroy
(
self
.
_ui
.
toggle_renderer
,
'
toggled
'
,
self
.
_on_group_toggled
)
connect_destroy
(
self
.
_ui
.
text_renderer
,
'
edited
'
,
self
.
_on_group_name_edited
)
self
.
add
(
self
.
_ui
.
main_grid
)
self
.
show_all
()
...
...
@@ -145,6 +159,10 @@ def _on_stack_child_changed(self, *args):
self
.
_ui
.
header_revealer
.
set_reveal_child
(
True
)
def
_on_destroy
(
self
,
_widget
):
for
task
in
self
.
_tasks
:
task
.
cancel
()
self
.
_tasks
.
clear
()
if
not
self
.
contact
.
is_pm_contact
:
self
.
_save_annotation
()
...
...
@@ -152,7 +170,7 @@ def _on_destroy(self, _widget):
GLib
.
source_remove
(
self
.
_update_timeout_id
)
self
.
unregister_events
()
app
.
c
ancel_tasks
(
self
)
app
.
c
heck_finalize
(
self
)
def
_save_annotation
(
self
):
buffer_
=
self
.
_ui
.
textview_annotation
.
get_buffer
()
...
...
@@ -183,7 +201,6 @@ def _on_vcard_received(self, task):
vcard
=
VCard
()
self
.
_vcard_grid
.
set_vcard
(
vcard
)
self
.
_load_avatar
()
def
_load_avatar
(
self
):
scale
=
self
.
get_scale_factor
()
...
...
@@ -210,16 +227,21 @@ def _query_device(self, contact):
}
self
.
_rebuild_devices_grid
()
self
.
_client
.
get_module
(
'
SoftwareVersion
'
).
request_software_version
(
task
=
self
.
_client
.
get_module
(
'
SoftwareVersion
'
).
request_software_version
(
contact
.
jid
,
callback
=
self
.
_set_os_info
,
user_data
=
contact
)
self
.
_client
.
get_module
(
'
EntityTime
'
).
request_entity_time
(
str
(
contact
.
jid
.
bare
),
contact
.
jid
.
resource
)
self
.
_tasks
.
append
(
task
)
task
=
self
.
_client
.
get_module
(
'
EntityTime
'
).
request_entity_time
(
contact
.
jid
,
callback
=
self
.
_set_entity_time
,
user_data
=
contact
)
self
.
_tasks
.
append
(
task
)
def
_set_os_info
(
self
,
task
):
self
.
_tasks
.
remove
(
task
)
try
:
result
=
task
.
finish
()
except
StanzaError
as
err
:
log
.
info
(
'
Could not retrieve software version: %s
'
,
err
)
except
Exception
as
err
:
log
.
warning
(
'
Could not retrieve software version: %s
'
,
err
)
return
contact
=
task
.
get_user_data
()
...
...
@@ -230,19 +252,19 @@ def _set_os_info(self, task):
self
.
_received_devices
.
add
(
contact
.
jid
.
resource
)
self
.
_rebuild_devices_grid
()
def
_set_entity_time
(
self
,
event
):
if
event
.
conn
.
name
!=
self
.
account
:
def
_set_entity_time
(
self
,
task
):
self
.
_tasks
.
remove
(
task
)
try
:
entity_time
=
task
.
finish
()
except
Exception
as
err
:
log
.
warning
(
'
Could not retrieve entity time: %s
'
,
err
)
return
if
self
.
contact
.
is_pm_contact
:
if
event
.
jid
!=
self
.
contact
.
jid
:
return
else
:
if
event
.
jid
.
bare
!=
self
.
contact
.
jid
:
return
contact
=
task
.
get_user_data
()
self
.
_devices
[
even
t
.
jid
.
resource
][
'
time
'
]
=
e
vent
.
time_info
self
.
_received_times
.
add
(
even
t
.
jid
.
resource
)
self
.
_devices
[
contac
t
.
jid
.
resource
][
'
time
'
]
=
e
ntity_time
self
.
_received_times
.
add
(
contac
t
.
jid
.
resource
)
self
.
_rebuild_devices_grid
()
def
_rebuild_devices_grid
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment