[epiphany-extensions/tabs-reloaded: 9/9] [tabs-reloaded] Use a progress renderer while loading
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany-extensions/tabs-reloaded: 9/9] [tabs-reloaded] Use a progress renderer while loading
- Date: Wed, 5 Aug 2009 16:11:10 +0000 (UTC)
commit 27294c1badc39b2f64a8d09a896d67fce81f7744
Author: Benjamin Otte <otte gnome org>
Date: Wed Aug 5 17:59:17 2009 +0200
[tabs-reloaded] Use a progress renderer while loading
.../tabs-reloaded/ephy-tabs-reloaded-extension.c | 51 ++++++++++++++++---
extensions/tabs-reloaded/tabs-reloaded.ui | 11 ++--
2 files changed, 49 insertions(+), 13 deletions(-)
---
diff --git a/extensions/tabs-reloaded/ephy-tabs-reloaded-extension.c b/extensions/tabs-reloaded/ephy-tabs-reloaded-extension.c
index 7465338..7e1ee1b 100644
--- a/extensions/tabs-reloaded/ephy-tabs-reloaded-extension.c
+++ b/extensions/tabs-reloaded/ephy-tabs-reloaded-extension.c
@@ -105,23 +105,53 @@ text_renderer_cell_data_func (GtkCellLayout * column,
{
EphyEmbed *embed;
EphyWebView *view;
+ WebKitWebView *webkit;
embed = ephy_tabs_manager_get_tab (EPHY_TABS_MANAGER (model),
iter);
view = ephy_embed_get_web_view (embed);
+ webkit = WEBKIT_WEB_VIEW (view);
g_object_set (renderer,
"text", ephy_web_view_get_title (view),
+ "visible", webkit_web_view_get_load_status (webkit) == WEBKIT_LOAD_FINISHED,
+ NULL);
+}
+
+static void
+progress_renderer_cell_data_func (GtkCellLayout * column,
+ GtkCellRenderer *renderer,
+ GtkTreeModel * model,
+ GtkTreeIter * iter,
+ gpointer unused)
+{
+ EphyEmbed *embed;
+ EphyWebView *view;
+ WebKitWebView *webkit;
+
+ embed = ephy_tabs_manager_get_tab (EPHY_TABS_MANAGER (model),
+ iter);
+ view = ephy_embed_get_web_view (embed);
+ webkit = WEBKIT_WEB_VIEW (view);
+
+ g_object_set (renderer,
+ "text", ephy_web_view_get_title (view),
+ "value", (int) (webkit_web_view_get_progress (webkit) * 100. + 0.5),
+ "visible", webkit_web_view_get_load_status (webkit) != WEBKIT_LOAD_FINISHED,
NULL);
}
static void
sanitize_tree_view (GtkTreeView *view)
{
- static const GtkCellLayoutDataFunc funcs[] = {
- pixbuf_renderer_cell_data_func,
- text_renderer_cell_data_func,
- NULL /* close button */
+ static const struct {
+ GtkCellLayoutDataFunc func;
+ gboolean expand;
+ } cell_info[] = {
+ { pixbuf_renderer_cell_data_func, FALSE },
+ { text_renderer_cell_data_func, TRUE },
+ { progress_renderer_cell_data_func, TRUE },
+ { NULL /* close button */, FALSE }
};
GtkCellLayout *column;
GtkCellRenderer *renderer;
@@ -135,17 +165,22 @@ sanitize_tree_view (GtkTreeView *view)
if (column == NULL)
break;
renderers = gtk_cell_layout_get_cells (column);
+ g_list_foreach (renderers, (GFunc) g_object_ref, NULL);
+ gtk_cell_layout_clear (column);
for (walk = renderers; walk; walk = g_list_next (walk))
{
renderer = walk->data;
- if (funcs[renderer_id])
+ gtk_cell_layout_pack_start (column, renderer, cell_info[renderer_id].expand);
+ if (cell_info[renderer_id].func)
gtk_cell_layout_set_cell_data_func (column,
renderer,
- funcs[renderer_id],
+ cell_info[renderer_id].func,
NULL,
NULL);
renderer_id++;
}
+ g_list_foreach (renderers, (GFunc) g_object_unref, NULL);
+ g_list_free (renderers);
}
/*
@@ -153,7 +188,7 @@ sanitize_tree_view (GtkTreeView *view)
* cell renderers and we need to add or remove data functions from
* the funcs array above to match that change.
*/
- g_assert (renderer_id == G_N_ELEMENTS (funcs));
+ g_assert (renderer_id == G_N_ELEMENTS (cell_info));
}
static void
@@ -219,7 +254,7 @@ impl_attach_window (EphyExtension *extension,
notebook = ephy_window_get_notebook (window);
g_signal_connect (notebook, "notify::show-tabs", G_CALLBACK (force_no_tabs), NULL);
- gtk_notebook_set_show_tabs (notebook, FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
tabs = (GtkWidget *) gtk_builder_get_object (builder, "TabView");
sanitize_tree_view (GTK_TREE_VIEW (tabs));
diff --git a/extensions/tabs-reloaded/tabs-reloaded.ui b/extensions/tabs-reloaded/tabs-reloaded.ui
index 46c6b92..f7c5d09 100644
--- a/extensions/tabs-reloaded/tabs-reloaded.ui
+++ b/extensions/tabs-reloaded/tabs-reloaded.ui
@@ -35,11 +35,12 @@
<property name="single_paragraph_mode">True</property>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn2">
- <property name="title">column</property>
+ <child>
+ <object class="GtkCellRendererProgress" id="progress">
+ <property name="width">1</property>
+ <property name="text_xalign">0</property>
+ </object>
+ </child>
<child>
<object class="GtkCellRendererPixbuf" id="close">
<property name="stock_id">gtk-close</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]