Files
evolution/mail/message-browser.c
Jeffrey Stedfast fb6caf533c Use gconf to get the paned size. (folder_browser_set_message_preview):
2003-01-07  Jeffrey Stedfast  <fejj@ximian.com>

	* folder-browser.c (save_cursor_pos): Use gconf to get the paned
	size.
	(folder_browser_set_message_preview): Same.
	(folder_browser_toggle_hide_deleted): Use gconf to set the
	hide-deleted state.
	(folder_browser_set_message_display_style): Same but for the
	message_display_style.
	(fb_resize_cb): Save the paned_size via gconf.
	(paned_size_changed): Callback for when the paned_size gets
	changed. Change the folder-browser's paned size to the new
	setting.
	(folder_browser_gui_init): Listen to changes to the paned_size and
	also get the initial size from gconf.

	* message-list.c (message_list_set_folder): Use gconf.
	(regen_list_regen): Use gconf.

	* message-browser.c (transfer_msg_done): Use gconf to get the
	hide_deleted setting.

	* mail-account-gui.c (sig_add_new_signature): Use gconf.

	* folder-browser-ui.c (folder_browser_ui_add_list): Use gconf.

	* folder-browser.c (save_cursor_pos): Use gconf.
	(folder_browser_set_message_preview): Same.
	(folder_browser_toggle_hide_deleted): Here too.
	(folder_browser_set_message_display_style): And here.
	(folder_browser_gui_init): Here too.
	(done_message_selected): And here.

	* mail-config.c (mail_config_get_thread_subject): Removed.
	(mail_config_set_thread_subject): Removed.
	(mail_config_get_empty_trash_on_exit): Removed.
	(mail_config_set_empty_trash_on_exit): Removed.
	(mail_config_get_last_filesel_dir): Removed.
	(mail_config_set_last_filesel_dir): Removed.
	(mail_config_get_hide_deleted): Removed.
	(mail_config_set_hide_deleted): Removed.
	(mail_config_get_paned_size): Removed.
	(mail_config_set_paned_size): Removed.
	(mail_config_get_send_html): Removed.
	(mail_config_set_send_html): Removed.
	(mail_config_get_confirm_unwanted_html): Removed.
	(mail_config_set_confirm_unwanted_html): Removed.
	(mail_config_get_citation_highlight): Removed.
	(mail_config_set_citation_highlight): Removed.
	(mail_config_get_citation_color): Removed.
	(mail_config_set_citation_color): Removed.
	(mail_config_get_do_seen_timeout): Removed.
	(mail_config_set_do_seen_timeout): Removed.
	(mail_config_get_mark_as_seen_timeout): Removed.
	(mail_config_set_mark_as_seen_timeout): Removed.
	(mail_config_get_prompt_empty_subject): Removed.
	(mail_config_set_prompt_empty_subject): Removed.
	(mail_config_get_prompt_only_bcc): Removed.
	(mail_config_set_prompt_only_bcc): Removed.
	(mail_config_get_confirm_expunge): Removed.
	(mail_config_set_confirm_expunge): Removed.
	(mail_config_get_confirm_goto_next_folder): Removed.
	(mail_config_set_confirm_goto_next_folder): Removed.
	(mail_config_get_goto_next_folder): Removed.
	(mail_config_set_goto_next_folder): Removed.
	(mail_config_get_http_mode): Removed.
	(mail_config_set_http_mode): Removed.
	(mail_config_get_default_forward_style): Removed.
	(mail_config_set_default_forward_style): Removed.
	(mail_config_get_default_reply_style): Removed.
	(mail_config_set_default_reply_style): Removed.
	(mail_config_get_message_display_style): Removed.
	(mail_config_set_message_display_style): Removed.
	(mail_config_get_default_charset): Removed.
	(mail_config_set_default_charset): Removed.
	(mail_config_get_x_mailer_display_style): Removed.
	(mail_config_set_x_mailer_display_style): Removed.

	* subscribe-dialog.c (populate_store_list): Use the list of
	accounts. We can't get the list of sources anymore.
	(populate_store_foreach): Updated.

	* mail-callbacks.c (guess_me_from_accounts): Use account->enabled.
	(mail_generate_reply): Same.
	(empty_trash): Here too.

	* mail-accounts.c (account_delete_clicked): Use account->enabled
	rather than source->enabled.
	(account_able_clicked): Same.
	(account_cursor_change): Here too.
	(mail_accounts_load): And here.

	* component-factory.c (owner_unset_cb): Use gconf empty-on-exit
	settings.
	(mail_load_storages): Use account->enabled rather than
	account->source->enabled. The struct changed.

	* mail-composer-prefs.c (sig_add): Get the send_html pref from gconf.

	* message-tag-followup.c (target_date_new): Use gconf.

	* mail-config.c (mail_config_get_week_start_day): Removed.

	* mail-tools.c (mail_tool_quote_message): Use gconf here too, but
	we don't need to parse the colour - just use it as a raw string.
	(mail_tool_forward_message): Use gconf.

	* mail-format.c (mail_format_data_wrapper_write_to_stream): Use gconf.
	(write_headers): Use gconf.
	(handle_text_plain): Same.

	* mail-display.c (mail_text_write): Updated to use gconf and parse
	GdkColour strings.
	(on_url_requested): Updated to use gconf.

	* mail-callbacks.c (ask_confirm_for_unwanted_html_mail): Use gconf
	rather than the old mail-config APIs which will be removed.
	(ask_confirm_for_empty_subject): Same.
	(ask_confirm_for_only_bcc): Here too.
	(composer_get_message): And here.
	(create_msg_composer): Same.
	(transfer_msg_done): Again here.
	(delete_msg): Here too.
	(confirm_expunge): And finally here.

	* mail-config.c (mail_config_write): Use gconf.
	(mail_config_get_sources): Removed.

	* mail-account-gui.c (mail_account_gui_save): No need to save
	enabled-state anymore for a source.

	* mail-config-druid.c (wizard_finish_cb): Instead of setting
	account->source->enabled to TRUE, just set account->enabled to
	TRUE. The structures changed a bit.

	* mail-send-recv.c (mail_send_receive): Get the list of accounts
	instead of sources, and pass them along to build_dialogue. I'm
	trying to get rid of the mail_config_get_sources() api.
	(mail_autoreceive_setup): Here too.

	* mail-config.c (mail_config_get_filter_log): Removed.
	(mail_config_set_filter_log): Removed.
	(mail_config_get_filter_log_path): Removed.
	(mail_config_set_filter_log_path): Removed.
	(mail_config_get_new_mail_notify): Removed.
	(mail_config_set_new_mail_notify): Removed.
	(mail_config_get_new_mail_notify_sound_file): Removed.
	(mail_config_set_new_mail_notify_sound_file): Removed.

	* mail-session.c (main_get_filter_driver): Updated to use the
	gconf settings.

