#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# 作者: ptptptptptpt < ptptptptptpt@163.com >
# 使用方法: sudo sh main.sh
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
import gtk
import vte
import user
class MainWindow(gtk.Window):
def __init__(self, parent=None):
gtk.Window.__init__(self)
self.connect('destroy', gtk.main_quit)
self.set_title('ubuntu-cloner v3.3.7')
self.set_icon_from_file('pics/ubuntu-cloner.png')
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
self.set_resizable(True)
vbox = gtk.VBox()
self.add(vbox)
hbox0 = gtk.HBox()
hbox1 = gtk.HBox()
hbox2 = gtk.HBox()
hbox1.set_border_width(10)
button1 = gtk.Button('克隆当前系统')
button1.set_border_width(9)
button1.connect('clicked', self.clone, None)
size = button1.size_request()
button1.set_size_request(size[0]+10, size[1]+30)
hbox1.pack_start(button1, expand = True)
button2 = gtk.Button('备份当前系统')
button2.set_border_width(9)
button2.connect('clicked', self.backup_current, None)
size = button2.size_request()
button2.set_size_request(size[0]+10, size[1]+30)
hbox1.pack_start(button2, expand = True)
button3 = gtk.Button('恢复系统')
button3.set_border_width(9)
button3.connect('clicked', self.restore, None)
size = button3.size_request()
button3.set_size_request(size[0]+36, size[1]+30)
hbox1.pack_start(button3, expand = True)
self.vte1 = vte.Terminal()
self.vte1.set_size_request(600, 320)
self.vte1.connect ("child-exited", self.on_vte_exit, None)
self.vte1.feed('请选择一个任务...')
scrollbar = gtk.VScrollbar()
adjustment = self.vte1.get_adjustment()
scrollbar.set_adjustment(adjustment)
hbox2.set_border_width(5)
hbox2.pack_start(self.vte1)
hbox2.pack_start(scrollbar, expand=False)
vbox.pack_start(hbox0, False)
vbox.pack_start(hbox1, False)
vbox.pack_start(hbox2, False)
def on_vte_exit(self, vte, data):
self.vte1.feed('\n\n子进程已终止。')
def clone(self, widget, data):
self.vte1.reset(True,True)
command_string = './ubuntu-cloner-main.sh clone'
command = command_string.split(' ')
self.vte1.fork_command(command=command[0], argv=command)
def backup_current(self, widget, data):
self.vte1.reset(True,True)
command_string = './ubuntu-cloner-main.sh backup'
command = command_string.split(' ')
self.vte1.fork_command(command=command[0], argv=command)
def restore(self, widget, data):
self.vte1.reset(True,True)
command_string = './ubuntu-cloner-main.sh restore'
command = command_string.split(' ')
self.vte1.fork_command(command=command[0], argv=command)
def main():
win = MainWindow();
win.show_all()
gtk.main()
if __name__ == '__main__':
main()