More effective status updates and less entry flickering

The statusbar and progressbar respectively should not
be updated too generously. Optimizing the status updates
reduces flickering of entries remarkably.
This commit is contained in:
Christian Dywan 2007-12-22 02:15:58 +01:00
parent cd1dce0e83
commit 84ceb56bf8
4 changed files with 33 additions and 43 deletions

View file

@ -813,7 +813,7 @@ void on_notebook_switch_page(GtkWidget* widget, GtkNotebookPage* page
update_favicon(browser);
update_security(browser);
update_gui_state(browser);
update_statusbar_text(browser);
update_statusbar(browser);
update_feeds(browser);
update_search_engines(browser);
}

View file

@ -310,17 +310,18 @@ void action_set_visible(const gchar* name, gboolean visible, CBrowser* browser)
gtk_action_set_visible(action, visible);
}
void update_statusbar_text(CBrowser* browser)
void update_statusbar(CBrowser* browser)
{
if(browser->statusMessage)
{
gtk_statusbar_pop(GTK_STATUSBAR(browser->statusbar), 1);
gtk_statusbar_push(GTK_STATUSBAR(browser->statusbar), 1
, browser->statusMessage);
}
sokoke_widget_set_visible(browser->progress, browser->loadedPercent > -1);
, browser->statusMessage ? browser->statusMessage : "");
if(browser->loadedPercent > -1)
{
if(browser->loadedPercent > -1)
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(browser->progress)
, browser->loadedPercent ? browser->loadedPercent / 100.0 : 0);
else
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(browser->progress));
gchar* message = g_strdup_printf("%d%% loaded", browser->loadedPercent);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(browser->progress), message);
g_free(message);
@ -368,26 +369,21 @@ void update_gui_state(CBrowser* browser)
GtkAction* action = gtk_action_group_get_action(browser->actiongroup, "RefreshStop");
if(browser->loadedPercent == -1)
{
gtk_widget_hide(browser->throbber);
gtk_widget_set_sensitive(browser->throbber, FALSE);
g_object_set(action, "stock-id", GTK_STOCK_REFRESH, NULL);
g_object_set(action, "tooltip", "Refresh the current page", NULL);
gtk_widget_hide(browser->progress);
}
else
{
gtk_widget_show(browser->throbber);
gtk_widget_set_sensitive(browser->throbber, TRUE);
g_object_set(action, "stock-id", GTK_STOCK_STOP, NULL);
g_object_set(action, "tooltip", "Stop loading the current page", NULL);
gtk_widget_show(browser->progress);
}
gtk_image_set_from_stock(GTK_IMAGE(browser->location_icon), GTK_STOCK_FILE
, GTK_ICON_SIZE_MENU);
if(browser->loadedPercent > -1)
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(browser->progress)
, browser->loadedPercent ? browser->loadedPercent / 100.0 : 0);
else
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(browser->progress));
update_statusbar_text(browser);
}
void update_feeds(CBrowser* browser)
@ -400,21 +396,14 @@ void update_search_engines(CBrowser* browser)
// TODO: Look for available search engines, requires dom access
}
void update_status_message(const gchar* message, CBrowser* browser)
{
g_free(browser->statusMessage);
browser->statusMessage = g_strdup(message ? message : "");
update_statusbar_text(browser);
}
void update_browser_actions(CBrowser* browser)
{
gboolean active = gtk_notebook_get_n_pages(GTK_NOTEBOOK(browser->webViews)) > 1;
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(browser->webViews), active);
action_set_sensitive("TabClose", active, browser);
guint n = xbel_folder_get_n_items(tabtrash);
action_set_sensitive("UndoTabClose", n, browser);
action_set_sensitive("TabsClosed", n, browser);
gboolean tabtrashEmpty = xbel_folder_is_empty(tabtrash);
action_set_sensitive("UndoTabClose", !tabtrashEmpty, browser);
action_set_sensitive("TabsClosed", !tabtrashEmpty, browser);
}
gchar* magic_uri(const gchar* uri, gboolean search)

View file

@ -75,7 +75,7 @@ void
action_set_visible(const gchar*, gboolean, CBrowser*);
void
update_statusbar_text(CBrowser*);
update_statusbar(CBrowser*);
void
update_edit_items(CBrowser*);
@ -89,9 +89,6 @@ update_feeds(CBrowser*);
void
update_search_engines(CBrowser*);
void
update_status_message(const gchar*, CBrowser*);
void
update_browser_actions(CBrowser*);

View file

@ -79,10 +79,10 @@ void on_webView_load_started(GtkWidget* webView, WebKitWebFrame* widget
browser->loadedPercent = 0;
update_favicon(browser);
if(webView == get_nth_webView(-1, browser))
{
update_gui_state(browser);
update_statusbar_text(browser);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(browser->progress), 0.1);
gtk_widget_show(browser->progress);
update_statusbar(browser);
}
}
void on_webView_load_committed(GtkWidget* webView, WebKitWebFrame* frame
@ -95,8 +95,8 @@ void on_webView_load_committed(GtkWidget* webView, WebKitWebFrame* frame
{
gtk_entry_set_text(GTK_ENTRY(browser->location), newUri);
gtk_label_set_text(GTK_LABEL(browser->webView_name), newUri);
update_status_message(NULL, browser);
update_gui_state(browser);
g_free(browser->statusMessage);
browser->statusMessage = NULL;
}
}
@ -104,7 +104,7 @@ void on_webView_load_changed(GtkWidget* webView, gint progress, CBrowser* browse
{
browser->loadedPercent = progress;
if(webView == get_nth_webView(-1, browser))
update_gui_state(browser);
update_statusbar(browser);
}
void on_webView_load_finished(GtkWidget* webView, WebKitWebFrame* widget
@ -114,13 +114,13 @@ void on_webView_load_finished(GtkWidget* webView, WebKitWebFrame* widget
update_favicon(browser);
if(webView == get_nth_webView(-1, browser))
update_gui_state(browser);
update_statusbar_text(browser);
gtk_widget_hide(browser->progress);
}
void on_webView_status_message(GtkWidget* webView, const gchar* text, CBrowser* browser)
{
update_status_message(text, browser);
g_free(browser->statusMessage);
browser->statusMessage = g_strdup(text);
update_statusbar(browser);
}
void on_webView_selection_changed(GtkWidget* webView, CBrowser* browser)
@ -137,7 +137,9 @@ gboolean on_webView_console_message(GtkWidget* webView
void on_webView_link_hover(GtkWidget* webView, const gchar* tooltip
, const gchar* uri, CBrowser* browser)
{
update_status_message(uri, browser);
g_free(browser->statusMessage);
browser->statusMessage = g_strdup(uri);
update_statusbar(browser);
g_free(browser->elementUri);
browser->elementUri = g_strdup(uri);
}
@ -277,7 +279,9 @@ gboolean on_webView_scroll(GtkWidget* webView, GdkEventScroll* event
gboolean on_webView_leave(GtkWidget* webView, GdkEventCrossing* event, CBrowser* browser)
{
update_status_message(NULL, browser);
g_free(browser->statusMessage);
browser->statusMessage = NULL;
update_statusbar(browser);
return TRUE;
}