aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-05-12 03:50:04 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-05-12 03:50:04 +0800
commit6febeab3270c35664cc3938d4f89b9c292550040 (patch)
tree2d04c55cf7fc1674f6b5b0c19fd6cad99400f3f3
parentb4796b63763b08f13aa77f51f679d0b660bf48a4 (diff)
downloadgsoc2013-evolution-6febeab3270c35664cc3938d4f89b9c292550040.tar
gsoc2013-evolution-6febeab3270c35664cc3938d4f89b9c292550040.tar.gz
gsoc2013-evolution-6febeab3270c35664cc3938d4f89b9c292550040.tar.bz2
gsoc2013-evolution-6febeab3270c35664cc3938d4f89b9c292550040.tar.lz
gsoc2013-evolution-6febeab3270c35664cc3938d4f89b9c292550040.tar.xz
gsoc2013-evolution-6febeab3270c35664cc3938d4f89b9c292550040.tar.zst
gsoc2013-evolution-6febeab3270c35664cc3938d4f89b9c292550040.zip
Set a title on the window "Reconfigure %s" where %s is the folder name.
2001-05-11 Jeffrey Stedfast <fejj@ximian.com> * mail-local.c (mail_local_reconfigure_folder): Set a title on the window "Reconfigure %s" where %s is the folder name. Also, don't allow more than one of these type windows to be opened per folder. * mail-tools.c (mail_tool_get_folder_name): Fix Danw's kludge to actually work :-) svn path=/trunk/; revision=9767
-rw-r--r--mail/ChangeLog9
-rw-r--r--mail/mail-local.c95
-rw-r--r--mail/mail-tools.c28
-rw-r--r--mail/mail-tools.h2
4 files changed, 88 insertions, 46 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index d88aa8b219..d72cf5b544 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,12 @@
+2001-05-11 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-local.c (mail_local_reconfigure_folder): Set a title on the
+ window "Reconfigure %s" where %s is the folder name. Also, don't
+ allow more than one of these type windows to be opened per folder.
+
+ * mail-tools.c (mail_tool_get_folder_name): Fix Danw's kludge to
+ actually work :-)
+
2001-05-11 Martha Burke <martha@ximian.com>
* gui/Makefile.am: sanitize LD_ADDS and CFLAGS so the libtool
diff --git a/mail/mail-local.c b/mail/mail-local.c
index 597a17b8e1..5c27fb0e0a 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -987,67 +987,96 @@ static struct _mail_msg_op reconfigure_folder_op = {
reconfigure_folder_free,
};
+/* hash table of folders that the user has a reconfig-folder dialog for */
+static GHashTable *reconfigure_folder_hash = NULL;
+
static void
-reconfigure_clicked(GnomeDialog *d, int button, struct _reconfigure_msg *m)
+reconfigure_clicked (GnomeDialog *dialog, int button, struct _reconfigure_msg *m)
{
if (button == 0) {
- GtkMenu *menu;
+ GtkWidget *menu;
int type;
char *types[] = { "mbox", "maildir", "mh" };
-
+
/* hack to clear the message list during update */
- message_list_set_folder(m->fb->message_list, NULL);
-
- menu = (GtkMenu *)gtk_option_menu_get_menu(m->optionlist);
- type = g_list_index(GTK_MENU_SHELL(menu)->children, gtk_menu_get_active(menu));
+ message_list_set_folder (m->fb->message_list, NULL);
+
+ menu = gtk_option_menu_get_menu (m->optionlist);
+ type = g_list_index (GTK_MENU_SHELL (menu)->children,
+ gtk_menu_get_active (GTK_MENU (menu)));
if (type < 0 || type > 2)
type = 0;
-
- gtk_widget_set_sensitive(m->frame, FALSE);
- gtk_widget_set_sensitive(m->apply, FALSE);
- gtk_widget_set_sensitive(m->cancel, FALSE);
-
+
+ gtk_widget_set_sensitive (m->frame, FALSE);
+ gtk_widget_set_sensitive (m->apply, FALSE);
+ gtk_widget_set_sensitive (m->cancel, FALSE);
+
m->newtype = g_strdup (types[type]);
- e_thread_put(mail_thread_queued, (EMsg *)m);
+ e_thread_put (mail_thread_queued, (EMsg *)m);
} else
- mail_msg_free((struct _mail_msg *)m);
-
+ mail_msg_free ((struct _mail_msg *)m);
+
if (button != -1)
- gnome_dialog_close(d);
+ gnome_dialog_close (dialog);
}
void
-mail_local_reconfigure_folder(FolderBrowser *fb)
+mail_local_reconfigure_folder (FolderBrowser *fb)
{
CamelStore *store;
GladeXML *gui;
GnomeDialog *gd;
struct _reconfigure_msg *m;
-
+ char *name, *title;
+
if (fb->folder == NULL) {
- g_warning("Trying to reconfigure nonexistant folder");
+ g_warning ("Trying to reconfigure nonexistant folder");
return;
}
-
- m = mail_msg_new(&reconfigure_folder_op, NULL, sizeof(*m));
- store = camel_folder_get_parent_store(fb->folder);
-
- gui = glade_xml_new(EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format");
+
+ if ((gd = g_hash_table_lookup (reconfigure_folder_hash, fb->folder))) {
+ /* FIXME: raise this dialog?? */
+ return;
+ }
+
+ m = mail_msg_new (&reconfigure_folder_op, NULL, sizeof (*m));
+ store = camel_folder_get_parent_store (fb->folder);
+
+ gui = glade_xml_new (EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format");
gd = (GnomeDialog *)glade_xml_get_widget (gui, "dialog_format");
-
+
+ name = mail_tool_get_folder_name (fb->folder);
+ title = g_strdup_printf ("Reconfigure %s", name);
+ gtk_window_set_title (GTK_WINDOW (gd), title);
+ g_free (title);
+ g_free (name);
+
m->frame = glade_xml_get_widget (gui, "frame_format");
m->apply = glade_xml_get_widget (gui, "apply_format");
m->cancel = glade_xml_get_widget (gui, "cancel_format");
m->optionlist = (GtkOptionMenu *)glade_xml_get_widget (gui, "option_format");
m->newtype = NULL;
m->fb = fb;
- gtk_object_ref((GtkObject *)fb);
-
- gtk_label_set_text((GtkLabel *)glade_xml_get_widget (gui, "label_format"),
- ((CamelService *)store)->url->protocol);
-
- gtk_signal_connect((GtkObject *)gd, "clicked", reconfigure_clicked, m);
- gtk_object_unref((GtkObject *)gui);
-
+ gtk_object_ref (GTK_OBJECT (fb));
+
+ gtk_label_set_text ((GtkLabel *)glade_xml_get_widget (gui, "label_format"),
+ ((CamelService *)store)->url->protocol);
+
+ gtk_signal_connect (GTK_OBJECT (gd), "clicked", reconfigure_clicked, m);
+ gtk_object_unref (GTK_OBJECT (gui));
+
+ if (!reconfigure_folder_hash)
+ reconfigure_folder_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ g_hash_table_insert (reconfigure_folder_hash, (gpointer) fb->folder, (gpointer) gd);
+
gnome_dialog_run_and_close (GNOME_DIALOG (gd));
+
+ /* remove this folder from our hash since we are done with it */
+ g_hash_table_remove (reconfigure_folder_hash, fb->folder);
+ if (g_hash_table_size (reconfigure_folder_hash) == 0) {
+ /* additional cleanup */
+ g_hash_table_destroy (reconfigure_folder_hash);
+ reconfigure_folder_hash = NULL;
+ }
}
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 994879953b..abec85f86c 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -62,23 +62,27 @@ mail_tool_get_folder_from_urlname (const gchar *url, const gchar *name,
return folder;
}
-const gchar *
+char *
mail_tool_get_folder_name (CamelFolder *folder)
{
const char *name = camel_folder_get_full_name (folder);
- char *path;
-
+ char *path, *pend;
+
/* This is a kludge. */
-
- if (strcmp (name, "//mbox") && strcmp (name, "//mh"))
- return name;
-
+ if (strcmp (name, "mbox") && strcmp (name, "mh") && strcmp (name, "maildir"))
+ return g_strdup (name);
+
/* For mbox/mh, return the parent store's final path component. */
- path = CAMEL_SERVICE (folder->parent_store)->url->path;
- if (strchr (path, '/'))
- return strrchr (path, '/') + 1;
- else
- return path;
+ path = g_strdup (CAMEL_SERVICE (folder->parent_store)->url->path);
+ pend = path + strlen (path) - 1;
+ if (*pend == '/')
+ *pend = '\0';
+
+ pend = path;
+ path = g_strdup (g_basename (path));
+ g_free (pend);
+
+ return path;
}
gchar *
diff --git a/mail/mail-tools.h b/mail/mail-tools.h
index 5738ea0efa..5cb546a250 100644
--- a/mail/mail-tools.h
+++ b/mail/mail-tools.h
@@ -34,7 +34,7 @@ mail_tool_get_folder_from_urlname (const gchar *url, const gchar *name,
guint32 flags, CamelException *ex);
/* Get a useful name for a given CamelFolder (ie, not "mbox") */
-const gchar *mail_tool_get_folder_name (CamelFolder *folder);
+char *mail_tool_get_folder_name (CamelFolder *folder);
/* Get the url for the local inbox, index returns if the mailbox is indexed */
gchar *mail_tool_get_local_inbox_url (int *index);