[Xfce4-commits] <thunar:jannis/new-shortcuts-pane> Implement the "Open" and "Open in new window" shortcut actions.

Jannis Pohlmann noreply at xfce.org
Thu Jun 9 23:22:01 CEST 2011


Updating branch refs/heads/jannis/new-shortcuts-pane
         to 0ef37a4f4407c009277c66b3a05e98f7e74070de (commit)
       from fe991014ace865c589a7087e7c8b0121c7f287e7 (commit)

commit 0ef37a4f4407c009277c66b3a05e98f7e74070de
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Thu Jun 9 23:20:55 2011 +0200

    Implement the "Open" and "Open in new window" shortcut actions.

 thunar/thunar-marshal.list     |    1 +
 thunar/thunar-shortcut-row.c   |   76 ++++++++++-------
 thunar/thunar-shortcut-row.h   |   50 ++++++-----
 thunar/thunar-shortcuts-view.c |  183 ++++++++++++++++++++++++++-------------
 4 files changed, 192 insertions(+), 118 deletions(-)

diff --git a/thunar/thunar-marshal.list b/thunar/thunar-marshal.list
index c9d116c..b35db70 100644
--- a/thunar/thunar-marshal.list
+++ b/thunar/thunar-marshal.list
@@ -5,6 +5,7 @@ FLAGS:STRING,FLAGS
 VOID:BOXED,OBJECT
 VOID:BOXED,POINTER
 VOID:STRING,STRING
+VOID:OBJECT,BOOLEAN
 VOID:UINT64,UINT,UINT,UINT
 VOID:UINT,BOXED,UINT,STRING
 VOID:UINT,BOXED
diff --git a/thunar/thunar-shortcut-row.c b/thunar/thunar-shortcut-row.c
index be91cf2..8ae62ae 100644
--- a/thunar/thunar-shortcut-row.c
+++ b/thunar/thunar-shortcut-row.c
@@ -34,6 +34,7 @@
 #include <thunar/thunar-enum-types.h>
 #include <thunar/thunar-file.h>
 #include <thunar/thunar-gio-extensions.h>
+#include <thunar/thunar-marshal.h>
 #include <thunar/thunar-preferences.h>
 #include <thunar/thunar-private.h>
 #include <thunar/thunar-shortcut-row.h>
@@ -126,13 +127,12 @@ static void     thunar_shortcut_row_poke_volume_finish    (ThunarBrowser
                                                            GVolume               *volume,
                                                            ThunarFile            *file,
                                                            GError                *error,
-                                                           gpointer               unused);
+                                                           gpointer               user_data);
 static void     thunar_shortcut_row_poke_file_finish      (ThunarBrowser         *browser,
                                                            ThunarFile            *file,
                                                            ThunarFile            *target_file,
                                                            GError                *error,
-                                                           gpointer               unused);
-static void     thunar_shortcut_row_resolve_and_activate  (ThunarShortcutRow     *row);
+                                                           gpointer               user_data);
 static void     thunar_shortcut_row_icon_changed          (ThunarShortcutRow     *row);
 static void     thunar_shortcut_row_label_changed         (ThunarShortcutRow     *row);
 static void     thunar_shortcut_row_location_changed      (ThunarShortcutRow     *row);
@@ -301,8 +301,10 @@ thunar_shortcut_row_class_init (ThunarShortcutRowClass *klass)
                   G_TYPE_FROM_CLASS (klass),
                   G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
