aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJP Rosevear <jpr@helixcode.com>2000-08-12 00:13:15 +0800
committerJP Rosevear <jpr@src.gnome.org>2000-08-12 00:13:15 +0800
commit64c6a63cf22abea49895554cb7a058adc30cd0fc (patch)
tree5e76ba21e91c467caf9e408a77b8da7af3fa5b80 /mail
parent562e6437b548f354f071d2430c62abc00f715270 (diff)
downloadgsoc2013-evolution-64c6a63cf22abea49895554cb7a058adc30cd0fc.tar.gz
gsoc2013-evolution-64c6a63cf22abea49895554cb7a058adc30cd0fc.tar.zst
gsoc2013-evolution-64c6a63cf22abea49895554cb7a058adc30cd0fc.zip
Check nrow, not srow.
2000-08-11 JP Rosevear <jpr@helixcode.com> * mail-config-gui.c (news_edit_clicked): Check nrow, not srow. svn path=/trunk/; revision=4738
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog33
-rw-r--r--mail/component-factory.c20
-rw-r--r--mail/mail-config-gui.c135
-rw-r--r--mail/mail-config.c118
-rw-r--r--mail/mail-config.glade2
-rw-r--r--mail/mail-config.h37
-rw-r--r--mail/mail-format.c4
7 files changed, 230 insertions, 119 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 385e627545..78fa34e912 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,36 @@
+2000-08-11 JP Rosevear <jpr@helixcode.com>
+
+ * mail-config-gui.c (news_edit_clicked): Check nrow, not srow.
+
+2000-08-11 JP Rosevear <jpr@helixcode.com>
+
+ * mail-config-gui.c (service_acceptable): Use camel_object_unref
+ instead of gtk_object_unref
+ (mail_druid_finish): Use new config accessors
+ (mail_config_druid): No need to call config functions
+ (news_add_clicked): Increments maxnrow, not maxsrow
+ (mail_config_apply_clicked): Use new config accessors
+ (mail_config): ditto
+
+ * component-factory.c (create_imap_storage): Use new
+ config accessors
+ (create_news_storage): ditto
+
+ * mail-config.glade: Set news clist name correctly
+
+ * mail-config.c (config_read): Rename from mail_config_read and
+ made private - no one should need to do a read manually.
+ (mail_config_set_send_html): New accessor
+ (mail_config_add_identity): ditto
+ (mail_config_get_sources): ditto
+ (mail_config_add_source): ditto
+ (mail_config_get_default_news): ditto
+ (mail_config_get_news): ditto
+ (mail_config_add_news): ditto
+
+ * mail-config.h: Prototype new accessors. Config struct is now
+ in mail-config.c and hidden from the world.
+
2000-08-11 Dan Winship <danw@helixcode.com>
* mail-ops.c (describe_fetch_mail): Use camel_service_get_name
diff --git a/mail/component-factory.c b/mail/component-factory.c
index a88d4e6619..ac35ca8556 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -189,18 +189,15 @@ create_vfolder_storage (EvolutionShellComponent *shell_component)
static void
create_imap_storage (EvolutionShellComponent *shell_component)
{
- const MailConfig *config;
+ const MailConfigService *s;
EvolutionShellClient *shell_client;
Evolution_Shell corba_shell;
EvolutionStorage *storage;
char *source = NULL, *server, *p;
-
- config = mail_config_fetch ();
- if (config->sources) {
- const MailConfigService *s;
- s = (MailConfigService *)config->sources->data;
+
+ s = mail_config_get_default_source ();
+ if (s)
source = s->url;
- }
if (!source || g_strncasecmp (source, "imap://", 7))
return;
@@ -238,18 +235,15 @@ create_imap_storage (EvolutionShellComponent *shell_component)
static void
create_news_storage (EvolutionShellComponent *shell_component)
{
- const MailConfig *config;
+ const MailConfigService *s;
EvolutionShellClient *shell_client;
Evolution_Shell corba_shell;
EvolutionStorage *storage;
char *source=NULL, *server, *p;
- config = mail_config_fetch ();
- if (config->news) {
- const MailConfigService *s;
- s = (MailConfigService *)config->news->data;
+ s = mail_config_get_default_news ();
+ if (s)
source = s->url;
- }
if (!source || g_strncasecmp (source, "news://", 7))
return;
diff --git a/mail/mail-config-gui.c b/mail/mail-config-gui.c
index d7520efb23..9b0481c5f4 100644
--- a/mail/mail-config-gui.c
+++ b/mail/mail-config-gui.c
@@ -162,7 +162,7 @@ typedef struct
GtkWidget *clistSources;
gint srow;
gint maxsrow;
- GtkWidget *clistNewsServers;
+ GtkWidget *clistNews;
gint nrow;
gint maxnrow;
MailDialogTransportPage *page;
@@ -745,7 +745,7 @@ service_acceptable (MailDialogServicePage *page)
if (camel_service_connect (service, ex)) {
camel_service_disconnect (service, ex);
- gtk_object_unref (GTK_OBJECT (service));
+ camel_object_unref (CAMEL_OBJECT (service));
camel_exception_free (ex);
info_dialog (page->vbox, "Connection successful!");
@@ -1216,8 +1216,9 @@ identity_dialog (const MailConfigIdentity *id, GtkWidget *parent)
iddialog->dialog = gnome_dialog_new (_("Add Identity"), NULL);
gtk_window_set_modal (GTK_WINDOW (iddialog->dialog), TRUE);
+ gtk_window_set_default_size (GTK_WINDOW (sdialog->dialog), 380, 450);
gtk_window_set_policy (GTK_WINDOW (iddialog->dialog),
- TRUE, TRUE, FALSE);
+ FALSE, TRUE, FALSE);
gnome_dialog_set_parent (GNOME_DIALOG (iddialog->dialog),
GTK_WINDOW (parent));
@@ -1313,7 +1314,7 @@ source_dialog (MailConfigService *source, GtkWidget *parent)
gtk_window_set_modal (GTK_WINDOW (sdialog->dialog), TRUE);
gtk_window_set_policy (GTK_WINDOW (sdialog->dialog),
- TRUE, TRUE, FALSE);
+ FALSE, FALSE, FALSE);
gtk_window_set_default_size (GTK_WINDOW (sdialog->dialog), 380, 450);
gnome_dialog_set_parent (GNOME_DIALOG (sdialog->dialog),
GTK_WINDOW (parent));
@@ -1546,23 +1547,23 @@ static void
mail_druid_finish (GnomeDruidPage *page, GnomeDruid *druid,
MailDruidDialog *dialog)
{
- MailConfig *config;
MailConfigIdentity *id;
MailConfigService *source;
+ MailConfigService *transport;
mail_config_clear ();
- config = mail_config_fetch ();
/* Identity */
id = identity_page_extract (dialog->idpage);
- config->ids = g_slist_append (config->ids, id);
+ mail_config_add_identity (id);
/* Source */
source = service_page_extract (dialog->spage->page);
- config->sources = g_slist_append (config->sources, source);
+ mail_config_add_source (source);
/* Transport */
- config->transport = service_page_extract (dialog->tpage->page);
+ transport = service_page_extract (dialog->tpage->page);
+ mail_config_set_transport (transport);
mail_config_write ();
@@ -1572,7 +1573,6 @@ mail_druid_finish (GnomeDruidPage *page, GnomeDruid *druid,
void
mail_config_druid (void)
{
- MailConfig *config;
MailDruidDialog *dialog;
GnomeDruidPageStart *spage;
GnomeDruidPageFinish *fpage;
@@ -1581,9 +1581,6 @@ mail_config_druid (void)
GdkImlibImage *mail_logo, *identity_logo;
GdkImlibImage *source_logo, *transport_logo;
- mail_config_read ();
- config = mail_config_fetch ();
-
provider_list (&sources, &news, &transports);
mail_logo = load_image ("evolution-inbox.png");
@@ -1858,7 +1855,7 @@ news_add_clicked (GtkWidget *widget, MailDialog *dialog)
news = news_dialog (NULL, dialog->dialog);
if (news) {
- GtkCList *clist = GTK_CLIST (dialog->clistNewsServers);
+ GtkCList *clist = GTK_CLIST (dialog->clistNews);
gchar *text[1];
gint row = 0;
@@ -1867,7 +1864,7 @@ news_add_clicked (GtkWidget *widget, MailDialog *dialog)
row = gtk_clist_append (clist, text);
gtk_clist_set_row_data (clist, row, news);
gtk_clist_select_row (clist, row, 0);
- dialog->maxsrow++;
+ dialog->maxnrow++;
gnome_property_box_changed (GNOME_PROPERTY_BOX (dialog->dialog));
}
@@ -1878,15 +1875,15 @@ news_edit_clicked (GtkWidget *widget, MailDialog *dialog)
{
MailConfigService *news, *news2;
- if (dialog->srow < 0)
+ if (dialog->nrow < 0)
return;
- news = gtk_clist_get_row_data (GTK_CLIST (dialog->clistNewsServers),
+ news = gtk_clist_get_row_data (GTK_CLIST (dialog->clistNews),
dialog->srow);
news2 = source_dialog (news, dialog->dialog);
if (news2) {
- GtkCList *clist = GTK_CLIST (dialog->clistNewsServers);
+ GtkCList *clist = GTK_CLIST (dialog->clistNews);
gtk_clist_set_text (clist, dialog->nrow, 0, news2->url);
gtk_clist_set_row_data (clist, dialog->nrow, news2);
@@ -1904,7 +1901,7 @@ news_delete_clicked (GtkWidget *widget, MailDialog *dialog)
if (dialog->nrow == -1)
return;
- clist = GTK_CLIST (dialog->clistNewsServers);
+ clist = GTK_CLIST (dialog->clistNews);
gtk_clist_remove (clist, dialog->nrow);
dialog->maxnrow--;
@@ -1940,10 +1937,14 @@ format_toggled (GtkWidget *widget, MailDialog *dialog)
}
static void
-mail_config_apply_clicked (GnomePropertyBox *property_box, gint page_num,
+mail_config_apply_clicked (GnomePropertyBox *property_box,
+ gint page_num,
MailDialog *dialog)
{
- MailConfig *config;
+ GtkCList *clist;
+ GtkToggleButton *chk;
+ MailConfigService *t;
+ gboolean send_html;
gpointer data;
int i;
@@ -1951,25 +1952,39 @@ mail_config_apply_clicked (GnomePropertyBox *property_box, gint page_num,
return;
mail_config_clear ();
- config = mail_config_fetch ();
/* Identities */
for (i = 0; i <= dialog->maxidrow; i++) {
- data = gtk_clist_get_row_data (GTK_CLIST (dialog->clistIdentities), i);
- config->ids = g_slist_append (config->ids, data);
+ clist = GTK_CLIST (dialog->clistIdentities);
+
+ data = gtk_clist_get_row_data (clist, i);
+ mail_config_add_identity ((MailConfigIdentity *) data);
}
/* Sources */
for (i = 0; i <= dialog->maxsrow; i++) {
- data = gtk_clist_get_row_data (GTK_CLIST (dialog->clistSources), i);
- config->sources = g_slist_append (config->sources, data);
+ clist = GTK_CLIST (dialog->clistSources);
+
+ data = gtk_clist_get_row_data (clist, i);
+ mail_config_add_source ((MailConfigService *) data);
}
/* Transport */
- config->transport = service_page_extract (dialog->page->page);
+ t = service_page_extract (dialog->page->page);
+ mail_config_set_transport (t);
+
+ /* News */
+ for (i = 0; i <= dialog->maxnrow; i++) {
+ clist = GTK_CLIST (dialog->clistNews);
+
+ data = gtk_clist_get_row_data (clist, i);
+ mail_config_add_news ((MailConfigService *) data);
+ }
/* Format */
- config->send_html = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->chkFormat));
+ chk = GTK_TOGGLE_BUTTON (dialog->chkFormat);
+ send_html = gtk_toggle_button_get_active (chk);
+ mail_config_set_send_html (send_html);
mail_config_write ();
}
@@ -1977,16 +1992,12 @@ mail_config_apply_clicked (GnomePropertyBox *property_box, gint page_num,
void
mail_config (void)
{
- MailConfig *config;
MailDialog *dialog;
GladeXML *gui;
+ MailConfigService *transport;
GtkCList *clist;
GtkWidget *button, *tvbox;
- GSList *sources, *news, *transports;
- gint len, row;
-
- mail_config_read ();
- config = mail_config_fetch ();
+ GSList *l, *sources, *news, *transports;
provider_list (&sources, &news, &transports);
@@ -2002,25 +2013,27 @@ mail_config (void)
clist = GTK_CLIST (dialog->clistIdentities);
gtk_clist_set_column_width (clist, 0, 80);
- len = g_slist_length (config->ids);
- for (row = 0; row < len; row++) {
+ l = mail_config_get_identities ();
+
+ dialog->maxidrow = g_slist_length (l) - 1;
+ dialog->idrow = -1;
+
+ for (; l != NULL; l = l->next) {
MailConfigIdentity *id;
+ gint row;
gchar *text[4];
- id = identity_copy ((MailConfigIdentity *)
- g_slist_nth_data (config->ids, row));
+ id = identity_copy ((MailConfigIdentity *)l->data);
text[0] = id->name;
text[1] = id->address;
text[2] = id->org;
text[3] = id->sig;
- gtk_clist_append (clist, text);
+ row = gtk_clist_append (clist, text);
gtk_clist_set_row_data (clist, row, id);
}
- dialog->maxidrow = len - 1;
- dialog->idrow = -1;
gtk_signal_connect (GTK_OBJECT (clist), "select_row",
GTK_SIGNAL_FUNC (identities_select_row),
dialog);
@@ -2043,21 +2056,24 @@ mail_config (void)
clist = GTK_CLIST (dialog->clistSources);
gtk_clist_set_column_width (clist, 0, 80);
- len = g_slist_length (config->sources);
- for (row = 0; row < len; row++) {
+ l = mail_config_get_sources ();
+
+ dialog->maxsrow = g_slist_length (l) - 1;
+ dialog->srow = -1;
+
+ for (; l != NULL; l = l->next) {
MailConfigService *source;
+ gint row;
gchar *text[1];
- source = service_copy ((MailConfigService *)g_slist_nth_data (config->sources, row));
+ source = service_copy ((MailConfigService *)l->data);
text[0] = source->url;
- gtk_clist_append (clist, text);
+ row = gtk_clist_append (clist, text);
gtk_clist_set_row_data (clist, row, source);
}
- dialog->maxsrow = len - 1;
- dialog->srow = -1;
gtk_signal_connect (GTK_OBJECT (clist), "select_row",
GTK_SIGNAL_FUNC (sources_select_row),
dialog);
@@ -2076,26 +2092,28 @@ mail_config (void)
dialog);
/* News Page */
- dialog->clistNewsServers = glade_xml_get_widget (gui, "clistNewsServers");
- clist = GTK_CLIST (dialog->clistNewsServers);
+ dialog->clistNews = glade_xml_get_widget (gui, "clistNews");
+ clist = GTK_CLIST (dialog->clistNews);
gtk_clist_set_column_width (clist, 0, 80);
- len = g_slist_length (config->news);
- for (row=0; row<len; row++) {
+ l = mail_config_get_news ();
+
+ dialog->maxnrow = g_slist_length (l) - 1;
+ dialog->nrow = -1;
+
+ for (; l != NULL; l = l->next) {
MailConfigService *news;
+ gint row;
gchar *text[1];
- news = service_copy ((MailConfigService *)
- g_slist_nth_data (config->news, row));
+ news = service_copy ((MailConfigService *)l->data);
text[0] = news->url;
- gtk_clist_append (clist, text);
+ row = gtk_clist_append (clist, text);
gtk_clist_set_row_data (clist, row, news);
}
- dialog->maxnrow = len - 1;
- dialog->nrow = -1;
gtk_signal_connect (GTK_OBJECT (clist), "select_row",
GTK_SIGNAL_FUNC (news_select_row),
dialog);
@@ -2116,7 +2134,8 @@ mail_config (void)
/* Transport Page */
tvbox = glade_xml_get_widget (gui, "transport_vbox");
dialog->page = transport_page_new (transports);
- service_page_set_url (dialog->page->page, config->transport);
+ transport = mail_config_get_transport ();
+ service_page_set_url (dialog->page->page, transport);
service_page_set_changed_cb (dialog->page->page,
mail_config_tpage_changed, dialog);
service_page_set_done_cb (dialog->page->page,
@@ -2128,7 +2147,7 @@ mail_config (void)
/* Other Page */
dialog->chkFormat = glade_xml_get_widget (gui, "chkFormat");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->chkFormat),
- config->send_html);
+ mail_config_send_html ());
gtk_signal_connect (GTK_OBJECT (dialog->chkFormat), "toggled",
GTK_SIGNAL_FUNC (format_toggled),
dialog);
diff --git a/mail/mail-config.c b/mail/mail-config.c
index a55f43711e..976f6a1765 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -36,9 +36,25 @@
#include "mail.h"
#include "mail-config.h"
+typedef struct
+{
+ gboolean configured;
+ GSList *ids;
+ GSList *sources;
+ GSList *news;
+ MailConfigService *transport;
+
+ gboolean thread_list;
+ gint paned_size;
+ gboolean send_html;
+} MailConfig;
+
static const char GCONFPATH[] = "/apps/Evolution/Mail";
static MailConfig *config = NULL;
+/* Prototypes */
+static void config_read (void);
+
/* Identity struct */
MailConfigIdentity *
identity_copy (MailConfigIdentity *id)
@@ -121,7 +137,7 @@ mail_config_init ()
config->sources = NULL;
config->transport = NULL;
- mail_config_read ();
+ config_read ();
}
void
@@ -144,10 +160,16 @@ mail_config_clear ()
service_destroy (config->transport);
config->transport = NULL;
+
+ if (config->news) {
+ g_slist_foreach (config->news, service_destroy_each, NULL);
+ g_slist_free (config->news);
+ config->news = NULL;
+ }
}
-void
-mail_config_read ()
+static void
+config_read ()
{
gchar *str;
gint len, i;
@@ -382,6 +404,42 @@ mail_config_is_configured ()
return config->configured;
}
+gboolean
+mail_config_thread_list ()
+{
+ return config->thread_list;
+}
+
+void
+mail_config_set_thread_list (gboolean value)
+{
+ config->thread_list = value;
+}
+
+gint
+mail_config_paned_size ()
+{
+ return config->paned_size;
+}
+
+void
+mail_config_set_paned_size (gint value)
+{
+ config->paned_size = value;
+}
+
+gboolean
+mail_config_send_html ()
+{
+ return config->send_html;
+}
+
+void
+mail_config_set_send_html (gboolean send_html)
+{
+ config->send_html = send_html;
+}
+
MailConfigIdentity *
mail_config_get_default_identity ()
{
@@ -397,6 +455,12 @@ mail_config_get_identities ()
return config->ids;
}
+void
+mail_config_add_identity (MailConfigIdentity *id)
+{
+ config->ids = g_slist_append (config->ids, id);
+}
+
MailConfigService *
mail_config_get_default_source ()
{
@@ -406,46 +470,54 @@ mail_config_get_default_source ()
return (MailConfigService *)config->sources->data;
}
-MailConfigService *
-mail_config_get_transport ()
+GSList *
+mail_config_get_sources ()
{
- return config->transport;
+ return config->sources;
}
-gboolean
-mail_config_send_html ()
+void
+mail_config_add_source (MailConfigService *source)
{
- return config->send_html;
+ config->sources = g_slist_append (config->sources, source);
}
-gboolean
-mail_config_thread_list ()
+MailConfigService *
+mail_config_get_transport ()
{
- return config->thread_list;
+ return config->transport;
}
void
-mail_config_set_thread_list (gboolean value)
+mail_config_set_transport (MailConfigService *transport)
{
- config->thread_list = value;
+ if (config->transport)
+ service_destroy (config->transport);
+
+ config->transport = transport;
}
-gint
-mail_config_paned_size ()
+MailConfigService *
+mail_config_get_default_news ()
{
- return config->paned_size;
+ if (!config->sources)
+ return NULL;
+
+ return (MailConfigService *)config->sources->data;
}
-void
-mail_config_set_paned_size (gint value)
+GSList *
+mail_config_get_news ()
{
- config->paned_size = value;
+ return config->news;
}
-MailConfig *
-mail_config_fetch (void)
+void
+mail_config_add_news (MailConfigService *news)
{
- return config;
+ config->news = g_slist_append (config->news, news);
}
+
+
diff --git a/mail/mail-config.glade b/mail/mail-config.glade
index 9a630516c6..23f1c44ab5 100644
--- a/mail/mail-config.glade
+++ b/mail/mail-config.glade
@@ -327,7 +327,7 @@
<widget>
<class>GtkCList</class>
- <name>clistNewsServers</name>
+ <name>clistNews</name>
<can_focus>True</can_focus>
<columns>1</columns>
<column_widths>80</column_widths>
diff --git a/mail/mail-config.h b/mail/mail-config.h
index fd1c0f3dda..e2ec379bb2 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -39,51 +39,46 @@ typedef struct
gboolean keep_on_server;
} MailConfigService;
-typedef struct
-{
- gboolean configured;
- GSList *ids;
- GSList *sources;
- GSList *news;
- MailConfigService *transport;
- gboolean send_html;
- gboolean thread_list;
- gint paned_size;
-} MailConfig;
-
/* Identities */
MailConfigIdentity *identity_copy (MailConfigIdentity *id);
-void identity_destroy (MailConfigIdentity *id);
-void identity_destroy_each (gpointer item, gpointer data);
+void identity_destroy (MailConfigIdentity *id);
+void identity_destroy_each (gpointer item, gpointer data);
/* Services */
MailConfigService *service_copy (MailConfigService *source);
-void service_destroy (MailConfigService *source);
-void service_destroy_each (gpointer item, gpointer data);
+void service_destroy (MailConfigService *source);
+void service_destroy_each (gpointer item, gpointer data);
/* Configuration */
void mail_config_init (void);
void mail_config_clear (void);
-void mail_config_read (void);
void mail_config_write (void);
void mail_config_write_on_exit (void);
/* General Accessor functions */
gboolean mail_config_is_configured (void);
-MailConfig *mail_config_fetch (void);
-gboolean mail_config_send_html (void);
gboolean mail_config_thread_list (void);
gint mail_config_paned_size (void);
void mail_config_set_thread_list (gboolean value);
void mail_config_set_paned_size (gint size);
+gboolean mail_config_send_html (void);
+void mail_config_set_send_html (gboolean send_html);
+
/* Identity Accessor functions */
MailConfigIdentity *mail_config_get_default_identity (void);
+void mail_config_add_identity (MailConfigIdentity *id);
GSList *mail_config_get_identities (void);
/* Service Accessor functions */
-MailConfigService *mail_config_get_default_source (void);
-MailConfigService *mail_config_get_transport (void);
+MailConfigService *mail_config_get_default_source (void);
+void mail_config_add_source (MailConfigService *source);
+
+MailConfigService *mail_config_get_transport (void);
+void mail_config_set_transport (MailConfigService *transport);
+
+MailConfigService *mail_config_get_default_news (void);
+void mail_config_add_news (MailConfigService *source);
#endif
diff --git a/mail/mail-format.c b/mail/mail-format.c
index eab8fdc018..b0f813610c 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -1641,7 +1641,6 @@ mail_get_message_body (CamelDataWrapper *data, gboolean want_plain, gboolean *is
EMsgComposer *
mail_generate_reply (CamelMimeMessage *message, gboolean to_all)
{
- const MailConfig *config;
CamelDataWrapper *contents;
char *text, *subject;
EMsgComposer *composer;
@@ -1649,8 +1648,7 @@ mail_generate_reply (CamelMimeMessage *message, gboolean to_all)
const char *repl_to, *message_id, *references;
GList *to, *cc;
- config = mail_config_fetch ();
- want_plain = !config->send_html;
+ want_plain = !mail_config_send_html ();
contents = camel_medium_get_content_object (CAMEL_MEDIUM (message));
text = mail_get_message_body (contents, want_plain, &is_html);