Philipp Hörist pushed to branch master at gajim / gajim

Commits:

4 changed files:

Changes:

  • gajim/gtk/dialogs.py
    ... ... @@ -15,6 +15,7 @@
    15 15
     from collections import namedtuple
    
    16 16
     
    
    17 17
     from gi.repository import Gtk
    
    18
    +from gi.repository import Pango
    
    18 19
     
    
    19 20
     from gajim.common import app
    
    20 21
     from gajim.common import helpers
    
    ... ... @@ -53,6 +54,11 @@ class DialogButton(namedtuple('DialogButton', ('response text callback args '
    53 54
                     default_kwargs['response'] = Gtk.ResponseType.OK
    
    54 55
                     default_kwargs['text'] = _('Delete')
    
    55 56
                     default_kwargs['action'] = ButtonAction.DESTRUCTIVE
    
    57
    +
    
    58
    +            elif type_ == 'Remove':
    
    59
    +                default_kwargs['response'] = Gtk.ResponseType.OK
    
    60
    +                default_kwargs['text'] = _('Remove')
    
    61
    +                default_kwargs['action'] = ButtonAction.DESTRUCTIVE
    
    56 62
                 else:
    
    57 63
                     raise ValueError('Unknown button type: %s ' % type_)
    
    58 64
     
    
    ... ... @@ -990,12 +996,16 @@ class ChangePasswordDialog(Gtk.Dialog):
    990 996
     
    
    991 997
     
    
    992 998
     class NewConfirmationDialog(Gtk.MessageDialog):
    
    993
    -    def __init__(self, title, text, sec_text, buttons, transient_for=None):
    
    999
    +    def __init__(self, title, text, sec_text, buttons,
    
    1000
    +                 modal=True, transient_for=None):
    
    1001
    +        if transient_for is None:
    
    1002
    +            transient_for = app.app.get_active_window()
    
    994 1003
             Gtk.MessageDialog.__init__(self,
    
    995 1004
                                        title=title,
    
    996 1005
                                        text=text,
    
    997 1006
                                        transient_for=transient_for,
    
    998
    -                                   message_type=Gtk.MessageType.QUESTION)
    
    1007
    +                                   message_type=Gtk.MessageType.QUESTION,
    
    1008
    +                                   modal=modal)
    
    999 1009
     
    
    1000 1010
             self._buttons = {}
    
    1001 1011
     
    
    ... ... @@ -1012,8 +1022,6 @@ class NewConfirmationDialog(Gtk.MessageDialog):
    1012 1022
     
    
    1013 1023
             self.connect('response', self._on_response)
    
    1014 1024
     
    
    1015
    -        self.run()
    
    1016
    -
    
    1017 1025
         def _on_response(self, _dialog, response):
    
    1018 1026
             if response == Gtk.ResponseType.DELETE_EVENT:
    
    1019 1027
                 # Look if DELETE_EVENT is mapped to another response
    
    ... ... @@ -1031,6 +1039,40 @@ class NewConfirmationDialog(Gtk.MessageDialog):
    1031 1039
                 button.callback(*button.args, **button.kwargs)
    
    1032 1040
             self.destroy()
    
    1033 1041
     
    
    1042
    +    def show(self):
    
    1043
    +        self.show_all()
    
    1044
    +
    
    1045
    +
    
    1046
    +class NewConfirmationCheckDialog(NewConfirmationDialog):
    
    1047
    +    def __init__(self, title, text, sec_text, check_text,
    
    1048
    +                 buttons, modal=True, transient_for=None):
    
    1049
    +        NewConfirmationDialog.__init__(self,
    
    1050
    +                                       title,
    
    1051
    +                                       text,
    
    1052
    +                                       sec_text,
    
    1053
    +                                       buttons,
    
    1054
    +                                       transient_for=transient_for,
    
    1055
    +                                       modal=modal)
    
    1056
    +
    
    1057
    +        self._checkbutton = Gtk.CheckButton.new_with_mnemonic(check_text)
    
    1058
    +        self._checkbutton.set_can_focus(False)
    
    1059
    +        self._checkbutton.set_margin_start(30)
    
    1060
    +        self._checkbutton.set_margin_end(30)
    
    1061
    +        label = self._checkbutton.get_child()
    
    1062
    +        label.set_line_wrap(True)
    
    1063
    +        label.set_max_width_chars(50)
    
    1064
    +        label.set_halign(Gtk.Align.START)
    
    1065
    +        label.set_line_wrap_mode(Pango.WrapMode.WORD)
    
    1066
    +        label.set_margin_start(10)
    
    1067
    +
    
    1068
    +        self.get_content_area().add(self._checkbutton)
    
    1069
    +
    
    1070
    +    def _on_response(self, _dialog, response):
    
    1071
    +        button = self._buttons.get(response)
    
    1072
    +        if button is not None:
    
    1073
    +            button.args.insert(0, self._checkbutton.get_active())
    
    1074
    +        super()._on_response(_dialog, response)
    
    1075
    +
    
    1034 1076
     
    
    1035 1077
     class ShortcutsWindow:
    
    1036 1078
         def __init__(self):
    

  • gajim/gtk/themes.py
    ... ... @@ -24,7 +24,6 @@ from gajim.common import app
    24 24
     from gajim.common.nec import NetworkEvent
    
    25 25
     from gajim.common.i18n import _
    
    26 26
     from gajim.common.const import StyleAttr
    
    27
    -from gajim.common.const import ButtonAction
    
    28 27
     
    
    29 28
     from gajim.gtk.dialogs import ErrorDialog
    
    30 29
     from gajim.gtk.dialogs import DialogButton
    
    ... ... @@ -326,7 +325,7 @@ class Themes(Gtk.ApplicationWindow):
    326 325
                 _('Do you want to permanently delete this theme?'),
    
    327 326
                 [DialogButton.make('Cancel'),
    
    328 327
                  DialogButton.make('Delete', callback=_remove_theme)],
    
    329
    -            transient_for=self)
    
    328
    +            transient_for=self).show()
    
    330 329
     
    
    331 330
         @staticmethod
    
    332 331
         def _on_destroy(*args):
    

  • gajim/history_manager.py
    ... ... @@ -44,7 +44,6 @@ from gi.repository import Gio
    44 44
     from gi.repository import Pango
    
    45 45
     
    
    46 46
     from gajim.common import app
    
    47
    -from gajim.common import i18n
    
    48 47
     from gajim.common import configpaths
    
    49 48
     from gajim.common.i18n import _
    
    50 49
     from gajim.common.i18n import ngettext
    
    ... ... @@ -578,7 +577,7 @@ class HistoryManager:
    578 577
                          paths_len, liststore[list_of_paths[0]][0]),
    
    579 578
                 [DialogButton.make('Cancel'),
    
    580 579
                  DialogButton.make('Delete', callback=on_ok)],
    
    581
    -            transient_for=self._ui.history_manager_window)
    
    580
    +            transient_for=self._ui.history_manager_window).show()
    
    582 581
     
    
    583 582
         def _delete_logs(self, liststore, list_of_paths):
    
    584 583
             paths_len = len(list_of_paths)
    
    ... ... @@ -615,7 +614,7 @@ class HistoryManager:
    615 614
                          paths_len),
    
    616 615
                 [DialogButton.make('Cancel'),
    
    617 616
                  DialogButton.make('Delete', callback=on_ok)],
    
    618
    -            transient_for=self._ui.history_manager_window)
    
    617
    +            transient_for=self._ui.history_manager_window).show()
    
    619 618
     
    
    620 619
         def on_search_db_button_clicked(self, widget):
    
    621 620
             text = self._ui.search_entry.get_text()
    

  • gajim/roster_window.py
    ... ... @@ -71,6 +71,8 @@ from gajim.gtk.dialogs import InputDialog
    71 71
     from gajim.gtk.dialogs import WarningDialog
    
    72 72
     from gajim.gtk.dialogs import InformationDialog
    
    73 73
     from gajim.gtk.dialogs import NonModalConfirmationDialog
    
    74
    +from gajim.gtk.dialogs import NewConfirmationCheckDialog
    
    75
    +from gajim.gtk.dialogs import DialogButton
    
    74 76
     from gajim.gtk.join_groupchat import JoinGroupchatWindow
    
    75 77
     from gajim.gtk.single_message import SingleMessageWindow
    
    76 78
     from gajim.gtk.add_contact import AddNewContactWindow
    
    ... ... @@ -3347,7 +3349,7 @@ class RosterWindow:
    3347 3349
             """
    
    3348 3350
             Remove a contact. list_ is a list of (contact, account) tuples
    
    3349 3351
             """
    
    3350
    -        def on_ok(is_checked, list_):
    
    3352
    +        def on_ok(is_checked):
    
    3351 3353
                 remove_auth = True
    
    3352 3354
                 if len(list_) == 1:
    
    3353 3355
                     contact = list_[0][0]
    
    ... ... @@ -3366,8 +3368,8 @@ class RosterWindow:
    3366 3368
                         contact.show = 'offline'
    
    3367 3369
                         app.contacts.add_contact(account, contact)
    
    3368 3370
                         self.add_contact(contact.jid, account)
    
    3369
    -        def on_ok2(list_):
    
    3370
    -            on_ok(False, list_)
    
    3371
    +        def on_ok2():
    
    3372
    +            on_ok(False)
    
    3371 3373
     
    
    3372 3374
             if len(list_) == 1:
    
    3373 3375
                 contact = list_[0][0]
    
    ... ... @@ -3380,19 +3382,22 @@ class RosterWindow:
    3380 3382
                     ConfirmationDialog(pritext, sectext + \
    
    3381 3383
                         _('By removing this contact you also remove authorization '
    
    3382 3384
                         'resulting in them always seeing you as offline.'),
    
    3383
    -                    on_response_ok=(on_ok2, list_))
    
    3385
    +                    on_response_ok=on_ok2)
    
    3384 3386
                 elif _('Not in Roster') in contact.get_shown_groups():
    
    3385 3387
                     # Contact is not in roster
    
    3386 3388
                     ConfirmationDialog(pritext, sectext + \
    
    3387
    -                    _('Do you want to continue?'), on_response_ok=(on_ok2,
    
    3388
    -                    list_))
    
    3389
    +                    _('Do you want to continue?'), on_response_ok=on_ok2)
    
    3389 3390
                 else:
    
    3390
    -                ConfirmationDialogCheck(pritext, sectext + \
    
    3391
    +                NewConfirmationCheckDialog(
    
    3392
    +                    _('Remove'),
    
    3393
    +                    pritext, sectext + \
    
    3391 3394
                         _('By removing this contact you also by default remove '
    
    3392
    -                    'authorization resulting in them always seeing you as'
    
    3393
    -                    ' offline.'),
    
    3394
    -                    _('I want this contact to know my status after removal'),
    
    3395
    -                    on_response_ok=(on_ok, list_))
    
    3395
    +                      'authorization resulting in them always seeing you as'
    
    3396
    +                      ' offline.'),
    
    3397
    +                    _('_I want this contact to know my status after removal'),
    
    3398
    +                    [DialogButton.make('Cancel'),
    
    3399
    +                     DialogButton.make('Remove', callback=on_ok)],
    
    3400
    +                     modal=False).show()
    
    3396 3401
             else:
    
    3397 3402
                 # several contact to remove at the same time
    
    3398 3403
                 pritext = _('Contacts will be removed from your roster')
    
    ... ... @@ -3403,8 +3408,7 @@ class RosterWindow:
    3403 3408
                 sectext = _('By removing these contacts:%s\nyou also remove '
    
    3404 3409
                     'authorization resulting in them always seeing you as '
    
    3405 3410
                     'offline.') % jids
    
    3406
    -            ConfirmationDialog(pritext, sectext,
    
    3407
    -                on_response_ok=(on_ok2, list_))
    
    3411
    +            ConfirmationDialog(pritext, sectext, on_response_ok=on_ok2)
    
    3408 3412
     
    
    3409 3413
         def on_send_custom_status(self, widget, contact_list, show, group=None):
    
    3410 3414
             """