Commit 6ba21fe5 authored by Philipp Hörist's avatar Philipp Hörist

Groupchat: Integrate subject change into GroupchatControl

parent c3f53b57
......@@ -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>
......
......@@ -627,17 +627,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 +2311,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():
......@@ -2972,7 +2950,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')
......
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