updated on Tue Jan 24 08:00:27 UTC 2012
[aur-mirror.git] / xfce4-places-plugin / 03_port-to-gio.patch
blobc3055d902ade5abc762c5d794657cd6dc5ba14e2
1 diff -Naur xfce4-places-plugin-1.2.0.orig/config.h.in xfce4-places-plugin-1.2.0/config.h.in
2 --- xfce4-places-plugin-1.2.0.orig/config.h.in 2009-07-31 08:21:07.000000000 +0200
3 +++ xfce4-places-plugin-1.2.0/config.h.in 2011-03-22 09:55:16.000000000 +0100
4 @@ -24,14 +24,17 @@
5 /* Define if the GNU gettext() function is already present or preinstalled. */
6 #undef HAVE_GETTEXT
8 +/* Define if gio-unix-2.0 >= 2.18.0 present */
9 +#undef HAVE_GIO_UNIX
11 /* Define to 1 if you have the <inttypes.h> header file. */
12 #undef HAVE_INTTYPES_H
14 /* Define if your <locale.h> file defines LC_MESSAGES. */
15 #undef HAVE_LC_MESSAGES
17 -/* Define if libxfce4panel-1.0 >= 4.5.92 present */
18 -#undef HAVE_LIBXFCE4PANEL_46
19 +/* Define if libnotify >= 0.4.0 present */
20 +#undef HAVE_LIBNOTIFY
22 /* Define to 1 if you have the <locale.h> header file. */
23 #undef HAVE_LOCALE_H
24 @@ -60,6 +63,12 @@
25 /* Define to 1 if you have the <unistd.h> header file. */
26 #undef HAVE_UNISTD_H
28 +/* Define to the sub-directory in which libtool stores uninstalled libraries. */
29 +#undef LT_OBJDIR
31 +/* Define to 1 if your C compiler doesn't accept -c and -o together. */
32 +#undef NO_MINUS_C_MINUS_O
34 /* Name of package */
35 #undef PACKAGE
37 @@ -75,6 +84,9 @@
38 /* Define to the one symbol short name of this package. */
39 #undef PACKAGE_TARNAME
41 +/* Define to the home page for this package. */
42 +#undef PACKAGE_URL
44 /* Define to the version of this package. */
45 #undef PACKAGE_VERSION
47 diff -Naur xfce4-places-plugin-1.2.0.orig/configure.in xfce4-places-plugin-1.2.0/configure.in
48 --- xfce4-places-plugin-1.2.0.orig/configure.in 2011-03-24 11:30:01.000000000 +0100
49 +++ xfce4-places-plugin-1.2.0/configure.in 2011-03-24 12:46:18.097893668 +0100
50 @@ -15,20 +15,29 @@
52 dnl check for basic programs
53 AC_PROG_CC()
54 +AM_PROG_CC_C_O
55 AC_PROG_INSTALL()
56 AC_PROG_LIBTOOL()
57 AC_PROG_INTLTOOL()
59 dnl check for required packages
60 -XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
61 -XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90.2])
62 +XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.22.0])
63 +XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.22.0])
64 +XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.22.0])
65 +XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.22.0])
66 +XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.22.0])
67 +XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0])
68 +XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.8.0])
69 XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.90.2])
70 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.90.2])
71 -XDT_CHECK_PACKAGE([THUNAR_VFS], [thunar-vfs-1], [0.3.2])
72 XDT_CHECK_PACKAGE([EXO], [exo-1], [0.5.0])
74 -dnl check for optional packages/versions
75 -XDT_CHECK_OPTIONAL_PACKAGE([LIBXFCE4PANEL_46], [libxfce4panel-1.0], [4.5.92], [libxfce4panel46], [Take advantage of Xfce 4.6 panel changes])
76 +XDT_CHECK_OPTIONAL_PACKAGE([GIO_UNIX], [gio-unix-2.0], [2.22.0], [gio-unix],
77 + [gio-unix, for special treatment of mount points on UNIX])
79 +dnl *** Optional support for libnotify ***
80 +XDT_CHECK_OPTIONAL_PACKAGE([LIBNOTIFY], [libnotify], [0.4.0], [notifications],
81 + [Mount notification support], [yes])
83 dnl check for i18n support
84 XDT_I18N([ar be ca cs da de dz el en_GB eo es et eu fi fr gl he hu id it ja ka ko lt lv mk nb nl pa pl pt_BR pt ro ru sq sv tr uk ur ur_PK zh_CN zh_TW])
85 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/Makefile.am xfce4-places-plugin-1.2.0/panel-plugin/Makefile.am
86 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/Makefile.am 2008-11-23 12:07:43.000000000 +0100
87 +++ xfce4-places-plugin-1.2.0/panel-plugin/Makefile.am 2011-03-24 18:21:18.505054556 +0100
88 @@ -6,11 +6,13 @@
90 xfce4_popup_places_CFLAGS = \
91 $(LIBX11_CFLAGS) \
92 + $(EXO_CFLAGS) \
93 $(GTK_CFLAGS)
95 xfce4_popup_places_LDADD = \
96 $(LIBX11_LDFLAGS) \
97 $(LIBX11_LIBS) \
98 + $(EXO_LIBS) \
99 $(GTK_LIBS)
102 @@ -20,7 +22,14 @@
103 plugin_PROGRAMS = \
104 xfce4-places-plugin
106 +#if HAVE_LIBNOTIFY
107 +xfce4_places_plugin_notify_sources = \
108 + model_volumes_notify.c \
109 + model_volumes_notify.h
110 +#endif
112 xfce4_places_plugin_SOURCES = \
113 + $(xfce4_places_plugin_notify_sources) \
114 places.c \
115 places.h \
116 support.c \
117 @@ -38,9 +47,7 @@
118 model_volumes.c \
119 model_volumes.h \
120 button.c \
121 - button.h \
122 - xfce46-compat.c \
123 - xfce46-compat.h
124 + button.h
128 @@ -48,18 +55,32 @@
129 -I$(top_builddir) \
130 -I$(top_srcdir) \
131 -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
132 + $(GIO_CFLAGS) \
133 + $(GIO_UNIX_CFLAGS) \
134 + $(GLIB_CFLAGS) \
135 + $(GTHREAD_CFLAGS) \
136 $(GTK_CFLAGS) \
137 + $(LIBNOTIFY_CFLAGS) \
138 + $(LIBX11_CFLAGS) \
139 $(LIBXFCE4UTIL_CFLAGS) \
140 $(LIBXFCEGUI4_CFLAGS) \
141 $(LIBXFCE4PANEL_CFLAGS) \
142 - $(THUNAR_VFS_CFLAGS) \
143 + $(EXO_CFLAGS) \
144 $(PLATFORM_CFLAGS)
146 xfce4_places_plugin_LDADD = \
147 + $(GIO_LIBS) \
148 + $(GIO_UNIX_LIBS) \
149 + $(GLIB_LIBS) \
150 + $(GTHREAD_LIBS) \
151 + $(GTK_LIBS) \
152 + $(LIBNOTIFY_LIBS) \
153 + $(LIBX11_LDFLAGS) \
154 + $(LIBX11_LIBS) \
155 $(LIBXFCE4UTIL_LIBS) \
156 $(LIBXFCEGUI4_LIBS) \
157 $(LIBXFCE4PANEL_LIBS) \
158 - @THUNAR_VFS_LIBS@
159 + $(EXO_LIBS)
163 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/Makefile.in xfce4-places-plugin-1.2.0/panel-plugin/Makefile.in
164 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/Makefile.in 2009-07-31 08:21:07.000000000 +0200
165 +++ xfce4-places-plugin-1.2.0/panel-plugin/Makefile.in 2011-03-24 18:25:56.366054338 +0100
166 @@ -57,8 +57,7 @@
167 xfce4_places_plugin-model_system.$(OBJEXT) \
168 xfce4_places_plugin-model_user.$(OBJEXT) \
169 xfce4_places_plugin-model_volumes.$(OBJEXT) \
170 - xfce4_places_plugin-button.$(OBJEXT) \
171 - xfce4_places_plugin-xfce46-compat.$(OBJEXT)
172 + xfce4_places_plugin-button.$(OBJEXT)
173 xfce4_places_plugin_OBJECTS = $(am_xfce4_places_plugin_OBJECTS)
174 am__DEPENDENCIES_1 =
175 xfce4_places_plugin_DEPENDENCIES = $(am__DEPENDENCIES_1) \
176 @@ -269,15 +268,25 @@
178 xfce4_popup_places_CFLAGS = \
179 $(LIBX11_CFLAGS) \
180 + $(EXO_CFLAGS) \
181 $(GTK_CFLAGS)
183 xfce4_popup_places_LDADD = \
184 $(LIBX11_LDFLAGS) \
185 $(LIBX11_LIBS) \
186 + $(EXO_LIBS) \
187 $(GTK_LIBS)
189 plugindir = $(libexecdir)/xfce4/panel-plugins
191 +#if HAVE_LIBNOTIFY
192 +xfce4_places_plugin_notify_sources = \
193 + model_volumes_notify.c \
194 + model_volumes_notify.h
195 +#endif
197 xfce4_places_plugin_SOURCES = \
198 + $(xfce4_places_plugin_notify_sources) \
199 places.c \
200 places.h \
201 support.c \
202 @@ -295,26 +304,38 @@
203 model_volumes.c \
204 model_volumes.h \
205 button.c \
206 - button.h \
207 - xfce46-compat.c \
208 - xfce46-compat.h
209 + button.h
211 xfce4_places_plugin_CFLAGS = \
212 -I$(top_builddir) \
213 -I$(top_srcdir) \
214 -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
215 + $(GIO_CFLAGS) \
216 + $(GIO_UNIX_CFLAGS) \
217 + $(GLIB_CFLAGS) \
218 + $(GTHREAD_CFLAGS) \
219 $(GTK_CFLAGS) \
220 + $(LIBNOTIFY_CFLAGS) \
221 + $(LIBX11_CFLAGS) \
222 $(LIBXFCE4UTIL_CFLAGS) \
223 $(LIBXFCEGUI4_CFLAGS) \
224 $(LIBXFCE4PANEL_CFLAGS) \
225 - $(THUNAR_VFS_CFLAGS) \
226 + $(EXO_CFLAGS) \
227 $(PLATFORM_CFLAGS)
229 xfce4_places_plugin_LDADD = \
230 + $(GIO_LIBS) \
231 + $(GIO_UNIX_LIBS) \
232 + $(GLIB_LIBS) \
233 + $(GTHREAD_LIBS) \
234 + $(GTK_LIBS) \
235 + $(LIBNOTIFY_LIBS) \
236 + $(LIBX11_LDFLAGS) \
237 + $(LIBX11_LIBS) \
238 $(LIBXFCE4UTIL_LIBS) \
239 $(LIBXFCEGUI4_LIBS) \
240 $(LIBXFCE4PANEL_LIBS) \
241 - @THUNAR_VFS_LIBS@
242 + $(EXO_LIBS)
246 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/model.h xfce4-places-plugin-1.2.0/panel-plugin/model.h
247 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/model.h 2008-01-09 02:20:42.000000000 +0100
248 +++ xfce4-places-plugin-1.2.0/panel-plugin/model.h 2011-03-24 18:06:48.743019371 +0100
249 @@ -23,6 +23,7 @@
250 #define _XFCE_PANEL_PLACES_MODEL_H
252 #include <glib.h>
253 +#include <gio/gio.h>
255 /* Places Bookmark Action */
256 typedef struct _PlacesBookmarkAction PlacesBookmarkAction;
257 @@ -59,7 +60,7 @@
258 gchar *label; /* must not be NULL */
259 gchar *uri; /* may be NULL */
260 places_uri_scheme uri_scheme;
261 - gchar *icon; /* may be NULL */
262 + GIcon *icon; /* may be NULL */
263 PlacesBookmarkAction *primary_action; /* may be NULL */
264 gboolean force_gray;
265 GList *actions; /* may be NULL (empty) */
266 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/model_system.c xfce4-places-plugin-1.2.0/panel-plugin/model_system.c
267 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/model_system.c 2009-05-24 07:23:15.000000000 +0200
268 +++ xfce4-places-plugin-1.2.0/panel-plugin/model_system.c 2011-03-22 11:11:25.000000000 +0100
269 @@ -30,13 +30,11 @@
270 #include <string.h>
272 #include <glib.h>
273 +#include <gio/gio.h>
275 #include <libxfce4util/libxfce4util.h>
277 -#define EXO_API_SUBJECT_TO_CHANGE
278 -#include <thunar-vfs/thunar-vfs.h>
280 -#define TRASH THUNAR_VFS_CHECK_VERSION(0,4,0)
281 +#define TRASH 1
282 #define XDG_USER_DIRS GLIB_CHECK_VERSION(2,14,0)
284 #define pbg_priv(pbg) ((PBSysData*) pbg->priv)
285 @@ -49,7 +47,7 @@
286 gchar *desktop_dir; /* NULL => no desktop or desktop is same as home */
287 #if TRASH
288 gboolean trash_is_empty;
289 - ThunarVfsPath *trash_path;
290 + GFile *trash_path;
291 #endif
293 } PBSysData;
294 @@ -60,7 +58,7 @@
295 g_assert(bookmark != NULL);
297 if(bookmark->uri != NULL){
298 - g_free(bookmark->uri);
299 + g_object_unref(bookmark->icon);
300 bookmark->uri = NULL;
303 @@ -80,15 +78,14 @@
305 #if TRASH
306 static gboolean
307 -pbsys_trash_is_empty(const ThunarVfsInfo *trash_info)
308 +pbsys_trash_is_empty(GFileInfo *trash_info)
310 - if (trash_info->custom_icon == NULL)
311 - return FALSE;
312 - if (strcmp("user-trash-full", trash_info->custom_icon) == 0)
313 - return FALSE;
314 - if (strcmp("gnome-fs-trash-full", trash_info->custom_icon) == 0)
315 + guint item_count = g_file_info_get_attribute_uint32(trash_info,
316 + G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT);
317 + if(item_count == 0)
318 + return TRUE;
319 + else
320 return FALSE;
321 - return TRUE;
323 #endif
325 @@ -130,7 +127,7 @@
326 PlacesBookmark *bookmark;
327 PlacesBookmarkAction *open, *terminal;
328 #if TRASH
329 - ThunarVfsInfo *trash_info;
330 + GFileInfo *trash_info;
331 #endif
332 const gchar *home_dir = xfce_get_homedir();
333 gchar *desktop_dir;
334 @@ -142,7 +139,7 @@
335 /* Home */
336 bookmark = places_bookmark_create((gchar*) g_get_user_name());
337 bookmark->uri = (gchar*) home_dir;
338 - bookmark->icon = "user-home";
339 + bookmark->icon = g_themed_icon_new("user-home");
341 terminal = places_create_open_terminal_action(bookmark);
342 bookmark->actions = g_list_prepend(bookmark->actions, terminal);
343 @@ -159,15 +156,20 @@
344 bookmark->uri_scheme = PLACES_URI_SCHEME_TRASH;
345 bookmark->finalize = pbsys_finalize_trash_bookmark;;
347 - /* Try for an icon from ThunarVFS to indicate whether trash is empty or not */
348 + /* Try for an icon to indicate whether trash is empty or not */
350 - trash_info = thunar_vfs_info_new_for_path(pbg_priv(bookmark_group)->trash_path, NULL);
351 + trash_info = g_file_query_info(pbg_priv(bookmark_group)->trash_path,
352 + "trash::*",
353 + G_FILE_QUERY_INFO_NONE,
354 + NULL, NULL);
355 pbg_priv(bookmark_group)->trash_is_empty = pbsys_trash_is_empty(trash_info);
356 - if(trash_info->custom_icon != NULL)
357 - bookmark->icon = g_strdup(trash_info->custom_icon);
358 + if (bookmark->icon != NULL)
359 + g_object_unref(bookmark->icon);
360 + if (pbg_priv(bookmark_group)->trash_is_empty)
361 + bookmark->icon = g_themed_icon_new("user-trash");
362 else
363 - bookmark->icon = g_strdup("user-trash-full");
364 - thunar_vfs_info_unref(trash_info);
365 + bookmark->icon = g_themed_icon_new("user-trash-full");
366 + g_object_unref(trash_info);
368 open = places_create_open_action(bookmark);
369 bookmark->actions = g_list_prepend(bookmark->actions, open);
370 @@ -185,7 +187,7 @@
371 if(desktop_dir != NULL){
372 bookmark = places_bookmark_create(_("Desktop"));
373 bookmark->uri = desktop_dir;
374 - bookmark->icon = "user-desktop";
375 + bookmark->icon = g_themed_icon_new("user-desktop");
376 bookmark->finalize = pbsys_finalize_desktop_bookmark;
379 @@ -201,7 +203,7 @@
380 /* File System (/) */
381 bookmark = places_bookmark_create(_("File System"));
382 bookmark->uri = "/";
383 - bookmark->icon = "gtk-harddisk";
384 + bookmark->icon = g_themed_icon_new("gtk-harddisk");
386 terminal = places_create_open_terminal_action(bookmark);
387 bookmark->actions = g_list_prepend(bookmark->actions, terminal);
388 @@ -220,7 +222,7 @@
389 gchar *desktop_dir;
390 #if TRASH
391 gboolean trash_is_empty;
392 - ThunarVfsInfo *trash_info;
393 + GFileInfo *trash_info;
394 #endif
396 if(!pbg_priv(bookmark_group)->check_changed)
397 @@ -236,9 +238,12 @@
399 #if TRASH
400 /* see if trash gets a different icon (e.g., was empty, now full) */
401 - trash_info = thunar_vfs_info_new_for_path(pbg_priv(bookmark_group)->trash_path, NULL);
402 + trash_info = g_file_query_info(pbg_priv(bookmark_group)->trash_path,
403 + "trash::*",
404 + G_FILE_QUERY_INFO_NONE,
405 + NULL, NULL);
406 trash_is_empty = pbsys_trash_is_empty(trash_info);
407 - thunar_vfs_info_unref(trash_info);
408 + g_object_unref(trash_info);
410 if(trash_is_empty != pbg_priv(bookmark_group)->trash_is_empty)
411 return TRUE;
412 @@ -251,8 +256,7 @@
413 pbsys_finalize(PlacesBookmarkGroup *bookmark_group)
415 #if TRASH
416 - thunar_vfs_path_unref(pbg_priv(bookmark_group)->trash_path);
417 - thunar_vfs_shutdown();
418 + g_object_unref(pbg_priv(bookmark_group)->trash_path);
419 #endif
421 g_free(pbg_priv(bookmark_group)->desktop_dir);
422 @@ -273,8 +277,7 @@
423 bookmark_group->priv = g_new0(PBSysData, 1);
425 #if TRASH
426 - thunar_vfs_init();
427 - pbg_priv(bookmark_group)->trash_path = thunar_vfs_path_get_for_trash();
428 + pbg_priv(bookmark_group)->trash_path = g_file_new_for_uri("trash:///");
429 #endif
431 return bookmark_group;
432 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/model_user.c xfce4-places-plugin-1.2.0/panel-plugin/model_user.c
433 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/model_user.c 2009-05-24 07:23:15.000000000 +0200
434 +++ xfce4-places-plugin-1.2.0/panel-plugin/model_user.c 2011-03-22 11:12:37.000000000 +0100
435 @@ -168,7 +168,7 @@
436 /* create the BookmarkInfo container */
437 bookmark = places_bookmark_create(name); /* label needs to be freed */
438 bookmark->uri = path; /* uri needs to be freed */
439 - bookmark->icon = "folder";
440 + bookmark->icon = g_themed_icon_new("folder");
441 bookmark->priv = GINT_TO_POINTER(pbuser_dir_exists(path));
442 bookmark->finalize = pbuser_finalize_bookmark;
444 @@ -213,7 +213,7 @@
445 clone = places_bookmark_create(g_strdup(orig->label));
446 clone->uri = g_strdup(orig->uri);
447 clone->uri_scheme = orig->uri_scheme;
448 - clone->icon = orig->icon;
449 + clone->icon = g_object_ref(orig->icon);
450 clone->finalize = pbuser_finalize_bookmark;
452 terminal = places_create_open_terminal_action(clone);
453 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/model_volumes.c xfce4-places-plugin-1.2.0/panel-plugin/model_volumes.c
454 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/model_volumes.c 2009-07-31 07:31:42.000000000 +0200
455 +++ xfce4-places-plugin-1.2.0/panel-plugin/model_volumes.c 2011-03-22 11:42:26.000000000 +0100
456 @@ -27,8 +27,15 @@
457 #include "model_volumes.h"
458 #include "support.h"
460 -#define EXO_API_SUBJECT_TO_CHANGE
461 -#include <thunar-vfs/thunar-vfs.h>
462 +#include <gio/gio.h>
463 +#ifdef HAVE_GIO_UNIX
464 +#include <gio/gunixmounts.h>
465 +#endif
466 +#include <gtk/gtk.h>
468 +#ifdef HAVE_LIBNOTIFY
469 +#include "model_volumes_notify.h"
470 +#endif
472 #include <libxfce4util/libxfce4util.h>
474 @@ -39,7 +46,7 @@
475 typedef struct
478 - ThunarVfsVolumeManager *volume_manager;
479 + GVolumeMonitor *volume_monitor;
480 gboolean changed;
481 gboolean mount_and_open_by_default;
483 @@ -47,67 +54,149 @@
486 /********** Actions Callbacks **********/
487 +static void
488 +pbvol_eject_finish(GObject *object,
489 + GAsyncResult *result,
490 + gpointer user_data)
492 + GVolume *volume = G_VOLUME(object);
493 + GError *error = NULL;
495 + g_return_if_fail(G_IS_VOLUME(object));
496 + g_return_if_fail(G_IS_ASYNC_RESULT(result));
498 + if (!g_volume_eject_with_operation_finish(volume, result, &error)) {
499 + /* ignore GIO errors handled internally */
500 + if(error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED) {
501 + gchar *volume_name = g_volume_get_name(volume);
502 + places_show_error_dialog(error,
503 + _("Failed to eject \"%s\""),
504 + volume_name);
505 + g_free(volume_name);
507 + g_error_free(error);
510 +#ifdef HAVE_LIBNOTIFY
511 + pbvol_notify_eject_finish(volume);
512 +#endif
515 static void
516 pbvol_eject(PlacesBookmarkAction *action)
518 - GError *error = NULL;
519 - ThunarVfsVolume *volume;
520 + GVolume *volume;
522 DBG("Eject");
524 - g_return_if_fail(THUNAR_VFS_IS_VOLUME(action->priv));
525 - volume = THUNAR_VFS_VOLUME(action->priv);
526 + g_return_if_fail(G_IS_VOLUME(action->priv));
527 + volume = G_VOLUME(action->priv);
529 - if(!thunar_vfs_volume_eject(volume, NULL, &error)){
530 - places_show_error_dialog(error,
531 - _("Failed to eject \"%s\""),
532 - thunar_vfs_volume_get_name (volume));
533 - g_error_free (error);
534 + if (g_volume_can_eject(volume)) {
535 +#ifdef HAVE_LIBNOTIFY
536 + pbvol_notify_eject(volume);
537 +#endif
538 + g_volume_eject_with_operation(volume, G_MOUNT_UNMOUNT_NONE, NULL,
539 + NULL,
540 + pbvol_eject_finish,
541 + g_object_ref(volume));
545 static void
546 -pbvol_unmount(PlacesBookmarkAction *action)
547 +pbvol_unmount_finish(GObject *object,
548 + GAsyncResult *result,
549 + gpointer user_data)
551 + GMount *mount = G_MOUNT(object);
552 GError *error = NULL;
553 - ThunarVfsVolume *volume;
555 + g_return_if_fail(G_IS_MOUNT(object));
556 + g_return_if_fail(G_IS_ASYNC_RESULT(result));
558 + if (!g_mount_unmount_with_operation_finish(mount, result, &error)) {
559 + /* ignore GIO errors handled internally */
560 + if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED) {
561 + gchar *mount_name = g_mount_get_name(mount);
562 + places_show_error_dialog(error,
563 + _("Failed to unmount \"%s\""),
564 + mount_name);
565 + g_free(mount_name);
567 + g_error_free (error);
570 +#ifdef HAVE_LIBNOTIFY
571 + pbvol_notify_unmount_finish(mount);
572 +#endif
575 +static void
576 +pbvol_unmount(PlacesBookmarkAction *action)
578 + GVolume *volume;
579 + GMount *mount;
581 DBG("Unmount");
583 - g_return_if_fail(THUNAR_VFS_IS_VOLUME(action->priv));
584 - volume = THUNAR_VFS_VOLUME(action->priv);
585 + g_return_if_fail(G_IS_VOLUME(action->priv));
586 + volume = G_VOLUME(action->priv);
587 + mount = g_volume_get_mount(volume);
589 + if (mount) {
590 +#ifdef HAVE_LIBNOTIFY
591 + pbvol_notify_unmount(mount);
592 +#endif
593 + g_mount_unmount_with_operation(mount, G_MOUNT_UNMOUNT_NONE, NULL,
594 + NULL,
595 + pbvol_unmount_finish,
596 + g_object_ref(volume));
600 +static void
601 +pbvol_mount_finish(GObject *object,
602 + GAsyncResult *result,
603 + gpointer user_data)
605 + GVolume *volume = G_VOLUME(object);
606 + GError *error = NULL;
608 - if(thunar_vfs_volume_is_mounted(volume)){
609 - if(!thunar_vfs_volume_unmount(volume, NULL, &error)){
610 + DBG("Mount finish");
612 - places_show_error_dialog(error,
613 - _("Failed to unmount \"%s\""),
614 - thunar_vfs_volume_get_name (volume));
615 - g_error_free (error);
617 + if (!g_volume_mount_finish(volume, result, &error)) {
618 + /* ignore GIO errors handled internally */
619 + if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED) {
620 + gchar *volume_name = g_volume_get_name(volume);
621 + places_show_error_dialog(error,
622 + _("Failed to mount \"%s\""),
623 + volume_name);
624 + g_free(volume_name);
626 + g_error_free (error);
630 static void
631 pbvol_mount(PlacesBookmarkAction *action)
633 - GError *error = NULL;
634 - ThunarVfsVolume *volume;
635 + GVolume *volume;
636 + GMount *mount;
638 DBG("Mount");
640 - g_return_if_fail(THUNAR_VFS_IS_VOLUME(action->priv));
641 - volume = THUNAR_VFS_VOLUME(action->priv);
642 + g_return_if_fail(G_IS_VOLUME(action->priv));
643 + volume = G_VOLUME(action->priv);
644 + mount = g_volume_get_mount(volume);
646 + if (!mount) {
647 + GMountOperation *operation = gtk_mount_operation_new(NULL);
649 + g_volume_mount(volume, G_MOUNT_MOUNT_NONE, operation, NULL,
650 + pbvol_mount_finish,
651 + g_object_ref(volume));
653 - if(!thunar_vfs_volume_is_mounted(volume)){
654 - if(!thunar_vfs_volume_mount(volume, NULL, &error)){
656 - places_show_error_dialog(error,
657 - _("Failed to mount \"%s\""),
658 - thunar_vfs_volume_get_name (volume));
659 - g_error_free (error);
661 + g_object_unref(operation);
665 @@ -115,33 +204,166 @@
666 pbvol_mount_and_open(PlacesBookmarkAction *action)
668 gchar *uri;
669 - ThunarVfsVolume *volume;
670 + GVolume *volume;
671 + GMount *mount;
673 DBG("Mount and open");
675 - g_return_if_fail(THUNAR_VFS_IS_VOLUME(action->priv));
676 - volume = THUNAR_VFS_VOLUME(action->priv);
677 + g_return_if_fail(G_IS_VOLUME(action->priv));
678 + volume = G_VOLUME(action->priv);
679 + mount = g_volume_get_mount(volume);
681 - if(!thunar_vfs_volume_is_mounted(volume))
682 + if (!mount)
683 pbvol_mount(action);
685 - if(thunar_vfs_volume_is_mounted(volume)){
686 - uri = thunar_vfs_path_dup_uri(thunar_vfs_volume_get_mount_point(volume));
687 + if (mount) {
688 + GFile *file = g_mount_get_root(mount);
689 + uri = g_file_get_uri(file);
690 places_load_file_browser(uri);
691 g_free(uri);
692 + g_object_unref(file);
693 + g_object_unref(mount);
697 +#ifdef HAVE_GIO_UNIX
698 +static gboolean
699 +pbvol_mount_is_internal (GMount *mount)
701 + const gchar *point_mount_path;
702 + gboolean is_internal = FALSE;
703 + GFile *root;
704 + GList *lp;
705 + GList *mount_points;
706 + gchar *mount_path;
708 + g_return_val_if_fail(G_IS_MOUNT(mount), FALSE);
710 + /* determine the mount path */
711 + root = g_mount_get_root(mount);
712 + mount_path = g_file_get_path(root);
713 + g_object_unref(root);
715 + /* assume non-internal if we cannot determine the path */
716 + if (!mount_path)
717 + return FALSE;
719 + if (g_unix_is_mount_path_system_internal(mount_path)) {
720 + /* mark as internal */
721 + is_internal = TRUE;
722 + } else {
723 + /* get a list of all mount points */
724 + mount_points = g_unix_mount_points_get(NULL);
726 + /* search for the mount point associated with the mount entry */
727 + for (lp = mount_points; !is_internal && lp != NULL; lp = lp->next) {
728 + point_mount_path = g_unix_mount_point_get_mount_path(lp->data);
730 + /* check if this is the mount point we are looking for */
731 + if (g_strcmp0(mount_path, point_mount_path) == 0) {
732 + /* mark as internal if the user cannot mount this device */
733 + if (!g_unix_mount_point_is_user_mountable(lp->data))
734 + is_internal = TRUE;
737 + /* free the mount point, we no longer need it */
738 + g_unix_mount_point_free(lp->data);
741 + /* free the mount point list */
742 + g_list_free(mount_points);
745 + g_free(mount_path);
748 + return is_internal;
750 +#endif
753 +gboolean
754 +pbvol_is_removable(GVolume *volume)
756 + gboolean can_eject = FALSE;
757 + gboolean can_mount = FALSE;
758 + gboolean can_unmount = FALSE;
759 + gboolean is_removable = FALSE;
760 + gboolean is_internal = FALSE;
761 + GDrive *drive;
762 + GMount *mount;
764 + g_return_val_if_fail(G_IS_VOLUME(volume), FALSE);
766 + /* check if the volume can be ejected */
767 + can_eject = g_volume_can_eject(volume);
769 + /* determine the drive for the volume */
770 + drive = g_volume_get_drive(volume);
771 + if (drive) {
772 + /* check if the drive media can be removed */
773 + is_removable = g_drive_is_media_removable(drive);
775 + /* release the drive */
776 + g_object_unref(drive);
778 + /* determine the mount for the volume (if it is mounted at all) */
779 + mount = g_volume_get_mount(volume);
780 + if (mount) {
781 +#ifdef HAVE_GIO_UNIX
782 + is_internal = pbvol_mount_is_internal (mount);
783 +#endif
785 + /* check if the volume can be unmounted */
786 + can_unmount = g_mount_can_unmount(mount);
788 + /* release the mount */
789 + g_object_unref(mount);
792 + /* determine whether the device can be mounted */
793 + can_mount = g_volume_can_mount(volume);
795 + return (!is_internal) && (can_eject || can_unmount || is_removable || can_mount);
798 +gboolean
799 +pbvol_is_present(GVolume *volume)
801 + gboolean has_media = FALSE;
802 + gboolean is_shadowed = FALSE;
803 + GDrive *drive;
804 + GMount *mount;
806 + g_return_val_if_fail(G_IS_VOLUME(volume), FALSE);
808 + drive = g_volume_get_drive (volume);
809 + if(drive) {
810 + has_media = g_drive_has_media(drive);
811 + g_object_unref(drive);
814 + mount = g_volume_get_mount(volume);
815 + if(mount) {
816 + is_shadowed = g_mount_is_shadowed(mount);
817 + g_object_unref(mount);
820 + return has_media && !is_shadowed;
823 static inline gboolean
824 -pbvol_show_volume(ThunarVfsVolume *volume){
826 - DBG("Volume: %s [mounted=%x removable=%x present=%x]", thunar_vfs_volume_get_name(volume),
827 - thunar_vfs_volume_is_mounted(volume),
828 - thunar_vfs_volume_is_removable(volume),
829 - thunar_vfs_volume_is_present(volume));
830 +pbvol_show_volume(GVolume *volume){
831 + GMount *mount = g_volume_get_mount(volume);
832 + DBG("Volume: %s [mounted=%x removable=%x present=%x]", g_volume_get_name(volume),
833 + mount,
834 + pbvol_is_removable(volume),
835 + pbvol_is_present(volume));
836 + if (mount)
837 + g_object_unref(mount);
839 - return thunar_vfs_volume_is_removable(volume) &&
840 - thunar_vfs_volume_is_present(volume);
841 + return pbvol_is_removable(volume) &&
842 + pbvol_is_present(volume);
845 static void
846 @@ -153,29 +375,23 @@
849 static void
850 -pbvol_volumes_added(ThunarVfsVolumeManager *volman, GList *volumes, PlacesBookmarkGroup *bookmark_group)
851 +pbvol_volume_added(GVolumeMonitor *monitor, GVolume *volume, PlacesBookmarkGroup *bookmark_group)
853 DBG("-");
855 pbg_priv(bookmark_group)->changed = TRUE;
856 - while(volumes != NULL){
857 - g_signal_connect_swapped(THUNAR_VFS_VOLUME(volumes->data), "changed",
858 - G_CALLBACK(pbvol_set_changed), bookmark_group);
859 - volumes = volumes->next;
861 + g_signal_connect_swapped(G_VOLUME(volume), "changed",
862 + G_CALLBACK(pbvol_set_changed), bookmark_group);
865 static void
866 -pbvol_volumes_removed(ThunarVfsVolumeManager *volman, GList *volumes, PlacesBookmarkGroup *bookmark_group)
867 +pbvol_volume_removed(GVolumeMonitor *monitor, GVolume *volume, PlacesBookmarkGroup *bookmark_group)
869 DBG("-");
871 pbg_priv(bookmark_group)->changed = TRUE;
872 - while(volumes != NULL){
873 - g_signal_handlers_disconnect_by_func(THUNAR_VFS_VOLUME(volumes->data),
874 - G_CALLBACK(pbvol_set_changed), bookmark_group);
875 - volumes = volumes->next;
877 + g_signal_handlers_disconnect_by_func(G_VOLUME(volume),
878 + G_CALLBACK(pbvol_set_changed), bookmark_group);
881 static void
882 @@ -191,7 +407,7 @@
883 pbvol_bookmark_action_finalize(PlacesBookmarkAction *action){
884 g_assert(action != NULL && action->priv != NULL);
886 - ThunarVfsVolume *volume = THUNAR_VFS_VOLUME(action->priv);
887 + GVolume *volume = G_VOLUME(action->priv);
888 g_object_unref(volume);
889 action->priv = NULL;
891 @@ -203,24 +419,28 @@
892 PlacesBookmark *bookmark;
893 PlacesBookmarkAction *action, *terminal, *open;
894 const GList *volumes;
895 - ThunarVfsVolume *volume;
896 - GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
898 - volumes = thunar_vfs_volume_manager_get_volumes(pbg_priv(bookmark_group)->volume_manager);
899 - while(volumes != NULL){
900 - volume = THUNAR_VFS_VOLUME(volumes->data);
901 + GVolume *volume;
902 + GMount *mount;
903 + GIcon *icon;
905 + volumes = g_volume_monitor_get_volumes(pbg_priv(bookmark_group)->volume_monitor);
906 + while (volumes != NULL) {
907 + volume = volumes->data;
908 + mount = g_volume_get_mount(volume);
910 if(pbvol_show_volume(volume)){
912 - bookmark = places_bookmark_create((gchar*) thunar_vfs_volume_get_name(volume));
913 - if(thunar_vfs_volume_is_mounted(volume))
914 - bookmark->uri = thunar_vfs_path_dup_uri(thunar_vfs_volume_get_mount_point(volume));
915 - else
916 + bookmark = places_bookmark_create((gchar*) g_volume_get_name(volume));
917 + if (mount) {
918 + GFile *file = g_mount_get_root(mount);
919 + bookmark->uri = g_file_get_uri(file);
920 + g_object_unref(file);
921 + } else
922 bookmark->uri = NULL;
923 - bookmark->icon = (gchar*) thunar_vfs_volume_lookup_icon_name(volume, icon_theme);
924 + bookmark->icon = g_volume_get_icon(volume);
925 bookmark->finalize = pbvol_bookmark_finalize;
927 - if(!thunar_vfs_volume_is_mounted(volume)){
928 + if (!mount) {
930 g_object_ref(volume);
931 action = places_bookmark_action_create(_("Mount and Open"));
932 @@ -253,7 +473,7 @@
936 - if(thunar_vfs_volume_is_ejectable(volume)){
937 + if (g_volume_can_eject(volume)) {
939 g_object_ref(volume);
940 action = places_bookmark_action_create(_("Eject"));
941 @@ -263,18 +483,15 @@
942 action->finalize = pbvol_bookmark_action_finalize;
943 bookmark->actions = g_list_append(bookmark->actions, action);
945 - }else{
946 - if(thunar_vfs_volume_is_mounted(volume)){
948 - g_object_ref(volume);
949 - action = places_bookmark_action_create(_("Unmount"));
950 - action->may_block = TRUE;
951 - action->priv = volume;
952 - action->action = pbvol_unmount;
953 - action->finalize = pbvol_bookmark_action_finalize;
954 - bookmark->actions = g_list_append(bookmark->actions, action);
958 + if (mount) {
959 + g_object_ref(volume);
960 + action = places_bookmark_action_create(_("Unmount"));
961 + action->may_block = TRUE;
962 + action->priv = volume;
963 + action->action = pbvol_unmount;
964 + action->finalize = pbvol_bookmark_action_finalize;
965 + bookmark->actions = g_list_append(bookmark->actions, action);
968 bookmarks = g_list_prepend(bookmarks, bookmark);
969 @@ -300,22 +517,21 @@
971 const GList *volumes;
973 - volumes = thunar_vfs_volume_manager_get_volumes(pbg_priv(bookmark_group)->volume_manager);
974 + volumes = g_volume_monitor_get_volumes(pbg_priv(bookmark_group)->volume_monitor);
975 while(volumes != NULL){
976 - g_signal_handlers_disconnect_by_func(THUNAR_VFS_VOLUME(volumes->data),
977 + g_signal_handlers_disconnect_by_func(G_VOLUME(volumes->data),
978 G_CALLBACK(pbvol_set_changed), bookmark_group);
979 volumes = volumes->next;
982 - g_signal_handlers_disconnect_by_func(pbg_priv(bookmark_group)->volume_manager,
983 - G_CALLBACK(pbvol_volumes_added), bookmark_group);
984 - g_signal_handlers_disconnect_by_func(pbg_priv(bookmark_group)->volume_manager,
985 - G_CALLBACK(pbvol_volumes_removed), bookmark_group);
987 - g_object_unref(pbg_priv(bookmark_group)->volume_manager);
988 - pbg_priv(bookmark_group)->volume_manager = NULL;
989 - thunar_vfs_shutdown();
991 + g_signal_handlers_disconnect_by_func(pbg_priv(bookmark_group)->volume_monitor,
992 + G_CALLBACK(pbvol_volume_added), bookmark_group);
993 + g_signal_handlers_disconnect_by_func(pbg_priv(bookmark_group)->volume_monitor,
994 + G_CALLBACK(pbvol_volume_removed), bookmark_group);
996 + g_object_unref(pbg_priv(bookmark_group)->volume_monitor);
997 + pbg_priv(bookmark_group)->volume_monitor = NULL;
999 g_free(pbg_priv(bookmark_group));
1000 bookmark_group->priv = NULL;
1002 @@ -323,7 +539,7 @@
1003 PlacesBookmarkGroup*
1004 places_bookmarks_volumes_create(gboolean mount_and_open_by_default)
1006 - const GList *volumes;
1007 + GList *volumes;
1008 PlacesBookmarkGroup *bookmark_group;
1010 bookmark_group = places_bookmark_group_create();
1011 @@ -331,24 +547,25 @@
1012 bookmark_group->changed = pbvol_changed;
1013 bookmark_group->finalize = pbvol_finalize;
1014 bookmark_group->priv = g_new0(PBVolData, 1);
1016 - thunar_vfs_init();
1017 - pbg_priv(bookmark_group)->volume_manager = thunar_vfs_volume_manager_get_default();
1019 + pbg_priv(bookmark_group)->volume_monitor = g_volume_monitor_get();
1020 pbg_priv(bookmark_group)->changed = TRUE;
1021 pbg_priv(bookmark_group)->mount_and_open_by_default = mount_and_open_by_default;
1023 - volumes = thunar_vfs_volume_manager_get_volumes(pbg_priv(bookmark_group)->volume_manager);
1024 - while(volumes != NULL){
1025 - g_signal_connect_swapped(THUNAR_VFS_VOLUME(volumes->data), "changed",
1027 + volumes = g_volume_monitor_get_volumes(pbg_priv(bookmark_group)->volume_monitor);
1028 + while(volumes != NULL) {
1029 + g_signal_connect_swapped(G_OBJECT(volumes->data), "changed",
1030 G_CALLBACK(pbvol_set_changed), bookmark_group);
1031 + g_object_unref(volumes->data);
1032 volumes = volumes->next;
1034 + g_list_free(volumes);
1036 - g_signal_connect(pbg_priv(bookmark_group)->volume_manager, "volumes-added",
1037 - G_CALLBACK(pbvol_volumes_added), bookmark_group);
1038 + g_signal_connect(pbg_priv(bookmark_group)->volume_monitor, "volume-added",
1039 + G_CALLBACK(pbvol_volume_added), bookmark_group);
1041 - g_signal_connect(pbg_priv(bookmark_group)->volume_manager, "volumes-removed",
1042 - G_CALLBACK(pbvol_volumes_removed), bookmark_group);
1043 + g_signal_connect(pbg_priv(bookmark_group)->volume_monitor, "volume-removed",
1044 + G_CALLBACK(pbvol_volume_removed), bookmark_group);
1046 return bookmark_group;
1048 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/model_volumes_notify.c xfce4-places-plugin-1.2.0/panel-plugin/model_volumes_notify.c
1049 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/model_volumes_notify.c 1970-01-01 01:00:00.000000000 +0100
1050 +++ xfce4-places-plugin-1.2.0/panel-plugin/model_volumes_notify.c 2011-03-22 11:48:32.000000000 +0100
1051 @@ -0,0 +1,317 @@
1052 +/* vi:set et ai sw=2 sts=2 ts=2: */
1053 +/*-
1054 + * Copyright (c) 2010 Jannis Pohlmann <jannis@xfce.org>
1056 + * This program is free software; you can redistribute it and/or
1057 + * modify it under the terms of the GNU General Public License as
1058 + * published by the Free Software Foundation; either version 2 of
1059 + * the License, or (at your option) any later version.
1061 + * This program is distributed in the hope that it will be useful,
1062 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1063 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1064 + * GNU General Public License for more details.
1066 + * You should have received a copy of the GNU General Public
1067 + * License along with this program; if not, write to the Free
1068 + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
1069 + * Boston, MA 02110-1301, USA.
1071 + * NOTE: THIS FILE WAS COPIED FROM THUNAR. FUNCTION PREFIXES WERE
1072 + * ALIGNED TO PLACES PLUGIN AND A FEW TRANSLATOR HINTS WERE ADDED.
1073 + */
1075 +#ifdef HAVE_CONFIG_H
1076 +#include <config.h>
1077 +#endif
1079 +#include <glib.h>
1080 +#include <gio/gio.h>
1082 +#include <libnotify/notify.h>
1084 +#include <libxfce4util/libxfce4util.h>
1086 +#include "model_volumes_notify.h"
1090 +static gboolean pbvol_notify_initted = FALSE;
1094 +static gboolean
1095 +pbvol_notify_init (void)
1097 + gchar *spec_version = NULL;
1099 + if (!pbvol_notify_initted
1100 + && notify_init (PACKAGE_NAME))
1102 + /* we do this to work around bugs in libnotify < 0.6.0. Older
1103 + * versions crash in notify_uninit() when no notifications are
1104 + * displayed before. These versions also segfault when the
1105 + * ret_spec_version parameter of notify_get_server_info is
1106 + * NULL... */
1107 + notify_get_server_info (NULL, NULL, NULL, &spec_version);
1108 + g_free (spec_version);
1110 + pbvol_notify_initted = TRUE;
1113 + return pbvol_notify_initted;
1118 +void
1119 +pbvol_notify_unmount (GMount *mount)
1121 + const gchar * const *icon_names;
1122 + NotifyNotification *notification = NULL;
1123 + const gchar *summary;
1124 + GFileInfo *info;
1125 + gboolean read_only = FALSE;
1126 + GFile *icon_file;
1127 + GFile *mount_point;
1128 + GIcon *icon;
1129 + gchar *icon_name = NULL;
1130 + gchar *message;
1131 + gchar *name;
1133 + g_return_if_fail (G_IS_MOUNT (mount));
1135 + if (!pbvol_notify_init ())
1136 + return;
1138 + mount_point = g_mount_get_root (mount);
1140 + info = g_file_query_info (mount_point, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
1141 + G_FILE_QUERY_INFO_NONE, NULL, NULL);
1143 + if (info != NULL)
1145 + read_only = !g_file_info_get_attribute_boolean (info,
1146 + G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
1148 + g_object_unref (info);
1151 + g_object_unref (mount_point);
1153 + name = g_mount_get_name (mount);
1155 + icon = g_mount_get_icon (mount);
1156 + if (G_IS_THEMED_ICON (icon))
1158 + icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon));
1159 + if (icon_names != NULL)
1160 + icon_name = g_strdup (icon_names[0]);
1162 + else if (G_IS_FILE_ICON (icon))
1164 + icon_file = g_file_icon_get_file (G_FILE_ICON (icon));
1165 + if (icon_file != NULL)
1167 + icon_name = g_file_get_path (icon_file);
1168 + g_object_unref (icon_file);
1171 + g_object_unref (icon);
1173 + if (icon_name == NULL)
1174 + icon_name = g_strdup ("drive-removable-media");
1176 + if (read_only)
1178 + /* TRANSLATORS: Please use the same translation here as in Thunar */
1179 + summary = _("Unmounting device");
1181 + /* TRANSLATORS: Please use the same translation here as in Thunar */
1182 + message = g_strdup_printf (_("The device \"%s\" is being unmounted by the system. "
1183 + "Please do not remove the media or disconnect the "
1184 + "drive"), name);
1186 + else
1188 + /* TRANSLATORS: Please use the same translation here as in Thunar */
1189 + summary = _("Writing data to device");
1191 + /* TRANSLATORS: Please use the same translation here as in Thunar */
1192 + message = g_strdup_printf (_("There is data that needs to be written to the "
1193 + "device \"%s\" before it can be removed. Please "
1194 + "do not remove the media or disconnect the drive"),
1195 + name);
1198 +#ifdef NOTIFY_CHECK_VERSION
1199 +#if NOTIFY_CHECK_VERSION (0, 7, 0)
1200 + notification = notify_notification_new (summary, message, icon_name);
1201 +#else
1202 + notification = notify_notification_new (summary, message, icon_name, NULL);
1203 +#endif
1204 +#else
1205 + notification = notify_notification_new (summary, message, icon_name, NULL);
1206 +#endif
1207 + notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL);
1208 + notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
1209 + notify_notification_show (notification, NULL);
1211 + g_object_set_data_full (G_OBJECT (mount), "pbvol-notification", notification,
1212 + g_object_unref);
1214 + g_free (message);
1215 + g_free (icon_name);
1216 + g_free (name);
1221 +void
1222 +pbvol_notify_unmount_finish (GMount *mount)
1224 + NotifyNotification *notification;
1226 + g_return_if_fail (G_IS_MOUNT (mount));
1228 + notification = g_object_get_data (G_OBJECT (mount), "pbvol-notification");
1229 + if (notification != NULL)
1231 + notify_notification_close (notification, NULL);
1232 + g_object_set_data (G_OBJECT (mount), "pbvol-notification", NULL);
1238 +void
1239 +pbvol_notify_eject (GVolume *volume)
1241 + const gchar * const *icon_names;
1242 + NotifyNotification *notification = NULL;
1243 + const gchar *summary;
1244 + GFileInfo *info;
1245 + gboolean read_only = FALSE;
1246 + GMount *mount;
1247 + GFile *icon_file;
1248 + GFile *mount_point;
1249 + GIcon *icon;
1250 + gchar *icon_name = NULL;
1251 + gchar *message;
1252 + gchar *name;
1254 + g_return_if_fail (G_IS_VOLUME (volume));
1256 + if (!pbvol_notify_init ())
1257 + return;
1259 + mount = g_volume_get_mount (volume);
1260 + if (mount != NULL)
1262 + mount_point = g_mount_get_root (mount);
1264 + info = g_file_query_info (mount_point, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
1265 + G_FILE_QUERY_INFO_NONE, NULL, NULL);
1267 + if (info != NULL)
1269 + read_only =
1270 + !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
1272 + g_object_unref (info);
1275 + g_object_unref (mount_point);
1278 + name = g_volume_get_name (volume);
1280 + icon = g_volume_get_icon (volume);
1281 + if (G_IS_THEMED_ICON (icon))
1283 + icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon));
1284 + if (icon_names != NULL)
1285 + icon_name = g_strdup (icon_names[0]);
1287 + else if (G_IS_FILE_ICON (icon))
1289 + icon_file = g_file_icon_get_file (G_FILE_ICON (icon));
1290 + if (icon_file != NULL)
1292 + icon_name = g_file_get_path (icon_file);
1293 + g_object_unref (icon_file);
1296 + g_object_unref (icon);
1298 + if (icon_name == NULL)
1299 + icon_name = g_strdup ("drive-removable-media");
1301 + if (read_only)
1303 + /* TRANSLATORS: Please use the same translation here as in Thunar */
1304 + summary = _("Ejecting device");
1306 + /* TRANSLATORS: Please use the same translation here as in Thunar */
1307 + message = g_strdup_printf (_("The device \"%s\" is being ejected. "
1308 + "This may take some time"), name);
1310 + else
1312 + /* TRANSLATORS: Please use the same translation here as in Thunar */
1313 + summary = _("Writing data to device");
1315 + /* TRANSLATORS: Please use the same translation here as in Thunar */
1316 + message = g_strdup_printf (_("There is data that needs to be written to the "
1317 + "device \"%s\" before it can be removed. Please "
1318 + "do not remove the media or disconnect the drive"),
1319 + name);
1322 +#ifdef NOTIFY_CHECK_VERSION
1323 +#if NOTIFY_CHECK_VERSION (0, 7, 0)
1324 + notification = notify_notification_new (summary, message, icon_name);
1325 +#else
1326 + notification = notify_notification_new (summary, message, icon_name, NULL);
1327 +#endif
1328 +#else
1329 + notification = notify_notification_new (summary, message, icon_name, NULL);
1330 +#endif
1331 + notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL);
1332 + notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
1333 + notify_notification_show (notification, NULL);
1335 + g_object_set_data_full (G_OBJECT (volume), "pbvol-notification", notification,
1336 + g_object_unref);
1338 + g_free (message);
1339 + g_free (icon_name);
1340 + g_free (name);
1345 +void
1346 +pbvol_notify_eject_finish (GVolume *volume)
1348 + NotifyNotification *notification;
1350 + g_return_if_fail (G_IS_VOLUME (volume));
1352 + notification = g_object_get_data (G_OBJECT (volume), "pbvol-notification");
1353 + if (notification != NULL)
1355 + notify_notification_close (notification, NULL);
1356 + g_object_set_data (G_OBJECT (volume), "pbvol-notification", NULL);
1362 +void
1363 +pbvol_notify_uninit (void)
1365 + if (pbvol_notify_initted
1366 + && notify_is_initted ())
1367 + notify_uninit ();
1369 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/model_volumes_notify.h xfce4-places-plugin-1.2.0/panel-plugin/model_volumes_notify.h
1370 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/model_volumes_notify.h 1970-01-01 01:00:00.000000000 +0100
1371 +++ xfce4-places-plugin-1.2.0/panel-plugin/model_volumes_notify.h 2011-03-22 11:49:53.000000000 +0100
1372 @@ -0,0 +1,37 @@
1373 +/* vi:set et ai sw=2 sts=2 ts=2: */
1374 +/*-
1375 + * Copyright (c) 2010 Jannis Pohlmann <jannis@xfce.org>
1377 + * This program is free software; you can redistribute it and/or
1378 + * modify it under the terms of the GNU General Public License as
1379 + * published by the Free Software Foundation; either version 2 of
1380 + * the License, or (at your option) any later version.
1382 + * This program is distributed in the hope that it will be useful,
1383 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1384 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1385 + * GNU General Public License for more details.
1387 + * You should have received a copy of the GNU General Public
1388 + * License along with this program; if not, write to the Free
1389 + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
1390 + * Boston, MA 02110-1301, USA.
1391 + */
1393 +#ifndef _XFCE_PANEL_PLACES_MODEL_VOLUMES_NOTIFY_H__
1394 +#define _XFCE_PANEL_PLACES_MODEL_VOLUMES_NOTIFY_H__
1396 +#include <glib.h>
1397 +#include <gio/gio.h>
1399 +G_BEGIN_DECLS
1401 +void pbvol_notify_unmount (GMount *mount);
1402 +void pbvol_notify_unmount_finish (GMount *mount);
1403 +void pbvol_notify_eject (GVolume *volume);
1404 +void pbvol_notify_eject_finish (GVolume *volume);
1405 +void pbvol_notify_uninit (void);
1407 +G_END_DECLS
1409 +#endif /* !_XFCE_PANEL_PLACES_MODEL_VOLUMES_NOTIFY_H__ */
1410 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/view.c xfce4-places-plugin-1.2.0/panel-plugin/view.c
1411 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/view.c 2011-03-24 11:34:16.000000000 +0100
1412 +++ xfce4-places-plugin-1.2.0/panel-plugin/view.c 2011-03-24 18:12:57.479026034 +0100
1413 @@ -57,8 +57,6 @@
1415 #include <string.h>
1417 -#include "xfce46-compat.h"
1419 #include "view.h"
1420 #include "support.h"
1421 #include "cfg.h"
1422 @@ -69,6 +67,10 @@
1423 #include "xfce4-popup-places.h"
1424 #include "button.h"
1426 +#ifdef HAVE_LIBNOTIFY
1427 +#include "model_volumes_notify.h"
1428 +#endif
1430 struct _PlacesViewCfgIface
1432 PlacesView *places_view;
1433 @@ -454,6 +456,42 @@
1435 /********** UI Helpers **********/
1437 +static GdkPixbuf *
1438 +pview_get_icon(GIcon *icon)
1440 + GtkIconTheme *itheme = gtk_icon_theme_get_default();
1441 + GdkPixbuf *pix = NULL;
1442 + gint width, height, size;
1444 + g_return_val_if_fail(icon != NULL, NULL);
1446 + if (gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height))
1447 + size = MAX(width, height);
1448 + else
1449 + size = 32;
1451 + if (G_IS_THEMED_ICON(icon)) {
1452 + GtkIconInfo *icon_info = gtk_icon_theme_lookup_by_gicon(itheme,
1453 + icon, size,
1454 + GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SIZE);
1455 + if (icon_info) {
1456 + GdkPixbuf *pix_theme = gtk_icon_info_load_icon(icon_info, NULL);
1457 + pix = gdk_pixbuf_copy(pix_theme);
1458 + gtk_icon_info_free(icon_info);
1459 + g_object_unref(G_OBJECT(pix_theme));
1461 + } else if(G_IS_LOADABLE_ICON(icon)) {
1462 + GInputStream *stream = g_loadable_icon_load(G_LOADABLE_ICON(icon),
1463 + size, NULL, NULL, NULL);
1464 + if (stream) {
1465 + pix = gdk_pixbuf_new_from_stream(stream, NULL, NULL);
1466 + g_object_unref(stream);
1470 + return pix;
1473 static void
1474 pview_destroy_menu(PlacesView *view)
1476 @@ -503,13 +541,7 @@
1478 /* try to set icon */
1479 if(view->cfg->show_icons && bookmark->icon != NULL){
1480 - gint icon_size;
1481 - gint width, height;
1482 - if (gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height))
1483 - icon_size = MAX(width, height);
1484 - else
1485 - icon_size = 32;
1486 - pb = xfce_themed_icon_load(bookmark->icon, icon_size);
1487 + pb = pview_get_icon(bookmark->icon);
1489 if(G_LIKELY(pb != NULL)){
1490 image = gtk_image_new_from_pixbuf(pb);
1491 @@ -910,6 +942,10 @@
1492 view->view_cfg_iface = NULL;
1494 g_free(view);
1496 +#ifdef HAVE_LIBNOTIFY
1497 + pbvol_notify_uninit();
1498 +#endif
1501 /* vim: set ai et tabstop=4: */
1502 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/xfce46-compat.c xfce4-places-plugin-1.2.0/panel-plugin/xfce46-compat.c
1503 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/xfce46-compat.c 2009-07-31 07:36:11.000000000 +0200
1504 +++ xfce4-places-plugin-1.2.0/panel-plugin/xfce46-compat.c 1970-01-01 01:00:00.000000000 +0100
1505 @@ -1,253 +0,0 @@
1507 - * Code was taken from libxfce4panel (LGPL2 or any later version),
1508 - * distributed here under the GPL.
1510 - * Copyright (c) 2005-2007 Jasper Huijsmans <jasper@xfce.org>
1512 - * This program is free software; you can redistribute it and/or modify
1513 - * it under the terms of the GNU General Public License as published by
1514 - * the Free Software Foundation; either version 2 of the License, or
1515 - * (at your option) any later version.
1517 - * This program is distributed in the hope that it will be useful,
1518 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1519 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1520 - * GNU Library General Public License for more details.
1522 - * You should have received a copy of the GNU General Public License
1523 - * along with this program; if not, write to the Free Software
1524 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1525 - */
1527 -#ifdef HAVE_CONFIG_H
1528 -# include <config.h>
1529 -#endif
1531 -#ifndef HAVE_LIBXFCE4PANEL_46
1533 -#include "xfce46-compat.h"
1535 -#include <libxfce4panel/xfce-panel-plugin.h>
1536 -#include <libxfce4panel/xfce-panel-macros.h>
1538 -/* support macros for debugging */
1539 -#ifndef NDEBUG
1540 -#define _panel_assert(expr) g_assert (expr)
1541 -#define _panel_assert_not_reached() g_assert_not_reached ()
1542 -#define _panel_return_if_fail(expr) g_return_if_fail (expr)
1543 -#define _panel_return_val_if_fail(expr, val) g_return_val_if_fail (expr, (val))
1544 -#else
1545 -#define _panel_assert(expr) G_STMT_START{ (void)0; }G_STMT_END
1546 -#define _panel_assert_not_reached() G_STMT_START{ (void)0; }G_STMT_END
1547 -#define _panel_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END
1548 -#define _panel_return_val_if_fail(expr, val) G_STMT_START{ (void)0; }G_STMT_END
1549 -#endif
1551 -/**
1552 - * xfce_panel_plugin_arrow_type:
1553 - * @plugin : an #XfcePanelPlugin
1555 - * Determine the #GtkArrowType for a widget that opens a menu and uses
1556 - * xfce_panel_plugin_position_menu() to position the menu.
1558 - * Returns: The #GtkArrowType to use.
1559 - **/
1560 -GtkArrowType
1561 -xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin)
1563 - XfceScreenPosition position;
1564 - GdkScreen *screen;
1565 - GdkRectangle geom;
1566 - gint mon, x, y;
1568 - if (!GTK_WIDGET_REALIZED (plugin))
1569 - return GTK_ARROW_UP;
1571 - position = xfce_panel_plugin_get_screen_position (plugin);
1572 - switch (position)
1574 - /* top */
1575 - case XFCE_SCREEN_POSITION_NW_H:
1576 - case XFCE_SCREEN_POSITION_N:
1577 - case XFCE_SCREEN_POSITION_NE_H:
1578 - return GTK_ARROW_DOWN;
1580 - /* left */
1581 - case XFCE_SCREEN_POSITION_NW_V:
1582 - case XFCE_SCREEN_POSITION_W:
1583 - case XFCE_SCREEN_POSITION_SW_V:
1584 - return GTK_ARROW_RIGHT;
1586 - /* right */
1587 - case XFCE_SCREEN_POSITION_NE_V:
1588 - case XFCE_SCREEN_POSITION_E:
1589 - case XFCE_SCREEN_POSITION_SE_V:
1590 - return GTK_ARROW_LEFT;
1592 - /* bottom */
1593 - case XFCE_SCREEN_POSITION_SW_H:
1594 - case XFCE_SCREEN_POSITION_S:
1595 - case XFCE_SCREEN_POSITION_SE_H:
1596 - return GTK_ARROW_UP;
1598 - /* floating */
1599 - default:
1600 - /* get the screen information */
1601 - screen = gtk_widget_get_screen (GTK_WIDGET (plugin));
1602 - mon = gdk_screen_get_monitor_at_window (screen, GTK_WIDGET (plugin)->window);
1603 - gdk_screen_get_monitor_geometry (screen, mon, &geom);
1604 - gdk_window_get_root_origin (GTK_WIDGET (plugin)->window, &x, &y);
1606 - /* get the position based on the screen position */
1607 - if (position == XFCE_SCREEN_POSITION_FLOATING_H)
1608 - return ((y < (geom.y + geom.height / 2)) ? GTK_ARROW_DOWN : GTK_ARROW_UP);
1609 - else
1610 - return ((x < (geom.x + geom.width / 2)) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT);
1616 -/**
1617 - * xfce_panel_plugin_position_widget:
1618 - * @plugin : an #XfcePanelPlugin
1619 - * @menu_widget : a #GtkWidget that will be used as popup menu
1620 - * @attach_widget : a #GtkWidget relative to which the menu should be positioned
1621 - * @x : return location for the x coordinate
1622 - * @y : return location for the y coordinate
1624 - * The menu widget is positioned relative to @attach_widget.
1625 - * If @attach_widget is NULL, the menu widget is instead positioned
1626 - * relative to @panel_plugin.
1628 - * This function is intended for custom menu widgets.
1629 - * For a regular #GtkMenu you should use xfce_panel_plugin_position_menu()
1630 - * instead (as callback argument to gtk_menu_popup()).
1632 - * See also: xfce_panel_plugin_position_menu().
1633 - **/
1634 -void
1635 -xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
1636 - GtkWidget *menu_widget,
1637 - GtkWidget *attach_widget,
1638 - gint *x,
1639 - gint *y)
1641 - GtkRequisition req;
1642 - GdkScreen *screen;
1643 - GdkRectangle geom;
1644 - gint mon;
1646 - _panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
1647 - _panel_return_if_fail (GTK_IS_WIDGET (menu_widget));
1648 - _panel_return_if_fail (attach_widget == NULL || GTK_IS_WIDGET (attach_widget));
1650 - if (attach_widget == NULL)
1651 - attach_widget = GTK_WIDGET (plugin);
1653 - if (!GTK_WIDGET_REALIZED (menu_widget))
1654 - gtk_widget_realize (menu_widget);
1656 - gtk_widget_size_request (menu_widget, &req);
1657 - gdk_window_get_origin (attach_widget->window, x, y);
1659 - switch (xfce_panel_plugin_arrow_type (plugin))
1661 - case GTK_ARROW_UP:
1662 - *y -= req.height;
1663 - break;
1665 - case GTK_ARROW_DOWN:
1666 - *y += attach_widget->allocation.height;
1667 - break;
1669 - case GTK_ARROW_LEFT:
1670 - *x -= req.width;
1671 - break;
1673 - default: /* GTK_ARROW_RIGHT and GTK_ARROW_NONE */
1674 - *x += attach_widget->allocation.width;
1675 - break;
1678 - screen = gtk_widget_get_screen (attach_widget);
1679 - mon = gdk_screen_get_monitor_at_window (screen, attach_widget->window);
1680 - gdk_screen_get_monitor_geometry (screen, mon, &geom);
1682 - /* keep inside the screen */
1683 - if (*x > geom.x + geom.width - req.width)
1684 - *x = geom.x + geom.width - req.width;
1685 - if (*x < geom.x)
1686 - *x = geom.x;
1687 - if (*y > geom.y + geom.height - req.height)
1688 - *y = geom.y + geom.height - req.height;
1689 - if (*y < geom.y)
1690 - *y = geom.y;
1692 - if (G_LIKELY (GTK_IS_MENU (menu_widget)))
1693 - gtk_menu_set_screen (GTK_MENU (menu_widget), screen);
1694 - else if (GTK_IS_WINDOW (menu_widget))
1695 - gtk_window_set_screen (GTK_WINDOW (menu_widget), screen);
1700 -/**
1701 - * xfce_panel_plugin_position_menu:
1702 - * @menu : a #GtkMenu
1703 - * @x : return location for the x coordinate
1704 - * @y : return location for the y coordinate
1705 - * @push_in : keep inside the screen (see #GtkMenuPositionFunc)
1706 - * @panel_plugin : a pointer to an #XfcePanelPlugin
1708 - * Function to be used as #GtkMenuPositionFunc in a call to gtk_menu_popup().
1709 - * As data argument it needs an #XfcePanelPlugin.
1711 - * The menu is normally positioned relative to @panel_plugin. If you want the
1712 - * menu to be positioned relative to another widget, you can use
1713 - * gtk_menu_attach_to_widget() to explicitly set a 'parent' widget.
1715 - * As a convenience, xfce_panel_plugin_position_menu() calls
1716 - * xfce_panel_plugin_register_menu() for the menu.
1718 - * <example>
1719 - * void
1720 - * myplugin_popup_menu (XfcePanelPlugin *plugin,
1721 - * GtkMenu *menu,
1722 - * GdkEventButton *ev)
1723 - * {
1724 - * gtk_menu_popup (menu, NULL, NULL,
1725 - * xfce_panel_plugin_position_menu, plugin,
1726 - * ev->button, ev->time );
1727 - * }
1728 - * </example>
1730 - * For a custom widget that will be used as a popup menu, use
1731 - * xfce_panel_plugin_position_widget() instead.
1733 - * See also: gtk_menu_popup().
1734 - **/
1735 -void
1736 -xfce_panel_plugin_position_menu (GtkMenu *menu,
1737 - gint *x,
1738 - gint *y,
1739 - gboolean *push_in,
1740 - gpointer panel_plugin)
1742 - XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (panel_plugin);
1743 - GtkWidget *attach_widget;
1745 - attach_widget = gtk_menu_get_attach_widget (menu);
1747 - xfce_panel_plugin_position_widget (plugin,
1748 - GTK_WIDGET (menu),
1749 - attach_widget,
1750 - x, y);
1752 - /* keep inside screen */
1753 - *push_in = TRUE;
1755 - xfce_panel_plugin_register_menu (plugin, menu);
1758 -#endif
1759 diff -Naur xfce4-places-plugin-1.2.0.orig/panel-plugin/xfce46-compat.h xfce4-places-plugin-1.2.0/panel-plugin/xfce46-compat.h
1760 --- xfce4-places-plugin-1.2.0.orig/panel-plugin/xfce46-compat.h 2008-11-23 12:09:10.000000000 +0100
1761 +++ xfce4-places-plugin-1.2.0/panel-plugin/xfce46-compat.h 1970-01-01 01:00:00.000000000 +0100
1762 @@ -1,18 +0,0 @@
1763 -#ifndef _XFCE46_COMPAT
1764 -#define _XFCE46_COMPAT
1766 -#ifdef HAVE_CONFIG_H
1767 -# include <config.h>
1768 -#endif
1770 -#ifndef HAVE_LIBXFCE4PANEL_46
1772 -#include <gtk/gtk.h>
1774 -void xfce_panel_plugin_position_menu (GtkMenu *menu,
1775 - gint *x,
1776 - gint *y,
1777 - gboolean *push_in,
1778 - gpointer panel_plugin);
1779 -#endif
1780 -#endif