[epiphany-extensions/tabs-reloaded: 13/16] [tabs-reloaded] Only cause redraws when relevant properties change
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany-extensions/tabs-reloaded: 13/16] [tabs-reloaded] Only cause redraws when relevant properties change
- Date: Wed, 16 Dec 2009 16:51:34 +0000 (UTC)
commit e5a25df472ed35089adc52df5addbcc040fd3b68
Author: Benjamin Otte <otte gnome org>
Date: Fri Aug 7 23:55:35 2009 +0200
[tabs-reloaded] Only cause redraws when relevant properties change
Previously we redrew whenever a notify signal happened. That was very
often, so it felt slow.
extensions/tabs-reloaded/ephy-cell-renderer-tab.c | 48 +++++++++++++++++++++
extensions/tabs-reloaded/ephy-cell-renderer-tab.h | 7 ++-
extensions/tabs-reloaded/ephy-tabs-manager.c | 10 +++-
3 files changed, 59 insertions(+), 6 deletions(-)
---
diff --git a/extensions/tabs-reloaded/ephy-cell-renderer-tab.c b/extensions/tabs-reloaded/ephy-cell-renderer-tab.c
index 46e1584..8b8e3c6 100644
--- a/extensions/tabs-reloaded/ephy-cell-renderer-tab.c
+++ b/extensions/tabs-reloaded/ephy-cell-renderer-tab.c
@@ -414,3 +414,51 @@ ephy_cell_renderer_tab_new (void)
return g_object_new (EPHY_TYPE_CELL_RENDERER_TAB, NULL);
}
+/**
+ * ephy_cell_renderer_needs_invalidation:
+ * @property_name: interned name of the property
+ *
+ * Checks if a #EphyCellRendererTab would need a repaint if the
+ * property with the given @property_name would have been changed
+ * on the #EphyWebView asociated to the #EphyEmbed of its tab. In
+ * that case, you should likely call gtk_tree_model_row_changed()
+ * on the row that represents the node that changed to cause this
+ * repaint.
+ *
+ * Returns: %TRUE if a tab would need a repaint, %FALSE if not.
+ **/
+gboolean
+ephy_cell_renderer_needs_invalidation (const char *property_name)
+{
+ static struct {
+ const char *property_name;
+ const char *interned_name;
+ } properties[] = {
+ /* EphyWebView */
+ { "embed-title", NULL },
+ { "icon", NULL },
+ /* WebKitWebView */
+ { "progress", NULL },
+ { "load-status", NULL },
+ };
+ guint i;
+
+ g_return_val_if_fail (property_name != NULL, TRUE);
+
+ if (properties[0].interned_name == NULL)
+ {
+ for (i = 0; i < G_N_ELEMENTS (properties); i++)
+ {
+ properties[i].interned_name = g_intern_string (properties[i].property_name);
+ }
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (properties); i++)
+ {
+ if (properties[i].interned_name == property_name)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
diff --git a/extensions/tabs-reloaded/ephy-cell-renderer-tab.h b/extensions/tabs-reloaded/ephy-cell-renderer-tab.h
index 5250306..d4e1b48 100644
--- a/extensions/tabs-reloaded/ephy-cell-renderer-tab.h
+++ b/extensions/tabs-reloaded/ephy-cell-renderer-tab.h
@@ -47,11 +47,12 @@ struct _EphyCellRendererTabClass
GtkCellRendererClass parent_class;
};
-GType ephy_cell_renderer_tab_get_type (void) G_GNUC_CONST;
-void ephy_cell_renderer_tab_register (GTypeModule *module);
+GType ephy_cell_renderer_tab_get_type (void) G_GNUC_CONST;
+void ephy_cell_renderer_tab_register (GTypeModule * module);
-GtkCellRenderer *ephy_cell_renderer_tab_new (void);
+GtkCellRenderer *ephy_cell_renderer_tab_new (void);
+gboolean ephy_cell_renderer_needs_invalidation (const char * property_name);
G_END_DECLS
diff --git a/extensions/tabs-reloaded/ephy-tabs-manager.c b/extensions/tabs-reloaded/ephy-tabs-manager.c
index 6fa22d6..7bac2ff 100644
--- a/extensions/tabs-reloaded/ephy-tabs-manager.c
+++ b/extensions/tabs-reloaded/ephy-tabs-manager.c
@@ -19,9 +19,9 @@
#include "config.h"
#include "ephy-tabs-manager.h"
-#include "ephy-debug.h"
-#include <epiphany/epiphany.h>
+#include "ephy-cell-renderer-tab.h"
+#include "ephy-debug.h"
G_DEFINE_DYNAMIC_TYPE (EphyTabsManager, ephy_tabs_manager, GTK_TYPE_TREE_STORE)
@@ -97,13 +97,17 @@ ephy_tabs_manager_new (void)
}
static void
-ephy_tabs_manager_view_changed (GObject *view, GParamSpec *psepc, EphyTabsManager *manager)
+ephy_tabs_manager_view_changed (GObject *view, GParamSpec *pspec, EphyTabsManager *manager)
{
GtkTreeModel *model = GTK_TREE_MODEL (manager);
GtkTreeIter iter;
EphyEmbed *embed;
GtkTreePath *path;
+ /* remove the interning code once bug 591106 is fixed */
+ if (!ephy_cell_renderer_needs_invalidation (g_intern_string (pspec->name)))
+ return;
+
embed = EPHY_EMBED (gtk_widget_get_parent (GTK_WIDGET (view)));
if (!ephy_tabs_manager_find_tab (manager, &iter, embed))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]