46
DeviceLauncherIcon::DeviceLauncherIcon(Launcher* launcher, GVolume* volume)
47
: SimpleLauncherIcon(launcher)
46
DeviceLauncherIcon::DeviceLauncherIcon(GVolume* volume)
47
: SimpleLauncherIcon()
49
49
, device_file_(g_volume_get_identifier(volume_, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE))
50
50
, gdu_device_(get_device_for_device_file(device_file_))
52
52
DevicesSettings::GetDefault().changed.connect(sigc::mem_fun(this, &DeviceLauncherIcon::OnSettingsChanged));
54
54
// Checks if in favourites!
71
71
tooltip_text = name.Str();
72
72
icon_name = icon_string.Str();
74
74
SetIconType(TYPE_DEVICE);
75
75
SetQuirk(QUIRK_RUNNING, false);
81
81
return g_volume_can_eject(volume_);
84
nux::Color DeviceLauncherIcon::BackgroundColor()
86
return nux::Color(0xFF333333);
89
nux::Color DeviceLauncherIcon::GlowColor()
91
return nux::Color(0xFF333333);
94
84
std::list<DbusmenuMenuitem*> DeviceLauncherIcon::GetMenus()
96
86
std::list<DbusmenuMenuitem*> result;
97
87
DbusmenuMenuitem* menu_item;
98
88
glib::Object<GDrive> drive(g_volume_get_drive(volume_));
100
// "Lock to launcher"/"Unlock from launcher" item
90
// "Lock to Launcher"/"Unlock from Launcher" item
101
91
if (DevicesSettings::GetDefault().GetDevicesOption() == DevicesSettings::ONLY_MOUNTED
102
92
&& drive && !g_drive_is_media_removable (drive))
104
94
menu_item = dbusmenu_menuitem_new();
106
dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, !keep_in_launcher_ ? _("Lock to launcher") : _("Unlock from launcher"));
96
dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, !keep_in_launcher_ ? _("Lock to Launcher") : _("Unlock from Launcher"));
107
97
dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
108
98
dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
110
100
g_signal_connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
111
101
G_CALLBACK(&DeviceLauncherIcon::OnTogglePin), this);
113
103
result.push_back(menu_item);
117
107
menu_item = dbusmenu_menuitem_new();
123
113
g_signal_connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
124
114
G_CALLBACK(&DeviceLauncherIcon::OnOpen), this);
126
116
result.push_back(menu_item);
129
119
if (gdu_device_ && !gdu_device_is_optical_disc(gdu_device_))
131
121
menu_item = dbusmenu_menuitem_new();
123
// TRANSLATORS: This refers to the action of formatting a device
133
124
dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Format..."));
134
125
dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
135
126
dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
137
128
g_signal_connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
138
129
G_CALLBACK(&DeviceLauncherIcon::OnFormat), this);
140
131
result.push_back(menu_item);
144
135
if (drive && g_drive_can_eject(drive))
146
137
menu_item = dbusmenu_menuitem_new();
148
139
GList *list = g_drive_get_volumes(drive);
149
140
if (list != NULL)
152
143
dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Eject"));
154
145
dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Eject parent drive"));
156
147
g_list_free_full(list, g_object_unref);
159
150
dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
160
151
dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
177
168
dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Safely remove"));
179
170
dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Safely remove parent drive"));
181
172
g_list_free_full(list, g_object_unref);
187
178
g_signal_connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
188
179
G_CALLBACK(&DeviceLauncherIcon::OnDriveStop), this);
190
181
result.push_back(menu_item);
253
244
SimpleLauncherIcon::ActivateLauncherIcon(arg);
254
245
SetQuirk(QUIRK_STARTING, true);
256
247
glib::Object<GMount> mount(g_volume_get_mount(volume_));
258
249
if (G_IS_MOUNT(mount.RawPtr()))
292
283
DeviceLauncherIcon* self)
294
285
if (g_volume_eject_with_operation_finish(self->volume_, result, NULL))
296
287
IconLoader::GetDefault().LoadFromGIconString(self->icon_name(), 48,
297
288
sigc::mem_fun(self, &DeviceLauncherIcon::ShowNotification));
301
void DeviceLauncherIcon::ShowNotification(std::string const& icon_name,
292
void DeviceLauncherIcon::ShowNotification(std::string const& icon_name,
303
294
GdkPixbuf* pixbuf)
306
297
glib::String name(g_volume_get_name(volume_));
307
298
glib::Object<NotifyNotification> notification(notify_notification_new(name,
308
299
_("The drive has been successfully ejected"),
311
302
notify_notification_set_hint(notification,
312
303
"x-canonical-private-synchronous",
313
304
g_variant_new_boolean(TRUE));
315
306
if(GDK_IS_PIXBUF(pixbuf))
316
307
notify_notification_set_image_from_pixbuf(notification, pixbuf);
318
309
notify_notification_show(notification, NULL);
335
326
DeviceLauncherIcon* self)
337
328
glib::String uuid(g_volume_get_identifier(self->volume_, G_VOLUME_IDENTIFIER_KIND_UUID));
339
330
self->keep_in_launcher_ = !self->keep_in_launcher_;
341
332
if (!self->keep_in_launcher_)
369
360
DeviceLauncherIcon* self)
371
362
glib::Error error;
373
364
gchar const* args[] = { "/usr/lib/gnome-disk-utility/gdu-format-tool",
375
366
self->device_file_.Value(),
378
369
g_spawn_async(NULL, // working dir
379
370
const_cast<gchar **>(args),
469
460
else if (visibility < 0)
471
462
glib::Object<GMount> mount(g_volume_get_mount(volume_));
472
SetQuirk(QUIRK_VISIBLE, mount.RawPtr() != NULL);
463
SetQuirk(QUIRK_VISIBLE, mount.RawPtr() != NULL);
476
SetQuirk(QUIRK_VISIBLE, visibility);
467
SetQuirk(QUIRK_VISIBLE, visibility);
479
470
case DevicesSettings::ALWAYS: