summarylogtreecommitdiffstats
path: root/thunar.patch
blob: a6efbca6a996f349d701702b4a9a36692babbc1c (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
diff --git a/thunar/thunar-toolbar-editor.c b/thunar/thunar-toolbar-editor.c
index 0fb3f607..8a70bb71 100644
--- a/thunar/thunar-toolbar-editor.c
+++ b/thunar/thunar-toolbar-editor.c
@@ -267,10 +267,6 @@ thunar_toolbar_editor_visible_func (GtkTreeModel *model,
 
   gtk_tree_model_get (model, iter, 3, &order, -1);
 
-   /* The item with order 0 is always THUNAR_WINDOW_ACTION_VIEW_MENUBAR which we want to hide */
-  if (order == 0)
-    visible = FALSE;
-
   return visible;
 }
 
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 26345602..db4c7a49 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -83,7 +83,6 @@ enum
   BACK,
   RELOAD,
   TOGGLE_SIDEPANE,
-  TOGGLE_MENUBAR,
   ZOOM_IN,
   ZOOM_OUT,
   ZOOM_RESET,
@@ -214,7 +213,6 @@ static gboolean  thunar_window_action_shortcuts_changed   (ThunarWindow
 static gboolean  thunar_window_action_tree_changed        (ThunarWindow           *window);
 static gboolean  thunar_window_action_image_preview       (ThunarWindow           *window);
 static gboolean  thunar_window_action_statusbar_changed   (ThunarWindow           *window);
-static void      thunar_window_action_menubar_update      (ThunarWindow           *window);
 static gboolean  thunar_window_action_menubar_changed     (ThunarWindow           *window);
 static gboolean  thunar_window_action_detailed_view       (ThunarWindow           *window);
 static gboolean  thunar_window_action_icon_view           (ThunarWindow           *window);
@@ -395,9 +393,9 @@ struct _ThunarWindow
   /* to be able to change folder on "device-pre-unmount" if required */
   ThunarDeviceMonitor       *device_monitor;
 
+  GtkWidget                 *header_bar;
   GtkWidget                 *grid;
   GtkWidget                 *menubar;
-  gboolean                   menubar_visible;
   GtkWidget                *spinner;
   GtkWidget                 *paned;
   GtkWidget                 *paned_right;
@@ -450,7 +448,8 @@ struct _ThunarWindow
   GtkWidget                 *location_toolbar_item_zoom_out;
   GtkWidget                 *location_toolbar_item_search;
   GtkWidget                 *location_toolbar_item_view_menubar;
-
+  GtkWidget                 *location_toolbar_item_spinner;
+  
   ThunarActionManager       *action_mgr;
 
   gulong                     signal_handler_id_history_changed;
@@ -512,7 +511,10 @@ static XfceGtkActionEntry thunar_window_action_entries[] =
     { THUNAR_WINDOW_ACTION_TOGGLE_SIDE_PANE,               "<Actions>/ThunarWindow/toggle-side-pane",                "F9",                   XFCE_GTK_MENU_ITEM,       NULL,                          NULL,                                                                                NULL,                      G_CALLBACK (thunar_window_toggle_sidepane),           },
     { THUNAR_WINDOW_ACTION_TOGGLE_IMAGE_PREVIEW,           "<Actions>/ThunarWindow/toggle-image-preview",            "",                     XFCE_GTK_CHECK_MENU_ITEM, N_ ("Image Preview"),          N_ ("Change the visibility of this window's image preview"),                         NULL,                      G_CALLBACK (thunar_window_action_image_preview),  },
     { THUNAR_WINDOW_ACTION_VIEW_STATUSBAR,                 "<Actions>/ThunarWindow/view-statusbar",                  "",                     XFCE_GTK_CHECK_MENU_ITEM, N_ ("St_atusbar"),             N_ ("Change the visibility of this window's statusbar"),                             NULL,                      G_CALLBACK (thunar_window_action_statusbar_changed),  },
-    { THUNAR_WINDOW_ACTION_VIEW_MENUBAR,                   "<Actions>/ThunarWindow/view-menubar",                    "<Primary>m",           XFCE_GTK_CHECK_MENU_ITEM, N_ ("_Menubar"),               N_ ("Change the visibility of this window's menubar"),                               "open-menu-symbolic",      G_CALLBACK (thunar_window_action_menubar_changed),    },
+
+    { THUNAR_WINDOW_ACTION_VIEW_MENUBAR,                   "<Actions>/ThunarWindow/view-menubar",                    "",                     XFCE_GTK_CHECK_MENU_ITEM, N_ ("_Menubar"),               NULL,                                                                                "open-menu",               G_CALLBACK (thunar_window_action_menubar_changed),    },
+    { THUNAR_WINDOW_ACTION_SPINNER,                        "<Actions>/ThunarWindow/spinner",                         "",                     0,                        N_ ("_Spinner"),               NULL,                                                                                NULL,                      NULL,      },
+
     { THUNAR_WINDOW_ACTION_CONFIGURE_TOOLBAR,              "<Actions>/ThunarWindow/view-configure-toolbar",          "",                     XFCE_GTK_MENU_ITEM ,      N_ ("Configure _Toolbar..."),  N_ ("Configure the toolbar"),                                                        NULL,                      G_CALLBACK (thunar_window_action_show_toolbar_editor),},
     { THUNAR_WINDOW_ACTION_CLEAR_DIRECTORY_SPECIFIC_SETTINGS,"<Actions>/ThunarWindow/clear-directory-specific-settings","",                  XFCE_GTK_IMAGE_MENU_ITEM, N_ ("Clear Saved _Folder View Settings"), N_ ("Delete saved view settings for this folder"),                        NULL,                      G_CALLBACK (thunar_window_action_clear_directory_specific_settings), },
     { THUNAR_WINDOW_ACTION_SHOW_HIDDEN,                    "<Actions>/ThunarWindow/show-hidden",                     "<Primary>h",           XFCE_GTK_CHECK_MENU_ITEM, N_ ("Show _Hidden Files"),     N_ ("Toggles the display of hidden files in the current window"),                    NULL,                      G_CALLBACK (thunar_window_action_show_hidden),        },
@@ -757,9 +759,7 @@ thunar_window_init (ThunarWindow *window)
 {
   GtkWidget             *label;
   GtkWidget             *infobar;
-  GtkWidget             *item;
   GtkWidget             *event_box;
-  gboolean               last_menubar_visible;
   gchar                 *last_location_bar;
   gchar                 *last_side_pane;
   gchar                 *uca_path;
@@ -803,7 +803,6 @@ thunar_window_init (ThunarWindow *window)
                 "last-window-width", &last_window_width,
                 "last-window-height", &last_window_height,
                 "last-window-maximized", &last_window_maximized,
-                "last-menubar-visible", &last_menubar_visible,
                 "last-separator-position", &last_separator_position,
                 "last-location-bar", &last_location_bar,
                 "last-side-pane", &last_side_pane,
@@ -842,7 +841,7 @@ thunar_window_init (ThunarWindow *window)
 
   /* determine the default window size from the preferences */
   gtk_window_set_default_size (GTK_WINDOW (window), last_window_width, last_window_height);
-
+  gtk_window_set_titlebar (GTK_WINDOW (window), window->header_bar);
   /* restore the maxized state of the window */
   if (G_UNLIKELY (last_window_maximized))
     gtk_window_maximize (GTK_WINDOW (window));
@@ -856,34 +855,19 @@ thunar_window_init (ThunarWindow *window)
   gtk_widget_show (window->grid);
 
   /* build the menubar */
-  window->menubar = gtk_menu_bar_new ();
+  window->menubar = gtk_menu_new ();
   thunar_window_create_menu (window, THUNAR_WINDOW_ACTION_FILE_MENU, G_CALLBACK (thunar_window_update_file_menu));
   thunar_window_create_menu (window, THUNAR_WINDOW_ACTION_EDIT_MENU, G_CALLBACK (thunar_window_update_edit_menu));
   thunar_window_create_menu (window, THUNAR_WINDOW_ACTION_VIEW_MENU, G_CALLBACK (thunar_window_update_view_menu));
   thunar_window_create_menu (window, THUNAR_WINDOW_ACTION_GO_MENU, G_CALLBACK (thunar_window_update_go_menu));
   thunar_window_create_menu (window, THUNAR_WINDOW_ACTION_BOOKMARKS_MENU, G_CALLBACK (thunar_window_update_bookmarks_menu));
   thunar_window_create_menu (window, THUNAR_WINDOW_ACTION_HELP_MENU, G_CALLBACK (thunar_window_update_help_menu));
-  gtk_widget_show_all (window->menubar);
-
-  window->menubar_visible = last_menubar_visible;
-  if (last_menubar_visible == FALSE)
-    gtk_widget_hide (window->menubar);
-  gtk_widget_set_hexpand (window->menubar, TRUE);
-  gtk_grid_attach (GTK_GRID (window->grid), window->menubar, 0, 0, 1, 1);
-
-  /* append the menu item for the spinner */
-  item = gtk_menu_item_new ();
-  gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
-  g_object_set (G_OBJECT (item), "right-justified", TRUE, NULL);
-  gtk_menu_shell_append (GTK_MENU_SHELL (window->menubar), item);
-  gtk_widget_show (item);
 
-  /* Required if F10 is pushed while the menu is hidden */
-  g_signal_connect_swapped (G_OBJECT (window->menubar), "deactivate", G_CALLBACK (thunar_window_action_menubar_update), window);
+  gtk_widget_set_vexpand (window->menubar, TRUE);
+  gtk_widget_show_all (window->menubar);
 
   /* place the spinner into the menu item */
   window->spinner = gtk_spinner_new ();
-  gtk_container_add (GTK_CONTAINER (item), window->spinner);
   gtk_widget_set_visible (GTK_WIDGET (window->spinner), TRUE);
 
   /* check if we need to add the root warning */
@@ -998,6 +982,11 @@ thunar_window_init (ThunarWindow *window)
   /* get a reference of the global job operation history */
   window->job_operation_history = thunar_job_operation_history_get_default ();
 
+  window->header_bar = gtk_header_bar_new ();
+  gtk_window_set_titlebar (GTK_WINDOW(window), window->header_bar);
+  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (window->header_bar),TRUE);
+  gtk_widget_show (window->header_bar);
+  
   window->location_toolbar = NULL;
   thunar_window_location_toolbar_create (window);
 
@@ -1403,8 +1392,7 @@ thunar_window_update_view_menu (ThunarWindow *window,
   gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (sub_items));
   xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_STATUSBAR), G_OBJECT (window),
                                                    gtk_widget_get_visible (window->statusbar), GTK_MENU_SHELL (menu));
