~ubuntu-branches/ubuntu/raring/thunar/raring

« back to all changes in this revision

Viewing changes to thunar/thunar-abstract-icon-view.c

  • Committer: Package Import Robot
  • Author(s): Lionel Le Folgoc
  • Date: 2012-12-03 13:13:58 UTC
  • mfrom: (1.3.4)
  • Revision ID: package-import@ubuntu.com-20121203131358-zk6tkel37d732wh6
Tags: 1.6.0-0ubuntu1
* Upload to raring.
* Remaining Ubuntu change:
  - debian/control: recommend udisks2 for mounting devices. lp: #1014632
* Drop obsolete Ubuntu changes:
  - debian/patches/02_guard-for-no-supported-vfs-schemas.patch,
    debian/patches/xubuntu_fix-duplicate-volumes.patch: included upstream.
* Bugs fixed:
  - "Thunar: sendto_printer broken" lp: #1061846
  - "segfault when a specific html file is selected" lp: #751739
  - "can't book mark remote shares" lp: #778268
  - "Thunar crashed with SIGSEGV in thunarx_menu_provider_get_file_actions()
    thinking a directory was a file" lp: #852410
  - "Left or right-clicking on 3MB or bigger svg file is unresponsive"
    lp: #893330
  - "Thunar crashed with SIGSEGV in fast_validate()" lp: #913041
  - "Thunar crashed with SIGSEGV in thunar_file_get_display_name()"
    lp: #931101
  - "Thunar crashed with SIGSEGV in sort_by_mime_type()" lp: #931842
  - "Thunar crashed with SIGSEGV in thunar_util_parse_parent()" lp: #969222
  - "thunar crashed with SIGSEGV in thunar_standard_view_cancel_thumbnailing()"
    lp: #1059397
  - "Does not unmount USB drive when you try first time" lp: #1059997
  - "regression: thunar no longer shows all unmounted, but mountable, volumes
    in sidepane" lp: #1068947
  - "Thunar shows folder sizes wrong" lp: #59235
  - "Right-click "Open With" list not refreshing" lp: #107392
  - "no thunar contextmenu with GTK setting "gtk-menu-popup-delay = 0""
    lp: #127372
  - "rename folder, still active but answers not on 'Enter'" lp: #479975
  - "Thunar hangs on first launch of each session" lp: #775117
  - "emblems disappear on rename" lp: #877755
  - "Remote Deleted file in Thunar remains visible until resfresh" lp: #999824
  - "Incorrect alphabetical sort order in thunar with non-latin (eg. cyrillic)
    file names" lp: #684317
  - "Thunar does not display current folder name" lp: #875193
  - "Thunar crashed with SIGSEGV in g_file_equal()" lp: #900306
  - "Hard to see, if volume is mounted or not" lp: #838917

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <thunar/thunar-abstract-icon-view-ui.h>
28
28
#include <thunar/thunar-gobject-extensions.h>
29
29
#include <thunar/thunar-gtk-extensions.h>
 
30
#include <thunar/thunar-preferences.h>
30
31
#include <thunar/thunar-private.h>
31
32
 
32
33
 
44
45
static GList       *thunar_abstract_icon_view_get_selected_items    (ThunarStandardView           *standard_view);
45
46
static void         thunar_abstract_icon_view_select_all            (ThunarStandardView           *standard_view);
46
47
static void         thunar_abstract_icon_view_unselect_all          (ThunarStandardView           *standard_view);
 
48
static void         thunar_abstract_icon_view_selection_invert      (ThunarStandardView           *standard_view);
47
49
static void         thunar_abstract_icon_view_select_path           (ThunarStandardView           *standard_view,
48
50
                                                                     GtkTreePath                  *path);
49
51
static void         thunar_abstract_icon_view_set_cursor            (ThunarStandardView           *standard_view,
99
101
  gint ui_merge_id;
100
102
 
101
103
  /* mouse gesture support */
102
 
  gint gesture_start_x;
103
 
  gint gesture_start_y;
104
 
  gint gesture_current_x;
105
 
  gint gesture_current_y;
106
 
  gint gesture_expose_id;
107
 
  gint gesture_motion_id;
108
 
  gint gesture_release_id;
 
104
  gint   gesture_start_x;
 
105
  gint   gesture_start_y;
 
106
  gint   gesture_current_x;
 
107
  gint   gesture_current_y;
 
108
  gulong gesture_expose_id;
 
109
  gulong gesture_motion_id;
 
110
  gulong gesture_release_id;
109
111
};
110
112
 
