aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-08-15 04:19:12 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-08-15 04:19:12 +0800
commit7ade227e6409c98a4010992450e111cf7bb10520 (patch)
treebdd716d894ae2f3b1affaa6bb68950a89441db13 /widgets/table
parentcca29c3424aede2bb3c9ec5a6d255ce490d3511b (diff)
downloadgsoc2013-evolution-7ade227e6409c98a4010992450e111cf7bb10520.tar.gz
gsoc2013-evolution-7ade227e6409c98a4010992450e111cf7bb10520.tar.zst
gsoc2013-evolution-7ade227e6409c98a4010992450e111cf7bb10520.zip
Merge revisions 35951:35992 from trunk.
svn path=/branches/kill-bonobo/; revision=35994
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/ChangeLog47
-rw-r--r--widgets/table/e-tree-table-adapter.c93
-rw-r--r--widgets/table/e-tree-table-adapter.h8
-rw-r--r--widgets/table/e-tree.c26
-rw-r--r--widgets/table/e-tree.h6
5 files changed, 127 insertions, 53 deletions
diff --git a/widgets/table/ChangeLog b/widgets/table/ChangeLog
index d5fe462ccd..cf632fc517 100644
--- a/widgets/table/ChangeLog
+++ b/widgets/table/ChangeLog
@@ -1,3 +1,50 @@
+2008-08-11 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #352695
+
+ * e-tree-table-adapter.c: (e_tree_table_adapter_load_expanded_state),
+ (e_tree_table_adapter_load_expanded_state_xml):
+ Call the e_table_model_changed in the proper function, to prevent
+ lock of the model caused by previous commit to this bug.
+
+2008-08-11 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #519292
+
+ * e-tree.h: (e_tree_load_all_expanded_state):
+ * e-tree.c: (e_tree_load_all_expanded_state):
+ * e-tree-table-adapter.h:
+ (e_tree_table_adapter_load_all_expanded_state):
+ * e-tree-table-adapter.c:
+ (e_tree_table_adapter_load_all_expanded_state),
+ (set_expanded_state_func), (set_collapsed_state_func):
+ Drop functions in favor of new functions.
+ * e-tree.h: (e_tree_force_expanded_state):
+ * e-tree.c: (e_tree_force_expanded_state):
+ * e-tree-table-adapter.h: (e_tree_table_adapter_force_expanded_state):
+ * e-tree-table-adapter.c: (e_tree_table_adapter_force_expanded_state),
+ (struct ETreeTableAdapterPriv), (create_gnode), (etta_init):
+ Use either default value of the model to expanded state of new node or
+ use the one which has been set (forced) by new functions.
+
+2008-08-11 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #352695
+
+ * e-tree-table-adapter.h:
+ (e_tree_table_adapter_save_expanded_state_xml),
+ (e_tree_table_adapter_load_expanded_state_xml):
+ * e-tree-table-adapter.c:
+ (e_tree_table_adapter_save_expanded_state_xml),
+ (e_tree_table_adapter_save_expanded_state),
+ (e_tree_table_adapter_load_expanded_state_xml),
+ (e_tree_table_adapter_load_expanded_state):
+ * e-tree.h: (e_tree_save_expanded_state_xml),
+ (e_tree_load_expanded_state_xml):
+ * e-tree.c: (e_tree_save_expanded_state_xml),
+ (e_tree_load_expanded_state_xml):
+ Be able to store expanded state also in memory, not only on the disk.
+
2008-07-15 Milan Crha <mcrha@redhat.com>
** Part of fix for bug #329821
diff --git a/widgets/table/e-tree-table-adapter.c b/widgets/table/e-tree-table-adapter.c
index 579b231bb3..7953440b57 100644
--- a/widgets/table/e-tree-table-adapter.c
+++ b/widgets/table/e-tree-table-adapter.c
@@ -82,6 +82,8 @@ struct ETreeTableAdapterPriv {
int sort_info_changed_id;
guint resort_idle_id;
+
+ int force_expanded_state; /* use this instead of model's default if not 0; <0 ... collapse, >0 ... expand */
};
static void etta_sort_info_changed (ETableSortInfo *sort_info, ETreeTableAdapter *etta);
@@ -322,7 +324,7 @@ create_gnode(ETreeTableAdapter *etta, ETreePath path)
node = g_new0(node_t, 1);
node->path = path;
node->index = -1;
- node->expanded = e_tree_model_get_expanded_default(etta->priv->source);
+ node->expanded = etta->priv->force_expanded_state == 0 ? e_tree_model_get_expanded_default (etta->priv->source) : etta->priv->force_expanded_state > 0;
node->expandable = e_tree_model_node_is_expandable(etta->priv->source, path);
node->expandable_set = 1;
node->num_visible_children = 0;
@@ -737,6 +739,7 @@ etta_init (ETreeTableAdapter *etta)
etta->priv->node_request_collapse_id = 0;
etta->priv->resort_idle_id = 0;
+ etta->priv->force_expanded_state = 0;
}
static void
@@ -912,14 +915,14 @@ save_expanded_state_func (gpointer keyp, gpointer value, gpointer data)
}
}
-void
-e_tree_table_adapter_save_expanded_state (ETreeTableAdapter *etta, const char *filename)
+xmlDoc *
+e_tree_table_adapter_save_expanded_state_xml (ETreeTableAdapter *etta)
{
TreeAndRoot tar;
xmlDocPtr doc;
xmlNode *root;
- g_return_if_fail(etta != NULL);
+ g_return_val_if_fail (etta != NULL, NULL);
doc = xmlNewDoc ((const unsigned char *)"1.0");
root = xmlNewDocNode (doc, NULL, (const unsigned char *)"expanded_state", NULL);
@@ -934,8 +937,21 @@ e_tree_table_adapter_save_expanded_state (ETreeTableAdapter *etta, const char *f
g_hash_table_foreach (etta->priv->nodes, save_expanded_state_func, &tar);
- e_xml_save_file (filename, doc);
- xmlFreeDoc (doc);
+ return doc;
+}
+
+void
+e_tree_table_adapter_save_expanded_state (ETreeTableAdapter *etta, const char *filename)
+{
+ xmlDoc *doc;
+
+ g_return_if_fail (etta != NULL);
+
+ doc = e_tree_table_adapter_save_expanded_state_xml (etta);
+ if (doc) {
+ e_xml_save_file (filename, doc);
+ xmlFreeDoc (doc);
+ }
}
static xmlDoc *
@@ -983,57 +999,24 @@ open_file (ETreeTableAdapter *etta, const char *filename)
return doc;
}
-static void
-set_expanded_state_func (gpointer keyp, gpointer value, gpointer data)
-{
- ETreePath path = keyp;
- node_t *node = ((GNode *)value)->data;
- ETreeTableAdapter *etta = (ETreeTableAdapter *) data;
-
- if (node->expanded != TRUE) {
- e_tree_table_adapter_node_set_expanded_recurse (etta, path, TRUE);
- node->expanded = TRUE;
- }
-}
-
-static void
-set_collapsed_state_func (gpointer keyp, gpointer value, gpointer data)
-{
- ETreePath path = keyp;
- node_t *node = ((GNode *)value)->data;
- ETreeTableAdapter *etta = (ETreeTableAdapter *) data;
-
- if (node->expanded != FALSE) {
- e_tree_table_adapter_node_set_expanded_recurse (etta, path, FALSE);
- node->expanded = FALSE;
- }
-}
-
+/* state: <0 ... collapse; 0 ... use default; >0 ... expand */
void
-e_tree_table_adapter_load_all_expanded_state (ETreeTableAdapter *etta, gboolean state)
+e_tree_table_adapter_force_expanded_state (ETreeTableAdapter *etta, int state)
{
+ g_return_if_fail (etta != NULL);
- g_return_if_fail(etta != NULL);
-
- if (state)
- g_hash_table_foreach (etta->priv->nodes, set_expanded_state_func, etta);
- else
- g_hash_table_foreach (etta->priv->nodes, set_collapsed_state_func, etta);
+ etta->priv->force_expanded_state = state;
}
void
-e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta, const char *filename)
+e_tree_table_adapter_load_expanded_state_xml (ETreeTableAdapter *etta, xmlDoc *doc)
{
- xmlDoc *doc;
xmlNode *root, *child;
gboolean model_default;
gboolean file_default = FALSE;
- g_return_if_fail(etta != NULL);
-
- doc = open_file(etta, filename);
- if (!doc)
- return;
+ g_return_if_fail (etta != NULL);
+ g_return_if_fail (doc != NULL);
root = xmlDocGetRootElement (doc);
@@ -1084,12 +1067,26 @@ e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta, const char *f
g_free (id);
}
- xmlFreeDoc (doc);
-
e_table_model_changed (E_TABLE_MODEL (etta));
}
void
+e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta, const char *filename)
+{
+ xmlDoc *doc;
+
+ g_return_if_fail(etta != NULL);
+
+ doc = open_file(etta, filename);
+ if (!doc)
+ return;
+
+ e_tree_table_adapter_load_expanded_state_xml (etta, doc);
+
+ xmlFreeDoc (doc);
+}
+
+void
e_tree_table_adapter_root_node_set_visible (ETreeTableAdapter *etta, gboolean visible)
{
int size;
diff --git a/widgets/table/e-tree-table-adapter.h b/widgets/table/e-tree-table-adapter.h
index cd23ba06bb..4d792f7451 100644
--- a/widgets/table/e-tree-table-adapter.h
+++ b/widgets/table/e-tree-table-adapter.h
@@ -30,6 +30,7 @@
#include <table/e-tree-model.h>
#include <table/e-table-sort-info.h>
#include <table/e-table-header.h>
+#include <libxml/tree.h>
G_BEGIN_DECLS
@@ -71,8 +72,8 @@ void e_tree_table_adapter_node_set_expanded (ETreeTableAdapter
void e_tree_table_adapter_node_set_expanded_recurse (ETreeTableAdapter *etta,
ETreePath path,
gboolean expanded);
-void e_tree_table_adapter_load_all_expanded_state (ETreeTableAdapter *etta,
- gboolean state);
+void e_tree_table_adapter_force_expanded_state (ETreeTableAdapter *etta,
+ int state);
void e_tree_table_adapter_root_node_set_visible (ETreeTableAdapter *etta,
gboolean visible);
ETreePath e_tree_table_adapter_node_at_row (ETreeTableAdapter *etta,
@@ -89,6 +90,9 @@ void e_tree_table_adapter_save_expanded_state (ETreeTableAdapter
void e_tree_table_adapter_load_expanded_state (ETreeTableAdapter *etta,
const char *filename);
+xmlDoc *e_tree_table_adapter_save_expanded_state_xml (ETreeTableAdapter *etta);
+void e_tree_table_adapter_load_expanded_state_xml (ETreeTableAdapter *etta, xmlDoc *doc);
+
void e_tree_table_adapter_set_sort_info (ETreeTableAdapter *etta,
ETableSortInfo *sort_info);
diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c
index 8b685a724b..6d375cdfc1 100644
--- a/widgets/table/e-tree.c
+++ b/widgets/table/e-tree.c
@@ -2069,10 +2069,32 @@ e_tree_load_expanded_state (ETree *et, char *filename)
e_tree_table_adapter_load_expanded_state (et->priv->etta, filename);
}
+xmlDoc *
+e_tree_save_expanded_state_xml (ETree *et)
+{
+ g_return_val_if_fail (et != NULL, NULL);
+ g_return_val_if_fail (E_IS_TREE (et), NULL);
+
+ return e_tree_table_adapter_save_expanded_state_xml (et->priv->etta);
+}
+
+void
+e_tree_load_expanded_state_xml (ETree *et, xmlDoc *doc)
+{
+ g_return_if_fail (et != NULL);
+ g_return_if_fail (E_IS_TREE (et));
+ g_return_if_fail (doc != NULL);
+
+ e_tree_table_adapter_load_expanded_state_xml (et->priv->etta, doc);
+}
+
+/* state: <0 ... collapse; 0 ... no force - use default; >0 ... expand;
+ when using this, be sure to reset to 0 once no forcing is required
+ anymore, aka the build of the tree is done */
void
-e_tree_load_all_expanded_state (ETree *et, gboolean state)
+e_tree_force_expanded_state (ETree *et, int state)
{
- e_tree_table_adapter_load_all_expanded_state (et->priv->etta, state);
+ e_tree_table_adapter_force_expanded_state (et->priv->etta, state);
}
gint
diff --git a/widgets/table/e-tree.h b/widgets/table/e-tree.h
index 6e736f1a0e..3093855e4b 100644
--- a/widgets/table/e-tree.h
+++ b/widgets/table/e-tree.h
@@ -286,9 +286,13 @@ void e_tree_save_expanded_state (ETree *et,
char *filename);
void e_tree_load_expanded_state (ETree *et,
char *filename);
+
+xmlDoc *e_tree_save_expanded_state_xml (ETree *et);
+void e_tree_load_expanded_state_xml (ETree *et, xmlDoc *doc);
+
int e_tree_row_count (ETree *et);
GtkWidget *e_tree_get_tooltip (ETree *et);
-void e_tree_load_all_expanded_state (ETree *et, gboolean state);
+void e_tree_force_expanded_state (ETree *et, int state);
typedef enum {
E_TREE_FIND_NEXT_BACKWARD = 0,