Back to index

unity  6.0.0
DeviceLauncherIcon.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00018  */
00019 
00020 #ifndef _DEVICE_LAUNCHER_ICON_H__H
00021 #define _DEVICE_LAUNCHER_ICON_H__H
00022 
00023 #include <gio/gio.h>
00024 #include <UnityCore/GLibWrapper.h>
00025 #include <UnityCore/GLibSignal.h>
00026 
00027 #include "SimpleLauncherIcon.h"
00028 
00029 namespace unity
00030 {
00031 namespace launcher
00032 {
00033 
00034 class DeviceLauncherIcon : public SimpleLauncherIcon
00035 {
00036 
00037 public:
00038   DeviceLauncherIcon(glib::Object<GVolume> const& volume);
00039 
00040   void OnRemoved();
00041   bool CanEject();
00042   void Eject();
00043 
00044 protected:
00045   std::list<DbusmenuMenuitem*> GetMenus();
00046   std::string GetName() const;
00047 
00048 private:
00049   void UpdateVisibility();
00050   void UpdateDeviceIcon();
00051   void ActivateLauncherIcon(ActionArg arg);
00052   void ShowMount(GMount* mount);
00053   void Unmount();
00054   void StopDrive();
00055   static void OnTogglePin(DbusmenuMenuitem* item, int time, DeviceLauncherIcon* self);
00056   static void OnOpen(DbusmenuMenuitem* item, int time, DeviceLauncherIcon* self);
00057   static void OnEject(DbusmenuMenuitem* item, int time, DeviceLauncherIcon* self);
00058   static void OnUnmount(DbusmenuMenuitem* item, int time, DeviceLauncherIcon* self);
00059   static void OnChanged(GVolume* volume, DeviceLauncherIcon* self);
00060   static void OnMountReady(GObject* object, GAsyncResult* result, DeviceLauncherIcon* self);
00061   static void OnEjectReady(GObject* object, GAsyncResult* result, DeviceLauncherIcon* self);
00062   static void OnUnmountReady(GObject* object, GAsyncResult* result, DeviceLauncherIcon* self);
00063   static void OnDriveStop(DbusmenuMenuitem* item, int time, DeviceLauncherIcon* self);
00064   void OnVolumeChanged(GVolume* volume);
00065   void OnSettingsChanged();
00066   void ShowNotification(std::string const&, unsigned, glib::Object<GdkPixbuf> const&, std::string const&);
00067 
00068 private:
00069   glib::Signal<void, GVolume*> signal_volume_changed_;
00070   glib::Source::UniquePtr changed_timeout_;
00071   glib::Object<GVolume> volume_;
00072 
00073   std::string name_;
00074   bool keep_in_launcher_;
00075 };
00076 
00077 }
00078 } // namespace unity
00079 
00080 #endif // _DEVICE_LAUNCHER_ICON_H__H