如果正在执行某些操作,则在关闭之前让终结者请求许可

apa*_*mer 5 gnome-terminal terminator

我通常使用 Terminator 作为终端而不是 GNOME 终端。到目前为止,我对《终结者》非常满意。但是,如果终端中正在运行某些东西,GNOME 终端会在关闭之前请求许可(例如,如果您使用 GNOME 终端通过 ssh 连接到另一台计算机,并且您想通过单击“X”按钮关闭该终端,它会提示您消息要求关闭)而终结者没有。可以在终结者中做到这一点吗?

小智 1

您需要编辑 terminatorlib container.py 文件,通常位于/usr/share/terminator/terminatorlib/container.py 找到 contruct_confirm_close || 删除它并粘贴此默认值

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.RESPONSE_ACCEPT
        
        dialog = gtk.Dialog(_('Close?'), window, gtk.DIALOG_MODAL)
        dialog.set_has_separator(False)
        dialog.set_resizable(False)
    
        dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
        c_all = dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT)
        c_all.get_children()[0].get_children()[0].get_children()[1].set_label(
                _('Close _Terminals'))
    
        primary = gtk.Label(_('<big><b>Close multiple terminals?</b></big>'))
        primary.set_use_markup(True)
        primary.set_alignment(0, 0.5)
        secondary = gtk.Label(_('This %s has several terminals open. Closing \
the %s will also close all terminals within it.') % (reqtype, reqtype))
        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.ICON_SIZE_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)
    
        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)
Run Code Online (Sandbox Code Playgroud)

请注意,在某些情况下或终止符版本中,'GTK_OBJECT可能被引用为gtkGTK