Skip to content

Commit 62ee32b

Browse files
committed
toolbar: Disable the 'create-folder' button in non-writable
locations.
1 parent d1807d4 commit 62ee32b

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

src/nemo-window-manage-views.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,7 @@ update_for_new_location (NemoWindowSlot *slot)
14951495
nemo_window_sync_bookmark_action (window);
14961496
nemo_window_sync_view_type (window);
14971497
nemo_window_sync_thumbnail_action(window);
1498+
nemo_window_sync_create_folder_button (window);
14981499

14991500
/* Load menus from nemo extensions for this location */
15001501
nemo_window_load_extension_menus (window);

src/nemo-window-menus.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,20 @@ menu_set_show_thumbnails_action (gboolean value, NemoWindow *window)
11391139
NULL);
11401140
}
11411141

1142+
void
1143+
toolbar_set_create_folder_button (gboolean value, NemoWindowPane *pane)
1144+
{
1145+
GtkActionGroup *action_group;
1146+
GtkAction *action;
1147+
1148+
action_group = nemo_window_pane_get_toolbar_action_group (pane);
1149+
1150+
action = gtk_action_group_get_action(action_group,
1151+
NEMO_ACTION_NEW_FOLDER);
1152+
1153+
gtk_action_set_sensitive (action, value);
1154+
}
1155+
11421156
void
11431157
menu_set_view_selection (guint action_id,
11441158
NemoWindow *window)

src/nemo-window-menus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ guint action_for_view_id (const char *view_id
3333
void toolbar_set_view_button (guint action_id, NemoWindowPane *pane);
3434
void toolbar_set_show_thumbnails_button (gboolean value, NemoWindowPane *pane);
3535
void menu_set_show_thumbnails_action (gboolean value, NemoWindow *window);
36+
void toolbar_set_create_folder_button (gboolean value, NemoWindowPane *pane);
3637
void menu_set_view_selection (guint action_id,
3738
NemoWindow *window);
3839
#endif /* NEMO_WINDOW_PANE_H */

src/nemo-window.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,21 @@ nemo_window_sync_thumbnail_action (NemoWindow *window)
15201520
slot);
15211521
}
15221522

1523+
void
1524+
nemo_window_sync_create_folder_button (NemoWindow *window)
1525+
{
1526+
NemoWindowSlot *slot;
1527+
gboolean allow;
1528+
1529+
slot = nemo_window_get_active_slot (window);
1530+
1531+
allow = nemo_file_can_write (slot->viewed_file) &&
1532+
!nemo_file_is_in_favorites (slot->viewed_file) &&
1533+
!nemo_file_is_in_trash (slot->viewed_file);
1534+
1535+
toolbar_set_create_folder_button (allow, slot->pane);
1536+
}
1537+
15231538
static void
15241539
zoom_level_changed_callback (NemoView *view,
15251540
NemoWindow *window)

src/nemo-window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ GtkWidget * nemo_window_ensure_location_bar (NemoWindow *window);
146146
void nemo_window_sync_location_widgets (NemoWindow *window);
147147
void nemo_window_sync_search_widgets (NemoWindow *window);
148148
void nemo_window_grab_focus (NemoWindow *window);
149-
149+
void nemo_window_sync_create_folder_button (NemoWindow *window);
150150
void nemo_window_hide_sidebar (NemoWindow *window);
151151
void nemo_window_show_sidebar (NemoWindow *window);
152152
void nemo_window_back_or_forward (NemoWindow *window,

0 commit comments

Comments
 (0)