Philipp Hörist pushed to branch master at gajim / gajim
Commits: 304e9a98 by wurstsalat at 2023-01-13T22:11:17+00:00 imprv: CreateGroupchatWindow: Add Advanced switch and always show address entry
Fixes #11310
- - - - -
3 changed files:
- gajim/data/gui/groupchat_creation.ui - gajim/gtk/builder.pyi - gajim/gtk/groupchat_creation.py
Changes:
===================================== gajim/data/gui/groupchat_creation.ui ===================================== @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 --> +<!-- Generated with glade 3.40.0 --> <interface> <requires lib="gtk+" version="3.24"/> <object class="GtkListStore" id="account_liststore"> @@ -38,7 +38,7 @@ </packing> </child> <child> - <!-- n-columns=2 n-rows=6 --> + <!-- n-columns=2 n-rows=5 --> <object class="GtkGrid" id="grid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -146,117 +146,173 @@ </packing> </child> <child> - <object class="GtkEntry" id="address_entry"> + <object class="GtkSwitch" id="advanced_switch"> + <property name="visible">True</property> <property name="can-focus">True</property> - <property name="no-show-all">True</property> - <signal name="changed" handler="_on_address_entry_changed" swapped="no"/> + <property name="halign">end</property> + <property name="margin-top">12</property> + <signal name="notify::active" handler="_on_toggle_advanced" swapped="no"/> </object> <packing> - <property name="left-attach">1</property> - <property name="top-attach">5</property> + <property name="left-attach">0</property> + <property name="top-attach">3</property> </packing> </child> <child> - <object class="GtkLabel" id="address_label"> + <object class="GtkLabel"> + <property name="visible">True</property> <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <property name="halign">end</property> - <property name="label" translatable="yes">_Address</property> - <property name="use-underline">True</property> - <style> - <class name="dim-label"/> - </style> + <property name="halign">start</property> + <property name="margin-top">12</property> + <property name="label" translatable="yes">Advanced Settings</property> </object> <packing> - <property name="left-attach">0</property> - <property name="top-attach">5</property> + <property name="left-attach">1</property> + <property name="top-attach">3</property> </packing> </child> <child> - <object class="GtkRadioButton" id="private_radio"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="margin-top">12</property> - <property name="active">True</property> - <property name="draw-indicator">True</property> - <property name="group">public_radio</property> - <signal name="toggled" handler="_on_public_private_toggled" swapped="no"/> + <object class="GtkBox" id="advanced_box"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="halign">center</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> <child> - <object class="GtkBox"> + <object class="GtkRadioButton" id="private_radio"> <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">start</property> - <property name="margin-start">6</property> - <property name="orientation">vertical</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="margin-top">12</property> + <property name="active">True</property> + <property name="draw-indicator">True</property> + <property name="group">public_radio</property> <child> - <object class="GtkLabel"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="halign">start</property> - <property name="label" translatable="yes">Private</property> - <property name="use-markup">True</property> - <property name="wrap">True</property> - <property name="xalign">0</property> - <style> - <class name="bold"/> - </style> + <property name="margin-start">6</property> + <property name="orientation">vertical</property> + <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">Private</property> + <property name="use-markup">True</property> + <property name="wrap">True</property> + <property name="xalign">0</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="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">You have to invite people so they can join</property> + <property name="wrap">True</property> + <property name="xalign">0</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="public_radio"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="draw-indicator">True</property> + <property name="group">private_radio</property> <child> - <object class="GtkLabel"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="halign">start</property> - <property name="label" translatable="yes">You have to invite people so they can join</property> - <property name="wrap">True</property> - <property name="xalign">0</property> - <style> - <class name="dim-label"/> - </style> + <property name="margin-start">6</property> + <property name="orientation">vertical</property> + <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">Public</property> + <property name="use-markup">True</property> + <property name="xalign">0</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="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Anyone can join</property> + <property name="wrap">True</property> + <property name="xalign">0</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> </child> </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">1</property> - <property name="top-attach">3</property> - </packing> - </child> - <child> - <object class="GtkRadioButton" id="public_radio"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="draw-indicator">True</property> - <property name="group">private_radio</property> <child> <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="margin-start">6</property> - <property name="orientation">vertical</property> + <property name="halign">end</property> + <property name="spacing">12</property> <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">Public</property> - <property name="use-markup">True</property> - <property name="xalign">0</property> + <property name="halign">end</property> + <property name="label" translatable="yes">_Address</property> + <property name="use-underline">True</property> <style> - <class name="bold"/> + <class name="dim-label"/> </style> </object> <packing> @@ -266,16 +322,11 @@ </packing> </child> <child> - <object class="GtkLabel"> + <object class="GtkEntry" id="address_entry"> + <property name="width-request">250</property> <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">start</property> - <property name="label" translatable="yes">Anyone can join</property> - <property name="wrap">True</property> - <property name="xalign">0</property> - <style> - <class name="dim-label"/> - </style> + <property name="can-focus">True</property> + <signal name="changed" handler="_on_address_entry_changed" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -284,19 +335,19 @@ </packing> </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> </child> </object> <packing> - <property name="left-attach">1</property> + <property name="left-attach">0</property> <property name="top-attach">4</property> + <property name="width">2</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property>
===================================== gajim/gtk/builder.pyi ===================================== @@ -388,10 +388,11 @@ class GroupchatCreationBuilder(Builder): description_entry: Gtk.Entry account_combo: Gtk.ComboBox account_label: Gtk.Label - address_entry: Gtk.Entry - address_label: Gtk.Label + advanced_switch: Gtk.Switch + advanced_box: Gtk.Box private_radio: Gtk.RadioButton public_radio: Gtk.RadioButton + address_entry: Gtk.Entry spinner: Gtk.Spinner create_button: Gtk.Button
===================================== gajim/gtk/groupchat_creation.py ===================================== @@ -12,6 +12,7 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import Any from typing import Optional from typing import Union
@@ -204,9 +205,6 @@ def _set_warning_from_error_code(self, error_code: str) -> None: self._set_warning(MUC_DISCO_ERRORS[error_code])
def _on_name_entry_changed(self, entry: Gtk.Entry) -> None: - if self._ui.private_radio.get_active(): - return - name = entry.get_text() name = name.replace(' ', '-') server = self._get_muc_service_jid() @@ -229,14 +227,12 @@ def _update_entry_completion(self, entry: Gtk.Entry, text: str) -> None: server = self._get_muc_service_jid() model.append([f'{text}@{server}'])
- def _on_public_private_toggled(self, _radiobutton: Gtk.RadioButton) -> None: - is_public = self._ui.public_radio.get_active() - if is_public: - self._validate_jid(self._ui.address_entry.get_text()) + def _on_toggle_advanced(self, switch: Gtk.Switch, *args: Any) -> None: + if switch.get_active(): + self._ui.advanced_box.set_no_show_all(False) + self._ui.advanced_box.show_all() else: - self._ui.create_button.set_sensitive(True) - self._ui.address_label.set_visible(is_public) - self._ui.address_entry.set_visible(is_public) + self._ui.advanced_box.hide()
def _on_create_clicked(self, _button: Gtk.Button) -> None: assert self._account is not None @@ -246,9 +242,8 @@ def _on_create_clicked(self, _button: Gtk.Button) -> None: _('You have to be connected to create a group chat.')) return
- if self._ui.public_radio.get_active(): - room_jid = self._ui.address_entry.get_text() - else: + room_jid = self._ui.address_entry.get_text() + if not self._ui.advanced_switch.get_active() or not room_jid: server = self._get_muc_service_jid() room_jid = f'{get_random_muc_localpart()}@{server}'
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/304e9a9870974da515352bd9991eade5a...