summaryrefslogtreecommitdiff
path: root/thunar-volman
diff options
context:
space:
mode:
authorBenedikt Meurer <benny@xfce.org>2007-01-15 17:57:27 +0000
committerBenedikt Meurer <benny@xfce.org>2007-01-15 17:57:27 +0000
commit433fca05a8a7bee0432eca879a9b88f954749ead (patch)
treed50e54ec3259671ccf5eac478a623c2decb824fb /thunar-volman
parent3112b17554fabc808676f4a2ba090961abaf207c (diff)
downloadthunar-volman-433fca05a8a7bee0432eca879a9b88f954749ead.tar.gz
2007-01-15 Benedikt Meurer <benny@xfce.org>
* thunar-volman/: Add support for printers. * po/POTFILES.in: Add new files here. * po/thunar-volman.pot, po/*.po: Merge new strings. * po/de.po: Update german translations. (Old svn revision: 2364)
Diffstat (limited to 'thunar-volman')
-rw-r--r--thunar-volman/Makefile.am2
-rw-r--r--thunar-volman/tvm-device.c14
-rw-r--r--thunar-volman/tvm-input-device.c1
-rw-r--r--thunar-volman/tvm-pda-device.c1
-rw-r--r--thunar-volman/tvm-preferences-dialog.c46
-rw-r--r--thunar-volman/tvm-preferences.c28
-rw-r--r--thunar-volman/tvm-printer-device.c80
-rw-r--r--thunar-volman/tvm-printer-device.h35
8 files changed, 197 insertions, 10 deletions
diff --git a/thunar-volman/Makefile.am b/thunar-volman/Makefile.am
index 7f0e73d..1b48156 100644
--- a/thunar-volman/Makefile.am
+++ b/thunar-volman/Makefile.am
@@ -33,6 +33,8 @@ thunar_volman_SOURCES = \
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-run.c \
diff --git a/thunar-volman/tvm-device.c b/thunar-volman/tvm-device.c
index 8f8bc2d..584b222 100644
--- a/thunar-volman/tvm-device.c
+++ b/thunar-volman/tvm-device.c
@@ -41,6 +41,7 @@
#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>
@@ -55,12 +56,13 @@ struct _TvmDeviceHandler
static const TvmDeviceHandler 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, },
+ { "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, },
};
diff --git a/thunar-volman/tvm-input-device.c b/thunar-volman/tvm-input-device.c
index 21443c0..664e856 100644
--- a/thunar-volman/tvm-input-device.c
+++ b/thunar-volman/tvm-input-device.c
@@ -29,7 +29,6 @@
#endif
#include <thunar-volman/tvm-input-device.h>
-#include <thunar-volman/tvm-prompt.h>
#include <thunar-volman/tvm-run.h>
diff --git a/thunar-volman/tvm-pda-device.c b/thunar-volman/tvm-pda-device.c
index f1983a8..8e3b942 100644
--- a/thunar-volman/tvm-pda-device.c
+++ b/thunar-volman/tvm-pda-device.c
@@ -31,7 +31,6 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <thunar-volman/tvm-pda-device.h>
-#include <thunar-volman/tvm-prompt.h>
#include <thunar-volman/tvm-run.h>
diff --git a/thunar-volman/tvm-preferences-dialog.c b/thunar-volman/tvm-preferences-dialog.c
index eac5efb..f8657bc 100644
--- a/thunar-volman/tvm-preferences-dialog.c
+++ b/thunar-volman/tvm-preferences-dialog.c
@@ -380,7 +380,7 @@ tvm_preferences_dialog_init (TvmPreferencesDialog *dialog)
/*
- Cameras
+ PDAs
*/
label = gtk_label_new (_("PDAs"));
vbox = g_object_new (GTK_TYPE_VBOX, "border-width", 12, "spacing", 12, NULL);
@@ -424,7 +424,7 @@ tvm_preferences_dialog_init (TvmPreferencesDialog *dialog)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
gtk_widget_show (frame);
- label = gtk_label_new (_("Pocket PC"));
+ 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);
@@ -454,6 +454,48 @@ tvm_preferences_dialog_init (TvmPreferencesDialog *dialog)
/*
+ 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"));
diff --git a/thunar-volman/tvm-preferences.c b/thunar-volman/tvm-preferences.c
index 5c95da6..27f3b65 100644
--- a/thunar-volman/tvm-preferences.c
+++ b/thunar-volman/tvm-preferences.c
@@ -58,6 +58,8 @@ enum
PROP_AUTOPALM_COMMAND,
PROP_AUTOPOCKETPC,
PROP_AUTOPOCKETPC_COMMAND,
+ PROP_AUTOPRINTER,
+ PROP_AUTOPRINTER_COMMAND,
PROP_AUTOKEYBOARD,
PROP_AUTOKEYBOARD_COMMAND,
PROP_AUTOMOUSE,
@@ -441,6 +443,32 @@ tvm_preferences_class_init (TvmPreferencesClass *klass)
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.
diff --git a/thunar-volman/tvm-printer-device.c b/thunar-volman/tvm-printer-device.c
new file mode 100644
index 0000000..2ae24f8
--- /dev/null
+++ b/thunar-volman/tvm-printer-device.c
@@ -0,0 +1,80 @@
+/* $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
new file mode 100644
index 0000000..429c82b
--- /dev/null
+++ b/thunar-volman/tvm-printer-device.h
@@ -0,0 +1,35 @@
+/* $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__ */