diff options
| author | Andrea Azzarone <azzaronea@gmail.com> | 2012-07-18 18:06:32 +0200 |
|---|---|---|
| committer | Andrea Azzarone <azzaronea@gmail.com> | 2012-07-18 18:06:32 +0200 |
| commit | d5f94ca359f3c423de530351ffa4e4a1e762865d (patch) | |
| tree | 9f24b1abdea8858774196c2fb6d2716d18f836f8 | |
| parent | a7a3754b6d2f4b2fcd9ad696125cf9e596255a67 (diff) | |
Minor changes.
(bzr r2507.1.5)
| -rw-r--r-- | launcher/DeviceLauncherIcon.h | 3 | ||||
| -rw-r--r-- | launcher/DeviceLauncherSection.cpp | 9 | ||||
| -rw-r--r-- | launcher/DeviceLauncherSection.h | 2 | ||||
| -rw-r--r-- | launcher/VolumeMonitorWrapper.cpp | 10 | ||||
| -rw-r--r-- | launcher/VolumeMonitorWrapper.h | 7 |
5 files changed, 18 insertions, 13 deletions
diff --git a/launcher/DeviceLauncherIcon.h b/launcher/DeviceLauncherIcon.h index 3758c4d41..16f7fe794 100644 --- a/launcher/DeviceLauncherIcon.h +++ b/launcher/DeviceLauncherIcon.h @@ -33,8 +33,9 @@ namespace launcher class DeviceLauncherIcon : public SimpleLauncherIcon { - public: + typedef nux::ObjectPtr<DeviceLauncherIcon> Ptr; + DeviceLauncherIcon(glib::Object<GVolume> const& volume); void OnRemoved(); diff --git a/launcher/DeviceLauncherSection.cpp b/launcher/DeviceLauncherSection.cpp index 3cbad6c17..93fcd8a12 100644 --- a/launcher/DeviceLauncherSection.cpp +++ b/launcher/DeviceLauncherSection.cpp @@ -44,10 +44,10 @@ void DeviceLauncherSection::PopulateEntries() if (map_.find(volume) != map_.end()) continue; - DeviceLauncherIcon* icon = new DeviceLauncherIcon(volume); + DeviceLauncherIcon::Ptr icon(new DeviceLauncherIcon(volume)); map_[volume] = icon; - IconAdded.emit(AbstractLauncherIcon::Ptr(icon)); + IconAdded.emit(icon); } } @@ -61,9 +61,10 @@ void DeviceLauncherSection::OnVolumeAdded(glib::Object<GVolume> const& volume) if (map_.find(volume) != map_.end()) return; - DeviceLauncherIcon* icon = new DeviceLauncherIcon(volume); + DeviceLauncherIcon::Ptr icon(new DeviceLauncherIcon(volume)); + map_[volume] = icon; - IconAdded.emit(AbstractLauncherIcon::Ptr(icon)); + IconAdded.emit(icon); } void DeviceLauncherSection::OnVolumeRemoved(glib::Object<GVolume> const& volume) diff --git a/launcher/DeviceLauncherSection.h b/launcher/DeviceLauncherSection.h index 45d923bac..95661b2a3 100644 --- a/launcher/DeviceLauncherSection.h +++ b/launcher/DeviceLauncherSection.h @@ -44,7 +44,7 @@ private: void OnVolumeAdded(glib::Object<GVolume> const& volume); void OnVolumeRemoved(glib::Object<GVolume> const& volume); - std::map<GVolume*, DeviceLauncherIcon*> map_; + std::map<GVolume*, DeviceLauncherIcon::Ptr> map_; VolumeMonitorWrapper::Ptr monitor_; glib::Idle device_populate_idle_; }; diff --git a/launcher/VolumeMonitorWrapper.cpp b/launcher/VolumeMonitorWrapper.cpp index d8b6024aa..8c1e8f747 100644 --- a/launcher/VolumeMonitorWrapper.cpp +++ b/launcher/VolumeMonitorWrapper.cpp @@ -31,12 +31,12 @@ VolumeMonitorWrapper::VolumeMonitorWrapper() sig_manager_.Add(new VolumeSignal(monitor_, "volume-removed", sigc::mem_fun(this, &VolumeMonitorWrapper::OnVolumeRemoved))); } -std::list<glib::Object<GVolume>> VolumeMonitorWrapper::GetVolumes() +VolumeMonitorWrapper::VolumeList VolumeMonitorWrapper::GetVolumes() { - std::list<glib::Object<GVolume>> ret; - GList* volumes = g_volume_monitor_get_volumes(monitor_); + VolumeList ret; + auto volumes = std::shared_ptr<GList>(g_volume_monitor_get_volumes(monitor_), g_list_free); - for (GList* v = volumes; v; v = v->next) + for (GList* v = volumes.get(); v; v = v->next) { if (!G_IS_VOLUME(v->data)) continue; @@ -47,8 +47,6 @@ std::list<glib::Object<GVolume>> VolumeMonitorWrapper::GetVolumes() ret.push_back(volume); } - g_list_free(volumes); - return ret; } diff --git a/launcher/VolumeMonitorWrapper.h b/launcher/VolumeMonitorWrapper.h index 9ca205e51..02835efc5 100644 --- a/launcher/VolumeMonitorWrapper.h +++ b/launcher/VolumeMonitorWrapper.h @@ -38,10 +38,15 @@ class VolumeMonitorWrapper : public sigc::trackable { public: typedef std::shared_ptr<VolumeMonitorWrapper> Ptr; + typedef std::list<glib::Object<GVolume>> VolumeList; VolumeMonitorWrapper(); - std::list<glib::Object<GVolume>> GetVolumes(); + // Makes VolumeMonitorWrapper uncopyable + VolumeMonitorWrapper(VolumeMonitorWrapper const&) = delete; + VolumeMonitorWrapper& operator=(VolumeMonitorWrapper const&) = delete; + + VolumeList GetVolumes(); // Signals sigc::signal<void, glib::Object<GVolume> const&> volume_added; |
