[Goodies-commits] r3693 - in xfce4-places-plugin/trunk: . panel-plugin
Diego Ongaro
ongardie at xfce.org
Mon Dec 10 11:37:00 CET 2007
Author: ongardie
Date: 2007-12-10 10:37:00 +0000 (Mon, 10 Dec 2007)
New Revision: 3693
Modified:
xfce4-places-plugin/trunk/ChangeLog
xfce4-places-plugin/trunk/TODO
xfce4-places-plugin/trunk/panel-plugin/model_volumes.c
xfce4-places-plugin/trunk/panel-plugin/support.c
xfce4-places-plugin/trunk/panel-plugin/support.h
Log:
2007-12-10 Diego Ongaro <ongardie at gmail.com>
* model_volumes.c, support.{c,h}: Show error messages when
mounts/unmounts fail
Modified: xfce4-places-plugin/trunk/ChangeLog
===================================================================
--- xfce4-places-plugin/trunk/ChangeLog 2007-12-10 08:14:45 UTC (rev 3692)
+++ xfce4-places-plugin/trunk/ChangeLog 2007-12-10 10:37:00 UTC (rev 3693)
@@ -2,6 +2,8 @@
* view.c: Bug: label didn't change when already shown
* view.c: Use GtkTooltip API when available
+ * model_volumes.c, support.{c,h}: Show error messages when
+ mounts/unmounts fail
2007-12-09 Diego Ongaro <ongardie at gmail.com>
Modified: xfce4-places-plugin/trunk/TODO
===================================================================
--- xfce4-places-plugin/trunk/TODO 2007-12-10 08:14:45 UTC (rev 3692)
+++ xfce4-places-plugin/trunk/TODO 2007-12-10 10:37:00 UTC (rev 3693)
@@ -1,3 +1,5 @@
use less resources
path/uri mess
-error messages and notifications for (un)mounting
+steal error message translations from Thunar
+----
+notifications for (un)mounting - newer versions of exo do this
Modified: xfce4-places-plugin/trunk/panel-plugin/model_volumes.c
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/model_volumes.c 2007-12-10 08:14:45 UTC (rev 3692)
+++ xfce4-places-plugin/trunk/panel-plugin/model_volumes.c 2007-12-10 10:37:00 UTC (rev 3693)
@@ -51,45 +51,79 @@
static void
pbvol_eject(PlacesBookmarkAction *action)
{
+ GError *error = NULL;
+ ThunarVfsVolume *volume;
+
DBG("Eject");
- ThunarVfsVolume *volume = THUNAR_VFS_VOLUME(action->priv);
+ g_return_if_fail(THUNAR_VFS_IS_VOLUME(action->priv));
+ volume = THUNAR_VFS_VOLUME(action->priv);
- thunar_vfs_volume_eject(volume, NULL, NULL);
+ if(!thunar_vfs_volume_eject(volume, NULL, &error)){
+ places_show_error_dialog(error,
+ _("Failed to eject \"%s\""),
+ thunar_vfs_volume_get_name (volume));
+ g_error_free (error);
+ }
}
static void
pbvol_unmount(PlacesBookmarkAction *action)
{
+ GError *error = NULL;
+ ThunarVfsVolume *volume;
+
DBG("Unmount");
- ThunarVfsVolume *volume = THUNAR_VFS_VOLUME(action->priv);
+ g_return_if_fail(THUNAR_VFS_IS_VOLUME(action->priv));
+ volume = THUNAR_VFS_VOLUME(action->priv);
- if(thunar_vfs_volume_is_mounted(volume))
- thunar_vfs_volume_unmount(volume, NULL, NULL);
+ if(thunar_vfs_volume_is_mounted(volume)){
+ if(!thunar_vfs_volume_unmount(volume, NULL, &error)){
+
+ places_show_error_dialog(error,
+ _("Failed to unmount \"%s\""),
+ thunar_vfs_volume_get_name (volume));
+ g_error_free (error);
+ }
+ }
}
static void
pbvol_mount(PlacesBookmarkAction *action)
{
+ GError *error = NULL;
+ ThunarVfsVolume *volume;
+
DBG("Mount");
- ThunarVfsVolume *volume = THUNAR_VFS_VOLUME(action->priv);
+ g_return_if_fail(THUNAR_VFS_IS_VOLUME(action->priv));
+ volume = THUNAR_VFS_VOLUME(action->priv);
- if(!thunar_vfs_volume_is_mounted(volume))
- thunar_vfs_volume_mount(volume, NULL, NULL);
+ if(!thunar_vfs_volume_is_mounted(volume)){
+ if(!thunar_vfs_volume_mount(volume, NULL, &error)){
+
+ places_show_error_dialog(error,
+ _("Failed to mount \"%s\""),
+ thunar_vfs_volume_get_name (volume));
+ g_error_free (error);
+ }
+ }
}
static void
pbvol_mount_and_open(PlacesBookmarkAction *action)
{
+ gchar *uri;
+ ThunarVfsVolume *volume;
+
DBG("Mount and open");
+
+ g_return_if_fail(THUNAR_VFS_IS_VOLUME(action->priv));
+ volume = THUNAR_VFS_VOLUME(action->priv);
- gchar *uri;
- ThunarVfsVolume *volume = THUNAR_VFS_VOLUME(action->priv);
-
if(!thunar_vfs_volume_is_mounted(volume))
- thunar_vfs_volume_mount(volume, NULL, NULL);
+ pbvol_mount(action);
if(thunar_vfs_volume_is_mounted(volume)){
uri = thunar_vfs_path_dup_uri(thunar_vfs_volume_get_mount_point(volume));
Modified: xfce4-places-plugin/trunk/panel-plugin/support.c
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/support.c 2007-12-10 08:14:45 UTC (rev 3692)
+++ xfce4-places-plugin/trunk/panel-plugin/support.c 2007-12-10 10:37:00 UTC (rev 3693)
@@ -4,6 +4,9 @@
*
* Copyright (c) 2007 Diego Ongaro <ongardie at gmail.com>
*
+ * Error dialog code adapted from thunar's thunar-dialogs.c:
+ * Copyright (c) 2005-2007 Benedikt Meurer <benny at xfce.org>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -166,4 +169,41 @@
return action;
}
+
+void
+places_show_error_dialog (const GError *error,
+ const gchar *format,
+ ...)
+{
+ GtkWidget *dialog;
+ va_list args;
+ gchar *primary_text;
+
+ /* determine the primary error text */
+ va_start (args, format);
+ primary_text = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ /* allocate the error dialog */
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s.", primary_text);
+
+ /* set secondary text if an error is provided */
+ if (G_LIKELY (error != NULL)){
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s.", error->message);
+ }
+
+ /* display the dialog */
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ /* cleanup */
+ gtk_widget_destroy (dialog);
+ g_free (primary_text);
+
+}
+
/* vim: set ai et tabstop=4: */
Modified: xfce4-places-plugin/trunk/panel-plugin/support.h
===================================================================
--- xfce4-places-plugin/trunk/panel-plugin/support.h 2007-12-10 08:14:45 UTC (rev 3692)
+++ xfce4-places-plugin/trunk/panel-plugin/support.h 2007-12-10 10:37:00 UTC (rev 3693)
@@ -4,6 +4,9 @@
*
* Copyright (c) 2007 Diego Ongaro <ongardie at gmail.com>
*
+ * Error dialog code adapted from thunar's thunar-dialogs.h:
+ * Copyright (c) 2005-2007 Benedikt Meurer <benny at xfce.org>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -43,6 +46,11 @@
PlacesBookmarkAction*
places_create_open_terminal_action(const PlacesBookmark *bookmark);
+void
+places_show_error_dialog (const GError *error,
+ const gchar *format,
+ ...) G_GNUC_PRINTF (2, 3);
+
#endif
/* vim: set ai et tabstop=4: */
More information about the Goodies-commits
mailing list