summaryrefslogtreecommitdiff
path: root/thunar-volman-settings
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis@xfce.org>2010-07-21 13:41:29 +0200
committerJannis Pohlmann <jannis@xfce.org>2010-07-25 19:42:29 +0200
commit344b273424f3e49fdedeb677db48db8fdaebf67c (patch)
treee6437509743651e195e3138f1f8e557ed3768d2d /thunar-volman-settings
parent11b47a673e22f3b9e7715548b5f5ca1a8ee8ba2a (diff)
downloadthunar-volman-344b273424f3e49fdedeb677db48db8fdaebf67c.tar.gz
Initial work on porting thunar-volman-settings to the new code.
The storage devices tab already works again.
Diffstat (limited to 'thunar-volman-settings')
-rw-r--r--thunar-volman-settings/Makefile.am75
-rw-r--r--thunar-volman-settings/main.c88
-rw-r--r--thunar-volman-settings/thunar-volman-settings.desktop.in.in12
-rw-r--r--thunar-volman-settings/tvm-command-entry.c418
-rw-r--r--thunar-volman-settings/tvm-command-entry.h62
-rw-r--r--thunar-volman-settings/tvm-preferences-dialog.c325
-rw-r--r--thunar-volman-settings/tvm-preferences-dialog.h46
7 files changed, 1026 insertions, 0 deletions
diff --git a/thunar-volman-settings/Makefile.am b/thunar-volman-settings/Makefile.am
new file mode 100644
index 0000000..296e0e7
--- /dev/null
+++ b/thunar-volman-settings/Makefile.am
@@ -0,0 +1,75 @@
+# 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) \
+ -I$(top_srcdir) \
+ -DBINDIR=\"$(bindir)\" \
+ -DG_LOG_DOMAIN=\"thunar-volman-settings\" \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ $(PLATFORM_CPPFLAGS)
+
+bin_PROGRAMS = \
+ thunar-volman-settings
+
+thunar_volman_settings_SOURCES = \
+ main.c \
+ tvm-command-entry.c \
+ tvm-command-entry.h \
+ tvm-preferences-dialog.c \
+ tvm-preferences-dialog.h \
+ ../thunar-volman/tvm-pango-extensions.c \
+ ../thunar-volman/tvm-pango-extensions.h
+
+thunar_volman_settings_CFLAGS = \
+ $(EXO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(LIBXFCE4UI_CFLAGS) \
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(XFCONF_CFLAGS) \
+ $(PLATFORM_CFLAGS)
+
+thunar_volman_settings_LDFLAGS = \
+ -no-undefined \
+ $(PLATFORM_LDFLAGS)
+
+thunar_volman_settings_LDADD = \
+ $(EXO_LIBS) \
+ $(GLIB_LIBS) \
+ $(GTK_LIBS) \
+ $(LIBXFCE4UI_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ $(XFCONF_LIBS)
+
+desktopdir = $(datadir)/applications
+desktop_in_in_files = thunar-volman-settings.desktop.in.in
+desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
+%.desktop.in: %.desktop.in.in
+ sed -e "s,\@libexecdir\@,$(libexecdir),g" < $< > $@
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+@INTLTOOL_DESKTOP_RULE@
+
+EXTRA_DIST = \
+ $(desktop_in_in_files)
+
+DISTCLEANFILES = \
+ $(desktop_in_files) \
+ $(desktop_DATA)
diff --git a/thunar-volman-settings/main.c b/thunar-volman-settings/main.c
new file mode 100644
index 0000000..f58aba7
--- /dev/null
+++ b/thunar-volman-settings/main.c
@@ -0,0 +1,88 @@
+/* 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
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include <gtk/gtk.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include <xfconf/xfconf.h>
+
+#include <thunar-volman-settings/tvm-preferences-dialog.h>
+
+
+int
+main (int argc,
+ char **argv)
+{
+ GtkWidget *dialog;
+ GError *error = NULL;
+
+ /* setup translation domain */
+ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+ /* setup application name */
+ g_set_application_name (_("Thunar Volume Manager Settings"));
+
+#ifdef G_ENABLE_DEBUG
+ /* 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 threading system */
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+
+ /* initialize GTK+ */
+ if (!gtk_init_with_args (&argc, &argv, NULL, NULL, GETTEXT_PACKAGE, &error))
+ {
+ g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message);
+ g_error_free (error);
+ return EXIT_FAILURE;
+ }
+
+ /* initialize xfconf */
+ if (!xfconf_init (&error))
+ {
+ g_fprintf (stderr, "%s: %s.\n", g_get_prgname (), error->message);
+ g_error_free (error);
+ return EXIT_FAILURE;
+ }
+
+ /* display the dialog */
+ dialog = tvm_preferences_dialog_new ();
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ /* free xfconf resources */
+ xfconf_shutdown ();
+
+ return EXIT_SUCCESS;
+}
diff --git a/thunar-volman-settings/thunar-volman-settings.desktop.in.in b/thunar-volman-settings/thunar-volman-settings.desktop.in.in
new file mode 100644
index 0000000..b82fb13
--- /dev/null
+++ b/thunar-volman-settings/thunar-volman-settings.desktop.in.in
@@ -0,0 +1,12 @@
+[Desktop Entry]
+Encoding=UTF-8
+_Name=Removable Drives and Media
+_Comment=Configure management of removable drives and media
+Exec=@libexecdir@/thunar-volman-settings
+Icon=gnome-dev-removable
+Terminal=false
+StartupNotify=true
+Type=Application
+Categories=X-XFCE;Settings;DesktopSettings;X-XfceSettingsDialog;
+
+# vi:set encoding=UTF-8:
diff --git a/thunar-volman-settings/tvm-command-entry.c b/thunar-volman-settings/tvm-command-entry.c
new file mode 100644
index 0000000..8ab3589
--- /dev/null
+++ b/thunar-volman-settings/tvm-command-entry.c
@@ -0,0 +1,418 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * 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., 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 <glib.h>
+
+#include <gtk/gtk.h>
+
+#include <exo/exo.h>
+
+#include <thunar-volman-settings/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-settings/tvm-command-entry.h b/thunar-volman-settings/tvm-command-entry.h
new file mode 100644
index 0000000..7d1be68
--- /dev/null
+++ b/thunar-volman-settings/tvm-command-entry.h
@@ -0,0 +1,62 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TVM_COMMAND_ENTRY_H__
+#define __TVM_COMMAND_ENTRY_H__
+
+#include <gtk/gtk.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-settings/tvm-preferences-dialog.c b/thunar-volman-settings/tvm-preferences-dialog.c
new file mode 100644
index 0000000..89acc75
--- /dev/null
+++ b/thunar-volman-settings/tvm-preferences-dialog.c
@@ -0,0 +1,325 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2005-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 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 <glib-object.h>
+
+#include <libxfce4ui/libxfce4ui.h>
+
+#include <xfconf/xfconf.h>
+
+#include <thunar-volman/tvm-pango-extensions.h>
+
+#include <thunar-volman-settings/tvm-command-entry.h>
+#include <thunar-volman-settings/tvm-preferences-dialog.h>
+
+
+
+/* property identifiers */
+enum
+{
+ PROP_0,
+};
+
+
+
+static void tvm_preferences_dialog_help_clicked (GtkWidget *button,
+ TvmPreferencesDialog *dialog);
+
+
+
+struct _TvmPreferencesDialogClass
+{
+ XfceTitledDialogClass __parent__;
+};
+
+struct _TvmPreferencesDialog
+{
+ XfceTitledDialog __parent__;
+};
+
+struct _TvmPreferencesDialogPrivate
+{
+};
+
+
+
+G_DEFINE_TYPE (TvmPreferencesDialog, tvm_preferences_dialog, XFCE_TYPE_TITLED_DIALOG)
+
+
+
+static void
+tvm_preferences_dialog_class_init (TvmPreferencesDialogClass *klass)
+{
+ /* Determine the parent type class */
+ tvm_preferences_dialog_parent_class = g_type_class_peek_parent (klass);
+}
+
+
+
+static void
+tvm_preferences_dialog_init (TvmPreferencesDialog *dialog)
+{
+ XfconfChannel *channel;
+ GtkSizeGroup *size_group;
+ GtkWidget *button;
+ GtkWidget *entry;
+ GtkWidget *frame;
+ GtkWidget *label;
+ GtkWidget *image;
+ GtkWidget *notebook;
+ GtkWidget *table;
+ GtkWidget *vbox;
+
+ channel = xfconf_channel_get ("thunar-volman");
+
+ /* 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"));
+ xfconf_g_property_bind (channel, "/automount-drives/enabled", G_TYPE_BOOLEAN,
+ 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"));
+ xfconf_g_property_bind (channel, "/automount-media/enabled", G_TYPE_BOOLEAN,
+ 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"));
+ xfconf_g_property_bind (channel, "/autobrowse/enabled", G_TYPE_BOOLEAN,
+ 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"));
+ xfconf_g_property_bind (channel, "/autorun/enabled", G_TYPE_BOOLEAN, 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"));
+ xfconf_g_property_bind (channel, "/autoopen/enabled", G_TYPE_BOOLEAN, 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"));
+ xfconf_g_property_bind (channel, "/autoburn/enabled", G_TYPE_BOOLEAN, 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:"));
+ xfconf_g_property_bind (channel, "/autoburn/enabled", G_TYPE_BOOLEAN, entry, "sensitive");
+ xfconf_g_property_bind (channel, "/autoburn/data-cd-command", G_TYPE_STRING, 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:"));
+ xfconf_g_property_bind (channel, "/autoburn/enabled", G_TYPE_BOOLEAN, entry, "sensitive");
+ xfconf_g_property_bind (channel, "/autoburn/audio-cd-command", G_TYPE_STRING, 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));
+}
+
+
+
+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 (GTK_IS_BUTTON (button));
+ g_return_if_fail (TVM_IS_PREFERENCES_DIALOG (dialog));
+
+ /* 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,
+ _("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);
+}
+
+
+
+GtkWidget *
+tvm_preferences_dialog_new (void)
+{
+ return g_object_new (TVM_TYPE_PREFERENCES_DIALOG, NULL);
+}
diff --git a/thunar-volman-settings/tvm-preferences-dialog.h b/thunar-volman-settings/tvm-preferences-dialog.h
new file mode 100644
index 0000000..e0ca571
--- /dev/null
+++ b/thunar-volman-settings/tvm-preferences-dialog.h
@@ -0,0 +1,46 @@
+/* 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_PREFERENCES_DIALOG_H__
+#define __TVM_PREFERENCES_DIALOG_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#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))
+
+typedef struct _TvmPreferencesDialogPrivate TvmPreferencesDialogPrivate;
+typedef struct _TvmPreferencesDialogClass TvmPreferencesDialogClass;
+typedef struct _TvmPreferencesDialog TvmPreferencesDialog;
+
+GType tvm_preferences_dialog_get_type (void) G_GNUC_CONST;
+
+GtkWidget *tvm_preferences_dialog_new (void) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
+
+G_END_DECLS
+
+#endif /* !__TVM_PREFERENCES_DIALOG_H__ */