svn path=/trunk/; revision=19271
2003-01-08 01:39:21 +00:00

364 lines
9.7 KiB
C

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors: Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright 2001 Ximian, Inc. (www.ximian.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <gal/util/e-util.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-ui-component.h>
#include <bonobo/bonobo-ui-container.h>
#include <bonobo/bonobo-ui-util.h>
#include "message-browser.h"
#include "mail.h"
#include "mail-callbacks.h"
#include "mail-tools.h"
#include "message-list.h"
#include "mail-ops.h"
#include "mail-vfolder.h"
#include "mail-autofilter.h"
#include "mail-mt.h"
#include "mail-local.h"
#include "mail-config.h"
#include "folder-browser-ui.h"
#define d(x)
#define MINIMUM_WIDTH 600
#define MINIMUM_HEIGHT 400
#define PARENT_TYPE BONOBO_TYPE_WINDOW
/* Size of the window last time it was changed. */
static GtkAllocation last_allocation = { 0, 0 };
static BonoboWindowClass *message_browser_parent_class;
static void
message_browser_destroy (GtkObject *object)
{
MessageBrowser *message_browser;
message_browser = MESSAGE_BROWSER (object);
if (message_browser->fb) {
g_signal_handlers_disconnect_matched(message_browser->fb, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, message_browser);
g_object_unref((message_browser->fb));
message_browser->fb = NULL;
}
if (GTK_OBJECT_CLASS (message_browser_parent_class)->destroy)
(GTK_OBJECT_CLASS (message_browser_parent_class)->destroy) (object);
}
static void
message_browser_class_init (GObjectClass *object_class)
{
((GtkObjectClass *)object_class)->destroy = message_browser_destroy;
message_browser_parent_class = g_type_class_ref(PARENT_TYPE);
}
static void
message_browser_init (GtkObject *object)
{
}
static void
transfer_msg_done (gboolean ok, void *data)
{
MessageBrowser *mb = data;
gboolean hide_deleted;
GConfClient *gconf;
int row;
#warning "GTK_OBJECT_DESTROYED"
/*if (ok && !GTK_OBJECT_DESTROYED (mb)) {*/
if (ok) {
gconf = gconf_client_get_default ();
hide_deleted = !gconf_client_get_bool (gconf, "/apps/evolution/mail/display/show_deleted", NULL);
row = e_tree_row_of_node (mb->fb->message_list->tree,
e_tree_get_cursor (mb->fb->message_list->tree));
/* If this is the last message and deleted messages
are hidden, select the previous */
if ((row + 1 == e_tree_row_count (mb->fb->message_list->tree)) && hide_deleted)
message_list_select (mb->fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS,
0, CAMEL_MESSAGE_DELETED, FALSE);
else
message_list_select (mb->fb->message_list, MESSAGE_LIST_SELECT_NEXT,
0, 0, FALSE);
}
g_object_unref (mb);
}
static void
transfer_msg (MessageBrowser *mb, int del)
{
const char *allowed_types[] = { "mail/*", "vtrash", NULL };
extern EvolutionShellClient *global_shell_client;
GNOME_Evolution_Folder *folder;
static char *last_uri = NULL;
GPtrArray *uids;
char *desc;
/* if (GTK_OBJECT_DESTROYED(mb))
return;*/
if (last_uri == NULL)
last_uri = g_strdup ("");
if (del)
desc = _("Move message(s) to");
else
desc = _("Copy message(s) to");
evolution_shell_client_user_select_folder (global_shell_client,
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (mb))),
desc, last_uri, allowed_types, &folder);
if (!folder)
return;
if (strcmp (last_uri, folder->evolutionUri) != 0) {
g_free (last_uri);
last_uri = g_strdup (folder->evolutionUri);
}
uids = g_ptr_array_new ();
message_list_foreach (mb->fb->message_list, enumerate_msg, uids);
if (del) {
g_object_ref((mb));
mail_transfer_messages (mb->fb->folder, uids, del,
folder->physicalUri, 0, transfer_msg_done, mb);
} else {
mail_transfer_messages (mb->fb->folder, uids, del,
folder->physicalUri, 0, NULL, NULL);
}
CORBA_free (folder);
}
/* UI callbacks */
static void
message_browser_close (BonoboUIComponent *uih, void *user_data, const char *path)
{
gtk_widget_destroy (GTK_WIDGET (user_data));
}
static void
message_browser_move (BonoboUIComponent *uih, void *user_data, const char *path)
{
transfer_msg(user_data, TRUE);
}
static void
message_browser_copy (BonoboUIComponent *uih, void *user_data, const char *path)
{
transfer_msg(user_data, FALSE);
}
static BonoboUIVerb
browser_verbs [] = {
BONOBO_UI_UNSAFE_VERB ("MessageBrowserClose", message_browser_close),
BONOBO_UI_UNSAFE_VERB ("MessageMove", message_browser_move),
BONOBO_UI_UNSAFE_VERB ("MessageCopy", message_browser_copy),
BONOBO_UI_VERB_END
};
/* FB message loading hookups */
static void
message_browser_message_loaded (FolderBrowser *fb, const char *uid, MessageBrowser *mb)
{
CamelMimeMessage *message;
char *subject = NULL;
char *title;
folder_browser_ui_message_loaded(fb);
message = fb->mail_display->current_message;
if (message)
subject = (char *) camel_mime_message_get_subject (message);
if (subject == NULL)
subject = _("(No subject)");
title = g_strdup_printf (_("%s - Message"), subject);
gtk_window_set_title (GTK_WINDOW (mb), title);
g_free (title);
}
static void
message_browser_message_list_built (MessageList *ml, MessageBrowser *mb)
{
const char *uid = g_object_get_data (G_OBJECT (mb), "uid");
g_signal_handlers_disconnect_matched(mb->fb, G_SIGNAL_MATCH_DATA|G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
message_browser_message_list_built, mb);
message_list_select_uid (ml, uid);
}
static void
message_browser_folder_loaded (FolderBrowser *fb, const char *uri, MessageBrowser *mb)
{
g_signal_connect(fb->message_list, "message_list_built",
G_CALLBACK(message_browser_message_list_built), mb);
}
static void
message_browser_size_allocate_cb (GtkWidget *widget,
GtkAllocation *allocation)
{
last_allocation = *allocation;
}
/* Construction */
static void
set_default_size (GtkWidget *widget)
{
int width, height;
width = MAX (MINIMUM_WIDTH, last_allocation.width);
height = MAX (MINIMUM_HEIGHT, last_allocation.height);
gtk_window_set_default_size (GTK_WINDOW (widget), width, height);
}
static void
set_bonobo_ui (GtkWidget *widget, FolderBrowser *fb)
{
BonoboUIContainer *uicont;
BonoboUIComponent *uic;
CORBA_Environment ev;
uicont = bonobo_window_get_ui_container(BONOBO_WINDOW(widget));
uic = bonobo_ui_component_new_default ();
bonobo_ui_component_set_container (uic, BONOBO_OBJREF (uicont), NULL);
folder_browser_set_ui_component (fb, uic);
/* Load our UI */
/*bonobo_ui_component_freeze (uic, NULL);*/
bonobo_ui_util_set_ui (uic, EVOLUTION_DATADIR, "evolution-mail-messagedisplay.xml", "evolution-mail", NULL);
/* Load the appropriate UI stuff from the folder browser */
folder_browser_ui_add_message (fb);
/* We just opened the message! We don't need to open it again. */
CORBA_exception_init (&ev);
/* remove the broken menus and toolbar items */
bonobo_ui_component_rm (uic, "/menu/File/FileOps/MessageOpen", &ev);
bonobo_ui_component_rm (uic, "/menu/Actions/ComponentActionsPlaceholder/MailMessageActions/GoTo", &ev);
bonobo_ui_component_rm (uic, "/menu/Tools", &ev);
bonobo_ui_component_rm (uic, "/Toolbar/MailNextButtons", &ev);
CORBA_exception_free (&ev);
/* Hack around the move/copy commands api's */
bonobo_ui_component_remove_listener (uic, "MessageCopy");
bonobo_ui_component_remove_listener (uic, "MessageMove");
/* Add the Close & Move/Copy items */
bonobo_ui_component_add_verb_list_with_data (uic, browser_verbs, widget);
/* Done */
/*bonobo_ui_component_thaw (uic, NULL);*/
}
GtkWidget *
message_browser_new (const GNOME_Evolution_Shell shell, const char *uri, const char *uid)
{
GtkWidget *vbox;
MessageBrowser *new;
FolderBrowser *fb;
new = g_object_new (MESSAGE_BROWSER_TYPE,
"title", "Ximian Evolution", NULL);
if (!new) {
g_warning ("Failed to construct Bonobo window!");
return NULL;
}
g_object_set_data_full(G_OBJECT(new), "uid", g_strdup (uid), g_free);
fb = FOLDER_BROWSER (folder_browser_new (shell, uri));
g_object_ref(fb);
gtk_object_sink((GtkObject *)fb);
new->fb = fb;
set_bonobo_ui (GTK_WIDGET (new), fb);
/* some evil hackery action... */
vbox = gtk_vbox_new (TRUE, 0);
gtk_widget_ref (GTK_WIDGET (fb->mail_display));
gtk_widget_reparent (GTK_WIDGET (fb->mail_display), vbox);
/* Note: normally we'd unref the fb->mail_display now, except
that if we do then our refcounts will not be in
harmony... both the fb *and* the message-browser need to
own a ref on the mail_display. */
gtk_widget_show (GTK_WIDGET (fb->mail_display));
gtk_widget_show (vbox);
g_signal_connect(new, "size_allocate",
G_CALLBACK (message_browser_size_allocate_cb), NULL);
bonobo_window_set_contents (BONOBO_WINDOW (new), vbox);
gtk_widget_grab_focus (GTK_WIDGET (MAIL_DISPLAY (fb->mail_display)->html));
set_default_size (GTK_WIDGET (new));
/* more evil hackery... */
g_signal_connect(fb, "folder_loaded", G_CALLBACK(message_browser_folder_loaded), new);
g_signal_connect(fb, "message_loaded", G_CALLBACK(message_browser_message_loaded), new);
return GTK_WIDGET (new);
}
/* Fin */
E_MAKE_TYPE (message_browser, "MessageBrowser", MessageBrowser, message_browser_class_init,
message_browser_init, PARENT_TYPE);