Philipp Hörist pushed to branch master at gajim / gajim
Commits: 6ba21fe5 by Philipp Hörist at 2019-07-17T22:00:47Z Groupchat: Integrate subject change into GroupchatControl
- - - - - a58e9d31 by Philipp Hörist at 2019-07-17T22:00:52Z Groupchat: Don't reload nickname page
- - - - - e2c4a6d5 by Philipp Hörist at 2019-07-17T22:01:06Z MessageWindow: Dont forward all keypresses to the MessageTextview
This is very messy, because it has the potential to disturb other widgets shortcuts. Instead we should give focus to the MessageTextview whenever it makes sense.
- - - - - 05bb0f45 by Philipp Hörist at 2019-07-17T22:01:06Z Groupchat: Give MessageTextview focus after page change
- - - - -
3 changed files:
- gajim/data/gui/groupchat_control.ui - gajim/groupchat_control.py - gajim/message_window.py
Changes:
===================================== gajim/data/gui/groupchat_control.ui ===================================== @@ -543,7 +543,7 @@ <property name="halign">start</property> <property name="valign">start</property> <property name="use_underline">True</property> - <signal name="clicked" handler="_on_nickname_cancel_clicked" swapped="no"/> + <signal name="clicked" handler="_on_page_cancel_clicked" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -592,6 +592,118 @@ <property name="position">2</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">Change Subject</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_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="subject_change_button"> + <property name="label" translatable="yes">Ch_ange</property> + <property name="visible">True</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_subject_change_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="GtkScrolledWindow"> + <property name="width_request">450</property> + <property name="height_request">250</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="subject_textview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="wrap_mode">word</property> + </object> + </child> + </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">subject</property> + <property name="position">3</property> + </packing> + </child> </object> <packing> <property name="expand">True</property>
===================================== gajim/groupchat_control.py ===================================== @@ -538,6 +538,7 @@ class GroupchatControl(ChatControlBase): transition = Gtk.StackTransitionType.SLIDE_DOWN if name == 'groupchat': transition = Gtk.StackTransitionType.SLIDE_UP + self.msg_textview.grab_focus() self.xml.stack.set_visible_child_full(name, transition)
def _get_current_page(self): @@ -627,17 +628,6 @@ class GroupchatControl(ChatControlBase):
# Actions
- def _on_change_subject(self, action, param): - def on_ok(subject): - # Note, we don't update self.subject since we don't know whether it - # will work yet - con = app.connections[self.account] - con.get_module('MUC').set_subject(self.room_jid, subject) - - InputTextDialog(_('Changing Subject'), - _('Please specify the new subject:'), input_str=self.subject, - ok_handler=on_ok, transient_for=self.parent_win.window) - def _on_disconnect(self, action, param): app.connections[self.account].get_module('MUC').leave(self.room_jid) self.force_non_minimizable = True @@ -2322,17 +2312,6 @@ class GroupchatControl(ChatControlBase): # gc can only have messages as event return nb
- def _on_change_subject_menuitem_activate(self, widget): - def on_ok(subject): - # Note, we don't update self.subject since we don't know whether it - # will work yet - con = app.connections[self.account] - con.get_module('MUC').set_subject(self.room_jid, subject) - - InputTextDialog(_('Changing Subject'), - _('Please specify the new subject:'), input_str=self.subject, - ok_handler=on_ok, transient_for=self.parent_win.window) - def _on_drag_data_received(self, widget, context, x, y, selection, target_type, timestamp): if not selection.get_data(): @@ -2949,6 +2928,8 @@ class GroupchatControl(ChatControlBase): self.revoke_owner(widget, jid)
def _on_change_nick(self, _action, _param): + if self._get_current_page() == 'nickname': + return self.xml.nickname_entry.set_text(self.nick) self.xml.nickname_entry.grab_focus() self.xml.nickname_change_button.grab_default() @@ -2972,7 +2953,23 @@ class GroupchatControl(ChatControlBase): self.room_jid, new_nick) self._show_page('groupchat')
- def _on_nickname_cancel_clicked(self, _button): + def _on_change_subject(self, _action, _param): + if self._get_current_page() == 'subject': + return + self.xml.subject_textview.get_buffer().set_text(self.subject) + self.xml.subject_textview.grab_focus() + self._show_page('subject') + + def _on_subject_change_clicked(self, _button): + buffer_ = self.xml.subject_textview.get_buffer() + subject = buffer_.get_text(buffer_.get_start_iter(), + buffer_.get_end_iter(), + False) + con = app.connections[self.account] + con.get_module('MUC').set_subject(self.room_jid, subject) + self._show_page('groupchat') + + def _on_page_cancel_clicked(self, _button): self._show_page('groupchat')
===================================== gajim/message_window.py ===================================== @@ -132,9 +132,6 @@ class MessageWindow: id_ = self.notebook.connect('switch-page', self._on_notebook_switch_page) self.handlers[id_] = self.notebook - id_ = self.notebook.connect('key-press-event', - self._on_notebook_key_press) - self.handlers[id_] = self.notebook
# Tab customizations pref_pos = app.config.get('tabs_position') @@ -257,17 +254,6 @@ class MessageWindow: self.move_to_next_unread_tab(False) return
- def _on_notebook_key_press(self, _widget, event): - control = self.get_active_control() - if control is None: - return - - if isinstance(control, ChatControlBase): - # we forwarded it to message textview - control.msg_textview.remove_placeholder() - control.msg_textview.event(event) - control.msg_textview.grab_focus() - def change_account_name(self, old_name, new_name): if old_name in self._controls: self._controls[new_name] = self._controls[old_name]
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/c3f53b574104ca9da94b4a741d52253f53...