Exemplo n.º 1
0
    public FDQueueView()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        UserSettings = new FDUserSettings();
        DataStore = new FDDataStore(UserSettings.CurrentDataStore, FDLogVerbosity.Warning);
        log = new FDOperationLog(DataStore, FDLogVerbosity.Warning, true);
        operationQueue = new FDOperationQueue(DataStore, UserSettings, log);
        treeview1.Selection.Changed += RemoveSensitive;

        //Create the item list
        items = new List<ListItem>();
        this.uploadQueue = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(Guid), typeof(FDItemStatus));

        //Create the tree view columns and misc
        TreeViewColumn icon = new TreeViewColumn();
        TreeViewColumn filename = new TreeViewColumn();
        TreeViewColumn progress = new TreeViewColumn();
        icon.Title = "";
        filename.Title = "Filename";
        progress.Title = "Progress";
        Gtk.CellRendererPixbuf iconCell = new Gtk.CellRendererPixbuf();
        Gtk.CellRendererText filenameCell = new Gtk.CellRendererText();
        Gtk.CellRendererText progressCell = new Gtk.CellRendererText();
        icon.PackStart(iconCell, true);
        filename.PackStart(filenameCell, true);
        progress.PackStart(progressCell, false);
        icon.AddAttribute(iconCell, "pixbuf", 0);
        filename.AddAttribute(filenameCell, "text", 1);
        progress.AddAttribute(progressCell, "text", 2);
        treeview1.AppendColumn(icon);
        treeview1.AppendColumn(filename);
        treeview1.AppendColumn(progress);
        treeview1.Model = this.uploadQueue;
        Gtk.TreeSelection selection = treeview1.Selection;
        selection.Mode = Gtk.SelectionMode.Multiple;

        //Verify our settings. If they aren't present, we need to show the settings dialog
        if(String.IsNullOrWhiteSpace(UserSettings.AWSAccessKey) ||
           String.IsNullOrWhiteSpace(UserSettings.AWSSecretKey) ||
           String.IsNullOrWhiteSpace(UserSettings.AWSGlacierVaultName))
        {
            FDPreferences preferences = new FDPreferences(this, DialogFlags.Modal, UserSettings, true);
            preferences.Run();
            preferences.Destroy();
        }

        //Create the uploader thread
        uploadQueueWorker = new BackgroundWorker();
        uploadQueueWorker.DoWork += new DoWorkEventHandler(_uploadQueueWork);
        uploadQueueWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_uploadQueueDone);
        if(!uploadQueueWorker.IsBusy)
        {
            uploadQueueWorker.RunWorkerAsync();
        }

        //Create the downloader thred
        downloadQueueWorker = new BackgroundWorker();
        downloadQueueWorker.DoWork += new DoWorkEventHandler(_downloadQueueWork);
        downloadQueueWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_downloadQueueDone);
        if(!downloadQueueWorker.IsBusy)
        {
            downloadQueueWorker.RunWorkerAsync();
        }

        //Now create the UI update thread that watches the uploader
        updateUIWorker = new BackgroundWorker();
        updateUIWorker.DoWork += new DoWorkEventHandler(_updateUIWork);
        updateUIWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_updateUIDone);
        if(!updateUIWorker.IsBusy)
        {
            updateUIWorker.RunWorkerAsync();
        }

        //Housekeeping functions for window
        this.DeleteEvent += OnDeleteEvent;

        //System.Console.WriteLine (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
        //System.Console.WriteLine (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
    }
Exemplo n.º 2
0
 protected void OnPreferencesActionActivated(object sender, System.EventArgs e)
 {
     //The preference window itself handles saving settings, so we just have to show it here.
     FDPreferences preferences = new FDPreferences(this, DialogFlags.Modal, UserSettings);
     preferences.Run ();
     preferences.Destroy();
 }