summarylogtreecommitdiffstats
path: root/split_pane.patch
blob: 48ec09e5d23ab1cc0f01d699f004641d486342e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
diff -rudp thunar-4.16.10.orig/thunar/thunar-standard-view.c thunar-4.16.10/thunar/thunar-standard-view.c
--- thunar-4.16.10.orig/thunar/thunar-standard-view.c	2021-10-16 13:53:35.000000000 -0400
+++ thunar-4.16.10/thunar/thunar-standard-view.c	2021-10-16 14:55:34.000000000 -0400
@@ -3594,8 +3594,8 @@ thunar_standard_view_queue_popup (Thunar
       standard_view->priv->drag_timer_event = gtk_get_current_event ();
 
       /* register the motion notify and the button release events on the real view */
-      g_signal_connect (G_OBJECT (view), "button-release-event", G_CALLBACK (thunar_standard_view_button_release_event), standard_view);
-      g_signal_connect (G_OBJECT (view), "motion-notify-event", G_CALLBACK (thunar_standard_view_motion_notify_event), standard_view);
+      g_signal_connect_after (G_OBJECT (view), "button-release-event", G_CALLBACK (thunar_standard_view_button_release_event), standard_view);
+      g_signal_connect_after (G_OBJECT (view), "motion-notify-event", G_CALLBACK (thunar_standard_view_motion_notify_event), standard_view);
     }
 }
 
diff -rudp thunar-4.16.10.orig/thunar/thunar-window.c thunar-4.16.10/thunar/thunar-window.c
--- thunar-4.16.10.orig/thunar/thunar-window.c	2021-10-16 13:53:35.000000000 -0400
+++ thunar-4.16.10/thunar/thunar-window.c	2021-10-16 15:10:34.000000000 -0400
@@ -76,6 +76,7 @@ enum
 enum
 {
   BACK,
+  PANE_WINDOW,
   RELOAD,
   TOGGLE_SIDEPANE,
   TOGGLE_MENUBAR,
@@ -111,6 +112,7 @@ static void      thunar_window_set_prope
                                                            guint                   prop_id,
                                                            const GValue           *value,
                                                            GParamSpec             *pspec);
+static gboolean  thunar_window_pane_window                (ThunarWindow           *window);
 static gboolean  thunar_window_reload                     (ThunarWindow           *window,
                                                            gboolean                reload_info);
 static gboolean  thunar_window_toggle_sidepane            (ThunarWindow           *window);
@@ -229,6 +231,9 @@ static gboolean  thunar_window_save_geom
 static void      thunar_window_save_geometry_timer_destroy(gpointer                user_data);
 static void      thunar_window_set_zoom_level             (ThunarWindow           *window,
                                                            ThunarZoomLevel         zoom_level);
