Commit 1cb58072 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist

Join Groupchat: Add nickname entry

parent d8aa6c93
Pipeline #6299 passed with stages
in 3 minutes and 24 seconds
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkBox" id="button_content">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">15</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">document-edit-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkPopover" id="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>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Join Group Chat as…</property>
<style>
<class name="bold"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Your Nickname</property>
<property name="activates_default">True</property>
<style>
<class name="linked"/>
</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="apply_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-ok-symbolic</property>
</object>
</child>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="padding-6"/>
</style>
</object>
</child>
</object>
</interface>
......@@ -302,40 +302,58 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_Back</property>
<object class="GtkBox" id="join_box">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="_on_back_clicked" swapped="no"/>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="join_button">
<property name="label" translatable="yes">_Join</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="_on_join_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>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_Join</property>
<property name="label" translatable="yes">_Back</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="_on_join_clicked" swapped="no"/>
<style>
<class name="suggested-action"/>
</style>
<signal name="clicked" handler="_on_back_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>
......
......@@ -245,6 +245,7 @@ infobar.error > revealer > box {
.margin-3 { margin: 3px; }
.margin-12 { margin: 12px; }
.margin-18 { margin: 18px; }
.padding-6 { margin: 6px; }
.padding-18 { margin: 18px; }
.padding-left30 { padding-left: 30px; }
......
......@@ -23,13 +23,14 @@ from gajim.common.i18n import _
from gajim.common.i18n import get_rfc5646_lang
from gajim.common.helpers import to_user_string
from gajim.common.helpers import get_alternative_venue
from gajim.common.helpers import get_group_chat_nick
from gajim.common.const import MUC_DISCO_ERRORS
from gajim.gtk.groupchat_info import GroupChatInfoScrolled
from gajim.gtk.groupchat_nick import NickChooser
from gajim.gtk.util import ensure_not_destroyed
class GroupchatJoin(Gtk.ApplicationWindow):
def __init__(self, account, jid):
Gtk.ApplicationWindow.__init__(self)
......@@ -59,17 +60,26 @@ class GroupchatJoin(Gtk.ApplicationWindow):
self._stack.set_visible_child_name('progress')
self._stack.get_visible_child().start()
self._stack.connect('notify::visible-child-name', self._on_page_changed)
self._stack.connect('notify::visible-child-name',
self._on_page_changed)
self._main_box.add(self._stack)
self._nick_chooser = NickChooser()
self._join_button = Gtk.Button.new_with_mnemonic(_('_Join'))
self._join_button.set_halign(Gtk.Align.END)
self._join_button.set_sensitive(False)
self._join_button.set_can_default(True)
self._join_button.get_style_context().add_class('suggested-action')
self._join_button.connect('clicked', self._on_join)
self._main_box.add(self._join_button)
join_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
join_box.get_style_context().add_class('linked')
join_box.set_halign(Gtk.Align.END)
join_box.add(self._nick_chooser)
join_box.add(self._join_button)
self._main_box.add(join_box)
self.connect('key-press-event', self._on_key_press_event)
self.connect('destroy', self._on_destroy)
......@@ -101,6 +111,9 @@ class GroupchatJoin(Gtk.ApplicationWindow):
elif result.is_muc:
self._muc_info_box.set_from_disco_info(result)
nickname = get_group_chat_nick(self.account, result.jid)
self._nick_chooser.set_text(nickname)
self._join_button.grab_default()
self._stack.set_visible_child_name('info')
else:
......@@ -121,8 +134,10 @@ class GroupchatJoin(Gtk.ApplicationWindow):
def _set_error_from_code(self, error_code):
self._show_error_page(MUC_DISCO_ERRORS[error_code])
def _on_join(self, _button):
app.interface.show_or_join_groupchat(self.account, self.jid)
def _on_join(self, *args):
nickname = self._nick_chooser.get_text()
app.interface.show_or_join_groupchat(
self.account, self.jid, nick=nickname)
self.destroy()
def _on_destroy(self, *args):
......
# This file is part of Gajim.
#
# Gajim is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 only.
#
# Gajim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import Gtk
from nbxmpp.protocol import InvalidJid
from nbxmpp.protocol import validate_resourcepart
from gajim.gtk.util import get_builder
class NickChooser(Gtk.MenuButton):
def __init__(self):
Gtk.MenuButton.__init__(self)
self._ui = get_builder('groupchat_nick_chooser.ui')
self.add(self._ui.button_content)
self.set_receives_default(False)
self.set_popover(self._ui.popover)
self._ui.popover.set_default_widget(
self._ui.apply_button)
self.connect('toggled', self._on_nickname_button_toggled)
self._ui.entry.connect('changed', self._on_nickname_changed)
self._ui.apply_button.connect('clicked', self._on_apply_nickname)
def get_text(self):
return self._ui.entry.get_text()
def set_text(self, text):
self._ui.entry.set_text(text)
self._ui.label.set_text(text)
def _on_nickname_button_toggled(self, _widget):
self._ui.entry.grab_focus()
def _on_nickname_changed(self, entry):
try:
validate_resourcepart(entry.get_text())
self._ui.apply_button.set_sensitive(True)
except InvalidJid:
self._ui.apply_button.set_sensitive(False)
def _on_apply_nickname(self, _button):
nickname = self._ui.entry.get_text()
self._ui.popover.popdown()
self._ui.label.set_text(nickname)
......@@ -27,6 +27,7 @@ from gajim.common import app
from gajim.common.helpers import validate_jid
from gajim.common.helpers import to_user_string
from gajim.common.helpers import get_groupchat_name
from gajim.common.helpers import get_group_chat_nick
from gajim.common.helpers import get_alternative_venue
from gajim.common.i18n import _
from gajim.common.i18n import get_rfc5646_lang
......@@ -34,6 +35,7 @@ from gajim.common.const import AvatarSize
from gajim.common.const import MUC_DISCO_ERRORS
from gajim.gtk.groupchat_info import GroupChatInfoScrolled
from gajim.gtk.groupchat_nick import NickChooser
from gajim.gtk.util import get_builder
from gajim.gtk.util import ensure_not_destroyed
from gajim.gtk.util import get_icon_name
......@@ -66,6 +68,9 @@ class StartChatDialog(Gtk.ApplicationWindow):
self._ui = get_builder('start_chat_dialog.ui')
self.add(self._ui.stack)
self._nick_chooser = NickChooser()
self._ui.join_box.pack_start(self._nick_chooser, True, False, 0)
self.new_contact_row_visible = False
self.new_contact_rows = {}
self.new_groupchat_rows = {}
......@@ -313,6 +318,8 @@ class StartChatDialog(Gtk.ApplicationWindow):
elif result.is_muc:
self._muc_info_box.set_account(account)
self._muc_info_box.set_from_disco_info(result)
self._nick_chooser.set_text(get_group_chat_nick(
account, result.jid))
self._ui.stack.set_visible_child_name('info')
else:
......@@ -336,7 +343,9 @@ class StartChatDialog(Gtk.ApplicationWindow):
def _on_join_clicked(self, _button=None):
account = self._muc_info_box.get_account()
jid = self._muc_info_box.get_jid()
app.interface.show_or_join_groupchat(account, str(jid))
nickname = self._nick_chooser.get_text()
app.interface.show_or_join_groupchat(
account, str(jid), nick=nickname)
self.ready_to_destroy = True
def _on_back_clicked(self, _button=None):
......
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