~deja-dup-hackers/deja-dup/22

« back to all changes in this revision

Viewing changes to deja-dup/AssistantOperation.vala

  • Committer: Michael Terry
  • Date: 2012-01-09 13:36:21 UTC
  • mfrom: (1265.1.3 read-error)
  • Revision ID: michael.terry@canonical.com-20120109133621-9fc30d8ld8cqxths
warn user if we fail to back up a file

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
  protected Gtk.Widget progress_page {get; private set;}
69
69
  
70
70
  protected Gtk.Label summary_label;
71
 
  Gtk.Widget error_widget;
72
 
  Gtk.TextView error_text_view;
 
71
  protected Gtk.Widget detail_widget;
 
72
  Gtk.TextView detail_text_view;
73
73
  protected Gtk.Widget summary_page {get; private set;}
74
74
  
75
75
  protected Gdk.Pixbuf op_icon {get; private set;}
266
266
 
267
267
    return page;
268
268
  }
269
 
  
 
269
 
 
270
  void show_detail(string detail)
 
271
  {
 
272
    page_box.set_size_request(300, 200);
 
273
    detail_widget.no_show_all = false;
 
274
    detail_widget.show_all();
 
275
    detail_text_view.buffer.set_text(detail, -1);
 
276
  }
 
277
 
270
278
  public virtual void show_error(string error, string? detail)
271
279
  {
272
280
    error_occurred = true;
273
281
    
274
282
    summary_label.label = error;
275
 
    summary_label.wrap = true;
276
283
    summary_label.selectable = true;
277
 
    summary_label.max_width_chars = 25;
278
284
    
279
 
    if (detail != null) {
280
 
      page_box.set_size_request(300, 200);
281
 
      error_widget.no_show_all = false;
282
 
      error_widget.show_all();
283
 
      error_text_view.buffer.set_text(detail, -1);
284
 
    }
 
285
    if (detail != null)
 
286
      show_detail(detail);
285
287
    
286
288
    go_to_page(summary_page);
287
289
    set_header_icon(Gtk.Stock.DIALOG_ERROR);
408
410
  {
409
411
    summary_label = new Gtk.Label("");
410
412
    summary_label.set("xalign", 0.0f);
 
413
    summary_label.wrap = true;
 
414
    summary_label.max_width_chars = 25;
411
415
    
412
 
    error_text_view = new Gtk.TextView();
413
 
    error_text_view.editable = false;
414
 
    error_text_view.wrap_mode = Gtk.WrapMode.WORD;
415
 
    error_text_view.height_request = 150;
 
416
    detail_text_view = new Gtk.TextView();
 
417
    detail_text_view.editable = false;
 
418
    detail_text_view.wrap_mode = Gtk.WrapMode.WORD;
 
419
    detail_text_view.height_request = 150;
416
420
 
417
421
    var scroll = new Gtk.ScrolledWindow(null, null);
418
 
    scroll.add(error_text_view);
 
422
    scroll.add(detail_text_view);
419
423
    scroll.no_show_all = true; // only will be shown if an error occurs
420
 
    error_widget = scroll;
 
424
    detail_widget = scroll;
421
425
    
422
426
    var page = new Gtk.Box(Gtk.Orientation.VERTICAL, 6);
423
427
    page.set("child", summary_label,
424
 
             "child", error_widget,
 
428
             "child", detail_widget,
425
429
             "border-width", 12);
426
430
    page.child_set(summary_label, "expand", false);
427
 
    page.child_set(error_widget, "expand", true);
 
431
    page.child_set(detail_widget, "expand", true);
428
432
    
429
433
    return page;
430
434
  }
472
476
    summary_page = page;
473
477
  }
474
478
  
475
 
  protected virtual void apply_finished(DejaDup.Operation op, bool success, bool cancelled)
 
479
  protected virtual void apply_finished(DejaDup.Operation op, bool success, bool cancelled, string? detail)
476
480
  {
477
481
    if (status_icon != null) {
478
 
      status_icon.done(success, cancelled);
 
482
      status_icon.done(success, cancelled, detail);
479
483
      status_icon = null;
480
484
    }
481
485
    this.op = null;
489
493
    else {
490
494
      if (success) {
491
495
        succeeded = true;
 
496
 
 
497
        if (detail != null) {
 
498
          // Expect one paragraph followed by a blank line.  The first paragraph
 
499
          // is an explanation before the full detail content.  So split it out
 
500
          // into a proper label to look nice.
 
501
          var halves = detail.split("\n\n", 2);
 
502
          if (halves.length == 1) // no full detail content
 
503
            summary_label.label = detail;
 
504
          else if (halves.length == 2) {
 
505
            summary_label.label = halves[0];
 
506
            show_detail(halves[1]);
 
507
          }
 
508
        }
 
509
 
492
510
        go_to_page(summary_page);
493
511
      }
494
512
      else // show error
579
597
  {
580
598
    hide();
581
599
    if (status_icon != null) {
582
 
      status_icon.done(false, true);
 
600
      status_icon.done(false, true, null);
583
601
      status_icon = null; // hide immediately to seem responsive
584
602
    }
585
603
  }