[Xfce4-commits] <thunar:master> Implement tab middle click in location buttons (bug #9684).

Nick Schermer noreply at xfce.org
Thu Dec 27 12:06:07 CET 2012


Updating branch refs/heads/master
         to dbea7584253be6b36b666c43b205df9011058df9 (commit)
       from 99af430d8acef55b295d1882888e832d783c6434 (commit)

commit dbea7584253be6b36b666c43b205df9011058df9
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Dec 27 12:04:58 2012 +0100

    Implement tab middle click in location buttons (bug #9684).

 thunar/thunar-location-button.c  |   30 +++++++++++++++++++++++-------
 thunar/thunar-location-buttons.c |    9 +++++++++
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/thunar/thunar-location-button.c b/thunar/thunar-location-button.c
index 6769d9d..6c7180b 100644
--- a/thunar/thunar-location-button.c
+++ b/thunar/thunar-location-button.c
@@ -35,6 +35,7 @@
 #include <thunar/thunar-icon-factory.h>
 #include <thunar/thunar-location-button.h>
 #include <thunar/thunar-pango-extensions.h>
+#include <thunar/thunar-preferences.h>
 #include <thunar/thunar-private.h>
 
 
@@ -217,8 +218,9 @@ thunar_location_button_class_init (ThunarLocationButtonClass *klass)
                   G_TYPE_FROM_CLASS (klass),
                   G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE, 0);
+                  g_cclosure_marshal_VOID__BOOLEAN,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_BOOLEAN);
 
   /**
    * ThunarLocationButton::context-menu:
@@ -573,6 +575,8 @@ thunar_location_button_button_release_event (GtkWidget            *button,
                                              ThunarLocationButton *location_button)
 {
   ThunarApplication *application;
+  ThunarPreferences *preferences;
+  gboolean           open_in_tab;
 
   _thunar_return_val_if_fail (THUNAR_IS_LOCATION_BUTTON (location_button), FALSE);
 
@@ -585,10 +589,22 @@ thunar_location_button_button_release_event (GtkWidget            *button,
       /* verify that we still have a valid file */
       if (G_LIKELY (location_button->file != NULL))
         {
-          /* open a new window for the folder */
-          application = thunar_application_get ();
-          thunar_application_open_window (application, location_button->file, gtk_widget_get_screen (GTK_WIDGET (location_button)), NULL);
-          g_object_unref (G_OBJECT (application));
+          preferences = thunar_preferences_get ();
+          g_object_get (preferences, "misc-middle-click-in-tab", &open_in_tab, NULL);
+          g_object_unref (preferences);
+
+          if (open_in_tab)
+            {
+              /* open in tab */
+              g_signal_emit (G_OBJECT (location_button), location_button_signals[CLICKED], 0, TRUE);
+            }
+          else
+            {
+              /* open a new window for the folder */
+              application = thunar_application_get ();
+              thunar_application_open_window (application, location_button->file, gtk_widget_get_screen (GTK_WIDGET (location_button)), NULL);
+              g_object_unref (G_OBJECT (application));
+            }
         }
     }
 
@@ -990,7 +1006,7 @@ void
 thunar_location_button_clicked (ThunarLocationButton *location_button)
 {
   _thunar_return_if_fail (THUNAR_IS_LOCATION_BUTTON (location_button));
-  g_signal_emit (G_OBJECT (location_button), location_button_signals[CLICKED], 0);
+  g_signal_emit (G_OBJECT (location_button), location_button_signals[CLICKED], 0, FALSE);
 }
 
 
diff --git a/thunar/thunar-location-buttons.c b/thunar/thunar-location-buttons.c
index 902b598..62325e8 100644
--- a/thunar/thunar-location-buttons.c
+++ b/thunar/thunar-location-buttons.c
@@ -108,6 +108,7 @@ static void           thunar_location_buttons_scroll_left               (GtkWidg
 static void           thunar_location_buttons_scroll_right              (GtkWidget                  *button,
                                                                          ThunarLocationButtons      *buttons);
 static void           thunar_location_buttons_clicked                   (ThunarLocationButton       *button,
+                                                                         gboolean                    open_in_tab,
                                                                          ThunarLocationButtons      *buttons);
 static void           thunar_location_buttons_context_menu              (ThunarLocationButton       *button,
                                                                          GdkEventButton             *event,
@@ -1114,6 +1115,7 @@ thunar_location_buttons_scroll_right (GtkWidget             *button,
 
 static void
 thunar_location_buttons_clicked (ThunarLocationButton  *button,
+                                 gboolean               open_in_tab,
                                  ThunarLocationButtons *buttons)
 {
   ThunarFile *directory;
@@ -1125,6 +1127,13 @@ thunar_location_buttons_clicked (ThunarLocationButton  *button,
   /* determine the directory associated with the clicked button */
   directory = thunar_location_button_get_file (button);
 
+  /* open in tab */
+  if (open_in_tab)
+    {
+      thunar_navigator_open_new_tab (THUNAR_NAVIGATOR (buttons), directory);
+      return;
+    }
+
   /* disconnect from previous current directory (if any) */
   if (G_LIKELY (buttons->current_directory != NULL))
     g_object_unref (G_OBJECT (buttons->current_directory));


More information about the Xfce4-commits mailing list