Commit ad8dd838 authored by Cosimo Cecchi's avatar Cosimo Cecchi

window-slot: let the "Loading" floating bar appear only after a timeout

It will appear only if loading takes more than 500ms.
parent 27574464
......@@ -1163,14 +1163,8 @@ nautilus_window_report_location_change (NautilusWindow *window)
}
static void
setup_loading_floating_bar (NautilusWindowSlot *slot)
real_setup_loading_floating_bar (NautilusWindowSlot *slot)
{
/* setup loading overlay */
if (slot->set_status_timeout_id != 0) {
g_source_remove (slot->set_status_timeout_id);
slot->set_status_timeout_id = 0;
}
nautilus_floating_bar_set_label (NAUTILUS_FLOATING_BAR (slot->floating_bar),
NAUTILUS_IS_SEARCH_DIRECTORY (nautilus_view_get_model (slot->content_view)) ?
_("Searching...") : _("Loading..."));
......@@ -1182,6 +1176,35 @@ setup_loading_floating_bar (NautilusWindowSlot *slot)
gtk_widget_show (slot->floating_bar);
}
static gboolean
setup_loading_floating_bar_timeout_cb (gpointer user_data)
{
NautilusWindowSlot *slot = user_data;
slot->loading_timeout_id = 0;
real_setup_loading_floating_bar (slot);
return FALSE;
}
static void
setup_loading_floating_bar (NautilusWindowSlot *slot)
{
/* setup loading overlay */
if (slot->set_status_timeout_id != 0) {
g_source_remove (slot->set_status_timeout_id);
slot->set_status_timeout_id = 0;
}
if (slot->loading_timeout_id != 0) {
g_source_remove (slot->loading_timeout_id);
slot->loading_timeout_id = 0;
}
slot->loading_timeout_id =
g_timeout_add (500, setup_loading_floating_bar_timeout_cb, slot);
}
/* This is called when we have decided we can actually change to the new view/location situation. */
static void
location_has_really_changed (NautilusWindowSlot *slot)
......@@ -1489,6 +1512,11 @@ nautilus_window_report_load_complete (NautilusWindow *window,
static void
remove_loading_floating_bar (NautilusWindowSlot *slot)
{
if (slot->loading_timeout_id != 0) {
g_source_remove (slot->loading_timeout_id);
slot->loading_timeout_id = 0;
}
gtk_widget_hide (slot->floating_bar);
nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (slot->floating_bar));
}
......
......@@ -242,6 +242,11 @@ nautilus_window_slot_dispose (GObject *object)
slot->set_status_timeout_id = 0;
}
if (slot->loading_timeout_id != 0) {
g_source_remove (slot->loading_timeout_id);
slot->loading_timeout_id = 0;
}
nautilus_window_slot_set_viewed_file (slot, NULL);
/* TODO? why do we unref here? the file is NULL.
* It was already here before the slot move, though */
......
......@@ -79,6 +79,7 @@ struct NautilusWindowSlot {
GtkWidget *floating_bar;
guint set_status_timeout_id;
guint loading_timeout_id;
NautilusView *content_view;
NautilusView *new_content_view;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment