Commit 6729a122 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Daniel Brötzmann
Browse files

GroupChatControl: Add management page

parent debab37e
......@@ -123,6 +123,91 @@
</object>
</child>
</object>
<object class="GtkPopover" id="manage_popover">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="manage_change_subject_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="_on_change_subject" swapped="no"/>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Change Subject…</property>
</object>
</child>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="manage_advanced_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="_on_configure_room" swapped="no"/>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Advanced Settings…</property>
</object>
</child>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="manage_destroy_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="_on_destroy_room" swapped="no"/>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Destroy…</property>
</object>
</child>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<style>
<class name="padding-6"/>
</style>
</object>
</child>
</object>
<object class="GtkBox" id="groupchat_control_hbox">
<property name="can_focus">True</property>
<child>
......@@ -2082,6 +2167,218 @@
<property name="position">14</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">12</property>
<property name="label" translatable="yes">Manage This Chat</property>
<style>
<class name="bold16"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkImage" id="avatar_button_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_end">6</property>
<property name="margin_bottom">6</property>
<property name="pixel_size">100</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
<child type="overlay">
<object class="GtkButton" id="avatar_select_button">
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<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"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">document-edit-symbolic</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkEntry" id="muc_description_entry">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="muc_name_entry">
<property name="width_request">250</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Name</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Description</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="margin_top">12</property>
<property name="direction">up</property>
<property name="popover">manage_popover</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">More…</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">18</property>
<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" id="manage_save_button">
<property name="label" translatable="yes">Save</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="_on_manage_save_clicked" swapped="no"/>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<style>
<class name="padding-18"/>
</style>
</object>
<packing>
<property name="name">muc-manage</property>
<property name="position">15</property>
</packing>
</child>
</object>
<packing>
<property name="index">-1</property>
......
......@@ -275,14 +275,11 @@ def add_actions(self):
super().add_actions()
actions = [
('groupchat-settings-', None, self._on_groupchat_settings),
('groupchat-manage-', None, self._on_groupchat_manage),
('rename-groupchat-', None, self._on_rename_groupchat),
('change-subject-', None, self._on_change_subject),
('change-nickname-', None, self._on_change_nick),
('disconnect-', None, self._on_disconnect),
('destroy-', None, self._on_destroy_room),
('configure-', None, self._on_configure_room),
('request-voice-', None, self._on_request_voice),
('upload-avatar-', None, self._on_upload_avatar),
('information-', None, self._on_information),
('invite-', None, self._on_invite),
('contact-information-', 's', self._on_contact_information),
......@@ -309,22 +306,8 @@ def update_actions(self, *args):
self.account, self.room_jid, self.nick)
con = app.connections[self.account]
# Destroy Room
self._get_action('destroy-').set_enabled(self.is_connected and
contact.affiliation.is_owner)
# Configure Room
self._get_action('configure-').set_enabled(
self.is_connected and contact.affiliation in (Affiliation.ADMIN,
Affiliation.OWNER))
self._get_action('request-voice-').set_enabled(self.is_connected and
contact.role.is_visitor)
# Change Subject
subject_change = self._is_subject_change_allowed()
self._get_action('change-subject-').set_enabled(self.is_connected and
subject_change)
self._get_action('request-voice-').set_enabled(
self.is_connected and contact.role.is_visitor)
# Change Nick
self._get_action('change-nickname-').set_enabled(self.is_connected)
......@@ -354,14 +337,40 @@ def update_actions(self, *args):
tooltip_text = _('No File Transfer available')
self.xml.sendfile_button.set_tooltip_text(tooltip_text)
# Upload Avatar
# Manage chat
vcard_support = False
if self.disco_info is not None:
vcard_support = self.disco_info.supports(Namespace.VCARD)
self._get_action('upload-avatar-').set_enabled(
self.is_connected and
vcard_support and
contact.affiliation.is_owner)
self.xml.muc_name_entry.set_text(self.disco_info.muc_name or '')
self.xml.muc_description_entry.set_text(
self.disco_info.muc_description or '')
self.xml.muc_name_entry.set_sensitive(
self.is_connected and contact.affiliation.is_owner)
self.xml.muc_description_entry.set_sensitive(
self.is_connected and contact.affiliation.is_owner)
self.xml.manage_save_button.set_sensitive(
self.is_connected and contact.affiliation.is_owner)
if (self.is_connected and vcard_support and
contact.affiliation.is_owner):
self.xml.avatar_select_button.show()
avatar_surface = app.interface.avatar_storage.get_muc_surface(
self.account,
str(self.disco_info.jid),
AvatarSize.GROUP_INFO,
self.scale_factor)
self.xml.avatar_button_image.set_from_surface(avatar_surface)
self.xml.manage_change_subject_button.set_sensitive(
self.is_connected and self._is_subject_change_allowed())
self.xml.manage_advanced_button.set_sensitive(
self.is_connected and contact.affiliation in (Affiliation.ADMIN,
Affiliation.OWNER))
self.xml.manage_destroy_button.set_sensitive(
self.is_connected and contact.affiliation.is_owner)
self._get_action('contact-information-').set_enabled(self.is_connected)
......@@ -375,14 +384,11 @@ def remove_actions(self):
super().remove_actions()
actions = [
'groupchat-settings-',
'groupchat-manage-',
'rename-groupchat-',
'change-subject-',
'change-nickname-',
'disconnect-',
'destroy-',
'configure-',
'request-voice-',
'upload-avatar-',
'information-',
'invite-',
'contact-information-',
......@@ -477,6 +483,10 @@ def _on_groupchat_settings(self, _action, _param):
self.xml.settings_scrolled_box.add(self._groupchat_settings_box)
self._show_page('muc-settings')
def _on_groupchat_manage(self, _action, _param):
self._show_page('muc-manage')
self.xml.manage_save_button.grab_default()
def _on_invite(self, _action, _param):
self._invite_box.load_contacts()
self._show_page('invite')
......@@ -497,7 +507,7 @@ def invite(self, contact_jid):
_('%s has been invited to this group chat') % contact_jid,
message_id=message_id)
def _on_destroy_room(self, _action, _param):
def _on_destroy_room(self, _button):
self.xml.destroy_reason_entry.grab_focus()
self.xml.destroy_button.grab_default()
self._show_page('destroy')
......@@ -528,7 +538,9 @@ def _on_destroy_confirm(self, _button):
con.get_module('MUC').destroy(self.room_jid, reason, jid)
self._show_page('groupchat')
def _on_configure_room(self, _action, _param):
def _on_configure_room(self, _button):
self.xml.manage_popover.popdown()
win = get_app_window('GroupchatConfig', self.account, self.room_jid)
if win is not None:
win.present()
......@@ -567,7 +579,7 @@ def _on_execute_command(self, _action, param):
jid += '/' + nick
AdHocCommand(self.account, jid)
def _on_upload_avatar(self, _action, _param):
def _on_upload_avatar(self, _button):
def _on_accept(filename):
data, sha = app.interface.avatar_storage.prepare_for_publish(
filename)
......@@ -2004,8 +2016,13 @@ def _on_rename_clicked(self, _button):
self.room_jid, name=new_name)
self._show_page('groupchat')
def _on_change_subject(self, _action, _param):
if self._get_current_page() != 'groupchat':
def _on_manage_save_clicked(self, _button):
print(self.xml.muc_name_entry.get_text())
print(self.xml.muc_description_entry.get_text())
self._show_page('groupchat')
def _on_change_subject(self, _button):
if self._get_current_page() not in ('groupchat', 'muc-manage'):
return
self.xml.subject_textview.get_buffer().set_text(self.subject)
self.xml.subject_textview.grab_focus()
......
......@@ -575,13 +575,8 @@ def get_groupchat_menu(control_id, account, jid):
groupchat_menu = [
('win.information-', _('Information')),
('win.groupchat-settings-', _('Settings…')),
(_('Manage Group Chat'), [
('win.rename-groupchat-', _('Rename…')),
('win.change-subject-', _('Change Subject…')),
('win.upload-avatar-', _('Upload Avatar…')),
('win.configure-', _('Configure…')),
('win.destroy-', _('Destroy…')),
]),
('win.groupchat-manage-', _('Manage…')),
('win.rename-groupchat-', _('Rename Chat…')),
('win.change-nickname-', _('Change Nickname…')),
('win.request-voice-', _('Request Voice')),
('win.execute-command-', _('Execute Command…')),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment