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

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

我通常使用 Terminator 作为终端,而不是 GNOME 终端。到目前为止,我对 Terminator 非常满意。但是,如果终端中正在运行某些程序,GNOME 终端会在关闭前请求权限(例如,如果您使用 GNOME 终端 ssh 到另一台计算机,并且想要通过单击按钮关闭该终端X,它会提示您一条消息,要求您提供关闭权限),而 Terminator 则不会。可以在 Terminator 中执行此操作吗?

答案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)

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

相关内容