+static gboolean  thunar_window_notebook_select            (GtkWidget              *notebook,
+                                                           GdkEvent               *event,
+                                                           ThunarWindow           *window);
 static void      thunar_window_update_window_icon         (ThunarWindow           *window);
 static void      thunar_window_create_menu                (ThunarWindow           *window,
                                                            ThunarWindowAction      action,
@@ -278,6 +283,7 @@ struct _ThunarWindowClass
   GtkWindowClass __parent__;
 
   /* internal action signals */
+  gboolean (*pane_window)     (ThunarWindow *window);
   gboolean (*reload)          (ThunarWindow *window,
                                gboolean      reload_info);
   gboolean (*zoom_in)         (ThunarWindow *window);
@@ -312,9 +318,12 @@ struct _ThunarWindow
   GtkWidget              *menubar;
   GtkWidget              *spinner;
   GtkWidget              *paned;
+  GtkWidget              *panes;
   GtkWidget              *sidepane;
   GtkWidget              *view_box;
   GtkWidget              *notebook;
+  GtkWidget              *notebook1;
+  GtkWidget              *notebook2;
   GtkWidget              *view;
   GtkWidget              *statusbar;
 
@@ -395,6 +404,7 @@ static XfceGtkActionEntry thunar_window_
     { THUNAR_WINDOW_ACTION_VIEW_AS_ICONS,                  "<Actions>/ThunarWindow/view-as-icons",                   "<Primary>1",           XFCE_GTK_RADIO_MENU_ITEM, N_ ("_Icon View"),             N_ ("Display folder content in an icon view"),                                        NULL,                      G_CALLBACK (thunar_window_action_icon_view),          },
     { THUNAR_WINDOW_ACTION_VIEW_AS_DETAILED_LIST,          "<Actions>/ThunarWindow/view-as-detailed-list",           "<Primary>2",           XFCE_GTK_RADIO_MENU_ITEM, N_ ("_List View"),             N_ ("Display folder content in a detailed list view"),                                NULL,                      G_CALLBACK (thunar_window_action_detailed_view),      },
     { THUNAR_WINDOW_ACTION_VIEW_AS_COMPACT_LIST,           "<Actions>/ThunarWindow/view-as-compact-list",            "<Primary>3",           XFCE_GTK_RADIO_MENU_ITEM, N_ ("_Compact View"),          N_ ("Display folder content in a compact list view"),                                 NULL,                      G_CALLBACK (thunar_window_action_compact_view),       },
+    { THUNAR_WINDOW_ACTION_PANE_WINDOW,                    "<Actions>/ThunarWindow/pane-window",                     "F3",                   XFCE_GTK_RADIO_MENU_ITEM, NULL,                          NULL,                                                                                 NULL,                      G_CALLBACK (thunar_window_pane_window),               },
 
     { THUNAR_WINDOW_ACTION_GO_MENU,                        "<Actions>/ThunarWindow/go-menu",                         "",                     XFCE_GTK_MENU_ITEM,       N_ ("_Go"),                    NULL,                                                                                NULL,                      NULL                                                  },
     { THUNAR_WINDOW_ACTION_OPEN_FILE_SYSTEM,               "<Actions>/ThunarWindow/open-file-system",                "",                     XFCE_GTK_IMAGE_MENU_ITEM, N_ ("File System"),            N_ ("Browse the file system"),                                                       "drive-harddisk",          G_CALLBACK (thunar_window_action_open_file_system),   },
@@ -453,6 +463,7 @@ thunar_window_class_init (ThunarWindowCl
   gtkwidget_class->configure_event = thunar_window_configure_event;
 
   klass->reload = thunar_window_reload;
+  klass->pane_window = thunar_window_pane_window;
   klass->zoom_in = thunar_window_zoom_in;
   klass->zoom_out = thunar_window_zoom_out;
   klass->zoom_reset = thunar_window_zoom_reset;
@@ -503,6 +514,23 @@ thunar_window_class_init (ThunarWindowCl
                                                          EXO_PARAM_READWRITE));
 
   /**
+   * ThunarWindow::pane-window:
+   * @window : a #ThunarWindow instance.
+   *
+   * Emitted whenever the user requests to pane the window
+   * of the currently displayed folder. This is an internal
+   * signal used to bind the action to keys.
+   **/
+  window_signals[PANE_WINDOW] =
+    g_signal_new (I_("pane-window"),
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (ThunarWindowClass, pane_window),
+                  g_signal_accumulator_true_handled, NULL,
+                  _thunar_marshal_BOOLEAN__VOID,
+                  G_TYPE_BOOLEAN, 0);
+
+/**
    * ThunarWindow::reload:
    * @window : a #ThunarWindow instance.
    *
@@ -757,25 +785,35 @@ thunar_window_init (ThunarWindow *window
   g_signal_connect_swapped (window->paned, "button-release-event", G_CALLBACK (thunar_window_save_paned), window);
 
   window->view_box = gtk_grid_new ();
-  gtk_paned_pack2 (GTK_PANED (window->paned), window->view_box, TRUE, FALSE);
+  gtk_paned_add2 (GTK_PANED (window->paned), window->view_box);
   gtk_widget_show (window->view_box);
 
+  /* Create panes where the notebook will be */
+  window->panes = gtk_hpaned_new (); gtk_widget_set_hexpand (window->panes, TRUE); gtk_widget_set_vexpand (window->panes, TRUE);
+  gtk_widget_add_events (window->panes, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK);
+  gtk_grid_attach (GTK_GRID (window->view_box), window->panes, 0, 1, 1, 1);
+  gtk_widget_show (window->panes);
+
   /* tabs */
-  window->notebook = gtk_notebook_new ();
-  gtk_widget_set_hexpand (window->notebook, TRUE);
-  gtk_widget_set_vexpand (window->notebook, TRUE);
-  gtk_grid_attach (GTK_GRID (window->view_box), window->notebook, 0, 1, 1, 1);
-  g_signal_connect (G_OBJECT (window->notebook), "switch-page", G_CALLBACK (thunar_window_notebook_switch_page), window);
-  g_signal_connect (G_OBJECT (window->notebook), "page-added", G_CALLBACK (thunar_window_notebook_page_added), window);
-  g_signal_connect (G_OBJECT (window->notebook), "page-removed", G_CALLBACK (thunar_window_notebook_page_removed), window);
-  g_signal_connect_after (G_OBJECT (window->notebook), "button-press-event", G_CALLBACK (thunar_window_notebook_button_press_event), window);
-  g_signal_connect (G_OBJECT (window->notebook), "popup-menu", G_CALLBACK (thunar_window_notebook_popup_menu), window);
-  g_signal_connect (G_OBJECT (window->notebook), "create-window", G_CALLBACK (thunar_window_notebook_create_window), window);
-  gtk_notebook_set_show_border (GTK_NOTEBOOK (window->notebook), FALSE);
-  gtk_notebook_set_scrollable (GTK_NOTEBOOK (window->notebook), TRUE);
-  gtk_container_set_border_width (GTK_CONTAINER (window->notebook), 0);
-  gtk_notebook_set_group_name (GTK_NOTEBOOK (window->notebook), "thunar-tabs");
-  gtk_widget_show (window->notebook);
+  /* notebook1 */
+  window->notebook1 = gtk_notebook_new ();
+  gtk_paned_pack1 (GTK_PANED (window->panes), window->notebook1, TRUE, FALSE);
+  g_signal_connect (G_OBJECT (window->notebook1), "switch-page", G_CALLBACK (thunar_window_notebook_switch_page), window);
+  g_signal_connect (G_OBJECT (window->notebook1), "page-added", G_CALLBACK (thunar_window_notebook_page_added), window);
+  g_signal_connect (G_OBJECT (window->notebook1), "page-removed", G_CALLBACK (thunar_window_notebook_page_removed), window);
+  g_signal_connect_after (G_OBJECT (window->notebook1), "button-press-event", G_CALLBACK (thunar_window_notebook_button_press_event), window);
+  g_signal_connect (G_OBJECT (window->notebook1), "popup-menu", G_CALLBACK (thunar_window_notebook_popup_menu), window);
+  g_signal_connect (G_OBJECT (window->notebook1), "create-window", G_CALLBACK (thunar_window_notebook_create_window), window);
+  gtk_notebook_set_show_border (GTK_NOTEBOOK (window->notebook1), FALSE);
+  //gtk_notebook_set_homogeneous_tabs (GTK_NOTEBOOK (window->notebook1), TRUE);
+  gtk_notebook_set_scrollable (GTK_NOTEBOOK (window->notebook1), TRUE);
+  gtk_container_set_border_width (GTK_CONTAINER (window->notebook1), 0);
+  gtk_notebook_set_group_name (GTK_NOTEBOOK (window->notebook1), "thunar-tabs");
+  gtk_widget_show (window->notebook1);
+
+  /* notebook2 */
+  window->notebook2 = NULL;
+  window->notebook = window->notebook1;
 
   /* allocate the new location bar widget */
   window->location_bar = thunar_location_bar_new ();
@@ -1632,6 +1670,122 @@ thunar_window_binding_create (ThunarWind
 
 
 
+static gboolean
+thunar_window_pane_window (ThunarWindow *window)
+{
+  GType view_type;
+  ThunarFile *directory;
+
+  _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE);
+  _thunar_return_val_if_fail (window->view_type != G_TYPE_NONE, FALSE);
+
+  /* if two panes are showed then remove not selected one */
+  if (window->notebook1 != NULL && window->notebook2 != NULL)
+    {
+      /* notebook1 is the selected notebook so it destroys notebook2 */
+      if (window->notebook == window->notebook1)
+        {
+          gtk_widget_destroy (window->notebook2);
+          window->notebook2 = NULL;
+        }
+      /* notebook2 is the selected notebook so it destroys notebook1 */
+      else
+        {
+          gtk_widget_destroy (window->notebook1);
+          window->notebook1 = NULL;
+        }
+    }
+  /* notebook1 is null so it crates it */
+  else if (window->notebook1 == NULL)
+    {
+      /* create the notebook1 */
+      window->notebook1 = gtk_notebook_new ();
+      gtk_paned_pack1 (GTK_PANED (window->panes), window->notebook1, TRUE, FALSE);
+      g_signal_connect (G_OBJECT (window->notebook1), "switch-page", G_CALLBACK (thunar_window_notebook_switch_page), window);
+      g_signal_connect (G_OBJECT (window->notebook1), "page-added", G_CALLBACK (thunar_window_notebook_page_added), window);
+      g_signal_connect (G_OBJECT (window->notebook1), "page-removed", G_CALLBACK (thunar_window_notebook_page_removed), window);
+      g_signal_connect_after (G_OBJECT (window->notebook1), "button-press-event", G_CALLBACK (thunar_window_notebook_button_press_event), window);
+      g_signal_connect (G_OBJECT (window->notebook1), "popup-menu", G_CALLBACK (thunar_window_notebook_popup_menu), window);
+      g_signal_connect (G_OBJECT (window->notebook1), "create-window", G_CALLBACK (thunar_window_notebook_create_window), window);
+      gtk_notebook_set_show_border (GTK_NOTEBOOK (window->notebook1), FALSE);
+      //gtk_notebook_set_homogeneous_tabs (GTK_NOTEBOOK (window->notebook1), TRUE);
+      gtk_notebook_set_scrollable (GTK_NOTEBOOK (window->notebook1), TRUE);
+      gtk_container_set_border_width (GTK_CONTAINER (window->notebook1), 0);
+      gtk_notebook_set_group_name (GTK_NOTEBOOK (window->notebook1), "thunar-tabs");
+      gtk_widget_show (window->notebook1);
+
+      /* set notebook2 to selected notebook */
+      window->notebook = window->notebook1;
+      directory = thunar_window_get_current_directory (window);
+      view_type = thunar_window_view_type_for_directory (window, directory);
+
+      thunar_window_notebook_insert (window, directory, view_type, 0, NULL);
+    }
+  /* Otherwise notebook2 is null so it creates it */
+  else
+    {
+      /* create the notebook2 */
+      window->notebook2 = gtk_notebook_new ();
+      gtk_paned_pack2 (GTK_PANED (window->panes), window->notebook2, TRUE, FALSE);
+      g_signal_connect (G_OBJECT (window->notebook2), "switch-page", G_CALLBACK (thunar_window_notebook_switch_page), window);
+      g_signal_connect (G_OBJECT (window->notebook2), "page-added", G_CALLBACK (thunar_window_notebook_page_added), window);
+      g_signal_connect (G_OBJECT (window->notebook2), "page-removed", G_CALLBACK (thunar_window_notebook_page_removed), window);
+      g_signal_connect_after (G_OBJECT (window->notebook2), "button-press-event", G_CALLBACK (thunar_window_notebook_button_press_event), window);
+      g_signal_connect (G_OBJECT (window->notebook2), "popup-menu", G_CALLBACK (thunar_window_notebook_popup_menu), window);
+      g_signal_connect (G_OBJECT (window->notebook2), "create-window", G_CALLBACK (thunar_window_notebook_create_window), window);
+      gtk_notebook_set_show_border (GTK_NOTEBOOK (window->notebook2), FALSE);
+      //gtk_notebook_set_homogeneous_tabs (GTK_NOTEBOOK (window->notebook2), TRUE);
+      gtk_notebook_set_scrollable (GTK_NOTEBOOK (window->notebook2), TRUE);
+      gtk_container_set_border_width (GTK_CONTAINER (window->notebook2), 0);
+      gtk_notebook_set_group_name (GTK_NOTEBOOK (window->notebook2), "thunar-tabs");
+      gtk_widget_show (window->notebook2);
+
+      /* set notebook2 to selected notebook */
+      window->notebook = window->notebook2;
+      directory = thunar_window_get_current_directory (window);
+      view_type = thunar_window_view_type_for_directory (window, directory);
+
+      thunar_window_notebook_insert (window, directory, view_type, 0, NULL);
+    }
+
+  return TRUE;
+}
+
+
+
+static gboolean
+thunar_window_notebook_select (GtkWidget     *view, 
+			       GdkEvent      *event, 
+			       ThunarWindow  *window)
+{
+  GtkWidget  *selected_notebook;
+  gint        current_page_n;
+  GtkWidget  *current_page;
+
+  /* if there is not two panes (notebook2 == NULL) nothing to do */
+  if (window->notebook2 == NULL)
+    return FALSE;
+
+  /* notebook selected */
+  selected_notebook = gtk_widget_get_ancestor (view, GTK_TYPE_NOTEBOOK);
+
+  /* if the notebook selected is the same than the current notebook selected nothing to do */
+  if (selected_notebook == window->notebook)
+    return FALSE;
+
+  /* select and activate selected notebook */
+  window->notebook = selected_notebook;
+  current_page_n = gtk_notebook_get_current_page (GTK_NOTEBOOK (window->notebook));
+  current_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), current_page_n);
+  //thunar_component_set_ui_manager (THUNAR_COMPONENT (window->view), NULL);
+  window->view = NULL;
+  thunar_window_notebook_switch_page (window->notebook, current_page, current_page_n, window);
+
+  return FALSE;
+}
+
+
+
 static void
 thunar_window_notebook_switch_page (GtkWidget    *notebook,
                                     GtkWidget    *page,
@@ -1645,7 +1799,8 @@ thunar_window_notebook_switch_page (GtkW
   _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
   _thunar_return_if_fail (GTK_IS_NOTEBOOK (notebook));
   _thunar_return_if_fail (THUNAR_IS_VIEW (page));
-  _thunar_return_if_fail (window->notebook == notebook);
+  _thunar_return_if_fail (window->notebook1 == notebook ||
+                          window->notebook2 == notebook);
 
   /* leave if nothing changed */
   if (window->view == page)
@@ -1812,7 +1967,7 @@ thunar_window_notebook_page_removed (Gtk
   g_signal_handlers_disconnect_matched (page, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, window);
 
   n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
-  if (n_pages == 0)
+  if (n_pages == 0 && window->notebook2 == NULL)
     {
       /* destroy the window */
       gtk_widget_destroy (GTK_WIDGET (window));
@@ -2033,6 +2188,11 @@ thunar_window_notebook_insert (ThunarWin
   gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (window->notebook), view, TRUE);
   gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (window->notebook), view, TRUE);
 
+  /* connect signal view */
+  gtk_widget_add_events (GTK_WIDGET (view), GDK_BUTTON_PRESS_MASK);
+  g_signal_connect (G_OBJECT (gtk_bin_get_child (GTK_BIN (view))), "button-press-event", G_CALLBACK (thunar_window_notebook_select), window);
+  g_signal_connect (G_OBJECT (gtk_bin_get_child (GTK_BIN (view))), "button-release-event", G_CALLBACK (thunar_window_notebook_select), window);
+
   return view;
 }
 
diff -rudp thunar-4.16.10.orig/thunar/thunar-window.h thunar-4.16.10/thunar/thunar-window.h
--- thunar-4.16.10.orig/thunar/thunar-window.h	2021-10-16 13:53:35.000000000 -0400
+++ thunar-4.16.10/thunar/thunar-window.h	2021-10-16 14:55:34.000000000 -0400
@@ -74,6 +74,7 @@ typedef enum
   THUNAR_WINDOW_ACTION_VIEW_AS_ICONS,
   THUNAR_WINDOW_ACTION_VIEW_AS_DETAILED_LIST,
   THUNAR_WINDOW_ACTION_VIEW_AS_COMPACT_LIST,
+  THUNAR_WINDOW_ACTION_PANE_WINDOW,
   THUNAR_WINDOW_ACTION_GO_MENU,
   THUNAR_WINDOW_ACTION_OPEN_PARENT,
   THUNAR_WINDOW_ACTION_BACK,