diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/ChangeLog | 9 | ||||
-rw-r--r-- | widgets/table/e-table-specification.c | 6 | ||||
-rw-r--r-- | widgets/table/e-tree-scrolled.c | 66 | ||||
-rw-r--r-- | widgets/table/e-tree-scrolled.h | 4 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 82 | ||||
-rw-r--r-- | widgets/table/e-tree.h | 4 |
6 files changed, 101 insertions, 70 deletions
diff --git a/widgets/ChangeLog b/widgets/ChangeLog index d8bd392bca..a6b6f50b25 100644 --- a/widgets/ChangeLog +++ b/widgets/ChangeLog @@ -1,3 +1,12 @@ +2006-08-31 Matthew Barnes <mbarnes@redhat.com> + + * table/e-table-specification.c: (e_table_specification_duplicate) + Return NULL if ETable specification string fails to load. + + * table/e-tree.c: + * table/e-tree-scrolled.c: + Improve error handling in the constructors. + 2007-06-18 Srinivasa Ragavan <sragavan@novell.com> * menus/gal-define-views-dialog.c diff --git a/widgets/table/e-table-specification.c b/widgets/table/e-table-specification.c index fb8f821335..47a146405e 100644 --- a/widgets/table/e-table-specification.c +++ b/widgets/table/e-table-specification.c @@ -425,7 +425,11 @@ e_table_specification_duplicate (ETableSpecification *spec) new_spec = e_table_specification_new (); spec_str = e_table_specification_save_to_string (spec); - e_table_specification_load_from_string (new_spec, spec_str); + if (!e_table_specification_load_from_string (new_spec, spec_str)) { + g_warning ("Unable to duplicate ETable specification"); + g_object_unref (new_spec); + new_spec = NULL; + } g_free (spec_str); return new_spec; diff --git a/widgets/table/e-tree-scrolled.c b/widgets/table/e-tree-scrolled.c index 1f1145065f..ce85ea8dbc 100644 --- a/widgets/table/e-tree-scrolled.c +++ b/widgets/table/e-tree-scrolled.c @@ -73,24 +73,26 @@ e_tree_scrolled_real_construct (ETreeScrolled *ets) gtk_widget_show(GTK_WIDGET(ets->tree)); } -ETreeScrolled *e_tree_scrolled_construct (ETreeScrolled *ets, - ETreeModel *etm, - ETableExtras *ete, - const char *spec, - const char *state) +gboolean +e_tree_scrolled_construct (ETreeScrolled *ets, + ETreeModel *etm, + ETableExtras *ete, + const char *spec, + const char *state) { - g_return_val_if_fail(ets != NULL, NULL); - g_return_val_if_fail(E_IS_TREE_SCROLLED(ets), NULL); - g_return_val_if_fail(etm != NULL, NULL); - g_return_val_if_fail(E_IS_TREE_MODEL(etm), NULL); - g_return_val_if_fail(ete == NULL || E_IS_TABLE_EXTRAS(ete), NULL); - g_return_val_if_fail(spec != NULL, NULL); + g_return_val_if_fail(ets != NULL, FALSE); + g_return_val_if_fail(E_IS_TREE_SCROLLED(ets), FALSE); + g_return_val_if_fail(etm != NULL, FALSE); + g_return_val_if_fail(E_IS_TREE_MODEL(etm), FALSE); + g_return_val_if_fail(ete == NULL || E_IS_TABLE_EXTRAS(ete), FALSE); + g_return_val_if_fail(spec != NULL, FALSE); - e_tree_construct(ets->tree, etm, ete, spec, state); + if (!e_tree_construct (ets->tree, etm, ete, spec, state)) + return FALSE; e_tree_scrolled_real_construct(ets); - return ets; + return TRUE; } GtkWidget *e_tree_scrolled_new (ETreeModel *etm, @@ -110,29 +112,34 @@ GtkWidget *e_tree_scrolled_new (ETreeModel *etm "vadjustment", NULL, NULL)); - ets = e_tree_scrolled_construct (ets, etm, ete, spec, state); + if (!e_tree_scrolled_construct (ets, etm, ete, spec, state)) { + g_object_unref (ets); + return NULL; + } return GTK_WIDGET (ets); } -ETreeScrolled *e_tree_scrolled_construct_from_spec_file (ETreeScrolled *ets, - ETreeModel *etm, - ETableExtras *ete, - const char *spec_fn, - const char *state_fn) +gboolean +e_tree_scrolled_construct_from_spec_file (ETreeScrolled *ets, + ETreeModel *etm, + ETableExtras *ete, + const char *spec_fn, + const char *state_fn) { - g_return_val_if_fail(ets != NULL, NULL); - g_return_val_if_fail(E_IS_TREE_SCROLLED(ets), NULL); - g_return_val_if_fail(etm != NULL, NULL); - g_return_val_if_fail(E_IS_TREE_MODEL(etm), NULL); - g_return_val_if_fail(ete == NULL || E_IS_TABLE_EXTRAS(ete), NULL); - g_return_val_if_fail(spec_fn != NULL, NULL); + g_return_val_if_fail(ets != NULL, FALSE); + g_return_val_if_fail(E_IS_TREE_SCROLLED(ets), FALSE); + g_return_val_if_fail(etm != NULL, FALSE); + g_return_val_if_fail(E_IS_TREE_MODEL(etm), FALSE); + g_return_val_if_fail(ete == NULL || E_IS_TABLE_EXTRAS(ete), FALSE); + g_return_val_if_fail(spec_fn != NULL, FALSE); - e_tree_construct_from_spec_file(ets->tree, etm, ete, spec_fn, state_fn); + if (!e_tree_construct_from_spec_file (ets->tree, etm, ete, spec_fn, state_fn)) + return FALSE; e_tree_scrolled_real_construct(ets); - return ets; + return TRUE; } GtkWidget *e_tree_scrolled_new_from_spec_file (ETreeModel *etm, @@ -151,7 +158,10 @@ GtkWidget *e_tree_scrolled_new_from_spec_file (ETreeModel *etm "hadjustment", NULL, "vadjustment", NULL, NULL)); - ets = e_tree_scrolled_construct_from_spec_file (ets, etm, ete, spec_fn, state_fn); + if (!e_tree_scrolled_construct_from_spec_file (ets, etm, ete, spec_fn, state_fn)) { + g_object_unref (ets); + return NULL; + } return GTK_WIDGET (ets); } diff --git a/widgets/table/e-tree-scrolled.h b/widgets/table/e-tree-scrolled.h index d7f617bffe..da85f5ac55 100644 --- a/widgets/table/e-tree-scrolled.h +++ b/widgets/table/e-tree-scrolled.h @@ -48,7 +48,7 @@ typedef struct { GType e_tree_scrolled_get_type (void); -ETreeScrolled *e_tree_scrolled_construct (ETreeScrolled *ets, +gboolean e_tree_scrolled_construct (ETreeScrolled *ets, ETreeModel *etm, ETableExtras *ete, const char *spec, @@ -58,7 +58,7 @@ GtkWidget *e_tree_scrolled_new (ETreeModel *etm, const char *spec, const char *state); -ETreeScrolled *e_tree_scrolled_construct_from_spec_file (ETreeScrolled *ets, +gboolean e_tree_scrolled_construct_from_spec_file (ETreeScrolled *ets, ETreeModel *etm, ETableExtras *ete, const char *spec_fn, diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 8269b92e11..da60bc2a6a 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -1386,7 +1386,7 @@ et_connect_to_etta (ETree *et) } -static ETree * +static gboolean et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, ETableSpecification *specification, ETableState *state) { @@ -1480,25 +1480,27 @@ et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, * This is the internal implementation of e_tree_new() for use by * subclasses or language bindings. See e_tree_new() for details. * - * Return value: - * The passed in value @e_tree or %NULL if there's an error. + * Return value: %TRUE on success, %FALSE if an error occurred **/ -ETree * +gboolean e_tree_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, const char *spec_str, const char *state_str) { ETableSpecification *specification; ETableState *state; - g_return_val_if_fail(e_tree != NULL, NULL); - g_return_val_if_fail(E_IS_TREE(e_tree), NULL); - g_return_val_if_fail(etm != NULL, NULL); - g_return_val_if_fail(E_IS_TREE_MODEL(etm), NULL); - g_return_val_if_fail(ete == NULL || E_IS_TABLE_EXTRAS(ete), NULL); - g_return_val_if_fail(spec_str != NULL, NULL); + g_return_val_if_fail(e_tree != NULL, FALSE); + g_return_val_if_fail(E_IS_TREE(e_tree), FALSE); + g_return_val_if_fail(etm != NULL, FALSE); + g_return_val_if_fail(E_IS_TREE_MODEL(etm), FALSE); + g_return_val_if_fail(ete == NULL || E_IS_TABLE_EXTRAS(ete), FALSE); + g_return_val_if_fail(spec_str != NULL, FALSE); specification = e_table_specification_new(); - e_table_specification_load_from_string(specification, spec_str); + if (!e_table_specification_load_from_string(specification, spec_str)) { + g_object_unref (specification); + return FALSE; + } if (state_str) { state = e_table_state_new(); e_table_state_load_from_string(state, state_str); @@ -1512,12 +1514,17 @@ e_tree_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, g_object_ref(state); } - e_tree = et_real_construct (e_tree, etm, ete, specification, state); + if (!et_real_construct (e_tree, etm, ete, specification, state)) { + g_object_unref (specification); + g_object_unref (state); + return FALSE; + } e_tree->priv->spec = specification; - g_object_unref(state); - return e_tree; + g_object_unref (state); + + return TRUE; } /** @@ -1532,29 +1539,27 @@ e_tree_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, * for use by subclasses or language bindings. See * e_tree_new_from_spec_file() for details. * - * Return value: - * The passed in value @e_tree or %NULL if there's an error. + * Return value: %TRUE on success, %FALSE if an error occurred **/ -ETree * +gboolean e_tree_construct_from_spec_file (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, const char *spec_fn, const char *state_fn) { ETableSpecification *specification; ETableState *state; - g_return_val_if_fail(e_tree != NULL, NULL); - g_return_val_if_fail(E_IS_TREE(e_tree), NULL); - g_return_val_if_fail(etm != NULL, NULL); - g_return_val_if_fail(E_IS_TREE_MODEL(etm), NULL); - g_return_val_if_fail(ete == NULL || E_IS_TABLE_EXTRAS(ete), NULL); - g_return_val_if_fail(spec_fn != NULL, NULL); + g_return_val_if_fail(e_tree != NULL, FALSE); + g_return_val_if_fail(E_IS_TREE(e_tree), FALSE); + g_return_val_if_fail(etm != NULL, FALSE); + g_return_val_if_fail(E_IS_TREE_MODEL(etm), FALSE); + g_return_val_if_fail(ete == NULL || E_IS_TABLE_EXTRAS(ete), FALSE); + g_return_val_if_fail(spec_fn != NULL, FALSE); specification = e_table_specification_new(); if (!e_table_specification_load_from_file(specification, spec_fn)) { g_object_unref(specification); - return NULL; + return FALSE; } - if (state_fn) { state = e_table_state_new(); if (!e_table_state_load_from_file(state, state_fn)) { @@ -1572,12 +1577,17 @@ e_tree_construct_from_spec_file (ETree *e_tree, ETreeModel *etm, ETableExtras *e g_object_ref(state); } - e_tree = et_real_construct (e_tree, etm, ete, specification, state); + if (!et_real_construct (e_tree, etm, ete, specification, state)) { + g_object_unref (specification); + g_object_unref (state); + return FALSE; + } e_tree->priv->spec = specification; + g_object_unref(state); - return e_tree; + return TRUE; } /** @@ -1604,7 +1614,7 @@ e_tree_construct_from_spec_file (ETree *e_tree, ETreeModel *etm, ETableExtras *e GtkWidget * e_tree_new (ETreeModel *etm, ETableExtras *ete, const char *spec, const char *state) { - ETree *e_tree, *ret_val; + ETree *e_tree; g_return_val_if_fail(etm != NULL, NULL); g_return_val_if_fail(E_IS_TREE_MODEL(etm), NULL); @@ -1613,13 +1623,12 @@ e_tree_new (ETreeModel *etm, ETableExtras *ete, const char *spec, const char *st e_tree = g_object_new (E_TREE_TYPE, NULL); - ret_val = e_tree_construct (e_tree, etm, ete, spec, state); - - if (ret_val == NULL) { + if (!e_tree_construct (e_tree, etm, ete, spec, state)) { g_object_unref (e_tree); + return NULL; } - return (GtkWidget *) ret_val; + return (GtkWidget *) e_tree; } /** @@ -1645,7 +1654,7 @@ e_tree_new (ETreeModel *etm, ETableExtras *ete, const char *spec, const char *st GtkWidget * e_tree_new_from_spec_file (ETreeModel *etm, ETableExtras *ete, const char *spec_fn, const char *state_fn) { - ETree *e_tree, *ret_val; + ETree *e_tree; g_return_val_if_fail(etm != NULL, NULL); g_return_val_if_fail(E_IS_TREE_MODEL(etm), NULL); @@ -1654,13 +1663,12 @@ e_tree_new_from_spec_file (ETreeModel *etm, ETableExtras *ete, const char *spec_ e_tree = g_object_new (E_TREE_TYPE, NULL); - ret_val = e_tree_construct_from_spec_file (e_tree, etm, ete, spec_fn, state_fn); - - if (ret_val == NULL) { + if (!e_tree_construct_from_spec_file (e_tree, etm, ete, spec_fn, state_fn)) { g_object_unref (e_tree); + return NULL; } - return (GtkWidget *) ret_val; + return (GtkWidget *) e_tree; } void diff --git a/widgets/table/e-tree.h b/widgets/table/e-tree.h index f244715c9a..76016ba230 100644 --- a/widgets/table/e-tree.h +++ b/widgets/table/e-tree.h @@ -138,7 +138,7 @@ typedef struct { } ETreeClass; GType e_tree_get_type (void); -ETree *e_tree_construct (ETree *e_tree, +gboolean e_tree_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, const char *spec, @@ -149,7 +149,7 @@ GtkWidget *e_tree_new (ETreeModel *etm, const char *state); /* Create an ETree using files. */ -ETree *e_tree_construct_from_spec_file (ETree *e_tree, +gboolean e_tree_construct_from_spec_file (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, const char *spec_fn, |