Simplify update_interface and avoid extra updates
This commit is contained in:
parent
9a78cc6f6e
commit
b563479014
1 changed files with 9 additions and 23 deletions
|
@ -288,17 +288,12 @@ _midori_browser_update_actions (MidoriBrowser* browser)
|
||||||
static void
|
static void
|
||||||
_midori_browser_update_interface (MidoriBrowser* browser)
|
_midori_browser_update_interface (MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
GtkWidget* widget;
|
GtkWidget* widget = midori_browser_get_current_tab (browser);
|
||||||
MidoriView* view;
|
MidoriView* view = MIDORI_VIEW (widget);
|
||||||
gboolean loading;
|
gboolean loading = midori_view_get_load_status (view) != MIDORI_LOAD_FINISHED;
|
||||||
gboolean can_reload;
|
gboolean can_reload = midori_view_can_reload (view);
|
||||||
GtkAction* action;
|
GtkAction* action;
|
||||||
|
|
||||||
widget = midori_browser_get_current_tab (browser);
|
|
||||||
view = MIDORI_VIEW (widget);
|
|
||||||
loading = midori_view_get_load_status (view) != MIDORI_LOAD_FINISHED;
|
|
||||||
can_reload = midori_view_can_reload (view);
|
|
||||||
|
|
||||||
_action_set_sensitive (browser, "Reload", can_reload);
|
_action_set_sensitive (browser, "Reload", can_reload);
|
||||||
_action_set_sensitive (browser, "Stop", can_reload && loading);
|
_action_set_sensitive (browser, "Stop", can_reload && loading);
|
||||||
_action_set_sensitive (browser, "Back", midori_view_can_go_back (view));
|
_action_set_sensitive (browser, "Back", midori_view_can_go_back (view));
|
||||||
|
@ -333,7 +328,7 @@ _midori_browser_update_interface (MidoriBrowser* browser)
|
||||||
midori_findbar_set_can_find (MIDORI_FINDBAR (browser->find),
|
midori_findbar_set_can_find (MIDORI_FINDBAR (browser->find),
|
||||||
midori_view_can_find (view));
|
midori_view_can_find (view));
|
||||||
|
|
||||||
action = gtk_action_group_get_action (browser->action_group, "ReloadStop");
|
action = _action_by_name (browser, "ReloadStop");
|
||||||
if (!loading)
|
if (!loading)
|
||||||
{
|
{
|
||||||
g_object_set (action,
|
g_object_set (action,
|
||||||
|
@ -355,12 +350,6 @@ _midori_browser_update_interface (MidoriBrowser* browser)
|
||||||
!gtk_widget_get_visible (browser->navigationbar) &&
|
!gtk_widget_get_visible (browser->navigationbar) &&
|
||||||
browser->progress_in_location)
|
browser->progress_in_location)
|
||||||
gtk_widget_show (browser->navigationbar);
|
gtk_widget_show (browser->navigationbar);
|
||||||
if (browser->progress_in_location)
|
|
||||||
{
|
|
||||||
action = _action_by_name (browser, "Location");
|
|
||||||
midori_location_action_set_progress (MIDORI_LOCATION_ACTION (action),
|
|
||||||
midori_view_get_progress (view));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_HILDON
|
#if HAVE_HILDON
|
||||||
|
@ -387,7 +376,6 @@ _midori_browser_update_interface (MidoriBrowser* browser)
|
||||||
}
|
}
|
||||||
midori_location_action_set_security_hint (
|
midori_location_action_set_security_hint (
|
||||||
MIDORI_LOCATION_ACTION (action), midori_view_get_security (view));
|
MIDORI_LOCATION_ACTION (action), midori_view_get_security (view));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -468,15 +456,14 @@ _midori_browser_update_progress (MidoriBrowser* browser,
|
||||||
g_free (message);
|
g_free (message);
|
||||||
if (!browser->progress_in_location)
|
if (!browser->progress_in_location)
|
||||||
progress = 0.0;
|
progress = 0.0;
|
||||||
midori_location_action_set_progress (action, progress);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (browser->progressbar));
|
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (browser->progressbar));
|
||||||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
||||||
NULL);
|
NULL);
|
||||||
midori_location_action_set_progress (action, 0.0);
|
|
||||||
}
|
}
|
||||||
|
midori_location_action_set_progress (action, progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -543,18 +530,19 @@ midori_view_notify_load_status_cb (GtkWidget* widget,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
MidoriView* view = MIDORI_VIEW (widget);
|
MidoriView* view = MIDORI_VIEW (widget);
|
||||||
|
MidoriLoadStatus load_status = midori_view_get_load_status (view);
|
||||||
const gchar* uri;
|
const gchar* uri;
|
||||||
GtkAction* action;
|
GtkAction* action;
|
||||||
|
|
||||||
uri = midori_view_get_display_uri (view);
|
uri = midori_view_get_display_uri (view);
|
||||||
action = _action_by_name (browser, "Location");
|
action = _action_by_name (browser, "Location");
|
||||||
|
|
||||||
if (midori_view_get_load_status (view) == MIDORI_LOAD_COMMITTED)
|
if (load_status == MIDORI_LOAD_COMMITTED)
|
||||||
midori_location_action_add_uri (MIDORI_LOCATION_ACTION (action), uri);
|
midori_location_action_add_uri (MIDORI_LOCATION_ACTION (action), uri);
|
||||||
|
|
||||||
if (widget == midori_browser_get_current_tab (browser))
|
if (widget == midori_browser_get_current_tab (browser))
|
||||||
{
|
{
|
||||||
if (midori_view_get_load_status (view) == MIDORI_LOAD_COMMITTED)
|
if (load_status == MIDORI_LOAD_COMMITTED)
|
||||||
{
|
{
|
||||||
midori_location_action_set_text (
|
midori_location_action_set_text (
|
||||||
MIDORI_LOCATION_ACTION (action), uri);
|
MIDORI_LOCATION_ACTION (action), uri);
|
||||||
|
@ -613,12 +601,10 @@ midori_view_notify_title_cb (GtkWidget* widget,
|
||||||
MidoriView* view = MIDORI_VIEW (widget);
|
MidoriView* view = MIDORI_VIEW (widget);
|
||||||
const gchar* uri;
|
const gchar* uri;
|
||||||
const gchar* title;
|
const gchar* title;
|
||||||
GtkAction* action;
|
|
||||||
gchar* window_title;
|
gchar* window_title;
|
||||||
|
|
||||||
uri = midori_view_get_display_uri (view);
|
uri = midori_view_get_display_uri (view);
|
||||||
title = midori_view_get_display_title (view);
|
title = midori_view_get_display_title (view);
|
||||||
action = _action_by_name (browser, "Location");
|
|
||||||
|
|
||||||
if (midori_view_get_load_status (view) == MIDORI_LOAD_COMMITTED)
|
if (midori_view_get_load_status (view) == MIDORI_LOAD_COMMITTED)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue