Philipp Hörist pushed to branch master at gajim / gajim
Commits: c18cc281 by Daniel Brötzmann at 2019-05-21T20:22:20Z Rework DoubleInputDialog to DestroyMucDialog
- - - - -
3 changed files:
- gajim/data/gui/dubbleinput_dialog.ui → gajim/data/gui/destroy_muc_dialog.ui - gajim/groupchat_control.py - gajim/gtk/dialogs.py
Changes:
===================================== gajim/data/gui/dubbleinput_dialog.ui → gajim/data/gui/destroy_muc_dialog.ui ===================================== @@ -1,32 +1,36 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface> - <requires lib="gtk+" version="3.12"/> - <object class="GtkDialog" id="dubbleinput_dialog"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkDialog" id="destroy_muc_dialog"> + <property name="width_request">250</property> <property name="can_focus">False</property> - <property name="border_width">6</property> + <property name="border_width">18</property> + <property name="resizable">False</property> + <property name="modal">True</property> <property name="type_hint">dialog</property> - <signal name="destroy" handler="on_dubbleinput_dialog_destroy" swapped="no"/> + <child> + <placeholder/> + </child> <child internal-child="vbox"> - <object class="GtkBox" id="dialog-vbox10"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> - <property name="spacing">6</property> + <property name="spacing">12</property> <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area9"> + <object class="GtkButtonBox"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="layout_style">end</property> <child> - <object class="GtkButton" id="cancelbutton"> - <property name="label">gtk-cancel</property> - <property name="use_action_appearance">False</property> + <object class="GtkButton" id="cancel_button"> + <property name="label">_Cancel</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="can_default">True</property> <property name="receives_default">False</property> - <property name="use_stock">True</property> + <property name="use_underline">True</property> </object> <packing> <property name="expand">False</property> @@ -35,15 +39,17 @@ </packing> </child> <child> - <object class="GtkButton" id="okbutton"> - <property name="label">gtk-ok</property> - <property name="use_action_appearance">False</property> + <object class="GtkButton" id="destroy_button"> + <property name="label">_Destroy</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="can_default">True</property> <property name="has_default">True</property> <property name="receives_default">False</property> - <property name="use_stock">True</property> + <property name="use_underline">True</property> + <style> + <class name="destructive-action"/> + </style> </object> <packing> <property name="expand">False</property> @@ -60,95 +66,129 @@ </packing> </child> <child> - <object class="GtkBox" id="vbox76"> + <object class="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="border_width">6</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> <child> - <object class="GtkBox" id="hbox2960"> + <object class="GtkLabel" id="label_header"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">12</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Destroy this group chat permanently?</property> + <property name="use_markup">True</property> + <property name="wrap">True</property> + <property name="xalign">0</property> + <style> + <class name="large-header"/> + </style> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="reason_expander"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="margin_top">6</property> <child> - <object class="GtkImage" id="image507"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="stock">gtk-dialog-question</property> - <property name="icon_size">6</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkEntry" id="reason_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="margin_top">6</property> + <property name="activates_default">True</property> + <property name="placeholder_text" translatable="yes">Reason...</property> + <property name="show_emoji_icon">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="alt_venue_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="margin_top">6</property> + <property name="label" translatable="yes">Where participants should go (optional)</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">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="alt_venue_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="placeholder_text" translatable="yes">Alternate venue...</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</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="GtkLabel" id="label1"> + <child type="label"> + <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="use_markup">True</property> + <property name="label" translatable="yes">_Reason and alternate venue (optional)</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">reason_entry</property> + <signal name="mnemonic-activate" handler="_on_reason_mnemonic_activate" swapped="no"/> + <style> + <class name="dim-label"/> + </style> </object> - <packing> - <property name="expand">True</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> + <property name="left_attach">1</property> + <property name="top_attach">1</property> </packing> </child> <child> - <object class="GtkEntry" id="input_entry1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="activates_default">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label2"> + <object class="GtkImage"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="valign">start</property> + <property name="icon_name">user-trash-symbolic</property> + <property name="icon_size">6</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="input_entry2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">3</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="height">2</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">0</property> </packing> </child> </object> </child> - <action-widgets> - <action-widget response="-6">cancelbutton</action-widget> - <action-widget response="-5">okbutton</action-widget> - </action-widgets> </object> </interface>
===================================== gajim/groupchat_control.py ===================================== @@ -71,7 +71,7 @@ from gajim.common.connection_handlers_events import GcMessageOutgoingEvent from gajim.gtk.dialogs import ErrorDialog from gajim.gtk.dialogs import InputTextDialog from gajim.gtk.dialogs import ConfirmationDialogCheck -from gajim.gtk.dialogs import DoubleInputDialog +from gajim.gtk.dialogs import DestroyMucDialog from gajim.gtk.dialogs import InputDialog from gajim.gtk.dialogs import ChangeNickDialog from gajim.gtk.single_message import SingleMessageWindow @@ -643,7 +643,7 @@ class GroupchatControl(ChatControlBase): self.force_non_minimizable = False
def _on_destroy_room(self, action, param): - def on_ok(reason, jid): + def _on_confirm(reason, jid): if jid: # Test jid try: @@ -658,12 +658,8 @@ class GroupchatControl(ChatControlBase): con = app.connections[self.account] con.get_module('MUC').destroy(self.room_jid, reason, jid)
- # Ask for a reason - DoubleInputDialog(_('Destroying %s') % '\u200E' + \ - self.room_jid, _('You are going to remove this room permanently.' - '\nYou may specify a reason below:'), - _('You may also enter an alternate venue:'), ok_handler=on_ok, - transient_for=self.parent_win.window) + # Ask for a reason (and an alternate venue) + DestroyMucDialog(self.room_jid, destroy_handler=_on_confirm)
def _on_configure_room(self, _action, _param): contact = app.contacts.get_gc_contact(
===================================== gajim/gtk/dialogs.py ===================================== @@ -814,72 +814,48 @@ class InputTextDialog(CommonInputDialog): return self.input_buffer.get_text(start_iter, end_iter, True)
-class DoubleInputDialog: +class DestroyMucDialog: """ - Class for Double Input dialog + Class for Destroy MUC Dialog """ + def __init__(self, room_jid, destroy_handler=None): + self._ui = get_builder('destroy_muc_dialog.ui') + self._ui.destroy_muc_dialog.set_transient_for( + app.app.get_active_window()) + + self.destroy_handler = destroy_handler + + title = _('Destroy %s') % room_jid + self._ui.destroy_muc_dialog.set_title(title) + label_header = _('Destroy this group chat permanently?') + self._ui.label_header.set_markup(label_header) + label_alt_venue = _('Where participants should go (optional)') + self._ui.alt_venue_label.set_markup(label_alt_venue) + + self._ui.reason_entry.connect('activate', self._on_entry_activate) + self._ui.alt_venue_entry.connect('activate', self._on_entry_activate) + + self._ui.destroy_button.connect( + 'clicked', self._on_destroy_button_clicked) + self._ui.cancel_button.connect( + 'clicked', self._on_cancel_button_clicked) + self._ui.connect_signals(self) + self._ui.destroy_muc_dialog.show_all()
- def __init__(self, title, label_str1, label_str2, input_str1=None, - input_str2=None, is_modal=True, ok_handler=None, cancel_handler=None, - transient_for=None): - self.xml = get_builder('dubbleinput_dialog.ui') - self.dialog = self.xml.get_object('dubbleinput_dialog') - label1 = self.xml.get_object('label1') - self.input_entry1 = self.xml.get_object('input_entry1') - label2 = self.xml.get_object('label2') - self.input_entry2 = self.xml.get_object('input_entry2') - self.dialog.set_title(title) - label1.set_markup(label_str1) - label2.set_markup(label_str2) - self.cancel_handler = cancel_handler - if input_str1: - self.input_entry1.set_text(input_str1) - self.input_entry1.select_region(0, -1) # select all - if input_str2: - self.input_entry2.set_text(input_str2) - self.input_entry2.select_region(0, -1) # select all - if transient_for is None: - transient_for = app.app.get_active_window() - self.dialog.set_transient_for(transient_for) + def _on_entry_activate(self, widget, *args): + self._ui.destroy_button.set_active(True)
- self.dialog.set_modal(is_modal) + def _on_reason_mnemonic_activate(self, widget, group_cycling=False): + self._ui.reason_expander.set_expanded(True)
- self.ok_handler = ok_handler - okbutton = self.xml.get_object('okbutton') - okbutton.connect('clicked', self.on_okbutton_clicked) - cancelbutton = self.xml.get_object('cancelbutton') - cancelbutton.connect('clicked', self.on_cancelbutton_clicked) - self.xml.connect_signals(self) - self.dialog.show_all() + def _on_destroy_button_clicked(self, widget): + user_input_reason = self._ui.reason_entry.get_text() + user_input_alt_venue = self._ui.alt_venue_entry.get_text() + self._ui.destroy_muc_dialog.destroy() + self.destroy_handler(user_input_reason, user_input_alt_venue)
- def on_dubbleinput_dialog_destroy(self, widget): - if not self.cancel_handler: - return False - if isinstance(self.cancel_handler, tuple): - self.cancel_handler[0](*self.cancel_handler[1:]) - else: - self.cancel_handler() - - def on_okbutton_clicked(self, widget): - user_input1 = self.input_entry1.get_text() - user_input2 = self.input_entry2.get_text() - self.cancel_handler = None - self.dialog.destroy() - if not self.ok_handler: - return - if isinstance(self.ok_handler, tuple): - self.ok_handler[0](user_input1, user_input2, *self.ok_handler[1:]) - else: - self.ok_handler(user_input1, user_input2) - - def on_cancelbutton_clicked(self, widget): - self.dialog.destroy() - if not self.cancel_handler: - return - if isinstance(self.cancel_handler, tuple): - self.cancel_handler[0](*self.cancel_handler[1:]) - else: - self.cancel_handler() + def _on_cancel_button_clicked(self, widget): + self._ui.destroy_muc_dialog.destroy()
class CertificateDialog(Gtk.ApplicationWindow):
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/c18cc281c5f5b7588771e7f3195496ee5d3...