--- thunar/thunar-application.c.old 2010-01-07 15:57:47.330280147 -0500 +++ thunar/thunar-application.c 2010-01-07 15:53:48.000000000 -0500 @@ -35,6 +35,9 @@ #include #endif +#include +#include + #include #include #include @@ -96,6 +99,7 @@ GdkScreen *screen); static void thunar_application_window_destroyed (GtkWidget *window, ThunarApplication *application); +static void thunar_application_volman_init (ThunarApplication *application); static void thunar_application_volman_device_added (ThunarVfsVolumeManager *volume_manager, const gchar *udi, ThunarApplication *application); @@ -233,6 +237,7 @@ g_signal_connect (G_OBJECT (application->volman), "device-added", G_CALLBACK (thunar_application_volman_device_added), application); g_signal_connect (G_OBJECT (application->volman), "device-removed", G_CALLBACK (thunar_application_volman_device_removed), application); g_signal_connect (G_OBJECT (application->volman), "device-eject", G_CALLBACK (thunar_application_volman_device_eject), application); + thunar_application_volman_init(application); } } @@ -543,7 +548,59 @@ gtk_main_quit (); } +/* + * Scan HAL for all UDI's and pass them to volman + * This ensures that all devices are handled when Thunar is first launched + * Much of this source is taken from hal-device.c from the HAL package + */ +static void +thunar_application_volman_init (ThunarApplication *application) +{ + DBusError error; + DBusConnection *conn; + LibHalContext *hal_ctx; + int num_devices; + char **device_names; + int i; + + dbus_error_init(&error); + + if (!(conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) { + fprintf(stderr, "error: dbus_bus_get: %s: %s\n", error.name, error.message); + LIBHAL_FREE_DBUS_ERROR(&error); + return; + } + if (!(hal_ctx = libhal_ctx_new())) return 3; + if (!libhal_ctx_set_dbus_connection(hal_ctx, conn)) return 4; + if (!libhal_ctx_init(hal_ctx, &error)) { + if (dbus_error_is_set(&error)) { + fprintf (stderr, "error: libhal_ctx_init: %s: %s\n", error.name, + error.message); + dbus_error_free (&error); + } + fprintf (stderr, "Could not initialise connection to hald.\n" + "Normally this means the HAL daemon (hald) is not running or not ready.\n"); + return 5; + } + + if(!(device_names = libhal_get_all_devices(hal_ctx, &num_devices, &error))) { + fprintf(stderr, "Empty HAL device list!\n"); + goto exit; + } + + for(i=0;ivolman, device_names[i], application); + } + + libhal_free_string_array(device_names); + +exit: + libhal_ctx_shutdown(hal_ctx, &error); + libhal_ctx_free(hal_ctx); + dbus_connection_unref(conn); + dbus_error_free(&error); +} static void thunar_application_volman_device_added (ThunarVfsVolumeManager *volume_manager,