111
113
 
153
155
  thunarstandard_view_class->get_selected_items = thunar_abstract_icon_view_get_selected_items;
154
156
  thunarstandard_view_class->select_all = thunar_abstract_icon_view_select_all;
155
157
  thunarstandard_view_class->unselect_all = thunar_abstract_icon_view_unselect_all;
 
158
  thunarstandard_view_class->selection_invert = thunar_abstract_icon_view_selection_invert;
156
159
  thunarstandard_view_class->select_path = thunar_abstract_icon_view_select_path;
157
160
  thunarstandard_view_class->set_cursor = thunar_abstract_icon_view_set_cursor;
158
161
  thunarstandard_view_class->scroll_to_path = thunar_abstract_icon_view_scroll_to_path;
319
322
 
320
323
 
321
324
static void
 
325
thunar_abstract_icon_view_selection_invert (ThunarStandardView *standard_view)
 
326
{
 
327
  _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (standard_view));
 
328
  exo_icon_view_selection_invert (EXO_ICON_VIEW (GTK_BIN (standard_view)->child));
 
329
}
 
330
 
 
331
 
 
332
 
 
333
static void
322
334
thunar_abstract_icon_view_select_path (ThunarStandardView *standard_view,
323
335
                                       GtkTreePath        *path)
324
336
{
406
418
  else if (abstract_icon_view->priv->gesture_start_x - abstract_icon_view->priv->gesture_current_x > 40
407
419
      && ABS (abstract_icon_view->priv->gesture_start_y - abstract_icon_view->priv->gesture_current_y) < 40)
408
420
    {
409
 
      return gtk_ui_manager_get_action (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, "/main-menu/go-menu/back");
 
421
      return gtk_ui_manager_get_action (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, "/main-menu/go-menu/placeholder-go-history-actions/back");
410
422
    }
411
423
  else if (abstract_icon_view->priv->gesture_current_x - abstract_icon_view->priv->gesture_start_x > 40
412
424
      && ABS (abstract_icon_view->priv->gesture_start_y - abstract_icon_view->priv->gesture_current_y) < 40)
413
425
    {
414
 
      return gtk_ui_manager_get_action (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, "/main-menu/go-menu/forward");
 
426
      return gtk_ui_manager_get_action (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, "/main-menu/go-menu/placeholder-go-history-actions/forward");
415
427
    }
416
428
  else if (abstract_icon_view->priv->gesture_current_y - abstract_icon_view->priv->gesture_start_y > 40
417
429
      && ABS (abstract_icon_view->priv->gesture_start_x - abstract_icon_view->priv->gesture_current_x) < 40)
464
476
                                              GdkEventButton         *event,
465
477
                                              ThunarAbstractIconView *abstract_icon_view)
