Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Daniel Brötzmann
gajim
Commits
f9eedc12
Commit
f9eedc12
authored
Sep 19, 2020
by
Daniel Brötzmann
Committed by
Daniel Brötzmann
Nov 22, 2021
Browse files
GroupChatControl: Add avatar selector page
parent
dac7c137
Pipeline
#8554
passed with stages
in 2 minutes and 58 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gajim/data/gui/groupchat_control.ui
View file @
f9eedc12
...
...
@@ -2216,7 +2216,7 @@
<property
name=
"no_show_all"
>
True
</property>
<property
name=
"halign"
>
end
</property>
<property
name=
"valign"
>
end
</property>
<signal
name=
"clicked"
handler=
"_on_
upload
_avatar"
swapped=
"no"
/>
<signal
name=
"clicked"
handler=
"_on_
change
_avatar"
swapped=
"no"
/>
<child>
<object
class=
"GtkImage"
>
<property
name=
"visible"
>
True
</property>
...
...
@@ -2380,6 +2380,114 @@
<property
name=
"position"
>
15
</property>
</packing>
</child>
<child>
<object
class=
"GtkBox"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"orientation"
>
vertical
</property>
<child>
<object
class=
"GtkGrid"
id=
"avatar_selector_grid"
>
<property
name=
"name"
>
settings_grid
</property>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
center
</property>
<property
name=
"valign"
>
center
</property>
<property
name=
"hexpand"
>
True
</property>
<property
name=
"vexpand"
>
True
</property>
<property
name=
"border_width"
>
18
</property>
<property
name=
"row_spacing"
>
6
</property>
<property
name=
"column_spacing"
>
12
</property>
<child>
<object
class=
"GtkBox"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
center
</property>
<property
name=
"margin_top"
>
6
</property>
<property
name=
"spacing"
>
12
</property>
<child
type=
"center"
>
<object
class=
"GtkButton"
id=
"avatar_update_button"
>
<property
name=
"label"
translatable=
"yes"
>
Update
</property>
<property
name=
"visible"
>
True
</property>
<property
name=
"sensitive"
>
False
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"can_default"
>
True
</property>
<property
name=
"receives_default"
>
True
</property>
<signal
name=
"clicked"
handler=
"_on_avatar_update_clicked"
swapped=
"no"
/>
<style>
<class
name=
"suggested-action"
/>
</style>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
2
</property>
</packing>
</child>
<child>
<object
class=
"GtkButton"
>
<property
name=
"label"
translatable=
"yes"
>
_Close
</property>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<property
name=
"use_underline"
>
True
</property>
<signal
name=
"clicked"
handler=
"_on_page_cancel_clicked"
swapped=
"no"
/>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
0
</property>
</packing>
</child>
<child>
<object
class=
"GtkButton"
>
<property
name=
"label"
translatable=
"yes"
>
Select File…
</property>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<signal
name=
"clicked"
handler=
"_on_avatar_select_file_clicked"
swapped=
"no"
/>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
1
</property>
</packing>
</child>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
2
</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"label"
translatable=
"yes"
>
Update Avatar
</property>
<style>
<class
name=
"bold16"
/>
</style>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
0
</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
0
</property>
</packing>
</child>
</object>
<packing>
<property
name=
"name"
>
avatar-selector
</property>
<property
name=
"position"
>
16
</property>
</packing>
</child>
</object>
<packing>
<property
name=
"index"
>
-1
</property>
...
...
gajim/groupchat_control.py
View file @
f9eedc12
...
...
@@ -69,6 +69,7 @@
from
gajim.gui.filechoosers
import
AvatarChooserDialog
from
gajim.gui.groupchat_config
import
GroupchatConfig
from
gajim.gui.adhoc
import
AdHocCommand
from
gajim.gui.avatar_selector
import
AvatarSelector
from
gajim.gui.dataform
import
DataFormWidget
from
gajim.gui.groupchat_info
import
GroupChatInfoScrolled
from
gajim.gui.groupchat_invite
import
GroupChatInvite
...
...
@@ -191,6 +192,11 @@ def __init__(self, parent_win, contact, muc_data, acct):
self
.
xml
.
invite_grid
.
attach
(
self
.
_invite_box
,
0
,
0
,
1
,
1
)
self
.
_invite_box
.
connect
(
'listbox-changed'
,
self
.
_on_invite_ready
)
# Avatar selector
self
.
_avatar_selector
=
AvatarSelector
()
self
.
_avatar_selector
.
set_size_request
(
400
,
400
)
self
.
xml
.
avatar_selector_grid
.
attach
(
self
.
_avatar_selector
,
0
,
1
,
1
,
1
)
self
.
control_menu
=
gui_menu_builder
.
get_groupchat_menu
(
self
.
control_id
,
self
.
account
,
self
.
room_jid
)
...
...
@@ -600,22 +606,23 @@ def _on_execute_command(self, _action, param):
jid
+=
'/'
+
nick
AdHocCommand
(
self
.
account
,
jid
)
def
_on_
upload
_avatar
(
self
,
_button
):
def
_on_accept
(
filename
):
data
,
sha
=
app
.
interface
.
avatar_stor
age
.
prepare_
for_publish
(
filename
)
if
sha
is
None
:
self
.
add_info_message
(
_
(
'Loading avatar failed
'
)
)
return
def
_on_
change
_avatar
(
self
,
_button
):
def
_on_accept
(
path
):
self
.
_
avatar_s
elec
tor
.
prepare_
crop_area
(
path
)
self
.
xml
.
avatar_update_button
.
set_sensitive
(
self
.
_avatar_selector
.
get_prepared
())
self
.
_show_page
(
'avatar-selector
'
)
self
.
xml
.
avatar_update_button
.
grab_default
()
vcard
=
VCard
()
vcard
.
set_avatar
(
data
,
'image/png'
)
AvatarChooserDialog
(
_on_accept
,
transient_for
=
self
.
parent_win
.
window
,
modal
=
True
)
con
=
app
.
connections
[
self
.
account
]
con
.
get_module
(
'VCardTemp'
).
set_vcard
(
vcard
,
jid
=
self
.
room_jid
,
callback
=
self
.
_on_upload_avatar_result
)
def
_on_avatar_select_file_clicked
(
self
,
_button
):
def
_on_accept
(
path
):
self
.
_avatar_selector
.
prepare_crop_area
(
path
)
self
.
xml
.
avatar_update_button
.
set_sensitive
(
self
.
_avatar_selector
.
get_prepared
()
)
AvatarChooserDialog
(
_on_accept
,
transient_for
=
self
.
parent_win
.
window
,
...
...
@@ -630,6 +637,27 @@ def _on_upload_avatar_result(self, task):
else
:
self
.
add_info_message
(
_
(
'Avatar upload successful'
))
def
_on_avatar_update_clicked
(
self
,
_button
):
success
,
data
,
_
,
_
=
self
.
_avatar_selector
.
get_avatar_bytes
()
if
not
success
:
self
.
add_info_message
(
_
(
'Loading avatar failed'
))
return
sha
=
app
.
interface
.
avatar_storage
.
save_avatar
(
data
)
if
sha
is
None
:
self
.
add_info_message
(
_
(
'Loading avatar failed'
))
return
vcard
=
VCard
()
vcard
.
set_avatar
(
data
,
'image/png'
)
client
=
app
.
get_client
(
self
.
account
)
client
.
get_module
(
'VCardTemp'
).
set_vcard
(
vcard
,
jid
=
self
.
room_jid
,
callback
=
self
.
_on_upload_avatar_result
)
self
.
_show_page
(
'groupchat'
)
def
_on_contact_information
(
self
,
_action
,
param
):
nick
=
param
.
get_string
()
gc_contact
=
app
.
contacts
.
get_gc_contact
(
self
.
account
,
...
...
@@ -777,7 +805,6 @@ def _update_avatar(self):
self
.
contact
.
jid
,
AvatarSize
.
CHAT
,
self
.
scale_factor
)
self
.
xml
.
avatar_image
.
set_from_surface
(
surface
)
def
draw_banner_text
(
self
):
...
...
@@ -788,7 +815,7 @@ def draw_banner_text(self):
self
.
xml
.
banner_name_label
.
set_text
(
self
.
room_name
)
@
event_filter
([
'jid=room_jid'
])
def
_on_update_room_avatar
(
self
,
event
):
def
_on_update_room_avatar
(
self
,
_
event
):
self
.
_update_avatar
()
@
event_filter
([
'account'
])
...
...
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