-                  g_cclosure_marshal_VOID__OBJECT,
-                  G_TYPE_NONE, 1, THUNAR_TYPE_FILE);
+                  _thunar_marshal_VOID__OBJECT_BOOLEAN,
+                  G_TYPE_NONE, 2, 
+                  THUNAR_TYPE_FILE,
+                  G_TYPE_BOOLEAN);
 
   row_signals[SIGNAL_CONTEXT_MENU] =
     g_signal_new (I_("context-menu"),
@@ -572,38 +574,36 @@ thunar_shortcut_row_button_press_event (GtkWidget      *widget,
 
   _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT_ROW (widget), FALSE);
 
-  /* distinguish between left, right and middle-click */
-  if (event->button == 1)
-    {
-      /* determine the widget's state */
-      state = gtk_widget_get_state (widget);
+  /* determine the widget's state */
+  state = gtk_widget_get_state (widget);
 
-      if (state == GTK_STATE_SELECTED)
-        {
-          if ((event->state & GDK_CONTROL_MASK) != 0)
-            gtk_widget_set_state (widget, GTK_STATE_NORMAL);
-        }
-      else
-        {
-          gtk_widget_set_state (widget, GTK_STATE_SELECTED);
-          gtk_widget_grab_focus (widget);
-        }
+  if (state == GTK_STATE_SELECTED)
+    {
+      if ((event->state & GDK_CONTROL_MASK) != 0)
+        gtk_widget_set_state (widget, GTK_STATE_NORMAL);
+    }
+  else
+    {
+      gtk_widget_set_state (widget, GTK_STATE_SELECTED);
+      gtk_widget_grab_focus (widget);
+    }
 
+  /* distinguish between left, right and middle click */
+  if (event->button == 1)
+    {
       /* resolve (e.g. mount) the shortcut and activate it */
       if (gtk_widget_get_state (widget) == GTK_STATE_SELECTED)
-        thunar_shortcut_row_resolve_and_activate (THUNAR_SHORTCUT_ROW (widget));
+        thunar_shortcut_row_resolve_and_activate (THUNAR_SHORTCUT_ROW (widget), FALSE);
     }
   else if (event->button == 3)
     {
-      /* TODO emit a context-menu signal or something similar here */
+      /* TODO start a context menu timeout */
       g_debug ("right button press");
-      return FALSE;
     }
   else if (event->button == 2)
     {
       /* TODO we don't handle middle-click events yet */
       g_debug ("middle button press");
-      return FALSE;
     }
 
   return TRUE;
@@ -640,6 +640,8 @@ static gboolean
 thunar_shortcut_row_key_press_event (GtkWidget   *widget,
                                      GdkEventKey *event)
 {
+  gboolean new_window;
+
   _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT_ROW (widget), FALSE);
 
   if (event->keyval == GDK_KEY_Return
@@ -647,7 +649,11 @@ thunar_shortcut_row_key_press_event (GtkWidget   *widget,
       || event->keyval == GDK_KEY_space
       || event->keyval== GDK_KEY_KP_Space)
     {
-      thunar_shortcut_row_resolve_and_activate (THUNAR_SHORTCUT_ROW (widget));
+      new_window = (event->state & GDK_CONTROL_MASK) != 0;
+
+      thunar_shortcut_row_resolve_and_activate (THUNAR_SHORTCUT_ROW (widget), 
+                                                new_window);
+
       return TRUE;
     }
 
@@ -1049,9 +1055,10 @@ thunar_shortcut_row_poke_volume_finish (ThunarBrowser *browser,
                                         GVolume       *volume,
                                         ThunarFile    *file,
                                         GError        *error,
-                                        gpointer       unused)
+                                        gpointer       user_data)
 {
   ThunarShortcutRow *row = THUNAR_SHORTCUT_ROW (browser);
+  gboolean           open_in_new_window = GPOINTER_TO_UINT (user_data);
 
   _thunar_return_if_fail (THUNAR_IS_SHORTCUT_ROW (browser));
   _thunar_return_if_fail (G_IS_VOLUME (volume));
@@ -1059,7 +1066,7 @@ thunar_shortcut_row_poke_volume_finish (ThunarBrowser *browser,
 
   if (error == NULL)
     {
-      g_signal_emit (row, row_signals[SIGNAL_ACTIVATED], 0, file);
+      g_signal_emit (row, row_signals[SIGNAL_ACTIVATED], 0, file, open_in_new_window);
     }
   else
     {
@@ -1079,9 +1086,10 @@ thunar_shortcut_row_poke_file_finish (ThunarBrowser *browser,
                                         ThunarFile    *file,
                                         ThunarFile    *target_file,
                                         GError        *error,
-                                        gpointer       unused)
+                                        gpointer       user_data)
 {
   ThunarShortcutRow *row = THUNAR_SHORTCUT_ROW (browser);
+  gboolean           open_in_new_window = GPOINTER_TO_UINT (user_data);
 
   _thunar_return_if_fail (THUNAR_IS_SHORTCUT_ROW (browser));
   _thunar_return_if_fail (THUNAR_IS_FILE (file));
@@ -1089,7 +1097,8 @@ thunar_shortcut_row_poke_file_finish (ThunarBrowser *browser,
 
   if (error == NULL)
     {
-      g_signal_emit (row, row_signals[SIGNAL_ACTIVATED], 0, target_file);
+      g_signal_emit (row, row_signals[SIGNAL_ACTIVATED], 0, target_file, 
+                     open_in_new_window);
     }
   else
     {
@@ -1104,8 +1113,9 @@ thunar_shortcut_row_poke_file_finish (ThunarBrowser *browser,
 
 
 
-static void
-thunar_shortcut_row_resolve_and_activate (ThunarShortcutRow *row)
+void
+thunar_shortcut_row_resolve_and_activate (ThunarShortcutRow *row,
+                                          gboolean           open_in_new_window)
 {
   ThunarFile *file;
   GError     *error = NULL;
@@ -1119,7 +1129,7 @@ thunar_shortcut_row_resolve_and_activate (ThunarShortcutRow *row)
 
       thunar_browser_poke_volume (THUNAR_BROWSER (row), row->volume, row,
                                   thunar_shortcut_row_poke_volume_finish,
-                                  NULL);
+                                  GUINT_TO_POINTER (open_in_new_window));
     }
   else if (row->location != NULL)
     {
@@ -1131,7 +1141,7 @@ thunar_shortcut_row_resolve_and_activate (ThunarShortcutRow *row)
 
           thunar_browser_poke_file (THUNAR_BROWSER (row), file, row,
                                     thunar_shortcut_row_poke_file_finish,
-                                    NULL);
+                                    GUINT_TO_POINTER (open_in_new_window));
 
           g_object_unref (file);
         }
diff --git a/thunar/thunar-shortcut-row.h b/thunar/thunar-shortcut-row.h
index 23dfa04..f69b1f5 100644
--- a/thunar/thunar-shortcut-row.h
+++ b/thunar/thunar-shortcut-row.h
@@ -37,31 +37,33 @@ G_BEGIN_DECLS
 typedef struct _ThunarShortcutRowClass ThunarShortcutRowClass;
 typedef struct _ThunarShortcutRow      ThunarShortcutRow;
 
-GType              thunar_shortcut_row_get_type          (void) G_GNUC_CONST;
+GType              thunar_shortcut_row_get_type             (void) G_GNUC_CONST;
 
-void               thunar_shortcut_row_set_icon          (ThunarShortcutRow *row,
-                                                          GIcon             *icon);
-void               thunar_shortcut_row_set_eject_icon    (ThunarShortcutRow *row,
-                                                          GIcon             *eject_icon);
-void               thunar_shortcut_row_set_label         (ThunarShortcutRow *row,
-                                                          const gchar       *label);
-GFile             *thunar_shortcut_row_get_location      (ThunarShortcutRow *row);
-void               thunar_shortcut_row_set_location      (ThunarShortcutRow *row,
-                                                          GFile             *location);
-ThunarFile        *thunar_shortcut_row_get_file          (ThunarShortcutRow *row);
-void               thunar_shortcut_row_set_file          (ThunarShortcutRow *row,
-                                                          ThunarFile        *file);
-GVolume           *thunar_shortcut_row_get_volume        (ThunarShortcutRow *row);
-void               thunar_shortcut_row_set_volume        (ThunarShortcutRow *row,
-                                                          GVolume           *volume);
-GMount            *thunar_shortcut_row_get_mount         (ThunarShortcutRow *row);
-void               thunar_shortcut_row_set_mount         (ThunarShortcutRow *row,
-                                                          GMount            *mount);
-ThunarShortcutType thunar_shortcut_row_get_shortcut_type (ThunarShortcutRow *row);
-void               thunar_shortcut_row_set_shortcut_type (ThunarShortcutRow *row,
-                                                          ThunarShortcutType shortcut_type);
-void               thunar_shortcut_row_set_icon_size     (ThunarShortcutRow *row,
-                                                          ThunarIconSize     icon_size);
+void               thunar_shortcut_row_set_icon             (ThunarShortcutRow *row,
+                                                             GIcon             *icon);
+void               thunar_shortcut_row_set_eject_icon       (ThunarShortcutRow *row,
+                                                             GIcon             *eject_icon);
+void               thunar_shortcut_row_set_label            (ThunarShortcutRow *row,
+                                                             const gchar       *label);
+GFile             *thunar_shortcut_row_get_location         (ThunarShortcutRow *row);
+void               thunar_shortcut_row_set_location         (ThunarShortcutRow *row,
+                                                             GFile             *location);
+ThunarFile        *thunar_shortcut_row_get_file             (ThunarShortcutRow *row);
+void               thunar_shortcut_row_set_file             (ThunarShortcutRow *row,
+                                                             ThunarFile        *file);
+GVolume           *thunar_shortcut_row_get_volume           (ThunarShortcutRow *row);
+void               thunar_shortcut_row_set_volume           (ThunarShortcutRow *row,
+                                                             GVolume           *volume);
+GMount            *thunar_shortcut_row_get_mount            (ThunarShortcutRow *row);
+void               thunar_shortcut_row_set_mount            (ThunarShortcutRow *row,
+                                                             GMount            *mount);
+ThunarShortcutType thunar_shortcut_row_get_shortcut_type    (ThunarShortcutRow *row);
+void               thunar_shortcut_row_set_shortcut_type    (ThunarShortcutRow *row,
+                                                             ThunarShortcutType shortcut_type);
+void               thunar_shortcut_row_set_icon_size        (ThunarShortcutRow *row,
+                                                             ThunarIconSize     icon_size);
+void               thunar_shortcut_row_resolve_and_activate (ThunarShortcutRow *row,
+                                                             gboolean           open_in_new_window);
 
 G_END_DECLS
 
diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c
index 3afe01c..3991c63 100644
--- a/thunar/thunar-shortcuts-view.c
+++ b/thunar/thunar-shortcuts-view.c
@@ -74,52 +74,59 @@ typedef void (*ThunarShortcutsViewForeachRowFunc) (ThunarShortcutsView *view,
 
 
 
-static void       thunar_shortcuts_view_constructed              (GObject                          *object);
-static void       thunar_shortcuts_view_finalize                 (GObject                          *object);
-static void       thunar_shortcuts_view_get_property             (GObject                          *object,
-                                                                  guint                             prop_id,
-                                                                  GValue                           *value,
-                                                                  GParamSpec                       *pspec);
-static void       thunar_shortcuts_view_set_property             (GObject                          *object,
-                                                                  guint                             prop_id,
-                                                                  const GValue                     *value,
-                                                                  GParamSpec                       *pspec);
-static void       thunar_shortcuts_view_row_inserted             (ThunarShortcutsView              *view,
-                                                                  GtkTreePath                      *path,
-                                                                  GtkTreeIter                      *iter,
-                                                                  GtkTreeModel                     *model);
-static void       thunar_shortcuts_view_row_deleted              (ThunarShortcutsView              *view,
-                                                                  GtkTreePath                      *path,
-                                                                  GtkTreeModel                     *model);
-static void       thunar_shortcuts_view_row_changed              (ThunarShortcutsView              *view,
-                                                                  GtkTreePath                      *path,
-                                                                  GtkTreeIter                      *iter,
-                                                                  GtkTreeModel                     *model);
-static GtkWidget *thunar_shortcuts_view_get_expander_at          (ThunarShortcutsView              *view,
-                                                                  gint                              index);
-static void       thunar_shortcuts_view_row_activated            (ThunarShortcutsView              *view,
-                                                                  ThunarFile                       *file,
-                                                                  ThunarShortcutRow                *row);
-static void       thunar_shortcuts_view_row_state_changed        (ThunarShortcutsView              *view,
-                                                                  GtkStateType                      previous_state,
-                                                                  ThunarShortcutRow                *row);
-static gboolean   thunar_shortcuts_view_row_context_menu         (ThunarShortcutsView              *view,
-                                                                  GtkWidget                        *widget);
-static void       thunar_shortcuts_view_open                     (ThunarShortcutsView              *view,
-                                                                  ThunarFile                       *file,
-                                                                  gboolean                          new_window);
-static void       thunar_shortcuts_view_foreach_row              (ThunarShortcutsView              *view,
-                                                                  ThunarShortcutsViewForeachRowFunc func,
-                                                                  gpointer                          user_data);
-static void       thunar_shortcuts_view_unselect_rows            (ThunarShortcutsView              *view,
-                                                                  ThunarShortcutRow                *row,
-                                                                  gpointer                          user_data);
-static void       thunar_shortcuts_view_unprelight_rows          (ThunarShortcutsView              *view,
-                                                                  ThunarShortcutRow                *row,
-                                                                  gpointer                          user_data);
-static void       thunar_shortcuts_view_update_selection_by_file (ThunarShortcutsView              *view,
-                                                                  ThunarShortcutRow                *row,
-                                                                  gpointer                          user_data);
+static void               thunar_shortcuts_view_constructed              (GObject                          *object);
+static void               thunar_shortcuts_view_finalize                 (GObject                          *object);
+static void               thunar_shortcuts_view_get_property             (GObject                          *object,
+                                                                          guint                             prop_id,
+                                                                          GValue                           *value,
+                                                                          GParamSpec                       *pspec);
+static void               thunar_shortcuts_view_set_property             (GObject                          *object,
+                                                                          guint                             prop_id,
+                                                                          const GValue                     *value,
+                                                                          GParamSpec                       *pspec);
+static void               thunar_shortcuts_view_row_inserted             (ThunarShortcutsView              *view,
+                                                                          GtkTreePath                      *path,
+                                                                          GtkTreeIter                      *iter,
+                                                                          GtkTreeModel                     *model);
+static void               thunar_shortcuts_view_row_deleted              (ThunarShortcutsView              *view,
+                                                                          GtkTreePath                      *path,
+                                                                          GtkTreeModel                     *model);
+static void               thunar_shortcuts_view_row_changed              (ThunarShortcutsView              *view,
+                                                                          GtkTreePath                      *path,
+                                                                          GtkTreeIter                      *iter,
+                                                                          GtkTreeModel                     *model);
+static GtkWidget *        thunar_shortcuts_view_get_expander_at          (ThunarShortcutsView              *view,
+                                                                          gint                              index);
+static void               thunar_shortcuts_view_row_activated            (ThunarShortcutsView              *view,
+                                                                          ThunarFile                       *file,
+                                                                          gboolean                          open_in_new_window,
+                                                                          ThunarShortcutRow                *row);
+static void               thunar_shortcuts_view_row_state_changed        (ThunarShortcutsView              *view,
+                                                                          GtkStateType                      previous_state,
+                                                                          ThunarShortcutRow                *row);
+static gboolean           thunar_shortcuts_view_row_context_menu         (ThunarShortcutsView              *view,
+                                                                          GtkWidget                        *widget);
+static void               thunar_shortcuts_view_row_open                 (ThunarShortcutsView              *view);
+static void               thunar_shortcuts_view_row_open_new_window      (ThunarShortcutsView              *view);
+static void               thunar_shortcuts_view_open                     (ThunarShortcutsView              *view,
+                                                                          ThunarFile                       *file,
+                                                                          gboolean                          new_window);
+static ThunarShortcutRow *thunar_shortcuts_view_get_selected_row         (ThunarShortcutsView              *view);
+static void               thunar_shortcuts_view_find_selected_row        (ThunarShortcutsView              *view,
+                                                                          ThunarShortcutRow                *row,
+                                                                          gpointer                          user_data);
+static void               thunar_shortcuts_view_foreach_row              (ThunarShortcutsView              *view,
+                                                                          ThunarShortcutsViewForeachRowFunc func,
+                                                                          gpointer                          user_data);
+static void               thunar_shortcuts_view_unselect_rows            (ThunarShortcutsView              *view,
+                                                                          ThunarShortcutRow                *row,
+                                                                          gpointer                          user_data);
+static void               thunar_shortcuts_view_unprelight_rows          (ThunarShortcutsView              *view,
+                                                                          ThunarShortcutRow                *row,
+                                                                          gpointer                          user_data);
+static void               thunar_shortcuts_view_update_selection_by_file (ThunarShortcutsView              *view,
+                                                                          ThunarShortcutRow                *row,
+                                                                          gpointer                          user_data);
 
 
 
@@ -144,10 +151,6 @@ static guint view_signals[LAST_SIGNAL];
 
 
 
-static GQuark thunar_shortcuts_view_row_quark;
-
-
-
 G_DEFINE_TYPE_WITH_CODE (ThunarShortcutsView, thunar_shortcuts_view, GTK_TYPE_EVENT_BOX,
                          G_IMPLEMENT_INTERFACE (THUNAR_TYPE_BROWSER, NULL))
 
@@ -158,9 +161,6 @@ thunar_shortcuts_view_class_init (ThunarShortcutsViewClass *klass)
 {
   GObjectClass   *gobject_class;
 
-  /* initialize the row quark */
-  thunar_shortcuts_view_row_quark = g_quark_from_static_string ("thunar-shortcuts-view-row");
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->constructed = thunar_shortcuts_view_constructed;
   gobject_class->finalize = thunar_shortcuts_view_finalize;
@@ -626,13 +626,14 @@ thunar_shortcuts_view_get_expander_at (ThunarShortcutsView *view,
 static void
 thunar_shortcuts_view_row_activated (ThunarShortcutsView *view,
                                      ThunarFile          *file,
+                                     gboolean             open_in_new_window,
                                      ThunarShortcutRow   *row)
 {
   _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
   _thunar_return_if_fail (THUNAR_IS_FILE (file));
   _thunar_return_if_fail (THUNAR_IS_SHORTCUT_ROW (row));
 
-  thunar_shortcuts_view_open (view, file, FALSE);
+  thunar_shortcuts_view_open (view, file, open_in_new_window);
 }
 
 
@@ -686,7 +687,8 @@ thunar_shortcuts_view_row_context_menu (ThunarShortcutsView *view,
 
   /* append the "Open" menu action */
   item = gtk_image_menu_item_new_with_mnemonic (_("_Open"));
-  g_object_set_qdata (G_OBJECT (item), thunar_shortcuts_view_row_quark, row);
+  g_signal_connect_swapped (item, "activate",
+                            G_CALLBACK (thunar_shortcuts_view_row_open), view);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   gtk_widget_show (item);
 
@@ -697,7 +699,9 @@ thunar_shortcuts_view_row_context_menu (ThunarShortcutsView *view,
 
   /* append the "Open in New Window" menu action */
   item = gtk_image_menu_item_new_with_mnemonic (_("Open in New Window"));
-  g_object_set_qdata (G_OBJECT (item), thunar_shortcuts_view_row_quark, row);
+  g_signal_connect_swapped (item, "activate",
+                            G_CALLBACK (thunar_shortcuts_view_row_open_new_window),
+                            view);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   gtk_widget_show (item);
 
@@ -714,7 +718,6 @@ thunar_shortcuts_view_row_context_menu (ThunarShortcutsView *view,
     {
       /* append the "Disconnect" item */
       item = gtk_image_menu_item_new_with_mnemonic (_("Disconn_ect"));
-      g_object_set_qdata (G_OBJECT (item), thunar_shortcuts_view_row_quark, row);
       gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
       gtk_widget_show (item);
 
@@ -734,7 +737,6 @@ thunar_shortcuts_view_row_context_menu (ThunarShortcutsView *view,
       /* check if we have a mounted volume */
       /* append the "Mount" item */
       item = gtk_image_menu_item_new_with_mnemonic (_("_Mount"));
-      g_object_set_qdata (G_OBJECT (item), thunar_shortcuts_view_row_quark, row);
       gtk_widget_set_sensitive (item, !thunar_g_volume_is_mounted (volume));
       gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
       gtk_widget_show (item);
@@ -743,7 +745,6 @@ thunar_shortcuts_view_row_context_menu (ThunarShortcutsView *view,
         {
           /* append the "Unmount" item */
           item = gtk_image_menu_item_new_with_mnemonic (_("_Unmount"));
-          g_object_set_qdata (G_OBJECT (item), thunar_shortcuts_view_row_quark, row);
           gtk_widget_set_sensitive (item, thunar_g_volume_is_mounted (volume));
           gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
           gtk_widget_show (item);
@@ -751,7 +752,6 @@ thunar_shortcuts_view_row_context_menu (ThunarShortcutsView *view,
 
       /* append the "Disconnect" (eject + safely remove drive) item */
       item = gtk_image_menu_item_new_with_mnemonic (_("Disconn_ect"));
-      g_object_set_qdata (G_OBJECT (item), thunar_shortcuts_view_row_quark, row);
       gtk_widget_set_sensitive (item, thunar_g_volume_is_mounted (volume));
       gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
       gtk_widget_show (item);
@@ -768,7 +768,6 @@ thunar_shortcuts_view_row_context_menu (ThunarShortcutsView *view,
     {
       /* append the "Empty Trash" menu action */
       item = gtk_image_menu_item_new_with_mnemonic (_("_Empty Trash"));
-      g_object_set_qdata (G_OBJECT (item), thunar_shortcuts_view_row_quark, row);
       gtk_widget_set_sensitive (item, (thunar_file_get_item_count (file) > 0));
       gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
       gtk_widget_show (item);
@@ -858,6 +857,68 @@ thunar_shortcuts_view_row_context_menu (ThunarShortcutsView *view,
 
 
 static void
+thunar_shortcuts_view_row_open (ThunarShortcutsView *view)
+{
+  ThunarShortcutRow *row;
+
+  _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
+
+  row = thunar_shortcuts_view_get_selected_row (view);
+
+  if (row != NULL)
+    thunar_shortcut_row_resolve_and_activate (row, FALSE);
+}
+
+
+
+static void
+thunar_shortcuts_view_row_open_new_window (ThunarShortcutsView *view)
+{
+  ThunarShortcutRow *row;
+
+  _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
+
+  row = thunar_shortcuts_view_get_selected_row (view);
+
+  if (row != NULL)
+    thunar_shortcut_row_resolve_and_activate (row, TRUE);
+}
+
+
+
+static ThunarShortcutRow *
+thunar_shortcuts_view_get_selected_row (ThunarShortcutsView *view)
+{
+  ThunarShortcutRow *result = NULL;
+
+  _thunar_return_val_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view), NULL);
+
+  thunar_shortcuts_view_foreach_row (view, thunar_shortcuts_view_find_selected_row,
+                                     &result);
+
+  return result;
+}
+
+
+
+static void
+thunar_shortcuts_view_find_selected_row (ThunarShortcutsView *view,
+                                         ThunarShortcutRow   *row,
+                                         gpointer             user_data)
+{
+  ThunarShortcutRow **return_value = user_data;
+
+  _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
+  _thunar_return_if_fail (THUNAR_IS_SHORTCUT_ROW (row));
+  _thunar_return_if_fail (return_value != NULL);
+
+  if (gtk_widget_get_state (GTK_WIDGET (row)) == GTK_STATE_SELECTED)
+    *return_value = row;
+}
+
+
+
+static void
 thunar_shortcuts_view_foreach_row (ThunarShortcutsView              *view,
                                    ThunarShortcutsViewForeachRowFunc func,
                                    gpointer                          user_data)



More information about the Xfce4-commits mailing list