summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2011-11-17 19:18:46 -0500
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2011-11-17 19:33:50 -0500
commit5890035ce41765d1ad41754e30174b56dbf692a6 (patch)
treebe6517f1a70f524dea9f7b6724c6d143ab17a66c
parente90717a501d3e99509c0e6ade83e3876d4a84f68 (diff)
downloadglade-5890035ce41765d1ad41754e30174b56dbf692a6.tar.gz
2011-11-17 Fredy Paquet <fpa@opag.ch>
* plugins/gtk+/glade-gtk.c: Improved performance of modifying GtkTable contents, shows specifically when loading files containing large tables. Bug 663516
-rw-r--r--ChangeLog21
-rw-r--r--plugins/gtk+/glade-gtk-table.c87
-rw-r--r--plugins/gtk+/glade-gtk.c6
3 files changed, 86 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 772bf44e..3faa4b0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,16 +1,23 @@
+2011-11-17 Fredy Paquet <fpa@opag.ch>
+
+ * plugins/gtk+/glade-gtk.c: Improved performance of modifying GtkTable
+ contents, shows specifically when loading files containing large tables.
+
+ Bug 663516
+
2011-11-03 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* gladeui/glade-design-layout.c:
o Added workaround for child bg bug on Adwaita theme.
o Fixed bug detecting widget including margins
-
+
* gladeui/glade-design-view.c: cleaned up glade_design_view_style_updated()
- to make it use new style context instead of modifying its own.
+ to make it use new style context instead of modifying its own.
2011-10-31 Juan Pablo Ugarte <juanpablougarte@gmail.com>
- * gladeui/glade-design-layout.c:
- o Use only button 1 press to select widgets.
+ * gladeui/glade-design-layout.c:
+ o Use only button 1 press to select widgets.
o Fixed bug in gdl_get_margins_from_pointer(), needed to translate coordinates
o In glade_design_layout_find_inside_container() use widget margins as
if they where part of the widget allocation.
@@ -96,15 +103,15 @@
unknown objects in xml files.
* gladeui/glade-utils.c: made glade_util_ui_message () accept markup strings.
-
+
* gladeui/glade-xml-utils.[ch]: added new function glade_xml_node_copy()
* gladeui/glade-widget.c:
o glade_widget_read() create object stub if class is unknown.
o glade_widget_write() used saved xml to dump stub objects.
-
+
* glade/gladeui/glade-project.c: make GladeProject remember unknown catalogs
- to avoid loosing requirements when loading/saving a file with unknown objects.
+ to avoid loosing requirements when loading/saving a file with unknown objects.
2011-09-19 Ignacio Casal Quinteiro <icq@gnome.org>
diff --git a/plugins/gtk+/glade-gtk-table.c b/plugins/gtk+/glade-gtk-table.c
index 52a24f09..e61193b8 100644
--- a/plugins/gtk+/glade-gtk-table.c
+++ b/plugins/gtk+/glade-gtk-table.c
@@ -547,32 +547,83 @@ glade_gtk_table_widget_exceeds_bounds (GtkTable * table, gint n_rows,
return ret;
}
+#define TABLE_OCCUPIED(occmap, n_columns, col, row) \
+ (occmap)[row * n_columns + col]
+
static void
-glade_gtk_table_refresh_placeholders (GtkTable * table)
+glade_gtk_table_build_occupation_maps(GtkTable *table, guint n_columns, guint n_rows,
+ gchar **child_map, gpointer **placeholder_map)
{
- GList *list, *children;
- guint n_columns, n_rows;
- gint i, j;
-
- g_object_get (table, "n-columns", &n_columns, "n-rows", &n_rows, NULL);
+ guint i, j;
+ GList *list, *children = gtk_container_get_children (GTK_CONTAINER (table));
- children = gtk_container_get_children (GTK_CONTAINER (table));
+ *child_map = g_malloc0(n_columns * n_rows * sizeof(gchar)); /* gchar is smaller than gboolean */
+ *placeholder_map = g_malloc0(n_columns * n_rows * sizeof(gpointer));
- for (list = children; list && list->data; list = list->next)
+ for (list = children; list && list->data; list = list->next)
{
- if (GLADE_IS_PLACEHOLDER (list->data))
- gtk_container_remove (GTK_CONTAINER (table), GTK_WIDGET (list->data));
+ GtkTableChild child;
+
+ glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
+ GTK_WIDGET (list->data), &child);
+
+ if (GLADE_IS_PLACEHOLDER(list->data))
+ {
+ /* assumption: placeholders are always attached to exactly 1 cell */
+ TABLE_OCCUPIED(*placeholder_map, n_columns, child.left_attach, child.top_attach) = list->data;
+ }
+ else
+ {
+ for (i = child.left_attach; i < child.right_attach && i < n_columns; i++)
+ {
+ for (j = child.top_attach; j < child.bottom_attach && j < n_rows; j++)
+ {
+ TABLE_OCCUPIED(*child_map, n_columns, i, j) = 1;
+ }
+ }
+ }
}
- g_list_free (children);
+ g_list_free (children);
+}
+
+static void
+glade_gtk_table_refresh_placeholders (GtkTable * table)
+{
+ guint n_columns, n_rows, i, j;
+ gchar *child_map;
+ gpointer *placeholder_map;
+
+ g_object_get (table, "n-columns", &n_columns, "n-rows", &n_rows, NULL);
+ glade_gtk_table_build_occupation_maps (table, n_columns, n_rows,
+ &child_map, &placeholder_map);
for (i = 0; i < n_columns; i++)
- for (j = 0; j < n_rows; j++)
- if (glade_gtk_table_has_child (table, i, j) == FALSE)
- {
- gtk_table_attach_defaults (table,
- glade_placeholder_new (),
- i, i + 1, j, j + 1);
- }
+ {
+ for (j = 0; j < n_rows; j++)
+ {
+ gpointer placeholder = TABLE_OCCUPIED(placeholder_map, n_columns, i, j);
+
+ if (TABLE_OCCUPIED(child_map, n_columns, i, j))
+ {
+ if (placeholder)
+ {
+ gtk_container_remove (GTK_CONTAINER (table),
+ GTK_WIDGET (placeholder));
+ }
+ }
+ else
+ {
+ if (!placeholder)
+ {
+ gtk_table_attach_defaults (table,
+ glade_placeholder_new (),
+ i, i + 1, j, j + 1);
+ }
+ }
+ }
+ }
+ g_free(child_map);
+ g_free(placeholder_map);
gtk_container_check_resize (GTK_CONTAINER (table));
}
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 799c5452..5ffd1484 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -2384,9 +2384,9 @@ glade_gtk_notebook_insert_children (GtkWidget * notebook,
{
gint i;
- /*********************************************************
- INSERT PAGES
- *********************************************************/
+ /*********************************************************
+ * INSERT PAGES *
+ *********************************************************/
for (i = 0; i < nchildren->pages; i++)
{
GtkWidget *page = notebook_get_page (nchildren, i);