Philipp Hörist pushed to branch master at gajim / gajim
Commits: b51b99f9 by Philipp Hörist at 2019-07-20T11:17:45Z Add a dependency on python-cairo and libcairo > 1.14.0
- - - - - 0dbad0ca by Philipp Hörist at 2019-07-20T13:33:08Z Groupchat: Integrate password entry into GroupChatControl
- - - - -
5 changed files:
- gajim/data/gui/groupchat_control.ui - gajim/gajim.py - gajim/groupchat_control.py - gajim/gui_interface.py - setup.cfg
Changes:
===================================== gajim/data/gui/groupchat_control.ui ===================================== @@ -84,6 +84,7 @@ <object class="GtkStack" id="stack"> <property name="visible">True</property> <property name="can_focus">False</property> + <signal name="notify::visible-child-name" handler="_on_page_change" swapped="no"/> <child> <object class="GtkBox" id="groupchat_control_vbox"> <property name="can_focus">True</property> @@ -704,6 +705,112 @@ <property name="position">3</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"> + <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="row_spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Enter password</property> + <property name="xalign">0</property> + <style> + <class name="bold16"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <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">_Cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="_on_password_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="password_set_button"> + <property name="label" translatable="yes">_Join</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> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="_on_password_set_clicked" swapped="no"/> + <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> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="password_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="visibility">False</property> + <property name="invisible_char">*</property> + <property name="input_purpose">password</property> + <signal name="notify::text" handler="_on_password_changed" swapped="no"/> + </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">0</property> + </packing> + </child> + </object> + <packing> + <property name="name">password</property> + <property name="position">4</property> + </packing> + </child> </object> <packing> <property name="expand">True</property>
===================================== gajim/gajim.py ===================================== @@ -28,6 +28,7 @@ from gajim.common import i18n
_MIN_NBXMPP_VER = "0.9.91" _MIN_GTK_VER = "3.22.0" +_MIN_CAIRO_VER = "1.14.0"
def _check_required_deps(): @@ -42,6 +43,22 @@ def _check_required_deps(): 'Quitting...' % _MIN_NBXMPP_VER) sys.exit(1)
+ try: + import cairo + except ImportError: + print('Gajim needs python-cairo to run. Quitting…') + sys.exit(1) + + if V(cairo.cairo_version_string()) < V(_MIN_CAIRO_VER): + print('Gajim needs libcairo >= %s to run. ' + 'Quitting...' % _MIN_CAIRO_VER) + sys.exit(1) + + if V(cairo.version) < V(_MIN_CAIRO_VER): + print('Gajim needs python-cairo >= %s to run. ' + 'Quitting...' % _MIN_CAIRO_VER) + sys.exit(1) +
def _init_gui(gui): if gui == 'GTK':
===================================== gajim/groupchat_control.py ===================================== @@ -1951,8 +1951,7 @@ class GroupchatControl(ChatControlBase): error_message = event.properties.error.message
if error_type == Error.NOT_AUTHORIZED: - app.interface.handle_gc_password_required( - self.account, self.room_jid, nick) + self._show_page('password')
elif error_type == Error.FORBIDDEN: # we are banned @@ -2475,7 +2474,11 @@ class GroupchatControl(ChatControlBase): if action == 'escape': if self._get_current_page() == 'groupchat': return Gdk.EVENT_PROPAGATE - self._show_page('groupchat') + + if self._get_current_page() == 'password': + self._on_password_cancel_clicked() + else: + self._show_page('groupchat') return Gdk.EVENT_STOP
if action == 'change-subject': @@ -2926,6 +2929,13 @@ class GroupchatControl(ChatControlBase): else: self.revoke_owner(widget, jid)
+ def _on_page_change(self, stack, _param): + page_name = stack.get_visible_child_name() + if page_name == 'password': + self.xml.password_entry.set_text('') + self.xml.password_entry.grab_focus() + self.xml.password_set_button.grab_default() + def _on_change_nick(self, _action, _param): if self._get_current_page() == 'nickname': return @@ -2968,6 +2978,21 @@ class GroupchatControl(ChatControlBase): con.get_module('MUC').set_subject(self.room_jid, subject) self._show_page('groupchat')
+ def _on_password_set_clicked(self, _button): + password = self.xml.password_entry.get_text() + app.gc_passwords[self.room_jid] = password + app.connections[self.account].get_module('MUC').join( + self.room_jid, self.nick, password) + self._show_page('groupchat') + + def _on_password_changed(self, entry, _param): + self.xml.password_set_button.set_sensitive(bool(entry.get_text())) + + def _on_password_cancel_clicked(self, _button=None): + self.force_non_minimizable = True + self.parent_win.remove_tab(self, self.parent_win.CLOSE_COMMAND) + self.force_non_minimizable = False + def _on_page_cancel_clicked(self, _button): self._show_page('groupchat')
===================================== gajim/gui_interface.py ===================================== @@ -266,34 +266,6 @@ class Interface: d.set_transient_for(gc_control.parent_win.window) d.set_modal(False)
- def handle_gc_password_required(self, account, room_jid, nick): - def on_ok(text): - app.connections[account].get_module('MUC').join( - room_jid, nick, text) - app.gc_passwords[room_jid] = text - gc_control.error_dialog = None - - def on_cancel(): - # get and destroy window - if room_jid in app.interface.minimized_controls[account]: - self.roster.on_disconnect(None, room_jid, account) - else: - win = self.msg_win_mgr.get_window(room_jid, account) - ctrl = self.msg_win_mgr.get_gc_control(room_jid, account) - win.remove_tab(ctrl, 3) - gc_control.error_dialog = None - - gc_control = self.msg_win_mgr.get_gc_control(room_jid, account) - if gc_control: - if gc_control.error_dialog: - gc_control.error_dialog.destroy() - - gc_control.error_dialog = InputDialog(_('Password Required'), - _('A Password is required to join the group chat %s. Please type it.') % \ - room_jid, is_modal=False, ok_handler=on_ok, - cancel_handler=on_cancel) - gc_control.error_dialog.input_entry.set_visibility(False) - def handle_event_presence(self, obj): # 'NOTIFY' (account, (jid, status, status message, resource, # priority, timestamp))
===================================== setup.cfg ===================================== @@ -25,6 +25,7 @@ install_requires = nbxmpp>=0.9.91 precis-i18n>=1.0.0 pyOpenSSL>=16.2 + pycairo>=1.14.0
[options.package_data] gajim =
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/2c82deccf7186b062da930e85a7bd53e1e...