aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-12-12 03:24:10 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-12-12 03:24:10 +0800
commit35e7a45e0f38140556af85c8791fd9c118dade02 (patch)
treed12988293cf7e8c2dd4863e91911834c408cf674
parenteb8d8f6bc042e34349e2937d2dfdd5d80664a70e (diff)
downloadgsoc2013-evolution-35e7a45e0f38140556af85c8791fd9c118dade02.tar
gsoc2013-evolution-35e7a45e0f38140556af85c8791fd9c118dade02.tar.gz
gsoc2013-evolution-35e7a45e0f38140556af85c8791fd9c118dade02.tar.bz2
gsoc2013-evolution-35e7a45e0f38140556af85c8791fd9c118dade02.tar.lz
gsoc2013-evolution-35e7a45e0f38140556af85c8791fd9c118dade02.tar.xz
gsoc2013-evolution-35e7a45e0f38140556af85c8791fd9c118dade02.tar.zst
gsoc2013-evolution-35e7a45e0f38140556af85c8791fd9c118dade02.zip
Shorten the namespace of some internal functions to just emft.
2003-12-11 Jeffrey Stedfast <fejj@ximian.com> * em-folder-tree.c: Shorten the namespace of some internal functions to just emft. * em-mailer-prefs.c (em_mailer_prefs_construct): Use newv() here and pass an array of GTypes - makes it simpler to change the order of columns later and/or add new columns if we need to. Also makes the line shorter :-) svn path=/trunk/; revision=23926
-rw-r--r--mail/ChangeLog14
-rw-r--r--mail/em-folder-tree.c84
-rw-r--r--mail/em-mailer-prefs.c175
3 files changed, 154 insertions, 119 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 94fc17aa56..0c74c62c50 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,10 +1,20 @@
+2003-12-11 Jeffrey Stedfast <fejj@ximian.com>
+
+ * em-folder-tree.c: Shorten the namespace of some internal
+ functions to just emft.
+
+ * em-mailer-prefs.c (em_mailer_prefs_construct): Use newv() here
+ and pass an array of GTypes - makes it simpler to change the order
+ of columns later and/or add new columns if we need to. Also makes
+ the line shorter :-)
+
2003-12-11 Grahame Bowland <grahame@angrygoats.net>
* em-format-html.c (efh_format_header): display
x-evolution-mailer pseudo header irrespective of
xmailer_mask. This is now handled by a header
configuration dialog.
-
+
* mail-config.glade: add tab to mail configuration
dialog to allow custom headers to be specified for
display.
@@ -43,7 +53,7 @@
the add button to FALSE if the entry box is empty, contains
a duplicate header, or contains an invalid header. Otherwise,
set it to TRUE.
-
+
* evolution-mail.schemas.in.in: add mail/display/headers
2003-12-10 Larry Ewing <lewing@ximian.com>
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 060f121626..4359e7a8f0 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -122,13 +122,13 @@ static void em_folder_tree_init (EMFolderTree *emft);
static void em_folder_tree_destroy (GtkObject *obj);
static void em_folder_tree_finalize (GObject *obj);
-static gboolean em_folder_tree_save_state (EMFolderTree *emft);
-static void em_folder_tree_queue_save_state (EMFolderTree *emft);
+static gboolean emft_save_state (EMFolderTree *emft);
+static void emft_queue_save_state (EMFolderTree *emft);
-static void tree_row_collapsed (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft);
-static void tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft);
-static gboolean tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft);
-static void tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft);
+static void emft_tree_row_collapsed (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft);
+static void emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft);
+static gboolean emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft);
+static void emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft);
static GtkVBoxClass *parent_class = NULL;
@@ -321,7 +321,7 @@ em_folder_tree_destroy (GtkObject *obj)
if (priv->save_state_id != 0) {
g_source_remove (priv->save_state_id);
- em_folder_tree_save_state (emft);
+ emft_save_state (emft);
}
priv->treeview = NULL;
@@ -376,12 +376,12 @@ em_folder_tree_construct (EMFolderTree *emft, EMFolderTreeModel *model)
priv->treeview = folder_tree_new (model);
gtk_widget_show ((GtkWidget *) priv->treeview);
- g_signal_connect (priv->treeview, "row-expanded", G_CALLBACK (tree_row_expanded), emft);
- g_signal_connect (priv->treeview, "row-collapsed", G_CALLBACK (tree_row_collapsed), emft);
- g_signal_connect (priv->treeview, "button-press-event", G_CALLBACK (tree_button_press), emft);
+ g_signal_connect (priv->treeview, "row-expanded", G_CALLBACK (emft_tree_row_expanded), emft);
+ g_signal_connect (priv->treeview, "row-collapsed", G_CALLBACK (emft_tree_row_collapsed), emft);
+ g_signal_connect (priv->treeview, "button-press-event", G_CALLBACK (emft_tree_button_press), emft);
selection = gtk_tree_view_get_selection ((GtkTreeView *) priv->treeview);
- g_signal_connect (selection, "changed", G_CALLBACK (tree_selection_changed), emft);
+ g_signal_connect (selection, "changed", G_CALLBACK (emft_tree_selection_changed), emft);
gtk_container_add ((GtkContainer *) scrolled, (GtkWidget *) priv->treeview);
gtk_widget_show (scrolled);
@@ -410,14 +410,14 @@ struct _gsbn {
};
static void
-get_store_by_name (CamelStore *store, struct _EMFolderTreeModelStoreInfo *si, struct _gsbn *gsbn)
+emft_get_store_by_name (CamelStore *store, struct _EMFolderTreeModelStoreInfo *si, struct _gsbn *gsbn)
{
if (!strcmp (si->display_name, gsbn->name))
gsbn->si = si;
}
static void
-expand_node (const char *key, gpointer value, EMFolderTree *emft)
+emft_expand_node (const char *key, gpointer value, EMFolderTree *emft)
{
struct _EMFolderTreePrivate *priv = emft->priv;
struct _EMFolderTreeModelStoreInfo *si;
@@ -451,7 +451,7 @@ expand_node (const char *key, gpointer value, EMFolderTree *emft)
gsbn.si = NULL;
gsbn.name = id;
- g_hash_table_foreach (priv->model->store_hash, (GHFunc) get_store_by_name, &gsbn);
+ g_hash_table_foreach (priv->model->store_hash, (GHFunc) emft_get_store_by_name, &gsbn);
if (!(si = gsbn.si)) {
g_free (id);
return;
@@ -473,7 +473,7 @@ expand_node (const char *key, gpointer value, EMFolderTree *emft)
static void
-loading_row_cb (EMFolderTreeModel *model, GtkTreePath *tree_path, GtkTreeIter *iter, EMFolderTree *emft)
+emft_loading_row_cb (EMFolderTreeModel *model, GtkTreePath *tree_path, GtkTreeIter *iter, EMFolderTree *emft)
{
struct _EMFolderTreeModelStoreInfo *si;
CamelStore *store;
@@ -509,9 +509,9 @@ em_folder_tree_new_with_model (EMFolderTreeModel *model)
g_object_ref (model);
/* FIXME: this sucks... */
- g_hash_table_foreach (model->expanded, (GHFunc) expand_node, emft);
+ g_hash_table_foreach (model->expanded, (GHFunc) emft_expand_node, emft);
- emft->priv->loading_row_id = g_signal_connect (model, "loading-row", G_CALLBACK (loading_row_cb), emft);
+ emft->priv->loading_row_id = g_signal_connect (model, "loading-row", G_CALLBACK (emft_loading_row_cb), emft);
return (GtkWidget *) emft;
}
@@ -570,7 +570,7 @@ struct _EMFolderTreeGetFolderInfo {
};
static void
-em_folder_tree_get_folder_info__get (struct _mail_msg *mm)
+emft_get_folder_info__get (struct _mail_msg *mm)
{
struct _EMFolderTreeGetFolderInfo *m = (struct _EMFolderTreeGetFolderInfo *) mm;
guint32 flags = m->flags;
@@ -582,7 +582,7 @@ em_folder_tree_get_folder_info__get (struct _mail_msg *mm)
}
static void
-em_folder_tree_get_folder_info__got (struct _mail_msg *mm)
+emft_get_folder_info__got (struct _mail_msg *mm)
{
struct _EMFolderTreeGetFolderInfo *m = (struct _EMFolderTreeGetFolderInfo *) mm;
struct _EMFolderTreePrivate *priv = m->emft->priv;
@@ -648,11 +648,11 @@ em_folder_tree_get_folder_info__got (struct _mail_msg *mm)
if (m->select_uri)
em_folder_tree_set_selected (m->emft, m->select_uri);
- em_folder_tree_queue_save_state (m->emft);
+ emft_queue_save_state (m->emft);
}
static void
-em_folder_tree_get_folder_info__free (struct _mail_msg *mm)
+emft_get_folder_info__free (struct _mail_msg *mm)
{
struct _EMFolderTreeGetFolderInfo *m = (struct _EMFolderTreeGetFolderInfo *) mm;
@@ -666,13 +666,13 @@ em_folder_tree_get_folder_info__free (struct _mail_msg *mm)
static struct _mail_msg_op get_folder_info_op = {
NULL,
- em_folder_tree_get_folder_info__get,
- em_folder_tree_get_folder_info__got,
- em_folder_tree_get_folder_info__free,
+ emft_get_folder_info__get,
+ emft_get_folder_info__got,
+ emft_get_folder_info__free,
};
static void
-update_model_expanded_state (struct _EMFolderTreePrivate *priv, GtkTreeIter *iter, gboolean expanded)
+emft_update_model_expanded_state (struct _EMFolderTreePrivate *priv, GtkTreeIter *iter, gboolean expanded)
{
struct _EMFolderTreeModelStoreInfo *si;
CamelStore *store;
@@ -696,7 +696,7 @@ update_model_expanded_state (struct _EMFolderTreePrivate *priv, GtkTreeIter *ite
}
static void
-tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *tree_path, EMFolderTree *emft)
+emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *tree_path, EMFolderTree *emft)
{
struct _EMFolderTreePrivate *priv = emft->priv;
struct _EMFolderTreeGetFolderInfo *m;
@@ -714,7 +714,7 @@ tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *tree_p
COL_BOOL_LOAD_SUBDIRS, &load,
-1);
- update_model_expanded_state (priv, root, TRUE);
+ emft_update_model_expanded_state (priv, root, TRUE);
if (!load) {
em_folder_tree_queue_save_state (emft);
@@ -739,9 +739,9 @@ tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *tree_p
}
static void
-tree_row_collapsed (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *tree_path, EMFolderTree *emft)
+emft_tree_row_collapsed (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *tree_path, EMFolderTree *emft)
{
- update_model_expanded_state (emft->priv, root, FALSE);
+ emft_update_model_expanded_state (emft->priv, root, FALSE);
em_folder_tree_queue_save_state (emft);
}
@@ -773,7 +773,7 @@ struct _EMCopyFolders {
};
static void
-em_copy_folders__copy (struct _mail_msg *mm)
+emft_copy_folders__copy (struct _mail_msg *mm)
{
struct _EMCopyFolders *m = (struct _EMCopyFolders *) mm;
guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE;
@@ -877,7 +877,7 @@ em_copy_folders__copy (struct _mail_msg *mm)
}
static void
-em_copy_folders__free (struct _mail_msg *mm)
+emft_copy_folders__free (struct _mail_msg *mm)
{
struct _EMCopyFolders *m = (struct _EMCopyFolders *) mm;
@@ -890,13 +890,13 @@ em_copy_folders__free (struct _mail_msg *mm)
static struct _mail_msg_op copy_folders_op = {
NULL,
- em_copy_folders__copy,
+ emft_copy_folders__copy,
NULL,
- em_copy_folders__free,
+ emft_copy_folders__free,
};
static void
-em_copy_folders (CamelStore *tostore, const char *tobase, CamelStore *fromstore, const char *frombase, int delete)
+emft_copy_folders (CamelStore *tostore, const char *tobase, CamelStore *fromstore, const char *frombase, int delete)
{
struct _EMCopyFolders *m;
@@ -956,7 +956,7 @@ emft_popup_copy_folder_selected (const char *uri, void *data)
else
tobase = "";
- em_copy_folders (tostore, tobase, fromstore, frombase, cfd->delete);
+ emft_copy_folders (tostore, tobase, fromstore, frombase, cfd->delete);
camel_url_free (url);
g_free (cfd);
@@ -1121,9 +1121,11 @@ emft_popup_delete_rec (CamelStore *store, CamelFolderInfo *fi, CamelException *e
camel_folder_freeze (folder);
for (i = 0; i < uids->len; i++)
camel_folder_delete_message (folder, uids->pdata[i]);
+
+ camel_folder_free_uids (folder, uids);
+
camel_folder_sync (folder, TRUE, NULL);
camel_folder_thaw (folder);
- camel_folder_free_uids (folder, uids);
}
camel_store_delete_folder (store, fi->full_name, ex);
@@ -1504,7 +1506,7 @@ static EMPopupItem emft_popup_menu[] = {
};
static gboolean
-tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft)
+emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft)
{
GSList *menus = NULL;
GtkMenu *menu;
@@ -1540,7 +1542,7 @@ tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emf
static void
-tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft)
+emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft)
{
struct _EMFolderTreePrivate *priv = emft->priv;
GtkTreeModel *model;
@@ -1685,7 +1687,7 @@ em_folder_tree_get_model (EMFolderTree *emft)
static gboolean
-em_folder_tree_save_state (EMFolderTree *emft)
+emft_save_state (EMFolderTree *emft)
{
struct _EMFolderTreePrivate *priv = emft->priv;
@@ -1697,12 +1699,12 @@ em_folder_tree_save_state (EMFolderTree *emft)
static void
-em_folder_tree_queue_save_state (EMFolderTree *emft)
+emft_queue_save_state (EMFolderTree *emft)
{
struct _EMFolderTreePrivate *priv = emft->priv;
if (priv->save_state_id != 0)
return;
- priv->save_state_id = g_timeout_add (1000, (GSourceFunc) em_folder_tree_save_state, emft);
+ priv->save_state_id = g_timeout_add (1000, (GSourceFunc) emft_save_state, emft);
}
diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c
index 2143f78667..8c6cbabec1 100644
--- a/mail/em-mailer-prefs.c
+++ b/mail/em-mailer-prefs.c
@@ -52,6 +52,13 @@ enum {
HEADER_LIST_N_COLUMNS,
};
+static GType col_types[] = {
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ G_TYPE_STRING
+};
+
/* temporarily copied from em-format.c */
static const struct {
const char *name;
@@ -256,14 +263,16 @@ static gboolean
emmp_header_is_valid (const char *header)
{
const char *p = header;
-
- if (strlen (header) == 0)
+
+ if (header[0] == 0)
return FALSE;
+
while (*p) {
if ((*p == ':') || (*p == ' '))
return FALSE;
p++;
}
+
return TRUE;
}
@@ -273,7 +282,7 @@ emmp_header_add_sensitivity (EMMailerPrefs *prefs)
const char *entry_contents;
GtkTreeIter iter;
gboolean valid;
-
+
/* the add header button should be sensitive if the text box contains
a valid header string, that is not a duplicate with something already
in the list view
@@ -283,20 +292,23 @@ emmp_header_add_sensitivity (EMMailerPrefs *prefs)
gtk_widget_set_sensitive (GTK_WIDGET (prefs->add_header), FALSE);
return;
}
+
/* check if this is a duplicate */
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (prefs->header_list_store), &iter);
while (valid) {
char *header_name;
-
+
gtk_tree_model_get (GTK_TREE_MODEL (prefs->header_list_store), &iter,
HEADER_LIST_HEADER_COLUMN, &header_name,
-1);
if (g_ascii_strcasecmp (header_name, entry_contents) == 0) {
- gtk_widget_set_sensitive (GTK_WIDGET(prefs->add_header), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->add_header), FALSE);
return;
}
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(prefs->header_list_store), &iter);
+
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (prefs->header_list_store), &iter);
}
+
gtk_widget_set_sensitive (GTK_WIDGET (prefs->add_header), TRUE);
}
@@ -308,14 +320,14 @@ emmp_header_list_enabled_toggled (GtkCellRendererToggle *cell, const char *path_
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
GtkTreeIter iter;
int enabled;
-
+
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, HEADER_LIST_ENABLED_COLUMN, &enabled, -1);
enabled = !enabled;
gtk_list_store_set (GTK_LIST_STORE (model), &iter, HEADER_LIST_ENABLED_COLUMN,
- enabled, -1);
+ enabled, -1);
gtk_tree_path_free (path);
-
+
if (prefs->control)
evolution_config_control_changed (prefs->control);
}
@@ -326,18 +338,18 @@ emmp_header_add_header (GtkWidget *widget, gpointer user_data)
EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
GtkTreeModel *model = GTK_TREE_MODEL (prefs->header_list_store);
GtkTreeIter iter;
-
- gtk_list_store_append(GTK_LIST_STORE (model), &iter);
- gtk_list_store_set(GTK_LIST_STORE (model), &iter,
- HEADER_LIST_NAME_COLUMN, gtk_entry_get_text (prefs->entry_header),
- HEADER_LIST_ENABLED_COLUMN, TRUE,
- HEADER_LIST_HEADER_COLUMN, gtk_entry_get_text (prefs->entry_header),
- HEADER_LIST_IS_DEFAULT_COLUMN, FALSE,
- -1);
+
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ HEADER_LIST_NAME_COLUMN, gtk_entry_get_text (prefs->entry_header),
+ HEADER_LIST_ENABLED_COLUMN, TRUE,
+ HEADER_LIST_HEADER_COLUMN, gtk_entry_get_text (prefs->entry_header),
+ HEADER_LIST_IS_DEFAULT_COLUMN, FALSE,
+ -1);
gtk_entry_set_text (prefs->entry_header, "");
emmp_header_remove_sensitivity (prefs);
emmp_header_add_sensitivity (prefs);
-
+
if (prefs->control)
evolution_config_control_changed (prefs->control);
}
@@ -362,7 +374,7 @@ static void
emmp_header_list_row_selected (GtkTreeSelection *selection, gpointer user_data)
{
EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
-
+
emmp_header_remove_sensitivity (prefs);
}
@@ -370,26 +382,24 @@ static void
emmp_header_entry_changed (GtkWidget *entry, gpointer user_data)
{
EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
-
+
emmp_header_add_sensitivity (prefs);
}
static void
em_mailer_prefs_construct (EMMailerPrefs *prefs)
{
+ GSList *list, *header_config_list, *header_add_list, *p;
+ GHashTable *default_header_hash;
GtkWidget *toplevel, *menu;
- GSList *list;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer;
+ GtkTreeIter iter;
+ char *font, *buf;
GladeXML *gui;
gboolean bool;
- char *font, *buf;
- int i, val;
- GSList *header_config_list, *header_add_list, *p;
- GtkTreeIter iter;
- GHashTable *default_header_hash;
- GtkTreeSelection *selection;
- GtkCellRenderer *header_list_name_renderer;
- GtkCellRenderer *header_list_enabled_renderer;
-
+ int val, i;
+
gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "preferences_tab", NULL);
prefs->gui = gui;
@@ -481,11 +491,11 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
gtk_toggle_button_set_active (prefs->font_share, !bool);
g_signal_connect (prefs->font_share, "toggled", G_CALLBACK (font_share_changed), prefs);
font_share_changed (GTK_WIDGET (prefs->font_share), prefs);
-
+
/* HTML Mail tab */
/* Loading Images */
-
+
val = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/display/load_http_images", NULL);
prefs->images_never = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radImagesNever"));
gtk_toggle_button_set_active (prefs->images_never, val == MAIL_CONFIG_HTTP_NEVER);
@@ -537,7 +547,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
prefs->restore_labels = GTK_BUTTON (glade_xml_get_widget (gui, "cmdRestoreLabels"));
g_signal_connect (prefs->restore_labels, "clicked", G_CALLBACK (restore_labels_clicked), prefs);
-
+
/* headers */
prefs->add_header = GTK_BUTTON (glade_xml_get_widget (gui, "cmdHeadersAdd"));
prefs->remove_header = GTK_BUTTON (glade_xml_get_widget (gui, "cmdHeadersRemove"));
@@ -548,24 +558,24 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
g_signal_connect (prefs->entry_header, "changed", G_CALLBACK (emmp_header_entry_changed), prefs);
g_signal_connect (prefs->entry_header, "activate", G_CALLBACK (emmp_header_add_header), prefs);
/* initialise the tree with appropriate headings */
- prefs->header_list_store = gtk_list_store_new (HEADER_LIST_N_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING);
+ prefs->header_list_store = gtk_list_store_newv (HEADER_LIST_N_COLUMNS, col_types);
g_signal_connect (prefs->add_header, "clicked", G_CALLBACK (emmp_header_add_header), prefs);
g_signal_connect (prefs->remove_header, "clicked", G_CALLBACK (emmp_header_remove_header), prefs);
gtk_tree_view_set_model (prefs->header_list, GTK_TREE_MODEL (prefs->header_list_store));
-
- header_list_enabled_renderer = gtk_cell_renderer_toggle_new ();
- g_object_set (header_list_enabled_renderer, "activatable", TRUE, NULL);
- g_signal_connect (header_list_enabled_renderer, "toggled", G_CALLBACK (emmp_header_list_enabled_toggled), prefs);
+
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_object_set (renderer, "activatable", TRUE, NULL);
+ g_signal_connect (renderer, "toggled", G_CALLBACK (emmp_header_list_enabled_toggled), prefs);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (prefs->header_list), -1,
- "Enabled", header_list_enabled_renderer,
+ "Enabled", renderer,
"active", HEADER_LIST_ENABLED_COLUMN,
NULL);
- header_list_name_renderer = gtk_cell_renderer_text_new ();
+ renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (prefs->header_list), -1,
- "Name", header_list_name_renderer,
+ "Name", renderer,
"text", HEADER_LIST_NAME_COLUMN,
NULL);
-
+
/* populated the listview with entries; firstly we add all the default headers, and then
we add read header configuration out of gconf. If a header in gconf is a default header,
we update the enabled flag accordingly
@@ -574,52 +584,54 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
default_header_hash = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < sizeof (default_headers) / sizeof (default_headers[0]); i++) {
struct _EMMailerPrefsHeader *h;
-
-
+
h = g_malloc (sizeof (struct _EMMailerPrefsHeader));
h->is_default = TRUE;
- h->name = g_strdup(default_headers[i].name);
+ h->name = g_strdup (default_headers[i].name);
if (g_ascii_strcasecmp (default_headers[i].name, EM_FORMAT_HEADER_XMAILER) == 0)
h->enabled = FALSE;
else
h->enabled = TRUE;
- g_hash_table_insert (default_header_hash, (gpointer)default_headers[i].name, h);
+ g_hash_table_insert (default_header_hash, (gpointer) default_headers[i].name, h);
header_add_list = g_slist_append (header_add_list, h);
}
-
+
/* read stored headers from gconf */
header_config_list = gconf_client_get_list (prefs->gconf, "/apps/evolution/mail/display/headers", GCONF_VALUE_STRING, NULL);
p = header_config_list;
while (p) {
- char *xml = (char *)p->data;
struct _EMMailerPrefsHeader *h, *def;
-
+ char *xml = (char *) p->data;
+
h = em_mailer_prefs_header_from_xml (xml);
if (h) {
- def = (struct _EMMailerPrefsHeader *)g_hash_table_lookup (default_header_hash, h->name);
+ def = g_hash_table_lookup (default_header_hash, h->name);
if (def) {
def->enabled = h->enabled;
- em_mailer_prefs_header_free(h);
+ em_mailer_prefs_header_free (h);
} else {
h->is_default = FALSE;
header_add_list = g_slist_append (header_add_list, h);
}
}
- p = g_slist_next (p);
+
+ p = p->next;
}
+
g_hash_table_destroy (default_header_hash);
g_slist_foreach (header_config_list, (GFunc) g_free, NULL);
g_slist_free (header_config_list);
-
+
p = header_add_list;
while (p) {
- struct _EMMailerPrefsHeader *h = (struct _EMMailerPrefsHeader *)p->data;
+ struct _EMMailerPrefsHeader *h = (struct _EMMailerPrefsHeader *) p->data;
const char *name;
-
+
if (g_ascii_strcasecmp (h->name, EM_FORMAT_HEADER_XMAILER) == 0)
name = _("Mailer");
else
name = _(h->name);
+
gtk_list_store_append (prefs->header_list_store, &iter);
gtk_list_store_set (prefs->header_list_store, &iter,
HEADER_LIST_NAME_COLUMN, name,
@@ -627,12 +639,14 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
HEADER_LIST_IS_DEFAULT_COLUMN, h->is_default,
HEADER_LIST_HEADER_COLUMN, h->name,
-1);
- em_mailer_prefs_header_free(h);
- p = g_slist_next(p);
+
+ em_mailer_prefs_header_free (h);
+ p = p->next;
}
+
g_slist_free (header_add_list);
emmp_header_remove_sensitivity (prefs);
-
+
/* Junk prefs */
prefs->check_incoming = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkCheckIncomingMail"));
bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/check_incoming", NULL);
@@ -750,7 +764,7 @@ em_mailer_prefs_apply (EMMailerPrefs *prefs)
g_slist_free_1 (l);
l = n;
}
-
+
/* Headers */
header_list = NULL;
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (prefs->header_list_store), &iter);
@@ -758,17 +772,19 @@ em_mailer_prefs_apply (EMMailerPrefs *prefs)
struct _EMMailerPrefsHeader h;
gboolean enabled;
char *xml;
-
+
gtk_tree_model_get (GTK_TREE_MODEL (prefs->header_list_store), &iter,
HEADER_LIST_HEADER_COLUMN, &h.name,
HEADER_LIST_ENABLED_COLUMN, &enabled,
-1);
h.enabled = enabled;
- xml = em_mailer_prefs_header_to_xml (&h);
- if (xml != NULL)
+
+ if ((xml = em_mailer_prefs_header_to_xml (&h)))
header_list = g_slist_append (header_list, xml);
+
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (prefs->header_list_store), &iter);
}
+
gconf_client_set_list (prefs->gconf, "/apps/evolution/mail/display/headers", GCONF_VALUE_STRING, header_list, NULL);
g_slist_foreach (header_list, (GFunc) g_free, NULL);
g_slist_free (header_list);
@@ -776,32 +792,37 @@ em_mailer_prefs_apply (EMMailerPrefs *prefs)
/* junk prefs */
gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/junk/check_incoming",
gtk_toggle_button_get_active (prefs->check_incoming), NULL);
-
+
gconf_client_suggest_sync (prefs->gconf, NULL);
}
static struct _EMMailerPrefsHeader *
emmp_header_from_xmldoc (xmlDocPtr doc)
{
+ struct _EMMailerPrefsHeader *h;
xmlNodePtr root;
xmlChar *name;
- struct _EMMailerPrefsHeader *h;
-
+
if (doc == NULL)
return NULL;
+
root = doc->children;
if (strcmp (root->name, "header") != 0)
return NULL;
+
name = xmlGetProp (root, "name");
if (name == NULL)
return NULL;
+
h = g_malloc0 (sizeof (struct _EMMailerPrefsHeader));
h->name = g_strdup (name);
xmlFree (name);
+
if (xmlHasProp (root, "enabled"))
h->enabled = 1;
else
h->enabled = 0;
+
return h;
}
@@ -817,14 +838,15 @@ emmp_header_from_xmldoc (xmlDocPtr doc)
struct _EMMailerPrefsHeader *
em_mailer_prefs_header_from_xml (const char *xml)
{
- xmlDocPtr doc;
struct _EMMailerPrefsHeader *header;
-
- doc = xmlParseDoc ((char *)xml);
- if (doc == NULL)
+ xmlDocPtr doc;
+
+ if (!(doc = xmlParseDoc ((char *) xml)))
return NULL;
+
header = emmp_header_from_xmldoc (doc);
xmlFreeDoc (doc);
+
return header;
}
@@ -840,6 +862,7 @@ em_mailer_prefs_header_free (struct _EMMailerPrefsHeader *header)
{
if (header == NULL)
return;
+
g_free (header->name);
g_free (header);
}
@@ -859,25 +882,25 @@ em_mailer_prefs_header_to_xml (struct _EMMailerPrefsHeader *header)
xmlChar *xml;
char *out;
int size;
-
+
g_return_val_if_fail (header != NULL, NULL);
g_return_val_if_fail (header->name != NULL, NULL);
-
+
doc = xmlNewDoc ("1.0");
-
+
root = xmlNewDocNode (doc, NULL, "header", NULL);
xmlSetProp (root, "name", header->name);
if (header->enabled)
xmlSetProp (root, "enabled", NULL);
-
+
xmlDocSetRootElement (doc, root);
xmlDocDumpMemory (doc, &xml, &size);
xmlFreeDoc (doc);
-
+
out = g_malloc (size + 1);
memcpy (out, xml, size);
- out[size] = 0;
+ out[size] = '\0';
xmlFree (xml);
-
+
return out;
}