~azzar1/unity/fix-crash-acc-controller

« back to all changes in this revision

Viewing changes to launcher/TrashLauncherIcon.cpp

  • Committer: Bileto Bot
  • Author(s): Andrea Azzarone
  • Date: 2016-07-14 10:04:45 UTC
  • mfrom: (4146.1.2 unity)
  • Revision ID: ci-train-bot@canonical.com-20160714100445-bfhzdf0qlz1a7ree
[TrashLauncherIcon] Create GFileMonitor in an idle to avoid blocking calls. (LP: #1602720)

Approved by: Marco Trevisan (Treviño)

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
  SkipQuirkAnimation(Quirk::VISIBLE);
56
56
  SetShortcut('t');
57
57
 
58
 
  glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str()));
59
 
 
60
 
  glib::Error err;
61
 
  trash_monitor_ = g_file_monitor_directory(location, G_FILE_MONITOR_NONE, cancellable_, &err);
62
 
  g_file_monitor_set_rate_limit(trash_monitor_, 1000);
63
 
 
64
 
  if (err)
65
 
  {
66
 
    LOG_ERROR(logger) << "Could not create file monitor for trash uri: " << err;
67
 
  }
68
 
  else
69
 
  {
70
 
    glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed",
71
 
    [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) {
72
 
      UpdateTrashIcon();
73
 
    });
74
 
  }
 
58
  _source_manager.AddIdle([this]{
 
59
    glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str()));
 
60
 
 
61
    glib::Error err;
 
62
    trash_monitor_ = g_file_monitor_directory(location, G_FILE_MONITOR_NONE, cancellable_, &err);
 
63
    g_file_monitor_set_rate_limit(trash_monitor_, 1000);
 
64
 
 
65
    if (err)
 
66
    {
 
67
      LOG_ERROR(logger) << "Could not create file monitor for trash uri: " << err;
 
68
    }
 
69
    else
 
70
    {
 
71
      glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed",
 
72
      [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) {
 
73
        UpdateTrashIcon();
 
74
      });
 
75
    }
 
76
 
 
77
    return false;
 
78
  });
75
79
 
76
80
  UpdateTrashIcon();
77
81
  UpdateStorageWindows();