diff options
author | Benedikt Meurer <benny@xfce.org> | 2007-01-15 17:21:08 +0000 |
---|---|---|
committer | Benedikt Meurer <benny@xfce.org> | 2007-01-15 17:21:08 +0000 |
commit | 3112b17554fabc808676f4a2ba090961abaf207c (patch) | |
tree | 21fb3cbf65f1a127b0a6e8d91adf3a28cbaa9266 /thunar-volman | |
parent | ad674fc156dd47bdf573c0fd4edc64f64fcea1a2 (diff) | |
download | thunar-volman-3112b17554fabc808676f4a2ba090961abaf207c.tar.gz |
2007-01-15 Benedikt Meurer <benny@xfce.org>
* icons/48x48/, thunar-volman/: Add support for PDAs (currently
Palm Pilots and Pocket PCs).
(Old svn revision: 2363)
Diffstat (limited to 'thunar-volman')
-rw-r--r-- | thunar-volman/Makefile.am | 2 | ||||
-rw-r--r-- | thunar-volman/tvm-device.c | 2 | ||||
-rw-r--r-- | thunar-volman/tvm-input-device.c | 2 | ||||
-rw-r--r-- | thunar-volman/tvm-pda-device.c | 121 | ||||
-rw-r--r-- | thunar-volman/tvm-pda-device.h | 35 | ||||
-rw-r--r-- | thunar-volman/tvm-preferences-dialog.c | 76 | ||||
-rw-r--r-- | thunar-volman/tvm-preferences.c | 58 |
7 files changed, 294 insertions, 2 deletions
diff --git a/thunar-volman/Makefile.am b/thunar-volman/Makefile.am index a7a3b0f..7f0e73d 100644 --- a/thunar-volman/Makefile.am +++ b/thunar-volman/Makefile.am @@ -27,6 +27,8 @@ thunar_volman_SOURCES = \ 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 \ diff --git a/thunar-volman/tvm-device.c b/thunar-volman/tvm-device.c index ebaad44..8f8bc2d 100644 --- a/thunar-volman/tvm-device.c +++ b/thunar-volman/tvm-device.c @@ -40,6 +40,7 @@ #include <thunar-volman/tvm-camera-device.h> #include <thunar-volman/tvm-device.h> #include <thunar-volman/tvm-input-device.h> +#include <thunar-volman/tvm-pda-device.h> @@ -59,6 +60,7 @@ static const TvmDeviceHandler handlers[] = { "input.keyboard", tvm_input_device_added, }, { "input.mouse", tvm_input_device_added, }, { "input.tablet", tvm_input_device_added, }, + { "pda", tvm_pda_device_added, }, }; diff --git a/thunar-volman/tvm-input-device.c b/thunar-volman/tvm-input-device.c index a4fb457..21443c0 100644 --- a/thunar-volman/tvm-input-device.c +++ b/thunar-volman/tvm-input-device.c @@ -48,7 +48,7 @@ static const struct /** - * tvm_block_input_added: + * tvm_input_device_added: * @preferences : a #TvmPreferences. * @context : a #LibHalContext. * @udi : the HAL device UDI of the newly added input device. diff --git a/thunar-volman/tvm-pda-device.c b/thunar-volman/tvm-pda-device.c new file mode 100644 index 0000000..f1983a8 --- /dev/null +++ b/thunar-volman/tvm-pda-device.c @@ -0,0 +1,121 @@ +/* $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-prompt.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 new file mode 100644 index 0000000..7d32008 --- /dev/null +++ b/thunar-volman/tvm-pda-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_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 index 21f4298..eac5efb 100644 --- a/thunar-volman/tvm-preferences-dialog.c +++ b/thunar-volman/tvm-preferences-dialog.c @@ -378,6 +378,81 @@ tvm_preferences_dialog_init (TvmPreferencesDialog *dialog) 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 (_("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 PC")); + 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); + + /* Input Devices */ @@ -513,3 +588,4 @@ 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.c b/thunar-volman/tvm-preferences.c index 712db87..5c95da6 100644 --- a/thunar-volman/tvm-preferences.c +++ b/thunar-volman/tvm-preferences.c @@ -54,6 +54,10 @@ enum PROP_AUTOIPOD_COMMAND, PROP_AUTOPHOTO, PROP_AUTOPHOTO_COMMAND, + PROP_AUTOPALM, + PROP_AUTOPALM_COMMAND, + PROP_AUTOPOCKETPC, + PROP_AUTOPOCKETPC_COMMAND, PROP_AUTOKEYBOARD, PROP_AUTOKEYBOARD_COMMAND, PROP_AUTOMOUSE, @@ -290,7 +294,7 @@ tvm_preferences_class_init (TvmPreferencesClass *klass) g_param_spec_boolean ("autoplay-audio-cd", "autoplay-audio-cd", "autoplay-audio-cd", - FALSE, + TRUE, EXO_PARAM_READWRITE)); /** @@ -385,6 +389,58 @@ tvm_preferences_class_init (TvmPreferencesClass *klass) 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:autokeyboard: * * Automatically run a program when an USB keyboard is connected. |