Commit c16f4f34 authored by Jesse van den Kieboom's avatar Jesse van den Kieboom

Improved heuristic for determining whether to show load/save progress

parent cb235cbe
......@@ -834,7 +834,8 @@ document_loading (GeditDocument *document,
goffset total_size,
GeditTab *tab)
{
double et;
gdouble et;
gdouble total_time;
g_return_if_fail ((tab->priv->state == GEDIT_TAB_STATE_LOADING) ||
(tab->priv->state == GEDIT_TAB_STATE_REVERTING));
......@@ -849,39 +850,15 @@ document_loading (GeditDocument *document,
et = g_timer_elapsed (tab->priv->timer, NULL);
if (tab->priv->times_called == 1)
/* et : total_time = size : total_size */
total_time = (et * total_size) / size;
if ((total_time - et) > 3.0)
{
if ((total_size == 0) || (total_size > 51200UL) /* 50 KB */)
{
show_loading_message_area (tab);
}
show_loading_message_area (tab);
}
else
{
if ((tab->priv->times_called == 3) && (total_size != 0))
{
gdouble total_time;
/* et : total_time = size : total_size */
total_time = (et * total_size)/size;
if ((total_time - et) > 3.0)
{
show_loading_message_area (tab);
}
}
else
{
if (et > 3.0)
{
show_loading_message_area (tab);
}
}
}
message_area_set_progress (tab, size, total_size);
tab->priv->times_called++;
}
static gboolean
......@@ -1102,7 +1079,8 @@ document_saving (GeditDocument *document,
goffset total_size,
GeditTab *tab)
{
double et;
gdouble et;
gdouble total_time;
g_return_if_fail (tab->priv->state == GEDIT_TAB_STATE_SAVING);
......@@ -1117,36 +1095,14 @@ document_saving (GeditDocument *document,
et = g_timer_elapsed (tab->priv->timer, NULL);
if (tab->priv->times_called == 1)
/* et : total_time = size : total_size */
total_time = (et * total_size)/size;
if ((total_time - et) > 3.0)
{
if ((total_size == 0) || (total_size > 51200UL) /* 50 KB */)
{
show_saving_message_area (tab);
}
show_saving_message_area (tab);
}
else
{
if ((tab->priv->times_called == 3) && (total_size != 0))
{
gdouble total_time;
/* et : total_time = size : total_size */
total_time = (et * total_size)/size;
if ((total_time - et) > 3.0)
{
show_saving_message_area (tab);
}
}
else
{
if (et > 3.0)
{
show_saving_message_area (tab);
}
}
}
message_area_set_progress (tab, size, total_size);
tab->priv->times_called++;
......
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