示例#1
0
文件: mainui.py 项目: linrunner/TLPUI
def quit_tlp_config(self, tlpconfig, window):
    changedproperties = get_changed_properties(tlpconfig)
    if len(changedproperties) == 0:
        Gtk.main_quit()
        return

    dialog = Gtk.Dialog(T_('Changed values'), window, 0, (
        Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
        Gtk.STOCK_OK, Gtk.ResponseType.OK
    ))
    dialog.set_default_size(150, 100)

    changeditemstext = T_('Do you really want to quit?\nFollowing items have changed:') + '\n\n'
    for property in changedproperties:
        changeditemstext += (property[0] + " -> " + property[2] + "\n\n")
    changeditemstext += T_('No changes will be saved.')

    label = Gtk.Label()
    label.set_markup(changeditemstext)
    label.set_valign(Gtk.Align.CENTER)
    box = dialog.get_content_area()
    box.pack_start(label, True, True, 0)

    dialog.show_all()
    response = dialog.run()

    if response == Gtk.ResponseType.OK:
        Gtk.main_quit()

    dialog.destroy()
示例#2
0
文件: mainui.py 项目: linrunner/TLPUI
def save_tlp_config(self, filenamepointer, tlpconfig, window):
    changedproperties = get_changed_properties(tlpconfig)

    dialog = Gtk.MessageDialog()
    dialog.set_default_size(150, 100)
    dialog.connect('key-press-event', close_window)

    if len(changedproperties) == 0:
        dialog.format_secondary_markup('<b>' + T_('No changes') + '</b>')
    else:
        infotext = '<b>' + T_('Changed values') + ':</b>\n'
        for property in changedproperties:
            infotext += '<small>' + property[0] + ' -> ' + property[2] + '</small>\n'

        dialog.format_secondary_markup(infotext.rstrip())
        filename = filenamepointer()
        try:
            write_tlp_file_config(changedproperties, filename)
            # reload config after file save
            load_tlp_config(self, filenamepointer, window)
        except PermissionError as error:
            dialog.format_secondary_markup(repr(error))

    dialog.run()
    dialog.destroy()
示例#3
0
def save_tlp_config(self, filenamepointer, tlpconfig, window):
    changedproperties = get_changed_properties(tlpconfig)

    dialog = Gtk.MessageDialog()
    dialog.set_default_size(150, 100)
    dialog.connect('key-press-event', close_window)

    if len(changedproperties) == 0:
        dialog.format_secondary_markup('<b>' + T_('No changes') + '</b>')
    else:
        infotext = '<b>' + T_('Changed values') + ':</b>\n'
        for property in changedproperties:
            infotext += '<small>' + property[0] + ' -> ' + property[
                2] + '</small>\n'

        dialog.format_secondary_markup(infotext.rstrip())
        filename = filenamepointer()
        try:
            write_tlp_file_config(changedproperties, filename)
            # reload config after file save
            load_tlp_config(self, filenamepointer, window)
        except PermissionError as error:
            dialog.format_secondary_markup(repr(error))

    dialog.run()
    dialog.destroy()
示例#4
0
def quit_tlp_config(self, tlpconfig, window):
    changedproperties = get_changed_properties(tlpconfig)
    if len(changedproperties) == 0:
        Gtk.main_quit()
        return

    dialog = Gtk.Dialog(T_('Changed values'), window, 0,
                        (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.OK))
    dialog.set_default_size(150, 100)

    changeditemstext = T_(
        'Do you really want to quit?\nFollowing items have changed:') + '\n\n'
    for property in changedproperties:
        changeditemstext += (property[0] + " -> " + property[2] + "\n\n")
    changeditemstext += T_('No changes will be saved.')

    label = Gtk.Label()
    label.set_markup(changeditemstext)
    label.set_valign(Gtk.Align.CENTER)
    box = dialog.get_content_area()
    box.pack_start(label, True, True, 0)

    dialog.show_all()
    response = dialog.run()

    if response == Gtk.ResponseType.OK:
        Gtk.main_quit()

    dialog.destroy()
示例#5
0
文件: mainui.py 项目: mantaroh/TLPUI
def save_tlp_config(self, window):
    changedproperties = get_changed_properties(settings.tlpconfig,
                                               settings.tlpconfig_original)

    dialog = Gtk.MessageDialog(window)
    dialog.set_default_size(150, 100)

    if len(changedproperties) == 0:
        dialog.format_secondary_markup('<b>' + language.MT_('No changes') +
                                       '</b>')
    else:
        infotext = '<b>' + language.MT_('Changed values') + ':</b>\n'
        for property in changedproperties:
            infotext += '<small>' + property[0] + ' -> ' + property[
                2] + '</small>\n'

        dialog.format_secondary_markup(infotext.rstrip())
        try:
            write_tlp_file_config(changedproperties, settings.tlpconfigfile)
            # reload config after file save
            load_tlp_config(self, window, True)
        except PermissionError as error:
            dialog.format_secondary_markup(repr(error))

    dialog.run()
    dialog.destroy()