summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore40
-rwxr-xr-xautogen.sh54
-rw-r--r--configure.in.in74
-rw-r--r--thunar-volman/Makefile.am71
-rw-r--r--thunar-volman/main.c206
-rw-r--r--thunar-volman/tvm-block-device.c884
-rw-r--r--thunar-volman/tvm-block-device.h36
-rw-r--r--thunar-volman/tvm-camera-device.c89
-rw-r--r--thunar-volman/tvm-camera-device.h35
-rw-r--r--thunar-volman/tvm-command-entry.c411
-rw-r--r--thunar-volman/tvm-command-entry.h61
-rw-r--r--thunar-volman/tvm-context.c93
-rw-r--r--thunar-volman/tvm-context.h59
-rw-r--r--thunar-volman/tvm-crypto-volume.c483
-rw-r--r--thunar-volman/tvm-crypto-volume.h35
-rw-r--r--thunar-volman/tvm-device.c240
-rw-r--r--thunar-volman/tvm-device.h67
-rw-r--r--thunar-volman/tvm-gio-extensions.c64
-rw-r--r--thunar-volman/tvm-gio-extensions.h34
-rw-r--r--thunar-volman/tvm-input-device.c101
-rw-r--r--thunar-volman/tvm-input-device.h35
-rw-r--r--thunar-volman/tvm-pango-extensions.c177
-rw-r--r--thunar-volman/tvm-pango-extensions.h36
-rw-r--r--thunar-volman/tvm-pda-device.c120
-rw-r--r--thunar-volman/tvm-pda-device.h35
-rw-r--r--thunar-volman/tvm-preferences-dialog.c719
-rw-r--r--thunar-volman/tvm-preferences-dialog.h43
-rw-r--r--thunar-volman/tvm-preferences.c963
-rw-r--r--thunar-volman/tvm-preferences.h43
-rw-r--r--thunar-volman/tvm-printer-device.c80
-rw-r--r--thunar-volman/tvm-printer-device.h35
-rw-r--r--thunar-volman/tvm-prompt.c173
-rw-r--r--thunar-volman/tvm-prompt.h51
-rw-r--r--thunar-volman/tvm-run.c297
-rw-r--r--thunar-volman/tvm-run.h51
-rw-r--r--thunar-volman/xfce-heading.c755
-rw-r--r--thunar-volman/xfce-heading.h82
-rw-r--r--thunar-volman/xfce-titled-dialog.c370
-rw-r--r--thunar-volman/xfce-titled-dialog.h75
39 files changed, 864 insertions, 6413 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..689645c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,40 @@
+*.gmo
+*.o
+*.la
+*.so
+*.a
+.deps
+.intltool-merge-cache
+.libs
+aclocal.m4
+autom4te.cache
+compile
+config.guess
+config.h
+config.h.in
+config.h.in~
+config.log
+config.status
+config.sub
+configure
+configure.in
+depcomp
+INSTALL
+install-sh
+intltool-extract.in
+intltool-merge.in
+intltool-update.in
+libtool
+ltmain.sh
+Makefile
+Makefile.in
+Makefile.in.in
+missing
+mkinstalldirs
+POTFILES
+stamp-it
+stamp-h1
+thunar-volman-settings
+thunar-volman-settings.desktop
+texput.log
+thunar-volman
diff --git a/autogen.sh b/autogen.sh
index 9769a5c..9ec5e44 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,12 +1,21 @@
-#!/bin/sh
-#
-# $Id$
-#
-# Copyright (c) 2002-2006
-# The Thunar development team. All rights reserved.
-#
-# Written for Thunar by Benedikt Meurer <benny@xfce.org>.
-#
+# vi:set et ai sw=2 sts=2 ts=2: */
+# -
+# Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
(type xdt-autogen) >/dev/null 2>&1 || {
cat >&2 <<EOF
@@ -18,29 +27,4 @@ EOF
exit 1
}
-# verify that po/LINGUAS is present
-(test -f po/LINGUAS) >/dev/null 2>&1 || {
- cat >&2 <<EOF
-autogen.sh: The file po/LINGUAS could not be found. Please check your snapshot
- or try to checkout again.
-EOF
- exit 1
-}
-
-# substitute revision and linguas
-linguas=`sed -e '/^#/d' po/LINGUAS`
-if test -d .git/svn; then
- revision=`git svn find-rev trunk 2>/dev/null ||
- git svn find-rev origin/trunk 2>/dev/null ||
- git svn find-rev HEAD 2>/dev/null ||
- git svn find-rev master 2>/dev/null`
-else
- revision=`LC_ALL=C svn info $0 | awk '/^Revision: / {printf "%05d\n", $2}'`
-fi
-sed -e "s/@LINGUAS@/${linguas}/g" \
- -e "s/@REVISION@/${revision}/g" \
- < "configure.in.in" > "configure.in"
-
-exec xdt-autogen $@
-
-# vi:set ts=2 sw=2 et ai:
+XDT_AUTOGEN_REQUIRED_VERSION="4.7.2" exec xdt-autogen $@
diff --git a/configure.in.in b/configure.in.in
index e99da55..439e9ad 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -81,79 +81,23 @@ dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([DBUS], [dbus-glib-1], [0.34])
-XDT_CHECK_PACKAGE([EXO_HAL], [exo-hal-0.3], [0.3.7.1svn-r27445])
-XDT_CHECK_PACKAGE([HAL], [hal], [0.5.0])
-XDT_CHECK_PACKAGE([THUNAR_VFS], [thunar-vfs-1], [0.5.1])
+XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.18.0])
+XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.18.0])
+XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.18.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0])
+XDT_CHECK_PACKAGE([GUDEV], [gudev-1.0], [145])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.7.0])
+XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.7.0])
dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
-AC_ARG_ENABLE([debug],
-AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes/full@:>@], [Turn on debugging @<:@default=tvm_debug_default@:>@]),
- [], [enable_debug=tvm_debug_default])
-AC_MSG_CHECKING([whether to enable debugging support])
-if test x"$enable_debug" = x"full" -o x"$enable_debug" = x"yes"; then
- dnl Print the result
- AC_MSG_RESULT([$enable_debug])
-
- dnl Make sure we detect possible errors (if supported)
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Wall -Werror"
- AC_MSG_CHECKING([whether $CC accepts -Wall -Werror])
- AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [
- AC_MSG_RESULT([yes])
- PLATFORM_CFLAGS="$PLATFORM_CFLAGS -Wall -Werror"
- ], [
- AC_MSG_RESULT([no])
- ])
- CFLAGS="$save_CFLAGS"
-
- dnl Paranoia for --enable-debug=full
- if test x"$enable_debug" = x"full"; then
- dnl Enable extensive debugging
- PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_ENABLE_DEBUG"
-
- dnl Use -O0 -g3 if the compiler supports it
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -O0 -g3"
- AC_MSG_CHECKING([whether $CC accepts -O0 -g3])
- AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [
- AC_MSG_RESULT([yes])
- PLATFORM_CFLAGS="$PLATFORM_CFLAGS -O0 -g3"
- ], [
- AC_MSG_RESULT([no])
- ])
- CFLAGS="$save_CFLAGS"
- fi
-else
- dnl Print the result
- AC_MSG_RESULT([$enable_debug])
-
- dnl Disable debugging (release build)
- PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DNDEBUG"
-
- dnl Disable object cast checks
- PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_DISABLE_CAST_CHECKS"
-
- dnl Disable all checks for --enable-debug=no
- if test x"$enable_debug" = x"no"; then
- PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
- fi
-fi
+XDT_FEATURE_DEBUG()
dnl **************************************
dnl *** Check for linker optimizations ***
dnl **************************************
-AC_MSG_CHECKING([whether $LD accepts -O1])
-case `$LD -O1 -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -Wl,-O1"
- AC_MSG_RESULT([yes])
- ;;
-*)
- AC_MSG_RESULT([no])
- ;;
-esac
+XDT_FEATURE_LINKER_OPTS()
dnl *********************************
dnl *** Substitute platform flags ***
diff --git a/thunar-volman/Makefile.am b/thunar-volman/Makefile.am
index c072b41..66aa8e9 100644
--- a/thunar-volman/Makefile.am
+++ b/thunar-volman/Makefile.am
@@ -1,4 +1,21 @@
-# $Id$
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
+# -
+# Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
INCLUDES = \
-I$(top_builddir) \
@@ -17,40 +34,24 @@ thunar_volman_SOURCES = \
main.c \
tvm-block-device.c \
tvm-block-device.h \
- tvm-camera-device.c \
- tvm-camera-device.h \
- tvm-command-entry.c \
- tvm-command-entry.h \
- tvm-crypto-volume.c \
- tvm-crypto-volume.h \
+ tvm-context.c \
+ tvm-context.h \
tvm-device.c \
tvm-device.h \
- tvm-input-device.c \
- tvm-input-device.h \
- tvm-pango-extensions.c \
- tvm-pango-extensions.h \
- tvm-pda-device.c \
- tvm-pda-device.h \
- tvm-preferences-dialog.c \
- tvm-preferences-dialog.h \
- tvm-preferences.c \
- tvm-preferences.h \
- tvm-printer-device.c \
- tvm-printer-device.h \
- tvm-prompt.c \
- tvm-prompt.h \
+ tvm-gio-extensions.c \
+ tvm-gio-extensions.h \
tvm-run.c \
- tvm-run.h \
- xfce-heading.c \
- xfce-heading.h \
- xfce-titled-dialog.c \
- xfce-titled-dialog.h
+ tvm-run.h
thunar_volman_CFLAGS = \
$(DBUS_CFLAGS) \
- $(EXO_HAL_CFLAGS) \
- $(HAL_CFLAGS) \
- $(THUNAR_VFS_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(GIO_CFLAGS) \
+ $(GTHREAD_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(GUDEV_CFLAGS) \
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(XFCONF_CFLAGS) \
$(PLATFORM_CFLAGS)
thunar_volman_LDFLAGS = \
@@ -59,8 +60,10 @@ thunar_volman_LDFLAGS = \
thunar_volman_LDADD = \
$(DBUS_LIBS) \
- $(EXO_HAL_LIBS) \
- $(HAL_LIBS) \
- $(THUNAR_VFS_LIBS)
-
-# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
+ $(GLIB_LIBS) \
+ $(GIO_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(GTK_LIBS) \
+ $(GUDEV_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ $(XFCONF_LIBS)
diff --git a/thunar-volman/main.c b/thunar-volman/main.c
index e4e4f15..96f16dd 100644
--- a/thunar-volman/main.c
+++ b/thunar-volman/main.c
@@ -1,66 +1,86 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@xfce.org>.
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option)
- * any later version.
+ * 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 (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
+#include <glib.h>
#include <glib/gstdio.h>
-#include <exo-hal/exo-hal.h>
+#include <gtk/gtk.h>
-#include <thunar-vfs/thunar-vfs.h>
+#include <gudev/gudev.h>
+#include <libxfce4util/libxfce4util.h>
+
+#include <xfconf/xfconf.h>
+
+#include <thunar-volman/tvm-context.h>
#include <thunar-volman/tvm-device.h>
-#include <thunar-volman/tvm-preferences-dialog.h>
-/* --- globals --- */
-static gchar *opt_hal_udi = NULL;
+/* variables for command line options */
+static gchar *opt_sysfs_path = NULL;
static gboolean opt_configure = FALSE;
static gboolean opt_version = FALSE;
-/* --- command line options --- */
+/* command line options */
static GOptionEntry option_entries[] =
{
- { "device-added", 'a', 0, G_OPTION_ARG_STRING, &opt_hal_udi, N_ ("The HAL device UDI of the newly added device"), NULL, },
+ { "device-added", 'a', 0, G_OPTION_ARG_STRING, &opt_sysfs_path, N_ ("The syfs path of the newly added device"), NULL, },
{ "configure", 'c', 0, G_OPTION_ARG_NONE, &opt_configure, N_ ("Configure management of removable drives and media"), NULL, },
- { "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, N_ ("Print version information and exit"), NULL, },
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &opt_version, N_ ("Print version information and exit"), NULL, },
{ NULL, },
};
+/* udev subsystems supported by thunar-volman */
+static const gchar *supported_udev_subsystems[] =
+{
+ "block",
+ "input",
+ NULL,
+};
+
+
+
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
- TvmPreferences *preferences;
- GtkWidget *dialog;
- GError *err = NULL;
+ XfconfChannel *channel;
+ GUdevClient *client;
+ GUdevDevice *device;
+ TvmContext *context = NULL;
+ GMainLoop *loop = NULL;
+ GError *error = NULL;
+ gint exit_code = EXIT_SUCCESS;
/* setup translation domain */
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
@@ -69,96 +89,106 @@ main (int argc, char **argv)
g_set_application_name (_("Thunar Volume Manager"));
#ifdef G_ENABLE_DEBUG
- /* Do NOT remove this line for now, If something doesn't work,
- * fix your code instead!
- */
+ /* Do NOT remove this line for now. If something doesn't work, fix your code instead */
g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
#endif
- /* initialize the GThread system */
+ /* initialize the threading system */
if (!g_thread_supported ())
g_thread_init (NULL);
- /* initialize Gtk+ */
- if (!gtk_init_with_args (&argc, &argv, NULL, option_entries, GETTEXT_PACKAGE, &err))
+ /* initialize GTK+ */
+ if (!gtk_init_with_args (&argc, &argv, NULL, option_entries, GETTEXT_PACKAGE, &error))
{
- /* check if we have an error message */
- if (G_LIKELY (err == NULL))
- {
- /* no error message, the GUI initialization failed */
- const gchar *display_name = gdk_get_display_arg_name ();
- g_fprintf (stderr, "thunar-volman: %s: %s.\n", _("Failed to open display"), (display_name != NULL) ? display_name : " ");
- }
- else
- {
- /* yep, there's an error, so print it */
- g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), err->message);
- g_error_free (err);
- }
+ g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message);
+ g_error_free (error);
return EXIT_FAILURE;
}
- /* check if we should print version information */
- if (G_UNLIKELY (opt_version))
+ /* initialize xfconf */
+ if (!xfconf_init (&error))
{
- g_print ("%s %s (Xfce %s)\n\n", PACKAGE_NAME, PACKAGE_VERSION, xfce_version_string ());
- g_print ("%s\n", "Copyright (c) 2004-2007");
- g_print ("\t%s\n\n", _("The Thunar development team. All rights reserved."));
- g_print ("%s\n\n", _("Written by Benedikt Meurer <benny@xfce.org>."));
- g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT);
- g_print ("\n");
- return EXIT_SUCCESS;
+ g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message);
+ g_error_free (error);
+ return EXIT_FAILURE;
}
- /* initialize the ThunarVFS library */
- thunar_vfs_init ();
-
- /* load the preferences for the volume manager */
- preferences = tvm_preferences_get ();
-
- /* check if we should configure the volume manager */
- if (G_UNLIKELY (opt_configure))
+ /* check if we should print the version information */
+ if (opt_version)
{
- /* bring up the preferences dialog */
- dialog = tvm_preferences_dialog_new ();
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ /* the --configure/-c option of thunar-volman exists for backwards-compatibility
+ * reasons only. what we really do here is spawning thunar-volman-settings */
+ if (!g_spawn_command_line_sync ("thunar-volman-settings", NULL, NULL, &exit_code,
+ &error))
+ {
+ g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message);
+ g_error_free (error);
+ exit_code = WEXITSTATUS (exit_code);
+ }
}
- else if (G_LIKELY (opt_hal_udi != NULL))
+ else if (opt_sysfs_path != NULL)
{
- /* make sure the specified UDI is valid */
- if (!exo_hal_udi_validate (opt_hal_udi, -1, NULL))
+ /* create an udev client */
+ client = g_udev_client_new (supported_udev_subsystems);
+
+ /* determine the device belonging to the sysfs path */
+ device = g_udev_client_query_by_sysfs_path (client, opt_sysfs_path);
+
+ if (device != NULL)
{
- /* TRANSLATORS: A HAL device UDI must match certain conditions to be valid (to be exact, it must be a valid D-Bus object path) */
- g_set_error (&err, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("The specified UDI \"%s\" is not a valid HAL device UDI"), opt_hal_udi);
+ /* get a reference on the thunar-volman settings channel */
+ channel = xfconf_channel_get ("thunar-volman");
+
+ /* create a new main loop */
+ loop = g_main_loop_new (NULL, FALSE);
+
+ /* allocate a new TvmContext */
+ context = tvm_context_new (client, device, channel, loop, &error);
+
+ /* handle the new device in an idle handler */
+ g_idle_add ((GSourceFunc) tvm_context_run, context);
+
+ /* release channel and device */
+ g_object_unref (device);
}
else
{
- /* try to handle the newly added device */
- tvm_device_added (preferences, opt_hal_udi, &err);
+ g_set_error (&error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("There is no device with the sysfs path \"%s\""),
+ opt_sysfs_path);
}
+
+ /* release the udev client */
+ g_object_unref (client);
}
else
{
- /* TRANSLATORS: thunar-volman wasn't invoked with either --device-added or --configure. */
- g_set_error (&err, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Must specify the new HAL device UDI with --device-added"));
+ /* TRANSLATORS: thunar-volman wasn't invoked with either --device-added or
+ * --configure */
+ g_set_error (&error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Must specify the sysfs path of new devices with --device-added"));
}
- /* flush the preferences */
- g_object_unref (G_OBJECT (preferences));
-
- /* shutdown thunar-vfs */
- thunar_vfs_shutdown ();
+ /* run the main loop */
+ if (loop != NULL)
+ {
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+ }
- /* check if an error occurred */
- if (G_UNLIKELY (err != NULL))
+ if (error != NULL)
{
- /* tell the user about the problem */
- g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), err->message);
- g_error_free (err);
- return EXIT_FAILURE;
+ g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message);
+ g_error_free (error);
+ exit_code = EXIT_FAILURE;
}
- return EXIT_SUCCESS;
-}
+ /* release the device context */
+ if (context != NULL)
+ tvm_context_free (context);
+
+ /* free xfconf resources */
+ xfconf_shutdown ();
+ return exit_code;
+}
diff --git a/thunar-volman/tvm-block-device.c b/thunar-volman/tvm-block-device.c
index de4e774..26c9483 100644
--- a/thunar-volman/tvm-block-device.c
+++ b/thunar-volman/tvm-block-device.c
@@ -1,782 +1,286 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
- * Copyright (c) 2007-2008 Benedikt Meurer <benny@xfce.org>.
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option)
- * any later version.
+ * 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 (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
+#include <gio/gio.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
+#include <gtk/gtk.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gudev/gudev.h>
+
+#include <libxfce4util/libxfce4util.h>
#include <thunar-volman/tvm-block-device.h>
-#include <thunar-volman/tvm-crypto-volume.h>
-#include <thunar-volman/tvm-prompt.h>
+#include <thunar-volman/tvm-context.h>
+#include <thunar-volman/tvm-device.h>
+#include <thunar-volman/tvm-gio-extensions.h>
#include <thunar-volman/tvm-run.h>
-static gboolean tvm_file_test (const gchar *directory,
- const gchar *filename,
- GFileTest test);
-static gboolean tvm_block_device_autoipod (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error);
-static gboolean tvm_block_device_autophoto (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error);
-static gboolean tvm_block_device_autorun (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error);
-static gboolean tvm_block_device_mount (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- GError **error);
-static gboolean tvm_block_device_mounted (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error);
+typedef gboolean (*TvmBlockDeviceHandler) (TvmContext *context,
+ GMount *mount,
+ GError **error);
-static gboolean
-tvm_file_test (const gchar *directory,
- const gchar *filename,
- GFileTest test)
-{
- const gchar *name;
- gboolean result = FALSE;
- gchar *path;
- GDir *dp;
-
- /* try to open the specified directory */
- dp = g_dir_open (directory, 0, NULL);
- if (G_LIKELY (dp != NULL))
- {
- while (!result)
- {
- /* read the next entry */
- name = g_dir_read_name (dp);
- if (G_UNLIKELY (name == NULL))
- break;
+static gboolean tvm_block_device_autobrowse (TvmContext *context,
+ GMount *mount,
+ GError **error);
- /* check if we have a potential match */
- if (g_ascii_strcasecmp (name, filename) == 0)
- {
- /* check if test condition met */
- path = g_build_filename (directory, name, NULL);
- result = g_file_test (path, test);
- g_free (path);
- }
- }
- /* cleanup */
- g_dir_close (dp);
- }
- return result;
-}
+static TvmBlockDeviceHandler block_device_handlers[] =
+{
+#if 0
+ tvm_block_device_autoipod,
+ tvm_block_device_autophoto,
+ tvm_block_device_autorun,
+#endif
+ tvm_block_device_autobrowse,
+};
static gboolean
-tvm_block_device_autoipod (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error)
+tvm_block_device_autobrowse (TvmContext *context,
+ GMount *mount,
+ GError **error)
{
+ gboolean autobrowse;
gboolean result = FALSE;
- gboolean autoipod;
- gboolean is_audio_player = FALSE;
- gchar *autoipod_command;
- gchar *autophoto_command;
- gchar *storage_udi;
- gchar *path_dcim = NULL;
- gchar *product;
- gint response = TVM_RESPONSE_NONE;
-
- /* check if music players should be handled automatically */
- g_object_get (G_OBJECT (preferences), "autoipod", &autoipod, "autoipod-command", &autoipod_command, NULL);
- if (G_LIKELY (autoipod && autoipod_command != NULL && *autoipod_command != '\0'))
- {
- /* determine the storage device UDI */
- storage_udi = libhal_device_get_property_string (context, udi, "block.storage_device", NULL);
- if (G_LIKELY (storage_udi != NULL))
- {
- /* check if we have a portable audio player here */
- if (libhal_device_query_capability (context, storage_udi, "portable_audio_player", NULL))
- {
- is_audio_player = TRUE;
- /* check if we have an iPod here */
- product = libhal_device_get_property_string (context, storage_udi, "info.product", NULL);
- if (product != NULL && strcmp (product, "iPod") != 0)
- {
- /* an iPod may have photos */
- path_dcim = g_build_filename (mount_point, "dcim", NULL);
- if (!g_file_test (path_dcim, G_FILE_TEST_IS_DIR))
- {
- /* no photos */
- g_free (path_dcim);
- path_dcim = NULL;
- }
- else
- {
- /* add the "content.photos" capability to this device */
- libhal_device_add_capability (context, udi, "content.photos", NULL);
- }
- }
- libhal_free_string (product);
- }
-
- /* check if autophoto command is specified, else we cannot handle the photos on the iPod anyway */
- g_object_get (G_OBJECT (preferences), "autophoto-command", &autophoto_command, NULL);
- if (G_UNLIKELY (autophoto_command == NULL || *autophoto_command == '\0'))
- {
- /* cannot handle photos */
- g_free (path_dcim);
- path_dcim = NULL;
- }
-
- /* iPods can carry both music and photos... */
- if (G_LIKELY (path_dcim != NULL))
- {
- /* ...so we need to prompt what to do */
- response = tvm_prompt (context, udi, "gnome-dev-ipod", _("Photos and Music"),
- _("Photos were found on your portable music player."),
- _("Would you like to import the photos or manage the music?"),
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("Import _Photos"), TVM_RESPONSE_PHOTOS,
- _("Manage _Music"), TVM_RESPONSE_MUSIC,
- NULL);
- }
- else
- {
- /* no photos, so we can manage only music */
- if(is_audio_player)
- response = TVM_RESPONSE_MUSIC;
- }
+ GError *err = NULL;
- /* check what to do */
- if (response == TVM_RESPONSE_MUSIC)
- {
- /* run the preferred application to manage music players */
- result = tvm_run_command (context, udi, autoipod_command, device_file, mount_point, error);
- }
- else if (response == TVM_RESPONSE_PHOTOS)
- {
- /* run the preferred application to manage photos */
- result = tvm_run_command (context, udi, autophoto_command, device_file, mount_point, error);
- }
+ g_return_val_if_fail (context != NULL, FALSE);
+ g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- /* cleanup */
- libhal_free_string (storage_udi);
- g_free (autophoto_command);
- g_free (path_dcim);
- }
+ /* check whether auto-browsing of volumes is enabled */
+ autobrowse = xfconf_channel_get_bool (context->channel, "/autobrowse/enabled", FALSE);
+ if (autobrowse)
+ {
+ /* try to open the mount point in thunar */
+ result = tvm_run_command (context, mount, "Thunar %m", &err);
}
- /* cleanup */
- g_free (autoipod_command);
+ /* forward errors to the caller */
+ if (err != NULL)
+ g_propagate_error (error, err);
return result;
}
-static gboolean
-tvm_block_device_autophoto (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error)
+static void
+tvm_block_device_mounted (TvmContext *context,
+ GMount *mount,
+ GError **error)
{
- gboolean result = FALSE;
- gboolean autophoto;
- gchar *autophoto_command;
- gint response;
+ gboolean success = FALSE;
+ GError *err = NULL;
+ guint n;
- /* check autophoto support is enabled */
- g_object_get (G_OBJECT (preferences), "autophoto", &autophoto, "autophoto-command", &autophoto_command, NULL);
- if (G_LIKELY (autophoto && autophoto_command != NULL && *autophoto_command != '\0'))
- {
- /* check if we have photos on the volume */
- if (tvm_file_test (mount_point, "dcim", G_FILE_TEST_IS_DIR))
- {
- /* add the "content.photos" capability to this device */
- libhal_device_add_capability (context, udi, "content.photos", NULL);
-
- /* ask the user whether to import photos */
- response = tvm_prompt (context, udi, "camera-photo", _("Photo Import"),
- _("A photo card has been detected."),
- _("There are photos on the card. Would you like to add these photos to your album?"),
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("Import _Photos"), TVM_RESPONSE_PHOTOS,
- NULL);
- if (G_LIKELY (response == TVM_RESPONSE_PHOTOS))
- {
- /* run the preferred application to manage photos */
- result = tvm_run_command (context, udi, autophoto_command, device_file, mount_point, error);
- }
- else
- {
- /* pretend that we handled the device */
- result = TRUE;
- }
- }
- }
- g_free (autophoto_command);
+ g_return_if_fail (context != NULL);
+ g_return_if_fail (G_IS_MOUNT (mount));
+ g_return_if_fail (error == NULL || *error == NULL);
- return result;
+ /* try block device handlers (iPod, cameras etc.) until one succeeds */
+ for (n = 0; !success && n < G_N_ELEMENTS (block_device_handlers); ++n)
+ success = (block_device_handlers[n]) (context, mount, &err);
+
+ /* forward errors to the caller */
+ if (err != NULL)
+ g_propagate_error (error, err);
}
-static gboolean
-tvm_block_device_autorun (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error)
+static void
+tvm_block_device_mount_finish (GVolume *volume,
+ GAsyncResult *result,
+ TvmContext *context)
{
- struct stat statb_mount_point;
- struct stat statb_autoopen;
- gboolean result;
- gboolean autoopen;
- gboolean autoplay;
- gboolean autorun;
- gchar *autoplay_command;
- gchar *path_autoopen;
- gchar line[1024];
- gchar *message;
- gchar *wine;
- gchar **argv;
- FILE *fp;
- gint response;
- gint n;
-
- /* check if autoplay video CDs/DVDs is enabled */
- g_object_get (G_OBJECT (preferences), "autoplay-video-cd", &autoplay, "autoplay-video-cd-command", &autoplay_command, NULL);
- if (G_LIKELY (autoplay))
- {
- /* check if we have a video CD or video DVD here */
- if (tvm_file_test (mount_point, "vcd", G_FILE_TEST_IS_DIR) || tvm_file_test (mount_point, "video_ts", G_FILE_TEST_IS_DIR))
- {
- /* try to spawn the preferred video CD/DVD-Player */
- result = tvm_run_command (context, udi, autoplay_command, device_file, mount_point, error);
- g_free (autoplay_command);
- return result;
- }
- }
- g_free (autoplay_command);
+ GMount *mount;
+ GError *error = NULL;
+
+ g_return_if_fail (G_IS_VOLUME (volume));
+ g_return_if_fail (G_IS_ASYNC_RESULT (result));
+ g_return_if_fail (context != NULL);
+
+ g_debug ("finish");
- /* check if autorun support is enabled */
- g_object_get (G_OBJECT (preferences), "autorun", &autorun, NULL);
- if (G_LIKELY (autorun))
+ /* finish mounting the volume */
+ if (g_volume_mount_finish (volume, result, &error))
{
- /* "Autostart Files" (Desktop Application Autostart Specification) */
- static const gchar *AUTORUN[] = { ".autorun", "autorun", "autorun.sh" };
- for (n = 0; n < G_N_ELEMENTS (AUTORUN); ++n)
+ /* get the moint point of the volume */
+ mount = g_volume_get_mount (volume);
+
+ if (mount != NULL)
{
- /* check if one of the autorun files is present and executable */
- if (tvm_file_test (mount_point, AUTORUN[n], G_FILE_TEST_IS_EXECUTABLE)
- && tvm_file_test (mount_point, AUTORUN[n], G_FILE_TEST_IS_REGULAR))
- {
- /* prompt the user whether to execute this file */
- message = g_strdup_printf (_("Would you like to allow \"%s\" to run?"), AUTORUN[n]);
- response = tvm_prompt (context, udi, "gnome-fs-executable", _("Auto-Run Confirmation"),
- _("Auto-Run capability detected"), message,
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("_Allow Auto-Run"), TVM_RESPONSE_AUTORUN,
- NULL);
- g_free (message);
-
- /* check if we should autorun */
- if (response == TVM_RESPONSE_AUTORUN)
- {
- /* prepare argv to launch autorun file */
- argv = g_new (gchar *, 2);
- argv[0] = g_build_filename (mount_point, AUTORUN[n], NULL);
- argv[1] = NULL;
-
- /* try to launch the autorun file */
- result = g_spawn_async (mount_point, argv, NULL, 0, NULL, NULL, NULL, error);
-
- /* cleanup */
- g_strfreev (argv);
-
- /* outa here */
- return result;
- }
- }
- }
+ /* inspect volume contents and perform actions based on them */
+ tvm_block_device_mounted (context, mount, &error);
- /* check if wine is present */
- wine = g_find_program_in_path ("wine");
- if (G_UNLIKELY (wine != NULL))
+ /* release the mount point */
+ g_object_unref (mount);
+ }
+ else
{
- /* check if we have an autorun.exe file */
- if (tvm_file_test (mount_point, "autorun.exe", G_FILE_TEST_IS_REGULAR))
- {
- /* prompt the user whether to execute this file */
- message = g_strdup_printf (_("Would you like to allow \"%s\" to run?"), "autorun.exe");
- response = tvm_prompt (context, udi, "gnome-fs-executable", _("Auto-Run Confirmation"),
- _("Auto-Run capability detected"), message,
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("_Allow Auto-Run"), TVM_RESPONSE_AUTORUN,
- NULL);
- g_free (message);
-
- /* check if we should autorun */
- if (response == TVM_RESPONSE_AUTORUN)
- {
- /* prepare argv to launch autorun.exe file */
- argv = g_new (gchar *, 3);
- argv[0] = wine;
- argv[1] = g_strdup ("autorun.exe");
- argv[2] = NULL;
-
- /* try to launch the autorun.exe file via wine */
- result = g_spawn_async (mount_point, argv, NULL, 0, NULL, NULL, NULL, error);
-
- /* cleanup */
- g_strfreev (argv);
-
- /* outa here */
- return result;
- }
- }
+ /* could not locate the mount point */
+ g_set_error (&error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Unable to locate mount point"));
}
- g_free (wine);
}
- /* check if autoopen support is enabled */
- g_object_get (G_OBJECT (preferences), "autoopen", &autoopen, NULL);
- if (G_LIKELY (autoopen))
- {
- /* "Autoopen Files" (Desktop Application Autostart Specification) */
- static const gchar *AUTOOPEN[] = { ".autoopen", "autoopen" };
- for (n = 0; n < G_N_ELEMENTS (AUTOOPEN); ++n)
- {
- /* check if one of the autoopen files is present */
- path_autoopen = g_build_filename (mount_point, AUTOOPEN[n], NULL);
- fp = fopen (path_autoopen, "r");
- g_free (path_autoopen);
+ /* release the volume */
+ g_object_unref (volume);
- /* check if the file could be opened */
- if (G_UNLIKELY (fp != NULL))
- {
- /* read the first line of the file (MUST NOT be an absolute path) */
- if (fgets (line, sizeof (line), fp) != NULL && !g_path_is_absolute (line))
- {
- /* determine the absolute path of the file */
- path_autoopen = g_build_filename (mount_point, line, NULL);
-
- /* the file must exist on exactly this device */
- if (stat (mount_point, &statb_mount_point) == 0 && stat (path_autoopen, &statb_autoopen) == 0
- && S_ISREG (statb_autoopen.st_mode) && (statb_autoopen.st_mode & 0111) == 0
- && (statb_mount_point.st_dev == statb_autoopen.st_dev))
- {
- /* prompt the user whether to autoopen this file */
- message = g_strdup_printf (_("Would you like to open \"%s\"?"), AUTOOPEN[n]);
- response = tvm_prompt (context, udi, "gnome-fs-executable", _("Auto-Open Confirmation"),
- _("Auto-Open capability detected"), message,
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("_Open"), TVM_RESPONSE_AUTOOPEN,
- NULL);
- g_free (message);
-
- /* check if we should autoopen */
- if (response == TVM_RESPONSE_AUTOOPEN)
- {
- /* prepare the command to autoopen */
- argv = g_new (gchar *, 3);
- argv[0] = g_strdup ("Thunar");
- argv[1] = path_autoopen;
- argv[2] = NULL;
-
- /* let Thunar open the file */
- result = g_spawn_async (mount_point, argv, NULL, 0, NULL, NULL, NULL, error);
-
- /* cleanup */
- g_free (path_autoopen);
- fclose (fp);
- return result;
- }
- }
-
- /* cleanup */
- g_free (path_autoopen);
- }
-
- /* close the file handle */
- fclose (fp);
- }
- }
- }
+ /* move error information into the context */
+ if (error != NULL)
+ g_propagate_error (context->error, error);
- /* not handled */
- return FALSE;
+ /* finish processing the device */
+ tvm_device_handler_finished (context);
}
-static gboolean
-tvm_block_device_mount (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- GError **error)
+static void
+tvm_block_device_mount (TvmContext *context)
{
- DBusError derror;
- gboolean result = FALSE;
- GSList *mount_points;
- gchar *device_file;
- gchar *argv[4];
- gint status;
-
- /* check if we should ignore the volume, if so, pretend that we succeed */
- if (libhal_device_get_property_bool (context, udi, "volume.ignore", NULL))
- return TRUE;
-
- /* generate the command to mount the device */
- argv[0] = (gchar *) "exo-mount";
- argv[1] = (gchar *) "--hal-udi";
- argv[2] = (gchar *) udi;
- argv[3] = NULL;
-
- /* let exo-mount mount the device */
- if (!g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &status, error))
- {
- /* failed to spawn the exo-mount command */
- return FALSE;
- }
- else if (!WIFEXITED (status) || WEXITSTATUS (status) != 0)
- {
- /* exo-mount failed, but already displayed an error */
- return TRUE;
- }
-
- /* initalize D-Bus error */
- dbus_error_init (&derror);
-
- /* successfully mounted the device, determine the device file */
- device_file = libhal_device_get_property_string (context, udi, "block.device", &derror);
- if (G_UNLIKELY (device_file == NULL))
- {
- /* propagate the error */
- dbus_set_g_error (error, &derror);
- return FALSE;
- }
-
- /* determine the active mount point(s) for the device from the kernel */
- mount_points = exo_mount_point_list_matched (EXO_MOUNT_POINT_MATCH_ACTIVE | EXO_MOUNT_POINT_MATCH_DEVICE, device_file, NULL, NULL, error);
- if (G_LIKELY (mount_points != NULL))
- {
- /* try to handled the mounted volume */
- result = tvm_block_device_mounted (preferences, context, udi, device_file, ((ExoMountPoint *) mount_points->data)->folder, error);
-
- /* release the mount points */
- g_slist_foreach (mount_points, (GFunc) exo_mount_point_free, NULL);
- g_slist_free (mount_points);
- }
-
- /* release the device file */
- libhal_free_string (device_file);
-
- return result;
-}
-
+ GMountOperation *mount_operation;
+ GVolume *volume;
+ g_return_if_fail (context != NULL);
+ /* determine the GVolume corresponding to the udev device */
+ volume =
+ tvm_g_volume_monitor_get_volume_for_kind (context->monitor,
+ G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE,
+ g_udev_device_get_device_file (context->device));
-static gboolean
-tvm_block_device_mounted (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error)
-{
- gboolean autobrowse;
- gboolean result;
- GError *err = NULL;
-
- /* check if we have a portable media player here */
- result = tvm_block_device_autoipod (preferences, context, udi, device_file, mount_point, &err);
- if (G_LIKELY (!result && err == NULL))
+ /* check if we have a volume */
+ if (volume != NULL)
{
- /* check if we have a digital photo camera here */
- result = tvm_block_device_autophoto (preferences, context, udi, device_file, mount_point, &err);
- if (G_LIKELY (!result && err == NULL))
+ /* check if we can mount the volume */
+ if (g_volume_can_mount (volume))
{
- /* try autorun (video CD/DVD, autoopen, etc.) first */
- result = tvm_block_device_autorun (preferences, context, udi, device_file, mount_point, &err);
- if (G_LIKELY (!result && err == NULL))
- {
- /* check if we should autobrowse the mount point folder */
- g_object_get (G_OBJECT (preferences), "autobrowse", &autobrowse, NULL);
- if (G_LIKELY (autobrowse))
- {
- /* open the mount point folder in Thunar */
- result = tvm_run_command (context, udi, "Thunar %m", device_file, mount_point, &err);
- }
- }
+ /* try to mount the volume asynchronously */
+ mount_operation = gtk_mount_operation_new (NULL);
+ g_volume_mount (volume, G_MOUNT_MOUNT_NONE, mount_operation,
+ NULL, (GAsyncReadyCallback) tvm_block_device_mount_finish, context);
+ g_object_unref (mount_operation);
+ }
+ else
+ {
+ g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Unable to mount the device"));
+
+ /* finish processing the device */
+ tvm_device_handler_finished (context);
}
}
-
- /* check if we need to propagate an error */
- if (G_UNLIKELY (err != NULL))
+ else
{
- /* propagate the error */
- g_propagate_error (error, err);
- result = FALSE;
+ g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Could not detect the volume corresponding to the device"));
+
+ /* finish processing the device */
+ tvm_device_handler_finished (context);
}
-
- return result;
}
-/**
- * tvm_block_device_added:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the HAL device UDI of the newly added block device.
- * @capability : the capability, which caused this handler to be run.
- * @error : return location for errors or %NULL.
- *
- * See #TvmDeviceCallback for further information.
- *
- * Return value: %TRUE if handled, %FALSE if not handled or an
- * unrecoverable error occurred.
- **/
-gboolean
-tvm_block_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error)
+void
+tvm_block_device_added (TvmContext *context)
{
- DBusError derror;
- gboolean disc_has_audio;
- gboolean disc_has_data;
- gboolean automount;
- gboolean autoplay;
- gboolean is_cdrom;
- gboolean has_filesystem;
- gboolean has_crypto;
- gchar *storage_udi;
- gchar *drive_type;
- gchar *fsusage;
- gint response;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (capability != NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- /* initialize D-Bus error */
- dbus_error_init (&derror);
-
- /* verify that we have a mountable volume here */
- if (!libhal_device_get_property_bool (context, udi, "block.is_volume", &derror))
- {
-err0: /* check if we have an error to propagate */
- if (dbus_error_is_set (&derror))
- {
- /* propagate the error */
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- }
-
- return FALSE;
- }
-
- /* determine the HAL UDI of the backing storage device */
- storage_udi = libhal_device_get_property_string (context, udi, "block.storage_device", &derror);
- if (G_UNLIKELY (storage_udi == NULL))
- goto err0;
-
- /* if the partition_table_changed flag is set, we don't want to mount as a partitioning tool might be modifying this device */
- if (libhal_device_get_property_bool (context, storage_udi, "storage.partition_table_changed", NULL))
+ const gchar *devtype;
+ const gchar *id_type;
+ const gchar *media_state;
+ const gchar *id_fs_usage;
+ gboolean is_cdrom;
+ gboolean is_partition;
+ gboolean is_volume;
+ guint64 audio_tracks;
+
+ g_return_if_fail (context != NULL);
+
+ /* collect general device information */
+ devtype = g_udev_device_get_devtype (context->device);
+ id_type = g_udev_device_get_property (context->device, "ID_TYPE");
+ id_fs_usage = g_udev_device_get_property (context->device, "ID_FS_USAGE");
+
+ /* distinguish device types */
+ is_cdrom = (g_strcmp0 (id_type, "cd") == 0);
+ is_partition = (g_strcmp0 (devtype, "partition") == 0);
+ is_volume = (g_strcmp0 (devtype, "disk") == 0)
+ && (g_strcmp0 (id_fs_usage, "filesystem") == 0);
+
+ if (is_cdrom)
{
-err1: libhal_free_string (storage_udi);
- goto err0;
- }
-
- /* check if this device supports removable media */
- if (libhal_device_get_property_bool (context, storage_udi, "storage.removable", NULL))
- {
- /* check if the device is locked */
- if (libhal_device_get_property_bool (context, storage_udi, "info.locked", NULL))
+ /* silently ignore CD drives without media */
+ if (g_udev_device_get_property_as_boolean (context->device, "ID_CDROM_MEDIA"))
{
- /* pretend that we handled the device */
- libhal_free_string (storage_udi);
- return TRUE;
- }
-
- /* determine the drive type */
- drive_type = libhal_device_get_property_string (context, storage_udi, "storage.drive_type", &derror);
- if (G_UNLIKELY (drive_type == NULL))
- goto err1;
-
- /* check if we have a CD-ROM here */
- is_cdrom = (strcmp (drive_type, "cdrom") == 0);
-
- /* we don't need the storage UDI any more */
- libhal_free_string (storage_udi);
-
- /* free the drive type */
- libhal_free_string (drive_type);
-
- /* CD-ROMs deserve special handling */
- if (G_LIKELY (is_cdrom))
- {
- /* check for blank discs */
- if (libhal_device_get_property_bool (context, udi, "volume.disc.is_blank", NULL))
+ /* collect CD information */
+ media_state = g_udev_device_get_property (context->device,
+ "ID_CDROM_MEDIA_STATE");
+ audio_tracks =
+ g_udev_device_get_property_as_uint64 (context->device,
+ "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO");
+
+ if (g_strcmp0 (media_state, "blank") == 0)
{
- /* run the preferred CD-Burner application */
- return tvm_run_cdburner (preferences, context, udi, error);
+#if 0
+ tvm_run_burn_software (client, device, channel, &error);
+#endif
+ }
+ else if (audio_tracks > 0)
+ {
+#if 0
+ /* TODO detect mixed CDs with audio AND data tracks */
+ tvm_run_cd_player (client, device, channel, &error);
+#endif
}
else
{
- /* check if we have DATA/AUDIO tracks */
- disc_has_audio = libhal_device_get_property_bool (context, udi, "volume.disc.has_audio", NULL);
- disc_has_data = libhal_device_get_property_bool (context, udi, "volume.disc.has_data", NULL);
- if (G_UNLIKELY (disc_has_audio && disc_has_data))
- {
- /* check if we need to prompt the user */
- g_object_get (G_OBJECT (preferences), "automount-media", &automount, "autoplay-audio-cd", &autoplay, NULL);
- if (G_LIKELY (automount && autoplay))
- {
- /* ask what do with the mixed audio/data disc */
- response = tvm_prompt (context, udi, "gnome-dev-cdrom-audio", _("Audio / Data CD"),
- _("The CD in the drive contains both music and files."),
- _("Would you like to listen to music or browse the files?"),
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("_Browse Files"), TVM_RESPONSE_BROWSE,
- _("_Play CD"), TVM_RESPONSE_PLAY,
- NULL);
- switch (response)
- {
- case TVM_RESPONSE_PLAY:
- goto autoplay_disc;
-
- case TVM_RESPONSE_BROWSE:
- goto automount_disc;
-
- default:
- break;
- }
- }
- else if (automount)
- {
- /* just automount the media */
- goto automount_disc;
- }
- else if (autoplay)
- {
- /* just autoplay the disc */
- goto autoplay_disc;
- }
- }
- else if (G_LIKELY (disc_has_audio))
- {
-autoplay_disc: /* run the preferred CD-Player application */
- return tvm_run_cdplayer (preferences, context, udi, error);
- }
- else if (G_LIKELY (disc_has_data))
- {
-automount_disc: /* check if we should automount removable media */
- g_object_get (G_OBJECT (preferences), "automount-media", &automount, NULL);
- if (G_LIKELY (automount))
- {
- /* try to mount the CD-ROM in the disc */
- return tvm_block_device_mount (preferences, context, udi, error);
- }
- }
+ /* mount the CD/DVD and continue with inspecting its contents */
+ tvm_block_device_mount (context);
}
}
}
- else
+ else if (is_partition || is_volume)
{
- /* we don't need the storage UDI any more */
- libhal_free_string (storage_udi);
+ /* mount the partition and continue with inspecting its contents */
+ tvm_block_device_mount (context);
}
-
- /* determine the file system usage of the volume */
- fsusage = libhal_device_get_property_string (context, udi, "volume.fsusage", NULL);
- has_crypto = (G_UNLIKELY (fsusage != NULL && strcmp (fsusage, "crypto") == 0));
- has_filesystem = (G_LIKELY (fsusage != NULL && strcmp (fsusage, "filesystem") == 0));
- libhal_free_string (fsusage);
-
- /* check if we have a crypto volume to setup here */
- if (G_UNLIKELY (has_crypto))
- {
- /* try to setup the crypto volume */
- return tvm_crypto_volume_setup (preferences, context, udi, error);
- }
- else if (G_LIKELY (has_filesystem))
+ else
{
- /* check if we should automount drives, otherwise, we're done here */
- g_object_get (G_OBJECT (preferences), "automount-drives", &automount, NULL);
- if (G_UNLIKELY (!automount))
- return FALSE;
+ /* generate an error for logging */
+ g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Unknown block device type"));
- /* try to mount the block device */
- return tvm_block_device_mount (preferences, context, udi, error);
+ /* finish processing the device */
+ tvm_device_handler_finished (context);
}
-
- return FALSE;
}
-
-
-
-
diff --git a/thunar-volman/tvm-block-device.h b/thunar-volman/tvm-block-device.h
index 2f51e6a..5f6f1d7 100644
--- a/thunar-volman/tvm-block-device.h
+++ b/thunar-volman/tvm-block-device.h
@@ -1,34 +1,34 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@xfce.org>.
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option)
- * any later version.
+ * 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 (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifndef __TVM_BLOCK_DEVICE_H__
#define __TVM_BLOCK_DEVICE_H__
+#include <glib.h>
+
+#include <thunar-volman/tvm-context.h>
#include <thunar-volman/tvm-device.h>
G_BEGIN_DECLS
-gboolean tvm_block_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error) G_GNUC_INTERNAL;
+void tvm_block_device_added (TvmContext *context);
G_END_DECLS
diff --git a/thunar-volman/tvm-camera-device.c b/thunar-volman/tvm-camera-device.c
deleted file mode 100644
index fb04a5a..0000000
--- a/thunar-volman/tvm-camera-device.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <thunar-volman/tvm-camera-device.h>
-#include <thunar-volman/tvm-prompt.h>
-#include <thunar-volman/tvm-run.h>
-
-
-
-/**
- * tvm_block_camera_added:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the HAL device UDI of the newly added camera device.
- * @capability : the capability, which caused this handler to be run.
- * @error : return location for errors or %NULL.
- *
- * See #TvmDeviceCallback for further information.
- *
- * Return value: %TRUE if handled, %FALSE if not handled or an
- * unrecoverable error occurred.
- **/
-gboolean
-tvm_camera_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error)
-{
- gboolean result = FALSE;
- gboolean autophoto;
- gchar *autophoto_command;
- gchar *access_method;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (capability != NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- /* check if this is a non-mass-storage camera device, handled by gphoto2 */
- access_method = libhal_device_get_property_string (context, udi, "camera.access_method", NULL);
- if ((access_method != NULL && strcmp (access_method, "ptp") == 0)
- || libhal_device_get_property_bool (context, udi, "camera.libgphoto2.support", NULL))
- {
- /* check if autophoto support is enabled */
- g_object_get (G_OBJECT (preferences), "autophoto", &autophoto, "autophoto-command", &autophoto_command, NULL);
- if (G_LIKELY (autophoto && autophoto_command != NULL && *autophoto_command != '\0'))
- {
- /* run the preferred photo management application */
- result = tvm_run_command (context, udi, autophoto_command, NULL, NULL, error);
- }
- g_free (autophoto_command);
- }
- libhal_free_string (access_method);
-
- return result;
-}
-
-
-
-
diff --git a/thunar-volman/tvm-camera-device.h b/thunar-volman/tvm-camera-device.h
deleted file mode 100644
index df09a27..0000000
--- a/thunar-volman/tvm-camera-device.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_CAMERA_DEVICE_H__
-#define __TVM_CAMERA_DEVICE_H__
-
-#include <thunar-volman/tvm-device.h>
-
-G_BEGIN_DECLS
-
-gboolean tvm_camera_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error) G_GNUC_INTERNAL;
-
-G_END_DECLS
-
-#endif /* !__TVM_CAMERA_DEVICE_H__ */
diff --git a/thunar-volman/tvm-command-entry.c b/thunar-volman/tvm-command-entry.c
deleted file mode 100644
index 8f2e349..0000000
--- a/thunar-volman/tvm-command-entry.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2005-2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <thunar-volman/tvm-command-entry.h>
-
-
-
-/* Property identifiers */
-enum
-{
- PROP_0,
- PROP_COMMAND,
-};
-
-
-
-static void tvm_command_entry_class_init (TvmCommandEntryClass *klass);
-static void tvm_command_entry_init (TvmCommandEntry *command_entry);
-static void tvm_command_entry_finalize (GObject *object);
-static void tvm_command_entry_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void tvm_command_entry_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void tvm_command_entry_clicked (GtkWidget *button,
- TvmCommandEntry *command_entry);
-
-
-
-static GObjectClass *tvm_command_entry_parent_class;
-
-
-
-GType
-tvm_command_entry_get_type (void)
-{
- static GType type = G_TYPE_INVALID;
-
- if (G_UNLIKELY (type == G_TYPE_INVALID))
- {
- static const GTypeInfo info =
- {
- sizeof (TvmCommandEntryClass),
- NULL,
- NULL,
- (GClassInitFunc) tvm_command_entry_class_init,
- NULL,
- NULL,
- sizeof (TvmCommandEntry),
- 0,
- (GInstanceInitFunc) tvm_command_entry_init,
- NULL,
- };
-
- type = g_type_register_static (GTK_TYPE_HBOX, I_("TvmCommandEntry"), &info, 0);
- }
-
- return type;
-}
-
-
-
-static void
-tvm_command_entry_class_init (TvmCommandEntryClass *klass)
-{
- GObjectClass *gobject_class;
-
- /* determine the parent type class */
- tvm_command_entry_parent_class = g_type_class_peek_parent (klass);
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = tvm_command_entry_finalize;
- gobject_class->get_property = tvm_command_entry_get_property;
- gobject_class->set_property = tvm_command_entry_set_property;
-
- /**
- * TvmCommandEntry:command:
- *
- * The command currently entered into this command entry widget.
- **/
- g_object_class_install_property (gobject_class,
- PROP_COMMAND,
- g_param_spec_string ("command",
- "command",
- "command",
- NULL,
- EXO_PARAM_READWRITE));
-}
-
-
-
-static void
-tvm_command_entry_init (TvmCommandEntry *command_entry)
-{
- GtkWidget *button;
- GtkWidget *align;
- GtkWidget *image;
-
- gtk_box_set_spacing (GTK_BOX (command_entry), 2);
-
- align = g_object_new (GTK_TYPE_ALIGNMENT, "width-request", 10, NULL);
- gtk_box_pack_start (GTK_BOX (command_entry), align, FALSE, FALSE, 0);
- gtk_widget_show (align);
-
- command_entry->label = g_object_new (GTK_TYPE_LABEL, "use-underline", TRUE, "xalign", 0.0f, NULL);
- gtk_box_pack_start (GTK_BOX (command_entry), command_entry->label, FALSE, FALSE, 10);
- gtk_widget_show (command_entry->label);
-
- command_entry->entry = gtk_entry_new ();
- gtk_label_set_mnemonic_widget (GTK_LABEL (command_entry->label), command_entry->entry);
- exo_mutual_binding_new (G_OBJECT (command_entry->entry), "text", G_OBJECT (command_entry), "command");
- gtk_box_pack_start (GTK_BOX (command_entry), command_entry->entry, TRUE, TRUE, 0);
- gtk_widget_show (command_entry->entry);
-
- button = gtk_button_new ();
- g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (tvm_command_entry_clicked), command_entry);
- gtk_box_pack_start (GTK_BOX (command_entry), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
-
- image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_show (image);
-}
-
-
-
-static void
-tvm_command_entry_finalize (GObject *object)
-{
- TvmCommandEntry *command_entry = TVM_COMMAND_ENTRY (object);
-
- /* cleanup properties */
- g_free (command_entry->command);
-
- (*G_OBJECT_CLASS (tvm_command_entry_parent_class)->finalize) (object);
-}
-
-
-
-static void
-tvm_command_entry_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- TvmCommandEntry *command_entry = TVM_COMMAND_ENTRY (object);
-
- switch (prop_id)
- {
- case PROP_COMMAND:
- g_value_set_string (value, tvm_command_entry_get_command (command_entry));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static void
-tvm_command_entry_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- TvmCommandEntry *command_entry = TVM_COMMAND_ENTRY (object);
-
- switch (prop_id)
- {
- case PROP_COMMAND:
- tvm_command_entry_set_command (command_entry, g_value_get_string (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-
-static void
-tvm_command_entry_clicked (GtkWidget *button,
- TvmCommandEntry *command_entry)
-{
- GtkFileFilter *filter;
- GtkWidget *toplevel;
- GtkWidget *chooser;
- gchar *filename;
- gchar *s;
-
- g_return_if_fail (GTK_IS_BUTTON (button));
- g_return_if_fail (TVM_IS_COMMAND_ENTRY (command_entry));
-
- /* determine the toplevel widget */
- toplevel = gtk_widget_get_toplevel (button);
- if (toplevel == NULL || !GTK_WIDGET_TOPLEVEL (toplevel))
- return;
-
- chooser = gtk_file_chooser_dialog_new (_("Select an Application"),
- GTK_WINDOW (toplevel),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE);
-
- /* add file chooser filters */
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("All Files"));
- gtk_file_filter_add_pattern (filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Executable Files"));
- gtk_file_filter_add_mime_type (filter, "application/x-csh");
- gtk_file_filter_add_mime_type (filter, "application/x-executable");
- gtk_file_filter_add_mime_type (filter, "application/x-perl");
- gtk_file_filter_add_mime_type (filter, "application/x-python");
- gtk_file_filter_add_mime_type (filter, "application/x-ruby");
- gtk_file_filter_add_mime_type (filter, "application/x-shellscript");
- gtk_file_filter_add_pattern (filter, "*.pl");
- gtk_file_filter_add_pattern (filter, "*.py");
- gtk_file_filter_add_pattern (filter, "*.rb");
- gtk_file_filter_add_pattern (filter, "*.sh");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Perl Scripts"));
- gtk_file_filter_add_mime_type (filter, "application/x-perl");
- gtk_file_filter_add_pattern (filter, "*.pl");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Python Scripts"));
- gtk_file_filter_add_mime_type (filter, "application/x-python");
- gtk_file_filter_add_pattern (filter, "*.py");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Ruby Scripts"));
- gtk_file_filter_add_mime_type (filter, "application/x-ruby");
- gtk_file_filter_add_pattern (filter, "*.rb");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Shell Scripts"));
- gtk_file_filter_add_mime_type (filter, "application/x-csh");
- gtk_file_filter_add_mime_type (filter, "application/x-shellscript");
- gtk_file_filter_add_pattern (filter, "*.sh");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
-
- /* use the bindir as default folder */
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), BINDIR);
-
- /* setup the currently selected file */
- g_object_get (G_OBJECT (command_entry), "command", &filename, NULL);
- if (G_LIKELY (filename != NULL))
- {
- /* use only the first argument */
- s = strchr (filename, ' ');
- if (G_UNLIKELY (s != NULL))
- *s = '\0';
-
- /* check if we have a file name */
- if (G_LIKELY (*filename != '\0'))
- {
- /* check if the filename is not an absolute path */
- if (G_LIKELY (!g_path_is_absolute (filename)))
- {
- /* try to lookup the filename in $PATH */
- s = g_find_program_in_path (filename);
- if (G_LIKELY (s != NULL))
- {
- /* use the absolute path instead */
- g_free (filename);
- filename = s;
- }
- }
-
- /* check if we have an absolute path now */
- if (G_LIKELY (g_path_is_absolute (filename)))
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), filename);
- }
-
- /* release the filename */
- g_free (filename);
- }
-
- /* run the chooser dialog */
- if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
- {
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
- tvm_command_entry_set_command (command_entry, filename);
- g_free (filename);
- }
-
- gtk_widget_destroy (chooser);
-}
-
-
-
-/**
- * tvm_command_entry_new:
- *
- * Allocates a new #TvmCommandEntry instance.
- *
- * Return value: the newly allocated #TvmCommandEntry.
- **/
-GtkWidget*
-tvm_command_entry_new (void)
-{
- return g_object_new (TVM_TYPE_COMMAND_ENTRY, NULL);
-}
-
-
-
-/**
- * tvm_command_entry_new:
- * @label : the label for the command entry.
- *
- * Allocates a new #TvmCommandEntry instance with the @label.
- *
- * Return value: the newly allocated #TvmCommandEntry.
- **/
-GtkWidget*
-tvm_command_entry_new_with_label (const gchar *label)
-{
- TvmCommandEntry *entry;
-
- g_return_val_if_fail (label == NULL || g_utf8_validate (label, -1, NULL), NULL);
-
- entry = g_object_new (TVM_TYPE_COMMAND_ENTRY, NULL);
- if (G_LIKELY (label != NULL))
- g_object_set (G_OBJECT (entry->label), "label", label, "use-underline", TRUE, NULL);
- return GTK_WIDGET (entry);
-}
-
-
-
-/**
- * tvm_command_entry_get_command:
- * @command_entry : a #TvmCommandEntry.
- *
- * Returns the command of the @command_entry.
- *
- * Return value: the command in the @command_entry.
- **/
-const gchar*
-tvm_command_entry_get_command (TvmCommandEntry *command_entry)
-{
- g_return_val_if_fail (TVM_IS_COMMAND_ENTRY (command_entry), NULL);
- return command_entry->command;
-}
-
-
-
-/**
- * tvm_command_entry_set_command:
- * @command_entry : a #TvmCommandEntry.
- * @command : the new command.
- *
- * Sets the command in @command_entry to @command.
- **/
-void
-tvm_command_entry_set_command (TvmCommandEntry *command_entry,
- const gchar *command)
-{
- g_return_if_fail (TVM_IS_COMMAND_ENTRY (command_entry));
- g_return_if_fail (g_utf8_validate (command, -1, NULL));
-
- /* update to the new command */
- g_free (command_entry->command);
- command_entry->command = g_strdup (command);
- g_object_notify (G_OBJECT (command_entry), "command");
-}
-
diff --git a/thunar-volman/tvm-command-entry.h b/thunar-volman/tvm-command-entry.h
deleted file mode 100644
index 73b213f..0000000
--- a/thunar-volman/tvm-command-entry.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2005-2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_COMMAND_ENTRY_H__
-#define __TVM_COMMAND_ENTRY_H__
-
-#include <exo/exo.h>
-
-G_BEGIN_DECLS
-
-typedef struct _TvmCommandEntryClass TvmCommandEntryClass;
-typedef struct _TvmCommandEntry TvmCommandEntry;
-
-#define TVM_TYPE_COMMAND_ENTRY (tvm_command_entry_get_type ())
-#define TVM_COMMAND_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TVM_TYPE_COMMAND_ENTRY, TvmCommandEntry))
-#define TVM_COMMAND_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TVM_TYPE_COMMAND_ENTRY, TvmCommandEntryClass))
-#define TVM_IS_COMMAND_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TVM_TYPE_COMMAND_ENTRY))
-#define TVM_IS_COMMAND_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TVM_TYPE_COMMAND_ENTRY))
-#define TVM_COMMAND_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TVM_TYPE_COMMAND_ENTRY, TvmCommandEntryClass))
-
-struct _TvmCommandEntryClass
-{
- GtkHBoxClass __parent__;
-};
-
-struct _TvmCommandEntry
-{
- GtkHBox __parent__;
- GtkWidget *entry;
- GtkWidget *label;
- gchar *command;
-};
-
-GType tvm_command_entry_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
-
-GtkWidget *tvm_command_entry_new (void) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-GtkWidget *tvm_command_entry_new_with_label (const gchar *label) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-
-const gchar *tvm_command_entry_get_command (TvmCommandEntry *command_entry) G_GNUC_INTERNAL;
-void tvm_command_entry_set_command (TvmCommandEntry *command_entry,
- const gchar *command) G_GNUC_INTERNAL;
-
-G_END_DECLS
-
-#endif /* !__TVM_COMMAND_ENTRY_H__ */
diff --git a/thunar-volman/tvm-context.c b/thunar-volman/tvm-context.c
new file mode 100644
index 0000000..8685f70
--- /dev/null
+++ b/thunar-volman/tvm-context.c
@@ -0,0 +1,93 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <gudev/gudev.h>
+
+#include <xfconf/xfconf.h>
+
+#include <thunar-volman/tvm-context.h>
+#include <thunar-volman/tvm-device.h>
+
+
+
+TvmContext *
+tvm_context_new (GUdevClient *client,
+ GUdevDevice *device,
+ XfconfChannel *channel,
+ GMainLoop *loop,
+ GError **error)
+{
+ TvmContext *context;
+
+ g_return_val_if_fail (G_UDEV_IS_CLIENT (client), NULL);
+ g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL);
+ g_return_val_if_fail (XFCONF_IS_CHANNEL (channel), NULL);
+ g_return_val_if_fail (loop != NULL, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ context = g_slice_new0 (TvmContext);
+
+ context->client = g_object_ref (client);
+ context->device = g_object_ref (device);
+ context->channel = g_object_ref (channel);
+ context->error = error;
+ context->loop = g_main_loop_ref (loop);
+ context->handlers = NULL;
+ context->monitor = g_volume_monitor_get ();
+
+ return context;
+}
+
+
+
+void
+tvm_context_free (TvmContext *context)
+{
+ if (context == NULL)
+ return;
+
+ g_main_loop_unref (context->loop);
+
+ g_list_free (context->handlers);
+
+ g_object_unref (context->monitor);
+ g_object_unref (context->channel);
+ g_object_unref (context->device);
+ g_object_unref (context->client);
+
+ g_slice_free (TvmContext, context);
+}
+
+
+
+gboolean
+tvm_context_run (TvmContext *context)
+{
+ tvm_device_added (context);
+
+ return FALSE;
+}
diff --git a/thunar-volman/tvm-context.h b/thunar-volman/tvm-context.h
new file mode 100644
index 0000000..9dbd33e
--- /dev/null
+++ b/thunar-volman/tvm-context.h
@@ -0,0 +1,59 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TVM_CONTEXT_H__
+#define __TVM_CONTEXT_H__
+
+#include <gio/gio.h>
+
+#include <gudev/gudev.h>
+
+#include <xfconf/xfconf.h>
+
+G_BEGIN_DECLS
+
+typedef struct _TvmContext TvmContext;
+
+
+
+TvmContext *tvm_context_new (GUdevClient *client,
+ GUdevDevice *device,
+ XfconfChannel *channel,
+ GMainLoop *loop,
+ GError **error) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+void tvm_context_free (TvmContext *context);
+gboolean tvm_context_run (TvmContext *context);
+
+
+
+struct _TvmContext
+{
+ GVolumeMonitor *monitor;
+ XfconfChannel *channel;
+ GUdevClient *client;
+ GUdevDevice *device;
+ GMainLoop *loop;
+ GError **error;
+ GList *handlers;
+};
+
+G_END_DECLS
+
+#endif /* !__TVM_CONTEXT_H__ */
diff --git a/thunar-volman/tvm-crypto-volume.c b/thunar-volman/tvm-crypto-volume.c
deleted file mode 100644
index 550089e..0000000
--- a/thunar-volman/tvm-crypto-volume.c
+++ /dev/null
@@ -1,483 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2008 Benedikt Meurer <benny@xfce.org>.
- * Copyright (c) 2008 Colin Leroy <colin@colino.net>.
- *
- * 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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#include <errno.h>
-
-#include <dbus/dbus-glib-lowlevel.h>
-#include <thunar-volman/tvm-block-device.h>
-#include <thunar-volman/tvm-crypto-volume.h>
-#include <libhal-storage.h>
-
-static void
-tvm_crypto_volume_prompt_update_text (GtkEditable *editable,
- gchar *new_text,
- gint new_text_len,
- gint *position,
- gpointer data)
-{
- gchar **response = (gchar **)data;
- if (response == NULL)
- return;
- g_free(*response);
- *response = gtk_editable_get_chars(editable, 0, -1);
-}
-
-typedef struct _CryptoDialogValidate {
- GtkWidget *dialog;
- gint response;
-} CryptoDialogValidate;
-
-void
-tvm_crypto_volume_prompt_validate_text (GtkEntry *entry,
- gpointer data)
-{
- CryptoDialogValidate *validate_data = (CryptoDialogValidate *)data;
- gtk_dialog_response(GTK_DIALOG(validate_data->dialog), validate_data->response);
-}
-
-static void
-tvm_crypto_volume_hal_device_removed (LibHalContext *context,
- const gchar *udi)
-{
- const gchar *dialog_udi;
- GtkWidget *dialog = libhal_ctx_get_user_data (context);
-
- /* check if the active UDI of the dialog was removed */
- dialog_udi = g_object_get_data (G_OBJECT (dialog), "udi");
- if (exo_str_is_equal (dialog_udi, udi))
- {
- /* cancel the dialog */
- gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
- }
-}
-
- /**
- * tvm_crypto_volume_ask_password:
- * @context : a #LibHalContext.
- * @udi : the UDI of the device being added, which is watched for removal.
- * @icon : the icon or %NULL.
- * @title : the prompt title.
- * @response_text : the response text.
- * @visible : whether text typed should be visible.
- * @default_response : Which response to return on Enter.
- * @primary_text : the primary prompt text.
- * @secondary_text : the secondary prompt text.
- * @first_button_text : the first button text.
- * @... : %NULL-terminated list of button text, response id pairs.
- *
- * Return value: the selected response.
- **/
-static gint
-tvm_crypto_volume_ask_password (LibHalContext *context,
- const gchar *udi,
- const gchar *icon,
- const gchar *title,
- gchar **response_text,
- gboolean visible,
- gint default_response,
- const gchar *primary_text,
- const gchar *secondary_text,
- const gchar *first_button_text,
- ...)
-{
- GtkWidget *dialog;
- GtkWidget *image;
- GtkWidget *label;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *entry;
- DBusError derror;
- va_list args;
- gint response;
- CryptoDialogValidate validate_data;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), 0);
- g_return_val_if_fail (context != NULL, GTK_RESPONSE_CANCEL);
-
- /* allocate a new dialog */
- dialog = gtk_dialog_new ();
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- g_object_set_data_full (G_OBJECT (dialog), "udi", g_strdup (udi), g_free);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 6);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12);
-
- /* setup the specified title */
- if (G_LIKELY (title != NULL))
- gtk_window_set_title (GTK_WINDOW (dialog), title);
-
- /* setup the specified buttons */
- if (G_LIKELY (first_button_text != NULL))
- {
- va_start (args, first_button_text);
- for (response = va_arg (args, gint); first_button_text != NULL; )
- {
- /* insert the button */
- gtk_dialog_add_button (GTK_DIALOG (dialog), first_button_text, response);
- first_button_text = va_arg (args, const gchar *);
- if (G_UNLIKELY (first_button_text == NULL))
- break;
- response = va_arg (args, gint);
- }
- va_end (args);
- }
-
- /* setup the hbox */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- /* setup the specified icon */
- if (G_LIKELY (icon != NULL))
- {
- /* setup an image for the icon */
- image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.0f, 0.0f);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
- gtk_widget_show (image);
- }
-
- /* setup the vbox */
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
- gtk_widget_show (vbox);
- g_object_set_data(G_OBJECT(dialog), "main_vbox", vbox);
-
- /* setup the primary text */
- label = gtk_label_new (primary_text);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- /* setup the secondary text */
- if (G_LIKELY (secondary_text != NULL))
- {
- label = gtk_label_new (secondary_text);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
- g_object_set_data(G_OBJECT(dialog), "secondary_text", label);
- }
-
- entry = gtk_entry_new();
- gtk_entry_set_visibility(GTK_ENTRY(entry), visible);
- gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
- gtk_widget_show (entry);
- g_object_set_data(G_OBJECT(dialog), "pass_entry", entry);
-
- /* initialize D-Bus error */
- dbus_error_init (&derror);
-
- /* setup HAL to watch the UDI for removal */
- libhal_ctx_set_user_data (context, dialog);
- libhal_ctx_set_device_removed (context, tvm_crypto_volume_hal_device_removed);
- libhal_device_property_watch_all (context, &derror);
-
- /* setup handler for the entered text */
- if (response_text)
- *response_text = NULL;
- g_signal_connect_after(G_OBJECT(entry), "insert-text",
- G_CALLBACK(tvm_crypto_volume_prompt_update_text),
- (gpointer) response_text);
- validate_data.dialog = dialog;
- validate_data.response = default_response;
- g_signal_connect(G_OBJECT(entry), "activate",
- G_CALLBACK(tvm_crypto_volume_prompt_validate_text),
- (gpointer) &validate_data);
-
- /* run the dialog */
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy(dialog);
-
- /* cleanup */
- libhal_ctx_set_device_removed (context, NULL);
- libhal_ctx_set_user_data (context, NULL);
- dbus_error_free (&derror);
-
- return response;
-}
-
-static gboolean
-progress_pulse(gpointer data)
-{
- GtkProgressBar *progress = GTK_PROGRESS_BAR(data);
- g_return_val_if_fail(progress != NULL, FALSE);
-
- gtk_progress_bar_pulse(progress);
-
- return TRUE;
-}
-
-static void
-tvm_crypto_volume_dbus_call_done (DBusPendingCall *call,
- void *user_data)
-{
- gtk_main_quit();
-}
-
-static gchar *
-tvm_crypto_volume_mount_install_crypto_volume (LibHalContext *context,
- const gchar *udi,
- LibHalVolume *volume,
- const gchar *password,
- gboolean *pass_error,
- GError **error)
-{
- gchar *plain_udi = NULL;
- DBusMessage *message = NULL;
- DBusMessage *result = NULL;
- DBusConnection *dbus_connection = NULL;
- DBusPendingCall *call = NULL;
- DBusError derror;
- dbus_bool_t send_err;
- *pass_error = FALSE;
- GtkWidget *window = NULL;
- GtkWidget *label, *vbox, *hbox;
- GtkWidget *wait_progress;
- GtkWidget *image;
- guint animator_id;
- g_clear_error(error);
-
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_container_set_border_width(GTK_CONTAINER(window), 8);
- gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
- gtk_window_set_title(GTK_WINDOW(window), _("Encrypted volume"));
- gtk_window_set_modal(GTK_WINDOW(window), TRUE);
- gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
-
- vbox = gtk_vbox_new(FALSE, 6);
- hbox = gtk_hbox_new(FALSE, 6);
- image = gtk_image_new_from_icon_name ("gtk-dialog-authentication", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.0f, 0.0f);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
- gtk_widget_show (image);
-
- label = gtk_label_new(_("<span weight=\"bold\" size=\"larger\">Mounting encrypted volume...</span>"));
- gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 0);
-
- label = gtk_label_new(_("Setting up the crypto layer..."));
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 0);
-
- wait_progress = gtk_progress_bar_new();
- gtk_box_pack_start(GTK_BOX(vbox), wait_progress, TRUE, FALSE, 0);
-
- gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
-
- gtk_container_add(GTK_CONTAINER(window), hbox);
- gtk_widget_show_all(hbox);
- animator_id = g_timeout_add(100, progress_pulse, wait_progress);
-
- gtk_widget_show_now(window);
-
- message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
- "org.freedesktop.Hal.Device.Volume.Crypto",
- "Setup");
-
- if (G_UNLIKELY (message == NULL))
- {
- /* out of memory */
-oom: g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM, g_strerror (ENOMEM));
- goto out;
- }
-
- if (!dbus_message_append_args (message,
- DBUS_TYPE_STRING, &password,
- DBUS_TYPE_INVALID)) {
- dbus_message_unref (message);
- goto oom;
- }
-
- dbus_error_init (&derror);
-
- dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror);
- if (G_UNLIKELY (dbus_connection == NULL))
- {
- /* propagate the error */
- dbus_set_g_error (error, &derror);
- goto out;
- }
-
- send_err = dbus_connection_send_with_reply (dbus_connection, message, &call, -1);
- if (G_UNLIKELY (send_err == FALSE))
- {
- /* release the result */
- dbus_message_unref (message);
- goto out;
- }
-
- dbus_pending_call_set_notify(call, tvm_crypto_volume_dbus_call_done, NULL, NULL);
- gtk_main();
-
- result = dbus_pending_call_steal_reply(call);
- /* release the message */
- dbus_message_unref (message);
-
- /* release the connection */
- dbus_connection_unref (dbus_connection);
-
- if (G_UNLIKELY (dbus_set_error_from_message(&derror, result)))
- {
- /* try to translate the error appropriately */
- if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.PermissionDenied") == 0)
- {
- /* TRANSLATORS: The user tried to setup a crypto layer (LUKS-encrpyted volume) but got Permission denied. */
- g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("You are not privileged to setup the crypto layer"));
- }
- else if (strcmp (derror.name, "org.freedesktop.Hal.Device.Volume.Crypto.SetupPasswordError") == 0)
- {
- /* TRANSLATORS: The user tried to setup a crypto layer (LUKS-encrpyted volume) and typed the wrong password. */
- g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Wrong password"));
- *pass_error = TRUE;
- }
- else
- {
- /* no precise error message, use the HAL one */
- dbus_set_g_error (error, &derror);
- }
-
- /* release the DBus error */
- dbus_error_free (&derror);
- dbus_message_unref (result);
- plain_udi = NULL;
- goto out;
- }
- else
- {
- dbus_message_unref (result);
- plain_udi = libhal_volume_crypto_get_clear_volume_udi (context, volume);
- }
-
-out:
- g_source_remove(animator_id);
- gtk_widget_destroy(window);
- return plain_udi;
-}
-
-/**
- * tvm_crypto_volume_setup:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the HAL volume UDI of the newly added crypto volume.
- * @error : return location for errors or %NULL.
- *
- * Tries to setup the crypto layer for the volume with the
- * specified @udi.
- *
- * Return value: %TRUE if handled, %FALSE if not handled or an
- * unrecoverable error occurred.
- */
-gboolean
-tvm_crypto_volume_setup (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- GError **error)
-{
- gchar *password = NULL;
- gboolean pass_error = FALSE;
- gint num_tries = 0;
- gchar *plain_udi = NULL;
- LibHalVolume *volume = NULL;
- gboolean result = FALSE;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- volume = libhal_volume_from_udi (context, udi);
- g_return_val_if_fail(volume != NULL, FALSE);
- plain_udi = libhal_volume_crypto_get_clear_volume_udi (context, volume);
- if (plain_udi != NULL) {
- libhal_volume_free(volume);
- libhal_free_string(plain_udi);
- return TRUE;
- }
-
- for (num_tries = 0; num_tries < 3; num_tries++) {
- gint response,len;
- response = tvm_crypto_volume_ask_password (context, udi, "gtk-dialog-authentication", _("Encrypted volume"),
- &password, FALSE, GTK_RESPONSE_OK,
- pass_error? _("<span weight=\"bold\" size=\"larger\">Wrong password.</span>")
- :_("<span weight=\"bold\" size=\"larger\">This volume is encrypted.</span>"),
- _("Please enter your password to decrypt and mount the volume."),
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("_Mount"), GTK_RESPONSE_OK,
- NULL);
- if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) {
- g_clear_error(error);
- num_tries = 3;
- } else if (password) {
- plain_udi = tvm_crypto_volume_mount_install_crypto_volume(context, udi, volume, password, &pass_error, error);
- }
- if (password) {
- len = strlen(password);
- memset(password, 0, len);
- g_debug("zeroed password %p", password);
- g_free(password);
- }
- if (*error != NULL && !pass_error) {
- /* display an error message to the user (exo-mount won't do it as it won't see the clear device */
- GtkWidget *message = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s.", _("Failed to setup the encrypted volume"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s.", (*error)->message);
- gtk_dialog_run (GTK_DIALOG (message));
- gtk_widget_destroy (message);
- break;
- }
- if (plain_udi != NULL) {
- libhal_free_string(plain_udi);
- result = TRUE;
- break;
- }
- }
- return result;
-}
-
-
diff --git a/thunar-volman/tvm-crypto-volume.h b/thunar-volman/tvm-crypto-volume.h
deleted file mode 100644
index 0e4ebf3..0000000
--- a/thunar-volman/tvm-crypto-volume.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2008 Benedikt Meurer <benny@xfce.org>.
- * Copyright (c) 2008 Colin Leroy <colin@colino.net>.
- *
- * 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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_CRYPTO_VOLUME_H__
-#define __TVM_CRYPTO_VOLUME_H__
-
-#include <thunar-volman/tvm-device.h>
-
-G_BEGIN_DECLS
-
-gboolean tvm_crypto_volume_setup (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- GError **error) G_GNUC_INTERNAL;
-
-G_END_DECLS
-
-#endif /* !__TVM_CRYPTO_VOLUME_H__ */
diff --git a/thunar-volman/tvm-device.c b/thunar-volman/tvm-device.c
index 584b222..6c0c045 100644
--- a/thunar-volman/tvm-device.c
+++ b/thunar-volman/tvm-device.c
@@ -1,203 +1,139 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@xfce.org>.
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option)
- * any later version.
+ * 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 (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
+#include <glib.h>
+
+#include <gudev/gudev.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <libxfce4util/libxfce4util.h>
+
+#include <xfconf/xfconf.h>
#include <thunar-volman/tvm-block-device.h>
-#include <thunar-volman/tvm-camera-device.h>
+#include <thunar-volman/tvm-context.h>
#include <thunar-volman/tvm-device.h>
-#include <thunar-volman/tvm-input-device.h>
-#include <thunar-volman/tvm-pda-device.h>
-#include <thunar-volman/tvm-printer-device.h>
typedef struct _TvmDeviceHandler TvmDeviceHandler;
+
+
+
+static void tvm_device_try_next_handler (TvmContext *context);
+
+
+
struct _TvmDeviceHandler
{
- const gchar *capability;
- TvmDeviceCallback callback;
+ const gchar *subsystem;
+ TvmDeviceHandlerFunc func;
};
-static const TvmDeviceHandler handlers[] =
+static TvmDeviceHandler subsystem_handlers[] =
{
- { "block", tvm_block_device_added, },
- { "camera", tvm_camera_device_added, },
- { "input.keyboard", tvm_input_device_added, },
- { "input.mouse", tvm_input_device_added, },
- { "input.tablet", tvm_input_device_added, },
- { "pda", tvm_pda_device_added, },
- { "printer", tvm_printer_device_added, },
+ { "block", tvm_block_device_added },
+#if 0
+ { "input", tvm_input_device_added },
+ { "sound", tvm_sound_device_added },
+ { "video4linux", tvm_video_device_added },
+#endif
};
-static gint
-strptrcmp (gconstpointer strptr1,
- gconstpointer strptr2)
+void
+tvm_device_handler_finished (TvmContext *context)
{
- return strcmp (*((const gchar **) strptr1),
- *((const gchar **) strptr2));
+ g_return_if_fail (context != NULL);
+
+ if (context->error != NULL && *context->error != NULL)
+ {
+ g_list_free (context->handlers);
+ g_main_loop_quit (context->loop);
+ }
+ else
+ {
+ if (context->handlers != NULL)
+ tvm_device_try_next_handler (context);
+ else
+ g_main_loop_quit (context->loop);
+ }
}
-/**
- * tvm_device_added:
- * @preferences : a #TvmPreferences.
- * @udi : the HAL device UDI of the newly added device.
- * @error : return location for errors or %NULL.
- *
- * Invoked whenever a new device is added, where @udi is the
- * HAL device UDI of the device in question. Returns %FALSE if
- * an unrecoverable error occurred, %TRUE otherwise.
- *
- * Return value: %FALSE in case of an unrecoverable error,
- * %TRUE otherwise.
- **/
-gboolean
-tvm_device_added (TvmPreferences *preferences,
- const gchar *udi,
- GError **error)
+static void
+tvm_device_try_next_handler (TvmContext *context)
{
- DBusConnection *connection;
- LibHalContext *context;
- DBusError derror;
- GError *err = NULL;
- gchar **capabilities;
- gint n_capabilities;
- gint i, j, n;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* try to allocate a new HAL context */
- context = libhal_ctx_new ();
- if (G_UNLIKELY (context == NULL))
- {
- /* out of memory */
- g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_NOMEM, g_strerror (ENOMEM));
- return FALSE;
- }
+ TvmDeviceHandler *handler;
- /* initialize D-Bus error */
- dbus_error_init (&derror);
+ g_return_if_fail (context != NULL);
- /* try to connect to the system bus */
- connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror);
- if (G_UNLIKELY (connection == NULL))
- {
-err0: /* release the HAL context */
- libhal_ctx_free (context);
+ handler = context->handlers->data;
+ context->handlers = g_list_delete_link (context->handlers, context->handlers);
- /* propagate the error */
- dbus_set_g_error (error, &derror);
- return FALSE;
- }
+ handler->func (context);
+}
- /* setup the D-Bus connection for the GLib main loop */
- dbus_connection_setup_with_g_main (connection, NULL);
- /* setup the D-Bus connection for the HAL context */
- libhal_ctx_set_dbus_connection (context, connection);
- /* the HAL context now owns the connection */
- dbus_connection_unref (connection);
+void
+tvm_device_added (TvmContext *context)
+{
+ const gchar *const *keys = NULL;
+ const gchar *subsystem;
+ gint n;
- /* try to initialize the HAL context */
- if (!libhal_ctx_init (context, &derror))
- goto err0;
+ g_return_if_fail (context != NULL);
- /* query the capabilities of the device */
- capabilities = libhal_device_get_property_strlist (context, udi, "info.capabilities", &derror);
- if (G_UNLIKELY (capabilities == NULL))
- {
- /* shutdown the HAL context */
- libhal_ctx_shutdown (context, NULL);
- goto err0;
- }
+#ifdef DEBUG
+ g_debug ("tvm_device_added:");
+ keys = g_udev_device_get_property_keys (context->device);
+ for (n = 0; keys != NULL && keys[n] != NULL; ++n)
+ g_debug (" %s = %s", keys[n], g_udev_device_get_property (context->device, keys[n]));
+#endif
- /* determine the number of capabilities */
- n_capabilities = g_strv_length (capabilities);
+ /* determine the subsystem to which the device belongs */
+ subsystem = g_udev_device_get_subsystem (context->device);
- /* sort the capabilities */
- qsort (capabilities, n_capabilities, sizeof (*capabilities), strptrcmp);
+ /* find all subsystem handlers for this subsystem */
+ for (n = G_N_ELEMENTS (subsystem_handlers)-1; n >= 0; --n)
+ if (g_strcmp0 (subsystem, subsystem_handlers[n].subsystem) == 0)
+ context->handlers = g_list_prepend (context->handlers, &subsystem_handlers[n]);
- /* try various handlers until one of them succeeds */
- for (i = 0, j = 0; err == NULL && i < G_N_ELEMENTS (handlers) && j < n_capabilities; ++i)
+ /* check if we have at least one handler */
+ if (context->handlers != NULL)
{
- /* search for a handler with the capability */
- for (n = -1; j < n_capabilities; )
- {
- /* check if we have a match here */
- n = strcmp (capabilities[j], handlers[i].capability);
- if (G_LIKELY (n >= 0))
- break;
- ++j;
- }
-
- /* check if we have a potential match */
- if (n == 0)
- {
- /* try to handle the device */
- if ((*handlers[i].callback) (preferences, context, udi, capabilities[j], &err))
- break;
- ++j;
- }
+ /* try the next handler in the list */
+ tvm_device_try_next_handler (context);
}
-
- /* cleanup the capabilities */
- libhal_free_string_array (capabilities);
-
- /* shutdown the HAL context */
- libhal_ctx_shutdown (context, NULL);
- libhal_ctx_free (context);
-
- /* check if we failed */
- if (G_UNLIKELY (err != NULL))
+ else
{
- /* propagate the error */
- g_propagate_error (error, err);
- return FALSE;
+ g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Device type not supported"));
+ g_main_loop_quit (context->loop);
}
-
- return TRUE;
}
-
-
diff --git a/thunar-volman/tvm-device.h b/thunar-volman/tvm-device.h
index 4934383..5f4417e 100644
--- a/thunar-volman/tvm-device.h
+++ b/thunar-volman/tvm-device.h
@@ -1,57 +1,42 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@xfce.org>.
+ * Copyright (c) 2010 Jannis Pohlmann <>
*
- * 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 (at your option)
- * any later version.
+ * 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 (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifndef __TVM_DEVICE_H__
#define __TVM_DEVICE_H__
-#include <libhal.h>
+#include <glib.h>
-#include <exo-hal/exo-hal.h>
-
-#include <thunar-volman/tvm-preferences.h>
+#include <thunar-volman/tvm-context.h>
G_BEGIN_DECLS
-/**
- * TvmDeviceCallback:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the HAL device UDI of the newly added device.
- * @capability : the capability that caused this callback to be invoked.
- * @error : return location for errors or %NULL.
- *
- * Prototype for device callbacks, which are invoked if a device is inserted,
- * with a capability they claim to be able to handle. Returns %TRUE if the
- * device was handled, %FALSE if the device cannot be handled or an unrecoverable
- * error occurred (in which case the @error should be set).
- *
- * Return value:
- **/
-typedef gboolean (*TvmDeviceCallback) (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error);
-
-gboolean tvm_device_added (TvmPreferences *preferences,
- const gchar *udi,
- GError **error) G_GNUC_INTERNAL;
+/* callback function type for device handlers */
+typedef void (*TvmDeviceHandlerCallback) (TvmContext *context);
+
+/* function type for device handlers */
+typedef void (*TvmDeviceHandlerFunc) (TvmContext *context);
+
+
+
+void tvm_device_added (TvmContext *context);
+void tvm_device_handler_finished (TvmContext *context);
G_END_DECLS
diff --git a/thunar-volman/tvm-gio-extensions.c b/thunar-volman/tvm-gio-extensions.c
new file mode 100644
index 0000000..46df3bc
--- /dev/null
+++ b/thunar-volman/tvm-gio-extensions.c
@@ -0,0 +1,64 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gio/gio.h>
+
+#include <thunar-volman/tvm-gio-extensions.h>
+
+
+
+GVolume *
+tvm_g_volume_monitor_get_volume_for_kind (GVolumeMonitor *monitor,
+ const gchar *kind,
+ const gchar *identifier)
+{
+ GVolume *volume = NULL;
+ GList *volumes;
+ GList *lp;
+ gchar *value;
+
+ g_return_val_if_fail (G_IS_VOLUME_MONITOR (monitor), NULL);
+ g_return_val_if_fail (kind != NULL && *kind != '\0', NULL);
+ g_return_val_if_fail (identifier != NULL && *identifier != '\0', NULL);
+
+ volumes = g_volume_monitor_get_volumes (monitor);
+
+ for (lp = volumes; volume == NULL && lp != NULL; lp = lp->next)
+ {
+ value = g_volume_get_identifier (lp->data, kind);
+ if (value != NULL)
+ {
+ if (g_strcmp0 (value, identifier) == 0)
+ volume = g_object_ref (lp->data);
+
+ g_free (value);
+ }
+
+ g_object_unref (lp->data);
+ }
+
+ g_list_free (volumes);
+
+ return volume;
+}
diff --git a/thunar-volman/tvm-gio-extensions.h b/thunar-volman/tvm-gio-extensions.h
new file mode 100644
index 0000000..c4d1c7d
--- /dev/null
+++ b/thunar-volman/tvm-gio-extensions.h
@@ -0,0 +1,34 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TVM_GIO_EXTENSIONS_H__
+#define __TVM_GIO_EXTENSIONS_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+GVolume *tvm_g_volume_monitor_get_volume_for_kind (GVolumeMonitor *monitor,
+ const gchar *kind,
+ const gchar *identifier);
+
+G_END_DECLS
+
+#endif /* !__TVM_GIO_EXTENSIONS_H__ */
diff --git a/thunar-volman/tvm-input-device.c b/thunar-volman/tvm-input-device.c
deleted file mode 100644
index 664e856..0000000
--- a/thunar-volman/tvm-input-device.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <thunar-volman/tvm-input-device.h>
-#include <thunar-volman/tvm-run.h>
-
-
-
-static const struct
-{
- const gchar *capability;
- const gchar *auto_option_name;
- const gchar *auto_command_name;
-} commands[] = {
- { "input.keyboard", "autokeyboard", "autokeyboard-command", },
- { "input.mouse", "automouse", "automouse-command", },
- { "input.tablet", "autotablet", "autotablet-command", },
-};
-
-
-
-/**
- * tvm_input_device_added:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the HAL device UDI of the newly added input device.
- * @capability : the capability, which caused this handler to be run.
- * @error : return location for errors or %NULL.
- *
- * See #TvmDeviceCallback for further information.
- *
- * Return value: %TRUE if handled, %FALSE if not handled or an
- * unrecoverable error occurred.
- **/
-gboolean
-tvm_input_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error)
-{
- gboolean result = FALSE;
- gboolean auto_enabled;
- gchar *auto_command;
- guint n;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (capability != NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- /* check which type of input device we have */
- for (n = 0; n < G_N_ELEMENTS (commands); ++n)
- if (strcmp (commands[n].capability, capability) == 0)
- break;
- if (G_LIKELY (n < G_N_ELEMENTS (commands)))
- {
- /* check if this handling is enabled and we have a command */
- g_object_get (G_OBJECT (preferences), commands[n].auto_option_name, &auto_enabled, commands[n].auto_command_name, &auto_command, NULL);
- if (G_LIKELY (auto_enabled && auto_command != NULL && *auto_command != '\0'))
- {
- /* try to run the command */
- result = tvm_run_command (context, udi, auto_command, NULL, NULL, error);
- }
- g_free (auto_command);
- }
-
- return result;
-}
-
-
-
-
diff --git a/thunar-volman/tvm-input-device.h b/thunar-volman/tvm-input-device.h
deleted file mode 100644
index 211b9ac..0000000
--- a/thunar-volman/tvm-input-device.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_INPUT_DEVICE_H__
-#define __TVM_INPUT_DEVICE_H__
-
-#include <thunar-volman/tvm-device.h>
-
-G_BEGIN_DECLS
-
-gboolean tvm_input_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error) G_GNUC_INTERNAL;
-
-G_END_DECLS
-
-#endif /* !__TVM_INPUT_DEVICE_H__ */
diff --git a/thunar-volman/tvm-pango-extensions.c b/thunar-volman/tvm-pango-extensions.c
deleted file mode 100644
index bb95891..0000000
--- a/thunar-volman/tvm-pango-extensions.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2006-2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-
-#include <thunar-volman/tvm-pango-extensions.h>
-
-
-
-static PangoAttrList *tvm_pango_attr_list_wrap (PangoAttribute *attribute, ...) G_GNUC_MALLOC;
-
-
-
-static PangoAttrList*
-tvm_pango_attr_list_wrap (PangoAttribute *attribute, ...)
-{
- PangoAttrList *attr_list;
- va_list args;
-
- /* allocate a new attribute list */
- attr_list = pango_attr_list_new ();
-
- /* add all specified attributes */
- va_start (args, attribute);
- while (attribute != NULL)
- {
- attribute->start_index = 0;
- attribute->end_index = -1;
- pango_attr_list_insert (attr_list, attribute);
- attribute = va_arg (args, PangoAttribute *);
- }
- va_end (args);
-
- return attr_list;
-}
-
-
-
-/**
- * tvm_pango_attr_list_big:
- *
- * Returns a #PangoAttrList for rendering big text.
- * The returned list is owned by the callee and must
- * not be freed or modified by the caller.
- *
- * Return value: a #PangoAttrList for rendering big text.
- **/
-PangoAttrList*
-tvm_pango_attr_list_big (void)
-{
- static PangoAttrList *attr_list = NULL;
- if (G_UNLIKELY (attr_list == NULL))
- attr_list = tvm_pango_attr_list_wrap (pango_attr_scale_new (PANGO_SCALE_LARGE), NULL);
- return attr_list;
-}
-
-
-
-/**
- * tvm_pango_attr_list_big_bold:
- *
- * Returns a #PangoAttrList for rendering big bold text.
- * The returned list is owned by the callee and must
- * not be freed or modified by the caller.
- *
- * Return value: a #PangoAttrList for rendering big bold text.
- **/
-PangoAttrList*
-tvm_pango_attr_list_big_bold (void)
-{
- static PangoAttrList *attr_list = NULL;
- if (G_UNLIKELY (attr_list == NULL))
- attr_list = tvm_pango_attr_list_wrap (pango_attr_scale_new (PANGO_SCALE_LARGE), pango_attr_weight_new (PANGO_WEIGHT_BOLD), NULL);
- return attr_list;
-}
-
-
-
-/**
- * tvm_pango_attr_list_bold:
- *
- * Returns a #PangoAttrList for rendering bold text.
- * The returned list is owned by the callee and must
- * not be freed or modified by the caller.
- *
- * Return value: a #PangoAttrList for rendering bold text.
- **/
-PangoAttrList*
-tvm_pango_attr_list_bold (void)
-{
- static PangoAttrList *attr_list = NULL;
- if (G_UNLIKELY (attr_list == NULL))
- attr_list = tvm_pango_attr_list_wrap (pango_attr_weight_new (PANGO_WEIGHT_BOLD), NULL);
- return attr_list;
-}
-
-
-
-/**
- * tvm_pango_attr_list_italic:
- *
- * Returns a #PangoAttrList for rendering italic text.
- * The returned list is owned by the callee and must
- * not be freed or modified by the caller.
- *
- * Return value: a #PangoAttrList for rendering italic text.
- **/
-PangoAttrList*
-tvm_pango_attr_list_italic (void)
-{
- static PangoAttrList *attr_list = NULL;
- if (G_UNLIKELY (attr_list == NULL))
- attr_list = tvm_pango_attr_list_wrap (pango_attr_style_new (PANGO_STYLE_ITALIC), NULL);
- return attr_list;
-}
-
-
-
-/**
- * tvm_pango_attr_list_small_italic:
- *
- * Returns a #PangoAttrList for rendering small italic text.
- * The returned list is owned by the callee and must
- * not be freed or modified by the caller.
- *
- * Return value: a #PangoAttrList for rendering small italic text.
- **/
-PangoAttrList*
-tvm_pango_attr_list_small_italic (void)
-{
- static PangoAttrList *attr_list = NULL;
- if (G_UNLIKELY (attr_list == NULL))
- attr_list = tvm_pango_attr_list_wrap (pango_attr_scale_new (PANGO_SCALE_SMALL), pango_attr_style_new (PANGO_STYLE_ITALIC), NULL);
- return attr_list;
-}
-
-
-
-/**
- * tvm_pango_attr_list_underline_single:
- *
- * Returns a #PangoAttrList for underlining text using a single line.
- * The returned list is owned by the callee and must not be freed
- * or modified by the caller.
- *
- * Return value: a #PangoAttrList for underlining text using a single line.
- **/
-PangoAttrList*
-tvm_pango_attr_list_underline_single (void)
-{
- static PangoAttrList *attr_list = NULL;
- if (G_UNLIKELY (attr_list == NULL))
- attr_list = tvm_pango_attr_list_wrap (pango_attr_underline_new (PANGO_UNDERLINE_SINGLE), NULL);
- return attr_list;
-}
diff --git a/thunar-volman/tvm-pango-extensions.h b/thunar-volman/tvm-pango-extensions.h
deleted file mode 100644
index e527667..0000000
--- a/thunar-volman/tvm-pango-extensions.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2006-2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_PANGO_EXTENSIONS_H__
-#define __TVM_PANGO_EXTENSIONS_H__
-
-#include <pango/pango.h>
-
-G_BEGIN_DECLS
-
-PangoAttrList *tvm_pango_attr_list_big (void) G_GNUC_CONST G_GNUC_INTERNAL;
-PangoAttrList *tvm_pango_attr_list_big_bold (void) G_GNUC_CONST G_GNUC_INTERNAL;
-PangoAttrList *tvm_pango_attr_list_bold (void) G_GNUC_CONST G_GNUC_INTERNAL;
-PangoAttrList *tvm_pango_attr_list_italic (void) G_GNUC_CONST G_GNUC_INTERNAL;
-PangoAttrList *tvm_pango_attr_list_small_italic (void) G_GNUC_CONST G_GNUC_INTERNAL;
-PangoAttrList *tvm_pango_attr_list_underline_single (void) G_GNUC_CONST G_GNUC_INTERNAL;
-
-G_END_DECLS
-
-#endif /* !__TVM_PANGO_EXTENSIONS_H__ */
diff --git a/thunar-volman/tvm-pda-device.c b/thunar-volman/tvm-pda-device.c
deleted file mode 100644
index 8e3b942..0000000
--- a/thunar-volman/tvm-pda-device.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <thunar-volman/tvm-pda-device.h>
-#include <thunar-volman/tvm-run.h>
-
-
-
-static const struct
-{
- const gchar *platform;
- const gchar *auto_option_name;
- const gchar *auto_command_name;
-} commands[] = {
- { "palm", "autopalm", "autopalm-command", },
- { "pocketpc", "autopocketpc", "autopocketpc-command", },
-};
-
-
-
-/**
- * tvm_pda_device_added:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the HAL device UDI of the newly added PDA device.
- * @capability : the capability, which caused this handler to be run.
- * @error : return location for errors or %NULL.
- *
- * See #TvmDeviceCallback for further information.
- *
- * Return value: %TRUE if handled, %FALSE if not handled or an
- * unrecoverable error occurred.
- **/
-gboolean
-tvm_pda_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error)
-{
- DBusError derror;
- gboolean result = FALSE;
- gboolean auto_enabled;
- gchar *auto_command;
- gchar *platform;
- guint n;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (capability != NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- /* initialize D-Bus error */
- dbus_error_init (&derror);
-
- /* determine the PDA platform */
- platform = libhal_device_get_property_string (context, udi, "pda.platform", &derror);
- if (G_UNLIKELY (platform == NULL))
- {
- /* propagate the error */
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- return FALSE;
- }
-
- /* check if we can handle that platform */
- for (n = 0; n < G_N_ELEMENTS (commands); ++n)
- if (strcmp (commands[n].platform, platform) == 0)
- break;
- if (G_LIKELY (n < G_N_ELEMENTS (commands)))
- {
- /* check if this handling is enabled and we have a command */
- g_object_get (G_OBJECT (preferences), commands[n].auto_option_name, &auto_enabled, commands[n].auto_command_name, &auto_command, NULL);
- if (G_LIKELY (auto_enabled && auto_command != NULL && *auto_command != '\0'))
- {
- /* try to run the command */
- result = tvm_run_command (context, udi, auto_command, NULL, NULL, error);
- }
- g_free (auto_command);
- }
-
- /* cleanup */
- libhal_free_string (platform);
-
- return result;
-}
-
-
-
-
diff --git a/thunar-volman/tvm-pda-device.h b/thunar-volman/tvm-pda-device.h
deleted file mode 100644
index 41edfbf..0000000
--- a/thunar-volman/tvm-pda-device.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_PDA_DEVICE_H__
-#define __TVM_PDA_DEVICE_H__
-
-#include <thunar-volman/tvm-device.h>
-
-G_BEGIN_DECLS
-
-gboolean tvm_pda_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error) G_GNUC_INTERNAL;
-
-G_END_DECLS
-
-#endif /* !__TVM_PDA_DEVICE_H__ */
diff --git a/thunar-volman/tvm-preferences-dialog.c b/thunar-volman/tvm-preferences-dialog.c
deleted file mode 100644
index 614e68b..0000000
--- a/thunar-volman/tvm-preferences-dialog.c
+++ /dev/null
@@ -1,719 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2005-2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <thunar-volman/tvm-command-entry.h>
-#include <thunar-volman/tvm-pango-extensions.h>
-#include <thunar-volman/tvm-preferences-dialog.h>
-#include <thunar-volman/xfce-titled-dialog.h>
-
-
-
-static void tvm_preferences_dialog_class_init (TvmPreferencesDialogClass *klass);
-static void tvm_preferences_dialog_init (TvmPreferencesDialog *dialog);
-static void tvm_preferences_dialog_finalize (GObject *object);
-static void tvm_preferences_dialog_help_clicked (GtkWidget *button,
- TvmPreferencesDialog *dialog);
-
-
-
-struct _TvmPreferencesDialogClass
-{
- XfceTitledDialogClass __parent__;
-};
-
-struct _TvmPreferencesDialog
-{
- XfceTitledDialog __parent__;
- TvmPreferences *preferences;
-};
-
-
-
-static GObjectClass *tvm_preferences_dialog_parent_class;
-
-
-
-GType
-tvm_preferences_dialog_get_type (void)
-{
- static GType type = G_TYPE_INVALID;
-
- if (G_UNLIKELY (type == G_TYPE_INVALID))
- {
- static const GTypeInfo info =
- {
- sizeof (TvmPreferencesDialogClass),
- NULL,
- NULL,
- (GClassInitFunc) tvm_preferences_dialog_class_init,
- NULL,
- NULL,
- sizeof (TvmPreferencesDialog),
- 0,
- (GInstanceInitFunc) tvm_preferences_dialog_init,
- NULL,
- };
-
- type = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, I_("TvmPreferencesDialog"), &info, 0);
- }
-
- return type;
-}
-
-
-
-static void
-tvm_preferences_dialog_class_init (TvmPreferencesDialogClass *klass)
-{
- GObjectClass *gobject_class;
-
- /* determine the parent type class */
- tvm_preferences_dialog_parent_class = g_type_class_peek_parent (klass);
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = tvm_preferences_dialog_finalize;
-}
-
-
-
-static void
-tvm_preferences_dialog_init (TvmPreferencesDialog *dialog)
-{
- GtkSizeGroup *size_group;
- GtkWidget *notebook;
- GtkWidget *button;
- GtkWidget *entry;
- GtkWidget *frame;
- GtkWidget *image;
- GtkWidget *label;
- GtkWidget *table;
- GtkWidget *vbox;
-
- /* grab a reference on the preferences */
- dialog->preferences = tvm_preferences_get ();
-
- /* configure the dialog properties */
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "gnome-dev-removable");
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_window_set_title (GTK_WINDOW (dialog), _("Removable Drives and Media"));
- xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), _("Configure management of removable drives and media"));
-
- /* add "Help" button */
- button = gtk_button_new_from_stock (GTK_STOCK_HELP);
- g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (tvm_preferences_dialog_help_clicked), dialog);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, FALSE, FALSE, 0);
- gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE);
- gtk_widget_show (button);
-
- /* add "Close" button */
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
-
- notebook = gtk_notebook_new ();
- gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
- gtk_widget_show (notebook);
-
-
- /*
- Storage
- */
- label = gtk_label_new (_("Storage"));
- vbox = g_object_new (GTK_TYPE_VBOX, "border-width", 12, "spacing", 12, NULL);
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
- gtk_widget_show (label);
- gtk_widget_show (vbox);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Removable Storage"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (5, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("gnome-dev-removable", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("_Mount removable drives when hot-plugged"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "automount-drives", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- button = gtk_check_button_new_with_mnemonic (_("Mount removable media when _inserted"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "automount-media", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- button = gtk_check_button_new_with_mnemonic (_("B_rowse removable media when inserted"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autobrowse", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- button = gtk_check_button_new_with_mnemonic (_("_Auto-run programs on new drives and media"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autorun", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- button = gtk_check_button_new_with_mnemonic (_("Auto-open files on new drives and media"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoopen", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Blank CDs and DVDs"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (3, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("tvm-burn-cd", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("_Burn a CD or DVD when a blank disc is inserted"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoburn", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- /* use a size group to make sure both labels request the same width */
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- entry = tvm_command_entry_new_with_label (_("Command for _Data CDs:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoburn-data-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_size_group_add_widget (size_group, TVM_COMMAND_ENTRY (entry)->label);
- gtk_widget_show (entry);
-
- entry = tvm_command_entry_new_with_label (_("Command for A_udio CDs:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoburn-audio-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_size_group_add_widget (size_group, TVM_COMMAND_ENTRY (entry)->label);
- gtk_widget_show (entry);
-
- /* release the size group */
- g_object_unref (G_OBJECT (size_group));
-
-
- /*
- Multimedia
- */
- label = gtk_label_new (_("Multimedia"));
- vbox = g_object_new (GTK_TYPE_VBOX, "border-width", 12, "spacing", 12, NULL);
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
- gtk_widget_show (label);
- gtk_widget_show (vbox);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Audio CDs"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("gnome-dev-cdrom-audio", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Play _audio CDs when inserted"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoplay-audio-cd", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("_Command:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoplay-audio-cd-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Video CDs/DVDs"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("gnome-dev-cdrom", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Play _video CDs and DVDs when inserted"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoplay-video-cd", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("C_ommand:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoplay-video-cd-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Portable Music Players"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("gnome-dev-ipod", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Play _music files when connected"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoipod", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("C_ommand:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoipod-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
-
- /*
- Cameras
- */
- label = gtk_label_new (_("Cameras"));
- vbox = g_object_new (GTK_TYPE_VBOX, "border-width", 12, "spacing", 12, NULL);
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
- gtk_widget_show (label);
- gtk_widget_show (vbox);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Digital Cameras"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("camera-photo", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Import digital photographs when connected"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autophoto", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("_Command:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autophoto-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
-
- /*
- PDAs
- */
- label = gtk_label_new (_("PDAs"));
- vbox = g_object_new (GTK_TYPE_VBOX, "border-width", 12, "spacing", 12, NULL);
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
- gtk_widget_show (label);
- gtk_widget_show (vbox);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Palmâ„¢"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("palm-pilot", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Sync _Palmâ„¢ devices when connected"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autopalm", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("_Command:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autopalm-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Pocket PCs"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("tvm-dev-pocketpc", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Sync Pocket P_C devices when connected"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autopocketpc", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("C_ommand:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autopocketpc-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
-
- /*
- Printers
- */
- label = gtk_label_new (_("Printers"));
- vbox = g_object_new (GTK_TYPE_VBOX, "border-width", 12, "spacing", 12, NULL);
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
- gtk_widget_show (label);
- gtk_widget_show (vbox);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Printers"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("gnome-dev-printer", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Automatically run a program when a _printer is connected"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoprinter", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("_Command:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autoprinter-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
-
- /*
- Input Devices
- */
- label = gtk_label_new (_("Input Devices"));
- vbox = g_object_new (GTK_TYPE_VBOX, "border-width", 12, "spacing", 12, NULL);
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
- gtk_widget_show (label);
- gtk_widget_show (vbox);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Keyboards"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("gnome-dev-keyboard", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Automatically run a program when an USB _keyboard is connected"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autokeyboard", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("_Command:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autokeyboard-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Mice"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("gnome-dev-mouse-optical", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Automatically run a program when an USB _mouse is connected"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "automouse", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("C_ommand:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "automouse-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-
- frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_widget_show (frame);
-
- label = gtk_label_new (_("Tablet"));
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_bold ());
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_widget_show (label);
-
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 8);
- gtk_container_add (GTK_CONTAINER (frame), table);
- gtk_widget_show (table);
-
- image = gtk_image_new_from_icon_name ("tvm-dev-tablet", GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f);
- gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (image);
-
- button = gtk_check_button_new_with_mnemonic (_("Automatically run a program when a _tablet is connected"));
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autotablet", G_OBJECT (button), "active");
- gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (button);
-
- entry = tvm_command_entry_new_with_label (_("Com_mand:"));
- exo_binding_new (G_OBJECT (button), "active", G_OBJECT (entry), "sensitive");
- exo_mutual_binding_new (G_OBJECT (dialog->preferences), "autotablet-command", G_OBJECT (entry), "command");
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (entry);
-}
-
-
-
-static void
-tvm_preferences_dialog_finalize (GObject *object)
-{
- TvmPreferencesDialog *dialog = TVM_PREFERENCES_DIALOG (object);
-
- /* release our reference on the preferences */
- g_object_unref (G_OBJECT (dialog->preferences));
-
- (*G_OBJECT_CLASS (tvm_preferences_dialog_parent_class)->finalize) (object);
-}
-
-
-
-static void
-tvm_preferences_dialog_help_clicked (GtkWidget *button,
- TvmPreferencesDialog *dialog)
-{
- GtkWidget *message;
- GError *err = NULL;
- gchar **argv;
- gchar *bindir;
- gchar *prefix;
- gchar *path;
-
- g_return_if_fail (TVM_IS_PREFERENCES_DIALOG (dialog));
- g_return_if_fail (GTK_IS_BUTTON (button));
-
- /* try to locate Thunar in the $PATH */
- path = g_find_program_in_path ("Thunar");
- if (G_UNLIKELY (path == NULL))
- path = g_find_program_in_path ("thunar");
- if (G_LIKELY (path != NULL))
- {
- bindir = g_path_get_dirname (path);
- prefix = g_path_get_dirname (bindir);
- g_free (bindir);
- g_free (path);
-
- /* now check if ThunarHelp is in $prefix/libexec */
- path = g_build_filename (prefix, "libexec", "ThunarHelp", NULL);
- if (!g_file_test (path, G_FILE_TEST_IS_EXECUTABLE))
- {
- /* release path */
- g_free (path);
-
- /* try to support Debian weirdness */
- path = g_build_filename (prefix, "lib", "thunar", "ThunarHelp", NULL);
- if (!g_file_test (path, G_FILE_TEST_IS_EXECUTABLE))
- {
- /* release path */
- g_free (path);
- path = NULL;
- }
- }
- }
-
- /* no ThunarHelp, weird! */
- if (G_UNLIKELY (path == NULL))
- path = g_strdup ("ThunarHelp");
-
- /* prepare command to run help */
- argv = g_new (gchar *, 4);
- argv[0] = path;
- argv[1] = g_strdup ("using-removable-media");
- argv[2] = g_strdup ("management-of-removable-drives-and-media");
- argv[3] = NULL;
-
- /* try to open the user manual */
- if (!gdk_spawn_on_screen (gtk_widget_get_screen (button), NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &err))
- {
- /* display an error message to the user */
- message = gtk_message_dialog_new (GTK_WINDOW (dialog),
- GTK_DIALOG_DESTROY_WITH_PARENT
- | GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s.", _("Failed to open the documentation browser"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s.", err->message);
- gtk_dialog_run (GTK_DIALOG (message));
- gtk_widget_destroy (message);
- g_error_free (err);
- }
-
- /* cleanup */
- g_strfreev (argv);
-}
-
-
-
-/**
- * tvm_preferences_dialog_new:
- * @parent : a #GtkWindow or %NULL.
- *
- * Allocates a new #TvmPreferencesDialog widget.
- *
- * Return value: the newly allocated #TvmPreferencesDialog.
- **/
-GtkWidget*
-tvm_preferences_dialog_new (void)
-{
- return g_object_new (TVM_TYPE_PREFERENCES_DIALOG, NULL);
-}
-
-
-
-/* vim:set encoding=UTF-8: */
diff --git a/thunar-volman/tvm-preferences-dialog.h b/thunar-volman/tvm-preferences-dialog.h
deleted file mode 100644
index 2c26142..0000000
--- a/thunar-volman/tvm-preferences-dialog.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2005-2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_PREFERENCES_DIALOG_H__
-#define __TVM_PREFERENCES_DIALOG_H__
-
-#include <thunar-volman/tvm-preferences.h>
-
-G_BEGIN_DECLS
-
-typedef struct _TvmPreferencesDialogClass TvmPreferencesDialogClass;
-typedef struct _TvmPreferencesDialog TvmPreferencesDialog;
-
-#define TVM_TYPE_PREFERENCES_DIALOG (tvm_preferences_dialog_get_type ())
-#define TVM_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TVM_TYPE_PREFERENCES_DIALOG, TvmPreferencesDialog))
-#define TVM_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TVM_TYPE_PREFERENCES_DIALOG, TvmPreferencesDialogClass))
-#define TVM_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TVM_TYPE_PREFERENCES_DIALOG))
-#define TVM_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TVM_TYPE_PREFERENCES_DIALOG))
-#define TVM_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TVM_TYPE_PREFERENCES_DIALOG, TvmPreferencesDialogClass))
-
-GType tvm_preferences_dialog_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
-
-GtkWidget *tvm_preferences_dialog_new (void) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-
-G_END_DECLS
-
-#endif /* !__TVM_PREFERENCES_DIALOG_H__ */
diff --git a/thunar-volman/tvm-preferences.c b/thunar-volman/tvm-preferences.c
deleted file mode 100644
index 5896ca2..0000000
--- a/thunar-volman/tvm-preferences.c
+++ /dev/null
@@ -1,963 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2005-2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <thunar-vfs/thunar-vfs.h>
-
-#include <thunar-volman/tvm-preferences.h>
-
-
-
-/* Property identifiers */
-enum
-{
- PROP_0,
- PROP_AUTOMOUNT_DRIVES,
- PROP_AUTOMOUNT_MEDIA,
- PROP_AUTOBROWSE,
- PROP_AUTORUN,
- PROP_AUTOOPEN,
- PROP_AUTOBURN,
- PROP_AUTOBURN_DATA_COMMAND,
- PROP_AUTOBURN_AUDIO_COMMAND,
- PROP_AUTOPLAY_AUDIO_CD,
- PROP_AUTOPLAY_AUDIO_CD_COMMAND,
- PROP_AUTOPLAY_VIDEO_CD,
- PROP_AUTOPLAY_VIDEO_CD_COMMAND,
- PROP_AUTOIPOD,
- PROP_AUTOIPOD_COMMAND,
- PROP_AUTOPHOTO,
- PROP_AUTOPHOTO_COMMAND,
- PROP_AUTOPALM,
- PROP_AUTOPALM_COMMAND,
- PROP_AUTOPOCKETPC,
- PROP_AUTOPOCKETPC_COMMAND,
- PROP_AUTOPRINTER,
- PROP_AUTOPRINTER_COMMAND,
- PROP_AUTOKEYBOARD,
- PROP_AUTOKEYBOARD_COMMAND,
- PROP_AUTOMOUSE,
- PROP_AUTOMOUSE_COMMAND,
- PROP_AUTOTABLET,
- PROP_AUTOTABLET_COMMAND,
- N_PROPERTIES,
-};
-
-
-
-static void tvm_preferences_class_init (TvmPreferencesClass *klass);
-static void tvm_preferences_init (TvmPreferences *preferences);
-static void tvm_preferences_dispose (GObject *object);
-static void tvm_preferences_finalize (GObject *object);
-static void tvm_preferences_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void tvm_preferences_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void tvm_preferences_resume_monitor (TvmPreferences *preferences);
-static void tvm_preferences_suspend_monitor (TvmPreferences *preferences);
-static void tvm_preferences_monitor (ThunarVfsMonitor *monitor,
- ThunarVfsMonitorHandle *handle,
- ThunarVfsMonitorEvent event,
- ThunarVfsPath *handle_path,
- ThunarVfsPath *event_path,
- gpointer user_data);
-static void tvm_preferences_queue_load (TvmPreferences *preferences);
-static void tvm_preferences_queue_store (TvmPreferences *preferences);
-static gboolean tvm_preferences_load_idle (gpointer user_data);
-static void tvm_preferences_load_idle_destroy (gpointer user_data);
-static gboolean tvm_preferences_store_idle (gpointer user_data);
-static void tvm_preferences_store_idle_destroy (gpointer user_data);
-
-
-
-struct _TvmPreferencesClass
-{
- GObjectClass __parent__;
-};
-
-struct _TvmPreferences
-{
- GObject __parent__;
-
- ThunarVfsMonitorHandle *handle;
- ThunarVfsMonitor *monitor;
-
- GValue values[N_PROPERTIES];
-
- gboolean loading_in_progress;
-
- gint load_idle_id;
- gint store_idle_id;
-};
-
-
-
-static GObjectClass *tvm_preferences_parent_class;
-
-
-
-GType
-tvm_preferences_get_type (void)
-{
- static GType type = G_TYPE_INVALID;
-
- if (G_UNLIKELY (type == G_TYPE_INVALID))
- {
- static const GTypeInfo info =
- {
- sizeof (TvmPreferencesClass),
- NULL,
- NULL,
- (GClassInitFunc) tvm_preferences_class_init,
- NULL,
- NULL,
- sizeof (TvmPreferences),
- 0,
- (GInstanceInitFunc) tvm_preferences_init,
- NULL,
- };
-
- type = g_type_register_static (G_TYPE_OBJECT, I_("TvmPreferences"), &info, 0);
- }
-
- return type;
-}
-
-
-
-static void
-transform_string_to_boolean (const GValue *src,
- GValue *dst)
-{
- g_value_set_boolean (dst, strcmp (g_value_get_string (src), "FALSE") != 0);
-}
-
-
-
-static void
-tvm_preferences_class_init (TvmPreferencesClass *klass)
-{
- GObjectClass *gobject_class;
-
- /* register transformation functions */
- if (!g_value_type_transformable (G_TYPE_STRING, G_TYPE_BOOLEAN))
- g_value_register_transform_func (G_TYPE_STRING, G_TYPE_BOOLEAN, transform_string_to_boolean);
-
- /* determine the parent type class */
- tvm_preferences_parent_class = g_type_class_peek_parent (klass);
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->dispose = tvm_preferences_dispose;
- gobject_class->finalize = tvm_preferences_finalize;
- gobject_class->get_property = tvm_preferences_get_property;
- gobject_class->set_property = tvm_preferences_set_property;
-
- /**
- * TvmPreferences:automount-drives:
- *
- * Mount removable drives when hot-plugged.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOMOUNT_DRIVES,
- g_param_spec_boolean ("automount-drives",
- "automount-drives",
- "automount-drives",
- TRUE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:automount-media:
- *
- * Mount removable media when inserted.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOMOUNT_MEDIA,
- g_param_spec_boolean ("automount-media",
- "automount-media",
- "automount-media",
- TRUE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autobrowse:
- *
- * Browse removable media when inserted.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOBROWSE,
- g_param_spec_boolean ("autobrowse",
- "autobrowse",
- "autobrowse",
- TRUE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autorun:
- *
- * Auto-run programs on new drives and media.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTORUN,
- g_param_spec_boolean ("autorun",
- "autorun",
- "autorun",
- TRUE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoopen:
- *
- * Auto-open files on new drives and media.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOOPEN,
- g_param_spec_boolean ("autoopen",
- "autoopen",
- "autoopen",
- TRUE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoburn:
- *
- * Burn a CD or DVD if a blank disc is inserted.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOBURN,
- g_param_spec_boolean ("autoburn",
- "autoburn",
- "autoburn",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoburn-data-command:
- *
- * Command to burn a new data CD/DVD.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOBURN_DATA_COMMAND,
- g_param_spec_string ("autoburn-data-command",
- "autoburn-data-command",
- "autoburn-data-command",
- "xfburn",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoburn-audio-command:
- *
- * Command to burn a new audio CD.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOBURN_AUDIO_COMMAND,
- g_param_spec_string ("autoburn-audio-command",
- "autoburn-audio-command",
- "autoburn-audio-command",
- "xfburn",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoplay-audio-cd:
- *
- * Play audio discs when inserted.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPLAY_AUDIO_CD,
- g_param_spec_boolean ("autoplay-audio-cd",
- "autoplay-audio-cd",
- "autoplay-audio-cd",
- TRUE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoplay-audio-cd-command:
- *
- * Command to run the preferred audio CD player.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPLAY_AUDIO_CD_COMMAND,
- g_param_spec_string ("autoplay-audio-cd-command",
- "autoplay-audio-cd-command",
- "autoplay-audio-cd-command",
- "totem %d",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoplay-video-cd:
- *
- * Play video CDs and DVDs when inserted.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPLAY_VIDEO_CD,
- g_param_spec_boolean ("autoplay-video-cd",
- "autoplay-video-cd",
- "autoplay-video-cd",
- TRUE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoplay-video-cd-command:
- *
- * Command to run the preferred video CD/DVD-Player.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPLAY_VIDEO_CD_COMMAND,
- g_param_spec_string ("autoplay-video-cd-command",
- "autoplay-video-cd-command",
- "autoplay-video-cd-command",
- "totem %d",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoipod:
- *
- * Play music files when portable music player is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOIPOD,
- g_param_spec_boolean ("autoipod",
- "autoipod",
- "autoipod",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoipod-command:
- *
- * Command to run when portable music player is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOIPOD_COMMAND,
- g_param_spec_string ("autoipod-command",
- "autoipod-command",
- "autoipod-command",
- "",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autophoto:
- *
- * Import photos when digital camera is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPHOTO,
- g_param_spec_boolean ("autophoto",
- "autophoto",
- "autophoto",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autophoto-command:
- *
- * Command to run when digitcal camera is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPHOTO_COMMAND,
- g_param_spec_string ("autophoto-command",
- "autophoto-command",
- "autophoto-command",
- "",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autopalm:
- *
- * Sync Palm devices when connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPALM,
- g_param_spec_boolean ("autopalm",
- "autopalm",
- "autopalm",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autopalm-command:
- *
- * Command to run when Palm device is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPALM_COMMAND,
- g_param_spec_string ("autopalm-command",
- "autopalm-command",
- "autopalm-command",
- "gpilotd-control-applet",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autopocketpc:
- *
- * Sync PocketPC devices when connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPOCKETPC,
- g_param_spec_boolean ("autopocketpc",
- "autopocketpc",
- "autopocketpc",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autopocketpc-command:
- *
- * Command to run when PocketPC device is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPOCKETPC_COMMAND,
- g_param_spec_string ("autopocketpc-command",
- "autopocketpc-command",
- "autopocketpc-command",
- "multisync",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoprinter:
- *
- * Automatically run a program when a printer is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPRINTER,
- g_param_spec_boolean ("autoprinter",
- "autoprinter",
- "autoprinter",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autoprinter-command:
- *
- * Command to run when a printer is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOPRINTER_COMMAND,
- g_param_spec_string ("autoprinter-command",
- "autoprinter-command",
- "autoprinter-command",
- "gnome-printer-add hal://%h",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autokeyboard:
- *
- * Automatically run a program when an USB keyboard is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOKEYBOARD,
- g_param_spec_boolean ("autokeyboard",
- "autokeyboard",
- "autokeyboard",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autokeyboard-command:
- *
- * Command to run when an USB keyboard is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOKEYBOARD_COMMAND,
- g_param_spec_string ("autokeyboard-command",
- "autokeyboard-command",
- "autokeyboard-command",
- "",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:automouse:
- *
- * Automatically run a program when an USB mouse is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOMOUSE,
- g_param_spec_boolean ("automouse",
- "automouse",
- "automouse",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:automouse-command:
- *
- * Command to run when an USB mouse is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOMOUSE_COMMAND,
- g_param_spec_string ("automouse-command",
- "automouse-command",
- "automouse-command",
- "",
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autotablet:
- *
- * Automatically run a program when a table is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOTABLET,
- g_param_spec_boolean ("autotablet",
- "autotablet",
- "autotablet",
- FALSE,
- EXO_PARAM_READWRITE));
-
- /**
- * TvmPreferences:autotablet-command:
- *
- * Command to run when a table is connected.
- **/
- g_object_class_install_property (gobject_class,
- PROP_AUTOTABLET_COMMAND,
- g_param_spec_string ("autotablet-command",
- "autotablet-command",
- "autotablet-command",
- "",
- EXO_PARAM_READWRITE));
-}
-
-
-
-static void
-tvm_preferences_init (TvmPreferences *preferences)
-{
- /* grab a reference on the VFS monitor */
- preferences->monitor = thunar_vfs_monitor_get_default ();
-
- /* load the settings */
- tvm_preferences_load_idle (preferences);
-
- /* launch the file monitor */
- tvm_preferences_resume_monitor (preferences);
-}
-
-
-
-static void
-tvm_preferences_dispose (GObject *object)
-{
- TvmPreferences *preferences = TVM_PREFERENCES (object);
-
- /* flush preferences */
- if (G_UNLIKELY (preferences->store_idle_id != 0))
- {
- tvm_preferences_store_idle (preferences);
- g_source_remove (preferences->store_idle_id);
- }
-
- (*G_OBJECT_CLASS (tvm_preferences_parent_class)->dispose) (object);
-}
-
-
-
-static void
-tvm_preferences_finalize (GObject *object)
-{
- TvmPreferences *preferences = TVM_PREFERENCES (object);
- guint n;
-
- /* stop any pending load idle source */
- if (G_UNLIKELY (preferences->load_idle_id != 0))
- g_source_remove (preferences->load_idle_id);
-
- /* stop the file monitor */
- if (G_LIKELY (preferences->monitor != NULL))
- {
- tvm_preferences_suspend_monitor (preferences);
- g_object_unref (G_OBJECT (preferences->monitor));
- }
-
- /* release the property values */
- for (n = 1; n < N_PROPERTIES; ++n)
- if (G_IS_VALUE (preferences->values + n))
- g_value_unset (preferences->values + n);
-
- (*G_OBJECT_CLASS (tvm_preferences_parent_class)->finalize) (object);
-}
-
-
-
-static void
-tvm_preferences_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- TvmPreferences *preferences = TVM_PREFERENCES (object);
- GValue *src;
-
- src = preferences->values + prop_id;
- if (G_IS_VALUE (src))
- g_value_copy (src, value);
- else
- g_param_value_set_default (pspec, value);
-}
-
-
-
-static void
-tvm_preferences_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- TvmPreferences *preferences = TVM_PREFERENCES (object);
- GValue *dst;
-
- dst = preferences->values + prop_id;
- if (G_UNLIKELY (!G_IS_VALUE (dst)))
- {
- g_value_init (dst, pspec->value_type);
- g_param_value_set_default (pspec, dst);
- }
-
- if (g_param_values_cmp (pspec, value, dst) != 0)
- {
- g_value_copy (value, dst);
- tvm_preferences_queue_store (preferences);
- }
-}
-
-
-
-static void
-tvm_preferences_resume_monitor (TvmPreferences *preferences)
-{
- ThunarVfsPath *path;
- gchar *filename;
-
- /* verify that the monitor is suspended */
- if (G_LIKELY (preferences->handle == NULL))
- {
- /* determine the save location for tvmrc to monitor */
- filename = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "Thunar/volmanrc", TRUE);
- if (G_LIKELY (filename != NULL))
- {
- /* determine the VFS path for the filename */
- path = thunar_vfs_path_new (filename, NULL);
- if (G_LIKELY (path != NULL))
- {
- /* add the monitor handle for the file */
- preferences->handle = thunar_vfs_monitor_add_file (preferences->monitor, path, tvm_preferences_monitor, preferences);
- thunar_vfs_path_unref (path);
- }
-
- /* release the filename */
- g_free (filename);
- }
- }
-}
-
-
-
-static void
-tvm_preferences_suspend_monitor (TvmPreferences *preferences)
-{
- /* verify that the monitor is active */
- if (G_LIKELY (preferences->handle != NULL))
- {
- /* disconnect the handle from the monitor */
- thunar_vfs_monitor_remove (preferences->monitor, preferences->handle);
- preferences->handle = NULL;
- }
-}
-
-
-
-static void
-tvm_preferences_monitor (ThunarVfsMonitor *monitor,
- ThunarVfsMonitorHandle *handle,
- ThunarVfsMonitorEvent event,
- ThunarVfsPath *handle_path,
- ThunarVfsPath *event_path,
- gpointer user_data)
-{
- TvmPreferences *preferences = TVM_PREFERENCES (user_data);
-
- g_return_if_fail (TVM_IS_PREFERENCES (preferences));
- g_return_if_fail (THUNAR_VFS_IS_MONITOR (monitor));
- g_return_if_fail (preferences->monitor == monitor);
- g_return_if_fail (preferences->handle == handle);
-
- /* schedule a reload whenever the file is created/changed */
- if (event == THUNAR_VFS_MONITOR_EVENT_CHANGED || event == THUNAR_VFS_MONITOR_EVENT_CREATED)
- tvm_preferences_queue_load (preferences);
-}
-
-
-
-static void
-tvm_preferences_queue_load (TvmPreferences *preferences)
-{
- if (preferences->load_idle_id == 0 && preferences->store_idle_id == 0)
- {
- preferences->load_idle_id = g_idle_add_full (G_PRIORITY_LOW, tvm_preferences_load_idle,
- preferences, tvm_preferences_load_idle_destroy);
- }
-}
-
-
-
-static void
-tvm_preferences_queue_store (TvmPreferences *preferences)
-{
- if (preferences->store_idle_id == 0 && !preferences->loading_in_progress)
- {
- preferences->store_idle_id = g_idle_add_full (G_PRIORITY_LOW, tvm_preferences_store_idle,
- preferences, tvm_preferences_store_idle_destroy);
- }
-}
-
-
-
-static gchar*
-property_name_to_option_name (const gchar *property_name)
-{
- const gchar *s;
- gboolean upper = TRUE;
- gchar *option;
- gchar *t;
-
- option = g_new (gchar, strlen (property_name) + 1);
- for (s = property_name, t = option; *s != '\0'; ++s)
- {
- if (*s == '-')
- {
- upper = TRUE;
- }
- else if (upper)
- {
- *t++ = g_ascii_toupper (*s);
- upper = FALSE;
- }
- else
- {
- *t++ = *s;
- }
- }
- *t = '\0';
-
- return option;
-}
-
-
-
-static gboolean
-tvm_preferences_load_idle (gpointer user_data)
-{
- TvmPreferences *preferences = TVM_PREFERENCES (user_data);
- const gchar *string;
- GParamSpec **specs;
- GParamSpec *spec;
- XfceRc *rc;
- GValue dst = { 0, };
- GValue src = { 0, };
- gchar *option;
- guint nspecs;
- guint n;
-
- rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "Thunar/volmanrc", TRUE);
- if (G_UNLIKELY (rc == NULL))
- {
- g_warning ("Failed to load tvm preferences.");
- return FALSE;
- }
-
- g_object_freeze_notify (G_OBJECT (preferences));
-
- xfce_rc_set_group (rc, "Configuration");
-
- preferences->loading_in_progress = TRUE;
-
- specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
- for (n = 0; n < nspecs; ++n)
- {
- spec = specs[n];
-
- option = property_name_to_option_name (spec->name);
- string = xfce_rc_read_entry (rc, option, NULL);
- g_free (option);
-
- if (G_UNLIKELY (string == NULL))
- continue;
-
- g_value_init (&src, G_TYPE_STRING);
- g_value_set_static_string (&src, string);
-
- if (spec->value_type == G_TYPE_STRING)
- {
- g_object_set_property (G_OBJECT (preferences), spec->name, &src);
- }
- else if (g_value_type_transformable (G_TYPE_STRING, spec->value_type))
- {
- g_value_init (&dst, spec->value_type);
- if (g_value_transform (&src, &dst))
- g_object_set_property (G_OBJECT (preferences), spec->name, &dst);
- g_value_unset (&dst);
- }
- else
- {
- g_warning ("Failed to load property \"%s\"", spec->name);
- }
-
- g_value_unset (&src);
- }
- g_free (specs);
-
- preferences->loading_in_progress = FALSE;
-
- xfce_rc_close (rc);
-
- g_object_thaw_notify (G_OBJECT (preferences));
-
- return FALSE;
-}
-
-
-
-static void
-tvm_preferences_load_idle_destroy (gpointer user_data)
-{
- TVM_PREFERENCES (user_data)->load_idle_id = 0;
-}
-
-
-
-static gboolean
-tvm_preferences_store_idle (gpointer user_data)
-{
- TvmPreferences *preferences = TVM_PREFERENCES (user_data);
- const gchar *string;
- GParamSpec **specs;
- GParamSpec *spec;
- XfceRc *rc;
- GValue dst = { 0, };
- GValue src = { 0, };
- gchar *option;
- guint nspecs;
- guint n;
-
- rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "Thunar/volmanrc", FALSE);
- if (G_UNLIKELY (rc == NULL))
- {
- g_warning ("Failed to store thunar-volman preferences.");
- return FALSE;
- }
-
- /* suspend the monitor (hopefully tricking FAM to avoid unnecessary reloads) */
- tvm_preferences_suspend_monitor (preferences);
-
- xfce_rc_set_group (rc, "Configuration");
-
- specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs);
- for (n = 0; n < nspecs; ++n)
- {
- spec = specs[n];
-
- g_value_init (&dst, G_TYPE_STRING);
-
- if (spec->value_type == G_TYPE_STRING)
- {
- g_object_get_property (G_OBJECT (preferences), spec->name, &dst);
- }
- else
- {
- g_value_init (&src, spec->value_type);
- g_object_get_property (G_OBJECT (preferences), spec->name, &src);
- g_value_transform (&src, &dst);
- g_value_unset (&src);
- }
-
- /* determine the option name for the spec */
- option = property_name_to_option_name (spec->name);
-
- /* store the setting */
- string = g_value_get_string (&dst);
- if (G_LIKELY (string != NULL))
- xfce_rc_write_entry (rc, option, string);
-
- /* cleanup */
- g_value_unset (&dst);
- g_free (option);
- }
-
- /* cleanup */
- xfce_rc_close (rc);
- g_free (specs);
-
- /* restart the monitor */
- tvm_preferences_resume_monitor (preferences);
-
- return FALSE;
-}
-
-
-
-static void
-tvm_preferences_store_idle_destroy (gpointer user_data)
-{
- TVM_PREFERENCES (user_data)->store_idle_id = 0;
-}
-
-
-
-/**
- * tvm_preferences_get:
- *
- * Queries the global #TvmPreferences instance, which is shared
- * by all modules. The function automatically takes a reference
- * for the caller, so you'll need to call g_object_unref() when
- * you're done with it.
- *
- * Return value: the global #TvmPreferences instance.
- **/
-TvmPreferences*
-tvm_preferences_get (void)
-{
- static TvmPreferences *preferences = NULL;
-
- if (G_UNLIKELY (preferences == NULL))
- {
- preferences = g_object_new (TVM_TYPE_PREFERENCES, NULL);
- g_object_add_weak_pointer (G_OBJECT (preferences), (gpointer) &preferences);
- }
- else
- {
- g_object_ref (G_OBJECT (preferences));
- }
-
- return preferences;
-}
-
-
diff --git a/thunar-volman/tvm-preferences.h b/thunar-volman/tvm-preferences.h
deleted file mode 100644
index 3c80e07..0000000
--- a/thunar-volman/tvm-preferences.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2005-2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_PREFERENCES_H__
-#define __TVM_PREFERENCES_H__
-
-#include <exo/exo.h>
-
-G_BEGIN_DECLS
-
-typedef struct _TvmPreferencesClass TvmPreferencesClass;
-typedef struct _TvmPreferences TvmPreferences;
-
-#define TVM_TYPE_PREFERENCES (tvm_preferences_get_type ())
-#define TVM_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TVM_TYPE_PREFERENCES, TvmPreferences))
-#define TVM_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TVM_TYPE_PREFERENCES, TvmPreferencesClass))
-#define TVM_IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TVM_TYPE_PREFERENCES))
-#define TVM_IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TVM_TYPE_PREFERENCES))
-#define TVM_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TVM_TYPE_PREFERENCES, TvmPreferencesClass))
-
-GType tvm_preferences_get_type (void) G_GNUC_CONST;
-
-TvmPreferences *tvm_preferences_get (void);
-
-G_END_DECLS
-
-#endif /* !__TVM_PREFERENCES_H__ */
diff --git a/thunar-volman/tvm-printer-device.c b/thunar-volman/tvm-printer-device.c
deleted file mode 100644
index 2ae24f8..0000000
--- a/thunar-volman/tvm-printer-device.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <thunar-volman/tvm-printer-device.h>
-#include <thunar-volman/tvm-run.h>
-
-
-
-/**
- * tvm_printer_device_added:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the HAL device UDI of the newly added printer device.
- * @capability : the capability, which caused this handler to be run.
- * @error : return location for errors or %NULL.
- *
- * See #TvmDeviceCallback for further information.
- *
- * Return value: %TRUE if handled, %FALSE if not handled or an
- * unrecoverable error occurred.
- **/
-gboolean
-tvm_printer_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error)
-{
- gboolean result = FALSE;
- gboolean autoprinter;
- gchar *autoprinter_command;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (capability != NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- /* check if we have a command to run for newly connected printers */
- g_object_get (G_OBJECT (preferences), "autoprinter", &autoprinter, "autoprinter-command", &autoprinter_command, NULL);
- if (G_LIKELY (autoprinter && autoprinter_command != NULL && *autoprinter_command != '\0'))
- {
- /* run the selected command for the user */
- result = tvm_run_command (context, udi, autoprinter_command, NULL, NULL, error);
- }
- g_free (autoprinter_command);
-
- return result;
-}
-
-
-
-
diff --git a/thunar-volman/tvm-printer-device.h b/thunar-volman/tvm-printer-device.h
deleted file mode 100644
index ef34ce9..0000000
--- a/thunar-volman/tvm-printer-device.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_PRINTER_DEVICE_H__
-#define __TVM_PRINTER_DEVICE_H__
-
-#include <thunar-volman/tvm-device.h>
-
-G_BEGIN_DECLS
-
-gboolean tvm_printer_device_added (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- const gchar *capability,
- GError **error) G_GNUC_INTERNAL;
-
-G_END_DECLS
-
-#endif /* !__TVM_PRINTER_DEVICE_H__ */
diff --git a/thunar-volman/tvm-prompt.c b/thunar-volman/tvm-prompt.c
deleted file mode 100644
index 756bfa5..0000000
--- a/thunar-volman/tvm-prompt.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-
-#include <thunar-volman/tvm-pango-extensions.h>
-#include <thunar-volman/tvm-prompt.h>
-
-
-
-static void
-hal_device_removed (LibHalContext *context,
- const gchar *udi)
-{
- const gchar *dialog_udi;
- GtkWidget *dialog = libhal_ctx_get_user_data (context);
-
- /* check if the active UDI of the dialog was removed */
- dialog_udi = g_object_get_data (G_OBJECT (dialog), "udi");
- if (exo_str_is_equal (dialog_udi, udi))
- {
- /* cancel the dialog */
- gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
- }
-}
-
-
-
-/**
- * tvm_prompt:
- * @context : a #LibHalContext.
- * @udi : the UDI of the device being added, which is watched for removal.
- * @icon : the icon or %NULL.
- * @title : the prompt title.
- * @primary_text : the primary prompt text.
- * @secondary_text : the secondary prompt text.
- * @first_button_text : the first button text.
- * @... : %NULL-terminated list of button text, response id pairs.
- *
- * Return value: the selected response.
- **/
-gint
-tvm_prompt (LibHalContext *context,
- const gchar *udi,
- const gchar *icon,
- const gchar *title,
- const gchar *primary_text,
- const gchar *secondary_text,
- const gchar *first_button_text,
- ...)
-{
- GtkWidget *dialog;
- GtkWidget *image;
- GtkWidget *label;
- GtkWidget *hbox;
- GtkWidget *vbox;
- DBusError derror;
- va_list args;
- gint response;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), GTK_RESPONSE_CANCEL);
- g_return_val_if_fail (context != NULL, GTK_RESPONSE_CANCEL);
-
- /* allocate a new dialog */
- dialog = gtk_dialog_new ();
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- g_object_set_data_full (G_OBJECT (dialog), "udi", g_strdup (udi), g_free);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 6);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12);
-
- /* setup the specified title */
- if (G_LIKELY (title != NULL))
- gtk_window_set_title (GTK_WINDOW (dialog), title);
-
- /* setup the specified buttons */
- if (G_LIKELY (first_button_text != NULL))
- {
- va_start (args, first_button_text);
- for (response = va_arg (args, gint); first_button_text != NULL; )
- {
- /* insert the button */
- gtk_dialog_add_button (GTK_DIALOG (dialog), first_button_text, response);
- first_button_text = va_arg (args, const gchar *);
- if (G_UNLIKELY (first_button_text == NULL))
- break;
- response = va_arg (args, gint);
- }
- va_end (args);
- }
-
- /* setup the hbox */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- /* setup the specified icon */
- if (G_LIKELY (icon != NULL))
- {
- /* setup an image for the icon */
- image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.0f, 0.0f);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
- gtk_widget_show (image);
- }
-
- /* setup the vbox */
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
- gtk_widget_show (vbox);
-
- /* setup the primary text */
- label = gtk_label_new (primary_text);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f);
- gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_big_bold ());
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- /* setup the secondary text */
- if (G_LIKELY (secondary_text != NULL))
- {
- label = gtk_label_new (secondary_text);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
- }
-
- /* initialize D-Bus error */
- dbus_error_init (&derror);
-
- /* setup HAL to watch the UDI for removal */
- libhal_ctx_set_user_data (context, dialog);
- libhal_ctx_set_device_removed (context, hal_device_removed);
- libhal_device_property_watch_all (context, &derror);
-
- /* run the dialog */
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- /* cleanup */
- libhal_ctx_set_device_removed (context, NULL);
- libhal_ctx_set_user_data (context, NULL);
- gtk_widget_destroy (dialog);
- dbus_error_free (&derror);
-
- return response;
-}
-
-
diff --git a/thunar-volman/tvm-prompt.h b/thunar-volman/tvm-prompt.h
deleted file mode 100644
index ec0c2b7..0000000
--- a/thunar-volman/tvm-prompt.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@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 (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __TVM_PROMPT_H__
-#define __TVM_PROMPT_H__
-
-#include <thunar-volman/tvm-device.h>
-
-G_BEGIN_DECLS
-
-enum
-{
- TVM_RESPONSE_NONE,
- TVM_RESPONSE_PLAY,
- TVM_RESPONSE_MUSIC,
- TVM_RESPONSE_BROWSE,
- TVM_RESPONSE_PHOTOS,
- TVM_RESPONSE_AUTORUN,
- TVM_RESPONSE_AUTOOPEN,
- TVM_RESPONSE_BURN_DATA_CD,
- TVM_RESPONSE_BURN_AUDIO_CD,
-};
-
-gint tvm_prompt (LibHalContext *context,
- const gchar *udi,
- const gchar *icon,
- const gchar *title,
- const gchar *primary_text,
- const gchar *secondary_text,
- const gchar *first_button_text,
- ...) G_GNUC_INTERNAL G_GNUC_NULL_TERMINATED;
-
-G_END_DECLS
-
-#endif /* !__TVM_PROMPT_H__ */
diff --git a/thunar-volman/tvm-run.c b/thunar-volman/tvm-run.c
index 1f2f951..23ea8aa 100644
--- a/thunar-volman/tvm-run.c
+++ b/thunar-volman/tvm-run.c
@@ -1,255 +1,54 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@xfce.org>.
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option)
- * any later version.
+ * 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 (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
+#include <gio/gio.h>
-#include <thunar-volman/tvm-prompt.h>
+#include <thunar-volman/tvm-context.h>
#include <thunar-volman/tvm-run.h>
-static void tvm_run_resolve (LibHalContext *context,
- const gchar *udi,
- gchar **device_file_return,
- gchar **mount_point_return);
-
-
-
-static void
-tvm_run_resolve (LibHalContext *context,
- const gchar *udi,
- gchar **device_file_return,
- gchar **mount_point_return)
-{
- GSList *mount_points;
- gchar *device_file;
-
- /* initialize return values */
- if (device_file_return != NULL)
- *device_file_return = NULL;
- if (mount_point_return != NULL)
- *mount_point_return = NULL;
-
- /* determine the device file path of the device */
- device_file = libhal_device_get_property_string (context, udi, "block.device", NULL);
- if (G_LIKELY (device_file != NULL))
- {
- /* determine the active mount point(s) for the device from the kernel */
- mount_points = exo_mount_point_list_matched (EXO_MOUNT_POINT_MATCH_ACTIVE | EXO_MOUNT_POINT_MATCH_DEVICE, device_file, NULL, NULL, NULL);
- if (G_LIKELY (mount_points != NULL))
- {
- /* return the mount point folder path */
- if (G_LIKELY (mount_point_return != NULL))
- *mount_point_return = g_strdup (((ExoMountPoint *) mount_points->data)->folder);
-
- /* release the mount points */
- g_slist_foreach (mount_points, (GFunc) exo_mount_point_free, NULL);
- g_slist_free (mount_points);
- }
-
- /* return the device file path */
- if (G_LIKELY (device_file_return != NULL))
- *device_file_return = g_strdup (device_file);
-
- /* cleanup */
- libhal_free_string (device_file);
- }
-}
-
-
-
-/**
- * tvm_run_cdburner:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the UDI of the blank CD/DVD.
- * @error : return location for errors or %NULL.
- *
- * Tries to spawn the preferred CD-Burner application for the
- * given @udi. Returns %TRUE if the device was handled, %FALSE
- * if not handled or an unrecoverable error occurred.
- *
- * Return value: %TRUE if handled, %FALSE otherwise.
- **/
-gboolean
-tvm_run_cdburner (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- GError **error)
-{
- const gchar *autoburn_command_name;
- gboolean autoburn;
- gboolean result = FALSE;
- gboolean is_dvd;
- gchar *autoburn_command;
- gchar *disc_type;
- gint response;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- /* check if autoburn is enabled */
- g_object_get (G_OBJECT (preferences), "autoburn", &autoburn, NULL);
- if (G_UNLIKELY (!autoburn))
- return TRUE;
-
- /* check if we have a DVD here */
- disc_type = libhal_device_get_property_string (context, udi, "volume.disc.type", NULL);
- is_dvd = (disc_type != NULL && strncmp (disc_type, "dvd_", 4) == 0);
- libhal_free_string (disc_type);
-
- /* ask the user what to do now */
- if (G_LIKELY (is_dvd))
- {
- /* ask what to do with the empty DVD */
- response = tvm_prompt (context, udi, "gnome-dev-disc-dvdr",
- _("Choose Disc Type"),
- _("You have inserted a blank disc."),
- _("What would you like to do?"),
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("Make _DVD"), TVM_RESPONSE_BURN_DATA_CD,
- NULL);
- }
- else
- {
- /* ask whether to burn data or audio CD */
- response = tvm_prompt (context, udi, "gnome-dev-disc-cdr",
- _("Choose Disc Type"),
- _("You have inserted a blank disc."),
- _("What would you like to do?"),
- _("Ig_nore"), GTK_RESPONSE_CANCEL,
- _("Make _Data CD"), TVM_RESPONSE_BURN_DATA_CD,
- _("Make _Audio CD"), TVM_RESPONSE_BURN_AUDIO_CD,
- NULL);
- }
-
- /* determine the autoburn command name */
- if (response == TVM_RESPONSE_BURN_DATA_CD)
- autoburn_command_name = "autoburn-data-command";
- else if (response == TVM_RESPONSE_BURN_AUDIO_CD)
- autoburn_command_name = "autoburn-audio-command";
- else
- return TRUE;
-
- /* determine the command */
- g_object_get (G_OBJECT (preferences), autoburn_command_name, &autoburn_command, NULL);
- if (G_LIKELY (autoburn_command != NULL && *autoburn_command != '\0'))
- {
- /* try to execute the preferred CD-Burner application */
- result = tvm_run_command (context, udi, autoburn_command, NULL, NULL, error);
- }
- g_free (autoburn_command);
-
- return result;
-}
-
-
-
-/**
- * tvm_run_cdplayer:
- * @preferences : a #TvmPreferences.
- * @context : a #LibHalContext.
- * @udi : the UDI of the Audio CD.
- * @error : return location for errors or %NULL.
- *
- * Tries to spawn the preferred CD-Player application for the
- * given @udi. Returns %TRUE if the device was handled, %FALSE
- * if not handled or an unrecoverable error occurred.
- *
- * Return value: %TRUE if handled, %FALSE otherwise.
- **/
-gboolean
-tvm_run_cdplayer (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- GError **error)
-{
- gboolean autoplay;
- gboolean result = TRUE;
- gchar *autoplay_command;
-
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (TVM_IS_PREFERENCES (preferences), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
-
- /* check if autoplay is enabled and we have a command */
- g_object_get (G_OBJECT (preferences), "autoplay-audio-cd", &autoplay, "autoplay-audio-cd-command", &autoplay_command, NULL);
- if (G_LIKELY (autoplay && autoplay_command != NULL && *autoplay_command != '\0'))
- {
- /* try to run the preferred CD-Player application */
- result = tvm_run_command (context, udi, autoplay_command, NULL, NULL, error);
- }
- g_free (autoplay_command);
-
- return result;
-}
-
-
-
-/**
- * tvm_run_command:
- * @context : a #LibHalContext.
- * @udi : the UDI of the device for which to run the @command.
- * @command : the command line of the application to spawn.
- * @device_file : the value to substitute for <literal>%d</literal> or %NULL.
- * @mount_point : the value to substitute for <literal>%m</literal> or %NULL.
- * @error : return location for errors or %NULL.
- *
- * Substitutes special values in @command and tries to spawn the application
- * identified by the @command.
- *
- * The HAL UDI will be substituted for <literal>%h</literal>, the device file path
- * for <literal>%d</literal> and the mount point for <literal>%m</literal>.
- *
- * Return value: %TRUE if the command was spawn successfully, %FALSE otherwise.
- **/
gboolean
-tvm_run_command (LibHalContext *context,
- const gchar *udi,
- const gchar *command,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error)
+tvm_run_command (TvmContext *context,
+ GMount *mount,
+ const gchar *command,
+ GError **error)
{
+ const gchar *device_file;
const gchar *p;
gboolean result;
GString *command_line;
- gchar *quoted;
- gchar *device;
- gchar *folder;
+ GError *err = NULL;
+ GFile *mount_point;
gchar **argv;
+ gchar *mount_path;
+ gchar *quoted;
- g_return_val_if_fail (exo_hal_udi_validate (udi, -1, NULL), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (context != NULL, FALSE);
+ g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
+ g_return_val_if_fail (command != NULL && *command != '\0', FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* perform the required substitutions */
command_line = g_string_new (NULL);
@@ -262,30 +61,18 @@ tvm_run_command (LibHalContext *context,
switch (*++p)
{
case 'd': /* device file */
- /* check if know the device file path */
+ device_file = g_udev_device_get_device_file (context->device);
if (G_LIKELY (device_file != NULL))
- device = g_strdup (device_file);
- else
- tvm_run_resolve (context, udi, &device, NULL);
- if (G_LIKELY (device != NULL))
- g_string_append (command_line, device);
- g_free (device);
- break;
-
- case 'h': /* HAL UDI */
- g_string_append (command_line, udi);
+ g_string_append (command_line, device_file);
break;
case 'm': /* mount point */
- /* check if know the mount point */
- if (G_LIKELY (mount_point != NULL))
- folder = g_strdup (mount_point);
- else
- tvm_run_resolve (context, udi, NULL, &folder);
- if (G_LIKELY (folder != NULL))
+ mount_point = g_mount_get_root (mount);
+ mount_path = g_file_get_path (mount_point);
+ if (G_LIKELY (mount_path != NULL))
{
/* substitute mount point quoted */
- quoted = g_shell_quote (folder);
+ quoted = g_shell_quote (mount_path);
g_string_append (command_line, quoted);
g_free (quoted);
}
@@ -294,7 +81,8 @@ tvm_run_command (LibHalContext *context,
/* %m must always be substituted */
g_string_append (command_line, "\"\"");
}
- g_free (folder);
+ g_free (mount_path);
+ g_object_unref (mount_point);
break;
case '%':
@@ -315,11 +103,14 @@ tvm_run_command (LibHalContext *context,
}
/* try to parse the command line */
- result = g_shell_parse_argv (command_line->str, NULL, &argv, error);
+ result = g_shell_parse_argv (command_line->str, NULL, &argv, &err);
if (G_LIKELY (result))
{
+ g_debug ("%s", command_line->str);
+
/* try to spawn the command asynchronously in the users home directory */
- result = g_spawn_async (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, error);
+ result = g_spawn_async (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL, &err);
/* cleanup */
g_strfreev (argv);
@@ -328,8 +119,8 @@ tvm_run_command (LibHalContext *context,
/* cleanup */
g_string_free (command_line, TRUE);
+ if (err != NULL)
+ g_propagate_error (error, err);
+
return result;
}
-
-
-
diff --git a/thunar-volman/tvm-run.h b/thunar-volman/tvm-run.h
index 9e50a98..cd450db 100644
--- a/thunar-volman/tvm-run.h
+++ b/thunar-volman/tvm-run.h
@@ -1,45 +1,36 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
- * Copyright (c) 2007 Benedikt Meurer <benny@xfce.org>.
+ * Copyright (c) 2010 Jannis Pohlmann <jannis@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 (at your option)
- * any later version.
+ * 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 (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifndef __TVM_RUN_H__
#define __TVM_RUN_H__
-#include <thunar-volman/tvm-device.h>
+#include <gio/gio.h>
-G_BEGIN_DECLS
-
-gboolean tvm_run_cdburner (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- GError **error) G_GNUC_INTERNAL;
+#include <thunar-volman/tvm-context.h>
-gboolean tvm_run_cdplayer (TvmPreferences *preferences,
- LibHalContext *context,
- const gchar *udi,
- GError **error) G_GNUC_INTERNAL;
+G_BEGIN_DECLS
-gboolean tvm_run_command (LibHalContext *context,
- const gchar *udi,
- const gchar *command,
- const gchar *device_file,
- const gchar *mount_point,
- GError **error) G_GNUC_INTERNAL;
+gboolean tvm_run_command (TvmContext *context,
+ GMount *mount,
+ const gchar *command,
+ GError **error);
G_END_DECLS
diff --git a/thunar-volman/xfce-heading.c b/thunar-volman/xfce-heading.c
deleted file mode 100644
index e0ebdcd..0000000
--- a/thunar-volman/xfce-heading.c
+++ /dev/null
@@ -1,755 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include "xfce-heading.h"
-
-
-
-#define XFCE_HEADING_BORDER 6
-#define XFCE_HEADING_SPACING 12
-#define XFCE_HEADING_ICON_SIZE 48
-
-#define XFCE_HEADING_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), XFCE_TYPE_HEADING, XfceHeadingPrivate))
-
-
-
-/* Property identifiers */
-enum
-{
- PROP_0,
- PROP_ICON,
- PROP_ICON_NAME,
- PROP_SUBTITLE,
- PROP_TITLE,
-};
-
-
-
-static void xfce_heading_class_init (XfceHeadingClass *klass);
-static void xfce_heading_init (XfceHeading *heading);
-static void xfce_heading_finalize (GObject *object);
-static void xfce_heading_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void xfce_heading_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void xfce_heading_realize (GtkWidget *widget);
-static void xfce_heading_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void xfce_heading_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
-static gboolean xfce_heading_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static AtkObject *xfce_heading_get_accessible (GtkWidget *widget);
-static PangoLayout *xfce_heading_make_layout (XfceHeading *heading);
-static GdkPixbuf *xfce_heading_make_pixbuf (XfceHeading *heading);
-
-
-
-struct _XfceHeadingPrivate
-{
- GdkPixbuf *icon;
- gchar *icon_name;
- gchar *subtitle;
- gchar *title;
-};
-
-
-
-G_DEFINE_TYPE (XfceHeading, xfce_heading, GTK_TYPE_WIDGET);
-
-
-
-static void
-xfce_heading_class_init (XfceHeadingClass *klass)
-{
- GtkWidgetClass *gtkwidget_class;
- GObjectClass *gobject_class;
-
- /* add our private data to the class */
- g_type_class_add_private (klass, sizeof (XfceHeadingPrivate));
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xfce_heading_finalize;
- gobject_class->get_property = xfce_heading_get_property;
- gobject_class->set_property = xfce_heading_set_property;
-
- gtkwidget_class = GTK_WIDGET_CLASS (klass);
- gtkwidget_class->realize = xfce_heading_realize;
- gtkwidget_class->size_request = xfce_heading_size_request;
- gtkwidget_class->style_set = xfce_heading_style_set;
- gtkwidget_class->expose_event = xfce_heading_expose_event;
- gtkwidget_class->get_accessible = xfce_heading_get_accessible;
-
- /**
- * XfceHeading:icon:
- *
- * The #GdkPixbuf to display as icon, or %NULL to use the
- * "icon-name" property.
- *
- * Since: 4.4.0
- **/
- g_object_class_install_property (gobject_class,
- PROP_ICON,
- g_param_spec_object ("icon",
- "icon",
- "icon",
- GDK_TYPE_PIXBUF,
- G_PARAM_READWRITE));
-
- /**
- * XfceHeading:icon-name:
- *
- * If the "icon" property value is %NULL this is the name of
- * the icon to display instead (looked up using the icon theme).
- * If this property is also %NULL or the specified icon does not
- * exist in the selected icon theme, no icon will be displayed.
- *
- * Since: 4.4.0
- **/
- g_object_class_install_property (gobject_class,
- PROP_ICON_NAME,
- g_param_spec_string ("icon-name",
- "icon-name",
- "icon-name",
- NULL,
- G_PARAM_READWRITE));
-
- /**
- * XfceHeading:subtitle:
- *
- * The sub title that should be displayed below the
- * title. May be %NULL or the empty string to display
- * only the title.
- *
- * Since: 4.4.0
- **/
- g_object_class_install_property (gobject_class,
- PROP_SUBTITLE,
- g_param_spec_string ("subtitle",
- "subtitle",
- "subtitle",
- NULL,
- G_PARAM_READWRITE));
-
- /**
- * XfceHeading:title:
- *
- * The title text to display in the heading.
- *
- * Since: 4.4.0
- **/
- g_object_class_install_property (gobject_class,
- PROP_TITLE,
- g_param_spec_string ("title",
- "title",
- "title",
- NULL,
- G_PARAM_READWRITE));
-}
-
-
-
-static void
-xfce_heading_init (XfceHeading *heading)
-{
- /* setup the private data */
- heading->priv = XFCE_HEADING_GET_PRIVATE (heading);
-
- /* setup the widget parameters */
- GTK_WIDGET_UNSET_FLAGS (heading, GTK_NO_WINDOW);
-}
-
-
-
-static void
-xfce_heading_finalize (GObject *object)
-{
- XfceHeading *heading = XFCE_HEADING (object);
-
- /* release the private data */
- if (G_UNLIKELY (heading->priv->icon != NULL))
- g_object_unref (G_OBJECT (heading->priv->icon));
- g_free (heading->priv->icon_name);
- g_free (heading->priv->subtitle);
- g_free (heading->priv->title);
-
- (*G_OBJECT_CLASS (xfce_heading_parent_class)->finalize) (object);
-}
-
-
-
-static void
-xfce_heading_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- XfceHeading *heading = XFCE_HEADING (object);
-
- switch (prop_id)
- {
- case PROP_ICON:
- g_value_set_object (value, xfce_heading_get_icon (heading));
- break;
-
- case PROP_ICON_NAME:
- g_value_set_string (value, xfce_heading_get_icon_name (heading));
- break;
-
- case PROP_SUBTITLE:
- g_value_set_string (value, xfce_heading_get_subtitle (heading));
- break;
-
- case PROP_TITLE:
- g_value_set_string (value, xfce_heading_get_title (heading));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static void
-xfce_heading_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- XfceHeading *heading = XFCE_HEADING (object);
-
- switch (prop_id)
- {
- case PROP_ICON:
- xfce_heading_set_icon (heading, g_value_get_object (value));
- break;
-
- case PROP_ICON_NAME:
- xfce_heading_set_icon_name (heading, g_value_get_string (value));
- break;
-
- case PROP_SUBTITLE:
- xfce_heading_set_subtitle (heading, g_value_get_string (value));
- break;
-
- case PROP_TITLE:
- xfce_heading_set_title (heading, g_value_get_string (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static void
-xfce_heading_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
-
- /* mark the widget as realized */
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- /* setup the window attributes */
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK;
-
- /* allocate the widget window */
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes,
- GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP);
- gdk_window_set_user_data (widget->window, widget);
-
- /* connect the style to the window */
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- /* set background color (using the base color) */
- gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
-}
-
-
-
-static void
-xfce_heading_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- XfceHeading *heading = XFCE_HEADING (widget);
- PangoLayout *layout;
- GdkPixbuf *pixbuf;
- gint layout_width;
- gint layout_height;
- gint pixbuf_width = 0;
- gint pixbuf_height = 0;
-
- /* determine the dimensions of the title text */
- layout = xfce_heading_make_layout (heading);
- pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
- g_object_unref (G_OBJECT (layout));
-
- /* determine the dimensions of the pixbuf */
- pixbuf = xfce_heading_make_pixbuf (heading);
- if (G_LIKELY (pixbuf != NULL))
- {
- pixbuf_width = gdk_pixbuf_get_width (pixbuf);
- pixbuf_height = gdk_pixbuf_get_height (pixbuf);
- g_object_unref (G_OBJECT (pixbuf));
- }
-
- /* determine the base dimensions */
- requisition->width = layout_width + pixbuf_width + ((pixbuf_width > 0) ? XFCE_HEADING_SPACING : 0);
- requisition->height = MAX (XFCE_HEADING_ICON_SIZE, MAX (pixbuf_height, layout_height));
-
- /* add border size */
- requisition->width += 2 * XFCE_HEADING_BORDER;
- requisition->height += 2 * XFCE_HEADING_BORDER;
-}
-
-
-
-static void
-xfce_heading_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
-{
- /* check if we're already realized */
- if (GTK_WIDGET_REALIZED (widget))
- {
- /* set background color (using the base color) */
- gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
- }
-}
-
-
-
-static gboolean
-xfce_heading_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
-{
- XfceHeading *heading = XFCE_HEADING (widget);
- PangoLayout *layout;
- GdkPixbuf *pixbuf;
- gboolean rtl;
- gint width;
- gint height;
- gint x;
- gint y;
-
- /* check if we should render from right to left */
- rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
-
- /* determine the initial horizontal position */
- x = (rtl ? widget->allocation.width - XFCE_HEADING_BORDER : XFCE_HEADING_BORDER);
-
- /* check if we have a pixbuf to render */
- pixbuf = xfce_heading_make_pixbuf (heading);
- if (G_LIKELY (pixbuf != NULL))
- {
- /* determine the pixbuf dimensions */
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
-
- /* determine the vertical position */
- y = (widget->allocation.height - height) / 2;
-
- /* render the pixbuf */
- gdk_draw_pixbuf (widget->window, widget->style->black_gc, pixbuf, 0, 0,
- (rtl ? x - width : x), y, width, height,
- GDK_RGB_DITHER_NORMAL, 0, 0);
-
- /* release the pixbuf */
- g_object_unref (G_OBJECT (pixbuf));
-
- /* advance the horizontal position */
- x += (rtl ? -1 : 1) * (width + XFCE_HEADING_SPACING);
- }
-
- /* generate the title layout */
- layout = xfce_heading_make_layout (heading);
- pango_layout_get_pixel_size (layout, &width, &height);
-
- /* determine the vertical position */
- y = (widget->allocation.height - height) / 2;
-
- /* render the title */
- gtk_paint_layout (widget->style, widget->window, GTK_WIDGET_STATE (widget), TRUE, &event->area,
- widget, "heading", (rtl ? x - width : x), y, layout);
-
- /* release the layout */
- g_object_unref (G_OBJECT (layout));
-
- return FALSE;
-}
-
-
-
-static AtkObject*
-xfce_heading_get_accessible (GtkWidget *widget)
-{
- AtkObject *object;
-
- object = (*GTK_WIDGET_CLASS (xfce_heading_parent_class)->get_accessible) (widget);
- atk_object_set_role (object, ATK_ROLE_HEADER);
-
- return object;
-}
-
-
-
-static PangoLayout*
-xfce_heading_make_layout (XfceHeading *heading)
-{
- PangoAttribute *attribute;
- PangoAttrList *attr_list;
- PangoLayout *layout;
- GString *text;
- gint title_length = 0;
-
- /* generate the full text */
- text = g_string_sized_new (128);
- if (G_LIKELY (heading->priv->title != NULL))
- {
- /* add the main title */
- title_length = strlen (heading->priv->title);
- g_string_append (text, heading->priv->title);
- }
- if (heading->priv->subtitle != NULL && *heading->priv->subtitle != '\0')
- {
- /* add an empty line between the title and the subtitle */
- if (G_LIKELY (heading->priv->title != NULL))
- g_string_append (text, "\n");
-
- /* add the subtitle */
- g_string_append (text, heading->priv->subtitle);
- }
-
- /* allocate and setup a new layout from the widget's context */
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (heading), text->str);
-
- /* allocate an attribute list (large bold title) */
- attr_list = pango_attr_list_new ();
- attribute = pango_attr_scale_new (PANGO_SCALE_LARGE); /* large title */
- attribute->start_index = 0;
- attribute->end_index = title_length;
- pango_attr_list_insert (attr_list, attribute);
- attribute = pango_attr_weight_new (PANGO_WEIGHT_BOLD); /* bold title */
- attribute->start_index = 0;
- attribute->end_index = title_length;
- pango_attr_list_insert (attr_list, attribute);
- pango_layout_set_attributes (layout, attr_list);
- pango_attr_list_unref (attr_list);
-
- /* cleanup */
- g_string_free (text, TRUE);
-
- return layout;
-}
-
-
-
-static GdkPixbuf*
-xfce_heading_make_pixbuf (XfceHeading *heading)
-{
- GtkIconTheme *icon_theme;
- GdkPixbuf *pixbuf = NULL;
- GdkScreen *screen;
-
- if (G_UNLIKELY (heading->priv->icon != NULL))
- {
- /* just use the specified icon */
- pixbuf = g_object_ref (G_OBJECT (heading->priv->icon));
- }
- else if (G_LIKELY (heading->priv->icon_name != NULL))
- {
- /* determine the icon theme for the current screen */
- screen = gtk_widget_get_screen (GTK_WIDGET (heading));
- icon_theme = gtk_icon_theme_get_for_screen (screen);
-
- /* try to load the icon from the icon theme */
- pixbuf = gtk_icon_theme_load_icon (icon_theme, heading->priv->icon_name,
- XFCE_HEADING_ICON_SIZE,
- GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
- }
-
- return pixbuf;
-}
-
-
-
-/**
- * xfce_heading_new:
- *
- * Allocates a new #XfceHeading instance.
- *
- * Return value: the newly allocated #XfceHeading.
- *
- * Since: 4.4.0
- **/
-GtkWidget*
-xfce_heading_new (void)
-{
- return g_object_new (XFCE_TYPE_HEADING, NULL);
-}
-
-
-
-/**
- * xfce_heading_get_icon:
- * @heading : a #XfceHeading.
- *
- * Returns the #GdkPixbuf that was set as icon for
- * @heading or %NULL if no icon is set. The returned
- * #GdkPixbuf object is owned by @heading.
- *
- * Return value: the icon for @heading, or %NULL.
- *
- * Since: 4.4.0
- **/
-GdkPixbuf*
-xfce_heading_get_icon (XfceHeading *heading)
-{
- g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
- return heading->priv->icon;
-}
-
-
-
-/**
- * xfce_heading_set_icon:
- * @heading : a #XfceHeading.
- * @icon : the new icon or %NULL.
- *
- * If @icon is not %NULL, @heading will display the new @icon
- * aside the title. Else, if @icon is %NULL no icon is displayed
- * unless an icon name was set with xfce_heading_set_icon_name().
- *
- * Since: 4.4.0
- **/
-void
-xfce_heading_set_icon (XfceHeading *heading,
- GdkPixbuf *icon)
-{
- g_return_if_fail (XFCE_IS_HEADING (heading));
- g_return_if_fail (icon == NULL || GDK_IS_PIXBUF (icon));
-
- /* check if we have a new icon */
- if (G_LIKELY (heading->priv->icon != icon))
- {
- /* disconnect from the previous icon */
- if (G_LIKELY (heading->priv->icon != NULL))
- g_object_unref (G_OBJECT (heading->priv->icon));
-
- /* activate the new icon */
- heading->priv->icon = icon;
-
- /* connect to the new icon */
- if (G_LIKELY (icon != NULL))
- g_object_ref (G_OBJECT (icon));
-
- /* schedule a resize */
- gtk_widget_queue_resize (GTK_WIDGET (heading));
-
- /* notify listeners */
- g_object_notify (G_OBJECT (heading), "icon");
- }
-}
-
-
-
-/**
- * xfce_heading_get_icon_name:
- * @heading : a #XfceHeading.
- *
- * Returns the icon name previously set by a call to
- * xfce_heading_set_icon_name() or %NULL if no icon name
- * is set for @heading.
- *
- * Return value: the icon name for @heading, or %NULL.
- *
- * Since: 4.4.0
- **/
-G_CONST_RETURN gchar*
-xfce_heading_get_icon_name (XfceHeading *heading)
-{
- g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
- return heading->priv->icon_name;
-}
-
-
-
-/**
- * xfce_heading_set_icon_name:
- * @heading : a #XfceHeading.
- * @icon_name : the new icon name, or %NULL.
- *
- * If @icon_name is not %NULL and the "icon" property is set to
- * %NULL, see xfce_heading_set_icon(), the @heading will display
- * the name icon identified by the @icon_name.
- *
- * Since: 4.4.0
- **/
-void
-xfce_heading_set_icon_name (XfceHeading *heading,
- const gchar *icon_name)
-{
- g_return_if_fail (XFCE_IS_HEADING (heading));
-
- /* release the previous icon name */
- g_free (heading->priv->icon_name);
-
- /* activate the new icon name */
- heading->priv->icon_name = g_strdup (icon_name);
-
- /* schedule a resize */
- gtk_widget_queue_resize (GTK_WIDGET (heading));
-
- /* notify listeners */
- g_object_notify (G_OBJECT (heading), "icon-name");
-}
-
-
-
-/**
- * xfce_heading_get_subtitle:
- * @heading : a #XfceHeading.
- *
- * Returns the sub title displayed below the
- * main title of the @heading, or %NULL if
- * no subtitle is set.
- *
- * Return value: the subtitle of @heading, or %NULL.
- *
- * Since: 4.4.0
- **/
-G_CONST_RETURN gchar*
-xfce_heading_get_subtitle (XfceHeading *heading)
-{
- g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
- return heading->priv->subtitle;
-}
-
-
-
-/**
- * xfce_heading_set_subtitle:
- * @heading : a #XfceHeading.
- * @subtitle : the new subtitle for @heading, or %NULL.
- *
- * If @subtitle is not %NULL and not the empty string, it
- * will be displayed by @heading below the main title.
- *
- * Since: 4.4.0
- **/
-void
-xfce_heading_set_subtitle (XfceHeading *heading,
- const gchar *subtitle)
-{
- g_return_if_fail (XFCE_IS_HEADING (heading));
- g_return_if_fail (subtitle == NULL || g_utf8_validate (subtitle, -1, NULL));
-
- /* release the previous subtitle */
- g_free (heading->priv->subtitle);
-
- /* activate the new subtitle */
- heading->priv->subtitle = g_strdup (subtitle);
-
- /* schedule a resize */
- gtk_widget_queue_resize (GTK_WIDGET (heading));
-
- /* notify listeners */
- g_object_notify (G_OBJECT (heading), "subtitle");
-}
-
-
-
-/**
- * xfce_heading_get_title:
- * @heading : a #XfceHeading.
- *
- * Returns the title displayed by the @heading.
- *
- * Return value: the title displayed by the @heading.
- *
- * Since: 4.4.0
- **/
-G_CONST_RETURN gchar*
-xfce_heading_get_title (XfceHeading *heading)
-{
- g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
- return heading->priv->title;
-}
-
-
-
-/**
- * xfce_heading_set_title:
- * @heading : a #XfceHeading.
- * @title : the new title for the @heading.
- *
- * Sets the title displayed by the @heading to the
- * specified @title.
- *
- * Since: 4.4.0
- **/
-void
-xfce_heading_set_title (XfceHeading *heading,
- const gchar *title)
-{
- g_return_if_fail (XFCE_IS_HEADING (heading));
- g_return_if_fail (title == NULL || g_utf8_validate (title, -1, NULL));
-
- /* release the previous title */
- g_free (heading->priv->title);
-
- /* activate the new title */
- heading->priv->title = g_strdup (title);
-
- /* schedule a resize */
- gtk_widget_queue_resize (GTK_WIDGET (heading));
-
- /* notify listeners */
- g_object_notify (G_OBJECT (heading), "title");
-}
-
-
diff --git a/thunar-volman/xfce-heading.h b/thunar-volman/xfce-heading.h
deleted file mode 100644
index 0ca1351..0000000
--- a/thunar-volman/xfce-heading.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XFCE_HEADING_H__
-#define __XFCE_HEADING_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-typedef struct _XfceHeadingPrivate XfceHeadingPrivate;
-typedef struct _XfceHeadingClass XfceHeadingClass;
-typedef struct _XfceHeading XfceHeading;
-
-#define XFCE_TYPE_HEADING (xfce_heading_get_type ())
-#define XFCE_HEADING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_HEADING, XfceHeading))
-#define XFCE_HEADING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_HEADING, XfceHeadingClass))
-#define XFCE_IS_HEADING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_HEADING))
-#define XFCE_IS_HEADING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_HEADING))
-#define XFCE_HEADING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_HEADING, XfceHeadingClass))
-
-struct _XfceHeadingClass
-{
- /*< private >*/
- GtkWidgetClass __parent__;
-
- /* reserved for future expansion */
- void (*reserved0) (void);
- void (*reserved1) (void);
- void (*reserved2) (void);
- void (*reserved3) (void);
- void (*reserved4) (void);
- void (*reserved5) (void);
-};
-
-struct _XfceHeading
-{
- /*< private >*/
- GtkWidget __parent__;
- XfceHeadingPrivate *priv;
-};
-
-GType xfce_heading_get_type (void) G_GNUC_CONST;
-
-GtkWidget *xfce_heading_new (void) G_GNUC_MALLOC;
-
-GdkPixbuf *xfce_heading_get_icon (XfceHeading *heading);
-void xfce_heading_set_icon (XfceHeading *heading,
- GdkPixbuf *icon);
-
-G_CONST_RETURN gchar *xfce_heading_get_icon_name (XfceHeading *heading);
-void xfce_heading_set_icon_name (XfceHeading *heading,
- const gchar *icon_name);
-
-G_CONST_RETURN gchar *xfce_heading_get_subtitle (XfceHeading *heading);
-void xfce_heading_set_subtitle (XfceHeading *heading,
- const gchar *subtitle);
-
-G_CONST_RETURN gchar *xfce_heading_get_title (XfceHeading *heading);
-void xfce_heading_set_title (XfceHeading *heading,
- const gchar *title);
-
-G_END_DECLS
-
-#endif /* !__XFCE_HEADING_H__ */
diff --git a/thunar-volman/xfce-titled-dialog.c b/thunar-volman/xfce-titled-dialog.c
deleted file mode 100644
index 9a12243..0000000
--- a/thunar-volman/xfce-titled-dialog.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-
-#include <gdk/gdkkeysyms.h>
-
-#include "xfce-heading.h"
-#include "xfce-titled-dialog.h"
-
-
-
-#define XFCE_TITLED_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), XFCE_TYPE_TITLED_DIALOG, XfceTitledDialogPrivate))
-
-
-
-/* Property identifiers */
-enum
-{
- PROP_0,
- PROP_SUBTITLE,
-};
-
-
-
-static void xfce_titled_dialog_class_init (XfceTitledDialogClass *klass);
-static void xfce_titled_dialog_init (XfceTitledDialog *titled_dialog);
-static void xfce_titled_dialog_finalize (GObject *object);
-static void xfce_titled_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void xfce_titled_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void xfce_titled_dialog_close (GtkDialog *dialog);
-static void xfce_titled_dialog_update_heading (XfceTitledDialog *titled_dialog);
-
-
-
-struct _XfceTitledDialogPrivate
-{
- GtkWidget *heading;
- gchar *subtitle;
-};
-
-
-
-G_DEFINE_TYPE (XfceTitledDialog, xfce_titled_dialog, GTK_TYPE_DIALOG);
-
-
-
-static void
-xfce_titled_dialog_class_init (XfceTitledDialogClass *klass)
-{
- GtkDialogClass *gtkdialog_class;
- GtkBindingSet *binding_set;
- GObjectClass *gobject_class;
-
- /* add our private data to the class */
- g_type_class_add_private (klass, sizeof (XfceTitledDialogPrivate));
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xfce_titled_dialog_finalize;
- gobject_class->get_property = xfce_titled_dialog_get_property;
- gobject_class->set_property = xfce_titled_dialog_set_property;
-
- gtkdialog_class = GTK_DIALOG_CLASS (klass);
- gtkdialog_class->close = xfce_titled_dialog_close;
-
- /**
- * XfceTitledDialog:subtitle:
- *
- * The subtitle displayed below the main dialog title.
- *
- * Since: 4.4.0
- **/
- g_object_class_install_property (gobject_class,
- PROP_SUBTITLE,
- g_param_spec_string ("subtitle",
- "subtitle",
- "subtitle",
- NULL,
- G_PARAM_READWRITE));
-
- /* connect additional key bindings to the GtkDialog::close action signal */
- binding_set = gtk_binding_set_by_class (klass);
- gtk_binding_entry_add_signal (binding_set, GDK_w, GDK_CONTROL_MASK, "close", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_W, GDK_CONTROL_MASK, "close", 0);
-}
-
-
-
-static void
-xfce_titled_dialog_init (XfceTitledDialog *titled_dialog)
-{
- GtkWidget *line;
- GtkWidget *vbox;
-
- /* connect the private data */
- titled_dialog->priv = XFCE_TITLED_DIALOG_GET_PRIVATE (titled_dialog);
-
- /* remove the main dialog box from the window */
- g_object_ref (G_OBJECT (GTK_DIALOG (titled_dialog)->vbox));
- gtk_container_remove (GTK_CONTAINER (titled_dialog), GTK_DIALOG (titled_dialog)->vbox);
-
- /* add a new vbox w/o border to the main window */
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (titled_dialog), vbox);
- gtk_widget_show (vbox);
-
- /* add the heading to the window */
- titled_dialog->priv->heading = xfce_heading_new ();
- gtk_box_pack_start (GTK_BOX (vbox), titled_dialog->priv->heading, FALSE, FALSE, 0);
- gtk_widget_show (titled_dialog->priv->heading);
-
- /* add the separator between header and content */
- line = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (vbox), line, FALSE, FALSE, 0);
- gtk_widget_show (line);
-
- /* add the main dialog box to the new vbox */
- gtk_box_pack_start (GTK_BOX (vbox), GTK_DIALOG (titled_dialog)->vbox, TRUE, TRUE, 0);
- g_object_unref (G_OBJECT (GTK_DIALOG (titled_dialog)->vbox));
-
- /* make sure to update the heading whenever one of the relevant window properties changes */
- g_signal_connect (G_OBJECT (titled_dialog), "notify::icon", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
- g_signal_connect (G_OBJECT (titled_dialog), "notify::icon-name", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
- g_signal_connect (G_OBJECT (titled_dialog), "notify::title", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
-
- /* initially update the heading properties */
- xfce_titled_dialog_update_heading (titled_dialog);
-}
-
-
-
-
-static void
-xfce_titled_dialog_finalize (GObject *object)
-{
- XfceTitledDialog *titled_dialog = XFCE_TITLED_DIALOG (object);
-
- /* release the subtitle */
- g_free (titled_dialog->priv->subtitle);
-
- (*G_OBJECT_CLASS (xfce_titled_dialog_parent_class)->finalize) (object);
-}
-
-
-
-static void
-xfce_titled_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- XfceTitledDialog *titled_dialog = XFCE_TITLED_DIALOG (object);
-
- switch (prop_id)
- {
- case PROP_SUBTITLE:
- g_value_set_string (value, xfce_titled_dialog_get_subtitle (titled_dialog));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static void
-xfce_titled_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- XfceTitledDialog *titled_dialog = XFCE_TITLED_DIALOG (object);
-
- switch (prop_id)
- {
- case PROP_SUBTITLE:
- xfce_titled_dialog_set_subtitle (titled_dialog, g_value_get_string (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static void
-xfce_titled_dialog_close (GtkDialog *dialog)
-{
- GdkEvent *event;
-
- /* verify that the dialog is realized */
- if (G_LIKELY (GTK_WIDGET_REALIZED (dialog)))
- {
- /* send a delete event to the dialog */
- event = gdk_event_new (GDK_DELETE);
- event->any.window = g_object_ref (GTK_WIDGET (dialog)->window);
- event->any.send_event = TRUE;
- gtk_main_do_event (event);
- gdk_event_free (event);
- }
-}
-
-
-
-static void
-xfce_titled_dialog_update_heading (XfceTitledDialog *titled_dialog)
-{
- /* update the heading properties using the window property values */
- xfce_heading_set_icon (XFCE_HEADING (titled_dialog->priv->heading), gtk_window_get_icon (GTK_WINDOW (titled_dialog)));
- xfce_heading_set_icon_name (XFCE_HEADING (titled_dialog->priv->heading), gtk_window_get_icon_name (GTK_WINDOW (titled_dialog)));
- xfce_heading_set_title (XFCE_HEADING (titled_dialog->priv->heading), gtk_window_get_title (GTK_WINDOW (titled_dialog)));
-}
-
-
-
-/**
- * xfce_titled_dialog_new:
- *
- * Allocates a new #XfceTitledDialog instance.
- *
- * Return value: the newly allocated #XfceTitledDialog.
- *
- * Since: 4.4.0
- **/
-GtkWidget*
-xfce_titled_dialog_new (void)
-{
- return g_object_new (XFCE_TYPE_TITLED_DIALOG, NULL);
-}
-
-
-
-/**
- * xfce_titled_dialog_new_with_buttons:
- * @title : title of the dialog, or %NULL.
- * @parent : transient parent window of the dialog, or %NULL.
- * @flags : from #GtkDialogFlags.
- * @first_button_text : stock ID or text to go in first, or %NULL.
- * @... : response ID for the first button, then additional buttons, ending with %NULL.
- *
- * See the documentation of gtk_dialog_new_with_buttons() for details about the
- * parameters and the returned dialog.
- *
- * Return value: the newly allocated #XfceTitledDialog.
- *
- * Since: 4.4.0
- **/
-GtkWidget*
-xfce_titled_dialog_new_with_buttons (const gchar *title,
- GtkWindow *parent,
- GtkDialogFlags flags,
- const gchar *first_button_text,
- ...)
-{
- const gchar *button_text;
- GtkWidget *dialog;
- va_list args;
- gint response_id;
-
- /* allocate the dialog */
- dialog = g_object_new (XFCE_TYPE_TITLED_DIALOG,
- "destroy-with-parent", ((flags & GTK_DIALOG_DESTROY_WITH_PARENT) != 0),
- "has-separator", ((flags & GTK_DIALOG_NO_SEPARATOR) == 0),
- "modal", ((flags & GTK_DIALOG_MODAL) != 0),
- "title", title,
- NULL);
-
- /* set the transient parent (if any) */
- if (G_LIKELY (parent != NULL))
- gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
-
- /* add all additional buttons */
- va_start (args, first_button_text);
- for (button_text = first_button_text; button_text != NULL; )
- {
- response_id = va_arg (args, gint);
- gtk_dialog_add_button (GTK_DIALOG (dialog), button_text, response_id);
- button_text = va_arg (args, const gchar *);
- }
- va_end (args);
-
- return dialog;
-}
-
-
-
-/**
- * xfce_titled_dialog_get_subtitle:
- * @titled_dialog : a #XfceTitledDialog.
- *
- * Returns the subtitle of the @titled_dialog, or %NULL
- * if no subtitle is displayed in the @titled_dialog.
- *
- * Return value: the subtitle of @titled_dialog, or %NULL.
- *
- * Since: 4.4.0
- **/
-G_CONST_RETURN gchar*
-xfce_titled_dialog_get_subtitle (XfceTitledDialog *titled_dialog)
-{
- g_return_val_if_fail (XFCE_IS_TITLED_DIALOG (titled_dialog), NULL);
- return titled_dialog->priv->subtitle;
-}
-
-
-
-/**
- * xfce_titled_dialog_set_subtitle:
- * @titled_dialog : a #XfceTitledDialog.
- * @subtitle : the new subtitle for the @titled_dialog, or %NULL.
- *
- * Sets the subtitle displayed by @titled_dialog to @subtitle; if
- * @subtitle is %NULL no subtitle will be displayed by the @titled_dialog.
- *
- * Since: 4.4.0
- **/
-void
-xfce_titled_dialog_set_subtitle (XfceTitledDialog *titled_dialog,
- const gchar *subtitle)
-{
- g_return_if_fail (XFCE_IS_TITLED_DIALOG (titled_dialog));
- g_return_if_fail (subtitle == NULL || g_utf8_validate (subtitle, -1, NULL));
-
- /* release the previous subtitle */
- g_free (titled_dialog->priv->subtitle);
-
- /* activate the new subtitle */
- titled_dialog->priv->subtitle = g_strdup (subtitle);
-
- /* update the subtitle for the heading */
- xfce_heading_set_subtitle (XFCE_HEADING (titled_dialog->priv->heading), subtitle);
-
- /* notify listeners */
- g_object_notify (G_OBJECT (titled_dialog), "subtitle");
-}
-
-
diff --git a/thunar-volman/xfce-titled-dialog.h b/thunar-volman/xfce-titled-dialog.h
deleted file mode 100644
index 5243a2e..0000000
--- a/thunar-volman/xfce-titled-dialog.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XFCE_TITLED_DIALOG_H__
-#define __XFCE_TITLED_DIALOG_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-typedef struct _XfceTitledDialogPrivate XfceTitledDialogPrivate;
-typedef struct _XfceTitledDialogClass XfceTitledDialogClass;
-typedef struct _XfceTitledDialog XfceTitledDialog;
-
-#define XFCE_TYPE_TITLED_DIALOG (xfce_titled_dialog_get_type ())
-#define XFCE_TITLED_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_TITLED_DIALOG, XfceTitledDialog))
-#define XFCE_TITLED_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_TITLED_DIALOG, XfceTitledDialogClass))
-#define XFCE_IS_TITLED_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_TITLED_DIALOG))
-#define XFCE_IS_TITLED_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_TITLED_DIALOG))
-#define XFCE_TITLED_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_TITLED_DIALOG, XfceTitledDialogClass))
-
-struct _XfceTitledDialogClass
-{
- /*< private >*/
- GtkDialogClass __parent__;
-
- /* reserved for future expansion */
- void (*reserved0) (void);
- void (*reserved1) (void);
- void (*reserved2) (void);
- void (*reserved3) (void);
- void (*reserved4) (void);
- void (*reserved5) (void);
-};
-
-struct _XfceTitledDialog
-{
- /*< private >*/
- GtkDialog __parent__;
- XfceTitledDialogPrivate *priv;
-};
-
-GType xfce_titled_dialog_get_type (void) G_GNUC_CONST;
-
-GtkWidget *xfce_titled_dialog_new (void) G_GNUC_MALLOC;
-GtkWidget *xfce_titled_dialog_new_with_buttons (const gchar *title,
- GtkWindow *parent,
- GtkDialogFlags flags,
- const gchar *first_button_text,
- ...) G_GNUC_MALLOC;
-
-G_CONST_RETURN gchar *xfce_titled_dialog_get_subtitle (XfceTitledDialog *titled_dialog);
-void xfce_titled_dialog_set_subtitle (XfceTitledDialog *titled_dialog,
- const gchar *subtitle);
-
-G_END_DECLS
-
-#endif /* !__XFCE_TITLED_DIALOG_H__ */