aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-03-07 21:37:18 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-03-07 22:11:24 +0800
commit30869d1fb7a94911ba030c8e0b8fa3b6c1614365 (patch)
tree30461dc85b6e548c47411389c0b9cc7e1cda4f38 /e-util
parent6ce1aed5b319c107b3300bc1e00e3efc63d5c303 (diff)
downloadgsoc2013-evolution-30869d1fb7a94911ba030c8e0b8fa3b6c1614365.tar
gsoc2013-evolution-30869d1fb7a94911ba030c8e0b8fa3b6c1614365.tar.gz
gsoc2013-evolution-30869d1fb7a94911ba030c8e0b8fa3b6c1614365.tar.bz2
gsoc2013-evolution-30869d1fb7a94911ba030c8e0b8fa3b6c1614365.tar.lz
gsoc2013-evolution-30869d1fb7a94911ba030c8e0b8fa3b6c1614365.tar.xz
gsoc2013-evolution-30869d1fb7a94911ba030c8e0b8fa3b6c1614365.tar.zst
gsoc2013-evolution-30869d1fb7a94911ba030c8e0b8fa3b6c1614365.zip
EConfig: Miscellaneous cleanups.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-config.c68
1 files changed, 37 insertions, 31 deletions
diff --git a/e-util/e-config.c b/e-util/e-config.c
index c4a6b7c419..97711f95be 100644
--- a/e-util/e-config.c
+++ b/e-util/e-config.c
@@ -76,7 +76,7 @@ struct _widget_node {
struct _check_node {
gchar *pageid;
- EConfigCheckFunc check;
+ EConfigCheckFunc func;
gpointer data;
};
@@ -116,29 +116,38 @@ G_DEFINE_TYPE (
G_TYPE_OBJECT)
static void
+check_node_free (struct _check_node *node)
+{
+ g_free (node->pageid);
+
+ g_slice_free (struct _check_node, node);
+}
+
+static void
config_finalize (GObject *object)
{
- EConfig *emp = (EConfig *) object;
- EConfigPrivate *p = emp->priv;
+ EConfigPrivate *priv;
GList *link;
+ priv = E_CONFIG_GET_PRIVATE (object);
+
d(printf("finalising EConfig %p\n", object));
- g_free (emp->id);
+ g_free (E_CONFIG (object)->id);
- link = p->menus;
+ link = priv->menus;
while (link != NULL) {
struct _menu_node *node = link->data;
if (node->free)
- node->free (emp, node->menu, node->data);
+ node->free (E_CONFIG (object), node->menu, node->data);
g_free (node);
link = g_list_delete_link (link, link);
}
- link = p->widgets;
+ link = priv->widgets;
while (link != NULL) {
struct _widget_node *node = link->data;
@@ -153,17 +162,9 @@ config_finalize (GObject *object)
link = g_list_delete_link (link, link);
}
- link = p->checks;
- while (link != NULL) {
- struct _check_node *node = link->data;
+ g_list_free_full (priv->checks, (GDestroyNotify) check_node_free);
- g_free (node->pageid);
- g_free (node);
-
- link = g_list_delete_link (link, link);
- }
-
- link = p->finish_pages;
+ link = priv->finish_pages;
while (link != NULL) {
struct _finish_page_node *node = link->data;
@@ -291,7 +292,7 @@ e_config_add_items (EConfig *ec,
* e_config_add_page_check:
* @ec: Initialised implemeting instance of EConfig.
* @pageid: pageid to check.
- * @check: checking callback.
+ * @func: checking callback.
* @data: user-data for the callback.
*
* Add a page-checking function callback. It will be called to validate the
@@ -308,14 +309,14 @@ e_config_add_items (EConfig *ec,
void
e_config_add_page_check (EConfig *ec,
const gchar *pageid,
- EConfigCheckFunc check,
+ EConfigCheckFunc func,
gpointer data)
{
struct _check_node *cn;
- cn = g_malloc0 (sizeof (*cn));
+ cn = g_slice_new0 (struct _check_node);
cn->pageid = g_strdup (pageid);
- cn->check = check;
+ cn->func = func;
cn->data = data;
ec->priv->checks = g_list_append (ec->priv->checks, cn);
@@ -534,21 +535,26 @@ ec_assistant_forward (gint current_page,
/* Find the next E_CONFIG_PAGE* type node. */
for (link = link->next; link != NULL; link = link->next) {
+ gboolean node_is_page;
+
node = (struct _widget_node *) link->data;
if (node->empty || node->frame == NULL)
continue;
- if (node->item->type == E_CONFIG_PAGE)
- break;
-
- if (node->item->type == E_CONFIG_PAGE_START)
- break;
-
- if (node->item->type == E_CONFIG_PAGE_FINISH)
- break;
+ switch (node->item->type) {
+ case E_CONFIG_PAGE:
+ case E_CONFIG_PAGE_START:
+ case E_CONFIG_PAGE_FINISH:
+ case E_CONFIG_PAGE_PROGRESS:
+ node_is_page = TRUE;
+ break;
+ default:
+ node_is_page = FALSE;
+ break;
+ }
- if (node->item->type == E_CONFIG_PAGE_PROGRESS)
+ if (node_is_page)
break;
}
@@ -1364,7 +1370,7 @@ e_config_page_check (EConfig *config,
if ((pageid == NULL
|| node->pageid == NULL
|| strcmp (node->pageid, pageid) == 0)
- && !node->check (config, pageid, node->data)) {
+ && !node->func (config, pageid, node->data)) {
return FALSE;
}