466
478
{
467
 
  GtkTreePath *path;
468
 
  GtkTreeIter  iter;
469
 
  ThunarFile  *file;
470
 
  GtkAction   *action;
 
479
  GtkTreePath       *path;
 
480
  GtkTreeIter        iter;
 
481
  ThunarFile        *file;
 
482
  GtkAction         *action;
 
483
  ThunarPreferences *preferences;
 
484
  gboolean           in_tab;
 
485
  const gchar       *action_name;
471
486
 
472
487
  if (event->type == GDK_BUTTON_PRESS && event->button == 3)
473
488
    {
485
500
          gtk_tree_path_free (path);
486
501
 
487
502
          /* queue the menu popup */
488
 
          thunar_standard_view_queue_popup (THUNAR_STANDARD_VIEW (abstract_icon_view), event);
 
503
          thunar_standard_view_context_menu (THUNAR_STANDARD_VIEW (abstract_icon_view), event->button, event->time);
489
504
        }
490
505
      else if ((event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
491
506
        {
522
537
              if (G_LIKELY (file != NULL))
523
538
                {
524
539
                  /* determine the action to perform depending on the type of the file */
525
 
                  action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager,
526
 
                      thunar_file_is_directory (file) ? "open-in-new-window" : "open");
527
 
      
 
540
                  if (thunar_file_is_directory (file))
 
541
                    {
 
542
                      /* lookup setting if we should open in a tab or a window */
 
543
                      preferences = thunar_preferences_get ();
 
544
                      g_object_get (preferences, "misc-middle-click-in-tab", &in_tab, NULL);
 
545
                      g_object_unref (preferences);
 
546
 
 
547
                      /* holding ctrl inverts the action */
 
548
                      if ((event->state & GDK_CONTROL_MASK) != 0)
 
549
                        in_tab = !in_tab;
 
550
 
 
551
                      action_name = in_tab ? "open-in-new-tab" : "open-in-new-window";
 
552
                    }
 
553
                  else
 
554
                    {
 
555
                      action_name = "open";
 
556
                    }
 
557
 
528
558
                  /* emit the action */
 
559
                  action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, action_name);
529
560
                  if (G_LIKELY (action != NULL))
530
561
                    gtk_action_activate (action);
531
562
 
610
641
  gchar      *stock_id;
611
642
  GdkColor    bg;
612
643
  cairo_t    *cr;
 
644
  gint        x, y;
613
645
 
614
646
  _thunar_return_val_if_fail (EXO_IS_ICON_VIEW (view), FALSE);
615
647
  _thunar_return_val_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view), FALSE);
617
649
  _thunar_return_val_if_fail (abstract_icon_view->priv->gesture_motion_id > 0, FALSE);
618
650
  _thunar_return_val_if_fail (abstract_icon_view->priv->gesture_release_id > 0, FALSE);
619
651
 
 
652
  /* create the cairo context (is already clipped) */
 
653
  cr = gdk_cairo_create (event->window);
 
654
 
620
655
  /* shade the abstract_icon view content while performing mouse gestures */
621
 
  cr = gdk_cairo_create (event->window);
622
656
  bg = GTK_WIDGET (view)->style->base[GTK_STATE_NORMAL];
623
657
  cairo_set_source_rgba (cr, bg.red / 65535.0, bg.green / 65535.0, bg.blue / 65535.0, 0.7);
624
 
  cairo_rectangle (cr, event->area.x, event->area.y, event->area.width, event->area.height);
625
 
  cairo_clip (cr);
626
658
  cairo_paint (cr);
627
 
  cairo_destroy (cr);
628
659
 
629
660
  /* determine the gesture action */
630
661
  action = thunar_abstract_icon_view_gesture_action (abstract_icon_view);
646
677
      /* draw the rendered icon */
647
678
      if (G_LIKELY (stock_icon != NULL))
648
679
        {
 
680
          /* x/y position of the icon */
 
681
          x = abstract_icon_view->priv->gesture_start_x - gdk_pixbuf_get_width (stock_icon) / 2;
 
682
          y = abstract_icon_view->priv->gesture_start_y - gdk_pixbuf_get_height (stock_icon) / 2;
 
683
 
649
684
          /* render the stock abstract_icon into the abstract_icon view window */
650
 
          gdk_draw_pixbuf (event->window, NULL, stock_icon, 0, 0,
651
 
                           abstract_icon_view->priv->gesture_start_x - gdk_pixbuf_get_width (stock_icon) / 2,
652
 
                           abstract_icon_view->priv->gesture_start_y - gdk_pixbuf_get_height (stock_icon) / 2,
653
 
                           gdk_pixbuf_get_width (stock_icon), gdk_pixbuf_get_height (stock_icon),
654
 
                           GDK_RGB_DITHER_NONE, 0, 0);
 
685
          gdk_cairo_set_source_pixbuf (cr, stock_icon, x, y);
 
686
          cairo_rectangle (cr, x, y,
 
687
                           gdk_pixbuf_get_width (stock_icon),
 
688
                           gdk_pixbuf_get_height (stock_icon));
 
689
          cairo_fill (cr);
655
690
 
656
691
          /* release the stock abstract_icon */
657
692
          g_object_unref (G_OBJECT (stock_icon));
661
696
      g_free (stock_id);
662
697
    }
663
698
 
 
699
  /* destroy context */
 
700
  cairo_destroy (cr);
 
701
 
664
702
  return FALSE;
665
703
}
666
704