-  xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_VIEW_MENUBAR), G_OBJECT (window),
-                                                   window->menubar_visible, GTK_MENU_SHELL (menu));
+
   xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_WINDOW_ACTION_CONFIGURE_TOOLBAR), G_OBJECT (window), GTK_MENU_SHELL (menu));
   xfce_gtk_menu_append_separator (GTK_MENU_SHELL (menu));
   if (window->directory_specific_settings)
@@ -3881,35 +3869,22 @@ thunar_window_action_statusbar_changed (ThunarWindow *window)
 
 
 
-static void
-thunar_window_action_menubar_update (ThunarWindow *window)
-{
-  _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
-
-  gtk_widget_set_visible (window->menubar, window->menubar_visible);
-}
-
-
-
 static gboolean
 thunar_window_action_menubar_changed (ThunarWindow *window)
 {
   _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE);
 
-  /* Dont rely on 'gtk_widget_set_visible', it will be wrong when the menubar is accessed via F10  */
-  window->menubar_visible = !window->menubar_visible;
+  GtkWidget *button = gtk_menu_get_attach_widget(GTK_MENU(window->menubar));
 
-  gtk_widget_set_visible (window->menubar, window->menubar_visible);
-  gtk_widget_set_visible (window->location_toolbar_item_view_menubar, !window->menubar_visible);
-
-  g_object_set (G_OBJECT (window->preferences), "last-menubar-visible", window->menubar_visible, NULL);
+  if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON(button)))
+  {
+    gtk_menu_popup_at_widget (GTK_MENU (window->menubar), button, GDK_GRAVITY_SOUTH, GDK_GRAVITY_NORTH,NULL);
+  }
 
   /* required in case of shortcut activation, in order to signal that the accel key got handled */
   return TRUE;
 }
 
