Advertisement
Guest User

Untitled

a guest
Aug 27th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 15.31 KB | None | 0 0
  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-26 13:57:17.000000000 -0500
  3. +++ Thunar-1.3.0/configure.in   2011-02-26 13:58:21.000000000 -0500
  4. @@ -191,6 +191,14 @@
  5.                             [0.4], [startup-notification],
  6.                             [startup notification library])
  7.  
  8. +dnl *************************************************
  9. +dnl *** Optional support for gstreamer            ***
  10. +dnl *************************************************
  11. +XDT_CHECK_OPTIONAL_PACKAGE([GSTREAMER],
  12. +                           [gstreamer-0.10],
  13. +                           [0.10], [gstreamer],
  14. +                           [nautilus-like mouseover preview])
  15. +
  16.  dnl ***************************************************************
  17.  dnl *** Optional support for GUDev (required for thunar-volman) ***
  18.  dnl ***************************************************************
  19. @@ -338,6 +346,11 @@
  20.  else
  21.  echo "* Startup Notification:               no"
  22.  fi
  23. +if test x"$GSTREAMER_FOUND" = x"yes"; then
  24. +echo "* GStreamer:               yes"
  25. +else
  26. +echo "* GStreamer:               no"
  27. +fi
  28.  if test x"$GUDEV_FOUND" = x"yes"; then
  29.  echo "* GUDev (required for thunar-volman): yes"
  30.  else
  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-26 13:57:17.000000000 -0500
  33. +++ Thunar-1.3.0/thunar/Makefile.am 2011-02-26 13:58:21.000000000 -0500
  34. @@ -281,6 +281,14 @@
  35.     $(DBUS_LIBS)
  36.  endif
  37.  
  38. +if HAVE_GSTREAMER
  39. +Thunar_CFLAGS +=                           \
  40. +   $(GSTREAMER_CFLAGS)
  41. +
  42. +Thunar_LDADD +=                                \
  43. +   $(GSTREAMER_LIBS)
  44. +endif
  45. +
  46.  if HAVE_GIO_UNIX
  47.  Thunar_CFLAGS +=                           \
  48.     $(GIO_UNIX_CFLAGS)
  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-26 13:57:17.000000000 -0500
  51. +++ Thunar-1.3.0/thunar/thunar-abstract-icon-view.c 2011-02-26 13:58:21.000000000 -0500
  52. @@ -468,9 +468,17 @@
  53.    GtkTreeIter  iter;
  54.    ThunarFile  *file;
  55.    GtkAction   *action;
  56. +  
  57. +  ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (abstract_icon_view);
  58. +  GtkWidget *real_view = GTK_BIN (standard_view)->child;
  59.  
  60.    if (event->type == GDK_BUTTON_PRESS && event->button == 3)
  61.      {
  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);
  65. +#endif
  66. +
  67.        /* open the context menu on right clicks */
  68.        if (exo_icon_view_get_item_at_pos (view, event->x, event->y, &path, NULL))
  69.          {
  70. @@ -496,12 +504,22 @@
  71.        
  72.            /* open the context menu */
  73.            thunar_standard_view_context_menu (THUNAR_STANDARD_VIEW (abstract_icon_view), event->button, event->time);
  74. +    
  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);
  78. +#endif
  79.          }
  80.  
  81.        return TRUE;
  82.      }
  83.    else if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS) && event->button == 2)
  84.      {
  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);
  88. +#endif
  89. +
  90.        /* unselect all currently selected items */
  91.        exo_icon_view_unselect_all (view);
  92.  
  93. @@ -536,6 +554,11 @@
  94.  
  95.            /* cleanup */
  96.            gtk_tree_path_free (path);
  97. +    
  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);
  101. +#endif
  102.          }
  103.        else if (event->type == GDK_BUTTON_PRESS)
  104.          {
  105. @@ -567,6 +590,9 @@
  106.                                                  ThunarAbstractIconView *abstract_icon_view)
  107.  {
  108.    GtkAction *action;
  109. +  
  110. +  ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (abstract_icon_view);
  111. +  GtkWidget *real_view = GTK_BIN (standard_view)->child;
  112.  
  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);
  115. @@ -594,6 +620,11 @@
  116.    /* redraw the abstract_icon view */
  117.    gtk_widget_queue_draw (GTK_WIDGET (view));
  118.  
  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);
  122. +#endif
  123. +
  124.    return FALSE;
  125.  }
  126.  
  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-26 13:57:17.000000000 -0500
  129. +++ Thunar-1.3.0/thunar/thunar-standard-view.c  2011-02-26 14:00:12.000000000 -0500
  130. @@ -31,6 +31,7 @@
  131.  #endif
  132.  
  133.  #include <gdk/gdkkeysyms.h>
  134. +#include <gdk/gdkcursor.h>
  135.  
  136.  #include <thunar/thunar-application.h>
  137.  #include <thunar/thunar-create-dialog.h>
  138. @@ -57,7 +58,7 @@
  139.  #endif
  140.  
  141.  
  142. -
  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))
  145.  
  146.  
  147. @@ -262,6 +263,7 @@
  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);
  155. @@ -671,6 +673,15 @@
  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);
  158.  
  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);
  162. +
  163. +  /* initialize the player */
  164. +  gst_init (NULL, NULL);
  165. +  standard_view->play = gst_element_factory_make ("playbin", "play");
  166. +#endif
  167. +
  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);
  171. @@ -796,7 +807,13 @@
  172.  
  173.    /* free the statusbar text (if any) */
  174.    g_free (standard_view->statusbar_text);
  175. -
  176. +  
  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));
  181. +#endif
  182. +  
  183.    (*G_OBJECT_CLASS (thunar_standard_view_parent_class)->finalize) (object);
  184.  }
  185.  
  186. @@ -2472,6 +2489,171 @@
  187.  
  188.  
  189.  
  190. +#ifdef HAVE_GSTREAMER
  191. +
  192. +/**
  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.
  197. + *
  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.
  200. + **/
  201. +gboolean
  202. +thunar_standard_view_try_preview (GtkWidget          *real_view,
  203. +                 GdkEventMotion     *event,
  204. +                 ThunarStandardView *standard_view)
  205. +{
  206. +  ExoIconView *view;
  207. +  GtkTreePath *path = NULL;
  208. +  GtkTreeIter iter;
  209. +  
  210. +  ThunarFile *file;
  211. +  gchar *mime_type;
  212. +  GList *preview_timer_list = NULL;
  213. +  
  214. +  view = EXO_ICON_VIEW (real_view);
  215. +  
  216. +  if (G_LIKELY (exo_icon_view_get_item_at_pos (view, event->x, event->y, &path, NULL)))
  217. +    {
  218. +      gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, path);
  219. +      file = thunar_list_model_get_file (standard_view->model, &iter);
  220. +      
  221. +      mime_type = g_strdup("video/");
  222. +      
  223. +      if (G_UNLIKELY (strncmp(mime_type, "audio/", 6) == 0))
  224. +        {
  225. +     if (G_LIKELY (path != NULL))
  226. +       {
  227. +         preview_timer_list = g_list_append(preview_timer_list, standard_view);
  228. +         preview_timer_list = g_list_append(preview_timer_list, g_file_get_uri(file->gfile));
  229. +        
  230. +         gtk_tree_path_free(path);
  231. +         g_timeout_add (50, (GtkFunction)thunar_standard_view_preview_timer, preview_timer_list);
  232. +         g_signal_handlers_disconnect_by_func (real_view, thunar_standard_view_try_preview, standard_view);
  233. +        
  234. +         return FALSE;
  235. +       }
  236. +   }
  237. +      else
  238. +        {
  239. +     g_object_unref (G_OBJECT (file));
  240. +   }
  241. +    }
  242. +    
  243. +    if (standard_view->playing)
  244. +      {
  245. +   gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
  246. +   gst_element_set_state (standard_view->play, GST_STATE_NULL);
  247. +   standard_view->playing = FALSE;
  248. +      }
  249. +    return FALSE;
  250. +}
  251. +
  252. +
  253. +
  254. +static gboolean
  255. +thunar_standard_view_preview_timer (GList *user_data)
  256. +{
  257. +  ThunarStandardView *standard_view = user_data->data;
  258. +  gchar *absolute_path = user_data->next->data;
  259. +  
  260. +  GtkWidget *real_view = GTK_BIN (standard_view)->child;
  261. +  ExoIconView *view = EXO_ICON_VIEW (real_view);
  262. +  
  263. +  GdkCursor *cursor;
  264. +  GdkPixmap *bitmap;
  265. +  GdkColor fg = { 0, 0, 0, 0 };
  266. +  GdkColor bg = { 0, 65535, 65535, 65535 };
  267. +  static unsigned char music_note_bits[] = MUSIC_NOTE;
  268. +  
  269. +  GtkTreePath *new_path = NULL;
  270. +  GtkTreeIter iter;
  271. +  ThunarFile *file;
  272. +  gint x, y;
  273. +  gint wx, wy;
  274. +  
  275. +  static int call_number = 0;
  276. +  
  277. +  g_signal_handlers_disconnect_by_func (real_view, thunar_standard_view_try_preview, standard_view);
  278. +  gtk_widget_get_pointer (GTK_WIDGET (standard_view), &wx, &wy);
  279. +  exo_icon_view_widget_to_icon_coords(view, wx, wy, &x, &y);
  280. +  
  281. +  if (standard_view->playing)
  282. +    {
  283. +      if (!exo_icon_view_get_item_at_pos (view, x, y, &new_path, NULL))
  284. +        {
  285. +     gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
  286. +     gst_element_set_state (standard_view->play, GST_STATE_NULL);
  287. +     standard_view->playing = FALSE;
  288. +        }
  289. +      else
  290. +        {
  291. +     gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, new_path);
  292. +          file = thunar_list_model_get_file (standard_view->model, &iter);
  293. +    
  294. +          if (strcmp(g_file_get_uri(file->gfile), absolute_path))
  295. +       {
  296. +         gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
  297. +         gst_element_set_state (standard_view->play, GST_STATE_NULL);
  298. +         standard_view->playing = FALSE;
  299. +       }
  300. +        }
  301. +    }
  302. +  else
  303. +    {
  304. +      if (exo_icon_view_get_item_at_pos (view, x, y, &new_path, NULL))
  305. +        {
  306. +     gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, new_path);
  307. +          file = thunar_list_model_get_file (standard_view->model, &iter);
  308. +    
  309. +          if (!strcmp(g_file_get_uri(file->gfile), absolute_path))
  310. +       {
  311. +         call_number++;
  312. +        
  313. +         if (call_number == 1)
  314. +           {
  315. +         bitmap = gdk_bitmap_create_from_data (NULL, music_note_bits, 16, 16);
  316. +         cursor = gdk_cursor_new_from_pixmap (bitmap, bitmap, &fg, &bg, 8, 8);
  317. +         gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, cursor);
  318. +        
  319. +         g_object_set (G_OBJECT (standard_view->play), "uri", g_file_get_uri(file->gfile), NULL);
  320. +       }
  321. +      
  322. +         if (call_number > 40)
  323. +           {
  324. +         gst_element_set_state (standard_view->play, GST_STATE_PLAYING);
  325. +         standard_view->playing = TRUE;
  326. +      
  327. +         call_number = 0;
  328. +         gtk_tree_path_free (new_path);
  329. +         g_signal_connect (G_OBJECT (real_view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
  330. +         return FALSE;
  331. +           }
  332. +         return TRUE;
  333. +       }
  334. +     else
  335. +       {
  336. +         gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
  337. +       }
  338. +        }
  339. +      else
  340. +        {
  341. +     gdk_window_set_cursor (GTK_WIDGET (standard_view)->window, NULL);
  342. +   }
  343. +    }
  344. +
  345. +  call_number = 0;
  346. +  gtk_tree_path_free (new_path);
  347. +  g_signal_connect (G_OBJECT (real_view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
  348. +  return FALSE;
  349. +}
  350. +
  351. +#endif
  352. +
  353. +
  354. +
  355.  static gboolean
  356.  thunar_standard_view_scroll_event (GtkWidget          *view,
  357.                                     GdkEventScroll     *event,
  358. @@ -3286,12 +3468,20 @@
  359.  static void
  360.  thunar_standard_view_drag_timer_destroy (gpointer user_data)
  361.  {
  362. +  ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (user_data);
  363. +  GtkWidget *view = GTK_BIN (standard_view)->child;
  364. +  
  365.    /* unregister the motion notify and button release event handlers (thread-safe) */
  366. -  g_signal_handlers_disconnect_by_func (GTK_BIN (user_data)->child, thunar_standard_view_button_release_event, user_data);
  367. -  g_signal_handlers_disconnect_by_func (GTK_BIN (user_data)->child, thunar_standard_view_motion_notify_event, user_data);
  368. +  g_signal_handlers_disconnect_by_func (view, thunar_standard_view_button_release_event, user_data);
  369. +  g_signal_handlers_disconnect_by_func (view, thunar_standard_view_motion_notify_event, user_data);
  370.  
  371.    /* reset the drag timer source id */
  372. -  THUNAR_STANDARD_VIEW (user_data)->priv->drag_timer_id = -1;
  373. +  standard_view->priv->drag_timer_id = -1;
  374. +
  375. +#ifdef HAVE_GSTREAMER
  376. +  /* enables audio-preview again */
  377. +  g_signal_connect (G_OBJECT (view), "motion-notify-event", G_CALLBACK (thunar_standard_view_try_preview), standard_view);
  378. +#endif
  379.  }
  380.  
  381.  
  382. diff -ru Thunar-1.3.0.orig/thunar/thunar-standard-view.h Thunar-1.3.0/thunar/thunar-standard-view.h
  383. --- Thunar-1.3.0.orig/thunar/thunar-standard-view.h 2011-02-26 13:57:17.000000000 -0500
  384. +++ Thunar-1.3.0/thunar/thunar-standard-view.h  2011-02-26 13:58:21.000000000 -0500
  385. @@ -26,6 +26,10 @@
  386.  #include <thunar/thunar-preferences.h>
  387.  #include <thunar/thunar-view.h>
  388.  
  389. +#ifdef HAVE_GSTREAMER
  390. +#include <gst/gst.h>
  391. +#endif
  392. +
  393.  G_BEGIN_DECLS;
  394.  
  395.  typedef struct _ThunarStandardViewPrivate ThunarStandardViewPrivate;
  396. @@ -138,6 +142,11 @@
  397.    ExoBinding                *loading_binding;
  398.    gboolean                   loading;
  399.  
  400. +#ifdef HAVE_GSTREAMER
  401. +  gboolean          playing;
  402. +  GstElement           *play;
  403. +#endif
  404. +
  405.    ThunarStandardViewPrivate *priv;
  406.  };
  407.  
  408. @@ -152,6 +161,10 @@
  409.  
  410.  void  thunar_standard_view_selection_changed  (ThunarStandardView *standard_view);
  411.  
  412. +gboolean thunar_standard_view_try_preview (GtkWidget          *real_view,
  413. +                         GdkEventMotion     *event,
  414. +                         ThunarStandardView *standard_view);
  415. +
  416.  G_END_DECLS;
  417.  
  418.  #endif /* !__THUNAR_STANDARD_VIEW_H__ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement