Esempio n. 1
0
 def on_cleanup_edited(self, widget, treepath, text):
     snapshot_row = self._TreeView.get_model()[treepath]
     snapshot_num = snapshot_row[0]
     snapshot_info = snapper.GetSnapshot(self.config, snapshot_num)
     snapper.SetSnapshot(self.config, snapshot_info[0], snapshot_info[5],
                         text, snapshot_info[7])
     snapshot_row[6] = text
Esempio n. 2
0
    def __init__(self, parent, config, snapshots):
        super(deleteDialog, self).__init__()
        builder = Gtk.Builder()
        builder.add_from_file(pkg_resources.resource_filename("snappergui",
                                                              "glade/deleteSnapshot.glade"))

        self.dialog = builder.get_object("dialogDelete")
        self.dialog.set_transient_for(parent)
        self.deletetreeview = builder.get_object("deletetreeview")
        builder.connect_signals(self)

        self.snapshots_list = snapshots
        self.to_delete = snapshots

        parents = []
        self.deleteTreeStore = Gtk.TreeStore(bool, int, str, str)
        for snapshot in snapshots:
            snapinfo = snapper.GetSnapshot(config, snapshot)
            # self.deleteTreeStore.append(self.get_row(snapinfo))
            if snapinfo[1] == 1:  # Pre snapshot
                parents.append(self.deleteTreeStore.append(None, self.get_row(snapinfo)))
            elif snapinfo[1] == 2:  # Post snapshot
                parent_node = None
                for parent in parents:
                    if self.deleteTreeStore.get_value(parent, 1) == snapinfo[2]:
                        parent_node = parent
                        break
                self.deleteTreeStore.append(parent_node)
            else:  # Single snapshot
                self.deleteTreeStore.append(None, self.get_row(snapinfo))
        self.deletetreeview.set_model(self.deleteTreeStore)
        self.deletetreeview.expand_all()
Esempio n. 3
0
    def update_controlls_and_userdatatreeview(self):
        config = self.get_current_config()
        userdatatreeview = self.builder.get_object("userdatatreeview")
        if config is not None:
            model, paths = self.configView[config].selection.get_selected_rows(
            )
        if config is None or len(paths) == 0:
            self.builder.get_object("snapshotActions").set_sensitive(False)
            userdatatreeview.set_model(None)
        else:
            self.builder.get_object("snapshotActions").set_sensitive(True)

            if len(paths) == 1 and not model.iter_has_child(
                    model.get_iter(paths[0])):
                self.builder.get_object("view-changes").set_sensitive(False)
            else:
                self.builder.get_object("view-changes").set_sensitive(True)

            try:
                snapshot_data = snapper.GetSnapshot(
                    config, model[model.get_iter(paths[0])][0])
                userdata_liststore = Gtk.ListStore(str, str)
                for key, value in snapshot_data[7].items():
                    userdata_liststore.append([key, value])
                userdatatreeview.set_model(userdata_liststore)
            except dbus.exceptions.DBusException:
                pass
Esempio n. 4
0
	def add_snapshot_to_tree(self, snapshot, pre_snapshot=None):
		treemodel = self._TreeView.get_model()
		snapinfo = snapper.GetSnapshot(self.config, snapshot)
		pre_number = snapinfo[2]
		if (snapinfo[1] == 2): # if type is post
			for aux, row in enumerate(treemodel):
				if(pre_number == row[0]):
					pre_snapshot = treemodel.get_iter(aux)
					break
		treemodel.append(pre_snapshot, self.snapshot_columns(snapinfo))
Esempio n. 5
0
 def add_snapshot_to_tree(self, snapshot, pre_snapshot=None):
     treemodel = self._TreeView.get_model()
     # Ignore if we are notified about snapshot we can't read details about.
     try:
         snapinfo = snapper.GetSnapshot(self.config, snapshot)
     except dbus.exceptions.DBusException:
         return
     pre_number = snapinfo[2]
     if snapinfo[1] == 2:  # if type is post
         for aux, row in enumerate(treemodel):
             if pre_number == row[0]:
                 pre_snapshot = treemodel.get_iter(aux)
                 break
     treemodel.append(pre_snapshot, self.snapshot_columns(snapinfo))
Esempio n. 6
0
 def on_snapshots_selection_changed(self, selection):
     config = self.get_current_config()
     userdatatreeview = self.builder.get_object("userdatatreeview")
     (model, paths) = selection.get_selected_rows()
     if (len(paths) == 0):
         self.builder.get_object("snapshotActions").set_sensitive(False)
         userdatatreeview.set_model(None)
     else:
         self.builder.get_object("snapshotActions").set_sensitive(True)
         try:
             snapshot_data = snapper.GetSnapshot(
                 config, model[model.get_iter(paths[0])][0])
             userdata_liststore = Gtk.ListStore(str, str)
             for key, value in snapshot_data[7].items():
                 userdata_liststore.append([key, value])
             userdatatreeview.set_model(userdata_liststore)
         except dbus.exceptions.DBusException:
             pass