Skip to content

Commit f5124bc

Browse files
committed
nemo-window-menus.c: Update extension and action entries in
the File menu when it is shown. In 5a271cd action and extension menu items stopped getting updated when the selection changed, instead updating only just prior to showing the popup menu. This implements the same behavior for the menubar. Fixes #2758
1 parent 42187d1 commit f5124bc

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

src/nemo-view.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10038,8 +10038,8 @@ real_update_menus (NemoView *view)
1003810038
nemo_file_list_free (selection);
1003910039
}
1004010040

10041-
static void
10042-
update_actions_and_extensions(NemoView *view)
10041+
void
10042+
nemo_view_update_actions_and_extensions (NemoView *view)
1004310043
{
1004410044
GList *selection;
1004510045

@@ -10076,7 +10076,7 @@ nemo_view_pop_up_selection_context_menu (NemoView *view,
1007610076
/* Make the context menu items not flash as they update to proper disabled,
1007710077
* etc. states by forcing menus to update now.
1007810078
*/
10079-
update_actions_and_extensions (view);
10079+
nemo_view_update_actions_and_extensions (view);
1008010080
update_context_menu_position_from_event (view, event);
1008110081

1008210082
eel_pop_up_context_menu (create_popup_menu
@@ -10102,7 +10102,7 @@ nemo_view_pop_up_background_context_menu (NemoView *view,
1010210102
/* Make the context menu items not flash as they update to proper disabled,
1010310103
* etc. states by forcing menus to update now.
1010410104
*/
10105-
update_actions_and_extensions (view);
10105+
nemo_view_update_actions_and_extensions (view);
1010610106
update_context_menu_position_from_event (view, event);
1010710107

1010810108
eel_pop_up_context_menu (create_popup_menu

src/nemo-view.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ void nemo_view_notify_selection_changed (NemoView *view)
355355
GtkUIManager * nemo_view_get_ui_manager (NemoView *view);
356356
NemoDirectory *nemo_view_get_model (NemoView *view);
357357
NemoFile *nemo_view_get_directory_as_file (NemoView *view);
358+
void nemo_view_update_actions_and_extensions (NemoView *view);
359+
358360
void nemo_view_pop_up_background_context_menu (NemoView *view,
359361
GdkEventButton *event);
360362
void nemo_view_pop_up_selection_context_menu (NemoView *view,

src/nemo-window-menus.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969

7070
#define MENU_PATH_EXTENSION_ACTIONS "/MenuBar/File/Extension Actions"
7171
#define POPUP_PATH_EXTENSION_ACTIONS "/background/Before Zoom Items/Extension Actions"
72+
#define MENU_BAR_PATH "/MenuBar"
7273

7374
#define NETWORK_URI "network:"
7475
#define COMPUTER_URI "computer:"
@@ -1273,8 +1274,26 @@ action_open_terminal_callback(GtkAction *action, gpointer callback_data)
12731274
g_object_unref (gfile);
12741275
}
12751276

1277+
static void
1278+
file_menu_bar_item_activated (GtkAction *action, gpointer user_data)
1279+
{
1280+
NemoWindow *window;
1281+
NemoView *view;
1282+
1283+
window = NEMO_WINDOW (user_data);
1284+
1285+
if (window->details->dynamic_menu_entries_current) {
1286+
return;
1287+
}
1288+
1289+
view = get_current_view (window);
1290+
nemo_view_update_actions_and_extensions (view);
1291+
1292+
window->details->dynamic_menu_entries_current = TRUE;
1293+
}
1294+
12761295
static const GtkActionEntry main_entries[] = {
1277-
/* name, stock id, label */ { "File", NULL, N_("_File") },
1296+
/* name, stock id, label */ { "File", NULL, N_("_File"), NULL, NULL, G_CALLBACK (file_menu_bar_item_activated) },
12781297
/* name, stock id, label */ { "Edit", NULL, N_("_Edit") },
12791298
/* name, stock id, label */ { "View", NULL, N_("_View") },
12801299
/* name, stock id, label */ { "Help", NULL, N_("_Help") },
@@ -1763,6 +1782,16 @@ nemo_window_initialize_actions (NemoWindow *window)
17631782
NULL);
17641783
}
17651784

1785+
static void
1786+
menu_bar_deactivated (GtkMenuShell *menu, gpointer user_data)
1787+
{
1788+
NemoWindow *window;
1789+
1790+
window = NEMO_WINDOW (user_data);
1791+
1792+
window->details->dynamic_menu_entries_current = FALSE;
1793+
}
1794+
17661795
/**
17671796
* nemo_window_initialize_menus
17681797
*
@@ -1774,6 +1803,7 @@ nemo_window_initialize_menus (NemoWindow *window)
17741803
{
17751804
GtkActionGroup *action_group;
17761805
GtkUIManager *ui_manager;
1806+
GtkWidget *menubar;
17771807
GtkAction *action;
17781808
GtkAction *action_to_hide;
17791809
gint i;
@@ -1877,6 +1907,14 @@ nemo_window_initialize_menus (NemoWindow *window)
18771907
/* add the UI */
18781908
gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/nemo/nemo-shell-ui.xml", NULL);
18791909

1910+
// window->details->menubar isn't set yet
1911+
menubar = gtk_ui_manager_get_widget (window->details->ui_manager, "/MenuBar");
1912+
1913+
g_signal_connect (menubar,
1914+
"deactivate",
1915+
G_CALLBACK (menu_bar_deactivated),
1916+
window);
1917+
18801918
nemo_window_initialize_trash_icon_monitor (window);
18811919
}
18821920

src/nemo-window-private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ struct NemoWindowDetails
110110
GList *ignore_meta_column_order;
111111
gchar *ignore_meta_sort_column;
112112
gint ignore_meta_sort_direction;
113+
114+
gboolean dynamic_menu_entries_current;
113115
};
114116

115117
/* window geometry */

0 commit comments

Comments
 (0)