1 diff -ru Thunar-1.3.0.orig/configure.in Thunar-1.3.0/configure.in
2 --- Thunar-1.3.0.orig/configure.in 2011-02-14 08:45:05.000000000 -0500
3 +++ Thunar-1.3.0/configure.in 2011-08-28 12:36:31.000000000 -0400
5 [0.4], [startup-notification],
6 [startup notification library])
8 +dnl *************************************************
9 +dnl *** Optional support for gstreamer ***
10 +dnl *************************************************
11 +XDT_CHECK_OPTIONAL_PACKAGE([GSTREAMER],
13 + [0.10], [gstreamer],
14 + [nautilus-like mouseover preview])
16 dnl ***************************************************************
17 dnl *** Optional support for GUDev (required for thunar-volman) ***
18 dnl ***************************************************************
21 echo "* Startup Notification: no"
23 +if test x"$GSTREAMER_FOUND" = x"yes"; then
24 +echo "* GStreamer: yes"
26 +echo "* GStreamer: no"
28 if test x"$GUDEV_FOUND" = x"yes"; then
29 echo "* GUDev (required for thunar-volman): yes"
31 diff -ru Thunar-1.3.0.orig/thunar/Makefile.am Thunar-1.3.0/thunar/Makefile.am
32 --- Thunar-1.3.0.orig/thunar/Makefile.am 2011-02-14 08:09:15.000000000 -0500
33 +++ Thunar-1.3.0/thunar/Makefile.am 2011-08-28 12:36:31.000000000 -0400
49 diff -ru Thunar-1.3.0.orig/thunar/thunar-abstract-icon-view.c Thunar-1.3.0/thunar/thunar-abstract-icon-view.c
50 --- Thunar-1.3.0.orig/thunar/thunar-abstract-icon-view.c 2011-02-04 10:27:17.000000000 -0500
51 +++ Thunar-1.3.0/thunar/thunar-abstract-icon-view.c 2011-08-28 12:36:31.000000000 -0400
57 + ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (abstract_icon_view);
58 + GtkWidget *real_view = GTK_BIN (standard_view)->child;
60 if (event->type == GDK_BUTTON_PRESS && event->button == 3)
62 +#ifdef HAVE_GSTREAMER
63 + /* we don't want audio-preview to interfere when clicks are going on */
64 + g_signal_handlers_disconnect_by_func (real_view, thunar_standard_view_try_preview, standard_view);
67 /* open the context menu on right clicks */
68 if (exo_icon_view_get_item_at_pos (view, event->x, event->y, &path, NULL))
72 /* open the context menu */
73 thunar_standard_view_context_menu (THUNAR_STANDARD_VIEW (abstract_icon_view), event->button, event->time);
75 +#ifdef HAVE_GSTREAMER
76 + /* turn audio-preview back on */
77 + g_signal_connect (G_OBJECT (real_view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
83 else if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS) && event->button == 2)
85 +#ifdef HAVE_GSTREAMER
86 + /* again, this type of click should override audio-preview */
87 + g_signal_handlers_disconnect_by_func (real_view, thunar_standard_view_try_preview, standard_view);
90 /* unselect all currently selected items */
91 exo_icon_view_unselect_all (view);
96 gtk_tree_path_free (path);
98 +#ifdef HAVE_GSTREAMER
99 + /* we just clicked on a file so let the audio-preview work again */
100 + g_signal_connect (G_OBJECT (real_view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
103 else if (event->type == GDK_BUTTON_PRESS)
106 ThunarAbstractIconView *abstract_icon_view)
110 + ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (abstract_icon_view);
111 + GtkWidget *real_view = GTK_BIN (standard_view)->child;
113 _thunar_return_val_if_fail (EXO_IS_ICON_VIEW (view), FALSE);
114 _thunar_return_val_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view), FALSE);
116 /* redraw the abstract_icon view */
117 gtk_widget_queue_draw (GTK_WIDGET (view));
119 +#ifdef HAVE_GSTREAMER
120 + /* re-allow the audio-preview */
121 + g_signal_connect (G_OBJECT (real_view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
127 diff -ru Thunar-1.3.0.orig/thunar/thunar-standard-view.c Thunar-1.3.0/thunar/thunar-standard-view.c
128 --- Thunar-1.3.0.orig/thunar/thunar-standard-view.c 2011-02-14 08:09:15.000000000 -0500
129 +++ Thunar-1.3.0/thunar/thunar-standard-view.c 2011-08-28 14:03:03.000000000 -0400
133 #include <gdk/gdkkeysyms.h>
134 +#include <gdk/gdkcursor.h>
136 #include <thunar/thunar-application.h>
137 #include <thunar/thunar-create-dialog.h>
143 +#define MUSIC_NOTE { 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x80, 0x1f, 0x80, 0x39, 0x80, 0x21, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xfc, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x00, 0x7c, 0x00, 0x00, 0x00 };
144 #define THUNAR_STANDARD_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), THUNAR_TYPE_STANDARD_VIEW, ThunarStandardViewPrivate))
148 static void thunar_standard_view_drag_scroll_timer_destroy (gpointer user_data);
149 static gboolean thunar_standard_view_drag_timer (gpointer user_data);
150 static void thunar_standard_view_drag_timer_destroy (gpointer user_data);
151 +static gboolean thunar_standard_view_preview_timer (GList *user_data);
152 static void thunar_standard_view_cancel_thumbnailing (ThunarStandardView *standard_view);
153 static void thunar_standard_view_schedule_thumbnail_timeout (ThunarStandardView *standard_view);
154 static void thunar_standard_view_schedule_thumbnail_idle (ThunarStandardView *standard_view);
156 /* stay informed about changes to the sort column/order */
157 g_signal_connect (G_OBJECT (standard_view->model), "sort-column-changed", G_CALLBACK (thunar_standard_view_sort_column_changed), standard_view);
159 +#ifdef HAVE_GSTREAMER
160 + /* stay informed about what audio-preview might need to happen */
161 + g_signal_connect (G_OBJECT (view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
163 + /* initialize the player */
164 + gst_init (NULL, NULL);
165 + standard_view->play = gst_element_factory_make ("playbin", "play");
168 /* setup support to navigate using a horizontal mouse wheel and the back and forward buttons */
169 g_signal_connect (G_OBJECT (view), "scroll-event", G_CALLBACK (thunar_standard_view_scroll_event), object);
170 g_signal_connect (G_OBJECT (view), "button-press-event", G_CALLBACK (thunar_standard_view_button_press_event), object);
173 /* free the statusbar text (if any) */
174 g_free (standard_view->statusbar_text);
177 +#ifdef HAVE_GSTREAMER
178 + /* stop audio-preview and release the gstreamer reference */
179 + gst_element_set_state (standard_view->play, GST_STATE_NULL);
180 + gst_object_unref (GST_OBJECT (standard_view->play));
183 (*G_OBJECT_CLASS (thunar_standard_view_parent_class)->finalize) (object);
186 @@ -2472,6 +2489,214 @@
190 +#ifdef HAVE_GSTREAMER
193 + * thunar_standard_view_try_preview:
194 + * @real_view : a GtkIconView or GtkTreeView.
195 + * @event : another motion_notify_event for the times when no mouse button is held down.
196 + * @standard_view : a #ThunarStandardView instance.
198 + * An alternative motion_notify_event signal handler that checks whether any audio files are under the cursor
199 + * and plays them in a short amount of time if the cursor stays there.
202 +thunar_standard_view_try_preview (GtkWidget *real_view,
203 + GdkEventMotion *event,
204 + ThunarStandardView *standard_view)
206 + ThunarPreferences *preferences;
208 + gboolean item_found;
209 + gboolean wrong_mime = TRUE;
211 + GtkTreePath *path = NULL;
216 + GList *preview_timer_list = NULL;
218 + preferences = thunar_preferences_get();
219 + g_object_get(G_OBJECT(preferences), "last-view", &view_type, NULL);
220 + g_object_unref(preferences);
222 + if (strncmp(view_type, "ThunarDetailsView", 17) == 0)
224 + item_found = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(real_view), event->x, event->y, &path, NULL, NULL, NULL);
228 + item_found = exo_icon_view_get_item_at_pos (EXO_ICON_VIEW (real_view), event->x, event->y, &path, NULL);
233 + if (G_LIKELY (item_found))
235 + gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, path);
236 + file = thunar_list_model_get_file (standard_view->model, &iter);
238 + if (G_LIKELY (file != NULL))
240 + mime_type = g_file_info_get_content_type (file->info);
241 + if (G_LIKELY (mime_type != NULL))
243 + wrong_mime = strncmp(mime_type, "audio/", 6);
247 + if (G_UNLIKELY (!wrong_mime))
249 + if (G_LIKELY (path != NULL))
251 + preview_timer_list = g_list_append(preview_timer_list, standard_view);
252 + preview_timer_list = g_list_append(preview_timer_list, g_file_get_uri(file->gfile));
254 + gtk_tree_path_free(path);
255 + g_timeout_add (50, (GtkFunction)thunar_standard_view_preview_timer, preview_timer_list);
256 + g_signal_handlers_disconnect_by_func (real_view, thunar_standard_view_try_preview, standard_view);
263 + g_object_unref (G_OBJECT (file));
267 + if (standard_view->playing)
269 + gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
270 + gst_element_set_state (standard_view->play, GST_STATE_NULL);
271 + standard_view->playing = FALSE;
279 +thunar_standard_view_preview_timer (GList *user_data)
281 + ThunarStandardView *standard_view = user_data->data;
282 + gchar *absolute_path = user_data->next->data;
284 + GtkWidget *real_view = GTK_BIN (standard_view)->child;
285 + ThunarPreferences *preferences;
287 + gboolean item_found;
291 + GdkColor fg = { 0, 0, 0, 0 };
292 + GdkColor bg = { 0, 65535, 65535, 65535 };
293 + static unsigned char music_note_bits[] = MUSIC_NOTE;
295 + GtkTreePath *new_path = NULL;
302 + static int call_number = 0;
304 + g_signal_handlers_disconnect_by_func (real_view, thunar_standard_view_try_preview, standard_view);
305 + gtk_widget_get_pointer (GTK_WIDGET (standard_view), &wx, &wy);
307 + preferences = thunar_preferences_get();
308 + g_object_get(G_OBJECT(preferences), "last-view", &view_type, NULL);
309 + g_object_unref(preferences);
311 + if (strncmp(view_type, "ThunarDetailsView", 17) == 0)
313 + gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW(real_view), wx, wy, &bx, &by);
314 + item_found = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(real_view), bx, by, &new_path, NULL, NULL, NULL);
318 + exo_icon_view_widget_to_icon_coords(EXO_ICON_VIEW (real_view), wx, wy, &x, &y);
319 + item_found = exo_icon_view_get_item_at_pos (EXO_ICON_VIEW (real_view), x, y, &new_path, NULL);
324 + if (standard_view->playing)
328 + gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
329 + gst_element_set_state (standard_view->play, GST_STATE_NULL);
330 + standard_view->playing = FALSE;
334 + gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, new_path);
335 + file = thunar_list_model_get_file (standard_view->model, &iter);
337 + if (strcmp(g_file_get_uri(file->gfile), absolute_path))
339 + gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
340 + gst_element_set_state (standard_view->play, GST_STATE_NULL);
341 + standard_view->playing = FALSE;
349 + gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, new_path);
350 + file = thunar_list_model_get_file (standard_view->model, &iter);
352 + if (!strcmp(g_file_get_uri(file->gfile), absolute_path))
356 + if (call_number == 1)
358 + bitmap = gdk_bitmap_create_from_data (NULL, music_note_bits, 16, 16);
359 + cursor = gdk_cursor_new_from_pixmap (bitmap, bitmap, &fg, &bg, 8, 8);
360 + gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, cursor);
362 + g_object_set (G_OBJECT (standard_view->play), "uri", g_file_get_uri(file->gfile), NULL);
365 + if (call_number > 40)
367 + gst_element_set_state (standard_view->play, GST_STATE_PLAYING);
368 + standard_view->playing = TRUE;
371 + gtk_tree_path_free (new_path);
372 + g_signal_connect (G_OBJECT (real_view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
379 + gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
384 + gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
389 + gtk_tree_path_free (new_path);
390 + g_signal_connect (G_OBJECT (real_view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
399 thunar_standard_view_scroll_event (GtkWidget *view,
400 GdkEventScroll *event,
401 @@ -3286,12 +3511,20 @@
403 thunar_standard_view_drag_timer_destroy (gpointer user_data)
405 + ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (user_data);
406 + GtkWidget *view = GTK_BIN (standard_view)->child;
408 /* unregister the motion notify and button release event handlers (thread-safe) */
409 - g_signal_handlers_disconnect_by_func (GTK_BIN (user_data)->child, thunar_standard_view_button_release_event, user_data);
410 - g_signal_handlers_disconnect_by_func (GTK_BIN (user_data)->child, thunar_standard_view_motion_notify_event, user_data);
411 + g_signal_handlers_disconnect_by_func (view, thunar_standard_view_button_release_event, user_data);
412 + g_signal_handlers_disconnect_by_func (view, thunar_standard_view_motion_notify_event, user_data);
414 /* reset the drag timer source id */
415 - THUNAR_STANDARD_VIEW (user_data)->priv->drag_timer_id = -1;
416 + standard_view->priv->drag_timer_id = -1;
418 +#ifdef HAVE_GSTREAMER
419 + /* enables audio-preview again */
420 + g_signal_connect (G_OBJECT (view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
425 diff -ru Thunar-1.3.0.orig/thunar/thunar-standard-view.h Thunar-1.3.0/thunar/thunar-standard-view.h
426 --- Thunar-1.3.0.orig/thunar/thunar-standard-view.h 2011-02-06 18:14:06.000000000 -0500
427 +++ Thunar-1.3.0/thunar/thunar-standard-view.h 2011-08-28 12:36:31.000000000 -0400
429 #include <thunar/thunar-preferences.h>
430 #include <thunar/thunar-view.h>
432 +#ifdef HAVE_GSTREAMER
433 +#include <gst/gst.h>
438 typedef struct _ThunarStandardViewPrivate ThunarStandardViewPrivate;
440 ExoBinding *loading_binding;
443 +#ifdef HAVE_GSTREAMER
448 ThunarStandardViewPrivate *priv;
453 void thunar_standard_view_selection_changed (ThunarStandardView *standard_view);
455 +gboolean thunar_standard_view_try_preview (GtkWidget *real_view,
456 + GdkEventMotion *event,
457 + ThunarStandardView *standard_view);
461 #endif /* !__THUNAR_STANDARD_VIEW_H__ */