Skip to content

Commit

Permalink
nemo-window: Restore initial syncing of view buttons. This was inadve…
Browse files Browse the repository at this point in the history
…rtantly

removed in d237626 while getting rid of some actual unused code related
to an old way view types used to be selected.

Fixes #1649
  • Loading branch information
mtwebster committed Nov 19, 2017
1 parent b5c12f9 commit 014664b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/nemo-window-manage-views.c
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,8 @@ update_for_new_location (NemoWindowSlot *slot)
nemo_window_sync_up_button (window);
nemo_window_sync_zoom_widgets (window);

nemo_window_sync_view_type (window);

/* Load menus from nemo extensions for this location */
nemo_window_load_extension_menus (window);
}
Expand Down
1 change: 1 addition & 0 deletions src/nemo-window-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ struct NemoWindowDetails
typedef void (*NemoBookmarkFailedCallback) (NemoWindow *window,
NemoBookmark *bookmark);

void nemo_window_sync_view_type (NemoWindow *window);
void nemo_window_load_extension_menus (NemoWindow *window);
NemoWindowPane *nemo_window_get_next_pane (NemoWindow *window);
void nemo_menus_append_bookmark_to_menu (NemoWindow *window,
Expand Down
1 change: 1 addition & 0 deletions src/nemo-window-slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ real_active (NemoWindowSlot *slot)
nemo_window_pane_sync_search_widgets (slot->pane);

if (slot->viewed_file != NULL) {
nemo_window_sync_view_type (window);
nemo_window_load_extension_menus (window);
}
}
Expand Down
64 changes: 59 additions & 5 deletions src/nemo-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };

typedef struct {
NemoWindow *window;
char *id;
} ActivateViewData;

G_DEFINE_TYPE (NemoWindow, nemo_window, GTK_TYPE_APPLICATION_WINDOW);

static const struct {
Expand Down Expand Up @@ -1140,6 +1135,58 @@ nemo_window_key_release_event (GtkWidget *widget,
* Main API
*/

static void
sync_view_type_callback (NemoFile *file,
gpointer callback_data)
{
NemoWindow *window;
NemoWindowSlot *slot;

slot = callback_data;
window = nemo_window_slot_get_window (slot);

if (slot == nemo_window_get_active_slot (window)) {
NemoWindowPane *pane;
const gchar *view_id;

if (slot->content_view == NULL) {
return;
}

pane = nemo_window_get_active_pane(window);
view_id = nemo_window_slot_get_content_view_id (slot);

toolbar_set_view_button (toolbar_action_for_view_id (view_id), pane);
}
}

static void
cancel_sync_view_type_callback (NemoWindowSlot *slot)
{
nemo_file_cancel_call_when_ready (slot->viewed_file,
sync_view_type_callback,
slot);
}

void
nemo_window_sync_view_type (NemoWindow *window)
{
NemoWindowSlot *slot;
NemoFileAttributes attributes;

g_return_if_fail (NEMO_IS_WINDOW (window));

attributes = nemo_mime_actions_get_required_file_attributes ();

slot = nemo_window_get_active_slot (window);

cancel_sync_view_type_callback (slot);
nemo_file_call_when_ready (slot->viewed_file,
attributes,
sync_view_type_callback,
slot);
}

void
nemo_window_sync_menu_bar (NemoWindow *window)
{
Expand Down Expand Up @@ -1307,6 +1354,11 @@ nemo_window_connect_content_view (NemoWindow *window,
G_CALLBACK (zoom_level_changed_callback),
window);

/* Update displayed the selected view type in the toolbar and menu. */
if (slot->pending_location == NULL) {
nemo_window_sync_view_type (window);
}

nemo_view_grab_focus (view);
}

Expand Down Expand Up @@ -1416,6 +1468,8 @@ nemo_window_slot_set_viewed_file (NemoWindowSlot *slot,

nemo_file_ref (file);

cancel_sync_view_type_callback (slot);

if (slot->viewed_file != NULL) {
nemo_file_monitor_remove (slot->viewed_file,
slot);
Expand Down

0 comments on commit 014664b

Please sign in to comment.