-
-
 static gboolean
 thunar_window_action_show_toolbar_editor (ThunarWindow *window)
 {
@@ -6109,7 +6084,8 @@ thunar_window_location_toolbar_create (ThunarWindow *window)
   gtk_widget_set_hexpand (window->location_toolbar, TRUE);
 
   /* The first toolbar item must always be THUNAR_WINDOW_ACTION_VIEW_MENUBAR which we hide by default */
-  window->location_toolbar_item_view_menubar = thunar_window_create_toolbar_item_from_action (window, THUNAR_WINDOW_ACTION_VIEW_MENUBAR, item_order++);
+  window->location_toolbar_item_view_menubar = thunar_window_create_toolbar_toggle_item_from_action (window, THUNAR_WINDOW_ACTION_VIEW_MENUBAR,FALSE, item_order++);
+  window->location_toolbar_item_spinner      = thunar_window_create_toolbar_item_from_action (window, THUNAR_WINDOW_ACTION_SPINNER, item_order++);
   window->location_toolbar_item_back         = thunar_window_create_toolbar_item_from_action (window, THUNAR_WINDOW_ACTION_BACK, item_order++);
   window->location_toolbar_item_forward      = thunar_window_create_toolbar_item_from_action (window, THUNAR_WINDOW_ACTION_FORWARD, item_order++);
   window->location_toolbar_item_parent       = thunar_window_create_toolbar_item_from_action (window, THUNAR_WINDOW_ACTION_OPEN_PARENT, item_order++);
@@ -6124,6 +6100,14 @@ thunar_window_location_toolbar_create (ThunarWindow *window)
                                                thunar_window_create_toolbar_item_from_action (window, THUNAR_WINDOW_ACTION_VIEW_AS_COMPACT_LIST, item_order++);
                                                thunar_window_create_toolbar_toggle_item_from_action (window, THUNAR_WINDOW_ACTION_VIEW_SPLIT, thunar_window_split_view_is_active (window), item_order++);
 
+  gtk_menu_attach_to_widget (GTK_MENU (window->menubar),window->location_toolbar_item_view_menubar,NULL);
+  g_object_bind_property (window->menubar,"visible", window->location_toolbar_item_view_menubar,"active", G_BINDING_SYNC_CREATE);
+
+  gtk_tool_button_set_icon_widget (window->location_toolbar_item_spinner,window->spinner);
+  g_object_bind_property (window->spinner,"active", window->location_toolbar_item_spinner,"visible", G_BINDING_SYNC_CREATE);
+
+  gtk_widget_set_sensitive (window->location_toolbar_item_spinner, FALSE);
+
   g_signal_connect (G_OBJECT (window->location_toolbar_item_back), "button-press-event", G_CALLBACK (thunar_window_history_clicked), G_OBJECT (window));
   g_signal_connect (G_OBJECT (window->location_toolbar_item_forward), "button-press-event", G_CALLBACK (thunar_window_history_clicked), G_OBJECT (window));
   g_signal_connect (G_OBJECT (window->location_toolbar_item_parent), "button-press-event", G_CALLBACK (thunar_window_open_parent_clicked), G_OBJECT (window));
@@ -6155,9 +6139,6 @@ thunar_window_location_toolbar_create (ThunarWindow *window)
   /* display the toolbar */
   gtk_widget_show_all (window->location_toolbar);
 
-  /* view_menubar is only visible when the menu is hidden */
-  gtk_widget_set_visible (window->location_toolbar_item_view_menubar, !window->menubar_visible);
-
   /* add the location bar itself after gtk_widget_show_all to not mess with the visibility of the location buttons */
   gtk_container_add (GTK_CONTAINER (tool_item), window->location_bar);
 
@@ -6168,7 +6149,8 @@ thunar_window_location_toolbar_create (ThunarWindow *window)
   thunar_window_location_toolbar_load_visibility (window);
 
   /* attach the toolbar to the window */
-  gtk_grid_attach (GTK_GRID (window->grid), window->location_toolbar, 0, 1, 1, 1);
+  gtk_header_bar_set_custom_title (GTK_HEADER_BAR (window->header_bar), window->location_toolbar);
+  //gtk_grid_attach (GTK_GRID (window->grid), window->location_toolbar, 0, 1, 1, 1);
 }
 
 
