(self, window, reqtype)
return(result)
Create a confirmation dialog for closing things
Create a confirmation dialog for closing things
Create a confirmation dialog for closing things
def construct_confirm_close(self, window, reqtype):
        """Create a confirmation dialog for closing things"""
        
        # skip this dialog if applicable
        if self.config['suppress_multiple_term_dialog']:
            return Gtk.ResponseType.ACCEPT
        
        dialog = Gtk.Dialog(_('Close?'), window, Gtk.DialogFlags.MODAL)
        dialog.set_resizable(False)
    
        dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
        c_all = dialog.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT)
        c_all.get_children()[0].get_children()[0].get_children()[1].set_label(
                _('Close _Terminals'))
    
        primary = Gtk.Label(label=_('<big><b>Close multiple terminals?</b></big>'))
        primary.set_use_markup(True)
        primary.set_alignment(0, 0.5)
        if reqtype == 'window':
            label_text = _('This window has several terminals open. Closing \
the window will also close all terminals within it.')
        elif reqtype == 'tab':
            label_text = _('This tab has several terminals open. Closing \
the tab will also close all terminals within it.')
        else:
            label_text = ''
        secondary = Gtk.Label(label=label_text)
        secondary.set_line_wrap(True)
                    
        labels = Gtk.VBox()
        labels.pack_start(primary, False, False, 6)
        labels.pack_start(secondary, False, False, 6)
    
        image = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_WARNING,
                                         Gtk.IconSize.DIALOG)
        image.set_alignment(0.5, 0)
    
        box = Gtk.HBox()
        box.pack_start(image, False, False, 6)
        box.pack_start(labels, False, False, 6)
        dialog.vbox.pack_start(box, False, False, 12)

        checkbox = Gtk.CheckButton(_("Do not show this message next time"))
        dialog.vbox.pack_end(checkbox, True, True, 0)
    
        dialog.show_all()

        result = dialog.run()
        
        # set configuration
        self.config.base.reload()
        self.config['suppress_multiple_term_dialog'] = checkbox.get_active()
        self.config.save()

        dialog.destroy()
                
        return(result)
def construct_confirm_close ( self , window , reqtype ) : # skip this dialog if applicable if self . config [ 'suppress_multiple_term_dialog' ] : return Gtk . ResponseType . ACCEPT dialog = Gtk . Dialog ( _ ( 'Close?' ) , window , Gtk . DialogFlags . MODAL ) dialog . set_resizable ( False ) dialog . add_button ( Gtk . STOCK_CANCEL , Gtk . ResponseType . REJECT ) c_all = dialog . add_button ( Gtk . STOCK_CLOSE , Gtk . ResponseType . ACCEPT ) c_all . get_children ( ) [ 0 ] . get_children ( ) [ 0 ] . get_children ( ) [ 1 ] . set_label ( _ ( 'Close _Terminals' ) ) primary = Gtk . Label ( label = _ ( '<big><b>Close multiple terminals?</b></big>' ) ) primary . set_use_markup ( True ) primary . set_alignment ( 0 , 0.5 ) if reqtype == 'window' : label_text = _ ( 'This window has several terminals open. Closing \
the window will also close all terminals within it.' ) elif reqtype == 'tab' : label_text = _ ( 'This tab has several terminals open. Closing \
the tab will also close all terminals within it.' ) else : label_text = '' secondary = Gtk . Label ( label = label_text ) secondary . set_line_wrap ( True ) labels = Gtk . VBox ( ) labels . pack_start ( primary , False , False , 6 ) labels . pack_start ( secondary , False , False , 6 ) image = Gtk . Image . new_from_stock ( Gtk . STOCK_DIALOG_WARNING , Gtk . IconSize . DIALOG ) image . set_alignment ( 0.5 , 0 ) box = Gtk . HBox ( ) box . pack_start ( image , False , False , 6 ) box . pack_start ( labels , False , False , 6 ) dialog . vbox . pack_start ( box , False , False , 12 ) checkbox = Gtk . CheckButton ( _ ( "Do not show this message next time" ) ) dialog . vbox . pack_end ( checkbox , True , True , 0 ) dialog . show_all ( ) result = dialog . run ( ) # set configuration self . config . base . reload ( ) self . config [ 'suppress_multiple_term_dialog' ] = checkbox . get_active ( ) self . config . save ( ) dialog . destroy ( ) return ( result )