@@ -6427,10 +6409,6 @@ thunar_window_toolbar_toggle_item_visibility (ThunarWindow *window,
     {
       GtkWidget *item = lp->data;
 
-      /* visibility of this item is only controlled by 'window->menubar_visible' */
-      if (item == window->location_toolbar_item_view_menubar)
-        continue;
-
       if (index == i)
         {
           gtk_widget_set_visible (item, !gtk_widget_is_visible (item));
diff --git a/thunar/thunar-window.h b/thunar/thunar-window.h
index efb98db2..e724bec8 100644
--- a/thunar/thunar-window.h
+++ b/thunar/thunar-window.h
@@ -65,7 +65,9 @@ typedef enum
   THUNAR_WINDOW_ACTION_TOGGLE_SIDE_PANE,
   THUNAR_WINDOW_ACTION_TOGGLE_IMAGE_PREVIEW,
   THUNAR_WINDOW_ACTION_VIEW_STATUSBAR,
+
   THUNAR_WINDOW_ACTION_VIEW_MENUBAR,
+  THUNAR_WINDOW_ACTION_SPINNER,
   THUNAR_WINDOW_ACTION_CONFIGURE_TOOLBAR,
   THUNAR_WINDOW_ACTION_SHOW_HIDDEN,
   THUNAR_WINDOW_ACTION_ZOOM_IN,