diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 2461 | ||||
-rw-r--r-- | mail/component-factory.c | 469 | ||||
-rw-r--r-- | mail/folder-browser.c | 1010 | ||||
-rw-r--r-- | mail/mail-account-gui.c | 592 | ||||
-rw-r--r-- | mail/mail-accounts.c | 582 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 1208 | ||||
-rw-r--r-- | mail/mail-composer-prefs.c | 754 | ||||
-rw-r--r-- | mail/mail-config-druid.c | 1166 | ||||
-rw-r--r-- | mail/mail-display.c | 1257 | ||||
-rw-r--r-- | mail/mail-format.c | 1525 | ||||
-rw-r--r-- | mail/mail-local.c | 227 | ||||
-rw-r--r-- | mail/mail-preferences.c | 293 | ||||
-rw-r--r-- | mail/mail-session.c | 566 | ||||
-rw-r--r-- | mail/mail.h | 37 | ||||
-rw-r--r-- | mail/subscribe-dialog.glade | 531 |
15 files changed, 5635 insertions, 7043 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index b6638c3e51..3daef220e2 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,554 +1,46 @@ -2003-04-01 Not Zed <NotZed@Ximian.com> - - * mail-display.c (mail_display_redisplay): if we're called and the - idle handler is set, remove it, so we dont go and redisplay it - again. Fixes #40522. - -2003-03-31 Jeffrey Stedfast <fejj@ximian.com> - - * mail-session.c: Properly init message_list. Fixed a type-o that - initialized it to the password_list. - -2003-03-31 Not Zed <NotZed@Ximian.com> - - * mail-session.c (pass_response): need to check for config_service - != NULL, not service != NULL before calling set_save_password. - Fix for #40472. - -2003-03-28 Not Zed <NotZed@Ximian.com> - - * folder-browser-ui.c: include e-meta.h - - * folder-browser.c (on_right_click): remove unused var. - -2003-03-28 Jeffrey Stedfast <fejj@ximian.com> - - * subscribe-dialog.c (fe_check_for_children): Declare a prototype - for this function prior to fe_got_children() so that - fe_got_children() can call us. - -2003-03-26 Dan Winship <danw@ximian.com> - - * mail-format.c (write_address): remove extra arg to - camel_url_encode - -2003-03-27 Not Zed <NotZed@Ximian.com> - - * folder-browser.c (folder_browser_gui_init): dont set the paned - initial size here, but hook onto the realize signal. - (paned_realised): set the paned size once we're realised. Fixes - #37084, its a bit of a hack, but it seems to work. - -2003-03-26 Jeffrey Stedfast <fejj@ximian.com> - - Fixes bug #40074. - - * folder-browser-factory.c (control_deactivate): Save message-list - state. - - * message-list.c (message_list_save_state): Save the various - states. - -2003-03-26 Jeffrey Stedfast <fejj@ximian.com> - - Fixes for bug #39870 - - * message-browser.c (transfer_msg_done): Close the - message-browser. Since the message doesn't exist anymore, we - should close it. - (message_browser_delete): New callback to handle deletion in the - message-browser window. - -2003-03-26 Jeffrey Stedfast <fejj@ximian.com> - - * subscribe-dialog.c (fe_got_children): If the CamelFolderInfo - node doesn't have \NoInferriors set, then check for - subfolders. Fixes bug #40314. - -2003-03-26 Not Zed <NotZed@Ximian.com> - - * mail-display.c (popup_window_destroy_cb): Undo jeff's patch - below for #40275, the destroy timeout is already removed in - popup_info_free. Unref the widget 'w' when we're done with it. - (popup_info_free): Move everything in here to popup_window_destroy - and remove, since nothing else uses it. - (make_popup_window): Ref the widget so it doesn't go away before - we're finished with it. Really fixes bug #40275/40188. - -2003-03-25 Jeffrey Stedfast <fejj@ximian.com> - - * mail-display.c (popup_window_destroy_cb): Remove the - timeout. Should fix bug #40275. - - * subscribe-dialog.c: Remove search entry which never worked right - (and can't work as users expect anyway, since we don't do - namespace stripping). Fixes bug #40083. - (ftree_node_new): Ignore \NoSelect as far as marking it - "subscribable". Fixes bug #40124. - -2003-03-25 Dan Winship <danw@ximian.com> - - * mail-account-editor.c: Update for e_notice move - (apply_changes): Pass a parent_window to e_notice - - * mail-account-gui.c: Update for e_notice move. - (mail_account_gui_save): Pass a parent_window to e_notice - - * mail-callbacks.c: Update for e_notice move - * mail-local.c: Likewise - * mail-signature-editor.c: Likewise - * mail-vfolder.c: Likewise - - * component-factory.c (interactive_cb): Update prototype - -2003-03-25 Not Zed <NotZed@Ximian.com> - - * mail-tools.c (meta_data_key): strdup the key before freeing the - url as it is probably pointing there. - -2003-03-25 Not Zed <NotZed@Ximian.com> - - * component-factory.c (got_folder): remove a debug printf that - made it in a commit. - - * folder-browser-ui.c (folder_browser_ui_add_global): Load - per-folder setting of show_preview from meta data. - (folder_browser_ui_add_list): Same, for thread_list. - - * mail-tools.c (mail_tool_get_meta_data) - (mail_tool_delete_meta_data): helpers to lookup/delete meta data. - - * mail-config.c (mail_config_uri_deleted): delete the meta-data - for the folder. - - * folder-browser.c (folder_browser_reload): dont reload the uri if - we're in the process of loading it still. - (folder_browser_new): load the folder meta data before loading the - folder. - (folder_browser_toggle_preview): - (folder_browser_toggle_threads): save change to meta-data. - (got_folder): Load the metadata if we have a folder to set, and - the meta-data has changed from initislisation. - -2003-03-23 Chris Toshok <toshok@ximian.com> - - * mail-callbacks.c (ask_confirm_for_unwanted_html_mail): pass - FALSE for e_destination_get_textrep's include_email arg. - -2003-03-21 Jeffrey Stedfast <fejj@ximian.com> - - * mail-format.c (mail_format_data_wrapper_write_to_stream): - Default to the charset provied in the MimePart's Content-Type over - that of the user's mailer charset. Fixes bug #39204. - -2003-03-21 Jeffrey Stedfast <fejj@ximian.com> - - * mail-composer-prefs.c (spell_load_values): "en_us" should not be - translated. Fixes bug #40088. - -2003-03-21 Larry Ewing <lewing@ximian.com> - - * mail-display.c (pixbuf_gen_idle): remember to disconnect the - destroy handler if whenever the loader is shut down. - -2003-03-20 Jeffrey Stedfast <fejj@ximian.com> - - * component-factory.c (owner_set_cb): Change the message_destroy - callback to just gtk_widget_destroy. No need to have a callback - simply to call this function. - (warning_response): Removed (see above). - - * mail-composer-prefs.c (sig_add_script_response): Don't forget to - add the signature to the signature list if it is a valid script. - - * mail-config.c (mail_config_signature_unregister_client): Make - sure we can find the registered handler before trying to remove it - from the list. - - * mail-session.c (do_user_message): Make the 5th argument to - gtk_message_dialog_new() "%s" and move the m->prompt to arg 6 so - that we are safe if the prompt string contains any %'s. Also - connect to the response signal for the user_msg dialog and set the - callback to gtk_widget_destroy so that the user can actually close - the dialog. We also need to g_object_weak_ref() the dialog so that - we can set the global message_dialog pointer back to NULL when it - gets destroyed. Fixes bug #40043. - -2003-03-20 Dan Winship <danw@ximian.com> - - * mail-ops.c (build_from): Remove this since there's a function in - CamelMimeMessage to do it now. - (save_messages_save): Use camel_mime_message_build_mbox_from. - -2003-03-21 Not Zed <NotZed@Ximian.com> - - ** for mail part of bug #38461. - - * importers/evolution-outlook-importer.c (load_file_fn): dont pass - in create flag to uri_to_folder, the folder must already exist. - - * importers/evolution-mbox-importer.c (folder_created_cb): - Removed, we now force the caller to create the destination folder - first. - (load_file_fn): Dont try and create a folder if it doesn't exist. - Also, use the uri directly as the destination uri, so we can - import into any folder. - (process_item_fn): If we dont have a folder, thats just an error, - return BAD_FILE. - - * importers/netscape-importer.c (netscape_import_file): As below - for elm_import_file. - (import_next): similarly as for pine import_next. - (importer_cb): just record result. - (importer_timeout_fn): removed. - - * importers/pine-importer.c (import_next): Similar to below for - the elm import_next. - (pine_import_file): As below for elm_import_file. - (importer_timeout_fn): removed. - (importer_cb): just record the result, and exit. - (import_next): change around to behave more like the elm importer, - cleaning up when we're done. - - * importers/elm-importer.c (elm_import_file): Create the - destination folder ourselves, dont pass it onto the mbox importer. - Simplify logic, just do the import within a while loop, polling - the g main loop as necessary, remove need for idle callbacks and - other crap. - (import_next): If elm_import_file fails, then just go straight to - the next folder, stops it falling in a heap. - (import_item_idle): removed. - (importer_cb): just record result/exit. - - * mail-importer.c (mail_importer_create_folder): removed. - (mail_importer_make_local_folder): new function to create a - local-only folder from a path. It runs synchronously by using a - recursive main loop. - (folder_created_cb): callback for make_local_folder. - -2003-03-19 Jeffrey Stedfast <fejj@ximian.com> - - * mail-config-druid.c (mail_config_druid_new): Revert ettore's - broken patch. - - * mail-search-dialogue.c: Removed - nothing uses this. - -2003-03-19 Ettore Perazzoli <ettore@ximian.com> - - * importers/GNOME_Evolution_Mail_Mbox_Importer.server.in.in: - Replace "evolution:menu-name" prop with "evolution:menu_name". - [#39692] - * importers/GNOME_Evolution_Mail_Outlook_Importer.server.in.in: - Likewise. - -2003-03-19 Ettore Perazzoli <ettore@ximian.com> - - * mail-config-druid.c (mail_config_druid_new): Give the druid the - DIALOG hint. [#39741 and friends.] - -2003-03-19 Radek Doulik <rodo@ximian.com> - - * mail-composer-prefs.c (spell_load_values): changed default - language to en_us instead of en - (spell_language_button_press): new handler, ported from 1.2 - (spell_setup): use spell_language_enable and - spell_language_button_press - -2003-03-18 Jeffrey Stedfast <fejj@ximian.com> - - * mail-callbacks.c (composer_get_message): - e_msg_composer_get_subject() now returns a const char *, so update - appropriately. - -2003-03-18 Larry Ewing <lewing@ximian.com> - - * mail-callbacks.c (do_mail_print): fix leak, cleanup variable - name, and call gtk_window_set_transient_for with a parent that is - actually a GtkWindow. - (mark_as_unseen): use g_source_remove. - -2003-03-18 Jeffrey Stedfast <fejj@ximian.com> - - * mail-config-druid.c (mail_config_druid_new): Set the type hint - to DIALOG so that Metacity shows this window on top. Fixes bug - #39914. - -2003-03-18 Not Zed <NotZed@Ximian.com> - - * mail-vfolder.c (new_rule_clicked): validate rule & rule is - unique. Workaround for #39464. Should this just use - rule_context_add_rule_gui?? - - * mail-search.c (mail_search_destroy): unhook from the html engine - signals here, before we redisplay the message. Also make sure - this processing only happens once. For #39759. - (mail_search_finalise): dont unhook from signals here. - -2003-03-12 Not Zed <NotZed@Ximian.com> - - * mail-callbacks.c (expunge_folder): use a hack to find out if the - message-list was focussed before we desensitise it. - (expunged_folder): If the message-list was focussed before, - re-grab the focus. For bug #29564. - -2003-03-17 Ettore Perazzoli <ettore@ximian.com> - - * mail-signature-editor.c (mail_signature_editor): Give the editor - the GDK_WINDOW_TYPE_HINT_DIALOG hint. [#38926] - -2003-03-17 Jeffrey Stedfast <fejj@ximian.com> - - * mail-display.c (pixbuf_gen_idle): If we fail to load the pixbuf, - don't use it (stops some g_warnings). - - Part of a fix for bug #39809 - - * mail-vfolder.c (vfolder_edit): Don't add the cancel button here. - - * mail-callbacks.c (filter_edit): Don't add the cancel button here. - -2003-03-17 Jeffrey Stedfast <fejj@ximian.com> +2003-03-14 Jeffrey Stedfast <fejj@ximian.com> * mail-display.c (do_external_viewer): Lookup the handler for the type. If we don't have a registered handler or if the registered - handler is not meant to be handled via a bonobo component, don't - use a bonobo component. + handler is not meant to be handled by a bonobo-component, don't + use a bonobo-component. * mail-format.c (mail_lookup_handler): If we register a new - handler that is to be handled by a bonobo component, set + handler that is to be handled by a bonobo-component, set handler->is_bonobo to TRUE. -2003-03-14 Dan Winship <danw@ximian.com> - - * component-factory.c (storage_connect, storage_connected): Update - for EvolutionStorage change - -2003-03-12 Jeffrey Stedfast <fejj@ximian.com> +2003-03-13 Jeffrey Stedfast <fejj@ximian.com> - * mail-signature-editor.c (menu_file_save_cb): Rewritten to do the - same as the composer's build_message() code. - -2003-03-11 Jeffrey Stedfast <fejj@ximian.com> - - * mail-accounts.c (account_add_clicked): Use - gtk_window_set_transient_for() on the druid with the settings - dialog as the parent window. + * mail-format.c (try_uudecoding): Don't use isspace() when looking + for the beginning of the filename, instead just check for ' ' and + '\t'. If the first non-blank location == eoln, then this is not a + valid uuencode line, so abort. + (handle_text_plain): Instead of using !g_strcasecmp (mime_type, + "text/plain") to see if the part is really text/plain, check + instead the ContentType on the CamelDataWrapper since mime_type + could be just the handler type. This will prevent uudecoding of + parts that are actually application/octet-stream which were + detected as text/plain by gnome-vfs. 2003-03-10 Jeffrey Stedfast <fejj@ximian.com> - * mail-signature-editor.c (do_exit): Remove the yes/no - buttons. Fixes bug #39382. - - * mail-accounts.c (account_able_toggled): New callback function to - handle the checkbox getting toggled. - (mail_accounts_treeview_new): Save the toggle renderer so we can - later connect to it's toggled signal. - (mail_accounts_tab_construct): Connect to the toggle-cell's - toggled signal. Fixes bug #39325. - -2003-03-11 Not Zed <NotZed@Ximian.com> - - * mail-vfolder.c (vfolder_editor_response): Fix the response code, - because some bastard changed the filter/* code and didn't fix the - callers. Partial fix for #39165. - -2003-03-10 Not Zed <NotZed@Ximian.com> - - * Makefile.am (libevolution_mail_la_SOURCES): removed main.c from - the build. - - * component-factory.c (component_factory_init): Remove, not used - anymore, causes linking problems some places. - (factory): Removed the debug printf. Added a case for the - composer. Part of fixing #39256. - -2003-03-07 Jeffrey Stedfast <fejj@ximian.com> - - All this snot just to fix bug #38925 and an attempt to fix bug - #38926 (but it seems no matter what I do, I can't work around the - bonoboness/modality/whatever of the shell's preferences dialog). - - * mail-account-gui.c (sig_add_new_signature): Get the toplevel - parent GtkWindow and pass that along to - mail_composer_prefs_new_signature() so that window layering can be - done correctly. - - * mail-composer-prefs.c (mail_composer_prefs_new_signature): - Simplify. We don't want to add the signature to the list until - after they have saved. - (sig_edit_cb): Pass FALSE as the is_new argument to - mail_signature_editor(). - (sig_event_client): Listen for signatures being added. - (mail_composer_prefs_new_signature): Now takes a GtkWindow arg as - the first arg rather than a MailComposerPrefs arg since we don't - really need it to be a MailComposerPrefs object. We'd rather use - the first arg as the parent GtkWindow so that we can set - transience for the editor window. - - * mail-signature-editor.c (mail_signature_editor): Now takes a - 'parent' argument (so we can set transient_for()) and a 'is_new' - argument specifying whether the editor is editing a new signature - or not. If it is, when the user saves, it will be added to the - signature list. otherwise it won't. - (sig_name_changed): Only use the mail_config_signature_set_name() - interface if it is *not* a new signature. - (menu_file_save_cb): If is_new, then save the signature to the - config - otherwise do what we did before and set the modifications - to it and emit the CHANGED event. - - * mail-config.c (mail_config_signature_new): Renamed from - mail_config_signature_add(). We no longer immediately add the - signature to the list of saved signatures. - (mail_config_signature_add): New function which adds the signature - and emits the SIG_ADDED event. - -2003-03-07 Jeffrey Stedfast <fejj@ximian.com> - - * mail-display.c (on_url_requested): If the part url is a text - part, use mail_format_data_wrapper_write_to_stream(). This should - fix bug #39204. - - * mail-format.c (mail_format_data_wrapper_write_to_stream): Make public. - -2003-03-06 Ettore Perazzoli <ettore@ximian.com> - - * mail-accounts.c (mail_accounts_treeview_new): Set the - shadow_type of the scrlled window to GTK_SHADOW_IN. - -2003-03-06 Ettore Perazzoli <ettore@ximian.com> - - * mail-config.glade: Add some spacing to the buttons. [#38227] - -2003-03-06 Ettore Perazzoli <ettore@ximian.com> - - * importers/evolution-mbox-importer.c (IN): Use G_GNUC_FUNCTION - instead of __FUNCTION__. - (OUT): Likewise. - * importers/netscape-importer.c (netscape_import_file): Likewise. - * mail-send-recv.c (receive_done): Likewise. - * mail-summary.c (SUMMARY_OUT): Likewise. - (SUMMARY_IN): Likewise. - (folder_changed_cb): Likewise. - (message_changed_cb): Likewise. - -2003-03-06 Jeffrey Stedfast <fejj@ximian.com> - - * folder-browser-factory.c: #include <string.h> - - * e-searching-tokenizer.c (camel_utf8_getc): Don't use __inline__ - as not all platforms/compilers support this keyword. - (g): Same. - -2003-03-06 Not Zed <NotZed@Ximian.com> - - * component-factory.c (owner_unset_cb): remove debug printf. - -2003-03-05 Not Zed <NotZed@Ximian.com> - - * component-factory.c (idle_quit): Removed old quit code. - (owner_unset_cb): Make this call synchronous. Wont cover all - cases but should be ok most of the time. + * mail-session.c (request_password): No need to convert the prompt + from Camel into UTF-8 (first, gtk widgets don't want UTF-8 and + second, the camel strings are already translated). Fixes bug + #36453. 2003-03-04 Jeffrey Stedfast <fejj@ximian.com> - * mail-search.c: Prototype some functions to shut the compiler up. - - * mail-callbacks.c (composer_get_message): Go back to using - e_destination_get_address() but use the camel-address parser on - the strings to make sure they are non-empty. Fixes bug #37854. - -2003-03-03 Jeffrey Stedfast <fejj@ximian.com> - - * mail-signature-editor.c (menu_file_save_cb): Use 'filename' when - creating the uri rather than using the uninitialised 'uri' - variable to create itself. Fixes bug #38864. - -2003-03-03 Not Zed <NotZed@Ximian.com> - - * mail-session.c (do_user_message): Do the same as below for - request_password, so we dont leave a mainloop lying around. - -2003-03-03 Jeffrey Stedfast <fejj@ximian.com> - - * mail-session.c (request_password): Don't connect to the response - signal if we are in the main thread - instead just use the return - value from gtk_dialog_run and then call pass_response() with the - response value. - -2003-03-03 Not Zed <NotZed@Ximian.com> - - * subscribe-dialog.c (fe_got_children): Remove the - e_tree_memory_sort_node, currently it crashes inside gal, the root - node seems to get free'd under it. - -2003-02-26 Jeffrey Stedfast <fejj@ximian.com> - - * mail-preferences.c: Reverted back to using e-iconv - - * mail-composer-preferences.c: Same. - -2003-02-26 Dan Winship <danw@ximian.com> - - * GNOME_Evolution_Mail.server.in.in: add a repo_id and a priority - level to the startup wizard - -2003-02-25 Jeffrey Stedfast <fejj@ximian.com> - - * mail-format.c: Reverted back to using e-iconv instead of - camel-iconv. - -2003-02-25 Dan Winship <danw@ximian.com> + * mail-callbacks.c (composer_get_message): Revert my prior change + to this code as it prevented users from sending to + address-lists. Instead make the code decode the addresses from + e_destination_get_address() to make sure they contain a valid + address (or list of addresses). See bug #37854 for details. - * mail-config-druid.c: Update for new EvolutionWizard interfaces. - -2003-02-25 Dan Winship <danw@ximian.com> - - * mail-config-druid.c: Redo this to not use the CORBA interfaces - in the local case (in preparation for redoing the CORBA - interfaces). - (mail_config_druid_new): Remove unused "shell" arg - - * mail-account-gui.c (mail_account_gui_transport_complete): Don't - crash if there's no transport selected at all. - (mail_account_gui_new): Don't try to set cc_addrs/bcc_addrs if - they're NULL. - - * mail-accounts.c (account_add_clicked): Don't need to pass shell - to mail_config_druid_new. - - * mail-callbacks.c (configure_mail): Don't need to pass shell to - mail_config_druid_new. - -2003-02-24 Jeffrey Stedfast <fejj@ximian.com> - - * mail-session.c (request_password): Make sure m->config_service - is non-NULL before using m->config_service->save_passwd since PGP - stuff will not have a config_service. Fixes bug #38149. - - * mail-account-gui.c (mail_account_gui_save): - s/e_account_list_changed/e_account_list_change - otherwise we get - an undefined symbol and we crash :-) - - * mail-composer-prefs.c (mail_composer_prefs_new_signature): Don't - always append "[script]" to the signature name. Also cleaned up - some memory leakage. - -2003-02-20 Not Zed <NotZed@Ximian.com> - - * mail-preferences.c (mail_preferences_apply): fix the g_snprintf - stuff. - - * mail-config.c (mail_config_add_account): Use new - e_account_list_add. - (mail_config_remove_account): Use new e_account_list_remove. - (mail_config_set_default_account): Similarly for - e_account_list_set_default. - (mail_config_get_default_account): Same for - e_account_list_get_default. - (mail_config_get_account_by_name): Use e_account_list_find. +2003-02-23 Jeffrey Stedfast <fejj@ximian.com> - * mail-account-gui.c (mail_account_gui_save): use new - e_account_list_changed call instead of manual signalling. + * mail-format.c (write_text_header): Add + E_TEXT_TO_HTML_CONVERT_SPACES to the flags. Fixes bug #38499. 2003-02-23 Jeffrey Stedfast <fejj@ximian.com> @@ -556,440 +48,21 @@ string rather than NULL to prevent a segfault on solaris. Fixes bug #38418. -2003-02-23 Jeffrey Stedfast <fejj@ximian.com> - - * mail-format.c (write_text_header): bitwise-or in - CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES to fix bug #38499. - - * mail-search.c (mail_search_destroy): New overloaded virtual - method, does what dialog_destroy_cb was trying to do. - (mail_search_construct): Connect to the "response" signal rather - than "clicked" to correspond to the GtkDialog API - (instead og the old GnomeDialog API). - (dialog_response_cb): Changed the function name and made it check - button == GTK_RESPONSE_ACCEPT to search, any other button - closes. Fixes bug #37947. - -2003-02-21 Hans Petter Jansson <hpj@ximian.com> - - * component-factory.c (factory): Don't try to get a FontPrefs control. - - * mail-config-factory.c (mail_config_control_factory_cb): Just return - NULL if a FontPrefs control was requested. - - * mail-config.c (mail_config_get_default_account): If no accounts - are defined, don't try to set the default account. - -2003-02-21 Dan Winship <danw@ximian.com> - - * Makefile.am (libevolution_mail_la_LIBADD): Remove libebook's - dependencies. - - * importers/Makefile.am (libevolution_pine_importer_la_LIBADD): - Likewise. - -2003-02-21 Dan Winship <danw@ximian.com> - - * mail-account-gui.c (mail_account_gui_build_extra_conf): Use - tables instead of vboxes, so that groups of label/entry pairs (as - in Connector's config page) can line up nicely. - - * mail-config.glade: Turn extra_vbox and extra_mailcheck_vbox into - tables. - - * mail-config-druid.c (get_fn): s/extra_vbox/extra_table/ - - * Makefile.am (libevolution_mail_la_LIBADD): - s/libcomposer.a/libcomposer.la/ - 2003-02-20 Jeffrey Stedfast <fejj@ximian.com> - * mail-callbacks.c (mark_all_as_seen): Use - camel_folder_free_uids(). - - * mail-format.c (write_headers): Use - camel_charset_canonical_name() here instead of - e_iconv_charset_name(). - - * mail-preferences.c (mail_preferences_construct): Same as below. - (mail_preferences_apply): Again here. - - * mail-composer-prefs.c (mail_composer_prefs_construct): Use - camel_charset_locale_name() here instead of - e_iconv_locale_charset(). - (mail_composer_prefs_apply): Same. - -2003-02-20 Dan Winship <danw@ximian.com> - - * Makefile.am (libevolution_mail_la_LIBADD): - s/libemiscwidgets.a/libemiscwidgets.la/ and likewise for - libefilterbar + * mail-callbacks.c (flag_messages): Revert a bogus patch that I + must have accidently committed? 2003-02-18 Jeffrey Stedfast <fejj@ximian.com> - * mail-callbacks.c (mark_all_as_seen): Fixed a memory leak - make - sure to free all uids. - - * mail-config.c (uri_to_key): Removed. - (lookup_signature): Removed. - (xml_get_int): Removed. - (xml_get_bool): Removed. - (mail_config_get_time_24hour): Removed. - - * evolution-mail.schemas: s/long/int/g and change default_account - to be a string instead of an int. - - * mail-config.c (mail_config_get_default_account): default_account - now uses the account uid, so change the code a bit to match uid - strings rather than use an index. - (mail_config_remove_account): Same here. simplifies the code a - bunch. - (mail_config_set_default_account): Here too. - - * folder-browser-ui.c (folder_browser_ui_setup_view_menus): Update - the GalView path. - -2003-02-14 Jeffrey Stedfast <fejj@ximian.com> - - * mail-session.c (do_get_pass): Change the logic here - slightly. Instead of only reprompting the user if the cache is - empty, also reprompt the user if the backend is forcing a - reprompt. - (request_password): If we have a cached passwd string for the - account, fill-in the GtkEntry box with that value by - default. This, together with the camel changes, fixes the - "Evolution forgets my POP passwd if it gets a -ERR response during - the login phase" bug. - -2003-02-13 Jeffrey Stedfast <fejj@ximian.com> - - * e-searching-tokenizer.c: #include <stdio.h> - - * mail-config-factory.c: #include <string.h> - - * mail-config-druid.c (identity_prepare): Use - gtk_editable_select_region() since gtk_entry_select_region() has - been deprecated. - (construct): Use gtk_window_set_resizable() instead of - gtk_window_set_policy(). - (wizard_free): account_destroy() is no longer around, use - g_object_unref() instead. (how did this even compile before?) - - * mail-account-gui.c (mail_account_gui_build_extra_conf): Use - gtk_label_set_text_with_mnemonic() instead of - gtk_label_parse_uline() as the latter has been deprecated. - -2003-02-12 Jeffrey Stedfast <fejj@ximian.com> - - * importers/netscape-importer.c: Removed unused variables. - - * importers/pine-importer.c: Removed unused variables. - (parse_address): Removed - it's unused and we have CamelAddress - available to us anyway. - - * importers/elm-importer.c: Removed unused variables. - - * importers/evolution-mbox-importer.c (load_file_fn): Removed an - unused variable. - -2003-02-11 Jeffrey Stedfast <fejj@ximian.com> - - * mail-account-editor.c (construct): Use - gtk_window_set_resizable() instead of gtk_window_set_policy(). - - * mail-config.c: Fix a bunch of warnings. - (mail_config_signature_write): Removed. - - * mail-callbacks.c: Removed unused variables. - - * mail-accounts.c (mail_accounts_tab_class_init): Register a - destroy virtual method. - (mail_accounts_tab_destroy): Set mail_display->destroyed = TRUE. - - * message-list.c (message_list_destroy): Set - mail_display->destroyed = TRUE. This is a workaround for the - GTK_OBJECT_DESTROYED() macro that we used to use before. - - * mail-display.c (mail_display_destroy): Set - mail_display->destroyed = TRUE. This is a workaround for the - GTK_OBJECT_DESTROYED() macro that we used to use before. - -2003-02-10 Jeffrey Stedfast <fejj@ximian.com> - - * message-list.c (build_tree): Use g_signal_emit() rather than - gtk_signal_emit(). - (build_flat): Same here. - - * mail-signature-editor.c: #include <string.h> - - * mail-vfolder.c: #include <string.h> - - * mail-session.c: #include <string.h> - - * mail-search.c: #include <string.h> - - * mail-mt.c: #include <string.h> - - * mail-ops.c (save_part_save): Use strcasecmp() instead of - g_strcasecmp(). - - * mail-local.c: #include <string.h> - (reconfigure_folder_reconfigured): Use a GtkDialog instead of - gnome_error_dialog(). - - * mail-format.c (find_preferred_alternative): Use g_ascii_strdown - since g_strdown is deprecated. - (fake_mime_part_from_data): Removed, no longer used it seems. - (destroy_part): Also removed. - - * mail-display.c (make_popup_window): Replace call to - gtk_window_set_polociy() with gtk_window_set_resizable() instead. - (popup_size_allocate_cb): Use gtk_window_set_position() with - GTK_WIN_POS_MOUSE instead of calculating the position to put it - in. - -2003-02-10 Ettore Perazzoli <ettore@ximian.com> - - * importers/Makefile.am: Split the ORBit IDL compilation rules to - work properly with parallel makes. - (BUILT_SOURCES): Add this. - (CLEANFILES): Add this. - - * Makefile.am: Split the ORBit IDL compilation rules to work - properly with parallel makes. - (BUILT_SOURCES): Add $(IDL_GENERATED) here. - (CLEANFILES): Remove from here. - -2003-02-10 Rodney Dawes <dobey@ximian.com> - - * importers/Makefile.am: Add LDFLAGS to ported libs - -2003-02-10 Larry Ewing <lewing@ximian.com> - - * mail-display.c (save_url): look in the http cache for images - when saving - (image_save_as): remove random warning. - (do_external_viewer): remove unused variable. - (do_attachment_header): use g_ascii_strdown - -2003-02-07 Larry Ewing <lewing@ximian.com> - - * mail-display.c (save_data_cb): don't use random memory as a - gconf client. - -2003-02-06 Chris Toshok <toshok@ximian.com> - - * importers/pine-importer.c (import_addressbook): track change to - e_book_load_uri type. - -2003-02-06 Ettore Perazzoli <ettore@ximian.com> - - * folder-browser.c (on_right_click): Use - e_auto_kill_popup_menu_on_selection_done() instead of - e_auto_kill_popup_menu_on_hide(). - -2003-02-06 Dan Winship <danw@ximian.com> - - * Makefile.am (INCLUDES): add EVOLUTION_PRIVDATADIR. Fix - EVOLUTION_ICONSDIR - - * component-factory.c (owner_set_cb): Use EVOLUTION_PRIVDATADIR - * mail-autofilter.c (filter_gui_add_from_message): Likewise - (mail_filter_rename_uri): Likewise - (mail_filter_delete_uri): Likewise - * mail-callbacks.c (filter_edit): Likewise. - * mail-search-dialogue.c (mail_search_dialogue_construct): - Likewise - * mail-session.c (main_get_filter_driver): Likewise - * mail-summary.c (generate_folder_summaries): Likewise - * mail-vfolder.c (vfolder_load_storage): Likewise - -2003-02-06 Dan Winship <danw@ximian.com> - - * Makefile.am: Remove *dir defs that are in configure.in now - (INCLUDES): clean up using new *dir variables - (libevolution_mail_la_LDFLAGS): remove -export-dynamic, add - -module - - * main.c (main): s/PACKAGE/GETTEXT_PACKAGE/ in gettext init - - * importers/Makefile.am (INCLUDES): change EVOLUTION_DATADIR to - EVOLUTION_PRIVDATADIR - - * importers/netscape-importer.c (netscape_import_filters): use - EVOLUTION_PRIVDATADIR - -2003-02-06 Larry Ewing <lewing@ximian.com> - - * mail-session.c (pass_activate): add an activate handler to the - entry so that hitting return will return an OK response. - -2003-02-05 Dan Winship <danw@ximian.com> - - * main.c (main): s/glade_gnome_init/glade_init/ - -2003-02-05 Not Zed <NotZed@Ximian.com> - - * importers/netscape-importer.c: update from ../../importers/. - (main): Removed. - (mail_importer_module_init): Setup module init fn. - (factory_fn): api changes. - (is_dir_empty): deprecated changes, and clean up logic. - (importer_cb): pulse progress bar, use idle function for - processing next item. - (import_next): Remove link before recursing, also fix memleak, and - api changes. - (netscape_import_file): dont release importer. - (*): gconf'ify - - * importers/elm-importer.c (elm_factory_fn): Track the - evolution_intelligent_importer, so we can unref it when done. - (*): gconf'ify. - - * importers/pine-importer.c (parse_line): use gobject stuff rather - than gtkobject. - (import_addressfile): close down 'properly' when finished. - (importer_timeout_fn): Do most processing decisions here, either - from a timeout or idle function. This prevents us getting 1 stack - frame per message and per folder. Close down properly also. - (importer_cb): Add a timeout, ignore the callback, or add an idle - function to process the next item. - (pine_import_file): dont release the importer if we can't load it, - its released elsewhere, i think. - (import_addressfile): step the progress bar as we go. - (factory_fn): Track the evolution_intelligent_importer, so we can - unref when done. - (*): gconf'ify - -2003-01-31 Not Zed <NotZed@Ximian.com> - - * importers/elm-importer.c (elm_can_import): g_file_exists -> - lstat, and g_build_filename api changes. - - * importers/pine-importer.c: moved from - ../../importers/pine-importer.c - (factory_fn): oaf->bonobo_activation - (mail_importer_module_init): setup factory. - (main): Removed. - (*): REemove bonobo config stuff. - (factory_fn): destroy signal -> weak ref. - (pine_destroy_cb): Fix signature for weak ref notify. - (import_addressfile): use new glib filename stuff. - (import_addressbook): same. - (pine_can_import): and here. - (import_next): and here. - (scan_dir): and here - (pine_create_structure): And here. - (pine_can_import): g_file_exists -> lstat. - (importer_cb): If there are more items, use an idle handler to - drop back a few stack frames rather than recursing for each - message. - (import_next): unlink data from dir_list before recursing, and fix - leak. - -2003-01-30 Not Zed <NotZed@Ximian.com> - - * importers/elm-importer.c (elm_destroy_cb): Change for weak ref - setup. - (elm_factory_fn): destroy -> weak ref. - -2003-01-29 Not Zed <NotZed@Ximian.com> - - * importers/elm-importer.c (importer_cb): Pass processItem off to - an idle handler, so we dont blow our stacks. Also update to use - progress_bar_pulse(). - (import_item_idle): Get the next message here instead. - (import_next): Fix a glist leak. Unlink the file before we import - it too. And close the dialogue and clean up when we've run out of - folders to import. - -2003-01-17 Not Zed <NotZed@Ximian.com> - - * importers/elm-importer.c (elm_create_structure): use/free elmdir - rather than double-free maildir. - -2003-01-16 Not Zed <NotZed@Ximian.com> - - * importers/elm-importer.c: update from ../importers/elm-importer.c - -2003-02-03 Jeffrey Stedfast <fejj@ximian.com> - - * message-list.c (mail_regen_list): Get the thread_subject setting - here instead of in regen_list_regen since that function will be - called in another thread and we can't make corba calls in anything - but the main thread. - (regen_list_regen): Don't make CORBA calls here! (shame on me). - - * mail-identify.c (mail_identify_mime_part): Just use - gnome_vfs_get_mime_type_from_name() so we can forget all the crap - I implemented before. - -2003-02-01 Jeffrey Stedfast <fejj@ximian.com> - - * mail-display.c (on_link_clicked): Pass in the *address* of the - GError to gnome_url_show(), otherwise bad things happen :-) - -2003-01-31 Jeffrey Stedfast <fejj@ximian.com> - - * mail-config.c (mail_config_get_labels): New function to return a - cached list of labels. - (mail_config_get_label_color_by_name): New convenience function to - search the cached labels. - (mail_config_get_label_color_by_index): Same. - (mail_config_init): Cache the labels and also listen for changes - to them in the gconf db. - (config_cache_labels): Internal function to cache the labels. + * mail-callbacks.c (mark_all_as_seen): Fixed a memory leak. We + need to free each individual uid string in the array, they aren't + const char *'s. - * folder-browser.c (on_right_click): Fixed the label colours in - the menu by using the cached linked list of labels. - - * mail-preferences.c (colorpicker_set_color): Now takes a string - argument allowing us to get rid of converting a string into an rgb - guint32 all over the place when trying to set defaults, since we - now store colors in gconf as strings. - (mail_preferences_construct): Use the cached labels (they are - already parsed for us). - -2003-01-27 Jeffrey Stedfast <fejj@ximian.com> - - * component-factory.c (storage_remove_folder): Change - strcmp(fi->path, path) to strcmp(fi->name, name) and now the - execution takes the right path. My patch base on Callie's patch - for bug #33525. - - * mail-identify.c (mail_identify_mime_part): Fixed a #warning by - converting a local path into a file: uri before feeding it to - gnome-vfs. - - * message-list.c (message_list_set_folder): Removed a FIXME that - I've decided is no longer needed. - -2003-01-22 Jeffrey Stedfast <fejj@ximian.com> - - * mail-config.c (mail_config_add_account): Emit the account-added - event. - (mail_config_remove_account): Emit the account-removed event. - - * mail-account-gui.c (mail_account_gui_save): Emit the changed - event on the account-list for the changed account. - -2003-01-24 Jeffrey Stedfast <fejj@ximian.com> - - * folder-browser-ui.c (folder_browser_ui_add_global): Set the - paned_size here. - - * folder-browser.c (folder_browser_gui_init): Don't bother - connecting to the hide-deleted, message-display-style, paned-size, - nor show-preview gconf notifications anymore, since we can just - set them when the view becomes active again in - folder-browser-ui.c. Cuts down on extra overhead. - (folder_browser_destroy): No need to disconnect from those - notifications anymore either. - -2003-01-24 Ettore Perazzoli <ettore@ximian.com> +2003-01-24 Not Zed <NotZed@Ximian.com> - * Makefile.am (iconsdir): Remove, this is now defined in - configure.in. + * mail-local.c (non_equal): We do actually need to check they are + file url's, otherwise, all file url's match. 2002-12-07 leon.zhang <leon.zhang@sun.com> @@ -1009,636 +82,31 @@ send_to_url. Fixes bug #35123 #35289 + +2003-01-24 Antonio Xu <antonio.xu@sun.com> -2003-01-24 Not Zed <NotZed@Ximian.com> - - * mail-local.c (non_equal): We do actually need to check they are - file url's, otherwise, all url's match. - -2003-01-23 Rodney Dawes <dobey@ximian.com> - - * folder-browser.c (fb_resize_cb): Use button_release instead of - size_allocate, and get the position from the Paned widget to prevent - calling CORBA all the time for GConf stuff - -2003-01-23 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (componentdir): Removed definition; this is now - defined in configure.in. - -2003-01-22 Jeffrey Stedfast <fejj@ximian.com> - - * mail-config.c (mail_config_get_thread_list): Removed. - (mail_config_set_thread_list): Removed. - (mail_config_uri_renamed): No longer needs to change threaded - state for each url either. - (mail_config_write_on_exit): Updated. - - * folder-browser-ui.c (folder_browser_ui_add_list): Get the - threaded state via gconf. - - * folder-browser.c (folder_browser_toggle_threads): Save the - threaded state. - -2003-01-22 Ettore Perazzoli <ettore@ximian.com> - - * folder-browser-ui.c (folder_browser_ui_setup_view_menus): Use - EVOLUTION_GALVIEWSDIR. - - * message-browser.c (set_bonobo_ui): Get - evolution-mail-messagedisplay.xml from EVOLUTION_UIDIR. - - * mail-signature-editor.c (mail_signature_editor): Get - evolution-signature-editor.xml from EVOLUTION_UIDIR. - - * folder-browser-ui.c (ui_add): Get the evoluiton-mail* XML files - from EVOLUTION_UIDIR. - - * Makefile.am (INCLUDES): Define EVOLUTION_GALVIEWSDIR; update - EVOLUTION_IMAGESDIR to include the $(BASE_VERSION). - (gladedir): Version using $(BASE_VERSION). - (etspecdir): Likewise. - (iconsdir): Likewise. - (buttonsdir): Likewise. - (etspecdir): Likewise. - - * component-factory.c (owner_set_cb): Look for vfoldertypes.xml in - the new version-aware location. - * mail-summary.c (generate_folder_summaries): Likewise. - * mail-search-dialogue.c (mail_search_dialogue_construct): Likewise. - * mail-vfolder.c (vfolder_load_storage): Likewise. - - * mail-autofilter.c (filter_gui_add_from_message): Look for - filtertypes.xml in the new version-aware location. - (mail_filter_rename_uri): Likewise. - (mail_filter_delete_uri): Likewise. - * mail-session.c (main_get_filter_driver): Likewise. - * mail-callbacks.c (filter_edit): Likewise. - -2003-01-22 Radek Doulik <rodo@ximian.com> - - * mail-callbacks.c (do_mail_print): put unrealized html widget - into top level widget (gtk window) before realizing it - destroy temporary widgets (w, html) - -2003-01-21 Jeffrey Stedfast <fejj@ximian.com> - - * mail-config.c (mail_config_remove_account): Don't unref the - account object, e_list_remove() apparently handles this for us. - - * mail-accounts.c (account_delete_clicked): Don't unref the - confirm dialog, it was already destroyed. - -2003-01-20 Jeffrey Stedfast <fejj@ximian.com> - - * evolution-mail.schemas: Default to hiding deleted - messages. Fixes bug #35929. - - * mail-preferences.c (entry_changed): Removed. - (toggle_button_toggled): Removed. - (settings_changed): New callback that replaces the two above. No - need to have multiple callback functions when the signature is the - same. - - * folder-browser.c (folder_browser_toggle_hide_deleted): Don't - !atoi (state) for the message_list_set_hidedeleted() call. - -2003-01-18 Larry Ewing <lewing@ximian.com> - - * mail-callbacks.c (save_msg_ok): e_question returns a boolean, - don't test for a specific value. - - * mail-display.c (html_button_press_event): make the event - handlers return FALSE so that gtkhtml can process the events. - (on_link_clicked): call gnome_url_show with all its arguments so - that it actually does something. Also pass news and nntp urls to - gnome_url_show so that they can be handled properly. - -2003-01-17 Larry Ewing <lewing@ximian.com> - - * mail-format.c (handle_text_enriched): wrap eriched entries with - a table so that they get proper indentation. - -2003-01-17 Jeffrey Stedfast <fejj@ximian.com> - - * mail-session.c (do_get_pass): Updated. - (request_password): Same. - - * mail-send-recv.c (mail_send): Fixed to use EAccountService. - - * mail-config-druid.c (make_account): Updated to use EAccount and - friends. - - * mail-account-gui.c (service_check_supported): Updated to use - EAccountService. - (mail_account_gui_new): Ref the account passed in and also update - to use EAccount objects. - (save_service): Updated to use an EAccountService. - (add_new_store): Updated to use an EAccount. - (mail_account_gui_save): Updated to use EAccounts. - (setup_signatures): Updated because the new account->id->def_sig - is now an int and not a structure pointer. - - * mail-account-editor.c (construct): Updated. - (mail_account_editor_new): Now takes an EAccount object as an - argument instead of a MailConfigAccount. - - * mail-crypto.c (mail_crypto_get_pgp_cipher_context): Updated to - use EAccounts. - - * subscribe-dialog.c (populate_store_foreach): Removed. - (populate_store_list): Can't use populate_store_foreach here - because of the change to EAccountList so do it manually. - - * mail-vfolder.c (uri_is_ignore): Rewrote to use EAccountList and - EIterator and all that fun. - - * mail-send-recv.c (build_dialogue): Updated to use EAccountList - and EAccount object stuff. *ugh* - (mail_send_receive): Here too. - (mail_autoreceive_setup): Same. - - * mail-callbacks.c (check_send_configuration): Updated. - (composer_get_message): Updated. - (compose_msg): " - (list_add_addresses): " - (guess_me): " - (guess_me_from_accounts): Same. - (forward_get_composer): Here too. - (mail_generate_reply): Same. - (redirect_get_composer): " - (empty_trash): And finally here. - - * mail-accounts.c (account_edit_clicked): Updated. - (account_delete_clicked): Same. - (account_default_clicked): Here too. - (account_able_clicked): " - (account_cursor_change): " - (mail_accounts_load): Again here. - - * folder-browser.c (folder_browser_is_drafts): Updated to use - EAccountList and EAccount stuff. - (folder_browser_is_sent): Same. - - * component-factory.c (mail_load_storages): Updated to use - EAccount and EAccountList stuff. - (owner_set_cb): Same. - (send_receive_cb): Here too. - - * mail-config.c: Rewritten to use EAccount and EAccountList - objects. - -2003-01-16 Jeffrey Stedfast <fejj@ximian.com> - - * mail-config-druid.c (get_fn): Connect to the toggled event on - the transport_needs_auth toggle button so if the user turns this - off after having deleted the username field, the Next button - becomes re-enabled. Fixes bug #36862. - -2003-01-16 Jeffrey Stedfast <fejj@ximian.com> - - * mail-composer-prefs.c (sig_fill_clist): Same as below. - - * mail-account-gui.c (sig_fill_options): - mail_config_get_signature_list() now returns a GSList instead of a - GList. - - * mail-config.c (signature_new_from_xml): New function to parse a - signature xml blob into a MailConfigSignature structure. - (config_read_signatures): Rewritten to use above function. - (signature_to_xml): New function to write a signature to xml. - (config_write_signatures_num): Removed. - (config_write_signature): Removed. - (config_write_signatures): Rewritten to use signature_to_xml and - gconf. - -2003-01-16 Dan Winship <danw@ximian.com> - - * mail-config.h (MailConfigAccount): Add a UID field (to match - EAccount), which never changes and can be used by gconf watchers - to distinguish an account rename from a deletion and creation. - - * mail-config.c (account_copy): Create a new UID on the new - account. - (account_new_from_xml): Read the UID. (If it doesn't have one, - make one.) - (account_to_xml): Write the UID. - - * mail-config-druid.c (make_account): add a UID to each account - -2003-01-15 Not Zed <NotZed@Ximian.com> - - * mail-accounts.c (account_able_clicked): Change the - enable/disable button when the state changes. - -2003-01-15 Jeffrey Stedfast <fejj@ximian.com> - - * mail-local.c (save_metainfo): Back to using e_xml_save_file(). - -2003-01-14 Ettore Perazzoli <ettore@ximian.com> - - * message-tag-editor.c (message_tag_editor_init): Make dialog - Cancel/OK to match HIG. - - * mail-signature-editor.c (do_exit): Make confirmation dialog - Discard/Cancel/Save to match the HIG. - - * mail-composer-prefs.c (mail_composer_prefs_construct): Make - dialog Cancel/OK to match HIG. - - * mail-account-editor.c (construct): Make the dialog - Apply/Close/OK to match HIG. - -2003-01-14 Jeffrey Stedfast <fejj@ximian.com> - - * mail-account-gui.c (mail_account_gui_save): Call - mail_config_save_accounts (). - - * mail-config.c (mail_config_save_accounts): New function to save - accounts without having to re-load them. - -2003-01-14 Radek Doulik <rodo@ximian.com> - - * folder-browser.c (etree_key): use gtk_scrolled_window_* - functions for mail_display->scroll - - * mail-display.c (mail_display_new): use gtk_scrolled_window_* - functions - - * mail-display.h: use GtkScrolledWindow instead of EScrollFrame - -2003-01-14 Jeffrey Stedfast <fejj@ximian.com> - - * mail-display.c (pixmap_press): Change the user_data argument to - be of type gpointer instead of EScrollFrame, since, well, it's not - an EScrollFrame anymore. - -2003-01-14 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (libevolution_mail_la_SOURCES): Add mail-format.h. - (EXTRA_DIST): Add $(schema_DATA). - -2003-01-14 Rodney Dawes <dobey@ximian.com> - - * Makefile.am: Make the component be unversioned as a shlib - -2003-01-14 Rodney Dawes <dobey@ximian.com> + * component-factory.c (storage_remove_folder): Change + strcmp(fi->path, path) to strcmp(fi->name, name) and now the + execution takes the right path. My patch base on Callie's patch + for bug #33525. - * folder-browser.c: Use GtkPaned instead of EPaned - 2003-01-13 Jeffrey Stedfast <fejj@ximian.com> - * mail-config.c (account_new_from_xml): Perform some sanity - checking on the auto-check-timeout value. - * folder-browser.c (folder_browser_copy): Correctly create the clipboard buffer by using a nul to delimit the uri and the list of uids. - * folder-browser-ui.c (folder_browser_ui_add_message): Check the - state of message_style in gconf and set the menus accordingly. - - * folder-browser.c (folder_browser_destroy): Remove listener for - message_style change notification. - (folder_browser_gui_init): Connect a listener for changes to - message_style. - - * mail-config.c (account_to_xml): Save the auto-check timeout - value. - (account_new_from_xml): Load the auto-check-timeout value. - -2003-01-13 Dan Winship <danw@ximian.com> - - * folder-info.c: s/BonoboXObject/BonoboObject/ - - * mail-config.c: Likewise - - * mail-offline-handler.c: Likewise - -2003-01-13 Not Zed <NotZed@Ximian.com> - - * mail-mt.c (mail_msg_check_error): hook onto destroy to remove - dialogue from active table. - (error_response): Just destroy on any response, dont unref either. - -2003-01-11 Jeffrey Stedfast <fejj@ximian.com> - - * mail-format.c (mail_format_data_wrapper_write_to_stream): - g_strdup the md->charset otherwise we'll get memory corruption - later. This may be why non-usascii text is displaying incorrectly. - -2003-01-10 Jeffrey Stedfast <fejj@ximian.com> - - * folder-browser-ui.c (folder_browser_ui_add_list): We also need - to call message_list_set_hidedeleted() here so that any - deactivated folder controls will change to the currently set state - when re-activated. - (folder_browser_ui_add_global): Same for show_preview. - - * folder-browser.c (hide_deleted_changed): Don't call - message_list_set_hidedeleted() here. - (folder_browser_toggle_hide_deleted): Instead, call it here. This - way we get a faster "response time". Also, this will make it so - that not all folder controls will regen their message-list at the - same time. - (folder_browser_toggle_preview): Same idea as the hide-deleted - changes. - (show_preview_changed): See above. - - * mail-config-druid.c (make_account): Default the new account to - enabled. - (wizard_finish_cb): Don't set enabled here. - -2003-01-10 Jeffrey Stedfast <fejj@ximian.com> - - * folder-browser.c (hide_deleted_changed): New callback for when - the HideDeleted state changes. - (folder_browser_gui_init): Listen for changes to hide_deleted so - we can update the menu state. - (folder_browser_destroy): Remove the hide_deleted notify handler. - (folder_browser_toggle_hide_deleted): When saving the setting, - remember that it is !atoi (state) rather than atoi (state) because - show vs hide. yea. - - * mail-session.c (main_get_filter_driver): notify-type is a int, - not a bool. Duh. - -2003-01-10 Jeffrey Stedfast <fejj@ximian.com> - - * component-factory.c (factory): Updated for function rename. - - * mail-config-factory.c (mail_config_control_factory_cb): - Namespaced the function name. - - * folder-browser-ui.c (folder_browser_ui_add_global): Don't add - the listener for show_preview here, it was moved into - folder-browser.c so we could detach the listener when the - folder-browser is destroyed. Also prevents a listener being added - multiple times (which was possible? before). - - * folder-browser.c (folder_browser_destroy): Remove the gconf - notify handler for show_preview. - (show_preview_changed): Moved here from folder-browser-ui.c +2003-01-09 Jeffrey Stedfast <fejj@ximian.com> * component-factory.c (storage_remove_folder): Fixed a situation in which we could notify the shell listener twice. -2003-01-10 Not Zed <NotZed@Ximian.com> - - * folder-browser.c (folder_browser_gui_init): Save the paned_size - notify handle. - (folder_browser_destroy): Remove gconf notify handler. - -2003-01-09 Chris Toshok <toshok@ximian.com> - - * mail-config-druid.c (wizard_finish_cb): enable the account - before attempting to saving it. - - * mail-accounts.c (account_delete_clicked): need to show the - buttons added to the dialog. - -2003-01-10 Not Zed <NotZed@Ximian.com> - - * mail-config.glade: Remove info.png from a couple of images, the - image is set via code at runtime. Removes some annoying runtime - warnings. - - * mail-send-recv.c (dialogue_response): dont unref the dialogue. - (dialog_destroy_cb): null out the send_recv_dialogue after destroy. - (build_dialogue): show the stop button - -2003-01-09 Chris Toshok <toshok@ximian.com> - - * folder-info.c (evolution_folder_info_notify_ready): pass bag to - bonobo_pbclient_set_boolean. - -2003-01-09 Ettore Perazzoli <ettore@ximian.com> - - * component-factory.c (owner_set_cb): Don't call - mail_config_register_factory() or - evolution_mail_config_wizard_init(). - -2003-01-09 Not Zed <NotZed@Ximian.com> - - * mail-config-druid.c: Added druidpagestart1 to the pages list. - (construct): Change the limits on the page initialisation, and - widget_show_all on the page rather than the content. - - * GNOME_Evolution_Mail.server.in.in: Make Mail a shlib component. - - * folder-info.c (evolution_folder_info_factory_init): Removed. - (evolution_folder_info_factory_fn): renamed to evolution_folder_info_new(). - - * mail-config-druid.c (evolution_mail_config_wizard_factory_fn): - Renamed to evolution_mail_config_wizard_new(). - (evolution_mail_config_wizard_init): Removed. - - * mail-config-factory.c (mail_config_register_factory): Remove. - (config_control_factory_cb): make this public. - - * Makefile.am: setup evolution-mail as a shared library. - - * component-factory.c (make_factory): implement the bonobo-plugin - factory for shlib operation. Also, preliminary work to setup mailer-specific - (factory): Implement the factory which starts various components. - - * mail-config.c (xml_get_prop): g_free->xmlFree - (account_to_xml): copy xml memory to glib memory when adding the 0 - on the end of the string. - (accounts_save): Use slightly different logic with appending to - the tail of the list, we can't use the &node trick with gslists. - (accounts_changed): Same here. - -2003-01-08 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Images are now in $(datadir)/evolution/images - instead of $(datadir)/images/evolution. - -2003-01-08 Jeffrey Stedfast <fejj@ximian.com> - - * folder-browser-ui.c (folder_browser_ui_add_global): Call - folder_browser_set_message_preview(). - - * mail-config.c (mail_config_get_show_preview): Removed. - (mail_config_set_show_preview): Removed. - - * folder-browser.c (folder_browser_toggle_preview): Simply set the - gconf show_preview setting and let the code in folder-browser-ui.c - detect it and update the UI. - - * folder-browser-ui.c (folder_browser_ui_add_global): Listen for - changed events on the show_preview setting. - - * mail-config.c (mail_config_set_default_account): Save the - setting via gconf. - (mail_config_add_account): Immediately save the list of accounts. - (mail_config_remove_account): Same. - (mail_config_signature_run_script): g_free the charset value and - use the composer's charset rather than the display charset. - (mail_config_get_default_account_num): Removed. - -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. - -2003-01-07 Dan Winship <danw@ximian.com> - - * mail-account-gui.c (mail_account_gui_auto_detect_extra_conf, - mail_account_gui_build_extra_conf): Don't translate the conf - strings. Camel already did it. - -2003-01-06 Dan Winship <danw@ximian.com> +2003-01-16 Jeffrey Stedfast <fejj@ximian.com> - * Makefile.am: remove idldir definition. (It's defined in - configure.in now) + * mail-config-druid.c (get_fn): Connect to the toggled event on + the transport_needs_auth toggle button so if the user turns this + off after having deleted the username field, the Next button + becomes re-enabled. Fixes bug #36862. 2003-01-04 Jeffrey Stedfast <fejj@ximian.com> @@ -1650,226 +118,7 @@ then the address is useless. This does all we can do mailer-side for the recent "SMTP Problem" thread. -2003-01-03 Jeffrey Stedfast <fejj@ximian.com> - - * mail-display.c: Fixed some build issues. - - * mail-search.c: Same. - - * mail-callbacks.c (save_draft_done): Use - g_signal_handlers_disconnect_by_func(). - (manage_subscriptions): Use a weak_ref instead of connecting to - the destroy event. - -2002-12-17 Jeffrey Stedfast <fejj@ximian.com> - - ...And a whole bunch more build fixes. - - * mail-vfolder.c (mail_vfolder_delete_uri): Don't use - g_string_sprintfa() anymore since it is apparently deprecated. - - * mail-session.c (main_get_filter_driver): Don't use - g_string_sprintfa() anymore since it is apparently deprecated. - - * mail-ops.c (build_from): Don't use g_string_sprintfa() anymore - since it is apparently deprecated. - - * mail-callbacks.c (ask_confirm_for_unwanted_html_mail): Don't use - g_string_sprintfa() anymore since it is apparently deprecated. - - * mail-autofilter.c: Don't use g_string_sprintfa() anymore since - it is apparently deprecated. - - * folder-browser.c: Don't use g_string_sprintfa() anymore since it - is apparently deprecated. - - * mail-search.c (mail_search_set_subject): Remove the unnecessary - g_strdup()'age as well as fix a possible buffer overrun. - - * mail-local.c (mail_local_folder_construct): Use - g_path_get_basename(). - - * mail-config-druid.c (make_account): Don't use e_utf8_* - functions. - -2002-12-16 Jeffrey Stedfast <fejj@ximian.com> - - * mail-format.c #define a STANDARD_ISSUE_TABLE_OPEN string used - for wrapping textual message parts to keep them being fully-left - justified. - (mail_format_raw_message): Wrap the content with a table so that - text isn't fully left-justified. - (write_hr): Use it here too. - (handle_text_plain): And finally here. - -2002-12-16 Jeffrey Stedfast <fejj@ximian.com> - - * mail-display.c (mail_error_printf): Use camel_text_to_html() - instead of e_text_to_html(). - (mail_text_write): Write the content directly to gtkhtml through - an html stream filter. - - * mail-format.c (attachment_header): Use camel_text_to_html() - instead of e_text_to_html(). - (write_text_header): Same. - (write_address): Here too. - (mail_get_message_rfc822): And here. - (mail_get_message_body): And finally here. - -2002-12-16 Jeffrey Stedfast <fejj@ximian.com> - - * mail-format.c (handle_text_plain): Re-implemented to use - streams. Also no need to check for html since - camel-mime-part-utils.c now does this for us and will re-tag the - mime-type as text/html thus the UI can be completely ignorant of - this process. - (handle_text_plain_flowed): Removed. - (write_one_text_plain_chunk): Removed. - (try_uudecoding): Removed. - (try_inline_binhex): Removed. - (handle_text_enriched): Re-implemented to use streams too. - -2002-12-15 Jeffrey Stedfast <fejj@ximian.com> - - * mail-format.c (write_text_header): Change the order of the args - to be consistant with other write functions. - (write_date): Same. - (write_field_row_begin): Here too. - (write_headers): Here too. - (write_one_text_plain_chunk): Don't strdup just to pass it to - mail_text_write() so that it can dup it yet again into html text - and dup it yet a 3rd time into a GByteArray. Instead just write it - to gtkhtml. - (handle_*): Fixed arguments to take a MailDisplayStream instead of - a GtkHTML widget and a GtkHMLStream. - - * mail-display.c (mail_display_render): Create a MailDisplayStream - to pass to mail_format_mime_message() and - mail_format_raw_message(). - - * mail-display-stream.[c,h]: New stream to replace - mail-stream-gtkhtml.c - - * mail-stream-gtkhtml.[c,h]: Removed. - -2002-12-13 Jeffrey Stedfast <fejj@ximian.com> - - * mail-callbacks.c (check_send_configuration): Make sure the - folder-browser is not NULL or we'll crash. - - * mail-preferences.c (mail_preferences_construct): Fix the colour - code to get a guint32 rgb correctly (I think - can't test because - the shell keeps crashing, yay). - - * message-tag-followup.c (construct): Don't re-use cell renderers - - I'm not sure this is actually safe to do. - - * mail-session.c: Get rid of unneeded CamelObject casts. - (user_message_response): Don't unref the dialog object after we've - destroyed it. - - * mail-display.c (write_data_to_file): Don't unref the dialog - object after we've destroyed it. - - * mail-callbacks.c: Same here. - - * component-factory.c: Here too. - - * message-tag-editor.c: Added MESSAGE_TAG_EDITOR_GET_CLASS macros. - -2002-12-12 Jeffrey Stedfast <fejj@ximian.com> - - * mail-accounts.c (mail_accounts_tab_construct): Setup - double-click here. - -2002-12-12 Jeffrey Stedfast <fejj@ximian.com> - - * mail-accounts.c (account_delete_clicked): Get rid of the ETable - #ifdef's - we won't ever be using ETable. - (account_default_clicked): Same. - (account_able_clicked): Here too. - (mail_accounts_load): And here. - (mail_accounts_treeview_new): Renamed from etable_new since we - won't ever be using an etable. - (mail_accounts_tab_construct): And finally here. - -2002-12-12 Not Zed <NotZed@Ximian.com> - - * folder-browser.c (my_folder_browser_init): cast a-warning a-way. - - * mail-composer-prefs.c (spell_setup): Terminate list_store_set - with -1. - - * mail-accounts.c (mail_accounts_etable_new): clist -> gtktreeview - stuff. Yes, this is not an etable. - (mail_accounts_tab_construct): Same. - (mail_accounts_load): Same. - (account_cursor_change): Same. - (account_able_clicked): And this. - (account_default_clicked): Same. - (account_delete_clicked): Guess? - (account_edit_clicked): And here too. - -2002-12-11 Jeffrey Stedfast <fejj@ximian.com> - - * mail-format.c (mail_format_data_wrapper_write_to_stream): New - function to handle a lot of the filtering/etc that was done in - mail_format_get_data_wrapper_text(). This is the first step toward - getting rid of e-text-to-html crap and using my tohtml stream - filter instead. - (mail_format_get_data_wrapper_text): Use the new function. - (mail_format_raw_message): Use camel streams to write the content - to gtkhtml rather than using get_data_wrapper_text() and then - converting that to html and then writing it to the gtkhtml stream. - -2002-12-10 Not Zed <NotZed@Ximian.com> - - * mail-composer-prefs.c (mail_composer_prefs_construct): language - is a treeview now. Not sure what to do with it yet, but get rid - of one warning anyway. - (mail_composer_prefs_construct): Same for sig_clist, but setup - model. - (sig_fill_clist): Change to use a gtktreeview instead of a clist. - (sig_selection_changed): New method to handle signature selection - changes with the new widgets. - (sig_delete): clist -> treeview. - (mail_composer_prefs_new_signature): Same. - (sig_edit): ditto. - (sig_current_sig): removed. - (sig_row_unselect): Removed. - (sig_row_select): Removed, now redundant. - (spell_select_lang): Removed, redundant. - (spell_set_ui_language): New implementation using list model more - effectively. - (spell_get_language_str): Same here. - (spell_set_ui_language): Removed this too, merged into - spell_set_ui, it was just wasting stack space. - (spell_language_selection_changed): renemd from - spell_language_select_row, converted to gtktreeview, etc. - (spell_language_unselect_row): Removed. - (spell_language_enable): Redone to use tree model. - (spell_language_button_press): Removed, i dont think this is - needed anymore. - (spell_setup): dont hook onto redundant signals. - - * mail-config-factory.c (config_control_factory_cb): ignore - mail-font-prefs in a different way (so we dont assert) - -2002-12-09 Chris Toshok <toshok@ximian.com> - - * mail-session.c (pass_response): pass "Mail" to e_passwords_*. - (do_get_pass): same. - (main_forget_password): same. - (mail_session_get_password): same. - (mail_session_remember_password): same. - (mail_session_forget_password): same. - - * mail-config.c (mail_config_write_on_exit): pass "Mail" to - e_passwords_*. - - * main.c (main): e_passwords_init is gone. - -2002-12-03 Jeffrey Stedfast <fejj@ximian.com> +2002-12-02 Jeffrey Stedfast <fejj@ximian.com> * mail-callbacks.c (guess_me_from_accounts): Use the same logic as mail_generate_reply(). Fixes bug #34882 @@ -1883,236 +132,28 @@ retval from message_rfc822_dnd() rather than relying on an exception, because one will not always necessarily be set. For MESSAGE_RFC822, also use the retval from message_rfc822_dnd(). - -2002-12-03 Not Zed <NotZed@Ximian.com> - - * folder-browser.c (folder_browser_finalise/destroy): frobbed - around with these till it exits without crashing. - - * message-list.c (message_list_destroy): made a destroy - handler again (was dispose). Frobbed around with this and - finalise till it can destroy without crashing. - - * message-browser.c (message_browser_new): ref/sink the - folderbrowser. + Based on preliminary work by Yuedong Du. 2002-11-25 Radek Doulik <rodo@ximian.com> * mail-preferences.c (mail_preferences_construct): magic_check --> magic_links_check -2002-11-27 Not Zed <NotZed@Ximian.com> - - * message-tag-followup.c (construct): gnome_pixmap -> gtkimage. - (construct): gtk_clist -> gtk_tree_view, setup columns. They dont - size well :-/ - (message_tag_followup_append_message): Append using model, remove - clist stuff. - (construct): Show date edit (glade bugs?) - - * folder-browser.c (folder_browser_class_init): gtk_marshal -> g_cclosure_marshal - (setup_popup_icons): gnome_pixmap -> gtk_image. - (on_right_click): gtk_pixmap -> gtk_image. - - * mail-accounts.c (account_delete_clicked): removed #if 0'd out code. - - * mail-send-recv.c (receive_done): remove FIXME and extra unref. - - * mail-session.c (request_password): Removed #if 0'd out stuff. - - * mail-vfolder.c (new_rule_clicked): proper cast for g_object_get_data. - - * mail-local.c (reconfigure_response): cast for g_object_get_data. - - * mail-account-editor.c (construct): GNOME_DIALOG -> GTK_DIALOG. - - * *.[ch]: re-ran fix.sh for e_notice change - - * mail-callbacks.c (save_msg_ok): g_object_get_data + - gtk_object_remove_no_notify -> g_object_steal_data. - (find_socket): gtk_container_children -> - gtk_container_get_children - (edit_msg): gnome_*_dialog -> gtk_message_dialog. - (resent_msg): " - (search_msg): " - (confirm_goto_next_folder): gtkmessagedialogised (even if not - used). - (confirm_expunge): gtkmessagedialogised - (filter_edit): " - (do_mail_print): e_notice -> gtk_message_dialog. - (are_you_sure): removed e_gnome_ok_cancel_dialog crap, replaced - with a gtk dialog. - (are_you_sure): gtkmessagedialogised. - (edit_msg_internal): Dont free uids array, are_you_sure() free's - it. - (resend_msg): Same. - (check_send_configuration): Use e_notice for stuff. Sigh, here we - go again ...! - (e_question): A utility function to ask a question, potentially - with 'dont ask again' as well. - (configure_mail): use e_question to save code. Here we go again, - again ... - (ask_confirm_for_unwanted_html_mail): " - (ask_confirm_for_only_bcc): " - (ask_confirm_for_only_bcc): " - (composer_get_message): Use e_notice. - (composer_save_draft_cb): Use e_question - (edit_msg): use e_notice, & change to an ERROR. - (resend_msg): same. - (save_msg_ok): Properly initialise ret to OK, and use e_question, - and use access() to determine existance/write access rather than - stat, display an error if we can't write to a file that exists, - and print the filename in all dialogues. - (confirm_goto_next_folder): Use e_question. - (confirm_expunge): use e_question. - (filter_edit): Use e_notice. - (do_mail_print): use e_notice. - -2002-11-26 Not Zed <NotZed@Ximian.com> - - * mail-vfolder.c (vfolder_gui_add_rule): clicked->response signal - for gtk dialogue. - (new_rule_clicked): Dont unref after destroy (duh, idiot again). - (edit_rule_response): Same here. - (mail_vfolder_delete_uri): Connect response signal to - gtk_widget_destroy directrly using g_signal_connect_swapped. - (close_dialogue): Removed, as no longer needed. - - * message-list.c (get_normalised_string): Duh idiot, "un-fixed" - the memleak i added. - - * mail-callbacks.c (composer_get_message): Set parent window in - message dialogue & DESTROY_WITH_PARENT flag. - (composer_save_draft_cb): - (configure_mail): - (check_send_configuration): Add DESTROY_WITH_PARENT flag to - gtk_message_dialog's - (local_configure_done): remove some unecessary/wrong casts. - (empty_trash_expunged_cb): " - (do_mail_print): use gtk_window_set_transient_for instead of - e_dialog_set_parent. - -2002-11-26 Not Zed <NotZed@Ximian.com> - - * mail-account-editor.c (mail_account_editor_new): - gtk_widget_set_parent_window -> gtk_window_set_transient_for. - - * mail-callbacks.c (composer_send_queued_cb): dont unref composer. - - * message-browser.c (message_browser_destroy): moved back from - finalise. - -2002-11-25 Not Zed <NotZed@Ximian.com> - - * message-list.c (message_list_dispose): move saving tree state - here. - (message_list_finalise): And take it from here. - - * mail-display.c (mail_display_destroy): @#$@# gtk. changed this - around a bit. - (mail_display_init): Fix prototype, its a gobject. - (mail_display_init): ref/sink the invisible gtkobject. - -2002-11-22 Not Zed <NotZed@Ximian.com> - - * mail-callbacks.c (ask_confirm_for_unwanted_html_mail): removed - e_messagebox, and use gtk_message_dialog directly. - (ask_confirm_for_empty_subject): and here. - (ask_confirm_for_only_bcc): And here too. - (msgbox_destroy_cb): Removed, since no longer needed. - 2002-11-15 Harry Lu <harry.lu@sun.com> * mail-display.c (write_data_to_file): Show file name when prompt - to user for overwrite. Fixes bug #34180. + to user for overwrite. -2002-11-21 Harry Lu <harry.lu@sun.com> +2002-11-20 Harry Lu <harry.lu@sun.com> - * mail-display.c (do_attachment_header): Enable dragging of all + * mail-display.c (do_attachment_header): Enable dragging of all attachments. For bug #34327. -2002-11-21 Jeffrey Stedfast <fejj@ximian.com> - - * mail-preferences.c (mail_preferences_construct): Since the - GSList returned from gconf needs to be free'd by us, we don't need - to strdup the values. Also make sure we don't leak the GSList - itself. - (mail_preferences_apply): Don't leak our GSList data. - -2002-08-30 Radek Doulik <rodo@ximian.com> - - * mail-display.c (mail_display_render): don't set margins for raw - message view - - * mail-format.c (mail_format_raw_message): as below - (handle_text_plain_flowed): as below - (mail_format_raw_message): don't use data_urls - - * mail-display.c (mail_text_write): put text in iframe, so it has - margins and should not be placed in table which changes wrapping - behavior - -2002-11-20 Jeffrey Stedfast <fejj@ximian.com> - - * mail-composer-prefs.c (mail_composer_prefs_construct): gconfify. - (mail_composer_prefs_apply): gconfify this also. - - * mail-preferences.c (mail_preferences_construct): - gconf_client_get_string() probably returns an allocated buffer. - -2002-11-20 Not Zed <NotZed@Ximian.com> - - * importers/Makefile.am (%.server.in): provide a proper implicit - rule for building .server.in from .server.in.in. The other one - just copied the first target to all destinations(!). - - * importers/evolution-outlook-importer.c (outlook_factory_fn): - destroy -> weak ref. - -2002-11-19 Jeffrey Stedfast <fejj@ximian.com> - - * mail-preferences.c (mail_preferences_apply): Save the settings - via gconf. - (mail_preferences_construct): Load the values from gconf. - 2002-11-19 Radek Doulik <rodo@ximian.com> * mail-composer-prefs.c (sig_load_preview): use gtk_html_begin_content to specify utf-8 -2002-11-19 Not Zed <NotZed@Ximian.com> - - * importers/evolution-mbox-importer.c (mail_importer_module_init): - fix warning message, outlook->mbox. - - * importers/Makefile.am: fix serverdir to point to - $libdir/bonobo/servers. - - * mail-callbacks.c (addrbook_sender): add type to - bonobo_widget_set_property. - - * mail-vfolder.c (vfolder_editor_response): dont unref after destroy. - - * mail-session.c (pass_response): dont unref aftrer destroy. - - * mail-local.c (reconfigure_response): dont unref after destroy. - - * mail-display.c (launch_cb): dont unref after destroy. - (launch_cb): " - (drag_data_get_cb): " - (html_button_press_event): add type to bonobo_widget::set_property - - * mail-config.c (mail_config_check_service): dont unref after - destroy. - - * component-factory.c (send_receive_cb): dont unref after destroy. - (request_quit): " - - * mail-signature-editor.c (mail_signature_editor): Use version 3.0 - of gtkhtml editor interfaces. - (do_exit): dont unref after destroy. - (format_html_cb): Add type to bonobo_widget::set_property. - 2002-11-18 Radek Doulik <rodo@ximian.com> * mail-composer-prefs.c (spell_setup_check_options): check @@ -2120,407 +161,13 @@ 2002-11-18 Jeffrey Stedfast <fejj@ximian.com> - * mail-accounts.c (mail_accounts_load): Specify the default - account. Also, don't need to use e_utf8_to_gtk_string() here. - -2002-11-18 Not Zed <NotZed@Ximian.com> - - * Makefile.am (evolution_mail_LDADD): Added back - libevolution-importer stuff. - (SUBDIRS): Added back importers. - - * importers/evolution-mbox-importer.c (load_file_fn): build the - uri without deprecated funcs. - (load_file_fn): dont free/alloc a camel_exception for no obvious - purpose. - (mbox_factory_fn): use weak_ref rather than destroy. - (importer_destroy_cb): fix signature for weak ref notify. - (mbox_factory_fn): add cid param. - - * importers/*.[ch]: ran fix script over everything. - - * importers/*.server.in.in: Added bonobo activation files. Moved - evolution-mail to @LIBEXEC@ as below. - - * importers/Makefile.am: oaf->bonobo activation stuff. - - * importers/evolution-outlook-importer.c (outlook_factory_fn): Add - component id to callback. - -2002-11-15 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Add rules to substitute @LIBEXEC@ in - GNOME_Evolution_Mail.server.in.in and install evolution-mail in - $(libexecdir) instead of $(bindir). + * mail-accounts.c (mail_accounts_load): Specify which account is + the default account. - * GNOME_Evolution_Mail.server.in.in: Replaced evolution-mail with - @LIBEXECDIR@/evolution-mail. - -2002-11-15 Rodney Dawes <dobey@ximian.com> - - * component-factory.c: Use bonobo_main_quit instead of gtk - 2002-11-15 Jeffrey Stedfast <fejj@ximian.com> * mail-composer-prefs.c (sig_edit): Correctly spell Advanced. -2002-11-15 Not Zed <NotZed@Ximian.com> - - * mail-summary.c (create_summary_view): weak notify -> ref. - - * mail-send-recv.c (build_dialogue): weak notify -> ref. - - * mail-accounts.c (account_edit_clicked): weak notify -> ref, i - presume this is what jeff meant, 'cause it dont compile otherwise. - -2002-11-14 Jeffrey Stedfast <fejj@ximian.com> - - * mail-accounts.c (account_edit_clicked): Use g_object_weak_ref - rather than connecting to destroy. - (account_add_clicked): Same. - - * mail-callbacks.c (addrbook_sender): Make this use - g_object_weak_notify also. - (subscribe_dialog_destroy): Add NULL guards here since I think we - really do want to connect to the "destroy" signal in the function - that connects us to that signal. - - * mail-config-factory.c (config_control_factory_cb): Same. - - * mail-display.c (save_part): Here too. - (make_popup_window): And here. - - * mail-send-recv.c (build_dialogue): Same here. - - * mail-summary.c (create_summary_view): Use g_object_weak_notify - instead of connecting to the destroy signal. - -2002-11-14 Ettore Perazzoli <ettore@ximian.com> - - * component-factory.c (owner_set_cb): Want a (GWeakNotify) cast - here, not (GWeakNotify *). - - * subscribe-dialog.c (fete_init): g_object_set() instead of - gtk_object_set(). - (populate_store_list): Likewise. - (menu_item_selected): g_object_get_data() instead of - gtk_object_get_data(). - - * message-list.c (message_list_create_extras): g_object_set() - instead of gtk_object_set(). - - * message-browser.c (message_browser_message_list_built): - g_object_get_data() instead of gtk_object_get_data(). - - * mail-vfolder.c (edit_rule_response): g_object_get_data() instead - of gtk_object_get_data(). - - * mail-summary.c (generate_folder_summaries): g_object_unref() the - context instead of gtk_object_destroy(). - - * mail-local.c (reconfigure_response): g_object_get_data() instead - of gtk_object_get_data(). - - * mail-display.c (pixbuf_gen_idle): g_object_unref() the GdkPixbuf - loader instead of gtk_object_destroy(). - (pixbuf_gen_idle): Likewise. - (embeddable_destroy_cb): Likewise. - - * mail-config-druid.c (mail_config_druid_destroy): No need to - gtk_object_destroy() the GladeXML object. - (construct): g_object_set() instead of gtk_object_set(). - - * folder-browser.c (folder_browser_gui_init): g_object_get_data() - instead of gtk_object_get_data(). - -2002-11-14 Not Zed <NotZed@Ximian.com> - - * component-factory.c (create_view): shell client objref. - (mail_add_storage): " - (mail_remove_storage): " - -2002-11-13 Joe Shaw <joe@ximian.com> - - * Makefile.am: Remove a couple backslashes that were causing - automake to complain, even though they were on lines that were - -commented out-. Sigh. - -2002-11-13 Ettore Perazzoli <ettore@ximian.com> - - * folder-info.c (evolution_folder_info_factory_fn): Use - g_object_new() instead of gtk_type_new(). - * folder-browser.c (folder_browser_new): Likewise. - * mail-account-gui.c - (mail_account_gui_folder_selector_button_new): Likewise. - * mail-font-prefs.c (mail_font_prefs_new): Likewise. - -2002-11-13 Ettore Perazzoli <ettore@ximian.com> - - * mail-format.c: Do not #include <libgnome/gnome-defs.h>. - * mail-importer.c: Likewise. - * mail-mt.c: Likewise. - * mail-ops.c: Likewise. - * mail-search-dialogue.c: Likewise. - * mail-session.c: Likewise. - * mail-vfolder.c: Likewise. - * message-tag-followup.c: Likewise. - * main.c: Likewise, and <libgnomeui/gnome-init.h>. - - * mail-callbacks.c: Do not #include <libgnome/gnome-paper.h>. - (do_mail_print): Remove the GnomePaper local variable. - -2002-11-13 Not Zed <NotZed@Ximian.com> - - * component-factory.c (owner_set_cb): destroy->weak ref. - (owner_set_cb): shell client changes. - - * mail-signature-editor.c (mail_signature_editor): bonobo api changes. - - * mail-local.c (save_metainfo): go back to using xmlSaveFile. - - * Makefile.am: Removed libevolution-importer from mail. - -2002-11-13 Not Zed <NotZed@Ximian.com> - - * GNOME_Evolution_Mail.server.in.in: Added to cvs. Currently - contains no configurable stuff, but maybe it will one day. - - * Makefile.am (server_DATA): change oaf stuff to server stuff for - bonobo activation. - - * mail-preferences.c (mail_preferences_apply): handle const entry text. - - * mail-composer-prefs.c (url_requested): Fixed typo. - (mail_composer_prefs_construct): gnomepixmap->gtkimage. - - * mail-callbacks.c (configure_mail): destroy dialogue before dealing - with response. - (mail_generate_reply): Fix a typo. - (popup_listener_cb): fix prototype. - (tag_editor_response): Handle gtk dialog response. - (flag_for_followup): Change gnome dialog to gtk dialog stuff. - (tag_editor_destroy_cb): - (tag_editor_cancel): - (tag_editor_ok): Removed, handled in _response(). - (filter_editor_response): renamed from _clicked, handle gtk - dialogue signal. - (filter_editor_destroy): Removed. - (footer_info_new): gnome font api changes. - (do_mail_print): port to gnome print 2. - - * mail-autofilter.c (mail_filter_delete_uri): message_dialog uses - a specific button enum, not the stock ones. - - * mail-accounts.c (mail_accounts_tab_get_type): gobjectify. - (account_delete_clicked): gdkdialogise. - - * mail-account-gui.c (mail_account_gui_setup): Hack around font - metric determination code. - - * mail-account-editor.c (mail_account_editor_get_type): - gobjectise. - (mail_account_editor_new): "" - - * folder-info.c (evolution_folder_info_notify_ready): use pbclient - interface. - - * folder-browser-factory.c (control_destroy_cb): fix a typo. - (folder_browser_factory_new_control): More typos. - - * folder-browser.c (on_right_click): cast around const warning. - (context_menu_position_func): fix for api change. - - * e-searching-tokenizer.c (e_searching_tokenizer_finalise): - Changed from destroy since it only frees memory. - (e_searching_tokenizer_get_type): glibify. - - * component-factory.c (request_quit): gtkdialogise. - (send_receive_cb): " - (create_component): gdk_pixbuf api. - (component_factory_init): bonobo activation stuff. - (warning_response): renamed from warning_clicked. - (owner_set_cb): gtkdialogise. - -2002-11-12 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am: Added files I've ported. - - * mail-config.c: Remove gnome-defs.h, this header no longer exists - in GNOME2. - -2002-11-13 Not Zed <NotZed@Ximian.com> - - * Makefile.am: Commented out stuff that doesn't build yet. Also - fixed idl build rule. importers still not built. - - * main.c (main): bonobactivationise. remove push visual/colormap. - (main): no longer activate activation, let bonobo_init do it. - - * mail-signature-editor.c (menu_help): Change help api. - - * mail-session.c (user_message_destroy_noreply): removed. Not - used? - - * mail-local.c (load_metainfo): xml root->children. - - * mail-format.c (g_string_append_len): Removed, it exists now. - -2002-11-12 Not Zed <NotZed@Ximian.com> - - * subscribe-dialog.c: gnome2ised, use gtkdialog. - (subscribe_get_global_extras): use a weak ref rather than destroy - signal. - - * message-tag-followup.c: gnome2ised. - - * message-tag-editor.c: gnome2ised & converted to gtkdialog. - - * message-list.c: gnome2ised. - (message_list_finalise): From destroy method. maybe should be - destroy still. - - * message-browser.c: port to gnome2 - (message_browser_finalise): renamed from destroy method. - - * mail-stream-gtkhtml.c: removed redundant - camel_class_get_global_classfuncs() call. - - * mail-signature-editor.c: gtkdialogised, & bonobo api changes. - - - * mail-search-dialogue.c: gtkdialogised. - - * mail-folder-cache.c: cleaned up camel ref/hook casts. - - * mail-composer-prefs.c (mail_composer_prefs_get_type): convert to - gtype. - - * mail-font-prefs.c (mail_font_prefs_destroy): from finalise. - - * mail-config.c: s/bonobo_config/e_config_listener/ Added - /apps/Evolution prefix to the evolution keys. Changed to use - e_config_listener, etc. - (mail_config_init): remove bonobo_config stuff. - (mail_config_check_service): gtk dialogise. - (check_response): from check_cancelled. - - * mail-config-druid.c (mail_config_druid_destroy): renamed from - _finalize, turned into destroy handler. - (construct): set type to toplevel, GTK_WINDOW_DIALOG no longer - exists. - - * mail-config-factory.c (mail_config_register_factory): bonobo api - changes. - - * mail-crypto.c (mail_crypto_get_pgp_cipher_context): cleaned up - unref casts. - - * mail-display.c (write_data_to_file): gnome->gtkdialog. - (on_link_clicked): use ascii_str*cmp on url. - (save_part): g_path stuff. - (launch_cb): gtk dialog. - (pixmap_press): de-oafify. - (pixbuf_for_mime_type): gnome-vfs api changes. - (do_attachment_header): Change the pixmap to a gtkimage. - (do_signature): " - (pixbuf_gen_idle): " - (do_attachment_header): ascii_str*cmp - (do_attachment_header): gnome pixmap->gtkimage. - (mail_display_destroy): protect against gtk mentalness. - (html_button_press_event): ascii_str*cmp - (drag_data_get_cb): added comment for translators of filename. - - * mail-format.c (component_supports): de-oafise. - (is_anonymous): ascii_strncmp - (attachment_header): remove utf8<>locale stuff, and gnomevfs api - changes. - (format_mime_part): fix g_strdown call. - (write_field_row_begin): kill utf8->gtk stuff. - (write_address): " - (default_header_index): ascii_strcasecmp - (handle_text_plain): " - (handle_text_enriched): " - (handle_multipart_encrypted): remove utf/gtk stuff. - (handle_message_external_body): ascii_str*cmp - - * mail-identify.c (mail_identify_mime_part): - (identify_by_magic): gnome vfs api changes. - - * mail-importer.c: Converted. - - * mail-local.c (load_metainfo): xml childs -> children. - (mls_get_folder): g_strerror. - (mls_delete_folder): g_strerror. - (reconfigure_got_folder): Gnome->GtkDialog - (reconfigure_response): from reconfigure_clicked. - - * mail-mt.c (mail_msg_check_error): gnome -> gtk dialog - (error_response): renmae from error_gone. destroy widget on any - response. - - * mail-offline-handler.c (impl_finalise): renamed from - impl_destroy since thats what it should be anyway. - - * mail-ops.c: removed utf8 widget conversion & camel_object_un/ref - casts. - - * mail-preferences.c (mail_preferences_get_type): glib2'ised. - - * mail-search.c (mail_search_finalise): renmaed from destroy & - properly chain. - (mail_search_get_type): glib2 & make gtkdialog parent. - (entry_run_search): run search when entry activated. not sure if - gtkdialog has anohter way to do this on an arbitrary widget. - - * mail-send-recv.c (dialogue_response): renamed from clicked. Use - gtkdialog. - - * mail-session.c (request_password_deleted): removed, redundant. - (pass_response): rename from pass_got, changed for gtkdialog. - (user_message_destroy): Removed, redundant. - (user_message_response): Renamed from user_message_clicked. - -2002-11-11 Not Zed <NotZed@Ximian.com> - - * mail-stream-gtkhtml.c (mail_stream_gtkhtml_class_init): dont use - get_global_classfuncs, just get the type - - * mail-tools.c: converted gnome2 api's. - - * mail-vfolder.c (vfolder_editor_response): clicked->response. - (vfolder_editor_destroy): Removed. - (vfolder_edit): gtk dialog api - (edit_rule_response): clicked->response. - (vfolder_edit_rule): gnomedialog->gtkdialog. - (vfolder_gui_add_rule): " - (new_rule_clicked): clicked->response - -2002-11-11 Jeffrey Stedfast <fejj@ximian.com> - - * mail-callbacks.c: Half way ported. I'll finish the rest later. - - * mail-autofilter.c: Ported. - - * mail-account-gui.c: Ported. - - * mail-account-editor.c: Ported. - - * folder-browser-ui.c: Ported. - - * folder-browser-factory.c: Ported. - - * folder-browser.c: Ported. - - * e-searching-tokenizer.c: Roughly ported. - -2002-11-10 Jeffrey Stedfast <fejj@ximian.com> - - * *.glade: Converted to libglade-2's format. - -2002-11-08 Jeffrey Stedfast <fejj@ximian.com> - - * mail-composer-prefs.c: Ported. - 2002-10-28 Jeffrey Stedfast <fejj@ximian.com> * folder-browser.c (folder_browser_query_changed): No longer need diff --git a/mail/component-factory.c b/mail/component-factory.c index e7e25493c0..e512331bd2 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -20,28 +20,18 @@ * Boston, MA 02111-1307, USA. */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif -#include <string.h> -#include <signal.h> - -#include <gconf/gconf.h> -#include <gconf/gconf-client.h> - -#include <camel/camel.h> - #include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-shlib-factory.h> - #include <gal/widgets/e-gui-utils.h> +#include "camel.h" + #include "Evolution.h" #include "evolution-storage.h" #include "evolution-wizard.h" -#include "evolution-composer.h" #include "folder-browser-factory.h" #include "evolution-shell-component.h" @@ -51,8 +41,6 @@ #include "mail.h" #include "mail-config.h" #include "mail-config-factory.h" -#include "mail-preferences.h" -#include "mail-composer-prefs.h" #include "mail-tools.h" #include "mail-ops.h" #include "mail-offline-handler.h" @@ -159,7 +147,7 @@ create_view (EvolutionShellComponent *shell_component, BonoboControl *control; shell_client = evolution_shell_component_get_owner (shell_component); - corba_shell = evolution_shell_client_corba_objref(shell_client); + corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)); if (type_is_mail (folder_type)) { const char *noselect; @@ -167,14 +155,14 @@ create_view (EvolutionShellComponent *shell_component, url = camel_url_new (physical_uri, NULL); noselect = url ? camel_url_get_param (url, "noselect") : NULL; - if (noselect && !strcasecmp (noselect, "yes")) + if (noselect && !g_strcasecmp (noselect, "yes")) control = create_noselect_control (); else control = folder_browser_factory_new_control (physical_uri, corba_shell); camel_url_free (url); } else if (type_is_vtrash (folder_type)) { - if (!strncasecmp (physical_uri, "file:", 5)) + if (!g_strncasecmp (physical_uri, "file:", 5)) control = folder_browser_factory_new_control ("vtrash:file:/", corba_shell); else control = folder_browser_factory_new_control (physical_uri, corba_shell); @@ -353,7 +341,7 @@ xfer_folder (EvolutionShellComponent *shell_component, if (remove && strcmp(src->protocol, dst->protocol) == 0) { char *sname, *dname; CamelStore *store; - + if (src->fragment) sname = src->fragment; else { @@ -362,7 +350,7 @@ xfer_folder (EvolutionShellComponent *shell_component, else sname = ""; } - + if (dst->fragment) dname = dst->fragment; else { @@ -371,11 +359,11 @@ xfer_folder (EvolutionShellComponent *shell_component, else dname = ""; } - + store = camel_session_get_store(session, source_physical_uri, &ex); if (store != NULL) camel_store_rename_folder(store, sname, dname, &ex); - + if (camel_exception_is_set(&ex)) GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev); else { @@ -387,7 +375,7 @@ xfer_folder (EvolutionShellComponent *shell_component, camel_object_unref((CamelObject *)store); } else { source = mail_tool_uri_to_folder (source_physical_uri, 0, &ex); - + if (source) { xfer_folder_data *xfd; @@ -395,17 +383,17 @@ xfer_folder (EvolutionShellComponent *shell_component, xfd->remove_source = remove_source; xfd->source_uri = g_strdup (source_physical_uri); xfd->listener = CORBA_Object_duplicate (listener, &ev); - + uids = camel_folder_get_uids (source); mail_transfer_messages (source, uids, remove_source, destination_physical_uri, CAMEL_STORE_FOLDER_CREATE, xfer_folder_done, xfd); camel_object_unref (CAMEL_OBJECT (source)); } else GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev); } - + CORBA_exception_free (&ev); camel_exception_clear (&ex); - + camel_url_free(src); camel_url_free(dst); } @@ -414,12 +402,13 @@ static void configure_folder_popup(BonoboUIComponent *component, void *user_data, const char *cname) { char *uri = user_data; - + + if (strncmp(uri, "vfolder:", 8) == 0) vfolder_edit_rule(uri); else { FolderBrowser *fb = folder_browser_factory_get_browser(uri); - + if (fb) configure_folder(component, fb, cname); else @@ -443,16 +432,14 @@ populate_folder_context_menu (EvolutionShellComponent *shell_component, if (!type_is_mail (type)) return; - + /* FIXME: handle other types */ - + /* the unmatched test is a bit of a hack but it works */ if ((strncmp(physical_uri, "vfolder:", 8) == 0 && strstr(physical_uri, "#" CAMEL_UNMATCHED_NAME) == NULL) || strncmp(physical_uri, "file:", 5) == 0) { - bonobo_ui_component_add_verb_full(uic, "ChangeFolderPropertiesPopUp", - g_cclosure_new(G_CALLBACK(configure_folder_popup), - g_strdup(physical_uri), (GClosureNotify)g_free)); + bonobo_ui_component_add_verb_full(uic, "ChangeFolderPropertiesPopUp", configure_folder_popup, g_strdup(physical_uri), g_free); bonobo_ui_component_set_translate (uic, EVOLUTION_SHELL_COMPONENT_POPUP_PLACEHOLDER, popup_xml, NULL); } } @@ -466,9 +453,9 @@ unpopulate_folder_context_menu (EvolutionShellComponent *shell_component, { if (!type_is_mail (type)) return; - + /* FIXME: handle other types */ - + /* the unmatched test is a bit of a hack but it works */ if ((strncmp(physical_uri, "vfolder:", 8) == 0 && strstr(physical_uri, "#" CAMEL_UNMATCHED_NAME) == NULL) @@ -506,7 +493,7 @@ destination_folder_handle_motion (EvolutionShellComponentDndDestinationFolder *f url = camel_url_new (physical_uri, NULL); noselect = url ? camel_url_get_param (url, "noselect") : NULL; - if (noselect && !strcasecmp (noselect, "yes")) + if (noselect && !g_strcasecmp (noselect, "yes")) /* uh, no way to say "illegal" */ *suggested_action_return = GNOME_Evolution_ShellComponentDnd_ACTION_DEFAULT; else @@ -536,7 +523,7 @@ message_rfc822_dnd (CamelFolder *dest, CamelStream *stream, CamelException *ex) msg = camel_mime_message_new (); if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mp) == -1) { - camel_object_unref (msg); + camel_object_unref (CAMEL_OBJECT (msg)); handled = FALSE; break; } @@ -544,7 +531,7 @@ message_rfc822_dnd (CamelFolder *dest, CamelStream *stream, CamelException *ex) /* append the message to the folder... */ info = g_new0 (CamelMessageInfo, 1); camel_folder_append_message (dest, msg, info, NULL, ex); - camel_object_unref (msg); + camel_object_unref (CAMEL_OBJECT (msg)); if (camel_exception_is_set (ex)) { handled = FALSE; @@ -555,7 +542,7 @@ message_rfc822_dnd (CamelFolder *dest, CamelStream *stream, CamelException *ex) camel_mime_parser_step (mp, 0, 0); } - camel_object_unref (mp); + camel_object_unref (CAMEL_OBJECT (mp)); return handled; } @@ -588,7 +575,7 @@ destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *des uri = camel_url_new (physical_uri, NULL); noselect = uri ? camel_url_get_param (uri, "noselect") : NULL; - if (noselect && !strcasecmp (noselect, "yes")) { + if (noselect && !g_strcasecmp (noselect, "yes")) { camel_url_free (uri); return FALSE; } @@ -640,8 +627,8 @@ destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *des stream = camel_stream_fs_new_with_fd (fd); retval = message_rfc822_dnd (folder, stream, &ex); - camel_object_unref (stream); - camel_object_unref (folder); + camel_object_unref (CAMEL_OBJECT (stream)); + camel_object_unref (CAMEL_OBJECT (folder)); if (action == GNOME_Evolution_ShellComponentDnd_ACTION_MOVE && retval) unlink (url); @@ -664,8 +651,8 @@ destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *des camel_stream_reset (stream); retval = message_rfc822_dnd (folder, stream, &ex); - camel_object_unref (stream); - camel_object_unref (folder); + camel_object_unref (CAMEL_OBJECT (stream)); + camel_object_unref (CAMEL_OBJECT (folder)); break; case ACCEPTED_DND_TYPE_X_EVOLUTION_MESSAGE: folder = mail_tools_x_evolution_message_parse (data->bytes._buffer, @@ -679,7 +666,7 @@ destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *des action == GNOME_Evolution_ShellComponentDnd_ACTION_MOVE, physical_uri, 0, NULL, NULL); - camel_object_unref (folder); + camel_object_unref (CAMEL_OBJECT (folder)); break; default: break; @@ -751,33 +738,40 @@ shell_client_destroy (GtkObject *object) } static void +warning_clicked (GtkWidget *dialog, gpointer user_data) +{ + gtk_widget_destroy (dialog); +} + +static void owner_set_cb (EvolutionShellComponent *shell_component, EvolutionShellClient *shell_client, const char *evolution_homedir, gpointer user_data) { GNOME_Evolution_Shell corba_shell; - EAccountList *accounts; + const GSList *accounts; int i; /* FIXME: should we ref this? */ global_shell_client = shell_client; - g_object_weak_ref ((GObject *) shell_client, (GWeakNotify) shell_client_destroy, NULL); + gtk_signal_connect (GTK_OBJECT (shell_client), "destroy", + shell_client_destroy, NULL); evolution_dir = g_strdup (evolution_homedir); mail_session_init (); - + async_event = mail_async_event_new(); - + storages_hash = g_hash_table_new (NULL, NULL); - corba_shell = evolution_shell_client_corba_objref (shell_client); - + corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)); + for (i = 0; i < sizeof (standard_folders) / sizeof (standard_folders[0]); i++) *standard_folders[i].uri = g_strdup_printf ("file://%s/local/%s", evolution_dir, standard_folders[i].name); vfolder_load_storage(corba_shell); - + accounts = mail_config_get_accounts (); mail_load_storages (corba_shell, accounts); @@ -790,15 +784,15 @@ owner_set_cb (EvolutionShellComponent *shell_component, } mail_autoreceive_setup (); - + { /* setup the global quick-search context */ char *user = g_strdup_printf ("%s/searches.xml", evolution_dir); - char *system = g_strdup (EVOLUTION_PRIVDATADIR "/vfoldertypes.xml"); + char *system = g_strdup (EVOLUTION_DATADIR "/evolution/vfoldertypes.xml"); search_context = rule_context_new (); - g_object_set_data_full(G_OBJECT(search_context), "user", user, g_free); - g_object_set_data_full(G_OBJECT(search_context), "system", system, g_free); + gtk_object_set_data_full (GTK_OBJECT (search_context), "user", user, g_free); + gtk_object_set_data_full (GTK_OBJECT (search_context), "system", system, g_free); rule_context_add_part_set (search_context, "partset", filter_part_get_type (), rule_context_add_part, rule_context_next_part); @@ -809,16 +803,18 @@ owner_set_cb (EvolutionShellComponent *shell_component, rule_context_load (search_context, system, user); } + mail_config_register_factory (corba_shell); + if (mail_config_is_corrupt ()) { GtkWidget *dialog; - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, - _("Some of your mail settings seem corrupt, " - "please check that everything is in order.")); - g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); + dialog = gnome_warning_dialog (_("Some of your mail settings seem corrupt, " + "please check that everything is in order.")); + gtk_signal_connect (GTK_OBJECT (dialog), "clicked", warning_clicked, NULL); + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_widget_show (dialog); } - + /* Everything should be ready now */ evolution_folder_info_notify_ready (); } @@ -845,8 +841,7 @@ debug_cb (EvolutionShellComponent *shell_component, gpointer user_data) } static void -interactive_cb (EvolutionShellComponent *shell_component, gboolean on, - gulong new_view_xid, gpointer user_data) +interactive_cb (EvolutionShellComponent *shell_component, gboolean on, gpointer user_data) { mail_session_set_interactive (on); } @@ -886,36 +881,67 @@ user_create_new_item_cb (EvolutionShellComponent *shell_component, g_warning ("Don't know how to create item of type \"%s\"", id); } +static gboolean +idle_quit (gpointer user_data) +{ + static int shutdown_vfolder = FALSE; + static int shutdown_shutdown = FALSE; + + if (!shutdown_shutdown) { + if (e_thread_busy(NULL) || mail_msg_active(-1)) { + usleep(10000); + return TRUE; + } + + if (!shutdown_vfolder) { + shutdown_vfolder = TRUE; + mail_vfolder_shutdown(); + return TRUE; + } + + if (mail_async_event_destroy(async_event) == -1) + return TRUE; + + shutdown_shutdown = TRUE; + g_hash_table_foreach (storages_hash, free_storage, NULL); + g_hash_table_destroy (storages_hash); + storages_hash = NULL; + } + + if (e_list_length (folder_browser_factory_get_control_list ())) + return TRUE; + + gtk_main_quit (); + + return FALSE; +} + static void owner_unset_cb (EvolutionShellComponent *shell_component, gpointer user_data); /* Table for signal handler setup/cleanup */ static struct { char *sig; - GCallback func; + GtkSignalFunc func; int hand; } shell_component_handlers[] = { - { "owner_set", G_CALLBACK(owner_set_cb), }, - { "owner_unset", G_CALLBACK(owner_unset_cb), }, - { "debug", G_CALLBACK(debug_cb), }, - { "interactive", G_CALLBACK(interactive_cb) }, - { "destroy", G_CALLBACK(owner_unset_cb), }, - { "handle_external_uri", G_CALLBACK(handle_external_uri_cb), }, - { "user_create_new_item", G_CALLBACK(user_create_new_item_cb) } + { "owner_set", owner_set_cb, }, + { "owner_unset", owner_unset_cb, }, + { "debug", debug_cb, }, + { "interactive", interactive_cb }, + { "destroy", owner_unset_cb, }, + { "handle_external_uri", handle_external_uri_cb, }, + { "user_create_new_item", user_create_new_item_cb } }; static void owner_unset_cb (EvolutionShellComponent *shell_component, gpointer user_data) { - GConfClient *gconf; - CORBA_Environment ev; int i; - EIterator *it; - - gconf = gconf_client_get_default (); + for (i=0;i<sizeof(shell_component_handlers)/sizeof(shell_component_handlers[0]);i++) - g_signal_handler_disconnect((GtkObject *)shell_component, shell_component_handlers[i].hand); + gtk_signal_disconnect((GtkObject *)shell_component, shell_component_handlers[i].hand); - if (gconf_client_get_bool (gconf, "/apps/evolution/mail/trash/empty_on_exit", NULL)) + if (mail_config_get_empty_trash_on_exit ()) empty_trash (NULL, NULL, NULL); unref_standard_folders (); @@ -924,51 +950,10 @@ owner_unset_cb (EvolutionShellComponent *shell_component, gpointer user_data) global_shell_client = NULL; mail_session_set_interactive (FALSE); - g_object_unref (search_context); + gtk_object_unref (GTK_OBJECT (search_context)); search_context = NULL; - - /* force de-activate of all controls, tho only one should be active anyway? */ - CORBA_exception_init(&ev); - for (it = e_list_get_iterator(folder_browser_factory_get_control_list()); - e_iterator_is_valid(it); - e_iterator_next(it)) { - Bonobo_Control_activate(bonobo_object_corba_objref((BonoboObject *)e_iterator_get(it)), - FALSE, &ev); - } - CORBA_exception_free(&ev); - - for (i= 0;i<3;i++) { - /* need to flush any outstanding tasks before proceeding */ - - /* NOTE!! This may cause a deadlock situation, if we were - called from a deeper main loop than the top level - - is there a way to detect this? - - is this a very big problem? - FIXME: should use semaphores or something to wait rather than polling */ - while (e_thread_busy(NULL) || mail_msg_active(-1)) { - if (g_main_context_pending(NULL)) - g_main_context_iteration(NULL, TRUE); - else - usleep(100000); - } - - switch(i) { - case 0: - mail_vfolder_shutdown(); - break; - case 1: - if (mail_async_event_destroy(async_event) == -1) { - g_warning("Cannot destroy async event: would deadlock"); - g_warning(" system may be unstable at exit"); - } - break; - case 2: - g_hash_table_foreach (storages_hash, free_storage, NULL); - g_hash_table_destroy (storages_hash); - storages_hash = NULL; - break; - } - } + + g_timeout_add(100, idle_quit, NULL); } static void @@ -976,7 +961,7 @@ send_receive_cb (EvolutionShellComponent *shell_component, gboolean show_dialog, void *data) { - EAccount *account; + const MailConfigAccount *account; /* FIXME: configure_mail() should be changed to work without a FolderBrowser, and then we will be able to call configure_mail from @@ -985,14 +970,13 @@ send_receive_cb (EvolutionShellComponent *shell_component, return; account = mail_config_get_default_account (); - if (!account || !account->transport->url) { + if (!account || !account->transport) { GtkWidget *dialog; - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - _("You have not set a mail transport method")); - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - + dialog = gnome_error_dialog (_("You have not set a mail transport method")); + gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE); + gtk_widget_show (dialog); + return; } @@ -1004,21 +988,25 @@ request_quit (EvolutionShellComponent *shell_component, void *closure) { GtkWidget *dialog; - int resp; - + if (!e_msg_composer_request_close_all ()) return FALSE; if (!outbox_folder || !camel_folder_get_message_count (outbox_folder)) return TRUE; - - dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_YES_NO, - _("You have unsent messages, do you wish to quit anyway?")); - gtk_dialog_set_default_response((GtkDialog *)dialog, GTK_RESPONSE_NO); - resp = gtk_dialog_run((GtkDialog *)dialog); - gtk_widget_destroy(dialog); - - return resp == GTK_RESPONSE_YES; + + dialog = gnome_message_box_new (_("You have unsent messages, do you wish to quit anyway?"), + GNOME_MESSAGE_BOX_QUESTION, + GNOME_STOCK_BUTTON_YES, /* Quit */ + GNOME_STOCK_BUTTON_NO, /* Don't quit */ + NULL); + + gtk_window_set_title (GTK_WINDOW (dialog), _("Warning: Unsent Messages")); + gnome_dialog_set_default (GNOME_DIALOG (dialog), 1); + if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == 0) + return TRUE; + + return FALSE; } static BonoboObject * @@ -1041,8 +1029,8 @@ create_component (void) request_quit, NULL); - g_signal_connect((shell_component), "send_receive", - G_CALLBACK (send_receive_cb), NULL); + gtk_signal_connect (GTK_OBJECT (shell_component), "send_receive", + GTK_SIGNAL_FUNC (send_receive_cb), NULL); destination_interface = evolution_shell_component_dnd_destination_folder_new (destination_folder_handle_motion, destination_folder_handle_drop, @@ -1051,26 +1039,28 @@ create_component (void) bonobo_object_add_interface (BONOBO_OBJECT (shell_component), BONOBO_OBJECT (destination_interface)); - icon = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/new-message.xpm", NULL); + evolution_mail_config_wizard_init (); + + icon = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/new-message.xpm"); evolution_shell_component_add_user_creatable_item (shell_component, "message", _("New Mail Message"), _("_Mail Message"), _("Compose a new mail message"), "mail", 'm', icon); if (icon != NULL) - g_object_unref (icon); + gdk_pixbuf_unref (icon); - icon = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/post-message-16.png", NULL); + icon = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/post-message-16.png"); evolution_shell_component_add_user_creatable_item (shell_component, "post", _("New Message Post"), _("_Post Message"), _("Post a new mail message"), "mail/public", 'p', icon); if (icon != NULL) - g_object_unref (icon); + gdk_pixbuf_unref (icon); for (i=0;i<sizeof(shell_component_handlers)/sizeof(shell_component_handlers[0]);i++) { - shell_component_handlers[i].hand = g_signal_connect((shell_component), + shell_component_handlers[i].hand = gtk_signal_connect(GTK_OBJECT(shell_component), shell_component_handlers[i].sig, shell_component_handlers[i].func, NULL); } @@ -1081,6 +1071,36 @@ create_component (void) return BONOBO_OBJECT (shell_component); } +void +component_factory_init (void) +{ + BonoboObject *shell_component; + int result; + + shell_component = create_component (); + result = oaf_active_server_register (COMPONENT_ID, bonobo_object_corba_objref (shell_component)); + if (result == OAF_REG_ERROR) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Cannot initialize the Evolution mail component.")); + exit (1); + } else if (result == OAF_REG_ALREADY_ACTIVE) { + g_warning ("evolution-mail is already running"); + exit (1); + } + + if (evolution_mail_config_factory_init () == FALSE) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Cannot initialize Evolution's mail config component.")); + exit (1); + } + + if (evolution_folder_info_factory_init () == FALSE) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Cannot initialize Evolution's folder info component.")); + exit (1); + } +} + static void notify_listener (const Bonobo_Listener listener, GNOME_Evolution_Storage_Result corba_result) @@ -1259,19 +1279,20 @@ storage_remove_folder (EvolutionStorage *storage, camel_url_free (url); if (!fi) { - notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI); camel_store_free_folder_info (store, root); + notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI); return; } storage_remove_folder_recursive (storage, store, fi, &ex); - camel_store_free_folder_info (store, root); if (camel_exception_is_set (&ex)) { notify_listener_exception (listener, &ex); camel_exception_clear (&ex); } else { notify_listener (listener, GNOME_Evolution_Storage_OK); } + + camel_store_free_folder_info (store, root); } static void @@ -1313,20 +1334,24 @@ storage_xfer_folder (EvolutionStorage *storage, } static void -storage_connected (CamelStore *store, CamelFolderInfo *info, void *listener) +storage_connected (CamelStore *store, CamelFolderInfo *info, void *storage) { - notify_listener (listener, (info ? GNOME_Evolution_Storage_OK : - GNOME_Evolution_Storage_GENERIC_ERROR)); + if (!info) { + /* Let it know the connection failed by calling + * has_subfolders again. + */ + evolution_storage_has_subfolders (storage, "/", + _("Connecting...")); + } } static void storage_connect (EvolutionStorage *storage, - const Bonobo_Listener listener, const char *path, CamelStore *store) { mail_note_store (CAMEL_STORE (store), storage, CORBA_OBJECT_NIL, - storage_connected, listener); + storage_connected, storage); } static void @@ -1337,10 +1362,10 @@ add_storage (const char *name, const char *uri, CamelService *store, EvolutionStorageResult res; storage = evolution_storage_new (name, FALSE); - g_signal_connect(storage, "open_folder", G_CALLBACK(storage_connect), store); - g_signal_connect(storage, "create_folder", G_CALLBACK(storage_create_folder), store); - g_signal_connect(storage, "remove_folder", G_CALLBACK(storage_remove_folder), store); - g_signal_connect(storage, "xfer_folder", G_CALLBACK(storage_xfer_folder), store); + gtk_signal_connect (GTK_OBJECT (storage), "open_folder", storage_connect, store); + gtk_signal_connect (GTK_OBJECT (storage), "create_folder", storage_create_folder, store); + gtk_signal_connect (GTK_OBJECT (storage), "remove_folder", storage_remove_folder, store); + gtk_signal_connect ((GtkObject *)storage, "xfer_folder", storage_xfer_folder, store); res = evolution_storage_register_on_shell (storage, corba_shell); @@ -1362,6 +1387,7 @@ add_storage (const char *name, const char *uri, CamelService *store, } } + void mail_add_storage (CamelStore *store, const char *name, const char *uri) { @@ -1372,7 +1398,7 @@ mail_add_storage (CamelStore *store, const char *name, const char *uri) g_return_if_fail (CAMEL_IS_STORE (store)); shell_client = evolution_shell_component_get_owner (shell_component); - shell = evolution_shell_client_corba_objref (shell_client); + shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)); camel_exception_init (&ex); @@ -1445,10 +1471,10 @@ mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const ch } void -mail_load_storages (GNOME_Evolution_Shell shell, EAccountList *accounts) +mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources) { CamelException ex; - EIterator *iter; + const GSList *iter; camel_exception_init (&ex); @@ -1457,23 +1483,22 @@ mail_load_storages (GNOME_Evolution_Shell shell, EAccountList *accounts) * it. */ - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - EAccountService *service; - EAccount *account; - const char *name; + for (iter = sources; iter; iter = iter->next) { + const MailConfigAccount *account = NULL; + const MailConfigService *service = NULL; + char *name; - account = (EAccount *) e_iterator_get (iter); + account = iter->data; service = account->source; name = account->name; - if (account->enabled && service->url != NULL) - mail_load_storage_by_uri (shell, service->url, name); + if (service == NULL || service->url == NULL || service->url[0] == '\0') + continue; - e_iterator_next (iter); + /* don't auto-connect here; the shell will tell us to goOnline */ + if (account->source->enabled) + mail_load_storage_by_uri (shell, service->url, name); } - - g_object_unref (iter); } void @@ -1532,7 +1557,7 @@ mail_remove_storage (CamelStore *store) mail_note_store_remove(store); shell_client = evolution_shell_component_get_owner (shell_component); - corba_shell = evolution_shell_client_corba_objref(shell_client); + corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)); evolution_storage_deregister_on_shell (storage, corba_shell); @@ -1570,105 +1595,3 @@ mail_storages_foreach (GHFunc func, gpointer data) { g_hash_table_foreach (storages_hash, func, data); } - - -#define FACTORY_ID "OAFIID:GNOME_Evolution_Mail_ControlFactory" - -#define MAIL_CONFIG_IID "OAFIID:GNOME_Evolution_MailConfig" -#define WIZARD_IID "OAFIID:GNOME_Evolution_Mail_Wizard" -#define FOLDER_INFO_IID "OAFIID:GNOME_Evolution_FolderInfo" -#define COMPOSER_IID "OAFIID:GNOME_Evolution_Mail_Composer" - -static BonoboObject * -factory (BonoboGenericFactory *factory, - const char *component_id, - void *closure) -{ - if (strcmp (component_id, COMPONENT_ID) == 0) - return create_component(); - else if (strcmp(component_id, MAIL_CONFIG_IID) == 0) - return (BonoboObject *)g_object_new (evolution_mail_config_get_type (), NULL); - else if (strcmp(component_id, FOLDER_INFO_IID) == 0) - return evolution_folder_info_new(); - else if (strcmp(component_id, WIZARD_IID) == 0) - return evolution_mail_config_wizard_new(); - -#warning "font prefs" -#define MAIL_FONT_PREFS_CONTROL_ID "OAFIID:GNOME_Evolution_Mail_FontPrefs_ConfigControl" - - else if (strcmp (component_id, MAIL_ACCOUNTS_CONTROL_ID) == 0 - || strcmp (component_id, MAIL_PREFERENCES_CONTROL_ID) == 0 - || strcmp (component_id, MAIL_COMPOSER_PREFS_CONTROL_ID) == 0 - /* || strcmp (component_id, MAIL_FONT_PREFS_CONTROL_ID) == 0 */) - return mail_config_control_factory_cb (factory, component_id, evolution_shell_client_corba_objref (global_shell_client)); - else if (strcmp(component_id, COMPOSER_IID) == 0) - return (BonoboObject *)evolution_composer_new(composer_send_cb, composer_save_draft_cb); - - g_warning (FACTORY_ID ": Don't know what to do with %s", component_id); - return NULL; -} - -/* The GNOME SEGV handler will lose if it's not run from the main Gtk - * thread. So if we crash in another thread, redirect the signal. - */ -static void (*gnome_segv_handler) (int); - -static GStaticMutex segv_mutex = G_STATIC_MUTEX_INIT; - -static void -segv_redirect (int sig) -{ - if (pthread_self () == mail_gui_thread) - gnome_segv_handler (sig); - else { - pthread_kill (mail_gui_thread, sig); - /* We can't return from the signal handler or the - * thread may SEGV again. But we can't pthread_exit, - * because then the thread may get cleaned up before - * bug-buddy can get a stack trace. So we block by - * trying to lock a mutex we know is already locked. - */ - g_static_mutex_lock (&segv_mutex); - } -} - - -static Bonobo_Unknown -make_factory (PortableServer_POA poa, const char *iid, gpointer impl_ptr, CORBA_Environment *ev) -{ - struct sigaction sa, osa; - static int init = 0; - - if (!init) { - sigaction (SIGSEGV, NULL, &osa); - if (osa.sa_handler != SIG_DFL) { - sa.sa_flags = 0; - sigemptyset (&sa.sa_mask); - sa.sa_handler = segv_redirect; - sigaction (SIGSEGV, &sa, NULL); - sigaction (SIGBUS, &sa, NULL); - sigaction (SIGFPE, &sa, NULL); - - sa.sa_handler = SIG_IGN; - sigaction (SIGXFSZ, &sa, NULL); - gnome_segv_handler = osa.sa_handler; - g_static_mutex_lock (&segv_mutex); - } - - /* init ? */ - mail_config_init (); - mail_msg_init (); - init = 1; - } - - return bonobo_shlib_factory_std (FACTORY_ID, poa, impl_ptr, factory, NULL, ev); -} - -static BonoboActivationPluginObject plugin_list[] = { - {FACTORY_ID, make_factory}, - { NULL } -}; -const BonoboActivationPlugin Bonobo_Plugin_info = { - plugin_list, "Evolution Mail component factory" -}; - diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 0c9c44151e..aa4566eb5b 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -3,7 +3,7 @@ * Authors: Miguel De Icaza <miguel@ximian.com> * Jeffrey Stedfast <fejj@ximian.com> * - * Copyright 2000-2003 Ximian, Inc. (www.ximian.com) + * Copyright 2000,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 @@ -26,19 +26,17 @@ #include <config.h> #endif -#include <string.h> #include <ctype.h> #include <errno.h> #include <gdk/gdkkeysyms.h> #include <gtk/gtkinvisible.h> +#include <gal/e-paned/e-vpaned.h> #include <gal/e-table/e-table.h> #include <gal/util/e-util.h> #include <gal/widgets/e-gui-utils.h> #include <gal/widgets/e-popup-menu.h> - -#include <gconf/gconf.h> -#include <gconf/gconf-client.h> +#include <gal/widgets/e-unicode.h> #include <libgnomeui/gnome-dialog-util.h> #include <libgnomeui/gnome-pixmap.h> @@ -54,9 +52,9 @@ #include "filter/filter-input.h" #include "filter/filter-label.h" +#include "mail-search-dialogue.h" #include "e-util/e-sexp.h" #include "e-util/e-mktemp.h" -#include "e-util/e-meta.h" #include "folder-browser.h" #include "e-searching-tokenizer.h" #include "mail.h" @@ -119,7 +117,7 @@ static const int num_paste_types = sizeof (paste_types) / sizeof (paste_types[0] static GdkAtom clipboard_atom = GDK_NONE; -static GtkTableClass *parent_class = NULL; +static GtkObjectClass *folder_browser_parent_class; enum { FOLDER_LOADED, @@ -130,44 +128,75 @@ enum { static guint folder_browser_signals [LAST_SIGNAL] = {0, }; static void -folder_browser_finalise (GObject *object) +folder_browser_finalise (GtkObject *object) { FolderBrowser *folder_browser; + CORBA_Environment ev; folder_browser = FOLDER_BROWSER (object); - + + CORBA_exception_init (&ev); + g_free (folder_browser->loading_uid); g_free (folder_browser->pending_uid); g_free (folder_browser->new_uid); g_free (folder_browser->loaded_uid); + if (folder_browser->search_full) + gtk_object_unref (GTK_OBJECT (folder_browser->search_full)); + + if (folder_browser->sensitize_timeout_id) + g_source_remove (folder_browser->sensitize_timeout_id); + + if (folder_browser->shell != CORBA_OBJECT_NIL) { + CORBA_Object_release (folder_browser->shell, &ev); + folder_browser->shell = CORBA_OBJECT_NIL; + } + + if (folder_browser->shell_view != CORBA_OBJECT_NIL) { + CORBA_Object_release(folder_browser->shell_view, &ev); + folder_browser->shell_view = CORBA_OBJECT_NIL; + } + + if (folder_browser->uicomp) + bonobo_object_unref (BONOBO_OBJECT (folder_browser->uicomp)); + g_free (folder_browser->uri); folder_browser->uri = NULL; - + + CORBA_exception_free (&ev); + + if (folder_browser->view_instance) { + gtk_object_unref (GTK_OBJECT (folder_browser->view_instance)); + folder_browser->view_instance = NULL; + } + + if (folder_browser->view_menus) { + gtk_object_unref (GTK_OBJECT (folder_browser->view_menus)); + folder_browser->view_menus = NULL; + } + + gtk_object_unref (GTK_OBJECT (folder_browser->invisible)); + folder_browser->invisible = NULL; + if (folder_browser->clipboard_selection) g_byte_array_free (folder_browser->clipboard_selection, TRUE); if (folder_browser->sensitise_state) { - g_hash_table_destroy (folder_browser->sensitise_state); + g_hash_table_destroy(folder_browser->sensitise_state); folder_browser->sensitise_state = NULL; } - G_OBJECT_CLASS (parent_class)->finalize (object); + folder_browser_parent_class->finalize (object); } static void folder_browser_destroy (GtkObject *object) { FolderBrowser *folder_browser; - CORBA_Environment ev; - GConfClient *gconf; folder_browser = FOLDER_BROWSER (object); - gconf = gconf_client_get_default (); - - CORBA_exception_init (&ev); - if (folder_browser->seen_id != 0) { gtk_timeout_remove (folder_browser->seen_id); folder_browser->seen_id = 0; @@ -187,52 +216,12 @@ folder_browser_destroy (GtkObject *object) gtk_widget_destroy (GTK_WIDGET (folder_browser->mail_display)); folder_browser->mail_display = NULL; } - - if (folder_browser->view_instance) { - g_object_unref (folder_browser->view_instance); - folder_browser->view_instance = NULL; - } - - if (folder_browser->view_menus) { - g_object_unref (folder_browser->view_menus); - folder_browser->view_menus = NULL; - } /* wait for all outstanding async events against us */ mail_async_event_destroy (folder_browser->async_event); - - if (folder_browser->search_full) { - g_object_unref (folder_browser->search_full); - folder_browser->search_full = NULL; - } - if (folder_browser->sensitize_timeout_id) { - g_source_remove (folder_browser->sensitize_timeout_id); - folder_browser->sensitize_timeout_id = 0; - } - - if (folder_browser->shell != CORBA_OBJECT_NIL) { - CORBA_Object_release (folder_browser->shell, &ev); - folder_browser->shell = CORBA_OBJECT_NIL; - } - - if (folder_browser->shell_view != CORBA_OBJECT_NIL) { - CORBA_Object_release (folder_browser->shell_view, &ev); - folder_browser->shell_view = CORBA_OBJECT_NIL; - } - - if (folder_browser->uicomp) { - bonobo_object_unref (BONOBO_OBJECT (folder_browser->uicomp)); - folder_browser->uicomp = NULL; - } - - if (folder_browser->invisible) { - g_object_unref (folder_browser->invisible); - folder_browser->invisible = NULL; - } - if (folder_browser->get_id != -1) { - mail_msg_cancel (folder_browser->get_id); + mail_msg_cancel(folder_browser->get_id); folder_browser->get_id = -1; } @@ -242,45 +231,38 @@ folder_browser_destroy (GtkObject *object) camel_object_unhook_event (CAMEL_OBJECT (folder_browser->folder), "message_changed", folder_changed, folder_browser); mail_sync_folder (folder_browser->folder, NULL, NULL); - camel_object_unref (folder_browser->folder); + camel_object_unref (CAMEL_OBJECT (folder_browser->folder)); folder_browser->folder = NULL; } - - CORBA_exception_free (&ev); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + folder_browser_parent_class->destroy (object); } static void -folder_browser_class_init (FolderBrowserClass *klass) +folder_browser_class_init (GtkObjectClass *object_class) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref(PARENT_TYPE); - object_class->destroy = folder_browser_destroy; - gobject_class->finalize = folder_browser_finalise; + object_class->finalize = folder_browser_finalise; + + folder_browser_parent_class = gtk_type_class (PARENT_TYPE); folder_browser_signals[FOLDER_LOADED] = - g_signal_new ("folder_loaded", - FOLDER_BROWSER_TYPE, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (FolderBrowserClass, folder_loaded), - NULL, - NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); + gtk_signal_new ("folder_loaded", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (FolderBrowserClass, folder_loaded), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); folder_browser_signals[MESSAGE_LOADED] = - g_signal_new ("message_loaded", - FOLDER_BROWSER_TYPE, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (FolderBrowserClass, message_loaded), - NULL, - NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); + gtk_signal_new ("message_loaded", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (FolderBrowserClass, message_loaded), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + + gtk_object_class_add_signals (object_class, folder_browser_signals, LAST_SIGNAL); /* clipboard atom */ if (!clipboard_atom) @@ -746,87 +728,84 @@ folder_browser_paste (GtkWidget *menuitem, FolderBrowser *fb) /* all this crap so we can give the user a whoopee doo status bar */ static void -update_status_bar (FolderBrowser *fb) +update_status_bar(FolderBrowser *fb) { - extern CamelFolder *outbox_folder, *sent_folder; CORBA_Environment ev; int tmp, total; GString *work; - + extern CamelFolder *outbox_folder, *sent_folder; + if (fb->folder == NULL || fb->message_list == NULL || fb->shell_view == CORBA_OBJECT_NIL) return; - - if (!fb->message_list->hidedeleted || !camel_folder_has_summary_capability (fb->folder)) { - total = camel_folder_get_message_count (fb->folder); + + if (!fb->message_list->hidedeleted || !camel_folder_has_summary_capability(fb->folder)) { + total = camel_folder_get_message_count(fb->folder); } else { - GPtrArray *sum = camel_folder_get_summary (fb->folder); + GPtrArray *sum = camel_folder_get_summary(fb->folder); int i; - + if (sum) { total = 0; - for (i = 0; i < sum->len; i++) { + for (i=0;i<sum->len;i++) { CamelMessageInfo *info = sum->pdata[i]; if ((info->flags & CAMEL_MESSAGE_DELETED) == 0) total++; } - camel_folder_free_summary (fb->folder, sum); + camel_folder_free_summary(fb->folder, sum); } else { - total = camel_folder_get_message_count (fb->folder); + total = camel_folder_get_message_count(fb->folder); } } - work = g_string_new (""); - g_string_append_printf (work, _("%d new"), camel_folder_get_unread_message_count (fb->folder)); - tmp = message_list_hidden (fb->message_list); + work = g_string_new(""); + g_string_sprintfa(work, _("%d new"), camel_folder_get_unread_message_count(fb->folder)); + tmp = message_list_hidden(fb->message_list); if (0 < tmp && tmp < total) { - g_string_append (work, _(", ")); + g_string_append(work, _(", ")); if (tmp < total / 2) - g_string_append_printf (work, _("%d hidden"), tmp); + g_string_sprintfa(work, _("%d hidden"), tmp); else - g_string_append_printf (work, _("%d visible"), total - tmp); + g_string_sprintfa(work, _("%d visible"), total - tmp); } - tmp = e_selection_model_selected_count (e_tree_get_selection_model (fb->message_list->tree)); + tmp = e_selection_model_selected_count(e_tree_get_selection_model(fb->message_list->tree)); if (tmp) { - g_string_append (work, _(", ")); - g_string_append_printf (work, _("%d selected"), tmp); + g_string_append(work, _(", ")); + g_string_sprintfa(work, _("%d selected"), tmp); } - g_string_append (work, _(", ")); - + g_string_append(work, _(", ")); + if (fb->folder == outbox_folder) - g_string_append_printf (work, _("%d unsent"), total); + g_string_sprintfa(work, _("%d unsent"), total); else if (fb->folder == sent_folder) - g_string_append_printf (work, _("%d sent"), total); + g_string_sprintfa(work, _("%d sent"), total); else - g_string_append_printf (work, _("%d total"), total); - - CORBA_exception_init (&ev); - GNOME_Evolution_ShellView_setFolderBarLabel (fb->shell_view, work->str, &ev); - CORBA_exception_free (&ev); - + g_string_sprintfa(work, _("%d total"), total); + + CORBA_exception_init(&ev); + GNOME_Evolution_ShellView_setFolderBarLabel(fb->shell_view, work->str, &ev); + CORBA_exception_free(&ev); + if (fb->update_status_bar_idle_id != 0) { g_source_remove (fb->update_status_bar_idle_id); fb->update_status_bar_idle_id = 0; } - - g_string_free (work, TRUE); + + g_string_free(work, TRUE); } static gboolean update_status_bar_idle_cb(gpointer data) { FolderBrowser *fb = data; - -#if 0 + if (!GTK_OBJECT_DESTROYED (fb)) -#endif update_status_bar (fb); fb->update_status_bar_idle_id = 0; - g_object_unref (fb); - + gtk_object_unref (GTK_OBJECT (fb)); return FALSE; } @@ -834,7 +813,7 @@ static void update_status_bar_idle(FolderBrowser *fb) { if (fb->update_status_bar_idle_id == 0) { - g_object_ref (fb); + gtk_object_ref (GTK_OBJECT (fb)); fb->update_status_bar_idle_id = g_idle_add (update_status_bar_idle_cb, fb); } } @@ -847,27 +826,24 @@ static void main_folder_changed(CamelObject *o, void *event_data, void *data) return; /* so some corba unref doesnt blow us away while we're busy */ - g_object_ref (fb); - update_status_bar (fb); + gtk_object_ref((GtkObject *)fb); + update_status_bar(fb); folder_browser_ui_scan_selection (fb); - g_object_unref (fb); + gtk_object_unref((GtkObject *)fb); } -static void folder_changed (CamelObject *obj, void *event_data, void *user_data) +static void folder_changed(CamelObject *o, void *event_data, void *data) { - FolderBrowser *fb = user_data; + FolderBrowser *fb = data; - mail_async_event_emit (fb->async_event, MAIL_ASYNC_GUI, - (MailAsyncFunc) main_folder_changed, - obj, NULL, user_data); + mail_async_event_emit(fb->async_event, MAIL_ASYNC_GUI, (MailAsyncFunc)main_folder_changed, o, NULL, data); } static void -got_folder (char *uri, CamelFolder *folder, void *user_data) +got_folder (char *uri, CamelFolder *folder, void *data) { - FolderBrowser *fb = user_data; - EMeta *meta; - + FolderBrowser *fb = data; + fb->get_id = -1; d(printf ("got folder '%s' = %p, previous folder was %p\n", uri, folder, fb->folder)); @@ -876,30 +852,16 @@ got_folder (char *uri, CamelFolder *folder, void *user_data) goto done; if (fb->folder) { - camel_object_unhook_event (fb->folder, "folder_changed", folder_changed, fb); - camel_object_unhook_event (fb->folder, "message_changed", folder_changed, fb); - camel_object_unref (fb->folder); - } - - if (folder) { - fb->folder = folder; - camel_object_ref (folder); - meta = mail_tool_get_meta_data(fb->uri); - if (meta != fb->meta) { - g_object_unref(fb->meta); - fb->meta = meta; - } else { - g_object_unref(meta); - } - } else { - fb->folder = NULL; - if (fb->meta) { - g_object_unref(fb->meta); - fb->meta = NULL; - } - goto done; + camel_object_unhook_event(fb->folder, "folder_changed", folder_changed, fb); + camel_object_unhook_event(fb->folder, "message_changed", folder_changed, fb); + camel_object_unref(fb->folder); } - + + fb->folder = folder; + if (folder == NULL) + goto done; + + camel_object_ref (CAMEL_OBJECT (folder)); gtk_widget_set_sensitive (GTK_WIDGET (fb->search), camel_folder_has_search_capability (folder)); message_list_set_folder (fb->message_list, folder, @@ -923,8 +885,8 @@ got_folder (char *uri, CamelFolder *folder, void *user_data) folder_browser_ui_set_selection_state (fb, FB_SELSTATE_NONE); done: - g_signal_emit (fb, folder_browser_signals[FOLDER_LOADED], 0, fb->uri); - g_object_unref (fb); + gtk_signal_emit (GTK_OBJECT (fb), folder_browser_signals [FOLDER_LOADED], fb->uri); + gtk_object_unref (GTK_OBJECT (fb)); } @@ -935,8 +897,8 @@ folder_browser_reload (FolderBrowser *fb) if (fb->folder) { mail_refresh_folder (fb->folder, NULL, NULL); - } else if (fb->uri && fb->get_id == -1) { - g_object_ref (fb); + } else if (fb->uri) { + gtk_object_ref (GTK_OBJECT (fb)); fb->get_id = mail_get_folder (fb->uri, 0, got_folder, fb, mail_thread_new); } } @@ -954,7 +916,7 @@ folder_browser_set_folder (FolderBrowser *fb, CamelFolder *folder, const char *u g_free (fb->uri); fb->uri = g_strdup (uri); - g_object_ref (fb); + gtk_object_ref (GTK_OBJECT (fb)); got_folder (NULL, folder, fb); } @@ -962,23 +924,23 @@ void folder_browser_set_ui_component (FolderBrowser *fb, BonoboUIComponent *uicomp) { g_return_if_fail (IS_FOLDER_BROWSER (fb)); - + if (fb->sensitize_timeout_id) { g_source_remove (fb->sensitize_timeout_id); fb->sensitize_timeout_id = 0; } - + if (fb->sensitise_state) { - g_hash_table_destroy (fb->sensitise_state); + g_hash_table_destroy(fb->sensitise_state); fb->sensitise_state = NULL; } if (fb->uicomp) bonobo_object_unref (BONOBO_OBJECT (fb->uicomp)); - + if (uicomp) bonobo_object_ref (BONOBO_OBJECT (uicomp)); - + fb->uicomp = uicomp; } @@ -986,18 +948,18 @@ void folder_browser_set_shell_view(FolderBrowser *fb, GNOME_Evolution_ShellView shell_view) { CORBA_Environment ev; - + CORBA_exception_init(&ev); if (fb->shell_view != CORBA_OBJECT_NIL) - CORBA_Object_release (fb->shell_view, &ev); - CORBA_exception_free (&ev); - - fb->shell_view = CORBA_Object_duplicate (shell_view, &ev); - CORBA_exception_free (&ev); + CORBA_Object_release(fb->shell_view, &ev); + CORBA_exception_free(&ev); + fb->shell_view = CORBA_Object_duplicate(shell_view, &ev); + CORBA_exception_free(&ev); + /* small hack, at this point we've just been activated */ if (fb->shell_view != CORBA_OBJECT_NIL) - update_status_bar (fb); + update_status_bar(fb); } extern CamelFolder *drafts_folder, *sent_folder, *outbox_folder; @@ -1012,35 +974,26 @@ extern CamelFolder *drafts_folder, *sent_folder, *outbox_folder; gboolean folder_browser_is_drafts (FolderBrowser *fb) { - gboolean is_drafts = FALSE; - EAccountList *accounts; - EAccount *account; - EIterator *iter; + const GSList *accounts; + MailConfigAccount *account; g_return_val_if_fail (IS_FOLDER_BROWSER (fb), FALSE); - + if (fb->uri == NULL || fb->folder == NULL) return FALSE; if (fb->folder == drafts_folder) return TRUE; - + accounts = mail_config_get_accounts (); - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); - if (account->drafts_folder_uri && - camel_store_uri_cmp (fb->folder->parent_store, account->drafts_folder_uri, fb->uri)) { - is_drafts = TRUE; - break; - } - - e_iterator_next (iter); + while (accounts) { + account = accounts->data; + if (account->drafts_folder_uri && camel_store_uri_cmp(fb->folder->parent_store, account->drafts_folder_uri, fb->uri)) + return TRUE; + accounts = accounts->next; } - g_object_unref (iter); - - return is_drafts; + return FALSE; } /** @@ -1053,35 +1006,26 @@ folder_browser_is_drafts (FolderBrowser *fb) gboolean folder_browser_is_sent (FolderBrowser *fb) { - gboolean is_sent = FALSE; - EAccountList *accounts; - EAccount *account; - EIterator *iter; + const GSList *accounts; + MailConfigAccount *account; g_return_val_if_fail (IS_FOLDER_BROWSER (fb), FALSE); - + if (fb->uri == NULL || fb->folder == NULL) return FALSE; - + if (fb->folder == sent_folder) return TRUE; accounts = mail_config_get_accounts (); - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); - if (account->sent_folder_uri && - camel_store_uri_cmp (fb->folder->parent_store, account->sent_folder_uri, fb->uri)) { - is_sent = TRUE; - break; - } - - e_iterator_next (iter); + while (accounts) { + account = accounts->data; + if (account->sent_folder_uri && camel_store_uri_cmp(fb->folder->parent_store, account->sent_folder_uri, fb->uri)) + return TRUE; + accounts = accounts->next; } - g_object_unref (iter); - - return is_sent; + return FALSE; } /** @@ -1103,26 +1047,22 @@ save_cursor_pos (FolderBrowser *fb) { ETreePath node; GtkAdjustment *adj; - int row, y, height, paned_size; - GConfClient *gconf; - + int row, y, height; + node = e_tree_get_cursor (fb->message_list->tree); if (!node) return -1; - + row = e_tree_row_of_node (fb->message_list->tree, node); - + if (row == -1) return 0; - + e_tree_get_cell_geometry (fb->message_list->tree, row, 0, NULL, &y, NULL, &height); - - gconf = gconf_client_get_default (); - paned_size = gconf_client_get_int (gconf, "/apps/evolution/mail/display/paned_size", NULL); - - adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (fb->message_list)); - y += adj->value - ((paned_size - height) / 2); + + adj = e_scroll_frame_get_vadjustment (E_SCROLL_FRAME (fb->message_list)); + y += adj->value - ((mail_config_get_paned_size () - height) / 2); return y; } @@ -1131,41 +1071,37 @@ static void set_cursor_pos (FolderBrowser *fb, int y) { GtkAdjustment *adj; - + if (y == -1) return; - - adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (fb->message_list)); + + adj = e_scroll_frame_get_vadjustment (E_SCROLL_FRAME (fb->message_list)); gtk_adjustment_set_value (adj, (gfloat)y); } static gboolean do_message_selected(FolderBrowser *fb); void -folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show_preview) +folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show_message_preview) { - GConfClient *gconf; - int paned_size, y; - - if (folder_browser->preview_shown == show_preview + if (folder_browser->preview_shown == show_message_preview || folder_browser->message_list == NULL) return; - - folder_browser->preview_shown = show_preview; - - gconf = gconf_client_get_default (); - paned_size = gconf_client_get_int (gconf, "/apps/evolution/mail/display/paned_size", NULL); - - if (show_preview) { + + folder_browser->preview_shown = show_message_preview; + + if (show_message_preview) { + int y; y = save_cursor_pos (folder_browser); - gtk_paned_set_position (GTK_PANED (folder_browser->vpaned), paned_size); + e_paned_set_position (E_PANED (folder_browser->vpaned), mail_config_get_paned_size ()); gtk_widget_show (GTK_WIDGET (folder_browser->mail_display)); do_message_selected (folder_browser); set_cursor_pos (folder_browser, y); } else { + e_paned_set_position (E_PANED (folder_browser->vpaned), 10000); gtk_widget_hide (GTK_WIDGET (folder_browser->mail_display)); mail_display_set_message (folder_browser->mail_display, NULL, NULL, NULL); - folder_browser_ui_message_loaded (folder_browser); + folder_browser_ui_message_loaded(folder_browser); } } @@ -1196,13 +1132,13 @@ folder_browser_search_menu_activated (ESearchBar *esb, int id, FolderBrowser *fb if (efb->current_query) { FilterRule *rule = vfolder_clone_rule(efb->current_query); char *name, *text; - + text = e_search_bar_get_text(esb); name = g_strdup_printf("%s %s", rule->name, (text&&text[0])?text:"''"); - g_free (text); + g_free(text); filter_rule_set_name(rule, name); - g_free (name); - + g_free(name); + filter_rule_set_source(rule, FILTER_SOURCE_INCOMING); vfolder_rule_add_source((VfolderRule *)rule, fb->uri); vfolder_gui_add_rule((VfolderRule *)rule); @@ -1219,16 +1155,16 @@ folder_browser_config_search (EFilterBar *efb, FilterRule *rule, int id, const c GList *partl; struct _camel_search_words *words; int i; - + st = E_SEARCHING_TOKENIZER (fb->mail_display->html->engine->ht); - + e_searching_tokenizer_set_secondary_search_string (st, NULL); /* we scan the parts of a rule, and set all the types we know about to the query string */ partl = rule->parts; while (partl) { FilterPart *part = partl->data; - + if (!strcmp(part->name, "subject")) { FilterInput *input = (FilterInput *)filter_part_find_element(part, "subject"); if (input) @@ -1237,11 +1173,12 @@ folder_browser_config_search (EFilterBar *efb, FilterRule *rule, int id, const c FilterInput *input = (FilterInput *)filter_part_find_element(part, "word"); if (input) filter_input_set_value(input, query); - + words = camel_search_words_split(query); for (i=0;i<words->len;i++) e_searching_tokenizer_add_secondary_search_string (st, words->words[i]->word); - camel_search_words_free (words); + camel_search_words_free(words); + } else if(!strcmp(part->name, "sender")) { FilterInput *input = (FilterInput *)filter_part_find_element(part, "sender"); if (input) @@ -1264,18 +1201,21 @@ static void folder_browser_search_do_search (ESearchBar *esb, FolderBrowser *fb) { char *search_word; - + if (fb->message_list == NULL) return; d(printf("do search\n")); - g_object_get (esb, "query", &search_word, NULL); - + gtk_object_get (GTK_OBJECT (esb), + "query", &search_word, + NULL); + message_list_set_search (fb->message_list, search_word); d(printf("query is %s\n", search_word)); - g_free (search_word); + g_free(search_word); + return; } static void @@ -1296,15 +1236,13 @@ folder_browser_toggle_preview (BonoboUIComponent *component, gpointer user_data) { FolderBrowser *fb = user_data; - gboolean bstate; - - if (type != Bonobo_UIComponent_STATE_CHANGED || fb->message_list == NULL) + + if (type != Bonobo_UIComponent_STATE_CHANGED + || fb->message_list == NULL) return; - bstate = atoi(state); - e_meta_set_bool(fb->meta, "show_preview", bstate); - gconf_client_set_bool (gconf_client_get_default(), "/apps/evolution/mail/display/show_preview", bstate, NULL); - folder_browser_set_message_preview (fb, bstate); + mail_config_set_show_preview (fb->uri, atoi (state)); + folder_browser_set_message_preview (fb, atoi (state)); } void @@ -1316,19 +1254,17 @@ folder_browser_toggle_threads (BonoboUIComponent *component, { FolderBrowser *fb = user_data; int prev_state; - gboolean bstate; - - if (type != Bonobo_UIComponent_STATE_CHANGED || fb->message_list == NULL) - return; - bstate = atoi(state); - e_meta_set_bool(fb->meta, "thread_list", bstate); - gconf_client_set_bool (gconf_client_get_default (), "/apps/evolution/mail/display/thread_list", bstate, NULL); - message_list_set_threaded (fb->message_list, bstate); + if (type != Bonobo_UIComponent_STATE_CHANGED + || fb->message_list == NULL) + return; + mail_config_set_thread_list (fb->uri, atoi (state)); + message_list_set_threaded (fb->message_list, atoi (state)); + prev_state = fb->selection_state; fb->selection_state = FB_SELSTATE_UNDEFINED; - folder_browser_ui_set_selection_state (fb, prev_state); + folder_browser_ui_set_selection_state (fb, prev_state); } void @@ -1339,17 +1275,14 @@ folder_browser_toggle_hide_deleted (BonoboUIComponent *component, gpointer user_data) { FolderBrowser *fb = user_data; - GConfClient *gconf; - - if (type != Bonobo_UIComponent_STATE_CHANGED || fb->message_list == NULL) + + if (type != Bonobo_UIComponent_STATE_CHANGED + || fb->message_list == NULL) return; - - gconf = gconf_client_get_default (); - gconf_client_set_bool (gconf, "/apps/evolution/mail/display/show_deleted", - !atoi (state), NULL); - + if (!(fb->folder && (fb->folder->folder_flags & CAMEL_FOLDER_IS_TRASH))) - message_list_set_hidedeleted (fb->message_list, atoi (state)); + mail_config_set_hide_deleted (atoi (state)); + message_list_set_hidedeleted (fb->message_list, atoi (state)); } void @@ -1361,25 +1294,20 @@ folder_browser_set_message_display_style (BonoboUIComponent *component { extern char *message_display_styles[]; FolderBrowser *fb = user_data; - GConfClient *gconf; int i; - + if (type != Bonobo_UIComponent_STATE_CHANGED - || atoi (state) == 0 + || atoi(state) == 0 || fb->message_list == NULL) return; - - gconf = gconf_client_get_default (); - - printf ("message display style: %s\n", path); - + for (i = 0; i < MAIL_CONFIG_DISPLAY_MAX; i++) { if (strstr (message_display_styles[i], path)) { fb->mail_display->display_style = i; mail_display_redisplay (fb->mail_display, TRUE); - + if (fb->pref_master) - gconf_client_set_int (gconf, "/apps/evolution/mail/display/message_style", i, NULL); + mail_config_set_message_display_style (i); return; } } @@ -1416,55 +1344,55 @@ vfolder_type_current(FolderBrowser *fb, int type) { GPtrArray *uids; int i; - + /* get uid */ - uids = g_ptr_array_new (); - message_list_foreach (fb->message_list, enumerate_msg, uids); - + uids = g_ptr_array_new(); + message_list_foreach(fb->message_list, enumerate_msg, uids); + if (uids->len == 1) - vfolder_type_uid (fb->folder, (char *)uids->pdata[0], fb->uri, type); - - for (i = 0; i < uids->len; i++) - g_free (uids->pdata[i]); - g_ptr_array_free (uids, TRUE); + vfolder_type_uid(fb->folder, (char *)uids->pdata[0], fb->uri, type); + + for (i=0; i<uids->len; i++) + g_free(uids->pdata[i]); + g_ptr_array_free(uids, TRUE); } /* external api to vfolder/filter on X, based on current message */ -void vfolder_subject (GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_SUBJECT); } -void vfolder_sender (GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_FROM); } -void vfolder_recipient (GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_TO); } -void vfolder_mlist (GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_MLIST); } +void vfolder_subject(GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_SUBJECT); } +void vfolder_sender(GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_FROM); } +void vfolder_recipient(GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_TO); } +void vfolder_mlist(GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_MLIST); } -static void filter_type_uid (CamelFolder *folder, const char *uid, const char *source, int type); +static void filter_type_uid(CamelFolder *folder, const char *uid, const char *source, int type); static void -filter_type_current (FolderBrowser *fb, int type) +filter_type_current(FolderBrowser *fb, int type) { GPtrArray *uids; int i; const char *source; - + if (folder_browser_is_sent (fb) || folder_browser_is_outbox (fb)) source = FILTER_SOURCE_OUTGOING; else source = FILTER_SOURCE_INCOMING; - + /* get uid */ - uids = g_ptr_array_new (); - message_list_foreach (fb->message_list, enumerate_msg, uids); - + uids = g_ptr_array_new(); + message_list_foreach(fb->message_list, enumerate_msg, uids); + if (uids->len == 1) - filter_type_uid (fb->folder, (char *)uids->pdata[0], source, type); - - for (i = 0; i < uids->len; i++) - g_free (uids->pdata[i]); - g_ptr_array_free (uids, TRUE); + filter_type_uid(fb->folder, (char *)uids->pdata[0], source, type); + + for (i=0; i<uids->len; i++) + g_free(uids->pdata[i]); + g_ptr_array_free(uids, TRUE); } -void filter_subject (GtkWidget *w, FolderBrowser *fb) { filter_type_current (fb, AUTO_SUBJECT); } -void filter_sender (GtkWidget *w, FolderBrowser *fb) { filter_type_current (fb, AUTO_FROM); } -void filter_recipient (GtkWidget *w, FolderBrowser *fb) { filter_type_current (fb, AUTO_TO); } -void filter_mlist (GtkWidget *w, FolderBrowser *fb) { filter_type_current (fb, AUTO_MLIST); } +void filter_subject(GtkWidget *w, FolderBrowser *fb) { filter_type_current(fb, AUTO_SUBJECT); } +void filter_sender(GtkWidget *w, FolderBrowser *fb) { filter_type_current(fb, AUTO_FROM); } +void filter_recipient(GtkWidget *w, FolderBrowser *fb) { filter_type_current(fb, AUTO_TO); } +void filter_mlist(GtkWidget *w, FolderBrowser *fb) { filter_type_current(fb, AUTO_MLIST); } /* ************************************************************ */ @@ -1479,14 +1407,14 @@ struct _filter_data { }; static void -filter_data_free (struct _filter_data *fdata) +filter_data_free(struct _filter_data *fdata) { - g_free (fdata->uid); - g_free (fdata->uri); + g_free(fdata->uid); + g_free(fdata->uri); if (fdata->folder) - camel_object_unref (fdata->folder); - g_free (fdata->mlist); - g_free (fdata); + camel_object_unref((CamelObject *)fdata->folder); + g_free(fdata->mlist); + g_free(fdata); } static void @@ -1497,14 +1425,14 @@ vfolder_type_got_message(CamelFolder *folder, const char *uid, CamelMimeMessage if (msg) vfolder_gui_add_from_message(msg, data->type, data->uri); - filter_data_free (data); + filter_data_free(data); } static void vfolder_type_uid(CamelFolder *folder, const char *uid, const char *uri, int type) { struct _filter_data *data; - + data = g_malloc0(sizeof(*data)); data->type = type; data->uri = g_strdup(uri); @@ -1520,18 +1448,18 @@ static void filter_type_got_message(CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *d) { struct _filter_data *data = d; - + if (msg) filter_gui_add_from_message(msg, data->source, data->type); - - filter_data_free (data); + + filter_data_free(data); } static void filter_type_uid(CamelFolder *folder, const char *uid, const char *source, int type) { struct _filter_data *data; - + data = g_malloc0(sizeof(*data)); data->type = type; data->source = source; @@ -1546,7 +1474,7 @@ static void filter_mlist_uid(GtkWidget *w, struct _filter_data *fdata) { filter void hide_none(GtkWidget *w, FolderBrowser *fb) { - message_list_hide_clear (fb->message_list); + message_list_hide_clear(fb->message_list); } void @@ -1555,19 +1483,19 @@ hide_selected(GtkWidget *w, FolderBrowser *fb) GPtrArray *uids; int i; - uids = g_ptr_array_new (); - message_list_foreach (fb->message_list, enumerate_msg, uids); - message_list_hide_uids (fb->message_list, uids); - for (i = 0; i < uids->len; i++) - g_free (uids->pdata[i]); - g_ptr_array_free (uids, TRUE); + uids = g_ptr_array_new(); + message_list_foreach(fb->message_list, enumerate_msg, uids); + message_list_hide_uids(fb->message_list, uids); + for (i=0; i<uids->len; i++) + g_free(uids->pdata[i]); + g_ptr_array_free(uids, TRUE); } void hide_deleted(GtkWidget *w, FolderBrowser *fb) { MessageList *ml = fb->message_list; - + message_list_hide_add(ml, "(match-all (system-flag \"deleted\"))", ML_HIDE_SAME, ML_HIDE_SAME); } @@ -1575,7 +1503,7 @@ void hide_read(GtkWidget *w, FolderBrowser *fb) { MessageList *ml = fb->message_list; - + message_list_hide_add(ml, "(match-all (system-flag \"seen\"))", ML_HIDE_SAME, ML_HIDE_SAME); } @@ -1612,17 +1540,17 @@ hide_subject(GtkWidget *w, FolderBrowser *fb) { const char *subject; GString *expr; - + if (fb->mail_display->current_message) { subject = camel_mime_message_get_subject(fb->mail_display->current_message); if (subject) { subject = strip_re(subject); if (subject && subject[0]) { - expr = g_string_new ("(match-all (header-contains \"subject\" "); - e_sexp_encode_string (expr, subject); - g_string_append (expr, "))"); - message_list_hide_add (fb->message_list, expr->str, ML_HIDE_SAME, ML_HIDE_SAME); - g_string_free (expr, TRUE); + expr = g_string_new("(match-all (header-contains \"subject\" "); + e_sexp_encode_string(expr, subject); + g_string_append(expr, "))"); + message_list_hide_add(fb->message_list, expr->str, ML_HIDE_SAME, ML_HIDE_SAME); + g_string_free(expr, TRUE); return; } } @@ -1630,25 +1558,70 @@ hide_subject(GtkWidget *w, FolderBrowser *fb) } void -hide_sender (GtkWidget *w, FolderBrowser *fb) +hide_sender(GtkWidget *w, FolderBrowser *fb) { const CamelInternetAddress *from; const char *real, *addr; GString *expr; - + if (fb->mail_display->current_message) { - from = camel_mime_message_get_from (fb->mail_display->current_message); - if (camel_internet_address_get (from, 0, &real, &addr)) { - expr = g_string_new ("(match-all (header-contains \"from\" "); - e_sexp_encode_string (expr, addr); - g_string_append (expr, "))"); - message_list_hide_add (fb->message_list, expr->str, ML_HIDE_SAME, ML_HIDE_SAME); - g_string_free (expr, TRUE); + from = camel_mime_message_get_from(fb->mail_display->current_message); + if (camel_internet_address_get(from, 0, &real, &addr)) { + expr = g_string_new("(match-all (header-contains \"from\" "); + e_sexp_encode_string(expr, addr); + g_string_append(expr, "))"); + message_list_hide_add(fb->message_list, expr->str, ML_HIDE_SAME, ML_HIDE_SAME); + g_string_free(expr, TRUE); return; } } } +#if 0 +struct _colour_data { + FolderBrowser *fb; + guint32 rgb; +}; + +#define COLOUR_NONE (~0) + +static void +colourise_msg (GtkWidget *widget, gpointer user_data) +{ + struct _colour_data *data = user_data; + char *colour = NULL; + GPtrArray *uids; + int i; + + if (data->rgb != COLOUR_NONE) { + colour = alloca (8); + sprintf (colour, "#%.2x%.2x%.2x", (data->rgb & 0xff0000) >> 16, + (data->rgb & 0xff00) >> 8, data->rgb & 0xff); + } + + uids = g_ptr_array_new (); + message_list_foreach (data->fb->message_list, enumerate_msg, uids); + for (i = 0; i < uids->len; i++) { + camel_folder_set_message_user_tag (data->fb->folder, uids->pdata[i], "colour", colour); + } + g_ptr_array_free (uids, TRUE); +} + +static void +colour_closures_free (GPtrArray *closures) +{ + struct _colour_data *data; + int i; + + for (i = 0; i < closures->len; i++) { + data = closures->pdata[i]; + gtk_object_unref (GTK_OBJECT (data->fb)); + g_free (data); + } + g_ptr_array_free (closures, TRUE); +} +#endif + struct _label_data { FolderBrowser *fb; const char *label; @@ -1660,7 +1633,7 @@ set_msg_label (GtkWidget *widget, gpointer user_data) struct _label_data *data = user_data; GPtrArray *uids; int i; - + uids = g_ptr_array_new (); message_list_foreach (data->fb->message_list, enumerate_msg, uids); for (i = 0; i < uids->len; i++) @@ -1676,7 +1649,7 @@ label_closures_free (GPtrArray *closures) for (i = 0; i < closures->len; i++) { data = closures->pdata[i]; - g_object_unref (data->fb); + gtk_object_unref (GTK_OBJECT (data->fb)); g_free (data); } g_ptr_array_free (closures, TRUE); @@ -1726,67 +1699,67 @@ enum { #define MLIST_FILTER (8) static EPopupMenu filter_menu[] = { - E_POPUP_ITEM_CC (N_("VFolder on _Subject"), G_CALLBACK (vfolder_subject_uid), NULL, SELECTION_SET), - E_POPUP_ITEM_CC (N_("VFolder on Se_nder"), G_CALLBACK (vfolder_sender_uid), NULL, SELECTION_SET), - E_POPUP_ITEM_CC (N_("VFolder on _Recipients"), G_CALLBACK (vfolder_recipient_uid), NULL, SELECTION_SET), - E_POPUP_ITEM_CC (N_("VFolder on Mailing _List"), G_CALLBACK (vfolder_mlist_uid), NULL, SELECTION_SET | IS_MAILING_LIST), + E_POPUP_ITEM_CC (N_("VFolder on _Subject"), GTK_SIGNAL_FUNC (vfolder_subject_uid), NULL, SELECTION_SET), + E_POPUP_ITEM_CC (N_("VFolder on Se_nder"), GTK_SIGNAL_FUNC (vfolder_sender_uid), NULL, SELECTION_SET), + E_POPUP_ITEM_CC (N_("VFolder on _Recipients"), GTK_SIGNAL_FUNC (vfolder_recipient_uid), NULL, SELECTION_SET), + E_POPUP_ITEM_CC (N_("VFolder on Mailing _List"), GTK_SIGNAL_FUNC (vfolder_mlist_uid), NULL, SELECTION_SET | IS_MAILING_LIST), E_POPUP_SEPARATOR, - E_POPUP_ITEM_CC (N_("Filter on Sub_ject"), G_CALLBACK (filter_subject_uid), NULL, SELECTION_SET), - E_POPUP_ITEM_CC (N_("Filter on Sen_der"), G_CALLBACK (filter_sender_uid), NULL, SELECTION_SET), - E_POPUP_ITEM_CC (N_("Filter on Re_cipients"), G_CALLBACK (filter_recipient_uid), NULL, SELECTION_SET), - E_POPUP_ITEM_CC (N_("Filter on _Mailing List"), G_CALLBACK (filter_mlist_uid), NULL, SELECTION_SET | IS_MAILING_LIST), + E_POPUP_ITEM_CC (N_("Filter on Sub_ject"), GTK_SIGNAL_FUNC (filter_subject_uid), NULL, SELECTION_SET), + E_POPUP_ITEM_CC (N_("Filter on Sen_der"), GTK_SIGNAL_FUNC (filter_sender_uid), NULL, SELECTION_SET), + E_POPUP_ITEM_CC (N_("Filter on Re_cipients"), GTK_SIGNAL_FUNC (filter_recipient_uid), NULL, SELECTION_SET), + E_POPUP_ITEM_CC (N_("Filter on _Mailing List"), GTK_SIGNAL_FUNC (filter_mlist_uid), NULL, SELECTION_SET | IS_MAILING_LIST), E_POPUP_TERMINATOR }; static EPopupMenu label_menu[] = { - E_POPUP_PIXMAP_WIDGET_ITEM_CC (N_("None"), NULL, G_CALLBACK (set_msg_label), NULL, 0), + E_POPUP_PIXMAP_WIDGET_ITEM_CC (N_("None"), NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0), E_POPUP_SEPARATOR, - E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0), - E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0), - E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0), - E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0), - E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0), + E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0), + E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0), + E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0), + E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0), + E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0), E_POPUP_TERMINATOR }; static EPopupMenu context_menu[] = { - E_POPUP_ITEM (N_("_Open"), G_CALLBACK (open_msg), 0), - E_POPUP_ITEM (N_("_Edit as New Message..."), G_CALLBACK (resend_msg), CAN_RESEND), - E_POPUP_ITEM (N_("_Save As..."), G_CALLBACK (save_msg), 0), - E_POPUP_ITEM (N_("_Print"), G_CALLBACK (print_msg), 0), + E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (open_msg), 0), + E_POPUP_ITEM (N_("_Edit as New Message..."), GTK_SIGNAL_FUNC (resend_msg), CAN_RESEND), + E_POPUP_ITEM (N_("_Save As..."), GTK_SIGNAL_FUNC (save_msg), 0), + E_POPUP_ITEM (N_("_Print"), GTK_SIGNAL_FUNC (print_msg), 0), E_POPUP_SEPARATOR, - E_POPUP_ITEM (N_("_Reply to Sender"), G_CALLBACK (reply_to_sender), 0), - E_POPUP_ITEM (N_("Reply to _List"), G_CALLBACK (reply_to_list), 0), - E_POPUP_ITEM (N_("Reply to _All"), G_CALLBACK (reply_to_all), 0), - E_POPUP_ITEM (N_("_Forward"), G_CALLBACK (forward), 0), + E_POPUP_ITEM (N_("_Reply to Sender"), GTK_SIGNAL_FUNC (reply_to_sender), 0), + E_POPUP_ITEM (N_("Reply to _List"), GTK_SIGNAL_FUNC (reply_to_list), 0), + E_POPUP_ITEM (N_("Reply to _All"), GTK_SIGNAL_FUNC (reply_to_all), 0), + E_POPUP_ITEM (N_("_Forward"), GTK_SIGNAL_FUNC (forward), 0), E_POPUP_SEPARATOR, - E_POPUP_ITEM (N_("Follo_w Up..."), G_CALLBACK (flag_for_followup), CAN_FLAG_FOR_FOLLOWUP), - E_POPUP_ITEM (N_("Fla_g Completed"), G_CALLBACK (flag_followup_completed), CAN_FLAG_COMPLETED), - E_POPUP_ITEM (N_("Cl_ear Flag"), G_CALLBACK (flag_followup_clear), CAN_CLEAR_FLAG), + E_POPUP_ITEM (N_("Follo_w Up..."), GTK_SIGNAL_FUNC (flag_for_followup), CAN_FLAG_FOR_FOLLOWUP), + E_POPUP_ITEM (N_("Fla_g Completed"), GTK_SIGNAL_FUNC (flag_followup_completed), CAN_FLAG_COMPLETED), + E_POPUP_ITEM (N_("Cl_ear Flag"), GTK_SIGNAL_FUNC (flag_followup_clear), CAN_CLEAR_FLAG), /* separator here? */ - E_POPUP_ITEM (N_("Mar_k as Read"), G_CALLBACK (mark_as_seen_cb), CAN_MARK_READ), - E_POPUP_ITEM (N_("Mark as _Unread"), G_CALLBACK (mark_as_unseen_cb), CAN_MARK_UNREAD), - E_POPUP_ITEM (N_("Mark as _Important"), G_CALLBACK (mark_as_important_cb), CAN_MARK_IMPORTANT), - E_POPUP_ITEM (N_("_Mark as Unimportant"), G_CALLBACK (mark_as_unimportant_cb), CAN_MARK_UNIMPORTANT), + E_POPUP_ITEM (N_("Mar_k as Read"), GTK_SIGNAL_FUNC (mark_as_seen_cb), CAN_MARK_READ), + E_POPUP_ITEM (N_("Mark as _Unread"), GTK_SIGNAL_FUNC (mark_as_unseen_cb), CAN_MARK_UNREAD), + E_POPUP_ITEM (N_("Mark as _Important"), GTK_SIGNAL_FUNC (mark_as_important_cb), CAN_MARK_IMPORTANT), + E_POPUP_ITEM (N_("_Mark as Unimportant"), GTK_SIGNAL_FUNC (mark_as_unimportant_cb), CAN_MARK_UNIMPORTANT), E_POPUP_SEPARATOR, - E_POPUP_ITEM (N_("_Delete"), G_CALLBACK (delete_msg), CAN_DELETE), - E_POPUP_ITEM (N_("U_ndelete"), G_CALLBACK (undelete_msg), CAN_UNDELETE), + E_POPUP_ITEM (N_("_Delete"), GTK_SIGNAL_FUNC (delete_msg), CAN_DELETE), + E_POPUP_ITEM (N_("U_ndelete"), GTK_SIGNAL_FUNC (undelete_msg), CAN_UNDELETE), E_POPUP_SEPARATOR, - E_POPUP_ITEM (N_("Mo_ve to Folder..."), G_CALLBACK (move_msg_cb), 0), - E_POPUP_ITEM (N_("_Copy to Folder..."), G_CALLBACK (copy_msg_cb), 0), + E_POPUP_ITEM (N_("Mo_ve to Folder..."), GTK_SIGNAL_FUNC (move_msg_cb), 0), + E_POPUP_ITEM (N_("_Copy to Folder..."), GTK_SIGNAL_FUNC (copy_msg_cb), 0), E_POPUP_SEPARATOR, @@ -1794,11 +1767,11 @@ static EPopupMenu context_menu[] = { E_POPUP_SEPARATOR, - E_POPUP_ITEM (N_("Add Sender to Address_book"), G_CALLBACK (addrbook_sender), SELECTION_SET | CAN_ADD_SENDER), + E_POPUP_ITEM (N_("Add Sender to Address_book"), GTK_SIGNAL_FUNC (addrbook_sender), SELECTION_SET | CAN_ADD_SENDER), E_POPUP_SEPARATOR, - E_POPUP_ITEM (N_("Appl_y Filters"), G_CALLBACK (apply_filters), 0), + E_POPUP_ITEM (N_("Appl_y Filters"), GTK_SIGNAL_FUNC (apply_filters), 0), E_POPUP_SEPARATOR, @@ -1849,7 +1822,7 @@ struct cmpf_data { static void context_menu_position_func (GtkMenu *menu, gint *x, gint *y, - gboolean *push_in, gpointer user_data) + gpointer user_data) { int tx, ty, tw, th; struct cmpf_data *closure = user_data; @@ -1871,7 +1844,7 @@ setup_popup_icons (void) char *filename; filename = g_strdup_printf ("%s/%s", EVOLUTION_IMAGES, context_pixmaps[i]); - context_menu[i].pixmap_widget = gtk_image_new_from_file (filename); + context_menu[i].pixmap_widget = gnome_pixmap_new_from_file (filename); g_free (filename); } } @@ -1881,15 +1854,14 @@ setup_popup_icons (void) static int on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event, FolderBrowser *fb) { - struct _filter_data *fdata = NULL; - GPtrArray *uids, *closures; CamelMessageInfo *info; - GSList *labels; + GPtrArray *uids, *closures; int enable_mask = 0; int hide_mask = 0; + int i; char *mlist = NULL; GtkMenu *menu; - int i; + struct _filter_data *fdata = NULL; if (!folder_browser_is_sent (fb)) { enable_mask |= CAN_RESEND; @@ -1954,7 +1926,7 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event fdata->mlist = g_strdup(mname); /* Escape the mailing list name before showing it */ - mlist = g_alloca ((strlen (mname) * 2) + 1); + mlist = alloca ((strlen (mname) * 2) + 1); p = mname; o = mlist; while ((c = *p++)) { @@ -2071,44 +2043,43 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event closures = g_ptr_array_new (); label_menu[0].closure = g_new (struct _label_data, 1); g_ptr_array_add (closures, label_menu[0].closure); - g_object_ref (fb); + gtk_object_ref (GTK_OBJECT (fb)); ((struct _label_data *) label_menu[0].closure)->fb = fb; ((struct _label_data *) label_menu[0].closure)->label = NULL; - i = 0; - labels = mail_config_get_labels (); - while (labels != NULL && i < 5) { + for (i = 0; i < filter_label_count(); i++) { struct _label_data *closure; - MailConfigLabel *label; GdkPixmap *pixmap; GdkColormap *map; - GdkColor colour; + GdkColor color; + guint32 rgb; GdkGC *gc; - label = labels->data; - gdk_color_parse (label->colour, &colour); + rgb = mail_config_get_label_color (i); + + color.red = ((rgb & 0xff0000) >> 8) | 0xff; + color.green = (rgb & 0xff00) | 0xff; + color.blue = ((rgb & 0xff) << 8) | 0xff; + map = gdk_colormap_get_system (); - gdk_color_alloc (map, &colour); + gdk_color_alloc (map, &color); pixmap = gdk_pixmap_new (GTK_WIDGET (fb)->window, 16, 16, -1); gc = gdk_gc_new (GTK_WIDGET (fb)->window); - gdk_gc_set_foreground (gc, &colour); + gdk_gc_set_foreground (gc, &color); gdk_draw_rectangle (pixmap, gc, TRUE, 0, 0, 16, 16); gdk_gc_unref (gc); closure = g_new (struct _label_data, 1); - g_object_ref (fb); + gtk_object_ref (GTK_OBJECT (fb)); closure->fb = fb; - closure->label = label->name; + closure->label = filter_label_label(i); g_ptr_array_add (closures, closure); - label_menu[i + 2].name = label->name; - label_menu[i + 2].pixmap_widget = gtk_image_new_from_pixmap (pixmap, NULL); + label_menu[i + 2].name = e_utf8_to_locale_string (mail_config_get_label_name (i)); + label_menu[i + 2].pixmap_widget = gtk_pixmap_new (pixmap, NULL); label_menu[i + 2].closure = closure; - - i++; - labels = labels->next; } setup_popup_icons (); @@ -2117,12 +2088,14 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event filter_menu[i].closure = fdata; menu = e_popup_menu_create (context_menu, enable_mask, hide_mask, fb); - e_auto_kill_popup_menu_on_selection_done (menu); + e_auto_kill_popup_menu_on_hide (menu); - g_object_set_data_full ((GObject *) menu, "label_closures", closures, (GtkDestroyNotify) label_closures_free); + gtk_object_set_data_full (GTK_OBJECT (menu), "label_closures", + closures, (GtkDestroyNotify) label_closures_free); if (fdata) - g_object_set_data_full ((GObject *) menu, "filter_data", fdata, (GtkDestroyNotify) filter_data_free); + gtk_object_set_data_full (GTK_OBJECT (menu), "filter_data", + fdata, (GtkDestroyNotify) filter_data_free); if (event->type == GDK_KEY_PRESS) { struct cmpf_data closure; @@ -2140,6 +2113,11 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event g_free (filter_menu[MLIST_FILTER].name); g_free (filter_menu[MLIST_VFOLDER].name); + /* free the label/colour menu */ + for (i = 0; i < 5; i++) { + g_free (label_menu[i + 2].name); + } + return TRUE; } @@ -2222,13 +2200,13 @@ etree_key (ETree *tree, int row, ETreePath path, int col, GdkEvent *ev, FolderBr { GtkAdjustment *vadj; gfloat page_size; - + if ((ev->key.state & GDK_CONTROL_MASK) != 0) return FALSE; - - vadj = gtk_scrolled_window_get_vadjustment (fb->mail_display->scroll); + + vadj = e_scroll_frame_get_vadjustment (fb->mail_display->scroll); page_size = vadj->page_size - vadj->step_increment; - + switch (ev->key.keyval) { case GDK_space: /* Work around Ximian 4939 */ @@ -2255,7 +2233,7 @@ etree_key (ETree *tree, int row, ETreePath path, int col, GdkEvent *ev, FolderBr default: return on_key_press ((GtkWidget *)tree, (GdkEventKey *)ev, fb); } - + return TRUE; } @@ -2276,13 +2254,13 @@ on_selection_changed (GtkObject *obj, gpointer user_data) { FolderBrowser *fb = FOLDER_BROWSER (user_data); FolderBrowserSelectionState state; - + /* we can get this signal at strange times... * if no uicomp, don't even bother */ - + if (fb->uicomp == NULL) return; - + switch (e_selection_model_selected_count (E_SELECTION_MODEL (obj))) { case 0: state = FB_SELSTATE_NONE; @@ -2294,40 +2272,24 @@ on_selection_changed (GtkObject *obj, gpointer user_data) state = FB_SELSTATE_MULTIPLE; break; } - + folder_browser_ui_set_selection_state (fb, state); - - update_status_bar_idle (fb); + + update_status_bar_idle(fb); } static void -on_cursor_activated (ETree *tree, int row, ETreePath path, gpointer user_data) -{ - on_selection_changed ((GtkObject *)tree, user_data); -} - -static gboolean -fb_resize_cb (GtkWidget *w, GdkEventButton *e, FolderBrowser *fb) +on_cursor_activated(ETree *tree, int row, ETreePath path, gpointer user_data) { - GConfClient *gconf; - - gconf = gconf_client_get_default (); - - if (GTK_WIDGET_REALIZED (w) && fb->preview_shown) - gconf_client_set_int (gconf, "/apps/evolution/mail/display/paned_size", gtk_paned_get_position (GTK_PANED (w)), NULL); - - return FALSE; + on_selection_changed((GtkObject *)tree, user_data); } -/* hack to get around the fact setting the paned size doesn't work */ static void -paned_realised(GtkWidget *w, FolderBrowser *fb) -{ - int size; - - size = gconf_client_get_int (gconf_client_get_default (), "/apps/evolution/mail/display/paned_size", NULL); - gtk_paned_set_position (GTK_PANED (fb->vpaned), size); +fb_resize_cb (GtkWidget *w, GtkAllocation *a, FolderBrowser *fb) +{ + if (GTK_WIDGET_REALIZED (w) && fb->preview_shown) + mail_config_set_paned_size (a->height); } static void @@ -2335,10 +2297,9 @@ folder_browser_gui_init (FolderBrowser *fb) { extern RuleContext *search_context; ESelectionModel *esm; - + /* The panned container */ - fb->vpaned = gtk_vpaned_new (); - g_signal_connect(fb->vpaned, "realize", G_CALLBACK(paned_realised), fb); + fb->vpaned = e_vpaned_new (); gtk_widget_show (fb->vpaned); gtk_table_attach (GTK_TABLE (fb), fb->vpaned, @@ -2349,8 +2310,8 @@ folder_browser_gui_init (FolderBrowser *fb) /* quick-search bar */ if (search_context) { - const char *systemrules = g_object_get_data (G_OBJECT (search_context), "system"); - const char *userrules = g_object_get_data (G_OBJECT (search_context), "user"); + const char *systemrules = gtk_object_get_data (GTK_OBJECT (search_context), "system"); + const char *userrules = gtk_object_get_data (GTK_OBJECT (search_context), "user"); fb->search = e_filter_bar_new (search_context, systemrules, userrules, folder_browser_config_search, fb); @@ -2359,31 +2320,33 @@ folder_browser_gui_init (FolderBrowser *fb) gtk_widget_show (GTK_WIDGET (fb->search)); - g_signal_connect (fb->search, "menu_activated", - G_CALLBACK (folder_browser_search_menu_activated), fb); - g_signal_connect (fb->search, "search_activated", - G_CALLBACK (folder_browser_search_do_search), fb); - g_signal_connect (fb->search, "query_changed", - G_CALLBACK (folder_browser_query_changed), fb); + gtk_signal_connect (GTK_OBJECT (fb->search), "menu_activated", + GTK_SIGNAL_FUNC (folder_browser_search_menu_activated), fb); + gtk_signal_connect (GTK_OBJECT (fb->search), "search_activated", + GTK_SIGNAL_FUNC (folder_browser_search_do_search), fb); + gtk_signal_connect (GTK_OBJECT (fb->search), "query_changed", + GTK_SIGNAL_FUNC (folder_browser_query_changed), fb); + gtk_table_attach (GTK_TABLE (fb), GTK_WIDGET (fb->search), 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0); - + esm = e_tree_get_selection_model (E_TREE (fb->message_list->tree)); - g_signal_connect (esm, "selection_changed", G_CALLBACK (on_selection_changed), fb); - g_signal_connect (esm, "cursor_activated", G_CALLBACK (on_cursor_activated), fb); + gtk_signal_connect (GTK_OBJECT (esm), "selection_changed", on_selection_changed, fb); + gtk_signal_connect (GTK_OBJECT (esm), "cursor_activated", on_cursor_activated, fb); fb->selection_state = FB_SELSTATE_NONE; /* default to none */ - gtk_paned_add1 (GTK_PANED (fb->vpaned), GTK_WIDGET (fb->message_list)); + e_paned_add1 (E_PANED (fb->vpaned), GTK_WIDGET (fb->message_list)); gtk_widget_show (GTK_WIDGET (fb->message_list)); - fb->paned_resize_id = g_signal_connect (fb->vpaned, "button_release_event", - G_CALLBACK (fb_resize_cb), fb); - - gtk_paned_add2 (GTK_PANED (fb->vpaned), GTK_WIDGET (fb->mail_display)); + gtk_signal_connect (GTK_OBJECT (fb->message_list), "size_allocate", + GTK_SIGNAL_FUNC (fb_resize_cb), fb); + + e_paned_add2 (E_PANED (fb->vpaned), GTK_WIDGET (fb->mail_display)); + e_paned_set_position (E_PANED (fb->vpaned), mail_config_get_paned_size ()); gtk_widget_show (GTK_WIDGET (fb->mail_display)); gtk_widget_show (GTK_WIDGET (fb)); } @@ -2395,8 +2358,7 @@ do_mark_seen (gpointer data) FolderBrowser *fb = FOLDER_BROWSER (data); if (fb->new_uid && fb->loaded_uid && !strcmp (fb->new_uid, fb->loaded_uid)) { - camel_folder_set_message_flags (fb->folder, fb->new_uid, - CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); + camel_folder_set_message_flags (fb->folder, fb->new_uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); } return FALSE; @@ -2410,24 +2372,18 @@ done_message_selected (CamelFolder *folder, const char *uid, CamelMimeMessage *m { FolderBrowser *fb = data; CamelMessageInfo *info; - GConfClient *gconf; - int timeout; - - gconf = gconf_client_get_default (); + int timeout = mail_config_get_mark_as_seen_timeout (); if (folder != fb->folder || fb->mail_display == NULL) return; - gconf = gconf_client_get_default (); - timeout = gconf_client_get_int (gconf, "/apps/evolution/mail/display/mark_seen_timeout", NULL); - info = camel_folder_get_message_info (fb->folder, uid); mail_display_set_message (fb->mail_display, (CamelMedium *) msg, fb->folder, info); if (info) camel_folder_free_message_info (fb->folder, info); /* FIXME: should this signal be emitted here?? */ - g_signal_emit (fb, folder_browser_signals[MESSAGE_LOADED], 0, uid); + gtk_signal_emit (GTK_OBJECT (fb), folder_browser_signals [MESSAGE_LOADED], uid); /* pain, if we have pending stuff, re-run */ if (fb->pending_uid) { @@ -2449,7 +2405,7 @@ done_message_selected (CamelFolder *folder, const char *uid, CamelMimeMessage *m if (fb->seen_id) gtk_timeout_remove (fb->seen_id); - if (msg && gconf_client_get_bool (gconf, "/apps/evolution/mail/display/mark_seen", NULL)) { + if (mail_config_get_do_seen_timeout () && msg) { if (timeout > 0) fb->seen_id = gtk_timeout_add (timeout, do_mark_seen, fb); else @@ -2502,7 +2458,7 @@ on_message_list_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer user { FolderBrowser *fb = (FolderBrowser *) user_data; - d(printf ("got focus!\n")); + printf ("got focus!\n"); folder_browser_ui_message_list_focus (fb); return FALSE; @@ -2513,22 +2469,25 @@ on_message_list_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer use { FolderBrowser *fb = (FolderBrowser *) user_data; - d(printf ("got unfocus!\n")); + printf ("got unfocus!\n"); folder_browser_ui_message_list_unfocus (fb); return FALSE; } static void -folder_browser_init (FolderBrowser *fb) +folder_browser_init (GtkObject *object) { - fb->async_event = mail_async_event_new (); + FolderBrowser *fb = (FolderBrowser *)object; + + fb->async_event = mail_async_event_new(); fb->get_id = -1; } static void -my_folder_browser_init (FolderBrowser *fb) +my_folder_browser_init (GtkObject *object) { + FolderBrowser *fb = FOLDER_BROWSER (object); int i; fb->view_instance = NULL; @@ -2550,58 +2509,62 @@ my_folder_browser_init (FolderBrowser *fb) fb->preview_shown = TRUE; - g_signal_connect (fb->mail_display->html, "key_press_event", - G_CALLBACK (on_key_press), fb); - g_signal_connect (fb->mail_display->html, "button_press_event", - G_CALLBACK (html_button_press_event), fb); + gtk_signal_connect (GTK_OBJECT (fb->mail_display->html), + "key_press_event", GTK_SIGNAL_FUNC (on_key_press), fb); + gtk_signal_connect (GTK_OBJECT (fb->mail_display->html), + "button_press_event", GTK_SIGNAL_FUNC (html_button_press_event), fb); - g_signal_connect (fb->message_list->tree, "key_press", - G_CALLBACK (etree_key), fb); + gtk_signal_connect (GTK_OBJECT (fb->message_list->tree), + "key_press", GTK_SIGNAL_FUNC (etree_key), fb); - g_signal_connect (fb->message_list->tree, "right_click", - G_CALLBACK (on_right_click), fb); + gtk_signal_connect (GTK_OBJECT (fb->message_list->tree), + "right_click", GTK_SIGNAL_FUNC (on_right_click), fb); - g_signal_connect (fb->message_list->tree, "double_click", - G_CALLBACK (on_double_click), fb); + gtk_signal_connect (GTK_OBJECT (fb->message_list->tree), + "double_click", GTK_SIGNAL_FUNC (on_double_click), fb); - g_signal_connect (fb->message_list, "focus_in_event", - G_CALLBACK (on_message_list_focus_in), fb); + gtk_signal_connect (GTK_OBJECT (fb->message_list), "focus_in_event", + GTK_SIGNAL_FUNC (on_message_list_focus_in), fb); - g_signal_connect (fb->message_list, "focus_out_event", - G_CALLBACK (on_message_list_focus_out), fb); + gtk_signal_connect (GTK_OBJECT (fb->message_list), "focus_out_event", + GTK_SIGNAL_FUNC (on_message_list_focus_out), fb); - g_signal_connect (fb->message_list, "message_selected", - G_CALLBACK (on_message_selected), fb); + gtk_signal_connect (GTK_OBJECT (fb->message_list), "message_selected", + on_message_selected, fb); /* drag & drop */ e_tree_drag_source_set (fb->message_list->tree, GDK_BUTTON1_MASK, drag_types, num_drag_types, GDK_ACTION_MOVE | GDK_ACTION_COPY); - g_signal_connect (fb->message_list->tree, "tree_drag_data_get", - G_CALLBACK (message_list_drag_data_get), fb); + gtk_signal_connect (GTK_OBJECT (fb->message_list->tree), "tree_drag_data_get", + GTK_SIGNAL_FUNC (message_list_drag_data_get), fb); e_tree_drag_dest_set (fb->message_list->tree, GTK_DEST_DEFAULT_ALL, drag_types, num_drag_types, GDK_ACTION_MOVE | GDK_ACTION_COPY); - g_signal_connect (fb->message_list->tree, "tree_drag_data_received", - G_CALLBACK (message_list_drag_data_received), fb); + gtk_signal_connect (GTK_OBJECT (fb->message_list->tree), "tree_drag_data_received", + GTK_SIGNAL_FUNC (message_list_drag_data_received), fb); /* cut, copy & paste */ fb->invisible = gtk_invisible_new (); - g_object_ref (fb->invisible); - gtk_object_sink ((GtkObject *) fb->invisible); for (i = 0; i < num_paste_types; i++) gtk_selection_add_target (fb->invisible, clipboard_atom, paste_types[i].target, paste_types[i].info); - g_signal_connect (fb->invisible, "selection_get", - G_CALLBACK (selection_get), fb); - g_signal_connect (fb->invisible, "selection_clear_event", - G_CALLBACK (selection_clear_event), fb); - g_signal_connect (fb->invisible, "selection_received", - G_CALLBACK (selection_received), fb); + gtk_signal_connect (GTK_OBJECT (fb->invisible), + "selection_get", + GTK_SIGNAL_FUNC (selection_get), + (gpointer) fb); + gtk_signal_connect (GTK_OBJECT (fb->invisible), + "selection_clear_event", + GTK_SIGNAL_FUNC (selection_clear_event), + (gpointer) fb); + gtk_signal_connect (GTK_OBJECT (fb->invisible), + "selection_received", + GTK_SIGNAL_FUNC (selection_received), + (gpointer) fb); folder_browser_gui_init (fb); } @@ -2613,11 +2576,11 @@ folder_browser_new (const GNOME_Evolution_Shell shell, const char *uri) FolderBrowser *folder_browser; CORBA_exception_init (&ev); - - folder_browser = g_object_new (folder_browser_get_type (), NULL); - - my_folder_browser_init (folder_browser); - + + folder_browser = gtk_type_new (folder_browser_get_type ()); + + my_folder_browser_init (GTK_OBJECT (folder_browser)); + folder_browser->shell = CORBA_Object_duplicate (shell, &ev); if (ev._major != CORBA_NO_EXCEPTION) { folder_browser->shell = CORBA_OBJECT_NIL; @@ -2625,13 +2588,12 @@ folder_browser_new (const GNOME_Evolution_Shell shell, const char *uri) CORBA_exception_free (&ev); return NULL; } - + CORBA_exception_free (&ev); if (uri) { folder_browser->uri = g_strdup (uri); - folder_browser->meta = mail_tool_get_meta_data(uri); - g_object_ref (folder_browser); + gtk_object_ref (GTK_OBJECT (folder_browser)); folder_browser->get_id = mail_get_folder (folder_browser->uri, 0, got_folder, folder_browser, mail_thread_new); } diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index 1542de946d..a823ed63d8 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -30,11 +30,8 @@ #include <string.h> #include <stdarg.h> -#include <gconf/gconf.h> -#include <gconf/gconf-client.h> - -#include <e-util/e-account-list.h> -#include <e-util/e-dialog-utils.h> +#include <gal/widgets/e-unicode.h> +#include <gal/widgets/e-gui-utils.h> #include "evolution-folder-selector-button.h" #include "mail-account-gui.h" @@ -51,7 +48,7 @@ extern char *default_drafts_folder_uri, *default_sent_folder_uri; extern EvolutionShellClient *global_shell_client; -static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, EAccountService *service); +static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, MailConfigService *service); static void service_changed (GtkEntry *entry, gpointer user_data); struct { @@ -107,7 +104,7 @@ get_focused_widget (GtkWidget *def, ...) gboolean mail_account_gui_identity_complete (MailAccountGui *gui, GtkWidget **incomplete) { - const char *text; + char *text; text = gtk_entry_get_text (gui->full_name); if (!text || !*text) { @@ -155,7 +152,7 @@ service_complete (MailAccountGuiService *service, GHashTable *extra_config, GtkW { const CamelProvider *prov = service->provider; GtkWidget *path; - const char *text; + char *text; if (!prov) return TRUE; @@ -225,8 +222,7 @@ mail_account_gui_auto_detect_extra_conf (MailAccountGui *gui) GtkWidget *path; CamelURL *url; char *text; - const char *tmp; - + if (!prov) return; @@ -263,9 +259,9 @@ mail_account_gui_auto_detect_extra_conf (MailAccountGui *gui) } if (path && CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_PATH)) { - tmp = gtk_entry_get_text (service->path); - if (tmp && *tmp) - camel_url_set_path (url, tmp); + text = gtk_entry_get_text (service->path); + if (text && *text) + camel_url_set_path (url, text); } camel_provider_auto_detect (prov, url, &auto_detected, NULL); @@ -332,12 +328,6 @@ mail_account_gui_auto_detect_extra_conf (MailAccountGui *gui) gboolean mail_account_gui_transport_complete (MailAccountGui *gui, GtkWidget **incomplete) { - if (!gui->transport.provider) { - if (incomplete) - *incomplete = GTK_WIDGET (gui->transport.type); - return FALSE; - } - /* If it's both source and transport, there's nothing extra to * configure on the transport page. */ @@ -372,7 +362,7 @@ mail_account_gui_transport_complete (MailAccountGui *gui, GtkWidget **incomplete gboolean mail_account_gui_management_complete (MailAccountGui *gui, GtkWidget **incomplete) { - const char *text; + char *text; text = gtk_entry_get_text (gui->account_name); if (text && *text) @@ -392,7 +382,7 @@ service_authtype_changed (GtkWidget *widget, gpointer user_data) CamelServiceAuthType *authtype; service->authitem = widget; - authtype = g_object_get_data ((GObject *) widget, "authtype"); + authtype = gtk_object_get_data (GTK_OBJECT (widget), "authtype"); gtk_widget_set_sensitive (GTK_WIDGET (service->remember), authtype->need_password); } @@ -407,7 +397,7 @@ build_auth_menu (MailAccountGuiService *service, GList *all_authtypes, GList *l, *s; if (service->authitem) - current = g_object_get_data ((GObject *) service->authitem, "authtype"); + current = gtk_object_get_data (GTK_OBJECT (service->authitem), "authtype"); else current = NULL; @@ -435,10 +425,11 @@ build_auth_menu (MailAccountGuiService *service, GList *all_authtypes, history = i; } - g_object_set_data ((GObject *) item, "authtype", authtype); - g_signal_connect (item, "activate", G_CALLBACK (service_authtype_changed), service); + gtk_object_set_data (GTK_OBJECT (item), "authtype", authtype); + gtk_signal_connect (GTK_OBJECT (item), "activate", + service_authtype_changed, service); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_menu_append (GTK_MENU (menu), item); gtk_widget_show (item); } @@ -448,7 +439,7 @@ build_auth_menu (MailAccountGuiService *service, GList *all_authtypes, if (first) { gtk_option_menu_set_history (service->authtype, history); - g_signal_emit_by_name (first, "activate"); + gtk_signal_emit_by_name (GTK_OBJECT (first), "activate"); } } @@ -457,17 +448,18 @@ transport_provider_set_available (MailAccountGui *gui, CamelProvider *provider, gboolean available) { GtkWidget *menuitem; - - menuitem = g_object_get_data ((GObject *) gui->transport.type, provider->protocol); + + menuitem = gtk_object_get_data (GTK_OBJECT (gui->transport.type), + provider->protocol); g_return_if_fail (menuitem != NULL); - gtk_widget_set_sensitive (menuitem, available); - + if (available) { - gpointer number = g_object_get_data ((GObject *) menuitem, "number"); - - g_signal_emit_by_name (menuitem, "activate"); - gtk_option_menu_set_history (gui->transport.type, GPOINTER_TO_UINT (number)); + gpointer number = gtk_object_get_data (GTK_OBJECT (menuitem), "number"); + + gtk_signal_emit_by_name (GTK_OBJECT (menuitem), "activate"); + gtk_option_menu_set_history (gui->transport.type, + GPOINTER_TO_UINT (number)); } } @@ -478,7 +470,7 @@ source_type_changed (GtkWidget *widget, gpointer user_data) GtkWidget *file_entry, *label, *frame, *dwidget = NULL; CamelProvider *provider; - provider = g_object_get_data ((GObject *) widget, "provider"); + provider = gtk_object_get_data (GTK_OBJECT (widget), "provider"); /* If the previously-selected provider has a linked transport, * disable it. @@ -564,7 +556,7 @@ source_type_changed (GtkWidget *widget, gpointer user_data) gtk_widget_hide (frame); } - g_signal_emit_by_name (gui->source.username, "changed"); + gtk_signal_emit_by_name (GTK_OBJECT (gui->source.username), "changed"); if (dwidget) gtk_widget_grab_focus (dwidget); @@ -596,7 +588,7 @@ transport_type_changed (GtkWidget *widget, gpointer user_data) CamelProvider *provider; GtkWidget *label, *frame; - provider = g_object_get_data ((GObject *) widget, "provider"); + provider = gtk_object_get_data (GTK_OBJECT (widget), "provider"); gui->transport.provider = provider; /* description */ @@ -659,7 +651,7 @@ transport_type_changed (GtkWidget *widget, gpointer user_data) } else gtk_widget_hide (frame); - g_signal_emit_by_name (gui->transport.hostname, "changed"); + gtk_signal_emit_by_name (GTK_OBJECT (gui->transport.hostname), "changed"); } static void @@ -675,12 +667,12 @@ static void service_check_supported (GtkButton *button, gpointer user_data) { MailAccountGuiService *gsvc = user_data; - EAccountService *service; + MailConfigService *service; GList *authtypes = NULL; GtkWidget *authitem; GtkWidget *window; - service = g_new0 (EAccountService, 1); + service = g_new0 (MailConfigService, 1); /* This is sort of a hack, when checking for supported AUTH types we don't want to use whatever authtype is selected @@ -703,8 +695,7 @@ service_check_supported (GtkButton *button, gpointer user_data) g_list_free (authtypes); } - g_free (service->url); - g_free (service); + service_destroy (service); } @@ -725,7 +716,9 @@ setup_toggle (GtkWidget *widget, const char *depname, MailAccountGui *gui) } toggle = g_hash_table_lookup (gui->extra_config, depname); - g_signal_connect (toggle, "toggled", G_CALLBACK (toggle_sensitivity), widget); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (toggle_sensitivity), + widget); toggle_sensitivity (toggle, widget); } @@ -733,14 +726,13 @@ void mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) { CamelURL *url; - GtkWidget *mailcheck_frame, *mailcheck_hbox; + GtkWidget *mailcheck_frame, *main_vbox, *cur_vbox; GtkWidget *hostname_label, *username_label, *path_label; GtkWidget *hostname, *username, *path; - GtkTable *main_table, *cur_table; CamelProviderConfEntry *entries; GList *children, *child; char *name; - int i, rows; + int i; if (url_string) url = camel_url_new (url_string, NULL); @@ -748,52 +740,55 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) url = NULL; hostname_label = glade_xml_get_widget (gui->xml, "source_host_label"); - gtk_label_set_text_with_mnemonic (GTK_LABEL (hostname_label), _("_Host:")); + gtk_label_parse_uline (GTK_LABEL (hostname_label), _("_Host:")); hostname = glade_xml_get_widget (gui->xml, "source_host"); username_label = glade_xml_get_widget (gui->xml, "source_user_label"); - gtk_label_set_text_with_mnemonic (GTK_LABEL (username_label), _("User_name:")); + gtk_label_parse_uline (GTK_LABEL (username_label), _("User_name:")); username = glade_xml_get_widget (gui->xml, "source_user"); path_label = glade_xml_get_widget (gui->xml, "source_path_label"); - gtk_label_set_text_with_mnemonic (GTK_LABEL (path_label), _("_Path:")); + gtk_label_parse_uline (GTK_LABEL (path_label), _("_Path:")); path = glade_xml_get_widget (gui->xml, "source_path"); - /* Remove the contents of the extra_table except for the - * mailcheck_frame. - */ - main_table = (GtkTable *)glade_xml_get_widget (gui->xml, "extra_table"); + main_vbox = glade_xml_get_widget (gui->xml, "extra_vbox"); + mailcheck_frame = glade_xml_get_widget (gui->xml, "extra_mailcheck_frame"); - children = gtk_container_get_children (GTK_CONTAINER (main_table)); - for (child = children; child; child = child->next) { - if (child->data != (gpointer)mailcheck_frame) { - gtk_container_remove (GTK_CONTAINER (main_table), - child->data); + + /* Remove any additional mailcheck items. */ + children = gtk_container_children (GTK_CONTAINER (mailcheck_frame)); + if (children) { + cur_vbox = children->data; + g_list_free (children); + children = gtk_container_children (GTK_CONTAINER (cur_vbox)); + for (child = children; child; child = child->next) { + if (child != children) { + gtk_container_remove (GTK_CONTAINER (cur_vbox), + child->data); + } } + g_list_free (children); } - g_list_free (children); - gtk_table_resize (main_table, 1, 2); - /* Remove any additional mailcheck items. */ - cur_table = (GtkTable *)glade_xml_get_widget (gui->xml, "extra_mailcheck_table"); - mailcheck_hbox = glade_xml_get_widget (gui->xml, "extra_mailcheck_hbox"); - children = gtk_container_get_children (GTK_CONTAINER (cur_table)); + /* Remove the contents of the extra_vbox except for the + * mailcheck_frame. + */ + children = gtk_container_children (GTK_CONTAINER (main_vbox)); for (child = children; child; child = child->next) { - if (child->data != (gpointer)mailcheck_hbox) { - gtk_container_remove (GTK_CONTAINER (cur_table), + if (child != children) { + gtk_container_remove (GTK_CONTAINER (main_vbox), child->data); } } g_list_free (children); - gtk_table_resize (cur_table, 1, 2); - + if (!gui->source.provider) { - gtk_widget_set_sensitive (GTK_WIDGET (main_table), FALSE); + gtk_widget_set_sensitive (main_vbox, FALSE); if (url) camel_url_free (url); return; } else - gtk_widget_set_sensitive (GTK_WIDGET (main_table), TRUE); + gtk_widget_set_sensitive (main_vbox, TRUE); /* Set up our hash table. */ if (gui->extra_config) @@ -804,8 +799,7 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) if (!entries) goto done; - cur_table = main_table; - rows = main_table->nrows; + cur_vbox = main_vbox; for (i = 0; ; i++) { switch (entries[i].type) { case CAMEL_PROVIDER_CONF_SECTION_START: @@ -813,27 +807,18 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) GtkWidget *frame; if (entries[i].name && !strcmp (entries[i].name, "mailcheck")) - cur_table = (GtkTable *)glade_xml_get_widget (gui->xml, "extra_mailcheck_table"); + cur_vbox = glade_xml_get_widget (gui->xml, "extra_mailcheck_vbox"); else { frame = gtk_frame_new (entries[i].text); - gtk_container_set_border_width (GTK_CONTAINER (frame), 3); - gtk_table_attach (main_table, frame, 0, 2, - rows, rows + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - cur_table = (GtkTable *)gtk_table_new (0, 2, FALSE); - rows = 0; - gtk_table_set_row_spacings (cur_table, 4); - gtk_table_set_col_spacings (cur_table, 8); - gtk_container_set_border_width (GTK_CONTAINER (cur_table), 3); - - gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (cur_table)); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + cur_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (cur_vbox), 4); + gtk_container_add (GTK_CONTAINER (frame), cur_vbox); } break; } case CAMEL_PROVIDER_CONF_SECTION_END: - cur_table = main_table; - rows = main_table->nrows; + cur_vbox = main_vbox; break; case CAMEL_PROVIDER_CONF_LABEL: @@ -841,18 +826,15 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) GtkWidget *label; if (!strcmp (entries[i].name, "username")) { - gtk_label_set_text_with_mnemonic (GTK_LABEL (username_label), entries[i].text); + gtk_label_parse_uline (GTK_LABEL (username_label), _(entries[i].text)); } else if (!strcmp (entries[i].name, "hostname")) { - gtk_label_set_text_with_mnemonic (GTK_LABEL (hostname_label), entries[i].text); + gtk_label_parse_uline (GTK_LABEL (hostname_label), _(entries[i].text)); } else if (!strcmp (entries[i].name, "path")) { - gtk_label_set_text_with_mnemonic (GTK_LABEL (path_label), entries[i].text); + gtk_label_parse_uline (GTK_LABEL (path_label), _(entries[i].text)); } else { /* make a new label */ - label = gtk_label_new (entries[i].text); - gtk_table_resize (cur_table, cur_table->nrows + 1, 2); - gtk_table_attach (cur_table, label, 0, 2, rows, rows + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - rows++; + label = gtk_label_new (_(entries[i].text)); + gtk_box_pack_start (GTK_BOX (cur_vbox), label, FALSE, FALSE, 0); } } break; @@ -862,16 +844,13 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) GtkWidget *checkbox; gboolean active; - checkbox = gtk_check_button_new_with_label (entries[i].text); + checkbox = gtk_check_button_new_with_label (_(entries[i].text)); if (url) active = camel_url_get_param (url, entries[i].name) != NULL; else active = atoi (entries[i].value); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), active); - - gtk_table_attach (cur_table, checkbox, 0, 2, rows, rows + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - rows++; + gtk_box_pack_start (GTK_BOX (cur_vbox), checkbox, FALSE, FALSE, 0); g_hash_table_insert (gui->extra_config, entries[i].name, checkbox); if (entries[i].depname) setup_toggle (checkbox, entries[i].depname, gui); @@ -880,33 +859,32 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) case CAMEL_PROVIDER_CONF_ENTRY: { - GtkWidget *label, *entry; + GtkWidget *hbox, *label, *entry; const char *text; if (!strcmp (entries[i].name, "username")) { - gtk_label_set_text_with_mnemonic (GTK_LABEL (username_label), entries[i].text); + gtk_label_parse_uline (GTK_LABEL (username_label), _(entries[i].text)); label = username_label; entry = username; } else if (!strcmp (entries[i].name, "hostname")) { - gtk_label_set_text_with_mnemonic (GTK_LABEL (hostname_label), entries[i].text); + gtk_label_parse_uline (GTK_LABEL (hostname_label), _(entries[i].text)); label = hostname_label; entry = hostname; } else if (!strcmp (entries[i].name, "path")) { - gtk_label_set_text_with_mnemonic (GTK_LABEL (path_label), entries[i].text); + gtk_label_parse_uline (GTK_LABEL (path_label), _(entries[i].text)); label = path_label; entry = path; } else { /* make a new text entry with label */ - label = gtk_label_new (entries[i].text); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); + hbox = gtk_hbox_new (FALSE, 8); + label = gtk_label_new (_(entries[i].text)); entry = gtk_entry_new (); - g_hash_table_insert (gui->extra_config, entries[i].name, entry); - gtk_table_attach (cur_table, label, 0, 1, rows, rows + 1, - GTK_FILL, 0, 0, 0); - gtk_table_attach (cur_table, entry, 1, 2, rows, rows + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - rows++; + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (hbox), entry, TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX (cur_vbox), hbox, FALSE, FALSE, 0); + g_hash_table_insert (gui->extra_config, entries[i].name, entry); } if (url) @@ -934,7 +912,7 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) gboolean enable; /* FIXME: this is pretty fucked... */ - data = entries[i].text; + data = _(entries[i].text); p = strstr (data, "%s"); g_return_if_fail (p != NULL); @@ -974,9 +952,7 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 4); - gtk_table_attach (cur_table, hbox, 0, 2, rows, rows + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - rows++; + gtk_box_pack_start (GTK_BOX (cur_vbox), hbox, FALSE, FALSE, 0); g_hash_table_insert (gui->extra_config, entries[i].name, checkbox); name = g_strdup_printf ("%s_value", entries[i].name); g_hash_table_insert (gui->extra_config, name, spin); @@ -994,7 +970,7 @@ mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string) } done: - gtk_widget_show_all (GTK_WIDGET (main_table)); + gtk_widget_show_all (main_vbox); if (url) camel_url_free (url); } @@ -1090,11 +1066,11 @@ mail_account_gui_folder_selector_button_new (char *widget_name, char *string1, char *string2, int int1, int int2) { - return (GtkWidget *)g_object_new (EVOLUTION_TYPE_FOLDER_SELECTOR_BUTTON, NULL); + return (GtkWidget *)gtk_type_new (EVOLUTION_TYPE_FOLDER_SELECTOR_BUTTON); } static gboolean -setup_service (MailAccountGuiService *gsvc, EAccountService *service) +setup_service (MailAccountGuiService *gsvc, MailConfigService *service) { CamelURL *url = camel_url_new (service->url, NULL); gboolean has_auth = FALSE; @@ -1131,11 +1107,11 @@ setup_service (MailAccountGuiService *gsvc, EAccountService *service) else if (!*use_ssl) /* old config code just used an empty string as the value */ use_ssl = "always"; - children = gtk_container_get_children(GTK_CONTAINER (gtk_option_menu_get_menu (gsvc->use_ssl))); + children = gtk_container_children (GTK_CONTAINER (gtk_option_menu_get_menu (gsvc->use_ssl))); for (item = children, i = 0; item; item = item->next, i++) { if (!strcmp (use_ssl, ssl_options[i].value)) { gtk_option_menu_set_history (gsvc->use_ssl, i); - g_signal_emit_by_name (item->data, "activate", gsvc); + gtk_signal_emit_by_name (item->data, "activate", gsvc); break; } } @@ -1146,14 +1122,14 @@ setup_service (MailAccountGuiService *gsvc, EAccountService *service) CamelServiceAuthType *authtype; int i; - children = gtk_container_get_children(GTK_CONTAINER (gtk_option_menu_get_menu (gsvc->authtype))); + children = gtk_container_children (GTK_CONTAINER (gtk_option_menu_get_menu (gsvc->authtype))); for (item = children, i = 0; item; item = item->next, i++) { - authtype = g_object_get_data ((GObject *) item->data, "authtype"); + authtype = gtk_object_get_data (item->data, "authtype"); if (!authtype) continue; if (!strcmp (authtype->authproto, url->authmech)) { gtk_option_menu_set_history (gsvc->authtype, i); - g_signal_emit_by_name (item->data, "activate"); + gtk_signal_emit_by_name (item->data, "activate"); break; } } @@ -1201,17 +1177,18 @@ construct_ssl_menu (MailAccountGuiService *service) for (i = 0; i < num_ssl_options; i++) { item = gtk_menu_item_new_with_label (_(ssl_options[i].label)); - g_object_set_data ((GObject *) item, "use_ssl", ssl_options[i].value); - g_signal_connect (item, "activate", G_CALLBACK (ssl_option_activate), service); + gtk_object_set_data (GTK_OBJECT (item), "use_ssl", ssl_options[i].value); + gtk_signal_connect (GTK_OBJECT (item), "activate", + ssl_option_activate, service); gtk_widget_show (item); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_menu_append (GTK_MENU (menu), item); } gtk_option_menu_remove_menu (service->use_ssl); gtk_option_menu_set_menu (service->use_ssl, menu); gtk_option_menu_set_history (service->use_ssl, i - 1); - g_signal_emit_by_name (item, "activate", service); + gtk_signal_emit_by_name (GTK_OBJECT (item), "activate", service); } static void @@ -1240,7 +1217,7 @@ sig_fill_options (MailAccountGui *gui) { GtkWidget *menu; GtkWidget *mi; - GSList *l; + GList *l; MailConfigSignature *sig; menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)); @@ -1249,17 +1226,21 @@ sig_fill_options (MailAccountGui *gui) clear_menu (menu); else menu = gtk_menu_new (); - - gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_menu_item_new_with_label (_("None"))); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_menu_item_new_with_label (_("Autogenerated"))); - /* gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_menu_item_new_with_label (_("Random"))); */ + + gtk_menu_append (GTK_MENU (menu), gtk_menu_item_new_with_label (_("None"))); + gtk_menu_append (GTK_MENU (menu), gtk_menu_item_new_with_label (_("Autogenerated"))); + /* gtk_menu_append (GTK_MENU (menu), gtk_menu_item_new_with_label (_("Random"))); */ for (l = mail_config_get_signature_list (); l; l = l->next) { + gchar *utf8; + sig = l->data; - mi = gtk_menu_item_new_with_label (sig->name); - g_object_set_data ((GObject *) mi, "sig", sig); + utf8 = e_utf8_to_gtk_string (menu, sig->name); + mi = gtk_menu_item_new_with_label (utf8); + g_free (utf8); + gtk_object_set_data (GTK_OBJECT (mi), "sig", sig); gtk_widget_show (mi); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); + gtk_menu_append (GTK_MENU (menu), mi); } } @@ -1272,7 +1253,7 @@ sig_changed (GtkWidget *w, MailAccountGui *gui) active = gtk_menu_get_active (GTK_MENU (w)); index = g_list_index (GTK_MENU_SHELL (w)->children, active); - gui->def_signature = (MailConfigSignature *) g_object_get_data(G_OBJECT(active), "sig"); + gui->def_signature = (MailConfigSignature *) gtk_object_get_data (GTK_OBJECT (active), "sig"); gui->auto_signature = index == 1 ? TRUE : FALSE; } @@ -1281,28 +1262,18 @@ sig_switch_to_list (GtkWidget *w, MailAccountGui *gui) { gtk_window_set_transient_for (GTK_WINDOW (gtk_widget_get_toplevel (w)), NULL); gdk_window_raise (GTK_WIDGET (gui->dialog)->window); - gtk_notebook_set_current_page (GTK_NOTEBOOK (glade_xml_get_widget (gui->dialog->gui, "notebook")), 3); + gtk_notebook_set_page (GTK_NOTEBOOK (glade_xml_get_widget (gui->dialog->gui, "notebook")), 3); } static void sig_add_new_signature (GtkWidget *w, MailAccountGui *gui) { - GConfClient *gconf; - gboolean send_html; - GtkWidget *parent; - if (!gui->dialog) return; sig_switch_to_list (w, gui); - gconf = gconf_client_get_default (); - send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL); - - parent = gtk_widget_get_toplevel (w); - parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - - gui->def_signature = mail_composer_prefs_new_signature ((GtkWindow *) parent, send_html, NULL); + gui->def_signature = mail_composer_prefs_new_signature (NULL, mail_config_get_send_html (), NULL); gui->auto_signature = FALSE; gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); @@ -1311,13 +1282,7 @@ sig_add_new_signature (GtkWidget *w, MailAccountGui *gui) static void setup_signatures (MailAccountGui *gui) { - MailConfigSignature *sig; - GSList *signatures; - - signatures = mail_config_get_signature_list (); - sig = g_slist_nth_data (signatures, gui->account->id->def_signature); - - gui->def_signature = sig; + gui->def_signature = gui->account->id->def_signature; gui->auto_signature = gui->account->id->auto_signature; gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); } @@ -1332,11 +1297,11 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailAccoun d(printf ("accounts ADDED\n")); mi = gtk_menu_item_new_with_label (sig->name); - g_object_set_data ((GObject *) mi, "sig", sig); + gtk_object_set_data (GTK_OBJECT (mi), "sig", sig); gtk_widget_show (mi); menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); - + gtk_menu_append (GTK_MENU (menu), mi); + break; } case MAIL_CONFIG_SIG_EVENT_NAME_CHANGED: { @@ -1351,9 +1316,8 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailAccoun gtk_label_set_text (GTK_LABEL (GTK_BIN (mi)->child), sig->name); gtk_option_menu_set_menu (GTK_OPTION_MENU (gui->sig_option_menu), menu); gtk_widget_unref (menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), - sig_gui_get_index (gui)); - + gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); + break; } case MAIL_CONFIG_SIG_EVENT_DELETED: { @@ -1365,14 +1329,13 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailAccoun if (sig == gui->def_signature) { gui->def_signature = NULL; gui->auto_signature = TRUE; - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), - sig_gui_get_index (gui)); + gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); } - + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)); mi = g_list_nth_data (GTK_MENU_SHELL (menu)->children, sig_get_index (sig)); gtk_container_remove (GTK_CONTAINER (menu), mi); - + break; } default: @@ -1385,11 +1348,10 @@ prepare_signatures (MailAccountGui *gui) { gui->sig_option_menu = glade_xml_get_widget (gui->xml, "sigOption"); sig_fill_options (gui); - g_signal_connect (gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)), - "selection-done", G_CALLBACK(sig_changed), gui); + gtk_signal_connect (GTK_OBJECT (gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu))), + "selection-done", sig_changed, gui); - glade_xml_signal_connect_data (gui->xml, "sigAddNewClicked", - G_CALLBACK (sig_add_new_signature), gui); + glade_xml_signal_connect_data (gui->xml, "sigAddNewClicked", GTK_SIGNAL_FUNC (sig_add_new_signature), gui); if (!gui->dialog) { gtk_widget_hide (glade_xml_get_widget (gui->xml, "sigLabel")); @@ -1401,24 +1363,22 @@ prepare_signatures (MailAccountGui *gui) } MailAccountGui * -mail_account_gui_new (EAccount *account, MailAccountsTab *dialog) +mail_account_gui_new (MailConfigAccount *account, MailAccountsTab *dialog) { const char *allowed_types[] = { "mail/*", NULL }; MailAccountGui *gui; GtkWidget *button; - g_object_ref (account); - gui = g_new0 (MailAccountGui, 1); gui->account = account; gui->dialog = dialog; - gui->xml = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL, NULL); + gui->xml = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL); /* Management */ gui->account_name = GTK_ENTRY (glade_xml_get_widget (gui->xml, "management_name")); gui->default_account = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "management_default")); if (account->name) - gtk_entry_set_text (gui->account_name, account->name); + e_utf8_gtk_entry_set_text (gui->account_name, account->name); if (!mail_config_get_default_account () || (account == mail_config_get_default_account ())) gtk_toggle_button_set_active (gui->default_account, TRUE); @@ -1431,30 +1391,32 @@ mail_account_gui_new (EAccount *account, MailAccountsTab *dialog) prepare_signatures (gui); - if (account->id->name) - gtk_entry_set_text (gui->full_name, account->id->name); - if (account->id->address) - gtk_entry_set_text (gui->email_address, account->id->address); - if (account->id->reply_to) - gtk_entry_set_text (gui->reply_to, account->id->reply_to); - if (account->id->organization) - gtk_entry_set_text (gui->organization, account->id->organization); - - setup_signatures (gui); + if (account->id) { + if (account->id->name) + e_utf8_gtk_entry_set_text (gui->full_name, account->id->name); + if (account->id->address) + e_utf8_gtk_entry_set_text (gui->email_address, account->id->address); + if (account->id->reply_to) + e_utf8_gtk_entry_set_text (gui->reply_to, account->id->reply_to); + if (account->id->organization) + e_utf8_gtk_entry_set_text (gui->organization, account->id->organization); + + setup_signatures (gui); + } /* Source */ gui->source.provider_type = CAMEL_PROVIDER_STORE; gui->source.type = GTK_OPTION_MENU (glade_xml_get_widget (gui->xml, "source_type_omenu")); gui->source.description = GTK_LABEL (glade_xml_get_widget (gui->xml, "source_description")); gui->source.hostname = GTK_ENTRY (glade_xml_get_widget (gui->xml, "source_host")); - g_signal_connect (gui->source.hostname, "changed", - G_CALLBACK (service_changed), &gui->source); + gtk_signal_connect (GTK_OBJECT (gui->source.hostname), "changed", + GTK_SIGNAL_FUNC (service_changed), &gui->source); gui->source.username = GTK_ENTRY (glade_xml_get_widget (gui->xml, "source_user")); - g_signal_connect (gui->source.username, "changed", - G_CALLBACK (service_changed), &gui->source); + gtk_signal_connect (GTK_OBJECT (gui->source.username), "changed", + GTK_SIGNAL_FUNC (service_changed), &gui->source); gui->source.path = GTK_ENTRY (glade_xml_get_widget (gui->xml, "source_path")); - g_signal_connect (gui->source.path, "changed", - G_CALLBACK (service_changed), &gui->source); + gtk_signal_connect (GTK_OBJECT (gui->source.path), "changed", + GTK_SIGNAL_FUNC (service_changed), &gui->source); gui->source.ssl_hbox = glade_xml_get_widget (gui->xml, "source_ssl_hbox"); gui->source.use_ssl = GTK_OPTION_MENU (glade_xml_get_widget (gui->xml, "source_use_ssl")); construct_ssl_menu (&gui->source); @@ -1462,8 +1424,8 @@ mail_account_gui_new (EAccount *account, MailAccountsTab *dialog) gui->source.authtype = GTK_OPTION_MENU (glade_xml_get_widget (gui->xml, "source_auth_omenu")); gui->source.remember = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "source_remember_password")); gui->source.check_supported = GTK_BUTTON (glade_xml_get_widget (gui->xml, "source_check_supported")); - g_signal_connect (gui->source.check_supported, "clicked", - G_CALLBACK (service_check_supported), &gui->source); + gtk_signal_connect (GTK_OBJECT (gui->source.check_supported), "clicked", + GTK_SIGNAL_FUNC (service_check_supported), &gui->source); gui->source_auto_check = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "extra_auto_check")); gui->source_auto_check_min = GTK_SPIN_BUTTON (glade_xml_get_widget (gui->xml, "extra_auto_check_min")); @@ -1472,28 +1434,27 @@ mail_account_gui_new (EAccount *account, MailAccountsTab *dialog) gui->transport.type = GTK_OPTION_MENU (glade_xml_get_widget (gui->xml, "transport_type_omenu")); gui->transport.description = GTK_LABEL (glade_xml_get_widget (gui->xml, "transport_description")); gui->transport.hostname = GTK_ENTRY (glade_xml_get_widget (gui->xml, "transport_host")); - g_signal_connect (gui->transport.hostname, "changed", - G_CALLBACK (service_changed), &gui->transport); + gtk_signal_connect (GTK_OBJECT (gui->transport.hostname), "changed", + GTK_SIGNAL_FUNC (service_changed), &gui->transport); gui->transport.username = GTK_ENTRY (glade_xml_get_widget (gui->xml, "transport_user")); - g_signal_connect (gui->transport.username, "changed", - G_CALLBACK (service_changed), &gui->transport); + gtk_signal_connect (GTK_OBJECT (gui->transport.username), "changed", + GTK_SIGNAL_FUNC (service_changed), &gui->transport); gui->transport.ssl_hbox = glade_xml_get_widget (gui->xml, "transport_ssl_hbox"); gui->transport.use_ssl = GTK_OPTION_MENU (glade_xml_get_widget (gui->xml, "transport_use_ssl")); construct_ssl_menu (&gui->transport); gui->transport.no_ssl = glade_xml_get_widget (gui->xml, "transport_ssl_disabled"); gui->transport_needs_auth = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "transport_needs_auth")); - g_signal_connect (gui->transport_needs_auth, "toggled", - G_CALLBACK (transport_needs_auth_toggled), gui); + gtk_signal_connect (GTK_OBJECT (gui->transport_needs_auth), "toggled", transport_needs_auth_toggled, gui); gui->transport.authtype = GTK_OPTION_MENU (glade_xml_get_widget (gui->xml, "transport_auth_omenu")); gui->transport.remember = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "transport_remember_password")); gui->transport.check_supported = GTK_BUTTON (glade_xml_get_widget (gui->xml, "transport_check_supported")); - g_signal_connect (gui->transport.check_supported, "clicked", - G_CALLBACK (service_check_supported), &gui->transport); + gtk_signal_connect (GTK_OBJECT (gui->transport.check_supported), "clicked", + GTK_SIGNAL_FUNC (service_check_supported), &gui->transport); /* Drafts folder */ gui->drafts_folder_button = GTK_BUTTON (glade_xml_get_widget (gui->xml, "drafts_button")); - g_signal_connect (gui->drafts_folder_button, "selected", - G_CALLBACK (folder_selected), &gui->drafts_folder_uri); + gtk_signal_connect (GTK_OBJECT (gui->drafts_folder_button), "selected", + GTK_SIGNAL_FUNC (folder_selected), &gui->drafts_folder_uri); if (account->drafts_folder_uri) gui->drafts_folder_uri = g_strdup (account->drafts_folder_uri); else @@ -1506,8 +1467,8 @@ mail_account_gui_new (EAccount *account, MailAccountsTab *dialog) /* Sent folder */ gui->sent_folder_button = GTK_BUTTON (glade_xml_get_widget (gui->xml, "sent_button")); - g_signal_connect (gui->sent_folder_button, "selected", - G_CALLBACK (folder_selected), &gui->sent_folder_uri); + gtk_signal_connect (GTK_OBJECT (gui->sent_folder_button), "selected", + GTK_SIGNAL_FUNC (folder_selected), &gui->sent_folder_uri); if (account->sent_folder_uri) gui->sent_folder_uri = g_strdup (account->sent_folder_uri); else @@ -1520,26 +1481,25 @@ mail_account_gui_new (EAccount *account, MailAccountsTab *dialog) /* Special Folders "Reset Defaults" button */ button = glade_xml_get_widget (gui->xml, "default_folders_button"); - g_signal_connect (button, "clicked", G_CALLBACK (default_folders_clicked), gui); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (default_folders_clicked), gui); /* Always Cc */ gui->always_cc = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "always_cc")); gtk_toggle_button_set_active (gui->always_cc, account->always_cc); gui->cc_addrs = GTK_ENTRY (glade_xml_get_widget (gui->xml, "cc_addrs")); - if (account->cc_addrs) - gtk_entry_set_text (gui->cc_addrs, account->cc_addrs); + e_utf8_gtk_entry_set_text (gui->cc_addrs, account->cc_addrs); /* Always Bcc */ gui->always_bcc = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "always_bcc")); gtk_toggle_button_set_active (gui->always_bcc, account->always_bcc); gui->bcc_addrs = GTK_ENTRY (glade_xml_get_widget (gui->xml, "bcc_addrs")); - if (account->bcc_addrs) - gtk_entry_set_text (gui->bcc_addrs, account->bcc_addrs); + e_utf8_gtk_entry_set_text (gui->bcc_addrs, account->bcc_addrs); /* Security */ gui->pgp_key = GTK_ENTRY (glade_xml_get_widget (gui->xml, "pgp_key")); if (account->pgp_key) - gtk_entry_set_text (gui->pgp_key, account->pgp_key); + e_utf8_gtk_entry_set_text (gui->pgp_key, account->pgp_key); gui->pgp_encrypt_to_self = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "pgp_encrypt_to_self")); gtk_toggle_button_set_active (gui->pgp_encrypt_to_self, account->pgp_encrypt_to_self); gui->pgp_always_sign = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "pgp_always_sign")); @@ -1552,7 +1512,7 @@ mail_account_gui_new (EAccount *account, MailAccountsTab *dialog) #if defined (HAVE_NSS) && defined (SMIME_SUPPORTED) gui->smime_key = GTK_ENTRY (glade_xml_get_widget (gui->xml, "smime_key")); if (account->smime_key) - gtk_entry_set_text (gui->smime_key, account->smime_key); + e_utf8_gtk_entry_set_text (gui->smime_key, account->smime_key); gui->smime_encrypt_to_self = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "smime_encrypt_to_self")); gtk_toggle_button_set_active (gui->smime_encrypt_to_self, account->smime_encrypt_to_self); gui->smime_always_sign = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "smime_always_sign")); @@ -1610,12 +1570,16 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) item = NULL; if (provider->object_types[CAMEL_PROVIDER_STORE] && provider->flags & CAMEL_PROVIDER_IS_SOURCE) { item = gtk_menu_item_new_with_label (provider->name); - g_object_set_data ((GObject *) gui->source.type, provider->protocol, item); - g_object_set_data ((GObject *) item, "provider", provider); - g_object_set_data ((GObject *) item, "number", GUINT_TO_POINTER (si)); - g_signal_connect (item, "activate", G_CALLBACK (source_type_changed), gui); + gtk_object_set_data (GTK_OBJECT (gui->source.type), + provider->protocol, item); + gtk_object_set_data (GTK_OBJECT (item), "provider", provider); + gtk_object_set_data (GTK_OBJECT (item), "number", + GUINT_TO_POINTER (si)); + gtk_signal_connect (GTK_OBJECT (item), "activate", + GTK_SIGNAL_FUNC (source_type_changed), + gui); - gtk_menu_shell_append(GTK_MENU_SHELL(stores), item); + gtk_menu_append (GTK_MENU (stores), item); gtk_widget_show (item); @@ -1624,7 +1588,7 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) hstore = si; } - if (source_proto && !strcasecmp (provider->protocol, source_proto)) { + if (source_proto && !g_strcasecmp (provider->protocol, source_proto)) { fstore = item; hstore = si; } @@ -1634,15 +1598,19 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) if (provider->object_types[CAMEL_PROVIDER_TRANSPORT]) { item = gtk_menu_item_new_with_label (provider->name); - g_object_set_data ((GObject *) gui->transport.type, provider->protocol, item); - g_object_set_data ((GObject *) item, "provider", provider); - g_object_set_data ((GObject *) item, "number", GUINT_TO_POINTER (ti)); - g_signal_connect (item, "activate", G_CALLBACK (transport_type_changed), gui); + gtk_object_set_data (GTK_OBJECT (gui->transport.type), + provider->protocol, item); + gtk_object_set_data (GTK_OBJECT (item), "provider", provider); + gtk_object_set_data (GTK_OBJECT (item), "number", + GUINT_TO_POINTER (ti)); + gtk_signal_connect (GTK_OBJECT (item), "activate", + GTK_SIGNAL_FUNC (transport_type_changed), + gui); - gtk_menu_shell_append(GTK_MENU_SHELL(transports), item); + gtk_menu_append (GTK_MENU (transports), item); gtk_widget_show (item); - + if (CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider)) gtk_widget_set_sensitive (item, FALSE); @@ -1651,7 +1619,7 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) htransport = ti; } - if (transport_proto && !strcasecmp (provider->protocol, transport_proto)) { + if (transport_proto && !g_strcasecmp (provider->protocol, transport_proto)) { ftransport = item; htransport = ti; } @@ -1660,7 +1628,7 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) } if (item && provider->authtypes) { - /*GdkFont *font = GTK_WIDGET (item)->style->font;*/ + GdkFont *font = GTK_WIDGET (item)->style->font; CamelServiceAuthType *at; int width; GList *a; @@ -1668,10 +1636,7 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) for (a = provider->authtypes; a; a = a->next) { at = a->data; - /* Just using string length is probably good enough, - as we only use the width of the widget, not the string */ - /*width = gdk_string_width (font, at->name);*/ - width = strlen(at->name) * 14; + width = gdk_string_width (font, at->name); if (width > max_width) { max_authname = at->name; max_width = width; @@ -1683,10 +1648,12 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) /* add a "None" option to the stores menu */ item = gtk_menu_item_new_with_label (_("None")); - g_object_set_data ((GObject *) item, "provider", NULL); - g_signal_connect (item, "activate", G_CALLBACK (source_type_changed), gui); + gtk_object_set_data (GTK_OBJECT (item), "provider", NULL); + gtk_signal_connect (GTK_OBJECT (item), "activate", + GTK_SIGNAL_FUNC (source_type_changed), + gui); - gtk_menu_shell_append(GTK_MENU_SHELL(stores), item); + gtk_menu_append (GTK_MENU (stores), item); gtk_widget_show (item); @@ -1709,16 +1676,16 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) menu = gtk_menu_new (); item = gtk_menu_item_new_with_label (max_authname); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_menu_append (GTK_MENU (menu), item); gtk_widget_show_all (menu); gtk_option_menu_set_menu (gui->source.authtype, menu); gtk_widget_show (GTK_WIDGET (gui->source.authtype)); gtk_widget_size_request (GTK_WIDGET (gui->source.authtype), &size_req); - gtk_widget_set_size_request (GTK_WIDGET (gui->source.authtype), + gtk_widget_set_usize (GTK_WIDGET (gui->source.authtype), size_req.width, -1); - gtk_widget_set_size_request (GTK_WIDGET (gui->transport.authtype), + gtk_widget_set_usize (GTK_WIDGET (gui->transport.authtype), size_req.width, -1); } @@ -1727,12 +1694,12 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) } if (fstore) { - g_signal_emit_by_name (fstore, "activate"); + gtk_signal_emit_by_name (GTK_OBJECT (fstore), "activate"); gtk_option_menu_set_history (gui->source.type, hstore); } if (ftransport) { - g_signal_emit_by_name (ftransport, "activate"); + gtk_signal_emit_by_name (GTK_OBJECT (ftransport), "activate"); gtk_option_menu_set_history (gui->transport.type, htransport); } @@ -1756,10 +1723,11 @@ mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top) } static void -save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, EAccountService *service) +save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, + MailConfigService *service) { CamelURL *url; - const char *str; + char *str; if (!gsvc->provider) { g_free (service->url); @@ -1780,7 +1748,7 @@ save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, EAccountSer GTK_WIDGET_IS_SENSITIVE (gsvc->authtype) && gsvc->authitem && url->user) { CamelServiceAuthType *authtype; - authtype = g_object_get_data(G_OBJECT(gsvc->authitem), "authtype"); + authtype = gtk_object_get_data (GTK_OBJECT (gsvc->authitem), "authtype"); if (authtype && authtype->authproto && *authtype->authproto) url->authmech = g_strdup (authtype->authproto); @@ -1810,7 +1778,7 @@ save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, EAccountSer if (gsvc->provider->flags & CAMEL_PROVIDER_SUPPORTS_SSL) { const char *use_ssl; - use_ssl = g_object_get_data(G_OBJECT(gsvc->ssl_selected), "use_ssl"); + use_ssl = gtk_object_get_data (GTK_OBJECT (gsvc->ssl_selected), "use_ssl"); /* set the value to either "always" or "when-possible" but don't bother setting it for "never" */ @@ -1834,7 +1802,7 @@ save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, EAccountSer static void add_new_store (char *uri, CamelStore *store, void *user_data) { - EAccount *account = user_data; + const MailConfigAccount *account = user_data; EvolutionStorage *storage; if (store == NULL) @@ -1853,13 +1821,13 @@ add_new_store (char *uri, CamelStore *store, void *user_data) gboolean mail_account_gui_save (MailAccountGui *gui) { - EAccount *account, *new; + MailConfigAccount *account = gui->account; + MailConfigAccount *old_account; CamelProvider *provider = NULL; CamelURL *source_url = NULL, *url; - gboolean is_new = FALSE; - const char *new_name; gboolean is_storage; - GSList *signatures; + gboolean enabled; + char *new_name; if (!mail_account_gui_identity_complete (gui, NULL) || !mail_account_gui_source_complete (gui, NULL) || @@ -1867,63 +1835,70 @@ mail_account_gui_save (MailAccountGui *gui) !mail_account_gui_management_complete (gui, NULL)) return FALSE; - new = gui->account; - /* this would happen at an inconvenient time in the druid, * but the druid performs its own check so this can't happen * here. */ - new_name = gtk_entry_get_text (gui->account_name); - account = mail_config_get_account_by_name (new_name); + new_name = e_utf8_gtk_entry_get_text (gui->account_name); + old_account = (MailConfigAccount *) mail_config_get_account_by_name (new_name); - if (account && account != new) { - e_notice (gui->account_name, GTK_MESSAGE_ERROR, _("You may not create two accounts with the same name.")); + if (old_account && old_account != account) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("You may not create two accounts with the same name.")); return FALSE; } - account = new; + /* make a copy of the old account for later use... */ + old_account = account_copy (account); - new = e_account_new (); - new->name = g_strdup (new_name); - new->enabled = account->enabled; + g_free (account->name); + account->name = new_name; /* construct the identity */ - new->id->name = g_strdup (gtk_entry_get_text (gui->full_name)); - new->id->address = g_strdup (gtk_entry_get_text (gui->email_address)); - new->id->reply_to = g_strdup (gtk_entry_get_text (gui->reply_to)); - new->id->organization = g_strdup (gtk_entry_get_text (gui->organization)); + identity_destroy (account->id); + account->id = g_new0 (MailConfigIdentity, 1); + account->id->name = e_utf8_gtk_entry_get_text (gui->full_name); + account->id->address = e_utf8_gtk_entry_get_text (gui->email_address); + account->id->reply_to = e_utf8_gtk_entry_get_text (gui->reply_to); + account->id->organization = e_utf8_gtk_entry_get_text (gui->organization); /* signatures */ - signatures = mail_config_get_signature_list (); - new->id->def_signature = g_slist_index (signatures, gui->def_signature); - new->id->auto_signature = gui->auto_signature; - - /* source */ - save_service (&gui->source, gui->extra_config, new->source); - if (new->source->url) { - provider = camel_session_get_provider (session, new->source->url, NULL); - source_url = provider ? camel_url_new (new->source->url, NULL) : NULL; + account->id->def_signature = gui->def_signature; + account->id->auto_signature = gui->auto_signature; + + enabled = account->source && account->source->enabled; + service_destroy (account->source); + account->source = g_new0 (MailConfigService, 1); + save_service (&gui->source, gui->extra_config, account->source); + if (account->source->url) { + provider = camel_session_get_provider (session, account->source->url, NULL); + source_url = provider ? camel_url_new (account->source->url, NULL) : NULL; } - new->source->auto_check = gtk_toggle_button_get_active (gui->source_auto_check); - if (new->source->auto_check) - new->source->auto_check_time = gtk_spin_button_get_value_as_int (gui->source_auto_check_min); + account->source->enabled = enabled; + + account->source->auto_check = gtk_toggle_button_get_active (gui->source_auto_check); + if (account->source->auto_check) + account->source->auto_check_time = gtk_spin_button_get_value_as_int (gui->source_auto_check_min); - /* transport */ + service_destroy (account->transport); + account->transport = g_new0 (MailConfigService, 1); if (CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (gui->transport.provider)) { /* The transport URI is the same as the source URI. */ - save_service (&gui->source, gui->extra_config, new->transport); + save_service (&gui->source, gui->extra_config, account->transport); } else - save_service (&gui->transport, NULL, new->transport); + save_service (&gui->transport, NULL, account->transport); /* Check to make sure that the Drafts folder uri is "valid" before assigning it */ url = source_url && gui->drafts_folder_uri ? camel_url_new (gui->drafts_folder_uri, NULL) : NULL; if (mail_config_get_account_by_source_url (gui->drafts_folder_uri) || (url && provider->url_equal (source_url, url))) { - new->drafts_folder_uri = g_strdup (gui->drafts_folder_uri); + g_free (account->drafts_folder_uri); + account->drafts_folder_uri = g_strdup (gui->drafts_folder_uri); } else { /* assign defaults - the uri is unknown to us (probably pointed to an old source url) */ - new->drafts_folder_uri = g_strdup (default_drafts_folder_uri); + g_free (account->drafts_folder_uri); + account->drafts_folder_uri = g_strdup (default_drafts_folder_uri); } if (url) @@ -1933,10 +1908,12 @@ mail_account_gui_save (MailAccountGui *gui) url = source_url && gui->sent_folder_uri ? camel_url_new (gui->sent_folder_uri, NULL) : NULL; if (mail_config_get_account_by_source_url (gui->sent_folder_uri) || (url && provider->url_equal (source_url, url))) { - new->sent_folder_uri = g_strdup (gui->sent_folder_uri); + g_free (account->sent_folder_uri); + account->sent_folder_uri = g_strdup (gui->sent_folder_uri); } else { /* assign defaults - the uri is unknown to us (probably pointed to an old source url) */ - new->sent_folder_uri = g_strdup (default_sent_folder_uri); + g_free (account->sent_folder_uri); + account->sent_folder_uri = g_strdup (default_sent_folder_uri); } if (url) @@ -1945,49 +1922,44 @@ mail_account_gui_save (MailAccountGui *gui) if (source_url) camel_url_free (source_url); - new->always_cc = gtk_toggle_button_get_active (gui->always_cc); - new->cc_addrs = g_strdup (gtk_entry_get_text (gui->cc_addrs)); - new->always_bcc = gtk_toggle_button_get_active (gui->always_bcc); - new->bcc_addrs = g_strdup (gtk_entry_get_text (gui->bcc_addrs)); + account->always_cc = gtk_toggle_button_get_active (gui->always_cc); + account->cc_addrs = e_utf8_gtk_entry_get_text (gui->cc_addrs); + account->always_bcc = gtk_toggle_button_get_active (gui->always_bcc); + account->bcc_addrs = e_utf8_gtk_entry_get_text (gui->bcc_addrs); - new->pgp_key = g_strdup (gtk_entry_get_text (gui->pgp_key)); - new->pgp_encrypt_to_self = gtk_toggle_button_get_active (gui->pgp_encrypt_to_self); - new->pgp_always_sign = gtk_toggle_button_get_active (gui->pgp_always_sign); - new->pgp_no_imip_sign = gtk_toggle_button_get_active (gui->pgp_no_imip_sign); - new->pgp_always_trust = gtk_toggle_button_get_active (gui->pgp_always_trust); + g_free (account->pgp_key); + account->pgp_key = e_utf8_gtk_entry_get_text (gui->pgp_key); + account->pgp_encrypt_to_self = gtk_toggle_button_get_active (gui->pgp_encrypt_to_self); + account->pgp_always_sign = gtk_toggle_button_get_active (gui->pgp_always_sign); + account->pgp_no_imip_sign = gtk_toggle_button_get_active (gui->pgp_no_imip_sign); + account->pgp_always_trust = gtk_toggle_button_get_active (gui->pgp_always_trust); #if defined (HAVE_NSS) && defined (SMIME_SUPPORTED) - new->smime_key = g_strdup (gtk_entry_get_text (gui->smime_key)); - new->smime_encrypt_to_self = gtk_toggle_button_get_active (gui->smime_encrypt_to_self); - new->smime_always_sign = gtk_toggle_button_get_active (gui->smime_always_sign); + g_free (account->smime_key); + account->smime_key = e_utf8_gtk_entry_get_text (gui->smime_key); + account->smime_encrypt_to_self = gtk_toggle_button_get_active (gui->smime_encrypt_to_self); + account->smime_always_sign = gtk_toggle_button_get_active (gui->smime_always_sign); #endif /* HAVE_NSS && SMIME_SUPPORTED */ is_storage = provider && (provider->flags & CAMEL_PROVIDER_IS_STORAGE) && !(provider->flags & CAMEL_PROVIDER_IS_EXTERNAL); if (!mail_config_find_account (account)) { - /* this is a new account so add it to our account-list */ - is_new = TRUE; - } else if (account->source->url) { + /* this is a new account so it it to our account-list */ + mail_config_add_account (account); + } else if (old_account->source && old_account->source->url) { /* this means the account was edited - if the old and new source urls are not identical, replace the old storage with the new storage */ #define sources_equal(old,new) (new->url && !strcmp (old->url, new->url)) - if (!sources_equal (account->source, new->source)) { + if (!sources_equal (old_account->source, account->source)) { /* Remove the old storage from the folder-tree */ - mail_remove_storage_by_uri (account->source->url); + mail_remove_storage_by_uri (old_account->source->url); } } - /* update the old account with the new settings */ - e_account_import (account, new); - g_object_unref (new); - - if (is_new) { - mail_config_add_account (account); - } else { - e_account_list_change (mail_config_get_accounts (), account); - } + /* destroy the copy of the old account */ + account_destroy (old_account); /* if the account provider is something we can stick in the folder-tree and not added by some other @@ -1999,7 +1971,6 @@ mail_account_gui_save (MailAccountGui *gui) if (gtk_toggle_button_get_active (gui->default_account)) mail_config_set_default_account (account); - mail_config_save_accounts (); mail_config_write_account_sig (account, -1); mail_autoreceive_setup (); @@ -2012,13 +1983,10 @@ mail_account_gui_destroy (MailAccountGui *gui) { if (gui->dialog) mail_config_signature_unregister_client ((MailConfigSignatureClient) sig_event_client, gui); - - g_object_unref (gui->xml); - g_object_unref (gui->account); - + + gtk_object_unref (GTK_OBJECT (gui->xml)); if (gui->extra_config) g_hash_table_destroy (gui->extra_config); - g_free (gui->drafts_folder_uri); g_free (gui->sent_folder_uri); g_free (gui); diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c index fb06efd6ba..1ad5c066fa 100644 --- a/mail/mail-accounts.c +++ b/mail/mail-accounts.c @@ -27,10 +27,16 @@ #include "mail-accounts.h" +#include <libgnomeui/gnome-stock.h> +#include <libgnomeui/gnome-messagebox.h> +#include <gal/e-table/e-table-memory-store.h> +#include <gal/e-table/e-table-scrolled.h> +#include <gal/e-table/e-cell-toggle.h> +#include <gal/util/e-unicode-i18n.h> +#include <gal/widgets/e-unicode.h> #include <camel/camel-url.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtktreeselection.h> +#include <bonobo/bonobo-generic-factory.h> #include "mail.h" #include "mail-config.h" @@ -40,11 +46,11 @@ #include "art/mark.xpm" +#define USE_ETABLE 0 static void mail_accounts_tab_class_init (MailAccountsTabClass *class); static void mail_accounts_tab_init (MailAccountsTab *prefs); -static void mail_accounts_tab_finalise (GObject *obj); -static void mail_accounts_tab_destroy (GtkObject *object); +static void mail_accounts_tab_finalise (GtkObject *obj); static void mail_accounts_load (MailAccountsTab *tab); @@ -57,23 +63,23 @@ static GtkVBoxClass *parent_class = NULL; #define PREFS_WINDOW(prefs) GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (prefs), GTK_TYPE_WINDOW)) -GType +GtkType mail_accounts_tab_get_type (void) { - static GType type = 0; + static GtkType type = 0; if (!type) { - GTypeInfo type_info = { - sizeof (MailAccountsTabClass), - NULL, NULL, - (GClassInitFunc) mail_accounts_tab_class_init, - NULL, NULL, + GtkTypeInfo type_info = { + "MailAccountsTab", sizeof (MailAccountsTab), - 0, - (GInstanceInitFunc) mail_accounts_tab_init, + sizeof (MailAccountsTabClass), + (GtkClassInitFunc) mail_accounts_tab_class_init, + (GtkObjectInitFunc) mail_accounts_tab_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL }; - type = g_type_register_static (gtk_vbox_get_type (), "MailAccountsTab", &type_info, 0); + type = gtk_type_unique (gtk_vbox_get_type (), &type_info); } return type; @@ -82,14 +88,14 @@ mail_accounts_tab_get_type (void) static void mail_accounts_tab_class_init (MailAccountsTabClass *klass) { - GtkObjectClass *gtk_object_class = (GtkObjectClass *) klass; - GObjectClass *object_class = (GObjectClass *) klass; + GtkObjectClass *object_class; - parent_class = g_type_class_ref (gtk_vbox_get_type ()); - - gtk_object_class->destroy = mail_accounts_tab_destroy; + object_class = (GtkObjectClass *) klass; + parent_class = gtk_type_class (gtk_vbox_get_type ()); object_class->finalize = mail_accounts_tab_finalise; + /* override methods */ + /* setup static data */ disabled_pixbuf = NULL; @@ -106,71 +112,59 @@ mail_accounts_tab_init (MailAccountsTab *prefs) } static void -mail_accounts_tab_destroy (GtkObject *obj) -{ - MailAccountsTab *prefs = (MailAccountsTab *) obj; - - prefs->destroyed = TRUE; - - GTK_OBJECT_CLASS (parent_class)->destroy (obj); -} - -static void -mail_accounts_tab_finalise (GObject *obj) +mail_accounts_tab_finalise (GtkObject *obj) { MailAccountsTab *prefs = (MailAccountsTab *) obj; - g_object_unref (prefs->gui); + gtk_object_unref (GTK_OBJECT (prefs->gui)); gdk_pixmap_unref (prefs->mark_pixmap); - g_object_unref (prefs->mark_bitmap); + gdk_bitmap_unref (prefs->mark_bitmap); - G_OBJECT_CLASS (parent_class)->finalize (obj); + ((GtkObjectClass *)(parent_class))->finalize (obj); } static void -account_add_finished (MailAccountsTab *prefs, GObject *deadbeef) +account_add_finished (GtkWidget *widget, gpointer user_data) { /* Either Cancel or Finished was clicked in the druid so reload the accounts */ + MailAccountsTab *prefs = user_data; + prefs->druid = NULL; - if (!prefs->destroyed) + if (!GTK_OBJECT_DESTROYED (prefs)) mail_accounts_load (prefs); - g_object_unref (prefs); + gtk_object_unref ((GtkObject *) prefs); } static void account_add_clicked (GtkButton *button, gpointer user_data) { MailAccountsTab *prefs = (MailAccountsTab *) user_data; - GtkWidget *parent; if (prefs->druid == NULL) { - prefs->druid = (GtkWidget *) mail_config_druid_new (); - - parent = gtk_widget_get_toplevel ((GtkWidget *) prefs); - if (GTK_WIDGET_TOPLEVEL (parent)) - gtk_window_set_transient_for ((GtkWindow *) prefs->druid, (GtkWindow *) parent); - - g_object_weak_ref ((GObject *) prefs->druid, - (GWeakNotify) account_add_finished, prefs); + prefs->druid = (GtkWidget *) mail_config_druid_new (prefs->shell); + gtk_signal_connect (GTK_OBJECT (prefs->druid), "destroy", + GTK_SIGNAL_FUNC (account_add_finished), prefs); gtk_widget_show (prefs->druid); - g_object_ref (prefs); + gtk_object_ref ((GtkObject *) prefs); } else { gdk_window_raise (prefs->druid->window); } } static void -account_edit_finished (MailAccountsTab *prefs, GObject *deadbeef) +account_edit_finished (GtkWidget *widget, gpointer user_data) { + MailAccountsTab *prefs = user_data; + prefs->editor = NULL; - if (!prefs->destroyed) + if (!GTK_OBJECT_DESTROYED (prefs)) mail_accounts_load (prefs); - g_object_unref (prefs); + gtk_object_unref ((GtkObject *) prefs); } static void @@ -179,26 +173,29 @@ account_edit_clicked (GtkButton *button, gpointer user_data) MailAccountsTab *prefs = (MailAccountsTab *) user_data; if (prefs->editor == NULL) { - GtkTreeSelection *selection; - EAccount *account = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - - selection = gtk_tree_view_get_selection (prefs->table); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - gtk_tree_model_get (model, &iter, 3, &account, -1); - - if (account) { - GtkWidget *parent; - - parent = gtk_widget_get_toplevel ((GtkWidget *) prefs); - parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; + int row; +#if USE_ETABLE + row = e_table_get_cursor_row (prefs->table); +#else + row = prefs->table->selection ? GPOINTER_TO_INT (prefs->table->selection->data) : -1; +#endif + if (row >= 0) { + MailConfigAccount *account; + GtkWidget *window; - prefs->editor = (GtkWidget *) mail_account_editor_new (account, (GtkWindow *) parent, prefs); + window = gtk_widget_get_ancestor (GTK_WIDGET (prefs), GTK_TYPE_WINDOW); - g_object_weak_ref ((GObject *) prefs->editor, (GWeakNotify) account_edit_finished, prefs); +#if USE_ETABLE + account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row); +#else + account = gtk_clist_get_row_data (prefs->table, row); +#endif + prefs->editor = (GtkWidget *) mail_account_editor_new (account, GTK_WINDOW (window), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->editor), "destroy", + GTK_SIGNAL_FUNC (account_edit_finished), + prefs); gtk_widget_show (prefs->editor); - g_object_ref (prefs); + gtk_object_ref ((GtkObject *) prefs); } } else { gdk_window_raise (prefs->editor->window); @@ -209,60 +206,66 @@ static void account_delete_clicked (GtkButton *button, gpointer user_data) { MailAccountsTab *prefs = user_data; - GtkTreeSelection *selection; - EAccount *account = NULL; - EAccountList *accounts; - GtkTreeModel *model; - GtkWidget *confirm; - GtkTreeIter iter; - int ans; - - selection = gtk_tree_view_get_selection (prefs->table); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - gtk_tree_model_get (model, &iter, 3, &account, -1); + const MailConfigAccount *account; + GnomeDialog *confirm; + const GSList *list; + int row, ans; + +#if USE_ETABLE + row = e_table_get_cursor_row (prefs->table); +#else + row = prefs->table->selection ? GPOINTER_TO_INT (prefs->table->selection->data) : -1; +#endif /* make sure we have a valid account selected and that we aren't editing anything... */ - if (account == NULL || prefs->editor != NULL) + if (row < 0 || prefs->editor != NULL) return; - confirm = gtk_message_dialog_new (PREFS_WINDOW (prefs), - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, - _("Are you sure you want to delete this account?")); - - button = (GtkButton *) gtk_button_new_from_stock (GTK_STOCK_YES); - gtk_button_set_label (button, _("Delete")); - gtk_dialog_add_action_widget ((GtkDialog *) confirm, (GtkWidget *) button, GTK_RESPONSE_YES); - gtk_widget_show ((GtkWidget *) button); - - button = (GtkButton *) gtk_button_new_from_stock (GTK_STOCK_NO); - gtk_button_set_label (button, _("Don't delete")); - gtk_dialog_add_action_widget ((GtkDialog *) confirm, (GtkWidget *) button, GTK_RESPONSE_NO); - gtk_widget_show ((GtkWidget *) button); - - ans = gtk_dialog_run ((GtkDialog *) confirm); - gtk_widget_destroy (confirm); - - if (ans == GTK_RESPONSE_YES) { - int len; + confirm = GNOME_DIALOG (gnome_message_box_new (_("Are you sure you want to delete this account?"), + GNOME_MESSAGE_BOX_QUESTION, + NULL)); + gnome_dialog_append_button_with_pixmap (confirm, _("Delete"), GNOME_STOCK_BUTTON_YES); + gnome_dialog_append_button_with_pixmap (confirm, _("Don't delete"), GNOME_STOCK_BUTTON_NO); + gtk_window_set_policy (GTK_WINDOW (confirm), TRUE, TRUE, TRUE); + gtk_window_set_modal (GTK_WINDOW (confirm), TRUE); + gtk_window_set_title (GTK_WINDOW (confirm), _("Really delete account?")); + gnome_dialog_set_parent (confirm, PREFS_WINDOW (prefs)); + ans = gnome_dialog_run_and_close (confirm); + + if (ans == 0) { + int select, len; + +#if USE_ETABLE + account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row); +#else + account = gtk_clist_get_row_data (prefs->table, row); +#endif /* remove it from the folder-tree in the shell */ - if (account->enabled && account->source && account->source->url) + if (account->source && account->source->url && account->source->enabled) mail_remove_storage_by_uri (account->source->url); /* remove it from the config file */ - mail_config_remove_account (account); - accounts = mail_config_get_accounts (); + list = mail_config_remove_account ((MailConfigAccount *) account); mail_config_write (); mail_autoreceive_setup (); - gtk_list_store_remove ((GtkListStore *) model, &iter); +#if USE_ETABLE + e_table_memory_store_remove (E_TABLE_MEMORY_STORE (prefs->model), row); +#else + gtk_clist_remove (prefs->table, row); +#endif - len = e_list_length ((EList *) accounts); + len = list ? g_slist_length ((GSList *) list) : 0; if (len > 0) { - gtk_tree_selection_select_iter (selection, &iter); + select = row >= len ? len - 1 : row; +#if USE_ETABLE + e_table_set_cursor_row (prefs->table, select); +#else + gtk_clist_select_row (prefs->table, select, 0); +#endif } else { gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), FALSE); @@ -276,16 +279,22 @@ static void account_default_clicked (GtkButton *button, gpointer user_data) { MailAccountsTab *prefs = user_data; - GtkTreeSelection *selection; - EAccount *account = NULL; - GtkTreeModel *model; - GtkTreeIter iter; + const MailConfigAccount *account; + int row; - selection = gtk_tree_view_get_selection (prefs->table); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - gtk_tree_model_get (model, &iter, 3, &account, -1); +#if USE_ETABLE + row = e_table_get_cursor_row (prefs->table); +#else + row = prefs->table->selection ? GPOINTER_TO_INT (prefs->table->selection->data) : -1; +#endif - if (account) { + if (row >= 0) { +#if USE_ETABLE + account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row); +#else + account = gtk_clist_get_row_data (prefs->table, row); +#endif + mail_config_set_default_account (account); mail_config_write (); @@ -298,222 +307,259 @@ static void account_able_clicked (GtkButton *button, gpointer user_data) { MailAccountsTab *prefs = user_data; - GtkTreeSelection *selection; - EAccount *account = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - - selection = gtk_tree_view_get_selection (prefs->table); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gtk_tree_model_get (model, &iter, 3, &account, -1); - account->enabled = !account->enabled; - gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->enabled, -1); - - gtk_button_set_label (prefs->mail_able, account->enabled ? _("Disable") : _("Enable")); - } + const MailConfigAccount *account; + int row; - if (account) { +#if USE_ETABLE + row = e_table_get_cursor_row (prefs->table); +#else + row = prefs->table->selection ? GPOINTER_TO_INT (prefs->table->selection->data) : -1; +#endif + + if (row >= 0) { +#if USE_ETABLE + account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row); +#else + account = gtk_clist_get_row_data (prefs->table, row); +#endif + + account->source->enabled = !account->source->enabled; + /* if the account got disabled, remove it from the folder-tree, otherwise add it to the folder-tree */ if (account->source->url) { - if (account->enabled) + if (account->source->enabled) mail_load_storage_by_uri (prefs->shell, account->source->url, account->name); else mail_remove_storage_by_uri (account->source->url); } +#if USE_ETABLE + +#else + if (account->source->enabled) + gtk_clist_set_pixmap (prefs->table, row, 0, + prefs->mark_pixmap, + prefs->mark_bitmap); + else + gtk_clist_set_pixmap (prefs->table, row, 0, NULL, NULL); + + gtk_clist_select_row (prefs->table, row, 0); +#endif + mail_autoreceive_setup (); mail_config_write (); } } +#if USE_ETABLE static void -account_able_toggled (GtkCellRendererToggle *renderer, char *arg1, gpointer user_data) +account_cursor_change (ETable *table, int row, gpointer user_data) { MailAccountsTab *prefs = user_data; - GtkTreeSelection *selection; - EAccount *account = NULL; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - - path = gtk_tree_path_new_from_string (arg1); - model = gtk_tree_view_get_model (prefs->table); - selection = gtk_tree_view_get_selection (prefs->table); - - if (gtk_tree_model_get_iter (model, &iter, path)) { - gtk_tree_model_get (model, &iter, 3, &account, -1); - account->enabled = !account->enabled; - gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->enabled, -1); - - if (gtk_tree_selection_iter_is_selected (selection, &iter)) - gtk_button_set_label (prefs->mail_able, account->enabled ? _("Disable") : _("Enable")); - } - - gtk_tree_path_free (path); - if (account) { - /* if the account got disabled, remove it from the - folder-tree, otherwise add it to the folder-tree */ - if (account->source->url) { - if (account->enabled) - mail_load_storage_by_uri (prefs->shell, account->source->url, account->name); - else - mail_remove_storage_by_uri (account->source->url); - } + if (row >= 0) { + const MailConfigAccount *account; - mail_autoreceive_setup (); + account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row); + if (account->source && account->source->enabled) + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->mail_able)->child), _("Disable")); + else + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->mail_able)->child), _("Enable")); - mail_config_write (); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), TRUE); + } else { + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), FALSE); + + gtk_widget_grab_focus (GTK_WIDGET (prefs->mail_add)); } } static void -account_double_click (GtkTreeView *treeview, GtkTreePath *path, - GtkTreeViewColumn *column, MailAccountsTab *prefs) +account_double_click (ETable *table, int row, int col, GdkEvent *event, gpointer user_data) { - account_edit_clicked (NULL, prefs); + account_edit_clicked (NULL, user_data); } - +#else static void -account_cursor_change (GtkTreeSelection *selection, MailAccountsTab *prefs) +account_cursor_change (GtkCList *table, int row, int column, GdkEventButton *event, gpointer user_data) { - EAccount *account = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - int state; - - state = gtk_tree_selection_get_selected (selection, &model, &iter); - if (state) { - gtk_tree_model_get (model, &iter, 3, &account, -1); - if (account->source && account->enabled) - gtk_button_set_label (prefs->mail_able, _("Disable")); + MailAccountsTab *prefs = user_data; + + if (row >= 0) { + const MailConfigAccount *account; + + account = gtk_clist_get_row_data (prefs->table, row); + if (account->source && account->source->enabled) + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->mail_able)->child), _("Disable")); else - gtk_button_set_label (prefs->mail_able, _("Enable")); + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->mail_able)->child), _("Enable")); + + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), TRUE); + + if (event && event->type == GDK_2BUTTON_PRESS) + account_edit_clicked (NULL, user_data); } else { + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), FALSE); + gtk_widget_grab_focus (GTK_WIDGET (prefs->mail_add)); } - - gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), state); - gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), state); - gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), state); - gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), state); } +#endif + static void mail_accounts_load (MailAccountsTab *prefs) { - EAccount *default_account; - EAccountList *accounts; - GtkListStore *model; - GtkTreeIter iter; - char *name, *val; - EIterator *node; + const GSList *node; int row = 0; - model = (GtkListStore *) gtk_tree_view_get_model (prefs->table); - gtk_list_store_clear (model); +#if USE_ETABLE + e_table_memory_freeze (E_TABLE_MEMORY (prefs->model)); - default_account = mail_config_get_default_account (); + e_table_memory_store_clear (E_TABLE_MEMORY_STORE (prefs->model)); +#else + gtk_clist_freeze (prefs->table); - accounts = mail_config_get_accounts (); - node = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (node)) { - EAccount *account; + gtk_clist_clear (prefs->table); +#endif + + node = mail_config_get_accounts (); + while (node) { + const MailConfigAccount *account; CamelURL *url; - account = (EAccount *) e_iterator_get (node); + account = node->data; url = account->source && account->source->url ? camel_url_new (account->source->url, NULL) : NULL; - gtk_list_store_append (model, &iter); - if (account == default_account) { - /* translators: default account indicator */ - name = val = g_strdup_printf ("%s %s", account->name, _("[Default]")); - } else { - val = account->name; - name = NULL; - } +#if USE_ETABLE + e_table_memory_store_insert_list (E_TABLE_MEMORY_STORE (prefs->model), + row, GINT_TO_POINTER (account->source->enabled), + account->name, + url && url->protocol ? url->protocol : U_("None")); - gtk_list_store_set (model, &iter, - 0, account->enabled, - 1, val, - 2, url && url->protocol ? url->protocol : (char *) _("None"), - 3, account, - -1); - g_free (name); + e_table_memory_set_data (E_TABLE_MEMORY (prefs->model), row, (gpointer) account); +#else + { + const MailConfigAccount *default_account; + char *str, *text[3]; + + default_account = mail_config_get_default_account (); + + str = e_utf8_to_gtk_string (GTK_WIDGET (prefs->table), account->name); + + text[0] = NULL; + text[1] = g_strdup_printf ("%s%s%s", str, account == default_account ? " " : "", + account == default_account ? _("[Default]") : ""); + text[2] = url && url->protocol ? url->protocol : (char *) _("None"); + + gtk_clist_insert (prefs->table, row, text); + + g_free (str); + g_free (text[1]); + + if (account->source->enabled) + gtk_clist_set_pixmap (prefs->table, row, 0, + prefs->mark_pixmap, + prefs->mark_bitmap); + + gtk_clist_set_row_data (prefs->table, row, (gpointer) account); + } +#endif if (url) camel_url_free (url); + node = node->next; row++; - - e_iterator_next (node); } - g_object_unref (node); +#if USE_ETABLE + e_table_memory_thaw (E_TABLE_MEMORY (prefs->model)); +#else + gtk_clist_thaw (prefs->table); +#endif } -GtkWidget *mail_accounts_treeview_new (char *widget_name, char *string1, char *string2, - int int1, int int2); +GtkWidget *mail_accounts_etable_new (char *widget_name, char *string1, char *string2, + int int1, int int2); +#if USE_ETABLE GtkWidget * -mail_accounts_treeview_new (char *widget_name, char *string1, char *string2, int int1, int int2) +mail_accounts_etable_new (char *widget_name, char *string1, char *string2, int int1, int int2) { - GtkWidget *table, *scrolled; - GtkTreeSelection *selection; - GtkCellRenderer *renderer; - GtkListStore *model; + ETableModel *model; + ETableExtras *extras; + GdkPixbuf *images[2]; + ETableMemoryStoreColumnInfo columns[] = { + E_TABLE_MEMORY_STORE_INTEGER, + E_TABLE_MEMORY_STORE_STRING, + E_TABLE_MEMORY_STORE_STRING, + E_TABLE_MEMORY_STORE_TERMINATOR, + }; - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN); + extras = e_table_extras_new (); - renderer = gtk_cell_renderer_toggle_new (); - g_object_set ((GObject *) renderer, "activatable", TRUE, NULL); + images[0] = disabled_pixbuf; /* disabled */ + images[1] = enabled_pixbuf; /* enabled */ + e_table_extras_add_cell (extras, "render_able", e_cell_toggle_new (0, 2, images)); - model = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - table = gtk_tree_view_new_with_model ((GtkTreeModel *) model); - gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, _("Enabled"), - renderer, "active", 0, NULL); + model = e_table_memory_store_new (columns); - g_object_set_data ((GObject *) scrolled, "renderer", renderer); + return e_table_scrolled_new_from_spec_file (model, extras, EVOLUTION_ETSPECDIR "/mail-accounts.etspec", NULL); +} +#else +GtkWidget * +mail_accounts_etable_new (char *widget_name, char *string1, char *string2, int int1, int int2) +{ + GtkWidget *table, *scrolled; + char *titles[3]; - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, _("Account name"), - renderer, "text", 1, NULL); - gtk_tree_view_insert_column_with_attributes ((GtkTreeView *)table, -1, _("Protocol"), - renderer, "text", 2, NULL); - selection = gtk_tree_view_get_selection ((GtkTreeView *) table); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - gtk_tree_view_set_headers_visible ((GtkTreeView *) table, TRUE); + scrolled = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - /* FIXME: column auto-resize? */ - /* Is this needed? - gtk_tree_view_column_set_alignment (gtk_tree_view_get_column (prefs->table, 0), 1.0);*/ + titles[0] = _("Enabled"); + titles[1] = _("Account name"); + titles[2] = _("Protocol"); + table = gtk_clist_new_with_titles (3, titles); + gtk_clist_set_selection_mode (GTK_CLIST (table), GTK_SELECTION_SINGLE); + gtk_clist_column_titles_show (GTK_CLIST (table)); gtk_container_add (GTK_CONTAINER (scrolled), table); - g_object_set_data ((GObject *) scrolled, "table", table); + gtk_object_set_data (GTK_OBJECT (scrolled), "table", table); gtk_widget_show (scrolled); gtk_widget_show (table); return scrolled; } +#endif static void mail_accounts_tab_construct (MailAccountsTab *prefs) { GtkWidget *toplevel, *widget; - GtkCellRenderer *renderer; GladeXML *gui; - gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "accounts_tab", NULL); + gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "accounts_tab"); prefs->gui = gui; /* get our toplevel widget */ @@ -527,30 +573,54 @@ mail_accounts_tab_construct (MailAccountsTab *prefs) widget = glade_xml_get_widget (gui, "etableMailAccounts"); - prefs->table = (GtkTreeView *) g_object_get_data ((GObject *) widget, "table"); - g_signal_connect (gtk_tree_view_get_selection (prefs->table), - "changed", G_CALLBACK (account_cursor_change), prefs); - g_signal_connect (prefs->table, "row-activated", G_CALLBACK (account_double_click), prefs); +#if USE_ETABLE + prefs->table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); + prefs->model = prefs->table->model; - renderer = g_object_get_data ((GObject *) widget, "renderer"); - g_signal_connect (renderer, "toggled", G_CALLBACK (account_able_toggled), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->table), "cursor_change", + account_cursor_change, prefs); + + gtk_signal_connect (GTK_OBJECT (prefs->table), "double_click", + account_double_click, prefs); mail_accounts_load (prefs); +#else + prefs->table = GTK_CLIST (gtk_object_get_data (GTK_OBJECT (widget), "table")); + gtk_clist_set_column_justification (prefs->table, 0, GTK_JUSTIFY_RIGHT); + + gtk_signal_connect (GTK_OBJECT (prefs->table), "select-row", + account_cursor_change, prefs); + + mail_accounts_load (prefs); + + { + int col; + + for (col = 0; col < 3; col++) { + gtk_clist_set_column_auto_resize (prefs->table, col, TRUE); + } + } +#endif prefs->mail_add = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountAdd")); - g_signal_connect (prefs->mail_add, "clicked", G_CALLBACK (account_add_clicked), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->mail_add), "clicked", + account_add_clicked, prefs); prefs->mail_edit = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountEdit")); - g_signal_connect (prefs->mail_edit, "clicked", G_CALLBACK (account_edit_clicked), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->mail_edit), "clicked", + account_edit_clicked, prefs); prefs->mail_delete = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountDelete")); - g_signal_connect (prefs->mail_delete, "clicked", G_CALLBACK (account_delete_clicked), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->mail_delete), "clicked", + account_delete_clicked, prefs); prefs->mail_default = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountDefault")); - g_signal_connect (prefs->mail_default, "clicked", G_CALLBACK (account_default_clicked), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->mail_default), "clicked", + account_default_clicked, prefs); prefs->mail_able = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountAble")); - g_signal_connect (prefs->mail_able, "clicked", G_CALLBACK (account_able_clicked), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->mail_able), "clicked", + account_able_clicked, prefs); } @@ -559,7 +629,7 @@ mail_accounts_tab_new (GNOME_Evolution_Shell shell) { MailAccountsTab *new; - new = (MailAccountsTab *) g_object_new (mail_accounts_tab_get_type (), NULL); + new = (MailAccountsTab *) gtk_type_new (mail_accounts_tab_get_type ()); mail_accounts_tab_construct (new); new->shell = shell; diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index d1fbb74957..4850ca79d0 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -29,24 +29,21 @@ #include <config.h> #endif -#include <time.h> #include <errno.h> - -#include <gtkhtml/gtkhtml.h> - -#include <gconf/gconf.h> -#include <gconf/gconf-client.h> - -#include <gtk/gtkmessagedialog.h> - -#include <libgnomeprint/gnome-print-job.h> -#include <libgnomeprintui/gnome-print-dialog.h> - +#include <time.h> +#include <libgnome/gnome-paper.h> +#include <libgnomeui/gnome-stock.h> +#include <libgnome/gnome-paper.h> +#include <libgnomeprint/gnome-print-master.h> +#include <libgnomeprint/gnome-print-master-preview.h> #include <bonobo/bonobo-widget.h> #include <bonobo/bonobo-socket.h> #include <gal/e-table/e-table.h> +#include <gal/widgets/e-gui-utils.h> +#include <gal/widgets/e-unicode.h> #include <e-util/e-dialog-utils.h> #include <filter/filter-editor.h> +#include <gtkhtml/gtkhtml.h> #include "mail.h" #include "message-browser.h" @@ -66,6 +63,7 @@ #include "subscribe-dialog.h" #include "message-tag-editor.h" #include "message-tag-followup.h" +#include "e-messagebox.h" #include "Evolution.h" #include "evolution-storage.h" @@ -77,40 +75,6 @@ #define FB_WINDOW(fb) GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (fb), GTK_TYPE_WINDOW)) -/* default is default gtk response - if again is != NULL, a checkbox "dont show this again" will appear, and the result stored in *again -*/ -static gboolean -e_question (GtkWindow *parent, int def, gboolean *again, const char *fmt, ...) -{ - GtkWidget *mbox, *check = NULL; - va_list ap; - int button; - char *str; - - va_start (ap, fmt); - str = g_strdup_vprintf (fmt, ap); - va_end (ap); - mbox = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, - "%s", str); - g_free (str); - gtk_dialog_set_default_response ((GtkDialog *) mbox, def); - if (again) { - check = gtk_check_button_new_with_label (_("Don't show this message again.")); - gtk_box_pack_start ((GtkBox *)((GtkDialog *) mbox)->vbox, check, TRUE, TRUE, 10); - gtk_widget_show (check); - } - - button = gtk_dialog_run ((GtkDialog *) mbox); - if (again) - *again = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); - gtk_widget_destroy (mbox); - - return button == GTK_RESPONSE_YES; -} - - struct _composer_callback_data { unsigned int ref_count; @@ -168,14 +132,14 @@ ccd_unref (struct _composer_callback_data *ccd) static void -composer_destroy_cb (gpointer user_data, GObject *deadbeef) +composer_destroy_cb (GtkWidget *composer, gpointer user_data) { ccd_unref (user_data); } static void -druid_destroy_cb (gpointer user_data, GObject *deadbeef) +druid_destroyed (void) { gtk_main_quit (); } @@ -184,17 +148,37 @@ static gboolean configure_mail (FolderBrowser *fb) { MailConfigDruid *druid; + GtkWidget *dialog; - if (e_question (FB_WINDOW (fb), GTK_RESPONSE_YES, NULL, - _("You have not configured the mail client.\n" - "You need to do this before you can send,\n" - "receive or compose mail.\n" - "Would you like to configure it now?"))) { - druid = mail_config_druid_new (); - g_object_weak_ref ((GObject *) druid, (GWeakNotify) druid_destroy_cb, NULL); - gtk_widget_show ((GtkWidget *) druid); - gtk_grab_add ((GtkWidget *) druid); + dialog = gnome_message_box_new ( + _("You have not configured the mail client.\n" + "You need to do this before you can send,\n" + "receive or compose mail.\n" + "Would you like to configure it now?"), + GNOME_MESSAGE_BOX_QUESTION, + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, NULL); + + /* + * Focus YES + */ + gnome_dialog_set_default (GNOME_DIALOG (dialog), 0); + gtk_widget_grab_focus (GTK_WIDGET (GNOME_DIALOG (dialog)->buttons->data)); + + e_gnome_dialog_set_parent (GNOME_DIALOG (dialog), FB_WINDOW (fb)); + + switch (gnome_dialog_run_and_close (GNOME_DIALOG (dialog))) { + case 0: + druid = mail_config_druid_new (fb->shell); + gtk_signal_connect (GTK_OBJECT (druid), "destroy", + GTK_SIGNAL_FUNC (druid_destroyed), NULL); + gtk_widget_show (GTK_WIDGET (druid)); + gtk_grab_add (GTK_WIDGET (druid)); gtk_main (); + break; + case 1: + default: + break; } return mail_config_is_configured (); @@ -203,52 +187,69 @@ configure_mail (FolderBrowser *fb) static gboolean check_send_configuration (FolderBrowser *fb) { - EAccount *account; + const MailConfigAccount *account; - if (!mail_config_is_configured ()) { - if (fb == NULL) { - e_notice (NULL, GTK_MESSAGE_WARNING, - _("You need to configure an account\nbefore you can compose mail.")); - return FALSE; - } - - if (!configure_mail (fb)) - return FALSE; - } + /* Check general */ + if (!mail_config_is_configured () && !configure_mail (fb)) + return FALSE; /* Get the default account */ account = mail_config_get_default_account (); /* Check for an identity */ if (!account) { - e_notice (FB_WINDOW (fb), GTK_MESSAGE_WARNING, - _("You need to configure an identity\nbefore you can compose mail.")); + GtkWidget *message; + + message = e_gnome_warning_dialog_parented (_("You need to configure an identity\n" + "before you can compose mail."), + FB_WINDOW (fb)); + + gnome_dialog_set_close (GNOME_DIALOG (message), TRUE); + gtk_widget_show (message); + return FALSE; } /* Check for a transport */ - if (!account->transport->url) { - e_notice (FB_WINDOW (fb), GTK_MESSAGE_WARNING, - _("You need to configure a mail transport\n" - "before you can compose mail.")); + if (!account->transport || !account->transport->url) { + GtkWidget *message; + + message = e_gnome_warning_dialog_parented (_("You need to configure a mail transport\n" + "before you can compose mail."), + GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (fb), + GTK_TYPE_WINDOW))); + + gnome_dialog_set_close (GNOME_DIALOG (message), TRUE); + gtk_widget_show (message); + return FALSE; } return TRUE; } +static void +msgbox_destroyed (GtkWidget *widget, gpointer data) +{ + gboolean *show_again = data; + GtkWidget *checkbox; + + checkbox = e_message_box_get_checkbox (E_MESSAGE_BOX (widget)); + *show_again = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); +} + static gboolean ask_confirm_for_unwanted_html_mail (EMsgComposer *composer, EDestination **recipients) { - gboolean show_again, res; - GConfClient *gconf; + gboolean show_again = TRUE; GString *str; - int i; + GtkWidget *mbox; + int i, button; - gconf = gconf_client_get_default (); - - if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/unwanted_html", NULL)) + if (!mail_config_get_confirm_unwanted_html ()) { + g_message ("doesn't want to see confirm html messages!"); return TRUE; + } /* FIXME: this wording sucks */ str = g_string_new (_("You are sending an HTML-formatted message. Please make sure that\n" @@ -256,51 +257,93 @@ ask_confirm_for_unwanted_html_mail (EMsgComposer *composer, EDestination **recip for (i = 0; recipients[i] != NULL; ++i) { if (!e_destination_get_html_mail_pref (recipients[i])) { const char *name; + char *buf; - name = e_destination_get_textrep (recipients[i], FALSE); + name = e_destination_get_textrep (recipients[i]); + buf = e_utf8_to_locale_string (name); - g_string_append_printf (str, " %s\n", name); + g_string_sprintfa (str, " %s\n", buf); + g_free (buf); } } g_string_append (str, _("Send anyway?")); - res = e_question ((GtkWindow *) composer, GTK_RESPONSE_YES, &show_again, "%s", str->str); + + mbox = e_message_box_new (str->str, + E_MESSAGE_BOX_QUESTION, + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); + g_string_free (str, TRUE); - gconf_client_set_bool (gconf, "/apps/evolution/mail/prompts/unwanted_html", show_again, NULL); + gtk_signal_connect (GTK_OBJECT (mbox), "destroy", + msgbox_destroyed, &show_again); + + button = gnome_dialog_run_and_close (GNOME_DIALOG (mbox)); - return res; + if (!show_again) { + mail_config_set_confirm_unwanted_html (show_again); + g_message ("don't show HTML warning again"); + } + + if (button == 0) + return TRUE; + else + return FALSE; } static gboolean ask_confirm_for_empty_subject (EMsgComposer *composer) { - gboolean show_again, res; - GConfClient *gconf; - - gconf = gconf_client_get_default (); + /* FIXME: EMessageBox should really handle this stuff + automagically. What Miguel thinks would be nice is to pass + in a unique id which could be used as a key in the config + file and the value would be an int. -1 for always show or + the button pressed otherwise. This probably means we'd have + to write e_messagebox_run () */ + gboolean show_again = TRUE; + GtkWidget *mbox; + int button; - if (gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/empty_subject", NULL)) + if (!mail_config_get_prompt_empty_subject ()) return TRUE; - res = e_question ((GtkWindow *) composer, GTK_RESPONSE_YES, &show_again, - _("This message has no subject.\nReally send?")); + mbox = e_message_box_new (_("This message has no subject.\nReally send?"), + E_MESSAGE_BOX_QUESTION, + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); + + gtk_signal_connect (GTK_OBJECT (mbox), "destroy", + msgbox_destroyed, &show_again); - gconf_client_set_bool (gconf, "/apps/evolution/mail/prompts/empty_subject", show_again, NULL); + button = gnome_dialog_run_and_close (GNOME_DIALOG (mbox)); - return res; + mail_config_set_prompt_empty_subject (show_again); + + if (button == 0) + return TRUE; + else + return FALSE; } static gboolean ask_confirm_for_only_bcc (EMsgComposer *composer, gboolean hidden_list_case) { - gboolean show_again, res; + /* FIXME: EMessageBox should really handle this stuff + automagically. What Miguel thinks would be nice is to pass + in a message-id which could be used as a key in the config + file and the value would be an int. -1 for always show or + the button pressed otherwise. This probably means we'd have + to write e_messagebox_run () */ + gboolean show_again = TRUE; + GtkWidget *mbox; + int button; const char *first_text; - GConfClient *gconf; + char *message_text; - gconf = gconf_client_get_default (); - - if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/only_bcc", NULL)) + if (!mail_config_get_prompt_only_bcc ()) return TRUE; /* If the user is mailing a hidden contact list, it is possible for @@ -317,14 +360,29 @@ ask_confirm_for_only_bcc (EMsgComposer *composer, gboolean hidden_list_case) first_text = _("This message contains only Bcc recipients."); } - res = e_question ((GtkWindow *) composer, GTK_RESPONSE_YES, &show_again, - "%s\n%s", first_text, - _("It is possible that the mail server may reveal the recipients " - "by adding an Apparently-To header.\nSend anyway?")); + message_text = g_strdup_printf ("%s\n%s", first_text, + _("It is possible that the mail server may reveal the recipients " + "by adding an Apparently-To header.\nSend anyway?")); + + mbox = e_message_box_new (message_text, + E_MESSAGE_BOX_QUESTION, + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); - gconf_client_set_bool (gconf, "/apps/evolution/mail/prompts/only_bcc", show_again, NULL); + gtk_signal_connect (GTK_OBJECT (mbox), "destroy", + msgbox_destroyed, &show_again); - return res; + button = gnome_dialog_run_and_close (GNOME_DIALOG (mbox)); + + mail_config_set_prompt_only_bcc (show_again); + + g_free (message_text); + + if (button == 0) + return TRUE; + else + return FALSE; } @@ -375,20 +433,23 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag ccd = ccd_new (); /* disconnect the previous signal handlers */ - g_signal_handlers_disconnect_matched(send->composer, G_SIGNAL_MATCH_FUNC, 0, - 0, NULL, composer_send_cb, NULL); - g_signal_handlers_disconnect_matched(send->composer, G_SIGNAL_MATCH_FUNC, 0, - 0, NULL, composer_save_draft_cb, NULL); + gtk_signal_disconnect_by_func (GTK_OBJECT (send->composer), + GTK_SIGNAL_FUNC (composer_send_cb), NULL); + gtk_signal_disconnect_by_func (GTK_OBJECT (send->composer), + GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); /* reconnect to the signals using a non-NULL ccd for the callback data */ - g_signal_connect (send->composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (send->composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) send->composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (send->composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (send->composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (send->composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); } e_msg_composer_set_enable_autosave (send->composer, TRUE); gtk_widget_show (GTK_WIDGET (send->composer)); + gtk_object_unref (GTK_OBJECT (send->composer)); } camel_message_info_free (info); @@ -402,18 +463,14 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag static CamelMimeMessage * composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_object_data) { + const MailConfigAccount *account; CamelMimeMessage *message = NULL; EDestination **recipients, **recipients_bcc; - gboolean send_html, confirm_html; CamelInternetAddress *cia; + char *subject; + int i; int hidden = 0, shown = 0; int num = 0, num_bcc = 0; - const char *subject; - GConfClient *gconf; - EAccount *account; - int i; - - gconf = gconf_client_get_default (); /* We should do all of the validity checks based on the composer, and not on the created message, as extra interaction may occur when we get the message @@ -458,7 +515,6 @@ composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_ } } } - e_destination_freev (recipients_bcc); } @@ -466,8 +522,15 @@ composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_ /* I'm sensing a lack of love, er, I mean recipients. */ if (num == 0 && !post) { - e_notice ((GtkWindow *) composer, GTK_MESSAGE_WARNING, - _("You must specify recipients in order to send this message.")); + GtkWidget *message_box; + + message_box = gnome_message_box_new (_("You must specify recipients in order to " + "send this message."), + GNOME_MESSAGE_BOX_WARNING, + GNOME_STOCK_BUTTON_OK, + NULL); + + gnome_dialog_run_and_close (GNOME_DIALOG (message_box)); goto finished; } @@ -477,17 +540,15 @@ composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_ goto finished; } - send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL); - confirm_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/unwanted_html", NULL); - /* Only show this warning if our default is to send html. If it isn't, we've manually switched into html mode in the composer and (presumably) had a good reason for doing this. */ - if (e_msg_composer_get_send_html (composer) && send_html && confirm_html) { + if (e_msg_composer_get_send_html (composer) && mail_config_get_send_html () + && mail_config_get_confirm_unwanted_html ()) { gboolean html_problem = FALSE; if (recipients) { - for (i = 0; recipients[i] != NULL && !html_problem; i++) { + for (i = 0; recipients[i] != NULL && !html_problem; ++i) { if (!e_destination_get_html_mail_pref (recipients[i])) html_problem = TRUE; } @@ -503,9 +564,12 @@ composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_ /* Check for no subject */ subject = e_msg_composer_get_subject (composer); if (subject == NULL || subject[0] == '\0') { - if (!ask_confirm_for_empty_subject (composer)) + if (!ask_confirm_for_empty_subject (composer)) { + g_free (subject); goto finished; + } } + g_free (subject); /* actually get the message now, this will sign/encrypt etc */ message = e_msg_composer_get_message (composer, save_html_object_data); @@ -543,7 +607,7 @@ got_post_folder (char *uri, CamelFolder *folder, void *data) *fp = folder; if (folder) - camel_object_ref (folder); + camel_object_ref (CAMEL_OBJECT (folder)); } void @@ -594,7 +658,7 @@ composer_send_cb (EMsgComposer *composer, gpointer user_data) ccd_ref (send->ccd); send->send = !post; send->composer = composer; - g_object_ref (composer); + gtk_object_ref (GTK_OBJECT (composer)); gtk_widget_hide (GTK_WIDGET (composer)); e_msg_composer_set_enable_autosave (composer, FALSE); @@ -628,14 +692,18 @@ save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *i ccd = ccd_new (); /* disconnect the previous signal handlers */ - g_signal_handlers_disconnect_by_func (sdi->composer, G_CALLBACK (composer_send_cb), NULL); - g_signal_handlers_disconnect_by_func (sdi->composer, G_CALLBACK (composer_save_draft_cb), NULL); + gtk_signal_disconnect_by_func (GTK_OBJECT (sdi->composer), + GTK_SIGNAL_FUNC (composer_send_cb), NULL); + gtk_signal_disconnect_by_func (GTK_OBJECT (sdi->composer), + GTK_SIGNAL_FUNC (composer_save_draft_cb), NULL); /* reconnect to the signals using a non-NULL ccd for the callback data */ - g_signal_connect (sdi->composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (sdi->composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) sdi->composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (sdi->composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (sdi->composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (sdi->composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); } if (ccd->drafts_folder) { @@ -668,7 +736,7 @@ save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *i gtk_widget_destroy (GTK_WIDGET (sdi->composer)); done: - g_object_unref (sdi->composer); + gtk_object_unref (GTK_OBJECT (sdi->composer)); if (sdi->ccd) ccd_unref (sdi->ccd); g_free (info); @@ -683,7 +751,7 @@ use_default_drafts_cb (int reply, gpointer data) if (reply == 0) { *folder = drafts_folder; - camel_object_ref (drafts_folder); + camel_object_ref (CAMEL_OBJECT (*folder)); } } @@ -694,7 +762,7 @@ save_draft_folder (char *uri, CamelFolder *folder, gpointer data) if (folder) { *save = folder; - camel_object_ref (folder); + camel_object_ref (CAMEL_OBJECT (folder)); } } @@ -703,11 +771,11 @@ composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user_data) { extern char *default_drafts_folder_uri; extern CamelFolder *drafts_folder; - struct _save_draft_info *sdi; - CamelFolder *folder = NULL; CamelMimeMessage *msg; CamelMessageInfo *info; - EAccount *account; + const MailConfigAccount *account; + struct _save_draft_info *sdi; + CamelFolder *folder = NULL; account = e_msg_composer_get_preferred_account (composer); if (account && account->drafts_folder_uri && @@ -718,17 +786,18 @@ composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user_data) mail_msg_wait (id); if (!folder) { - if (!e_question ((GtkWindow *) composer, GTK_RESPONSE_YES, NULL, - _("Unable to open the drafts folder for this account.\n" - "Would you like to use the default drafts folder?"))) - return; + GtkWidget *dialog; - folder = drafts_folder; - camel_object_ref (drafts_folder); + dialog = gnome_ok_cancel_dialog_parented (_("Unable to open the drafts folder for this account.\n" + "Would you like to use the default drafts folder?"), + use_default_drafts_cb, &folder, GTK_WINDOW (composer)); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + if (!folder) + return; } } else { folder = drafts_folder; - camel_object_ref (folder); + camel_object_ref (CAMEL_OBJECT (folder)); } msg = e_msg_composer_get_message_draft (composer); @@ -738,32 +807,31 @@ composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user_data) sdi = g_malloc (sizeof (struct _save_draft_info)); sdi->composer = composer; - g_object_ref (composer); + gtk_object_ref (GTK_OBJECT (composer)); sdi->ccd = user_data; if (sdi->ccd) ccd_ref (sdi->ccd); sdi->quit = quit; mail_append_mail (folder, msg, info, save_draft_done, sdi); - camel_object_unref (folder); - camel_object_unref (msg); + camel_object_unref (CAMEL_OBJECT (folder)); + camel_object_unref (CAMEL_OBJECT (msg)); } static GtkWidget * -create_msg_composer (EAccount *account, gboolean post, const char *url) +create_msg_composer (const MailConfigAccount *account, gboolean post, const char *url) { EMsgComposer *composer; - GConfClient *gconf; gboolean send_html; /* Make sure that we've actually been passed in an account. If one has * not been passed in, grab the default account. */ - if (account == NULL) + if (account == NULL) { account = mail_config_get_default_account (); + } - gconf = gconf_client_get_default (); - send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL); + send_html = mail_config_get_send_html (); if (post) composer = e_msg_composer_new_post (); @@ -785,10 +853,10 @@ create_msg_composer (EAccount *account, gboolean post, const char *url) void compose_msg (GtkWidget *widget, gpointer user_data) { + const MailConfigAccount *account; FolderBrowser *fb = FOLDER_BROWSER (user_data); struct _composer_callback_data *ccd; GtkWidget *composer; - EAccount *account; if (FOLDER_BROWSER_IS_DESTROYED (fb) || !check_send_configuration (fb)) return; @@ -802,10 +870,12 @@ compose_msg (GtkWidget *widget, gpointer user_data) ccd = ccd_new (); - g_signal_connect (composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); gtk_widget_show (composer); } @@ -816,7 +886,7 @@ send_to_url (const char *url, const char *parent_uri) { struct _composer_callback_data *ccd; GtkWidget *composer; - EAccount *account = NULL; + MailConfigAccount *account = NULL; /* FIXME: no way to get folder browser? Not without * big pain in the ass, as far as I can tell */ @@ -833,20 +903,22 @@ send_to_url (const char *url, const char *parent_uri) ccd = ccd_new (); - g_signal_connect (composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); gtk_widget_show (composer); } static GList * list_add_addresses (GList *list, const CamelInternetAddress *cia, GHashTable *account_hash, - GHashTable *rcpt_hash, EAccount **me) + GHashTable *rcpt_hash, const MailConfigAccount **me) { + const MailConfigAccount *account; const char *name, *addr; - EAccount *account; int i; for (i = 0; camel_internet_address_get (cia, i, &name, &addr); i++) { @@ -872,10 +944,10 @@ list_add_addresses (GList *list, const CamelInternetAddress *cia, GHashTable *ac return list; } -static EAccount * +static const MailConfigAccount * guess_me (const CamelInternetAddress *to, const CamelInternetAddress *cc, GHashTable *account_hash) { - EAccount *account = NULL; + const MailConfigAccount *account = NULL; const char *addr; int i; @@ -904,12 +976,12 @@ guess_me (const CamelInternetAddress *to, const CamelInternetAddress *cc, GHashT return account; } -static EAccount * -guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddress *cc, EAccountList *accounts) +static const MailConfigAccount * +guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddress *cc, const GSList *accounts) { - EAccount *account, *def; + const MailConfigAccount *account, *def; GHashTable *account_hash; - EIterator *iter; + const GSList *l; account_hash = g_hash_table_new (g_strcase_hash, g_strcase_equal); @@ -919,12 +991,12 @@ guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddre g_hash_table_insert (account_hash, (char *) def->id->address, (void *) def); } - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); + l = accounts; + while (l) { + account = l->data; if (account->id->address) { - EAccount *acnt; + const MailConfigAccount *acnt; /* Accounts with identical email addresses that are enabled * take precedence over the accounts that aren't. If all @@ -933,7 +1005,7 @@ guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddre * account always takes precedence no matter what. */ acnt = g_hash_table_lookup (account_hash, account->id->address); - if (acnt && acnt != def && !acnt->enabled && account->enabled) { + if (acnt && acnt != def && !acnt->source->enabled && account->source->enabled) { g_hash_table_remove (account_hash, acnt->id->address); acnt = NULL; } @@ -942,11 +1014,9 @@ guess_me_from_accounts (const CamelInternetAddress *to, const CamelInternetAddre g_hash_table_insert (account_hash, (char *) account->id->address, (void *) account); } - e_iterator_next (iter); + l = l->next; } - g_object_unref (iter); - account = guess_me (to, cc, account_hash); g_hash_table_destroy (account_hash); @@ -981,22 +1051,18 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char const CamelInternetAddress *reply_to, *sender, *to_addrs, *cc_addrs; const char *name = NULL, *address = NULL, *source = NULL; const char *message_id, *references, *mlist = NULL; - char *text = NULL, *subject, format[256]; - EAccount *def, *account, *me = NULL; - EAccountList *accounts = NULL; + char *text = NULL, *subject, date_str[100], *format; + const MailConfigAccount *def, *account, *me = NULL; + const GSList *l, *accounts = NULL; GHashTable *account_hash = NULL; CamelMessageInfo *info = NULL; GList *to = NULL, *cc = NULL; EDestination **tov, **ccv; EMsgComposer *composer; CamelMimePart *part; - GConfClient *gconf; - EIterator *iter; time_t date; char *url; - gconf = gconf_client_get_default (); - if (mode == REPLY_POST) { composer = e_msg_composer_new_post (); if (composer != NULL) { @@ -1022,12 +1088,12 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char g_hash_table_insert (account_hash, (char *) def->id->address, (void *) def); } - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); + l = accounts; + while (l) { + account = l->data; if (account->id->address) { - EAccount *acnt; + const MailConfigAccount *acnt; /* Accounts with identical email addresses that are enabled * take precedence over the accounts that aren't. If all @@ -1036,7 +1102,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char * account always takes precedence no matter what. */ acnt = g_hash_table_lookup (account_hash, account->id->address); - if (acnt && acnt != def && !acnt->enabled && account->enabled) { + if (acnt && acnt != def && !acnt->source->enabled && account->source->enabled) { g_hash_table_remove (account_hash, acnt->id->address); acnt = NULL; } @@ -1045,11 +1111,9 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char g_hash_table_insert (account_hash, (char *) account->id->address, (void *) account); } - e_iterator_next (iter); + l = l->next; } - g_object_unref (iter); - to_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); cc_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); mail_ignore_address (composer, to_addrs); @@ -1076,7 +1140,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char max = camel_address_length (CAMEL_ADDRESS (to_addrs)); for (i = 0; i < max; i++) { camel_internet_address_get (to_addrs, i, &name, &address); - if (!strcasecmp (address, mlist)) + if (!g_strcasecmp (address, mlist)) break; } @@ -1084,7 +1148,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char max = camel_address_length (CAMEL_ADDRESS (cc_addrs)); for (i = 0; i < max; i++) { camel_internet_address_get (cc_addrs, i, &name, &address); - if (!strcasecmp (address, mlist)) + if (!g_strcasecmp (address, mlist)) break; } } @@ -1167,7 +1231,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char } /* set body text here as we want all ignored words to take effect */ - switch (gconf_client_get_int (gconf, "/apps/evolution/mail/format/reply_style", NULL)) { + switch (mail_config_get_default_reply_style ()) { case MAIL_CONFIG_REPLY_DO_NOT_QUOTE: /* do nothing */ break; @@ -1175,7 +1239,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char /* attach the original message as an attachment */ part = mail_tool_make_message_attachment (message); e_msg_composer_attach (composer, part); - camel_object_unref (part); + camel_object_unref (CAMEL_OBJECT (part)); break; case MAIL_CONFIG_REPLY_QUOTED: default: @@ -1188,9 +1252,12 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char } date = camel_mime_message_get_date (message, NULL); - strftime (format, sizeof (format), _("On %a, %Y-%m-%d at %H:%M, %%s wrote:"), localtime (&date)); + strftime (date_str, sizeof (date_str), _("On %a, %Y-%m-%d at %H:%M, %%s wrote:"), + localtime (&date)); + format = e_utf8_from_locale_string (date_str); text = mail_tool_quote_message (message, format, name && *name ? name : address); mail_ignore (composer, name, address); + g_free (format); if (text) { e_msg_composer_set_body_text (composer, text); g_free (text); @@ -1203,7 +1270,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char if (!subject) subject = g_strdup (""); else { - if (!strncasecmp (subject, "Re: ", 4)) + if (!g_strncasecmp (subject, "Re: ", 4)) subject = g_strndup (subject, MAX_SUBJECT_LEN); else { if (strlen (subject) < MAX_SUBJECT_LEN) { @@ -1298,10 +1365,12 @@ mail_reply (CamelFolder *folder, CamelMimeMessage *msg, const char *uid, int mod ccd->flags |= CAMEL_MESSAGE_ANSWERED_ALL; ccd->set = ccd->flags; - g_signal_connect (composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); gtk_widget_show (GTK_WIDGET (composer)); e_msg_composer_unset_changed (composer); @@ -1352,13 +1421,13 @@ enumerate_msg (MessageList *ml, const char *uid, gpointer data) static EMsgComposer * forward_get_composer (CamelMimeMessage *message, const char *subject) { + const MailConfigAccount *account = NULL; struct _composer_callback_data *ccd; - EAccount *account = NULL; EMsgComposer *composer; if (message) { const CamelInternetAddress *to_addrs, *cc_addrs; - EAccountList *accounts; + const GSList *accounts = NULL; accounts = mail_config_get_accounts (); to_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); @@ -1381,10 +1450,12 @@ forward_get_composer (CamelMimeMessage *message, const char *subject) if (composer) { ccd = ccd_new (); - g_signal_connect (composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); e_msg_composer_set_headers (composer, account->name, NULL, NULL, NULL, subject); } else { @@ -1495,11 +1566,7 @@ forward_attached (GtkWidget *widget, gpointer user_data) void forward (GtkWidget *widget, gpointer user_data) { - MailConfigForwardStyle style; - GConfClient *gconf; - - gconf = gconf_client_get_default (); - style = gconf_client_get_int (gconf, "/apps/evolution/mail/format/forward_style", NULL); + MailConfigForwardStyle style = mail_config_get_default_forward_style (); if (style == MAIL_CONFIG_FORWARD_ATTACHED) forward_attached (widget, user_data); @@ -1513,7 +1580,7 @@ post_to_url (const char *url) { struct _composer_callback_data *ccd; GtkWidget *composer; - EAccount *account = NULL; + MailConfigAccount *account = NULL; /* FIXME: no way to get folder browser? Not without * big pain in the ass, as far as I can tell */ @@ -1531,10 +1598,12 @@ post_to_url (const char *url) ccd = ccd_new (); - g_signal_connect (composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); gtk_widget_show (composer); } @@ -1568,10 +1637,10 @@ post_reply (GtkWidget *widget, gpointer user_data) static EMsgComposer * redirect_get_composer (CamelMimeMessage *message) { + const MailConfigAccount *account = NULL; const CamelInternetAddress *to_addrs, *cc_addrs; + const GSList *accounts = NULL; struct _composer_callback_data *ccd; - EAccountList *accounts = NULL; - EAccount *account = NULL; EMsgComposer *composer; g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); @@ -1602,10 +1671,12 @@ redirect_get_composer (CamelMimeMessage *message) if (composer) { ccd = ccd_new (); - g_signal_connect (composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); } else { g_warning ("Could not create composer"); } @@ -1654,20 +1725,16 @@ static void transfer_msg_done (gboolean ok, void *data) { FolderBrowser *fb = data; - gboolean hide_deleted; - GConfClient *gconf; int row; if (ok && !FOLDER_BROWSER_IS_DESTROYED (fb)) { - 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 (fb->message_list->tree, e_tree_get_cursor (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 (fb->message_list->tree)) && hide_deleted) + if ((row + 1 == e_tree_row_count (fb->message_list->tree)) + && mail_config_get_hide_deleted ()) message_list_select (fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS, 0, CAMEL_MESSAGE_DELETED, FALSE); else @@ -1675,7 +1742,7 @@ transfer_msg_done (gboolean ok, void *data) 0, 0, FALSE); } - g_object_unref (fb); + gtk_object_unref (GTK_OBJECT (fb)); } static void @@ -1715,7 +1782,7 @@ transfer_msg (FolderBrowser *fb, gboolean delete_from_source) message_list_foreach (fb->message_list, enumerate_msg, uids); if (delete_from_source) { - g_object_ref (fb); + gtk_object_ref (GTK_OBJECT (fb)); mail_transfer_messages (fb->folder, uids, delete_from_source, folder->physicalUri, 0, transfer_msg_done, fb); @@ -1723,7 +1790,6 @@ transfer_msg (FolderBrowser *fb, gboolean delete_from_source) mail_transfer_messages (fb->folder, uids, delete_from_source, folder->physicalUri, 0, NULL, NULL); } - CORBA_free (folder); } @@ -1757,7 +1823,7 @@ find_socket (GtkContainer *container) { GList *children, *tmp; - children = gtk_container_get_children (container); + children = gtk_container_children (container); while (children) { if (BONOBO_IS_SOCKET (children->data)) return children->data; @@ -1770,14 +1836,13 @@ find_socket (GtkContainer *container) g_list_free_1 (children); children = tmp; } - - return NULL; + return NULL; } static void popup_listener_cb (BonoboListener *listener, - const char *event_name, - const CORBA_any *any, + char *event_name, + CORBA_any *any, CORBA_Environment *ev, gpointer user_data) { @@ -1801,17 +1866,18 @@ addrbook_sender (GtkWidget *widget, gpointer user_data) GtkWidget *socket; GPtrArray *uids; int i; - + if (FOLDER_BROWSER_IS_DESTROYED (fb)) return; - - uids = g_ptr_array_new (); - message_list_foreach (fb->message_list, enumerate_msg, uids); + + uids = g_ptr_array_new(); + message_list_foreach(fb->message_list, enumerate_msg, uids); if (uids->len != 1) goto done; - - info = camel_folder_get_message_info (fb->folder, uids->pdata[0]); - if (info == NULL || (addr_str = camel_message_info_from (info)) == NULL) + + info = camel_folder_get_message_info(fb->folder, uids->pdata[0]); + if (info == NULL + || (addr_str = camel_message_info_from(info)) == NULL) goto done; win = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -1820,23 +1886,25 @@ addrbook_sender (GtkWidget *widget, gpointer user_data) control = bonobo_widget_new_control ("OAFIID:GNOME_Evolution_Addressbook_AddressPopup", CORBA_OBJECT_NIL); bonobo_widget_set_property (BONOBO_WIDGET (control), - "email", TC_CORBA_string, addr_str, + "email", addr_str, NULL); bonobo_event_source_client_add_listener (bonobo_widget_get_objref (BONOBO_WIDGET (control)), popup_listener_cb, NULL, NULL, win); socket = find_socket (GTK_CONTAINER (control)); - - g_object_weak_ref ((GObject *) socket, (GWeakNotify) gtk_widget_destroy, win); + gtk_signal_connect_object (GTK_OBJECT (socket), + "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (win)); gtk_container_add (GTK_CONTAINER (win), control); gtk_widget_show_all (win); done: - for (i = 0; i < uids->len; i++) - g_free (uids->pdata[i]); - g_ptr_array_free (uids, TRUE); + for (i=0; i < uids->len; i++) + g_free(uids->pdata[i]); + g_ptr_array_free(uids, TRUE); } void @@ -1984,7 +2052,6 @@ flag_messages (FolderBrowser *fb, guint32 mask, guint32 set) camel_folder_set_message_flags (fb->folder, uids->pdata[i], mask, set); g_free (uids->pdata[i]); } - camel_folder_thaw (fb->folder); g_ptr_array_free (uids, TRUE); @@ -2009,13 +2076,13 @@ toggle_flags (FolderBrowser *fb, guint32 mask) guint32 flags; flags = ~(camel_folder_get_message_flags (fb->folder, uids->pdata[i])); - + /* if we're flagging a message important, always undelete it too */ if (mask & flags & CAMEL_MESSAGE_FLAGGED) { flags &= ~CAMEL_MESSAGE_DELETED; mask |= CAMEL_MESSAGE_DELETED; } - + /* if we're flagging a message deleted, mark it seen. If * we're undeleting it, we also want it to be seen, so always do this. */ @@ -2023,9 +2090,9 @@ toggle_flags (FolderBrowser *fb, guint32 mask) flags |= CAMEL_MESSAGE_SEEN; mask |= CAMEL_MESSAGE_SEEN; } - + camel_folder_set_message_flags (fb->folder, uids->pdata[i], mask, flags); - + g_free (uids->pdata[i]); } camel_folder_thaw (fb->folder); @@ -2051,7 +2118,7 @@ mark_as_unseen (BonoboUIComponent *uih, void *user_data, const char *path) /* Remove the automatic mark-as-read timer first */ if (fb->seen_id) { - g_source_remove (fb->seen_id); + gtk_timeout_remove (fb->seen_id); fb->seen_id = 0; } @@ -2102,33 +2169,51 @@ struct _tag_editor_data { }; static void -tag_editor_response(GtkWidget *gd, int button, struct _tag_editor_data *data) +tag_editor_ok (GtkWidget *button, gpointer user_data) { + struct _tag_editor_data *data = user_data; CamelFolder *folder; CamelTag *tags, *t; GPtrArray *uids; int i; - - /*if (FOLDER_BROWSER_IS_DESTROYED (data->fb)) - goto done;*/ - - if (button == GTK_RESPONSE_OK - && (tags = message_tag_editor_get_tag_list (data->editor))) { - folder = data->fb->folder; - uids = data->uids; - camel_folder_freeze (folder); - for (i = 0; i < uids->len; i++) { - for (t = tags; t; t = t->next) - camel_folder_set_message_user_tag (folder, uids->pdata[i], t->name, t->value); - } - camel_folder_thaw (folder); - camel_tag_list_free (&tags); + if (FOLDER_BROWSER_IS_DESTROYED (data->fb)) + goto done; + + tags = message_tag_editor_get_tag_list (data->editor); + if (tags == NULL) + goto done; + + folder = data->fb->folder; + uids = data->uids; + + camel_folder_freeze (folder); + for (i = 0; i < uids->len; i++) { + for (t = tags; t; t = t->next) + camel_folder_set_message_user_tag (folder, uids->pdata[i], t->name, t->value); } + camel_folder_thaw (folder); + + camel_tag_list_free (&tags); + + done: + gtk_widget_destroy (GTK_WIDGET (data->editor)); +} - gtk_widget_destroy(gd); +static void +tag_editor_cancel (GtkWidget *button, gpointer user_data) +{ + struct _tag_editor_data *data = user_data; + + gtk_widget_destroy (GTK_WIDGET (data->editor)); +} - g_object_unref (data->fb); +static void +tag_editor_destroy (GnomeDialog *dialog, gpointer user_data) +{ + struct _tag_editor_data *data = user_data; + + gtk_object_unref (GTK_OBJECT (data->fb)); g_ptr_array_free (data->uids, TRUE); g_free (data); } @@ -2164,8 +2249,10 @@ flag_for_followup (BonoboUIComponent *uih, void *user_data, const char *path) camel_message_info_from (info), camel_message_info_subject (info)); } - - g_signal_connect(editor, "response", G_CALLBACK(tag_editor_response), data); + + gnome_dialog_button_connect (GNOME_DIALOG (editor), 0, tag_editor_ok, data); + gnome_dialog_button_connect (GNOME_DIALOG (editor), 1, tag_editor_cancel, data); + gnome_dialog_set_close (GNOME_DIALOG (editor), TRUE); /* special-case... */ if (uids->len == 1) { @@ -2179,6 +2266,9 @@ flag_for_followup (BonoboUIComponent *uih, void *user_data, const char *path) } } + gtk_signal_connect (GTK_OBJECT (editor), "destroy", + tag_editor_destroy, data); + gtk_widget_show (editor); } @@ -2299,10 +2389,12 @@ do_edit_messages (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, voi ccd->drafts_uid = g_strdup (uids->pdata[i]); } - g_signal_connect (composer, "send", G_CALLBACK (composer_send_cb), ccd); - g_signal_connect (composer, "save-draft", G_CALLBACK (composer_save_draft_cb), ccd); - - g_object_weak_ref ((GObject *) composer, (GWeakNotify) composer_destroy_cb, ccd); + gtk_signal_connect (GTK_OBJECT (composer), "send", + GTK_SIGNAL_FUNC (composer_send_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "save-draft", + GTK_SIGNAL_FUNC (composer_save_draft_cb), ccd); + gtk_signal_connect (GTK_OBJECT (composer), "destroy", + GTK_SIGNAL_FUNC (composer_destroy_cb), ccd); gtk_widget_show (GTK_WIDGET (composer)); } @@ -2313,21 +2405,19 @@ static gboolean are_you_sure (const char *msg, GPtrArray *uids, FolderBrowser *fb) { GtkWidget *dialog; + char *buf; int button, i; - - dialog = gtk_message_dialog_new (FB_WINDOW (fb), GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, - msg, uids->len); - button = gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); - if (button != GTK_RESPONSE_OK) { + buf = g_strdup_printf (msg, uids->len); + dialog = e_gnome_ok_cancel_dialog_parented (buf, NULL, NULL, FB_WINDOW (fb)); + button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + if (button != 0) { for (i = 0; i < uids->len; i++) g_free (uids->pdata[i]); g_ptr_array_free (uids, TRUE); } - return button == GTK_RESPONSE_OK; + return button == 0; } static void @@ -2341,8 +2431,16 @@ edit_msg_internal (FolderBrowser *fb) uids = g_ptr_array_new (); message_list_foreach (fb->message_list, enumerate_msg, uids); - if (uids->len > 10 && !are_you_sure (_("Are you sure you want to edit all %d messages?"), uids, fb)) + if (uids->len > 10 && !are_you_sure (_("Are you sure you want to edit all %d messages?"), uids, fb)) { + int i; + + for (i = 0; i < uids->len; i++) + g_free (uids->pdata[i]); + + g_ptr_array_free (uids, TRUE); + return; + } mail_get_messages (fb->folder, uids, do_edit_messages, fb); } @@ -2356,8 +2454,13 @@ edit_msg (GtkWidget *widget, gpointer user_data) return; if (!folder_browser_is_drafts (fb)) { - e_notice(FB_WINDOW(fb), GTK_MESSAGE_ERROR, - _("You may only edit messages saved\nin the Drafts folder.")); + GtkWidget *dialog; + + dialog = gnome_warning_dialog_parented (_("You may only edit messages saved\n" + "in the Drafts folder."), + FB_WINDOW (fb)); + gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE); + gtk_widget_show (dialog); return; } @@ -2379,6 +2482,7 @@ do_resend_messages (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, v } + void resend_msg (GtkWidget *widget, gpointer user_data) { @@ -2389,8 +2493,13 @@ resend_msg (GtkWidget *widget, gpointer user_data) return; if (!folder_browser_is_sent (fb)) { - e_notice (FB_WINDOW (fb), GTK_MESSAGE_ERROR, - _("You may only resend messages\nin the Sent folder.")); + GtkWidget *dialog; + + dialog = gnome_warning_dialog_parented (_("You may only resend messages\n" + "in the Sent folder."), + FB_WINDOW (fb)); + gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE); + gtk_widget_show (dialog); return; } @@ -2400,13 +2509,20 @@ resend_msg (GtkWidget *widget, gpointer user_data) uids = g_ptr_array_new (); message_list_foreach (fb->message_list, enumerate_msg, uids); - if (uids->len > 10 && !are_you_sure (_("Are you sure you want to resend all %d messages?"), uids, fb)) + if (uids->len > 10 && !are_you_sure (_("Are you sure you want to resend all %d messages?"), uids, fb)) { + int i; + + for (i = 0; i < uids->len; i++) + g_free (uids->pdata[i]); + + g_ptr_array_free (uids, TRUE); + return; + } mail_get_messages (fb->folder, uids, do_resend_messages, fb); } - void search_msg (GtkWidget *widget, gpointer user_data) { @@ -2419,10 +2535,8 @@ search_msg (GtkWidget *widget, gpointer user_data) if (fb->mail_display->current_message == NULL) { GtkWidget *dialog; - dialog = gtk_message_dialog_new (FB_WINDOW(fb), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, - _("No Message Selected")); - g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); + dialog = gnome_warning_dialog_parented (_("No Message Selected"), FB_WINDOW (fb)); + gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE); gtk_widget_show (dialog); return; } @@ -2448,8 +2562,8 @@ save_msg_ok (GtkWidget *widget, gpointer user_data) CamelFolder *folder; GPtrArray *uids; const char *path; + int fd, ret = 0; struct stat st; - gboolean ret = TRUE; path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (user_data)); if (path[0] == '\0') @@ -2458,21 +2572,33 @@ save_msg_ok (GtkWidget *widget, gpointer user_data) /* make sure we can actually save to it... */ if (stat (path, &st) != -1 && !S_ISREG (st.st_mode)) return; - - if (access(path, F_OK) == 0) { - if (access(path, W_OK) != 0) { - e_notice(GTK_WINDOW(user_data), GTK_MESSAGE_ERROR, - _("Cannot save to `%s'\n %s"), path, g_strerror(errno)); - return; - } - - ret = e_question(GTK_WINDOW(user_data), GTK_RESPONSE_NO, NULL, - _("`%s' already exists.\nOverwrite it?"), path); + + fd = open (path, O_RDONLY); + if (fd != -1) { + GtkWidget *dialog; + GtkWidget *text; + + close (fd); + + dialog = gnome_dialog_new (_("Overwrite file?"), + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); + + e_gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (user_data)); + + text = gtk_label_new (_("A file by that name already exists.\nOverwrite it?")); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), text, TRUE, TRUE, 4); + gtk_window_set_policy (GTK_WINDOW (dialog), FALSE, TRUE, FALSE); + gtk_widget_show (text); + + ret = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); } - if (ret) { - folder = g_object_get_data ((GObject *) user_data, "folder"); - uids = g_object_steal_data (G_OBJECT (user_data), "uids"); + if (ret == 0) { + folder = gtk_object_get_data (GTK_OBJECT (user_data), "folder"); + uids = gtk_object_get_data (GTK_OBJECT (user_data), "uids"); + gtk_object_remove_no_notify (GTK_OBJECT (user_data), "uids"); mail_save_messages (folder, uids, path, NULL, NULL); gtk_widget_destroy (GTK_WIDGET (user_data)); } @@ -2516,13 +2642,13 @@ save_msg (GtkWidget *widget, gpointer user_data) path = g_strdup_printf ("%s/", g_get_home_dir ()); gtk_file_selection_set_filename (filesel, path); g_free (path); - - g_object_set_data_full ((GObject *) filesel, "uids", uids, save_msg_destroy); - g_object_set_data ((GObject *) filesel, "folder", fb->folder); - - g_signal_connect (filesel->ok_button, "clicked", G_CALLBACK (save_msg_ok), filesel); - g_signal_connect_swapped (filesel->cancel_button, "clicked", - G_CALLBACK (gtk_widget_destroy), filesel); + gtk_object_set_data_full (GTK_OBJECT (filesel), "uids", uids, save_msg_destroy); + gtk_object_set_data (GTK_OBJECT (filesel), "folder", fb->folder); + gtk_signal_connect (GTK_OBJECT (filesel->ok_button), + "clicked", GTK_SIGNAL_FUNC (save_msg_ok), filesel); + gtk_signal_connect_object (GTK_OBJECT (filesel->cancel_button), + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (filesel)); gtk_widget_show (GTK_WIDGET (filesel)); } @@ -2537,15 +2663,11 @@ void delete_msg (GtkWidget *button, gpointer user_data) { FolderBrowser *fb = FOLDER_BROWSER (user_data); - gboolean hide_deleted; - GConfClient *gconf; int deleted, row; if (FOLDER_BROWSER_IS_DESTROYED (fb)) return; - gconf = gconf_client_get_default (); - deleted = flag_messages (fb, CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN); @@ -2554,11 +2676,10 @@ delete_msg (GtkWidget *button, gpointer user_data) row = e_tree_row_of_node (fb->message_list->tree, e_tree_get_cursor (fb->message_list->tree)); - hide_deleted = !gconf_client_get_bool (gconf, "/apps/evolution/mail/display/show_deleted", NULL); - /* If this is the last message and deleted messages are hidden, select the previous */ - if ((row + 1 == e_tree_row_count (fb->message_list->tree)) && hide_deleted) + if ((row+1 == e_tree_row_count (fb->message_list->tree)) + && mail_config_get_hide_deleted ()) message_list_select (fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS, 0, CAMEL_MESSAGE_DELETED, FALSE); else @@ -2573,6 +2694,153 @@ undelete_msg (GtkWidget *button, gpointer user_data) flag_messages (FOLDER_BROWSER (user_data), CAMEL_MESSAGE_DELETED, 0); } + +#if 0 +static gboolean +confirm_goto_next_folder (FolderBrowser *fb) +{ + GtkWidget *dialog, *label, *checkbox; + int button; + + if (!mail_config_get_confirm_goto_next_folder ()) + return mail_config_get_goto_next_folder (); + + dialog = gnome_dialog_new (_("Go to next folder with unread messages?"), + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); + + e_gnome_dialog_set_parent (GNOME_DIALOG (dialog), FB_WINDOW (fb)); + + label = gtk_label_new (_("There are no more new messages in this folder.\n" + "Would you like to go to the next folder?")); + + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4); + + checkbox = gtk_check_button_new_with_label (_("Do not ask me again.")); + gtk_object_ref (GTK_OBJECT (checkbox)); + gtk_widget_show (checkbox); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), checkbox, TRUE, TRUE, 4); + + button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox))) + mail_config_set_confirm_goto_next_folder (FALSE); + + gtk_object_unref (GTK_OBJECT (checkbox)); + + if (button == 0) { + mail_config_set_goto_next_folder (TRUE); + return TRUE; + } else { + mail_config_set_goto_next_folder (FALSE); + return FALSE; + } +} + +static CamelFolderInfo * +find_current_folder (CamelFolderInfo *root, const char *current_uri) +{ + CamelFolderInfo *node, *current = NULL; + + node = root; + while (node) { + if (!strcmp (current_uri, node->url)) { + current = node; + break; + } + + current = find_current_folder (node->child, current_uri); + if (current) + break; + + node = node->sibling; + } + + return current; +} + +static CamelFolderInfo * +find_next_folder_r (CamelFolderInfo *node) +{ + CamelFolderInfo *next; + + while (node) { + if (node->unread_message_count > 0) + return node; + + next = find_next_folder_r (node->child); + if (next) + return next; + + node = node->sibling; + } + + return NULL; +} + +static CamelFolderInfo * +find_next_folder (CamelFolderInfo *current) +{ + CamelFolderInfo *next; + + /* first search subfolders... */ + next = find_next_folder_r (current->child); + if (next) + return next; + + /* now search siblings... */ + next = find_next_folder_r (current->sibling); + if (next) + return next; + + /* now go up one level (if we can) and search... */ + if (current->parent && current->parent->sibling) { + return find_next_folder_r (current->parent->sibling); + } else { + return NULL; + } +} + +static void +do_evil_kludgy_goto_next_folder_hack (FolderBrowser *fb) +{ + CamelFolderInfo *root, *current, *node; + CORBA_Environment ev; + CamelStore *store; + + store = camel_folder_get_parent_store (fb->folder); + + /* FIXME: loop over all available mail stores? */ + + root = camel_store_get_folder_info (store, "", CAMEL_STORE_FOLDER_INFO_RECURSIVE | + CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, NULL); + + if (!root) + return; + + current = find_current_folder (root, fb->uri); + g_assert (current != NULL); + + node = find_next_folder (current); + if (node) { + g_warning ("doin' my thang..."); + CORBA_exception_init (&ev); + GNOME_Evolution_ShellView_changeCurrentView (fb->shell_view, "evolution:/local/Inbox", &ev); + if (ev._major != CORBA_NO_EXCEPTION) + g_warning ("got an exception"); + CORBA_exception_free (&ev); + } else { + g_warning ("can't find a folder with unread mail?"); + } + + camel_store_free_folder_info (store, root); +} +#endif + void next_msg (GtkWidget *button, gpointer user_data) { @@ -2592,7 +2860,12 @@ next_unread_msg (GtkWidget *button, gpointer user_data) if (FOLDER_BROWSER_IS_DESTROYED (fb)) return; - message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT, 0, CAMEL_MESSAGE_SEEN, TRUE); + if (!message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT, 0, CAMEL_MESSAGE_SEEN, TRUE)) { +#if 0 + if (confirm_goto_next_folder (fb)) + do_evil_kludgy_goto_next_folder_hack (fb); +#endif + } } void @@ -2664,33 +2937,50 @@ expunged_folder (CamelFolder *f, void *data) fb->expunging = NULL; gtk_widget_set_sensitive (GTK_WIDGET (fb->message_list), TRUE); - - /* FIXME: we should check that the focus hasn't changed in the - * mean time, otherwise we steal the focus unecessarily. - * Check :get_toplevel()->focus_widget? */ - if (fb->expunge_mlfocussed) - gtk_widget_grab_focus((GtkWidget *)fb->message_list); } static gboolean confirm_expunge (FolderBrowser *fb) { - gboolean res, show_again; - GConfClient *gconf; - - gconf = gconf_client_get_default (); + GtkWidget *dialog, *label, *checkbox; + int button; - if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/prompts/expunge", NULL)) + if (!mail_config_get_confirm_expunge ()) return TRUE; - res = e_question (FB_WINDOW (fb), GTK_RESPONSE_NO, &show_again, - _("This operation will permanently erase all messages marked as\n" - "deleted. If you continue, you will not be able to recover these messages.\n" - "\nReally erase these messages?")); + dialog = gnome_dialog_new (_("Warning"), + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); + + e_gnome_dialog_set_parent (GNOME_DIALOG (dialog), FB_WINDOW (fb)); + + label = gtk_label_new (_("This operation will permanently erase all messages marked as deleted. If you continue, you will not be able to recover these messages.\n\nReally erase these messages?")); + + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4); - gconf_client_set_bool (gconf, "/apps/evolution/mail/prompts/expunge", show_again, NULL); + checkbox = gtk_check_button_new_with_label (_("Do not ask me again.")); + gtk_object_ref (GTK_OBJECT (checkbox)); + gtk_widget_show (checkbox); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), checkbox, TRUE, TRUE, 4); - return res; + /* Set the 'No' button as the default */ + gnome_dialog_set_default (GNOME_DIALOG (dialog), 1); + + button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + + if (button == 0 && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox))) + mail_config_set_confirm_expunge (FALSE); + + gtk_object_unref (GTK_OBJECT (checkbox)); + + if (button == 0) + return TRUE; + else + return FALSE; } void @@ -2703,17 +2993,8 @@ expunge_folder (BonoboUIComponent *uih, void *user_data, const char *path) if (fb->folder && (fb->expunging == NULL || fb->folder != fb->expunging) && confirm_expunge (fb)) { CamelMessageInfo *info; - GtkWindow *top; - GtkWidget *focus; - - /* disable the message list so user can't click on them while we expunge */ - - /* nasty hack to find out if some widget inside the message list is focussed ... */ - top = GTK_WINDOW (gtk_widget_get_toplevel((GtkWidget *)fb->message_list)); - focus = top?top->focus_widget:NULL; - while (focus && focus != (GtkWidget *)fb->message_list) - focus = focus->parent; - fb->expunge_mlfocussed = focus == (GtkWidget *)fb->message_list; + + /* hide the deleted messages so user can't click on them while we expunge */ gtk_widget_set_sensitive (GTK_WIDGET (fb->message_list), FALSE); /* Only blank the mail display if the message being @@ -2735,22 +3016,28 @@ expunge_folder (BonoboUIComponent *uih, void *user_data, const char *path) static GtkWidget *filter_editor = NULL; static void -filter_editor_response (GtkWidget *dialog, int button, FolderBrowser *fb) +filter_editor_destroy (GtkWidget *dialog, gpointer user_data) +{ + filter_editor = NULL; +} + +static void +filter_editor_clicked (GtkWidget *dialog, int button, FolderBrowser *fb) { FilterContext *fc; - if (button == GTK_RESPONSE_ACCEPT) { + if (button == 0) { char *user; - fc = g_object_get_data(G_OBJECT(dialog), "context"); + fc = gtk_object_get_data (GTK_OBJECT (dialog), "context"); user = g_strdup_printf ("%s/filters.xml", evolution_dir); rule_context_save ((RuleContext *)fc, user); g_free (user); } - - gtk_widget_destroy(dialog); - - filter_editor = NULL; + + if (button != -1) { + gnome_dialog_close (GNOME_DIALOG (dialog)); + } } static const char *filter_source_names[] = { @@ -2773,23 +3060,32 @@ filter_edit (BonoboUIComponent *uih, void *user_data, const char *path) fc = filter_context_new (); user = g_strdup_printf ("%s/filters.xml", evolution_dir); - system = EVOLUTION_PRIVDATADIR "/filtertypes.xml"; + system = EVOLUTION_DATADIR "/evolution/filtertypes.xml"; rule_context_load ((RuleContext *)fc, system, user); g_free (user); if (((RuleContext *)fc)->error) { - e_notice(FB_WINDOW (fb), GTK_MESSAGE_ERROR, - _("Error loading filter information:\n%s"), - ((RuleContext *)fc)->error); + GtkWidget *dialog; + char *err; + + err = g_strdup_printf (_("Error loading filter information:\n%s"), + ((RuleContext *)fc)->error); + dialog = gnome_warning_dialog_parented (err, FB_WINDOW (fb)); + g_free (err); + + gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE); + gtk_widget_show (dialog); return; } filter_editor = (GtkWidget *)filter_editor_new (fc, filter_source_names); - /* FIXME: maybe this needs destroy func? */ - gtk_window_set_transient_for ((GtkWindow *) filter_editor, FB_WINDOW (fb)); + gnome_dialog_set_parent (GNOME_DIALOG (filter_editor), FB_WINDOW (fb)); gtk_window_set_title (GTK_WINDOW (filter_editor), _("Filters")); - g_object_set_data_full ((GObject *) filter_editor, "context", fc, (GtkDestroyNotify) g_object_unref); - g_signal_connect (filter_editor, "response", G_CALLBACK (filter_editor_response), fb); + + gtk_object_set_data_full (GTK_OBJECT (filter_editor), "context", fc, (GtkDestroyNotify)gtk_object_unref); + gtk_signal_connect (GTK_OBJECT (filter_editor), "clicked", filter_editor_clicked, fb); + gtk_signal_connect (GTK_OBJECT (filter_editor), "destroy", filter_editor_destroy, NULL); + gnome_dialog_append_buttons(GNOME_DIALOG(filter_editor), GNOME_STOCK_BUTTON_CANCEL, NULL); gtk_widget_show (GTK_WIDGET (filter_editor)); } @@ -2826,13 +3122,11 @@ footer_print_cb (GtkHTML *html, GnomePrintContext *print_context, double x, double y, double width, double height, gpointer user_data) { struct footer_info *info = (struct footer_info *) user_data; - + if (info->local_font) { - char *text = g_strdup_printf (_("Page %d of %d"), info->page_num, info->pages); - /*gdouble tw = gnome_font_get_width_string (info->local_font, text);*/ - /* FIXME: work out how to measure this */ - gdouble tw = strlen (text) * 8; - + gchar *text = g_strdup_printf (_("Page %d of %d"), info->page_num, info->pages); + gdouble tw = gnome_font_get_width_string (info->local_font, text); + gnome_print_gsave (print_context); gnome_print_newpath (print_context); gnome_print_setrgbcolor (print_context, .0, .0, .0); @@ -2840,7 +3134,7 @@ footer_print_cb (GtkHTML *html, GnomePrintContext *print_context, gnome_print_setfont (print_context, info->local_font); gnome_print_show (print_context, text); gnome_print_grestore (print_context); - + g_free (text); info->page_num++; } @@ -2858,16 +3152,15 @@ static struct footer_info * footer_info_new (GtkHTML *html, GnomePrintContext *pc, gdouble *line) { struct footer_info *info; - + info = g_new (struct footer_info, 1); - info->local_font = gnome_font_find_closest ("Helvetica", 10.0); - - if (info->local_font) + info->local_font = gnome_font_new_closest ("Helvetica", GNOME_FONT_BOOK, FALSE, 10); + if (info->local_font) { *line = gnome_font_get_ascender (info->local_font) + gnome_font_get_descender (info->local_font); - + } info->page_num = 1; info->pages = gtk_html_print_get_pages_num (html, pc, 0.0, *line); - + return info; } @@ -2875,43 +3168,51 @@ static void do_mail_print (FolderBrowser *fb, gboolean preview) { GtkHTML *html; - GtkWidget *w = NULL; GnomePrintContext *print_context; - GnomePrintJob *print_master; - GnomePrintConfig *config = NULL; - GtkDialog *dialog; + GnomePrintMaster *print_master; + GnomePrintDialog *dialog; + GnomePrinter *printer = NULL; + GnomePaper *paper; gdouble line = 0.0; + int copies = 1; + int collate = FALSE; struct footer_info *info; - + if (!preview) { - dialog = (GtkDialog *) gnome_print_dialog_new (NULL, _("Print Message"), GNOME_PRINT_DIALOG_COPIES); - gtk_dialog_set_default_response (dialog, GNOME_PRINT_DIALOG_RESPONSE_PRINT); - gtk_window_set_transient_for ((GtkWindow *) dialog, (GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *) fb)); - - switch (gtk_dialog_run (dialog)) { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - break; - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: + dialog = GNOME_PRINT_DIALOG (gnome_print_dialog_new (_("Print Message"), + GNOME_PRINT_DIALOG_COPIES)); + gnome_dialog_set_default (GNOME_DIALOG (dialog), GNOME_PRINT_PRINT); + e_gnome_dialog_set_parent (GNOME_DIALOG (dialog), FB_WINDOW (fb)); + + switch (gnome_dialog_run (GNOME_DIALOG (dialog))) { + case GNOME_PRINT_PRINT: + break; + case GNOME_PRINT_PREVIEW: preview = TRUE; break; + case -1: + return; default: - gtk_widget_destroy ((GtkWidget *) dialog); + gnome_dialog_close (GNOME_DIALOG (dialog)); return; } - config = gnome_print_dialog_get_config ((GnomePrintDialog *) dialog); - gtk_widget_destroy ((GtkWidget *)dialog); + gnome_print_dialog_get_copies (dialog, &copies, &collate); + printer = gnome_print_dialog_get_printer (dialog); + gnome_dialog_close (GNOME_DIALOG (dialog)); } - if (config) { - print_master = gnome_print_job_new (config); - gnome_print_config_unref (config); - } else - print_master = gnome_print_job_new (NULL); + print_master = gnome_print_master_new (); - /* paper size settings? */ - /*gnome_print_master_set_paper (print_master, paper);*/ - print_context = gnome_print_job_get_context (print_master); + if (printer) + gnome_print_master_set_printer (print_master, printer); + paper = (GnomePaper *) gnome_paper_with_name (_("US-Letter")); + + if (!paper) + paper = (GnomePaper *) gnome_paper_with_name (gnome_paper_name_default ()); + gnome_print_master_set_paper (print_master, paper); + gnome_print_master_set_copies (print_master, copies, collate); + print_context = gnome_print_master_get_context (print_master); html = GTK_HTML (gtk_html_new ()); mail_display_initialize_gtkhtml (fb->mail_display, html); @@ -2921,13 +3222,8 @@ do_mail_print (FolderBrowser *fb, gboolean preview) user's theme. */ fb->mail_display->printing = TRUE; - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (html))) { - /* gtk widgets don't like to be realized outside top level widget - so we put new html widget into gtk window */ - w = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (html)); + if (!GTK_WIDGET_REALIZED (GTK_WIDGET (html))) gtk_widget_realize (GTK_WIDGET (html)); - } mail_display_render (fb->mail_display, html, TRUE); gtk_html_print_set_master (html, print_master); @@ -2937,24 +3233,25 @@ do_mail_print (FolderBrowser *fb, gboolean preview) fb->mail_display->printing = FALSE; - gnome_print_job_close (print_master); - gtk_widget_destroy (GTK_WIDGET (html)); - if (w) - gtk_widget_destroy (w); + gnome_print_master_close (print_master); if (preview){ - GtkWidget *pw; + gboolean landscape = FALSE; + GnomePrintMasterPreview *preview; - pw = gnome_print_job_preview_new (print_master, _("Print Preview")); - gtk_widget_show (pw); + preview = gnome_print_master_preview_new_with_orientation ( + print_master, _("Print Preview"), landscape); + gtk_widget_show (GTK_WIDGET (preview)); } else { - int result = gnome_print_job_print (print_master); + int result = gnome_print_master_print (print_master); - if (result == -1) - e_notice (FB_WINDOW (fb), GTK_MESSAGE_ERROR, _("Printing of message failed")); + if (result == -1){ + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Printing of message failed")); + } } - - g_object_unref (print_master); + + /* FIXME: We are leaking the GtkHTML object */ } /* This is pretty evil. FolderBrowser's API should be extended to allow these sorts of @@ -2985,7 +3282,7 @@ done_message_selected (CamelFolder *folder, const char *uid, CamelMimeMessage *m g_free (fb->loaded_uid); fb->loaded_uid = fb->loading_uid; fb->loading_uid = NULL; - + if (msg) do_mail_print (fb, preview); } @@ -3052,12 +3349,10 @@ print_preview_msg (GtkWidget *button, gpointer user_data) static GtkObject *subscribe_dialog = NULL; static void -subscribe_dialog_destroy (GtkObject *dialog, GObject *deadbeef) +subscribe_dialog_destroy (GtkWidget *widget, gpointer user_data) { - if (subscribe_dialog) { - g_object_unref (subscribe_dialog); - subscribe_dialog = NULL; - } + gtk_object_unref (subscribe_dialog); + subscribe_dialog = NULL; } void @@ -3065,9 +3360,8 @@ manage_subscriptions (BonoboUIComponent *uih, void *user_data, const char *path) { if (!subscribe_dialog) { subscribe_dialog = subscribe_dialog_new (); - - g_object_weak_ref ((GObject *) SUBSCRIBE_DIALOG (subscribe_dialog)->app, - (GWeakNotify) subscribe_dialog_destroy, subscribe_dialog); + gtk_signal_connect (GTK_OBJECT (SUBSCRIBE_DIALOG (subscribe_dialog)->app), "destroy", + subscribe_dialog_destroy, NULL); subscribe_dialog_show (subscribe_dialog); } else { @@ -3083,7 +3377,7 @@ local_configure_done(const char *uri, CamelFolder *folder, void *data) FolderBrowser *fb = data; if (FOLDER_BROWSER_IS_DESTROYED (fb)) { - g_object_unref(fb); + gtk_object_unref((GtkObject *)fb); return; } @@ -3091,7 +3385,7 @@ local_configure_done(const char *uri, CamelFolder *folder, void *data) folder = fb->folder; message_list_set_folder(fb->message_list, folder, FALSE); - g_object_unref(fb); + gtk_object_unref((GtkObject *)fb); } void @@ -3107,7 +3401,7 @@ configure_folder (BonoboUIComponent *uih, void *user_data, const char *path) vfolder_edit_rule (fb->uri); } else { message_list_set_folder(fb->message_list, NULL, FALSE); - g_object_ref((GtkObject *)fb); + gtk_object_ref((GtkObject *)fb); mail_local_reconfigure_folder(fb->uri, local_configure_done, fb); } } @@ -3190,19 +3484,18 @@ stop_threads (BonoboUIComponent *uih, void *user_data, const char *path) static void empty_trash_expunged_cb (CamelFolder *folder, void *data) { - camel_object_unref (folder); + camel_object_unref (CAMEL_OBJECT (folder)); } void empty_trash (BonoboUIComponent *uih, void *user_data, const char *path) { + MailConfigAccount *account; CamelProvider *provider; - EAccountList *accounts; + const GSList *accounts; CamelFolder *vtrash; FolderBrowser *fb; CamelException ex; - EAccount *account; - EIterator *iter; fb = user_data ? FOLDER_BROWSER (user_data) : NULL; @@ -3213,12 +3506,11 @@ empty_trash (BonoboUIComponent *uih, void *user_data, const char *path) /* expunge all remote stores */ accounts = mail_config_get_accounts (); - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - account = (EAccount *) e_iterator_get (iter); + while (accounts) { + account = accounts->data; /* make sure this is a valid source */ - if (account->enabled && account->source->url) { + if (account->source && account->source->enabled && account->source->url) { provider = camel_session_get_provider (session, account->source->url, &ex); if (provider) { /* make sure this store is a remote store */ @@ -3235,16 +3527,14 @@ empty_trash (BonoboUIComponent *uih, void *user_data, const char *path) /* clear the exception for the next round */ camel_exception_clear (&ex); } - - e_iterator_next (iter); + accounts = accounts->next; } - g_object_unref (iter); - /* Now empty the local trash folder */ vtrash = mail_tool_get_trash ("file:/", TRUE, &ex); - if (vtrash) + if (vtrash) { mail_expunge_folder (vtrash, empty_trash_expunged_cb, NULL); + } camel_exception_clear (&ex); } diff --git a/mail/mail-composer-prefs.c b/mail/mail-composer-prefs.c index 8b361035dd..8e6cbb54f8 100644 --- a/mail/mail-composer-prefs.c +++ b/mail/mail-composer-prefs.c @@ -25,20 +25,16 @@ #include <config.h> #endif -#include <string.h> - #include "mail-composer-prefs.h" #include "composer/e-msg-composer.h" +#include <gtk/gtksignal.h> + #include <bonobo/bonobo-generic-factory.h> +#include <bonobo/bonobo-object-client.h> -#include <gal/util/e-iconv.h> #include <gal/widgets/e-gui-utils.h> - -#include <gtk/gtktreemodel.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtktreeview.h> +#include <gal/widgets/e-unicode.h> #include "widgets/misc/e-charset-picker.h" @@ -52,30 +48,30 @@ static void mail_composer_prefs_class_init (MailComposerPrefsClass *class); static void mail_composer_prefs_init (MailComposerPrefs *dialog); static void mail_composer_prefs_destroy (GtkObject *obj); -static void mail_composer_prefs_finalise (GObject *obj); +static void mail_composer_prefs_finalise (GtkObject *obj); static void sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailComposerPrefs *prefs); static GtkVBoxClass *parent_class = NULL; -GType +GtkType mail_composer_prefs_get_type (void) { - static GType type = 0; + static GtkType type = 0; if (!type) { - static const GTypeInfo info = { - sizeof (MailComposerPrefsClass), - NULL, NULL, - (GClassInitFunc) mail_composer_prefs_class_init, - NULL, NULL, + GtkTypeInfo type_info = { + "MailComposerPrefs", sizeof (MailComposerPrefs), - 0, - (GInstanceInitFunc) mail_composer_prefs_init, + sizeof (MailComposerPrefsClass), + (GtkClassInitFunc) mail_composer_prefs_class_init, + (GtkObjectInitFunc) mail_composer_prefs_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL }; - type = g_type_register_static (gtk_vbox_get_type (), "MailComposerPrefs", &info, 0); + type = gtk_type_unique (gtk_vbox_get_type (), &type_info); } return type; @@ -84,13 +80,15 @@ mail_composer_prefs_get_type (void) static void mail_composer_prefs_class_init (MailComposerPrefsClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GtkObjectClass *object_class; - parent_class = g_type_class_ref (gtk_vbox_get_type ()); + object_class = (GtkObjectClass *) klass; + parent_class = gtk_type_class (gtk_vbox_get_type ()); object_class->destroy = mail_composer_prefs_destroy; - gobject_class->finalize = mail_composer_prefs_finalise; + object_class->finalize = mail_composer_prefs_finalise; + /* override methods */ + } static void @@ -102,27 +100,28 @@ mail_composer_prefs_init (MailComposerPrefs *composer_prefs) } static void -mail_composer_prefs_finalise (GObject *obj) +mail_composer_prefs_finalise (GtkObject *obj) { MailComposerPrefs *prefs = (MailComposerPrefs *) obj; - g_object_unref (prefs->gui); - g_object_unref (prefs->pman); - g_object_unref (prefs->enabled_pixbuf); + gtk_object_unref (GTK_OBJECT (prefs->gui)); + gtk_object_unref (GTK_OBJECT (prefs->pman)); + gdk_pixbuf_unref (prefs->enabled_pixbuf); gdk_pixmap_unref (prefs->mark_pixmap); - g_object_unref (prefs->mark_bitmap); - - G_OBJECT_CLASS (parent_class)->finalize (obj); + gdk_bitmap_unref (prefs->mark_bitmap); + + ((GtkObjectClass *)(parent_class))->finalize (obj); } static void mail_composer_prefs_destroy (GtkObject *obj) { MailComposerPrefs *prefs = (MailComposerPrefs *) obj; - + mail_config_signature_unregister_client ((MailConfigSignatureClient) sig_event_client, prefs); - GTK_OBJECT_CLASS (parent_class)->destroy (obj); + if (GTK_OBJECT_CLASS (parent_class)) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (obj); } static void @@ -130,7 +129,7 @@ attach_style_info (GtkWidget *item, gpointer user_data) { int *style = user_data; - g_object_set_data ((GObject *) item, "style", GINT_TO_POINTER (*style)); + gtk_object_set_data (GTK_OBJECT (item), "style", GINT_TO_POINTER (*style)); (*style)++; } @@ -164,7 +163,8 @@ option_menu_connect (GtkOptionMenu *omenu, gpointer user_data) items = GTK_MENU_SHELL (menu)->children; while (items) { item = items->data; - g_signal_connect (item, "activate", G_CALLBACK (menu_changed), user_data); + gtk_signal_connect (GTK_OBJECT (item), "activate", + menu_changed, user_data); items = items->next; } } @@ -178,18 +178,18 @@ sig_load_preview (MailComposerPrefs *prefs, MailConfigSignature *sig) gtk_html_load_from_string (GTK_HTML (prefs->sig_preview), " ", 1); return; } - + if (sig->script) str = mail_config_signature_run_script (sig->script); else str = e_msg_composer_get_sig_file_content (sig->filename, sig->html); if (!str) - str = g_strdup (""); + str = g_strdup (" "); /* printf ("HTML: %s\n", str); */ - if (sig->html) { + if (sig->html) gtk_html_load_from_string (GTK_HTML (prefs->sig_preview), str, strlen (str)); - } else { + else { GtkHTMLStream *stream; int len; @@ -205,181 +205,180 @@ sig_load_preview (MailComposerPrefs *prefs, MailConfigSignature *sig) g_free (str); } +static MailConfigSignature * +sig_current_sig (MailComposerPrefs *prefs) +{ + return gtk_clist_get_row_data (GTK_CLIST (prefs->sig_clist), prefs->sig_row); +} + static void -sig_edit_cb (GtkWidget *widget, MailComposerPrefs *prefs) +sig_edit (GtkWidget *widget, MailComposerPrefs *prefs) { - GtkTreeSelection *selection; - MailConfigSignature *sig; - GtkTreeModel *model; - GtkWidget *parent; - GtkTreeIter iter; - - selection = gtk_tree_view_get_selection (prefs->sig_list); - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - gtk_tree_model_get (model, &iter, 1, &sig, -1); + MailConfigSignature *sig = sig_current_sig (prefs); - if (!sig->filename || *sig->filename == '\0') { - g_free (sig->filename); - sig->filename = g_strdup (_("Unnamed")); - } - - parent = gtk_widget_get_toplevel ((GtkWidget *) prefs); - parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - - mail_signature_editor (sig, (GtkWindow *) parent, FALSE); + if (sig->filename && *sig->filename) + mail_signature_editor (sig); + else + e_notice (GTK_WINDOW (prefs), GNOME_MESSAGE_BOX_ERROR, + _("Please specify signature filename\nin Advanced section of signature settings.")); } MailConfigSignature * -mail_composer_prefs_new_signature (GtkWindow *parent, gboolean html, const char *script) +mail_composer_prefs_new_signature (MailComposerPrefs *prefs, gboolean html, const gchar *script) { MailConfigSignature *sig; + char *name[1]; + int row; + + sig = mail_config_signature_add (html, script); + + if (prefs) { + if (!(name[0] = e_utf8_to_gtk_string (GTK_WIDGET (prefs->sig_clist), sig->name))) + name[0] = g_strdup (""); + + if (sig->script) { + char *tmp; + + tmp = name[0]; + name[0] = g_strconcat (tmp, _(" [script]"), NULL); + g_free (tmp); + } + + row = gtk_clist_append (prefs->sig_clist, name); + gtk_clist_set_row_data (prefs->sig_clist, row, sig); + gtk_clist_select_row (GTK_CLIST (prefs->sig_clist), row, 0); + g_free (name[0]); + /*gtk_widget_grab_focus (prefs->sig_name);*/ + } - sig = mail_config_signature_new (html, script); - mail_signature_editor (sig, parent, TRUE); + if (sig->filename && *sig->filename) + mail_signature_editor (sig); return sig; } +static void sig_row_unselect (GtkCList *clist, int row, int col, GdkEvent *event, MailComposerPrefs *prefs); + static void -sig_delete_cb (GtkWidget *widget, MailComposerPrefs *prefs) +sig_delete (GtkWidget *widget, MailComposerPrefs *prefs) { - MailConfigSignature *sig; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - - selection = gtk_tree_view_get_selection (prefs->sig_list); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gtk_tree_model_get (model, &iter, 1, &sig, -1); - gtk_list_store_remove ((GtkListStore *) model, &iter); - mail_config_signature_delete (sig); - } + MailConfigSignature *sig = sig_current_sig (prefs); + + gtk_clist_remove (prefs->sig_clist, prefs->sig_row); + mail_config_signature_delete (sig); + if (prefs->sig_row < prefs->sig_clist->rows) + gtk_clist_select_row (prefs->sig_clist, prefs->sig_row, 0); + else if (prefs->sig_row) + gtk_clist_select_row (prefs->sig_clist, prefs->sig_row - 1, 0); + else + sig_row_unselect (prefs->sig_clist, prefs->sig_row, 0, NULL, prefs); } static void -sig_add_cb (GtkWidget *widget, MailComposerPrefs *prefs) +sig_add (GtkWidget *widget, MailComposerPrefs *prefs) { - GConfClient *gconf; - gboolean send_html; - GtkWidget *parent; - - gconf = gconf_client_get_default (); - send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL); - - parent = gtk_widget_get_toplevel ((GtkWidget *) prefs); - parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - - mail_composer_prefs_new_signature ((GtkWindow *) parent, send_html, NULL); + mail_composer_prefs_new_signature (prefs, mail_config_get_send_html (), NULL); } static void -sig_add_script_response (GtkWidget *widget, int button, MailComposerPrefs *prefs) +sig_add_script_add (GtkWidget *widget, MailComposerPrefs *prefs) { - const char *script, *name; - GtkWidget *dialog; + char *script, *name; GtkWidget *entry; - if (button == GTK_RESPONSE_ACCEPT) { - entry = glade_xml_get_widget (prefs->sig_script_gui, "fileentry_add_script_script"); - script = gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (entry)))); + entry = glade_xml_get_widget (prefs->sig_script_gui, "fileentry_add_script_script"); + script = gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (entry)))); + + entry = glade_xml_get_widget (prefs->sig_script_gui, "entry_add_script_name"); + name = e_utf8_gtk_entry_get_text (GTK_ENTRY (entry)); + if (script && *script) { + struct stat st; - entry = glade_xml_get_widget (prefs->sig_script_gui, "entry_add_script_name"); - name = gtk_entry_get_text (GTK_ENTRY (entry)); - if (script && *script) { - struct stat st; + if (!stat (script, &st) + && S_ISREG (st.st_mode) && (st.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR))) { + MailConfigSignature *sig; + + sig = mail_composer_prefs_new_signature (prefs, TRUE, script); + mail_config_signature_set_name (sig, name); + g_free (name); + gtk_widget_hide (prefs->sig_script_dialog); - if (!stat (script, &st) && S_ISREG (st.st_mode) && access (script, X_OK) == 0) { - MailConfigSignature *sig; - GtkWidget *parent; - - parent = gtk_widget_get_toplevel ((GtkWidget *) prefs); - parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - - sig = mail_composer_prefs_new_signature ((GtkWindow *) parent, TRUE, script); - mail_config_signature_set_name (sig, name); - mail_config_signature_add (sig); - - gtk_widget_hide (prefs->sig_script_dialog); - - return; - } + return; } - - dialog = gtk_message_dialog_new (GTK_WINDOW (prefs->sig_script_dialog), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - "%s", _("You must specify a valid script name.")); - - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); } - - gtk_widget_hide (widget); + gnome_dialog_run_and_close (GNOME_DIALOG (gnome_ok_dialog_parented (_("Please specify a valid script name"), + GTK_WINDOW (prefs->sig_script_dialog)))); } static void -sig_add_script_cb (GtkWidget *widget, MailComposerPrefs *prefs) +sig_add_script_cancel (GtkWidget *widget, MailComposerPrefs *prefs) +{ + gnome_dialog_close (GNOME_DIALOG (prefs->sig_script_dialog)); +} + +static void +sig_add_script (GtkWidget *widget, MailComposerPrefs *prefs) { GtkWidget *entry; entry = glade_xml_get_widget (prefs->sig_script_gui, "entry_add_script_name"); gtk_entry_set_text (GTK_ENTRY (entry), _("Unnamed")); - gtk_widget_show (prefs->sig_script_dialog); + gtk_widget_show_all (prefs->sig_script_dialog); gdk_window_raise (prefs->sig_script_dialog->window); } static void -sig_selection_changed (GtkTreeSelection *selection, MailComposerPrefs *prefs) +sig_row_select (GtkCList *clist, int row, int col, GdkEvent *event, MailComposerPrefs *prefs) { MailConfigSignature *sig; - GtkTreeModel *model; - GtkTreeIter iter; - int state; - - state = gtk_tree_selection_get_selected (selection, &model, &iter); - if (state) { - gtk_tree_model_get (model, &iter, 1, &sig, -1); - sig_load_preview (prefs, sig); - } - gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_delete, state); - gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_edit, state); + d(printf ("sig_row_select\n")); + sig = gtk_clist_get_row_data (prefs->sig_clist, row); + prefs->sig_row = row; + + gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_delete, TRUE); + gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_edit, sig->script == NULL); + + sig_load_preview (prefs, sig); } static void -sig_fill_clist (GtkTreeView *clist) +sig_row_unselect (GtkCList *clist, int row, int col, GdkEvent *event, MailComposerPrefs *prefs) { - GSList *l; - GtkListStore *model; - GtkTreeIter iter; - - model = (GtkListStore *) gtk_tree_view_get_model (clist); - gtk_list_store_clear (model); + d(printf ("sig_row_unselect\n")); + gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_delete, FALSE); + gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_edit, FALSE); +} + +static void +sig_fill_clist (GtkCList *clist) +{ + GList *l; + char *name[1]; + int row; + gtk_clist_freeze (clist); for (l = mail_config_get_signature_list (); l; l = l->next) { - MailConfigSignature *sig = l->data; - char *name = NULL, *val; - - gtk_list_store_append (model, &iter); - - if (sig->script) - name = val = g_strconcat (sig->name, " ", _("[script]"), NULL); - else - val = sig->name; - gtk_list_store_set (model, &iter, 0, val, 1, sig, -1); - g_free (name); + name[0] = e_utf8_to_gtk_string (GTK_WIDGET (clist), ((MailConfigSignature *) l->data)->name); + if (((MailConfigSignature *) l->data)->script) { + char *tmp; + + tmp = name [0]; + name[0] = g_strconcat (name[0], _(" [script]"), NULL); + g_free (tmp); + } + row = gtk_clist_append (clist, name); + gtk_clist_set_row_data (clist, row, l->data); + g_free (name [0]); } + gtk_clist_thaw (clist); } static void url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle) { GtkHTMLStreamStatus status; - char buf[128]; - ssize_t size; int fd; if (!strncmp (url, "file:", 5)) @@ -388,12 +387,14 @@ url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle) fd = open (url, O_RDONLY); status = GTK_HTML_STREAM_OK; if (fd != -1) { - while ((size = read (fd, buf, sizeof (buf)))) { + ssize_t size; + void *buf = alloca (1 << 7); + while ((size = read (fd, buf, 1 << 7))) { if (size == -1) { status = GTK_HTML_STREAM_ERROR; break; } else - gtk_html_write (html, handle, buf, size); + gtk_html_write (html, handle, (const gchar *) buf, size); } } else status = GTK_HTML_STREAM_ERROR; @@ -404,46 +405,29 @@ url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle) static void sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailComposerPrefs *prefs) { - MailConfigSignature *current; - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - char path[16]; + char *tmp, *tmp1; switch (event) { - case MAIL_CONFIG_SIG_EVENT_ADDED: - d(printf ("signature ADDED\n")); - - model = gtk_tree_view_get_model (prefs->sig_list); - gtk_list_store_append ((GtkListStore *) model, &iter); - gtk_list_store_set ((GtkListStore *) model, &iter, 0, sig->name, 1, sig, -1); - break; case MAIL_CONFIG_SIG_EVENT_NAME_CHANGED: - d(printf ("signature NAME CHANGED\n")); - - /* this is one bizarro interface */ - model = gtk_tree_view_get_model (prefs->sig_list); - sprintf (path, "%d", sig->id); - if (gtk_tree_model_get_iter_from_string (model, &iter, path)) { - char *val, *name = NULL; - - if (sig->script) - name = val = g_strconcat (sig->name, " ", _("[script]"), NULL); - else - val = sig->name; - - gtk_list_store_set ((GtkListStore *) model, &iter, 0, val, -1); - g_free (name); + d(printf ("accounts NAME CHANGED\n")); + tmp = e_utf8_to_gtk_string (GTK_WIDGET (prefs->sig_clist), sig->name); + if (sig->script) { + tmp1 = tmp; + tmp = g_strconcat (tmp, _(" [script]"), NULL); + g_free (tmp1); + } + gtk_clist_set_text (GTK_CLIST (prefs->sig_clist), sig->id, 0, tmp); + g_free (tmp); + if (sig == sig_current_sig (prefs)) { + prefs->sig_switch = TRUE; + /*e_utf8_gtk_entry_set_text (GTK_ENTRY (prefs->sig_name), sig->name);*/ + prefs->sig_switch = FALSE; } break; case MAIL_CONFIG_SIG_EVENT_CONTENT_CHANGED: - d(printf ("signature CONTENT CHANGED\n")); - selection = gtk_tree_view_get_selection (prefs->sig_list); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gtk_tree_model_get (model, &iter, 1, ¤t, -1); - if (sig == current) - sig_load_preview (prefs, sig); - } + d(printf ("accounts CONTENT CHANGED\n")); + if (sig == sig_current_sig (prefs)) + sig_load_preview (prefs, sig); break; default: ; @@ -459,38 +443,54 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailCompos #include "Spell.h" #define GNOME_SPELL_GCONF_DIR "/GNOME/Spell" -#define SPELL_API_VERSION "0.3" +#define SPELL_API_VERSION "0.2" static void -spell_set_ui (MailComposerPrefs *prefs) +spell_select_lang (MailComposerPrefs *prefs, const gchar *abrev) { - GtkListStore *model; - GtkTreeIter iter; - GHashTable *present; - gboolean go; - char **strv; int i; + + for (i = 0; i < prefs->language_seq->_length; i ++) { + if (!strcasecmp (abrev, prefs->language_seq->_buffer [i].abrev)) { + gtk_clist_set_pixmap (GTK_CLIST (prefs->language), i, 0, prefs->mark_pixmap, prefs->mark_bitmap); + } + } +} - prefs->spell_active = FALSE; - - /* setup the language list */ - strv = g_strsplit (prefs->language_str, " ", 0); - present = g_hash_table_new (g_str_hash, g_str_equal); - for (i = 0; strv[i]; i++) - g_hash_table_insert (present, strv[i], strv[i]); +static void +spell_set_ui_language (MailComposerPrefs *prefs) +{ + char *l, *last, *lang; + int i; - model = (GtkListStore *) gtk_tree_view_get_model (prefs->language); - for (go = gtk_tree_model_get_iter_first ((GtkTreeModel *) model, &iter); go; - go = gtk_tree_model_iter_next ((GtkTreeModel *) model, &iter)) { - char *abbr; - - gtk_tree_model_get ((GtkTreeModel *) model, &iter, 2, &abbr, -1); - gtk_list_store_set (model, &iter, 0, g_hash_table_lookup (present, abbr) != NULL, -1); + gtk_clist_freeze (GTK_CLIST (prefs->language)); + gtk_clist_unselect_all (GTK_CLIST (prefs->language)); + + for (i = 0; i < prefs->language_seq->_length; i ++) { + gtk_clist_set_pixmap (GTK_CLIST (prefs->language), i, 0, NULL, NULL); } - g_hash_table_destroy (present); - g_strfreev (strv); + last = prefs->language_str; + while ((l = strchr (last, ' '))) { + if (l != last) { + lang = g_strndup (last, l - last); + spell_select_lang (prefs, lang); + g_free (lang); + } + + last = l + 1; + } + if (last) + spell_select_lang (prefs, last); + gtk_clist_thaw (GTK_CLIST (prefs->language)); +} + +static void +spell_set_ui (MailComposerPrefs *prefs) +{ + prefs->spell_active = FALSE; + spell_set_ui_language (prefs); gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (prefs->colour), prefs->spell_error_color.red, prefs->spell_error_color.green, @@ -502,31 +502,26 @@ spell_set_ui (MailComposerPrefs *prefs) static gchar * spell_get_language_str (MailComposerPrefs *prefs) { - GString *str = g_string_new (""); - GtkListStore *model; - GtkTreeIter iter; - gboolean go; + GString *str = g_string_new (NULL); char *rv; - - model = (GtkListStore *) gtk_tree_view_get_model (prefs->language); - for (go = gtk_tree_model_get_iter_first ((GtkTreeModel *) model, &iter); - go; - go = gtk_tree_model_iter_next ((GtkTreeModel *) model, &iter)) { - char *abbr; - gboolean state; + int i; + + for (i = 0; i < GTK_CLIST (prefs->language)->rows; i ++) { + GdkPixmap *pmap = NULL; + GdkBitmap *bmap; - gtk_tree_model_get ((GtkTreeModel *) model, &iter, 0, &state, 2, &abbr, -1); - if (state) { + gtk_clist_get_pixmap (GTK_CLIST (prefs->language), i, 0, &pmap, &bmap); + if (pmap) { if (str->len) g_string_append_c (str, ' '); - g_string_append (str, abbr); + g_string_append (str, gtk_clist_get_row_data (GTK_CLIST (prefs->language), i)); } } rv = str->str; g_string_free (str, FALSE); - return rv; + return rv ? rv : g_strdup (""); } static void @@ -567,7 +562,7 @@ spell_load_values (MailComposerPrefs *prefs) GConfValue *val; char *def_lang; - def_lang = g_strdup ("en_us"); + def_lang = g_strdup ("en"); g_free (prefs->language_str); prefs->language_str = g_strdup (def_lang); prefs->spell_error_color.red = 0xffff; @@ -639,111 +634,141 @@ spell_color_set (GtkWidget *widget, guint r, guint g, guint b, guint a, gpointer } static void -spell_language_selection_changed (GtkTreeSelection *selection, MailComposerPrefs *prefs) +spell_language_select_row (GtkWidget *widget, gint row, gint column, GdkEvent *event, MailComposerPrefs *prefs) { - GtkTreeIter iter; - GtkTreeModel *model; - gboolean state = FALSE; - - if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gtk_tree_model_get ((GtkTreeModel *) model, &iter, 0, &state, -1); - gtk_button_set_label ((GtkButton *) prefs->spell_able_button, state ? _("Disable") : _("Enable")); - state = TRUE; + GList *sel = GTK_CLIST (prefs->language)->selection; + + if (sel) { + GdkPixmap *pmap = NULL; + GdkBitmap *bmap; + int row = GPOINTER_TO_INT (sel->data); + + gtk_clist_get_pixmap (GTK_CLIST (prefs->language), row, 0, &pmap, &bmap); + if (pmap) + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->spell_able_button)->child), _("Disable")); + else + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->spell_able_button)->child), _("Enable")); } - gtk_widget_set_sensitive (prefs->spell_able_button, state); + + gtk_widget_set_sensitive (prefs->spell_able_button, TRUE); +} + +static void +spell_language_unselect_row (GtkWidget *widget, gint row, gint column, GdkEvent *event, MailComposerPrefs *prefs) +{ + gtk_widget_set_sensitive (prefs->spell_able_button, FALSE); } static void spell_language_enable (GtkWidget *widget, MailComposerPrefs *prefs) { - GtkTreeIter iter; - GtkTreeModel *model; - GtkTreeSelection *selection; - gboolean state; + GList *sel = GTK_CLIST (prefs->language)->selection; - selection = gtk_tree_view_get_selection (prefs->language); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gtk_tree_model_get (model, &iter, 0, &state, -1); - gtk_list_store_set ((GtkListStore *) model, &iter, 0, !state, -1); - gtk_button_set_label ((GtkButton *) prefs->spell_able_button, state ? _("Enable") : _("Disable")); + if (sel) { + GdkPixmap *pmap = NULL; + GdkBitmap *bmap; + int row = GPOINTER_TO_INT (sel->data); + + gtk_clist_get_pixmap (GTK_CLIST (prefs->language), row, 0, &pmap, &bmap); + if (pmap) { + gtk_clist_set_pixmap (GTK_CLIST (prefs->language), row, 0, NULL, NULL); + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->spell_able_button)->child), _("Enable")); + } else { + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->spell_able_button)->child), _("Disable")); + gtk_clist_set_pixmap (GTK_CLIST (prefs->language), row, 0, prefs->mark_pixmap, prefs->mark_bitmap); + } + spell_changed (prefs); } } -static gboolean -spell_language_button_press (GtkTreeView *tv, GdkEventButton *event, MailComposerPrefs *prefs) +static void +spell_language_button_press (GtkWidget *widget, GdkEventButton *event, MailComposerPrefs *prefs) { - GtkTreePath *path = NULL; - GtkTreeViewColumn *column = NULL; - gtk_tree_view_get_path_at_pos (tv, event->x, event->y, &path, &column, NULL, NULL); - - if (path != NULL && column != NULL && !strcmp (gtk_tree_view_column_get_title (column), _("Enabled"))) { - GtkTreeIter iter; - GtkTreeModel *model; - gboolean enabled; - - model = gtk_tree_view_get_model (tv); - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, 0, &enabled, -1); - gtk_list_store_set ((GtkListStore *) model, &iter, 0, !enabled, -1); - spell_changed (prefs); + int row, col; + + if (gtk_clist_get_selection_info (prefs->language, event->x, event->y, &row, &col)) { + if (col == 0) { + GList *sel = GTK_CLIST (prefs->language)->selection; + GdkPixmap *pmap = NULL; + GdkBitmap *bmap; + + gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event"); + + gtk_clist_get_pixmap (GTK_CLIST (prefs->language), row, 0, &pmap, &bmap); + if (pmap) + gtk_clist_set_pixmap (GTK_CLIST (prefs->language), row, 0, NULL, NULL); + else + gtk_clist_set_pixmap (GTK_CLIST (prefs->language), row, 0, + prefs->mark_pixmap, prefs->mark_bitmap); + + if (sel && GPOINTER_TO_INT (sel->data) == row) + gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->spell_able_button)->child), + pmap ? _("Enable") : _("Disable")); + + spell_changed (prefs); + } } - - return FALSE; } static void spell_setup (MailComposerPrefs *prefs) { - GtkListStore *model; - GtkTreeIter iter; int i; - model = (GtkListStore *) gtk_tree_view_get_model (prefs->language); - + gtk_clist_freeze (GTK_CLIST (prefs->language)); if (prefs->language_seq) { for (i = 0; i < prefs->language_seq->_length; i++) { - gtk_list_store_append (model, &iter); - gtk_list_store_set (model, &iter, - 1, _(prefs->language_seq->_buffer[i].name), - 2, prefs->language_seq->_buffer[i].abbreviation, - -1); + char *texts[2]; + + texts[0] = NULL; + texts[1] = _(prefs->language_seq->_buffer [i].name); + gtk_clist_append (GTK_CLIST (prefs->language), texts); + gtk_clist_set_row_data (GTK_CLIST (prefs->language), i, prefs->language_seq->_buffer [i].abrev); } } + gtk_clist_thaw (GTK_CLIST (prefs->language)); spell_load_values (prefs); spell_set_ui (prefs); - glade_xml_signal_connect_data (prefs->gui, "spellColorSet", G_CALLBACK (spell_color_set), prefs); + glade_xml_signal_connect_data (prefs->gui, "spellColorSet", GTK_SIGNAL_FUNC (spell_color_set), prefs); + glade_xml_signal_connect_data (prefs->gui, "spellLanguageSelectRow", + GTK_SIGNAL_FUNC (spell_language_select_row), prefs); + glade_xml_signal_connect_data (prefs->gui, "spellLanguageUnselectRow", + GTK_SIGNAL_FUNC (spell_language_unselect_row), prefs); glade_xml_signal_connect_data (prefs->gui, "spellLanguageEnable", GTK_SIGNAL_FUNC (spell_language_enable), prefs); - g_signal_connect (prefs->language, "button_press_event", G_CALLBACK (spell_language_button_press), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->language), "button_press_event", spell_language_button_press, prefs); } static gboolean spell_setup_check_options (MailComposerPrefs *prefs) { + BonoboObjectClient *dictionary_client; GNOME_Spell_Dictionary dict; CORBA_Environment ev; char *dictionary_id; dictionary_id = "OAFIID:GNOME_Spell_Dictionary:" SPELL_API_VERSION; - dict = bonobo_activation_activate_from_id (dictionary_id, 0, NULL, NULL); - if (dict == CORBA_OBJECT_NIL) { + dictionary_client = bonobo_object_activate (dictionary_id, 0); + + if (!dictionary_client) { g_warning ("Cannot activate %s", dictionary_id); return FALSE; } + dict = bonobo_object_corba_objref (BONOBO_OBJECT (dictionary_client)); CORBA_exception_init (&ev); prefs->language_seq = GNOME_Spell_Dictionary_getLanguages (dict, &ev); if (ev._major != CORBA_NO_EXCEPTION) prefs->language_seq = NULL; CORBA_exception_free (&ev); - + if (prefs->language_seq == NULL) return FALSE; - + gconf_client_add_dir (prefs->gconf, GNOME_SPELL_GCONF_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL); spell_setup (prefs); @@ -759,13 +784,8 @@ static void mail_composer_prefs_construct (MailComposerPrefs *prefs) { GtkWidget *toplevel, *widget, *menu, *info_pixmap; - GtkDialog *dialog; GladeXML *gui; - GtkListStore *model; - GtkTreeSelection *selection; - gboolean bool; int style; - char *buf; char *names[][2] = { { "live_spell_check", "chkEnableSpellChecking" }, { "magic_smileys_check", "chkAutoSmileys" }, @@ -775,9 +795,9 @@ mail_composer_prefs_construct (MailComposerPrefs *prefs) prefs->gconf = gconf_client_get_default (); - gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "composer_tab", NULL); + gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "composer_tab"); prefs->gui = gui; - prefs->sig_script_gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "vbox_add_script_signature", NULL); + prefs->sig_script_gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "vbox_add_script_signature"); /* get our toplevel widget */ toplevel = glade_xml_get_widget (gui, "toplevel"); @@ -792,66 +812,46 @@ mail_composer_prefs_construct (MailComposerPrefs *prefs) /* Default Behavior */ prefs->send_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkSendHTML")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/composer/send_html", NULL); - gtk_toggle_button_set_active (prefs->send_html, bool); - g_signal_connect (prefs->send_html, "toggled", G_CALLBACK (toggle_button_toggled), prefs); + gtk_toggle_button_set_active (prefs->send_html, mail_config_get_send_html ()); + gtk_signal_connect (GTK_OBJECT (prefs->send_html), "toggled", + toggle_button_toggled, prefs); prefs->auto_smileys = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkAutoSmileys")); - /* FIXME: set active? */ - g_signal_connect (prefs->auto_smileys, "toggled", G_CALLBACK (toggle_button_toggled), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->auto_smileys), "toggled", + toggle_button_toggled, prefs); prefs->prompt_empty_subject = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptEmptySubject")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/prompts/empty_subject", NULL); - gtk_toggle_button_set_active (prefs->prompt_empty_subject, bool); - g_signal_connect (prefs->prompt_empty_subject, "toggled", G_CALLBACK (toggle_button_toggled), prefs); + gtk_toggle_button_set_active (prefs->prompt_empty_subject, mail_config_get_prompt_empty_subject ()); + gtk_signal_connect (GTK_OBJECT (prefs->prompt_empty_subject), "toggled", + toggle_button_toggled, prefs); prefs->prompt_bcc_only = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptBccOnly")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/prompts/only_bcc", NULL); - gtk_toggle_button_set_active (prefs->prompt_bcc_only, bool); - g_signal_connect (prefs->prompt_bcc_only, "toggled", G_CALLBACK (toggle_button_toggled), prefs); + gtk_toggle_button_set_active (prefs->prompt_bcc_only, mail_config_get_prompt_only_bcc ()); + gtk_signal_connect (GTK_OBJECT (prefs->prompt_bcc_only), "toggled", + toggle_button_toggled, prefs); prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset")); - buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/composer/charset", NULL); - menu = e_charset_picker_new (buf ? buf : e_iconv_locale_charset ()); + menu = e_charset_picker_new (mail_config_get_default_charset ()); gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu)); option_menu_connect (prefs->charset, prefs); - g_free (buf); -#warning "gtkhtml prop manager" -#if 0 /* Spell Checking: GtkHTML part */ prefs->pman = GTK_HTML_PROPMANAGER (gtk_html_propmanager_new (NULL)); - g_signal_connect (prefs->pman, "changed", G_CALLBACK(toggle_button_toggled), prefs); - g_object_ref (prefs->pman); + gtk_signal_connect (GTK_OBJECT (prefs->pman), "changed", toggle_button_toggled, prefs); + gtk_object_ref (GTK_OBJECT (prefs->pman)); gtk_html_propmanager_set_names (prefs->pman, names); gtk_html_propmanager_set_gui (prefs->pman, gui, NULL); -#endif - + /* Spell Checking: GNOME Spell part */ prefs->colour = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, "colorpickerSpellCheckColor")); - prefs->language = GTK_TREE_VIEW (glade_xml_get_widget (gui, "clistSpellCheckLanguage")); - model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model (prefs->language, (GtkTreeModel *) model); - gtk_tree_view_insert_column_with_attributes (prefs->language, -1, _("Enabled"), - gtk_cell_renderer_toggle_new (), - "active", 0, - NULL); - gtk_tree_view_insert_column_with_attributes (prefs->language, -1, _("Language(s)"), - gtk_cell_renderer_text_new (), - "text", 1, - NULL); - selection = gtk_tree_view_get_selection (prefs->language); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - g_signal_connect (selection, "changed", G_CALLBACK (spell_language_selection_changed), prefs); -#if 0 - gtk_clist_set_column_justification (prefs->language, 0, GTK_JUSTIFY_RIGHT); - gtk_clist_set_column_auto_resize (prefs->language, 0, TRUE); -#endif - + prefs->language = GTK_CLIST (glade_xml_get_widget (gui, "clistSpellCheckLanguage")); prefs->spell_able_button = glade_xml_get_widget (gui, "buttonSpellCheckEnable"); info_pixmap = glade_xml_get_widget (gui, "pixmapSpellInfo"); - gtk_image_set_from_file (GTK_IMAGE (info_pixmap), EVOLUTION_IMAGES "/info-bulb.png"); + gtk_clist_set_column_justification (prefs->language, 0, GTK_JUSTIFY_RIGHT); + gtk_clist_set_column_auto_resize (prefs->language, 0, TRUE); + gnome_pixmap_load_file (GNOME_PIXMAP (info_pixmap), EVOLUTION_IMAGES "/info-bulb.png"); + if (!spell_setup_check_options (prefs)) { gtk_widget_hide (GTK_WIDGET (prefs->colour)); gtk_widget_hide (GTK_WIDGET (prefs->language)); @@ -859,55 +859,48 @@ mail_composer_prefs_construct (MailComposerPrefs *prefs) /* Forwards and Replies */ prefs->forward_style = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuForwardStyle")); - style = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/format/forward_style", NULL); - gtk_option_menu_set_history (prefs->forward_style, style); + gtk_option_menu_set_history (prefs->forward_style, mail_config_get_default_forward_style ()); style = 0; gtk_container_foreach (GTK_CONTAINER (gtk_option_menu_get_menu (prefs->forward_style)), attach_style_info, &style); option_menu_connect (prefs->forward_style, prefs); prefs->reply_style = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuReplyStyle")); - style = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/format/reply_style", NULL); - gtk_option_menu_set_history (prefs->reply_style, style); + gtk_option_menu_set_history (prefs->reply_style, mail_config_get_default_reply_style ()); style = 0; gtk_container_foreach (GTK_CONTAINER (gtk_option_menu_get_menu (prefs->reply_style)), attach_style_info, &style); option_menu_connect (prefs->reply_style, prefs); /* Signatures */ - dialog = (GtkDialog *) gtk_dialog_new (); - prefs->sig_script_dialog = (GtkWidget *) dialog; - gtk_dialog_add_buttons (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); - gtk_window_set_title ((GtkWindow *) dialog, _("Add script signature")); - g_signal_connect (dialog, "response", G_CALLBACK (sig_add_script_response), prefs); - widget = glade_xml_get_widget (prefs->sig_script_gui, "vbox_add_script_signature"); - gtk_box_pack_start_defaults ((GtkBox *) dialog->vbox, widget); - prefs->sig_add = GTK_BUTTON (glade_xml_get_widget (gui, "cmdSignatureAdd")); - g_signal_connect (prefs->sig_add, "clicked", G_CALLBACK (sig_add_cb), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->sig_add), "clicked", + GTK_SIGNAL_FUNC (sig_add), prefs); - glade_xml_signal_connect_data (gui, "cmdSignatureAddScriptClicked", - G_CALLBACK (sig_add_script_cb), prefs); + prefs->sig_script_dialog = gnome_dialog_new (_("Add script signature"), + _("Add Signature"), GNOME_STOCK_BUTTON_CANCEL, NULL); + gnome_dialog_close_hides (GNOME_DIALOG (prefs->sig_script_dialog), TRUE); + gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (prefs->sig_script_dialog)->vbox), + glade_xml_get_widget (prefs->sig_script_gui, "vbox_add_script_signature")); + gnome_dialog_button_connect (GNOME_DIALOG (prefs->sig_script_dialog), 0, sig_add_script_add, prefs); + gnome_dialog_button_connect (GNOME_DIALOG (prefs->sig_script_dialog), 1, sig_add_script_cancel, prefs); + + glade_xml_signal_connect_data (gui, "cmdSignatureAddScriptClicked", sig_add_script, prefs); prefs->sig_edit = GTK_BUTTON (glade_xml_get_widget (gui, "cmdSignatureEdit")); - g_signal_connect (prefs->sig_edit, "clicked", G_CALLBACK (sig_edit_cb), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->sig_edit), "clicked", + GTK_SIGNAL_FUNC (sig_edit), prefs); prefs->sig_delete = GTK_BUTTON (glade_xml_get_widget (gui, "cmdSignatureDelete")); - g_signal_connect (prefs->sig_delete, "clicked", G_CALLBACK (sig_delete_cb), prefs); - - prefs->sig_list = GTK_TREE_VIEW (glade_xml_get_widget (gui, "clistSignatures")); - model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model (prefs->sig_list, (GtkTreeModel *)model); - gtk_tree_view_insert_column_with_attributes (prefs->sig_list, -1, _("Signature(s)"), - gtk_cell_renderer_text_new (), - "text", 0, - NULL); - selection = gtk_tree_view_get_selection (prefs->sig_list); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - g_signal_connect (selection, "changed", G_CALLBACK (sig_selection_changed), prefs); - - sig_fill_clist (prefs->sig_list); + gtk_signal_connect (GTK_OBJECT (prefs->sig_delete), "clicked", + GTK_SIGNAL_FUNC (sig_delete), prefs); + + prefs->sig_clist = GTK_CLIST (glade_xml_get_widget (gui, "clistSignatures")); + sig_fill_clist (prefs->sig_clist); + gtk_signal_connect (GTK_OBJECT (prefs->sig_clist), "select_row", + GTK_SIGNAL_FUNC (sig_row_select), prefs); + gtk_signal_connect (GTK_OBJECT (prefs->sig_clist), "unselect_row", + GTK_SIGNAL_FUNC (sig_row_unselect), prefs); if (mail_config_get_signature_list () == NULL) { gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_delete, FALSE); gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_edit, FALSE); @@ -916,10 +909,13 @@ mail_composer_prefs_construct (MailComposerPrefs *prefs) /* preview GtkHTML widget */ widget = glade_xml_get_widget (gui, "scrolled-sig"); prefs->sig_preview = (GtkHTML *) gtk_html_new (); - g_signal_connect (prefs->sig_preview, "url_requested", G_CALLBACK (url_requested), NULL); + gtk_signal_connect (GTK_OBJECT (prefs->sig_preview), "url_requested", GTK_SIGNAL_FUNC (url_requested), NULL); gtk_widget_show (GTK_WIDGET (prefs->sig_preview)); gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (prefs->sig_preview)); + if (GTK_CLIST (prefs->sig_clist)->rows) + gtk_clist_select_row (GTK_CLIST (prefs->sig_clist), 0, 0); + mail_config_signature_register_client ((MailConfigSignatureClient) sig_event_client, prefs); } @@ -929,7 +925,7 @@ mail_composer_prefs_new (void) { MailComposerPrefs *new; - new = (MailComposerPrefs *) g_object_new (mail_composer_prefs_get_type (), NULL); + new = (MailComposerPrefs *) gtk_type_new (mail_composer_prefs_get_type ()); mail_composer_prefs_construct (new); return (GtkWidget *) new; @@ -946,45 +942,35 @@ mail_composer_prefs_apply (MailComposerPrefs *prefs) /* General tab */ /* Default Behavior */ - gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/composer/send_html", - gtk_toggle_button_get_active (prefs->send_html), NULL); - - gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/prompts/empty_subject", - gtk_toggle_button_get_active (prefs->prompt_empty_subject), NULL); - - gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/prompts/only_bcc", - gtk_toggle_button_get_active (prefs->prompt_bcc_only), NULL); + mail_config_set_send_html (gtk_toggle_button_get_active (prefs->send_html)); + mail_config_set_prompt_empty_subject (gtk_toggle_button_get_active (prefs->prompt_empty_subject)); + mail_config_set_prompt_only_bcc (gtk_toggle_button_get_active (prefs->prompt_bcc_only)); menu = gtk_option_menu_get_menu (prefs->charset); - if (!(string = e_charset_picker_get_charset (menu))) - string = g_strdup (e_iconv_locale_charset ()); - - gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/composer/charset", string, NULL); - g_free (string); + string = e_charset_picker_get_charset (menu); + if (string) { + mail_config_set_default_charset (string); + g_free (string); + } /* Spell Checking */ -#warning "gtkhtml propmanager" -#if 0 gtk_html_propmanager_apply (prefs->pman); -#endif spell_apply (prefs); /* Forwards and Replies */ menu = gtk_option_menu_get_menu (prefs->forward_style); item = gtk_menu_get_active (GTK_MENU (menu)); - val = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "style")); - gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/format/forward_style", val, NULL); + val = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (item), "style")); + mail_config_set_default_forward_style (val); menu = gtk_option_menu_get_menu (prefs->reply_style); item = gtk_menu_get_active (GTK_MENU (menu)); - val = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "style")); - gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/format/reply_style", val, NULL); + val = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (item), "style")); + mail_config_set_default_reply_style (val); /* Keyboard Shortcuts */ /* FIXME: implement me */ /* Signatures */ /* FIXME: implement me */ - - gconf_client_suggest_sync (prefs->gconf, NULL); } diff --git a/mail/mail-config-druid.c b/mail/mail-config-druid.c index 6210d8177b..6afa19b642 100644 --- a/mail/mail-config-druid.c +++ b/mail/mail-config-druid.c @@ -23,7 +23,6 @@ * */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -33,23 +32,38 @@ #include <string.h> #include <unistd.h> -#include <gal/util/e-util.h> -#include <glade/glade.h> -#include <gtkhtml/gtkhtml.h> #include <libgnomeui/gnome-dialog.h> #include <libgnomeui/gnome-dialog-util.h> #include <libgnomeui/gnome-druid.h> #include <libgnomeui/gnome-druid-page-standard.h> -#include <bonobo/bonobo-exception.h> - +#include <glade/glade.h> +#include <gtkhtml/gtkhtml.h> +#include <gal/widgets/e-unicode.h> #include "mail-config-druid.h" #include "mail-config.h" #include "mail-ops.h" #include "mail.h" #include "mail-session.h" +#include <bonobo/bonobo-exception.h> +#include <bonobo/bonobo-control.h> +#include <bonobo/bonobo-widget.h> +#include <bonobo/bonobo-generic-factory.h> +#include <bonobo/bonobo-context.h> + #include <evolution-wizard.h> -#include <e-util/e-account.h> + +static void mail_config_druid_class_init (MailConfigDruidClass *class); +static void mail_config_druid_finalize (GtkObject *obj); + +static GtkWindowClass *parent_class; + +/* These globals need fixed FIXME FIXME FIXME FIXME*/ +static GHashTable *page_hash = NULL; +static GList *page_list = NULL; +static EvolutionWizard *account_wizard; + +#define WIZARD_IID "OAFIID:GNOME_Evolution_Mail_Wizard_Factory" typedef enum { MAIL_CONFIG_WIZARD_PAGE_NONE = -1, @@ -58,202 +72,294 @@ typedef enum { MAIL_CONFIG_WIZARD_PAGE_EXTRA, MAIL_CONFIG_WIZARD_PAGE_TRANSPORT, MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT, - - MAIL_CONFIG_WIZARD_NUM_PAGES } MailConfigWizardPage; typedef struct { - /* Only one of these will be set */ - GnomeDruid *druid; - EvolutionWizard *corba_wizard; - MailAccountGui *gui; - GPtrArray *interior_pages; - GnomeDruidPage *last_page; + MailConfigAccount *account; + EvolutionWizard *wizard; gboolean identity_copied; CamelProvider *last_source; MailConfigWizardPage page; } MailConfigWizard; +GtkType +mail_config_druid_get_type (void) +{ + static GtkType type = 0; + + if (!type) { + GtkTypeInfo type_info = { + "MailConfigDruid", + sizeof (MailConfigDruid), + sizeof (MailConfigDruidClass), + (GtkClassInitFunc) mail_config_druid_class_init, + (GtkObjectInitFunc) NULL, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + type = gtk_type_unique (gtk_window_get_type (), &type_info); + } + + return type; +} + +static void +mail_config_druid_class_init (MailConfigDruidClass *class) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass *) class; + parent_class = gtk_type_class (gtk_window_get_type ()); + + /* override methods */ + object_class->finalize = mail_config_druid_finalize; +} + +static void +mail_config_druid_finalize (GtkObject *obj) +{ + MailConfigDruid *druid = (MailConfigDruid *) obj; + CORBA_Environment ev; + + gtk_object_destroy (GTK_OBJECT (druid->xml)); + + CORBA_exception_init (&ev); + Bonobo_EventSource_removeListener ((Bonobo_EventSource) druid->event_source, druid->id, &ev); + CORBA_exception_free (&ev); + + bonobo_object_release_unref ((Bonobo_Unknown) druid->event_source, &ev); + bonobo_object_unref (BONOBO_OBJECT (druid->listener)); + + ((GtkObjectClass *)(parent_class))->finalize (obj); +} +static struct { + char *name; + char *text; +} info[] = { + { "identity_html", + N_("Please enter your name and email address below. The \"optional\" fields below do not need to be filled in, unless you wish to include this information in email you send.") }, + { "source_html", + N_("Please enter information about your incoming mail server below. If you are not sure, ask your system administrator or Internet Service Provider.") }, + { "extra_html", + N_("Please select among the following options") }, + { "transport_html", + N_("Please enter information about the way you will send mail. If you are not sure, ask your system administrator or Internet Service Provider.") }, + { "management_html", + N_("You are almost done with the mail configuration process. The identity, incoming mail server and outgoing mail transport method which you provided will be grouped together to make an Evolution mail account. Please enter a name for this account in the space below. This name will be used for display purposes only.") } +}; +static int num_info = (sizeof (info) / sizeof (info[0])); + +static GtkWidget * +create_label (const char *name) +{ + GtkWidget *widget, *align; + int i; + + for (i = 0; i < num_info; i++) { + if (!strcmp (name, info[i].name)) + break; + } + + g_return_val_if_fail (i != num_info, NULL); + + widget = gtk_label_new (_(info[i].text)); + gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); + gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_FILL); + gtk_widget_show (widget); + + align = gtk_alignment_new (0.0, 0.5, 1.0, 1.0); + gtk_container_add (GTK_CONTAINER (align), widget); + + gtk_widget_show (align); + + return align; +} static void -config_wizard_set_buttons_sensitive (MailConfigWizard *mcw, - gboolean prev_sensitive, - gboolean next_sensitive) -{ - if (mcw->corba_wizard) { - evolution_wizard_set_buttons_sensitive (mcw->corba_wizard, - prev_sensitive, - next_sensitive, - TRUE, NULL); - } else { - gnome_druid_set_buttons_sensitive (mcw->druid, - prev_sensitive, - next_sensitive, - TRUE, FALSE); +druid_cancel (GnomeDruid *druid, gpointer user_data) +{ + MailConfigDruid *config = user_data; + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); + + GNOME_Evolution_Wizard_notifyAction (wiz, 0, GNOME_Evolution_Wizard_CANCEL, &ev); + CORBA_exception_free (&ev); + + if (page_list != NULL) { + g_list_free (page_list); + page_list = NULL; + } + + if (page_hash != NULL) { + g_hash_table_destroy (page_hash); + page_hash = NULL; } + + gtk_widget_destroy (GTK_WIDGET (config)); } static void -config_wizard_set_page (MailConfigWizard *mcw, MailConfigWizardPage page) +druid_finish (GnomeDruidPage *page, gpointer arg1, gpointer user_data) { - if (mcw->corba_wizard) - evolution_wizard_set_page (mcw->corba_wizard, page, NULL); - else { - if (page <= mcw->interior_pages->len) - gnome_druid_set_page (mcw->druid, mcw->interior_pages->pdata[page]); - else - gnome_druid_set_page (mcw->druid, mcw->last_page); + MailConfigDruid *druid = user_data; + + gtk_object_set_data (GTK_OBJECT (account_wizard), "account-data", NULL); + if (page_list != NULL) { + g_list_free (page_list); + page_list = NULL; + } + + if (page_hash != NULL) { + g_hash_table_destroy (page_hash); + page_hash = NULL; } + + gtk_widget_destroy (GTK_WIDGET (druid)); } /* Identity Page */ static void identity_changed (GtkWidget *widget, gpointer data) { - MailConfigWizard *mcw = data; + MailConfigWizard *gui = data; GtkWidget *incomplete; gboolean next_sensitive; - if (mcw->page != MAIL_CONFIG_WIZARD_PAGE_IDENTITY) + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_IDENTITY) return; - next_sensitive = mail_account_gui_identity_complete (mcw->gui, &incomplete); + next_sensitive = mail_account_gui_identity_complete (gui->gui, &incomplete); - config_wizard_set_buttons_sensitive (mcw, TRUE, next_sensitive); + evolution_wizard_set_buttons_sensitive (gui->wizard, TRUE, next_sensitive, TRUE, NULL); if (!next_sensitive) gtk_widget_grab_focus (incomplete); } static void -identity_prepare (MailConfigWizard *mcw) +identity_prepare (EvolutionWizard *wizard, gpointer data) { + MailConfigWizard *gui = data; const char *name; - mcw->page = MAIL_CONFIG_WIZARD_PAGE_IDENTITY; + gui->page = MAIL_CONFIG_WIZARD_PAGE_IDENTITY; - name = gtk_entry_get_text (mcw->gui->full_name); + name = gtk_entry_get_text (gui->gui->full_name); if (!name) { name = g_get_real_name (); - gtk_entry_set_text (mcw->gui->full_name, name ? name : ""); - gtk_editable_select_region (GTK_EDITABLE (mcw->gui->full_name), 0, -1); + gtk_entry_set_text (gui->gui->full_name, name ? name : ""); + gtk_entry_select_region (gui->gui->full_name, 0, -1); } - gtk_widget_grab_focus (GTK_WIDGET (mcw->gui->full_name)); - identity_changed (NULL, mcw); + gtk_widget_grab_focus (GTK_WIDGET (gui->gui->full_name)); + identity_changed (NULL, data); } static gboolean -identity_next (MailConfigWizard *mcw) +identity_next (EvolutionWizard *wizard, gpointer data) { - if (!mcw->identity_copied) { + MailConfigWizard *gui = data; + + if (!gui->identity_copied) { char *username; - const char *user; - + /* Copy the username part of the email address into * the Username field of the source and transport pages. */ - user = gtk_entry_get_text (mcw->gui->email_address); - username = g_strndup (user, strcspn (user, "@")); - gtk_entry_set_text (mcw->gui->source.username, username); - gtk_entry_set_text (mcw->gui->transport.username, username); + username = gtk_entry_get_text (gui->gui->email_address); + username = g_strndup (username, strcspn (username, "@")); + gtk_entry_set_text (gui->gui->source.username, username); + gtk_entry_set_text (gui->gui->transport.username, username); g_free (username); - mcw->identity_copied = TRUE; + gui->identity_copied = TRUE; } return FALSE; } -static void -identity_activate_cb (GtkEntry *ent, gpointer user_data) -{ - MailConfigWizard *mcw = user_data; - - if (mail_account_gui_identity_complete (mcw->gui, NULL) && - !identity_next (mcw)) - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_SOURCE); -} - /* Incoming mail Page */ static void source_changed (GtkWidget *widget, gpointer data) { - MailConfigWizard *mcw = data; + MailConfigWizard *gui = data; GtkWidget *incomplete; gboolean next_sensitive; - if (mcw->page != MAIL_CONFIG_WIZARD_PAGE_SOURCE) + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_SOURCE) return; - next_sensitive = mail_account_gui_source_complete (mcw->gui, &incomplete); + next_sensitive = mail_account_gui_source_complete (gui->gui, &incomplete); - config_wizard_set_buttons_sensitive (mcw, TRUE, next_sensitive); + evolution_wizard_set_buttons_sensitive (gui->wizard, TRUE, next_sensitive, TRUE, NULL); if (!next_sensitive) gtk_widget_grab_focus (incomplete); } static void -source_prepare (MailConfigWizard *mcw) +source_prepare (EvolutionWizard *wizard, gpointer data) { - mcw->page = MAIL_CONFIG_WIZARD_PAGE_SOURCE; - source_changed (NULL, mcw); + MailConfigWizard *gui = data; + + gui->page = MAIL_CONFIG_WIZARD_PAGE_SOURCE; + source_changed (NULL, gui); } static gboolean -source_next (MailConfigWizard *mcw) +source_next (EvolutionWizard *wizard, gpointer data) { + MailConfigWizard *gui = data; + /* FIXME: if online, check that the data is good. */ - if (mcw->gui->source.provider && mcw->gui->source.provider->extra_conf) + if (gui->gui->source.provider && gui->gui->source.provider->extra_conf) return FALSE; /* Otherwise, skip to transport page. */ - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_TRANSPORT); + evolution_wizard_set_page (gui->wizard, MAIL_CONFIG_WIZARD_PAGE_TRANSPORT, NULL); + return TRUE; } -static void -source_activate_cb (GtkEntry *ent, gpointer user_data) -{ - MailConfigWizard *mcw = user_data; - - if (mail_account_gui_source_complete (mcw->gui, NULL) && - !source_next (mcw)) - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_EXTRA); -} - /* Extra Config Page */ static void -extra_prepare (MailConfigWizard *mcw) +extra_prepare (EvolutionWizard *wizard, gpointer data) { - mcw->page = MAIL_CONFIG_WIZARD_PAGE_EXTRA; - if (mcw->gui->source.provider != mcw->last_source) { - mcw->last_source = mcw->gui->source.provider; - mail_account_gui_auto_detect_extra_conf (mcw->gui); + MailConfigWizard *gui = data; + + gui->page = MAIL_CONFIG_WIZARD_PAGE_EXTRA; + if (gui->gui->source.provider != gui->last_source) { + gui->last_source = gui->gui->source.provider; + mail_account_gui_auto_detect_extra_conf (gui->gui); } } /* Transport Page */ static gboolean -transport_next (MailConfigWizard *mcw) +transport_next (EvolutionWizard *wizard, gpointer data) { /* FIXME: if online, check that the data is good. */ return FALSE; } static gboolean -transport_back (MailConfigWizard *mcw) +transport_back (EvolutionWizard *wizard, gpointer data) { - if (mcw->gui->source.provider && mcw->gui->source.provider->extra_conf) + MailConfigWizard *gui = data; + + if (gui->gui->source.provider && gui->gui->source.provider->extra_conf) return FALSE; else { - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_SOURCE); + evolution_wizard_set_page (wizard, MAIL_CONFIG_WIZARD_PAGE_SOURCE, NULL); return TRUE; } } @@ -261,66 +367,60 @@ transport_back (MailConfigWizard *mcw) static void transport_changed (GtkWidget *widget, gpointer data) { - MailConfigWizard *mcw = data; + MailConfigWizard *gui = data; GtkWidget *incomplete; gboolean next_sensitive; - if (mcw->page != MAIL_CONFIG_WIZARD_PAGE_TRANSPORT) + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_TRANSPORT) return; - next_sensitive = mail_account_gui_transport_complete (mcw->gui, &incomplete); + next_sensitive = mail_account_gui_transport_complete (gui->gui, &incomplete); - config_wizard_set_buttons_sensitive (mcw, TRUE, next_sensitive); + evolution_wizard_set_buttons_sensitive (gui->wizard, TRUE, next_sensitive, TRUE, NULL); if (!next_sensitive) gtk_widget_grab_focus (incomplete); } static void -transport_prepare (MailConfigWizard *mcw) -{ - mcw->page = MAIL_CONFIG_WIZARD_PAGE_TRANSPORT; - transport_changed (NULL, mcw); -} - -static void -transport_activate_cb (GtkEntry *ent, gpointer user_data) +transport_prepare (EvolutionWizard *wizard, gpointer data) { - MailConfigWizard *mcw = user_data; - - if (mail_account_gui_transport_complete (mcw->gui, NULL) && - !transport_next (mcw)) - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT); + MailConfigWizard *gui = data; + + gui->page = MAIL_CONFIG_WIZARD_PAGE_TRANSPORT; + transport_changed (NULL, data); } /* Management page */ static gboolean -management_check (MailConfigWizard *mcw) +management_check (MailConfigWizard *wizard) { gboolean next_sensitive; - const char *text; + char *text; - text = gtk_entry_get_text (mcw->gui->account_name); + text = gtk_entry_get_text (wizard->gui->account_name); next_sensitive = text && *text; /* no accounts with the same name */ if (next_sensitive && mail_config_get_account_by_name (text)) next_sensitive = FALSE; - config_wizard_set_buttons_sensitive (mcw, TRUE, next_sensitive); + evolution_wizard_set_buttons_sensitive (wizard->wizard, TRUE, + next_sensitive, TRUE, NULL); return next_sensitive; } static void -management_prepare (MailConfigWizard *mcw) +management_prepare (EvolutionWizard *wizard, gpointer data) { + MailConfigWizard *gui = data; const char *name, *text; - mcw->page = MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT; + gui->page = MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT; - text = gtk_entry_get_text (mcw->gui->account_name); + text = gtk_entry_get_text (gui->gui->account_name); if (!text || *text == '\0') { - name = gtk_entry_get_text(mcw->gui->email_address); + name = e_utf8_gtk_entry_get_text (gui->gui->email_address); if (name && *name) { if (mail_config_get_account_by_name (name)) { char *template; @@ -338,444 +438,630 @@ management_prepare (MailConfigWizard *mcw) } while (mail_config_get_account_by_name (name) && i != 0); } - gtk_entry_set_text(mcw->gui->account_name, name); + e_utf8_gtk_entry_set_text (gui->gui->account_name, name); } } - management_check (mcw); + management_check (gui); } static void management_changed (GtkWidget *widget, gpointer data) { - MailConfigWizard *mcw = data; + MailConfigWizard *gui = data; - if (mcw->page != MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT) + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT) return; - management_check (mcw); + management_check (gui); - gtk_widget_grab_focus (GTK_WIDGET (mcw->gui->account_name)); + gtk_widget_grab_focus (GTK_WIDGET (gui->gui->account_name)); } -static void -management_activate_cb (GtkEntry *ent, gpointer user_data) +static MailConfigAccount * +make_account (void) { - MailConfigWizard *mcw = user_data; - - if (management_check (mcw)) - config_wizard_set_page (mcw, mcw->page + 1); + MailConfigAccount *account; + char *name, *user; + struct utsname uts; + + account = g_new0 (MailConfigAccount, 1); + + account->id = g_new0 (MailConfigIdentity, 1); + name = g_get_real_name (); + account->id->name = e_utf8_from_locale_string (name); + user = g_get_user_name (); + if (user && !uname (&uts) && strchr (uts.nodename, '.')) + account->id->address = g_strdup_printf ("%s@%s", user, uts.nodename); + + if (mail_config_get_default_transport ()) + account->transport = service_copy (mail_config_get_default_transport ()); + + return account; } +static const char *pages[] = { + "identity_page", + "source_page", + "extra_page", + "transport_page", + "management_page", + "finish_page", + NULL +}; -#define WIZARD_ICON(name) (EVOLUTION_IMAGES "/mail-config-druid-" name ".png") +static int +page_to_num (gpointer page) +{ + gpointer r; -static struct { - const char *page_name, *title, *icon_path; - void (*prepare_func) (MailConfigWizard *mcw); - gboolean (*back_func) (MailConfigWizard *mcw); - gboolean (*next_func) (MailConfigWizard *mcw); - const char *help_text; -} wizard_pages[] = { - { "identity_page", N_("Identity"), WIZARD_ICON ("identity"), - identity_prepare, NULL, identity_next, - N_("Please enter your name and email address below. " - "The \"optional\" fields below do not need to be " - "filled in, unless you wish to include this " - "information in email you send.") - }, - - { "source_page", N_("Receiving Mail"), WIZARD_ICON ("receive"), - source_prepare, NULL, source_next, - N_("Please enter information about your incoming " - "mail server below. If you are not sure, ask your " - "system administrator or Internet Service Provider.") - }, - - { "extra_page", N_("Receiving Mail"), WIZARD_ICON ("receive"), - extra_prepare, NULL, NULL, - N_("Please select among the following options") - }, - - { "transport_page", N_("Sending Mail"), WIZARD_ICON ("send"), - transport_prepare, transport_back, transport_next, - N_("Please enter information about the way you will " - "send mail. If you are not sure, ask your system " - "administrator or Internet Service Provider.") - }, - - { "management_page", N_("Account Management"), WIZARD_ICON ("account-name"), - management_prepare, NULL, NULL, - N_("You are almost done with the mail configuration " - "process. The identity, incoming mail server and " - "outgoing mail transport method which you provided " - "will be grouped together to make an Evolution mail " - "account. Please enter a name for this account in " - "the space below. This name will be used for display " - "purposes only.") + r = g_hash_table_lookup (page_hash, page); + if (r == NULL) { + return 0; } -}; -static const int num_wizard_pages = sizeof (wizard_pages) / sizeof (wizard_pages[0]); -static GtkWidget * -get_page (GladeXML *xml, int page_num) + return GPOINTER_TO_INT (r); +} + +static gboolean +next_func (GnomeDruidPage *page, + GnomeDruid *druid, + gpointer data) { - GtkWidget *vbox, *widget; + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + int pagenum; - vbox = gtk_vbox_new (FALSE, 4); + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); - widget = gtk_label_new (_(wizard_pages[page_num].help_text)); - gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); - gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_FILL); - gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); - gtk_widget_show_all (vbox); - - switch (page_num) { - case MAIL_CONFIG_WIZARD_PAGE_IDENTITY: - widget = glade_xml_get_widget (xml, "identity_required_frame"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); - widget = glade_xml_get_widget (xml, "identity_optional_frame"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); - break; + pagenum = page_to_num (page); + GNOME_Evolution_Wizard_notifyAction (wiz, pagenum, GNOME_Evolution_Wizard_NEXT, &ev); + CORBA_exception_free (&ev); - case MAIL_CONFIG_WIZARD_PAGE_SOURCE: - widget = glade_xml_get_widget (xml, "source_vbox"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - break; + if (pagenum < 5-1) + return TRUE; - case MAIL_CONFIG_WIZARD_PAGE_EXTRA: - widget = glade_xml_get_widget (xml, "extra_table"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - break; + return FALSE; +} - case MAIL_CONFIG_WIZARD_PAGE_TRANSPORT: - widget = glade_xml_get_widget (xml, "transport_vbox"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - break; +static gboolean +prepare_func (GnomeDruidPage *page, + GnomeDruid *druid, + gpointer data) +{ + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + int pagenum; - case MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT: - widget = glade_xml_get_widget (xml, "management_frame"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - break; + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); - default: - g_return_val_if_reached (NULL); - } - - return vbox; + pagenum = page_to_num (page); + GNOME_Evolution_Wizard_notifyAction (wiz, pagenum, GNOME_Evolution_Wizard_PREPARE, &ev); + CORBA_exception_free (&ev); + return FALSE; +} + +static gboolean +back_func (GnomeDruidPage *page, + GnomeDruid *druid, + gpointer data) +{ + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + int pagenum; + + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); + + pagenum = page_to_num (page); + GNOME_Evolution_Wizard_notifyAction (wiz, pagenum, GNOME_Evolution_Wizard_BACK, &ev); + CORBA_exception_free (&ev); + + if (pagenum > 0) + return TRUE; + + return FALSE; } +static gboolean +finish_func (GnomeDruidPage *page, + GnomeDruid *druid, + gpointer data) +{ + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + int pagenum; + + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); + + pagenum = page_to_num (page); + GNOME_Evolution_Wizard_notifyAction (wiz, 0, GNOME_Evolution_Wizard_FINISH, &ev); + CORBA_exception_free (&ev); -static MailConfigWizard * -config_wizard_new (void) + druid_finish (page, druid, data); + return FALSE; +} + +static void +wizard_listener_event (BonoboListener *listener, + char *event_name, + BonoboArg *event_data, + CORBA_Environment *ev, + MailConfigDruid *druid) { - MailConfigWizard *mcw; - const char *name, *user; - EAccountService *xport; - struct utsname uts; - EAccount *account; - - /* Create a new account object with some defaults */ - account = e_account_new (); - account->enabled = TRUE; + CORBA_short buttons, pagenum; + GnomeDruidPage *page; + + if (strcmp (event_name, EVOLUTION_WIZARD_SET_BUTTONS_SENSITIVE) == 0) { + buttons = (int) *((CORBA_short *)event_data->_value); + gnome_druid_set_buttons_sensitive (GNOME_DRUID (druid->druid), + (buttons & 4) >> 2, + (buttons & 2) >> 1, + (buttons & 1)); + } else if (strcmp (event_name, EVOLUTION_WIZARD_SET_SHOW_FINISH) == 0) { + gnome_druid_set_show_finish (GNOME_DRUID (druid->druid), + (gboolean) *((CORBA_boolean *)event_data->_value)); + } else if (strcmp (event_name, EVOLUTION_WIZARD_SET_PAGE) == 0) { + pagenum = (int) *((CORBA_short *) event_data->_value); + + page = g_list_nth_data (page_list, pagenum); + gnome_druid_set_page (GNOME_DRUID (druid->druid), page); + } +} + +static void +construct (MailConfigDruid *druid) +{ + GtkWidget *widget; + GNOME_Evolution_Wizard corba_wizard; + Bonobo_Listener corba_listener; + CORBA_Environment ev; + int i; + + /* Start account wizard */ + CORBA_exception_init (&ev); + corba_wizard = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Mail_Wizard", 0, NULL, &ev); + CORBA_exception_free (&ev); + g_assert (account_wizard != NULL); - name = g_get_real_name (); - account->id->name = g_strdup (name); - user = g_get_user_name (); - if (user && !uname (&uts) && strchr (uts.nodename, '.')) - account->id->address = g_strdup_printf ("%s@%s", user, uts.nodename); + druid->xml = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL); + /* get our toplevel widget and reparent it */ + widget = glade_xml_get_widget (druid->xml, "druid"); + gtk_widget_reparent (widget, GTK_WIDGET (druid)); - if ((xport = mail_config_get_default_transport ())) { - account->transport->url = g_strdup (xport->url); - account->transport->save_passwd = xport->save_passwd; + druid->druid = GNOME_DRUID (widget); + + /* set window title */ + gtk_window_set_title (GTK_WINDOW (druid), _("Evolution Account Assistant")); + gtk_window_set_policy (GTK_WINDOW (druid), FALSE, TRUE, FALSE); + gtk_window_set_modal (GTK_WINDOW (druid), FALSE); + gtk_object_set (GTK_OBJECT (druid), "type", GTK_WINDOW_DIALOG, NULL); + + druid->listener = bonobo_listener_new (NULL, NULL); + gtk_signal_connect (GTK_OBJECT (druid->listener), "event-notify", + GTK_SIGNAL_FUNC (wizard_listener_event), druid); + corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (druid->listener)); + CORBA_exception_init (&ev); + druid->event_source = (Bonobo_Unknown) bonobo_object_query_interface ( + BONOBO_OBJECT (account_wizard), "IDL:Bonobo/EventSource:1.0"); + g_assert (druid->event_source != CORBA_OBJECT_NIL); + druid->id = Bonobo_EventSource_addListener ((Bonobo_EventSource) druid->event_source, corba_listener, &ev); + if (BONOBO_EX (&ev)) { + g_warning ("Error adding listener (%s)", + CORBA_exception_id (&ev)); + } + CORBA_exception_free (&ev); + + if (page_hash != NULL) { + g_hash_table_destroy (page_hash); } + page_hash = g_hash_table_new (NULL, NULL); + for (i = 0; pages[i] != NULL; i++) { + GtkWidget *page; + GnomeDruidPageStandard *dpage; + + page = glade_xml_get_widget (druid->xml, pages[i]); + /* Store pages */ + g_hash_table_insert (page_hash, page, GINT_TO_POINTER (i)); + page_list = g_list_append (page_list, page); + + gtk_signal_connect (GTK_OBJECT (page), "next", + GTK_SIGNAL_FUNC (next_func), druid); + gtk_signal_connect (GTK_OBJECT (page), "prepare", + GTK_SIGNAL_FUNC (prepare_func), druid); + gtk_signal_connect (GTK_OBJECT (page), "back", + GTK_SIGNAL_FUNC (back_func), druid); - /* Create the config wizard object */ - mcw = g_new0 (MailConfigWizard, 1); - mcw->gui = mail_account_gui_new (account, NULL); - g_object_unref (account); - - /* Set up gui */ - g_signal_connect (mcw->gui->account_name, "changed", - G_CALLBACK (management_changed), mcw); - g_signal_connect (mcw->gui->full_name, "changed", - G_CALLBACK (identity_changed), mcw); - g_signal_connect (mcw->gui->email_address, "changed", - G_CALLBACK (identity_changed), mcw); - g_signal_connect (mcw->gui->reply_to,"changed", - G_CALLBACK (identity_changed), mcw); - g_signal_connect (mcw->gui->source.hostname, "changed", - G_CALLBACK (source_changed), mcw); - g_signal_connect (mcw->gui->source.username, "changed", - G_CALLBACK (source_changed), mcw); - g_signal_connect (mcw->gui->source.path, "changed", - G_CALLBACK (source_changed), mcw); - g_signal_connect (mcw->gui->transport.hostname, "changed", - G_CALLBACK (transport_changed), mcw); - g_signal_connect (mcw->gui->transport.username, "changed", - G_CALLBACK (transport_changed), mcw); - g_signal_connect (mcw->gui->transport_needs_auth, "toggled", - G_CALLBACK (transport_changed), mcw); - - g_signal_connect (mcw->gui->account_name, "activate", - G_CALLBACK (management_activate_cb), mcw); - - g_signal_connect (mcw->gui->full_name, "activate", - G_CALLBACK (identity_activate_cb), mcw); - g_signal_connect (mcw->gui->email_address, "activate", - G_CALLBACK (identity_activate_cb), mcw); - g_signal_connect (mcw->gui->reply_to,"activate", - G_CALLBACK (identity_activate_cb), mcw); - g_signal_connect (mcw->gui->organization, "activate", - G_CALLBACK (identity_activate_cb), mcw); - - g_signal_connect (mcw->gui->source.hostname, "activate", - G_CALLBACK (source_activate_cb), mcw); - g_signal_connect (mcw->gui->source.username, "activate", - G_CALLBACK (source_activate_cb), mcw); - g_signal_connect (mcw->gui->source.path, "activate", - G_CALLBACK (source_activate_cb), mcw); - - g_signal_connect (mcw->gui->transport.hostname, "activate", - G_CALLBACK (transport_activate_cb), mcw); - g_signal_connect (mcw->gui->transport.username, "activate", - G_CALLBACK (transport_activate_cb), mcw); - - return mcw; + gtk_signal_connect (GTK_OBJECT (page), "finish", + GTK_SIGNAL_FUNC (finish_func), druid); + + if (i != 5) { + Bonobo_Control control; + GtkWidget *w; + CORBA_Environment ev; + + dpage = GNOME_DRUID_PAGE_STANDARD (page); + + CORBA_exception_init (&ev); + control = GNOME_Evolution_Wizard_getControl (corba_wizard, i, &ev); + if (BONOBO_EX (&ev)) { + g_warning ("Error getting page %d: %s", i, + CORBA_exception_id (&ev)); + CORBA_exception_free (&ev); + continue; + } + + w = bonobo_widget_new_control_from_objref (control, + CORBA_OBJECT_NIL); + gtk_box_pack_start (GTK_BOX (dpage->vbox), w, TRUE, + TRUE, 0); + gtk_widget_show_all (w); + } + } + gtk_signal_connect (GTK_OBJECT (druid->druid), "cancel", druid_cancel, druid); + + gnome_druid_set_buttons_sensitive (druid->druid, FALSE, TRUE, TRUE); } -static void -free_config_wizard (MailConfigWizard *mcw) +MailConfigDruid * +mail_config_druid_new (GNOME_Evolution_Shell shell) { - mail_account_gui_destroy (mcw->gui); + MailConfigDruid *new; - if (mcw->interior_pages) - g_ptr_array_free (mcw->interior_pages, TRUE); + new = (MailConfigDruid *) gtk_type_new (mail_config_druid_get_type ()); + construct (new); + new->shell = shell; - g_free (mcw); + return new; } -/* In-proc config druid */ +static void wizard_next_cb (EvolutionWizard *wizard, int page_num, MailConfigWizard *gui); static void -druid_cancel (GnomeDruid *druid, gpointer user_data) +goto_next_page (MailConfigWizard *gui) { - MailConfigWizard *mcw = user_data; - GtkWidget *window; - - window = glade_xml_get_widget (mcw->gui->xml, "account_druid"); - gtk_widget_destroy (window); - - free_config_wizard (mcw); + wizard_next_cb (gui->wizard, gui->page, gui); } static void -druid_finish (GnomeDruidPage *page, GnomeDruid *druid, gpointer user_data) +identity_activate_cb (GtkEntry *ent, gpointer user_data) { - MailConfigWizard *mcw = user_data; + MailConfigWizard *gui = (MailConfigWizard *) user_data; - mail_account_gui_save (mcw->gui); - druid_cancel (druid, user_data); + if (mail_account_gui_identity_complete (gui->gui, NULL)) + goto_next_page (gui); } static void -druid_prepare (GnomeDruidPage *page, GnomeDruid *druid, gpointer data) +source_activate_cb (GtkEntry *ent, gpointer user_data) { - MailConfigWizard *mcw = g_object_get_data (G_OBJECT (druid), "MailConfigWizard"); - int page_num = GPOINTER_TO_INT (data); + MailConfigWizard *gui = (MailConfigWizard *) user_data; - if (wizard_pages[page_num].prepare_func) - wizard_pages[page_num].prepare_func (mcw); + if (mail_account_gui_source_complete (gui->gui, NULL)) + goto_next_page (gui); } - -static gboolean -druid_back (GnomeDruidPage *page, GnomeDruid *druid, gpointer data) -{ - MailConfigWizard *mcw = g_object_get_data (G_OBJECT (druid), "MailConfigWizard"); - int page_num = GPOINTER_TO_INT (data); - if (wizard_pages[page_num].back_func) - return wizard_pages[page_num].back_func (mcw); - else - return FALSE; -} - -static gboolean -druid_next (GnomeDruidPage *page, GnomeDruid *druid, gpointer data) +static void +transport_activate_cb (GtkEntry *ent, gpointer user_data) { - MailConfigWizard *mcw = g_object_get_data (G_OBJECT (druid), "MailConfigWizard"); - int page_num = GPOINTER_TO_INT (data); + MailConfigWizard *gui = (MailConfigWizard *) user_data; - if (wizard_pages[page_num].next_func) - return wizard_pages[page_num].next_func (mcw); - else - return FALSE; + if (mail_account_gui_transport_complete (gui->gui, NULL)) + goto_next_page (gui); } - -MailConfigDruid * -mail_config_druid_new (void) +static void +management_activate_cb (GtkEntry *ent, gpointer user_data) { - MailConfigWizard *mcw; - GtkWidget *new, *page; - int i; + MailConfigWizard *gui = (MailConfigWizard *) user_data; - mcw = config_wizard_new (); - mcw->druid = (GnomeDruid *)glade_xml_get_widget (mcw->gui->xml, "druid"); - g_object_set_data (G_OBJECT (mcw->druid), "MailConfigWizard", mcw); - - mcw->interior_pages = g_ptr_array_new (); - for (i = 0; i < num_wizard_pages; i++) { - page = glade_xml_get_widget (mcw->gui->xml, - wizard_pages[i].page_name); - g_ptr_array_add (mcw->interior_pages, page); - gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (page)->vbox), - get_page (mcw->gui->xml, i), - FALSE, FALSE, 0); - g_signal_connect (page, "back", G_CALLBACK (druid_back), - GINT_TO_POINTER (i)); - g_signal_connect (page, "next", G_CALLBACK (druid_next), - GINT_TO_POINTER (i)); - - /* At least in 2.0 (and probably 2.2 too), - * GnomeDruidPageStandard is broken and you need to - * connect_after to "prepare" or else its default - * method will run after your signal handler and - * undo its button sensitivity changes. - */ - g_signal_connect_after (page, "prepare", - G_CALLBACK (druid_prepare), - GINT_TO_POINTER (i)); - } - g_signal_connect (mcw->druid, "cancel", G_CALLBACK (druid_cancel), mcw); + if (management_check (gui)) + goto_next_page (gui); +} - mcw->last_page = (GnomeDruidPage *)glade_xml_get_widget (mcw->gui->xml, "finish_page"); - g_signal_connect (mcw->last_page, "finish", G_CALLBACK (druid_finish), mcw); +static BonoboControl * +get_fn (EvolutionWizard *wizard, + int page_num, + void *closure) +{ + MailConfigWizard *gui = closure; + BonoboControl *control; + GtkWidget *vbox, *widget; + static gboolean first_time = TRUE; + + if (gui->gui == NULL) { + if (gui->account == NULL) { + gui->account = make_account (); + gtk_object_set_data (GTK_OBJECT (wizard), "account-data", + gui->account); + } + + gui->gui = mail_account_gui_new (gui->account, NULL); + + /* set up signals, etc */ + gtk_signal_connect (GTK_OBJECT (gui->gui->account_name), + "changed", management_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->full_name), + "changed", identity_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->email_address), + "changed", identity_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->reply_to), + "changed", identity_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.hostname), + "changed", source_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.username), + "changed", source_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.path), + "changed", source_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->transport.hostname), + "changed", transport_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->transport.username), + "changed", transport_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->transport_needs_auth), + "toggled", transport_changed, gui); + + gtk_signal_connect (GTK_OBJECT (gui->gui->account_name), + "activate", management_activate_cb, gui); + + gtk_signal_connect (GTK_OBJECT (gui->gui->full_name), + "activate", identity_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->email_address), + "activate", identity_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->reply_to), + "activate", identity_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->organization), + "activate", identity_activate_cb, gui); + + gtk_signal_connect (GTK_OBJECT (gui->gui->source.hostname), + "activate", source_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.username), + "activate", source_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.path), + "activate", source_activate_cb, gui); + + gtk_signal_connect (GTK_OBJECT (gui->gui->transport.hostname), + "activate", transport_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->transport.username), + "activate", transport_activate_cb, gui); + first_time = TRUE; + } + + /* Fill in the druid pages */ + vbox = gtk_vbox_new (FALSE, 0); + switch (page_num) { + case 0: + widget = create_label ("identity_html"); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + widget = glade_xml_get_widget (gui->gui->xml, "identity_required_frame"); + gtk_widget_reparent (widget, vbox); + gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); + widget = glade_xml_get_widget (gui->gui->xml, "identity_optional_frame"); + gtk_widget_reparent (widget, vbox); + gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); + break; + + case 1: + widget = create_label ("source_html"); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + widget = glade_xml_get_widget (gui->gui->xml, "source_vbox"); + gtk_widget_reparent (widget, vbox); + gtk_widget_show (widget); + break; + + case 2: + widget = create_label ("extra_html"); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + widget = glade_xml_get_widget (gui->gui->xml, "extra_vbox"); + gtk_widget_reparent (widget, vbox); + break; + + case 3: + widget = create_label ("transport_html"); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + widget = glade_xml_get_widget (gui->gui->xml, "transport_vbox"); + gtk_widget_reparent (widget, vbox); + gtk_widget_show (widget); + break; + + case 4: + widget = glade_xml_get_widget (gui->gui->xml, "management_frame"); + gtk_widget_reparent (widget, vbox); + break; - gnome_druid_set_buttons_sensitive (mcw->druid, FALSE, TRUE, TRUE, FALSE); - gtk_widget_show_all (GTK_WIDGET (mcw->druid)); - mail_account_gui_setup (mcw->gui, NULL); + default: + return NULL; + } + + gtk_widget_show (vbox); + control = bonobo_control_new (vbox); - new = glade_xml_get_widget (mcw->gui->xml, "account_druid"); - gtk_window_set_type_hint ((GtkWindow *) new, GDK_WINDOW_TYPE_HINT_DIALOG); + if (first_time) { + mail_account_gui_setup (gui->gui, NULL); + first_time = FALSE; + } - return (MailConfigDruid *) new; + return control; } +typedef gboolean (*NextFunc)(EvolutionWizard *wizard, gpointer data); -/* CORBA wizard */ +static struct { + NextFunc next_func; + GtkSignalFunc prepare_func; + NextFunc back_func; + GtkSignalFunc finish_func; + GtkSignalFunc help_func; +} wizard_pages[] = { + { identity_next, + GTK_SIGNAL_FUNC (identity_prepare), + NULL, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) }, + { source_next, + GTK_SIGNAL_FUNC (source_prepare), + NULL, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) }, + { NULL, + GTK_SIGNAL_FUNC (extra_prepare), + NULL, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) }, + { transport_next, + GTK_SIGNAL_FUNC (transport_prepare), + transport_back, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) }, + { NULL, + GTK_SIGNAL_FUNC (management_prepare), + NULL, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) } +}; static void wizard_next_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { - if (page_num >= MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT) - return; - - if (wizard_pages[page_num].next_func && - wizard_pages[page_num].next_func (mcw)) - return; - - evolution_wizard_set_page (wizard, page_num + 1, NULL); + if (wizard_pages[page_num].next_func == NULL + || !(wizard_pages[page_num].next_func (wizard, gui))) { + if (page_num < 5-1) { + evolution_wizard_set_page(wizard, page_num+1, NULL); + } + } } static void wizard_prepare_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { - if (wizard_pages[page_num].prepare_func) - wizard_pages[page_num].prepare_func (mcw); + if (wizard_pages[page_num].prepare_func != NULL) { + wizard_pages[page_num].prepare_func (wizard, gui); + } } static void wizard_back_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { - if (page_num >= MAIL_CONFIG_WIZARD_NUM_PAGES) { - evolution_wizard_set_page (wizard, MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT, NULL); - return; - } - - if (wizard_pages[page_num].back_func && - wizard_pages[page_num].back_func (mcw)) - return; - - if (page_num > 0) - evolution_wizard_set_page (wizard, page_num - 1, NULL); + if (page_num >= 5) + evolution_wizard_set_page(wizard, 4, NULL); + else if (wizard_pages[page_num].back_func == NULL + || !(wizard_pages[page_num].back_func (wizard, gui))) { + if (page_num > 0) + evolution_wizard_set_page(wizard, page_num-1, NULL); + } } static void wizard_finish_cb (EvolutionWizard *wizard, + int page_num, MailConfigWizard *w) { MailAccountGui *gui = w->gui; - + /* Save the settings for that account */ if (mail_account_gui_save (gui) == FALSE) /* problem. Um, how to keep the druid alive? */ return; + if (gui->account->source) + gui->account->source->enabled = TRUE; + /* Write out the config info */ mail_config_write (); mail_account_gui_destroy (gui); w->gui = NULL; + w->account = NULL; } static void wizard_cancel_cb (EvolutionWizard *wizard, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { - mail_account_gui_destroy (mcw->gui); - mcw->gui = NULL; + mail_account_gui_destroy (gui->gui); + gui->gui = NULL; } static void wizard_help_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { } -BonoboObject * -evolution_mail_config_wizard_new (void) +static void +wizard_free (MailConfigWizard *wizard) +{ + if (wizard->gui) + mail_account_gui_destroy (wizard->gui); + + if (wizard->account) + account_destroy (wizard->account); + + g_free (wizard); +} + +static BonoboObject * +evolution_mail_config_wizard_factory_fn (BonoboGenericFactory *factory, + void *closure) { EvolutionWizard *wizard; - MailConfigWizard *mcw; - GdkPixbuf *icon; - int i; + MailConfigAccount *account; + MailConfigWizard *gui; - mcw = config_wizard_new (); - mail_account_gui_setup (mcw->gui, NULL); + account = make_account (); - wizard = evolution_wizard_new (); - for (i = 0; i < MAIL_CONFIG_WIZARD_NUM_PAGES; i++) { - icon = gdk_pixbuf_new_from_file (wizard_pages[i].icon_path, NULL); - evolution_wizard_add_page (wizard, _(wizard_pages[i].title), - icon, get_page (mcw->gui->xml, i)); - g_object_unref (icon); - } + gui = g_new (MailConfigWizard, 1); + gui->gui = NULL; + gui->account = account; + gui->identity_copied = FALSE; + gui->last_source = NULL; + gui->page = MAIL_CONFIG_WIZARD_PAGE_NONE; - g_object_set_data_full (G_OBJECT (wizard), "MailConfigWizard", - mcw, (GDestroyNotify)free_config_wizard); - mcw->corba_wizard = wizard; + wizard = evolution_wizard_new (get_fn, 5, gui); + account_wizard = wizard; - g_signal_connect (wizard, "next", G_CALLBACK (wizard_next_cb), mcw); - g_signal_connect (wizard, "prepare", G_CALLBACK (wizard_prepare_cb), mcw); - g_signal_connect (wizard, "back", G_CALLBACK (wizard_back_cb), mcw); - g_signal_connect (wizard, "finish", G_CALLBACK (wizard_finish_cb), mcw); - g_signal_connect (wizard, "cancel", G_CALLBACK (wizard_cancel_cb), mcw); - g_signal_connect (wizard, "help", G_CALLBACK (wizard_help_cb), mcw); + gtk_object_set_data_full (GTK_OBJECT (account_wizard), + "account-data", gui, + (GtkDestroyNotify) wizard_free); + gui->wizard = wizard; - return BONOBO_OBJECT (wizard); + gtk_signal_connect (GTK_OBJECT (wizard), "next", + GTK_SIGNAL_FUNC (wizard_next_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "prepare", + GTK_SIGNAL_FUNC (wizard_prepare_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "back", + GTK_SIGNAL_FUNC (wizard_back_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "finish", + GTK_SIGNAL_FUNC (wizard_finish_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "cancel", + GTK_SIGNAL_FUNC (wizard_cancel_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "help", + GTK_SIGNAL_FUNC (wizard_help_cb), gui); + + return BONOBO_OBJECT (wizard); +} + +void +evolution_mail_config_wizard_init (void) +{ + BonoboGenericFactory *factory; + + factory = bonobo_generic_factory_new (WIZARD_IID, + evolution_mail_config_wizard_factory_fn, NULL); + + if (factory == NULL) { + g_warning ("Error starting factory"); + return; + } + + bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory)); } diff --git a/mail/mail-display.c b/mail/mail-display.c index 657275df98..e1ecc0e272 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -29,30 +29,26 @@ #include <config.h> #endif -#include <string.h> #include <sys/stat.h> #include <ctype.h> #include <fcntl.h> #include <errno.h> - -#include <gtk/gtkinvisible.h> -#include <libgnome/gnome-program.h> - -#include <gconf/gconf.h> -#include <gconf/gconf-client.h> - +#include <libgnorba/gnorba.h> +#include <libgnomevfs/gnome-vfs-mime-info.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h> #include <libgnomevfs/gnome-vfs.h> -#include <libgnome/gnome-url.h> #include <bonobo/bonobo-control-frame.h> #include <bonobo/bonobo-stream-memory.h> +#include <bonobo/bonobo-ui-toolbar-icon.h> #include <bonobo/bonobo-widget.h> #include <bonobo/bonobo-socket.h> #include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf-loader.h> #include <gal/util/e-util.h> +#include <gal/util/e-unicode-i18n.h> #include <gal/widgets/e-popup-menu.h> - +#include <gal/widgets/e-unicode.h> +#include <gtk/gtkinvisible.h> #include <gtkhtml/gtkhtml.h> #include <gtkhtml/gtkhtml-embedded.h> #include <gtkhtml/htmlengine.h> @@ -60,19 +56,18 @@ #include <gtkhtml/htmltext.h> #include <gtkhtml/htmlinterval.h> #include <gtkhtml/gtkhtml-stream.h> - #include <libsoup/soup-message.h> +#include "e-util/e-html-utils.h" #include "e-util/e-mktemp.h" #include "addressbook/backend/ebook/e-book-util.h" #include "e-searching-tokenizer.h" #include "folder-browser-factory.h" -#include "mail-display-stream.h" +#include "mail-stream-gtkhtml.h" #include "folder-browser.h" -#include "mail-config.h" #include "mail-display.h" -#include "mail-format.h" +#include "mail-config.h" #include "mail-ops.h" #include "mail-mt.h" #include "mail.h" @@ -180,24 +175,31 @@ write_data_written(CamelMimePart *part, char *name, int done, void *data) static gboolean write_data_to_file (CamelMimePart *part, const char *name, gboolean unique) { - int fd, ret = FALSE; + int fd; + int ret = FALSE; g_return_val_if_fail (CAMEL_IS_MIME_PART (part), FALSE); fd = open (name, O_WRONLY | O_CREAT | O_EXCL, 0666); if (fd == -1 && errno == EEXIST && !unique) { - GtkWidget *dialog; - int button; + GtkWidget *dlg; + GtkWidget *text; + char *msg; + + dlg = gnome_dialog_new (_("Overwrite file?"), + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, - _("File `%s' already exists.\nOverwrite it?"), - name); + msg = g_strdup_printf (_("File `%s' already exists.\nOverwrite it?"), name); + text = gtk_label_new (msg); + g_free (msg); - g_object_set (dialog, "title", _("Overwrite file?"), "allow_grow", TRUE, NULL); - button = gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), text, TRUE, TRUE, 4); + gtk_window_set_policy (GTK_WINDOW (dlg), FALSE, TRUE, FALSE); + gtk_widget_show (text); - if (button != GTK_RESPONSE_YES) + if (gnome_dialog_run_and_close (GNOME_DIALOG (dlg)) != 0) return FALSE; } @@ -213,11 +215,13 @@ write_data_to_file (CamelMimePart *part, const char *name, gboolean unique) static char * make_safe_filename (const char *prefix,CamelMimePart *part) { - const char *name; + const char *name = NULL; char *safe, *p; - name = part ? camel_mime_part_get_filename (part) : NULL; - + if (part) { + name = camel_mime_part_get_filename (part); + } + if (!name) { /* This is a filename. Translators take note. */ name = _("attachment"); @@ -239,29 +243,27 @@ make_safe_filename (const char *prefix,CamelMimePart *part) static void save_data_cb (GtkWidget *widget, gpointer user_data) { - GtkFileSelection *file_select; - GConfClient *gconf; + GtkFileSelection *file_select = (GtkFileSelection *) + gtk_widget_get_ancestor (widget, GTK_TYPE_FILE_SELECTION); char *dir; - file_select = (GtkFileSelection *) gtk_widget_get_ancestor (widget, GTK_TYPE_FILE_SELECTION); - /* uh, this doesn't really feel right, but i dont know what to do better */ gtk_widget_hide (GTK_WIDGET (file_select)); - write_data_to_file (user_data, gtk_file_selection_get_filename (file_select), FALSE); + write_data_to_file (user_data, gtk_file_selection_get_filename (file_select), + FALSE); /* preserve the pathname */ - dir = g_path_get_dirname (gtk_file_selection_get_filename (file_select)); - gconf = gconf_client_get_default (); - gconf_client_set_string (gconf, "/apps/evolution/mail/save_dir", dir, NULL); + dir = g_dirname (gtk_file_selection_get_filename (file_select)); + mail_config_set_last_filesel_dir (dir); g_free (dir); gtk_widget_destroy (GTK_WIDGET (file_select)); } static void -save_destroy_cb (CamelMimePart *part, GObject *deadbeef) +save_destroy_cb (GtkWidget *widget, CamelMimePart *part) { - camel_object_unref (part); + camel_object_unref (CAMEL_OBJECT (part)); } static gboolean @@ -290,7 +292,7 @@ mail_display_jump_to_anchor (MailDisplay *md, const char *url) char *anchor = strstr (url, "#"); g_return_if_fail (anchor != NULL); - + if (anchor) gtk_html_jump_to_anchor (md->html, anchor + 1); } @@ -298,20 +300,14 @@ mail_display_jump_to_anchor (MailDisplay *md, const char *url) static void on_link_clicked (GtkHTML *html, const char *url, MailDisplay *md) { - - if (!strncasecmp (url, "mailto:", 7)) { + if (!g_strncasecmp (url, "news:", 5) || !g_strncasecmp (url, "nntp:", 5)) { + g_warning ("Can't handle news URLs yet."); + } else if (!g_strncasecmp (url, "mailto:", 7)) { send_to_url (url, NULL); } else if (*url == '#') { mail_display_jump_to_anchor (md, url); } else { - GError *err = NULL; - - gnome_url_show (url, &err); - - if (err) { - g_warning ("gnome_url_show: %s", err->message); - g_error_free (err); - } + gnome_url_show (url); } } @@ -319,40 +315,37 @@ static void save_part (CamelMimePart *part) { GtkFileSelection *file_select; - char *filename, *dir, *base; - GConfClient *gconf; + char *filename; - camel_object_ref (part); + g_return_if_fail (part != NULL); + camel_object_ref (CAMEL_OBJECT (part)); - gconf = gconf_client_get_default (); - dir = gconf_client_get_string (gconf, "/apps/evolution/mail/save_dir", NULL); - filename = make_safe_filename (dir, part); - g_free (dir); + filename = make_safe_filename (mail_config_get_last_filesel_dir (), part); file_select = GTK_FILE_SELECTION ( gtk_file_selection_new (_("Save Attachment"))); gtk_file_selection_set_filename (file_select, filename); /* set the GtkEntry with the locale filename by breaking abstraction */ - base = g_path_get_basename (filename); - gtk_entry_set_text (GTK_ENTRY (file_select->selection_entry), base); + e_utf8_gtk_entry_set_text (GTK_ENTRY (file_select->selection_entry), g_basename (filename)); g_free (filename); - g_free (base); - g_signal_connect (file_select->ok_button, "clicked", - G_CALLBACK (save_data_cb), part); - - g_signal_connect_swapped (file_select->cancel_button, "clicked", - G_CALLBACK (gtk_widget_destroy), file_select); - - g_object_weak_ref ((GObject *) file_select, (GWeakNotify) save_destroy_cb, part); + gtk_signal_connect (GTK_OBJECT (file_select->ok_button), "clicked", + GTK_SIGNAL_FUNC (save_data_cb), part); + gtk_signal_connect_object (GTK_OBJECT (file_select->cancel_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (file_select)); + gtk_signal_connect (GTK_OBJECT (file_select), "destroy", + GTK_SIGNAL_FUNC (save_destroy_cb), part); + gtk_widget_show (GTK_WIDGET (file_select)); } static void save_cb (GtkWidget *widget, gpointer user_data) { - CamelMimePart *part = g_object_get_data ((GObject *) user_data, "CamelMimePart"); + CamelMimePart *part = gtk_object_get_data (GTK_OBJECT (user_data), "CamelMimePart"); save_part (part); } @@ -360,18 +353,18 @@ save_cb (GtkWidget *widget, gpointer user_data) static void launch_cb (GtkWidget *widget, gpointer user_data) { - CamelMimePart *part = g_object_get_data(user_data, "CamelMimePart"); + CamelMimePart *part = gtk_object_get_data (user_data, "CamelMimePart"); MailMimeHandler *handler; GList *apps, *children, *c; GnomeVFSMimeApplication *app; char *command, *filename; const char *tmpdir; - handler = mail_lookup_handler (g_object_get_data(user_data, "mime_type")); + handler = mail_lookup_handler (gtk_object_get_data (user_data, "mime_type")); g_return_if_fail (handler != NULL && handler->applications != NULL); /* Yum. Too bad EPopupMenu doesn't allow per-item closures. */ - children = gtk_container_get_children (GTK_CONTAINER (widget->parent)); + children = gtk_container_children (GTK_CONTAINER (widget->parent)); g_return_if_fail (children != NULL && children->next != NULL && children->next->next != NULL); for (c = children->next->next, apps = handler->applications; c && apps; c = c->next, apps = apps->next) { @@ -382,40 +375,30 @@ launch_cb (GtkWidget *widget, gpointer user_data) g_return_if_fail (c != NULL && apps != NULL); app = apps->data; - tmpdir = e_mkdtemp ("app-launcher-XXXXXX"); + tmpdir = e_mkdtemp ("evolution.XXXXXX"); if (!tmpdir) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_RESPONSE_CLOSE, - _("Could not create temporary directory: %s"), - g_strerror (errno)); - - /* FIXME: this should be async */ - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); + char *msg = g_strdup_printf (_("Could not create temporary directory: %s"), + g_strerror (errno)); + gnome_error_dialog (msg); + g_free (msg); return; } filename = make_safe_filename (tmpdir, part); if (!write_data_to_file (part, filename, TRUE)) { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_RESPONSE_CLOSE, - _("Could not create temporary file '%s': %s"), - filename, g_strerror (errno)); - - /* FIXME: this should be async */ - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); + char *msg = g_strdup_printf (_("Could not create temporary file '%s': %s"), + filename, g_strerror (errno)); + gnome_error_dialog (msg); g_free (filename); + g_free (msg); return; } command = g_strdup_printf ("%s %s%s &", app->command, - app->expects_uris == GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS ? - "file://" : "", filename); + app->expects_uris == GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS ? "file://" : "", + filename); g_free (filename); system (command); @@ -425,9 +408,9 @@ launch_cb (GtkWidget *widget, gpointer user_data) static void inline_cb (GtkWidget *widget, gpointer user_data) { - MailDisplay *md = g_object_get_data (user_data, "MailDisplay"); - CamelMimePart *part = g_object_get_data (user_data, "CamelMimePart"); - + MailDisplay *md = gtk_object_get_data (user_data, "MailDisplay"); + CamelMimePart *part = gtk_object_get_data (user_data, "CamelMimePart"); + mail_part_toggle_displayed (part, md); mail_display_queue_redisplay (md); } @@ -436,24 +419,24 @@ static void button_press (GtkWidget *widget, CamelMimePart *part) { MailDisplay *md; - - md = g_object_get_data ((GObject *) widget, "MailDisplay"); + + md = gtk_object_get_data (GTK_OBJECT (widget), "MailDisplay"); if (md == NULL) { g_warning ("No MailDisplay on button!"); return; } - + mail_part_toggle_displayed (part, md); mail_display_queue_redisplay (md); } static gboolean -pixmap_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data) +pixmap_press (GtkWidget *widget, GdkEventButton *event, EScrollFrame *user_data) { EPopupMenu *menu; - EPopupMenu save_item = E_POPUP_ITEM (N_("Save Attachment..."), G_CALLBACK (save_cb), 0); - EPopupMenu view_item = E_POPUP_ITEM (N_("View Inline"), G_CALLBACK (inline_cb), 2); - EPopupMenu open_item = E_POPUP_ITEM (N_("Open in %s..."), G_CALLBACK (launch_cb), 1); + EPopupMenu save_item = E_POPUP_ITEM (N_("Save Attachment..."), GTK_SIGNAL_FUNC (save_cb), 0); + EPopupMenu view_item = E_POPUP_ITEM (N_("View Inline"), GTK_SIGNAL_FUNC (inline_cb), 2); + EPopupMenu open_item = E_POPUP_ITEM (N_("Open in %s..."), GTK_SIGNAL_FUNC (launch_cb), 1); MailDisplay *md; CamelMimePart *part; MailMimeHandler *handler; @@ -475,10 +458,11 @@ pixmap_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data) /* Stop the signal, since we don't want the button's class method to mess up our popup. */ - g_signal_stop_emission_by_name (widget, "button_press_event"); + gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event"); - part = g_object_get_data ((GObject *) widget, "CamelMimePart"); - handler = mail_lookup_handler (g_object_get_data ((GObject *) widget, "mime_type")); + part = gtk_object_get_data (GTK_OBJECT (widget), "CamelMimePart"); + handler = mail_lookup_handler (gtk_object_get_data (GTK_OBJECT (widget), + "mime_type")); if (handler && handler->applications) nitems = g_list_length (handler->applications) + 2; @@ -489,27 +473,30 @@ pixmap_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data) /* Save item */ memcpy (&menu[0], &save_item, sizeof (menu[0])); menu[0].name = _(menu[0].name); - + /* Inline view item */ memcpy (&menu[1], &view_item, sizeof (menu[1])); if (handler && handler->builtin) { - md = g_object_get_data ((GObject *) widget, "MailDisplay"); - + md = gtk_object_get_data (GTK_OBJECT (widget), "MailDisplay"); + if (!mail_part_is_displayed_inline (part, md)) { if (handler->component) { - Bonobo_ActivationProperty *prop; + OAF_Property *prop; char *name; - - prop = bonobo_server_info_prop_find (handler->component, "name"); + + prop = oaf_server_info_prop_find ( + handler->component, "name"); if (!prop) { - prop = bonobo_server_info_prop_find (handler->component, - "description"); + prop = oaf_server_info_prop_find ( + handler->component, + "description"); } - if (prop && prop->v._d == Bonobo_ACTIVATION_P_STRING) + if (prop && prop->v._d == OAF_P_STRING) name = prop->v._u.value_string; else name = "bonobo"; - menu[1].name = g_strdup_printf (_("View Inline (via %s)"), name); + menu[1].name = g_strdup_printf ( + _("View Inline (via %s)"), name); } else menu[1].name = g_strdup (_(menu[1].name)); } else @@ -518,13 +505,13 @@ pixmap_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data) menu[1].name = g_strdup (_(menu[1].name)); mask |= 2; } - + /* External views */ if (handler && handler->applications) { GnomeVFSMimeApplication *app; GList *apps; int i; - + apps = handler->applications; for (i = 2; i < nitems; i++, apps = apps->next) { app = apps->data; @@ -533,16 +520,16 @@ pixmap_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data) } } else { memcpy (&menu[2], &open_item, sizeof (menu[2])); - menu[2].name = g_strdup_printf (_(menu[2].name), _("External Viewer")); + menu[2].name = g_strdup_printf (_(menu[2].name), + _("External Viewer")); mask |= 1; } - + e_popup_menu_run (menu, (GdkEvent *)event, mask, 0, widget); - + for (i = 1; i < nitems; i++) g_free (menu[i].name); g_free (menu); - return TRUE; } @@ -553,47 +540,48 @@ pixbuf_for_mime_type (const char *mime_type) char *filename = NULL; GdkPixbuf *pixbuf = NULL; - icon_name = gnome_vfs_mime_get_icon (mime_type); + /* GnomeVFS changed the key from icon-filename to + icon_filename, so check icon_filename first and if that + fails, fall back to the old key name */ + if (!(icon_name = gnome_vfs_mime_get_value (mime_type, "icon_filename"))) + icon_name = gnome_vfs_mime_get_value (mime_type, "icon-filename"); if (icon_name) { if (*icon_name == '/') { - pixbuf = gdk_pixbuf_new_from_file (icon_name, NULL); + pixbuf = gdk_pixbuf_new_from_file (icon_name); if (pixbuf) return pixbuf; } - filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, - icon_name, TRUE, NULL); + filename = gnome_pixmap_file (icon_name); if (!filename) { char *fm_icon; fm_icon = g_strdup_printf ("nautilus/%s", icon_name); - filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, - fm_icon, TRUE, NULL); + filename = gnome_pixmap_file (fm_icon); if (!filename) { g_free (fm_icon); fm_icon = g_strdup_printf ("mc/%s", icon_name); - filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, - fm_icon, TRUE, NULL); + filename = gnome_pixmap_file (fm_icon); } g_free (fm_icon); } if (filename) { - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + pixbuf = gdk_pixbuf_new_from_file (filename); g_free (filename); } } if (!pixbuf) { - filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, - "gnome-unknown.png", TRUE, NULL); + filename = gnome_pixmap_file ("gnome-unknown.png"); if (filename) { - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + pixbuf = gdk_pixbuf_new_from_file (filename); g_free (filename); } else { g_warning ("Could not get any icon for %s!",mime_type); - pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)empty_xpm); + pixbuf = gdk_pixbuf_new_from_xpm_data ( + (const char **)empty_xpm); } } @@ -604,9 +592,9 @@ static gboolean pixbuf_uncache (gpointer key) { GdkPixbuf *pixbuf; - + pixbuf = g_hash_table_lookup (thumbnail_cache, key); - g_object_unref (pixbuf); + gdk_pixbuf_unref (pixbuf); g_hash_table_remove (thumbnail_cache, key); g_free (key); return FALSE; @@ -620,93 +608,73 @@ pixbuf_gen_idle (struct _PixbufLoader *pbl) char tmp[4096]; int len, width, height, ratio; gpointer orig_key; - + /* Get the pixbuf from the cache */ if (g_hash_table_lookup_extended (thumbnail_cache, pbl->cid, &orig_key, (gpointer *)&mini)) { width = gdk_pixbuf_get_width (mini); height = gdk_pixbuf_get_height (mini); - - gtk_image_set_from_pixbuf ((GtkImage *) pbl->pixmap, mini); - gtk_widget_set_size_request (pbl->pixmap, width, height); + + bonobo_ui_toolbar_icon_set_pixbuf ( + BONOBO_UI_TOOLBAR_ICON (pbl->pixmap), mini); + gtk_widget_set_usize (pbl->pixmap, width, height); /* Restart the cache-cleaning timer */ g_source_remove_by_user_data (orig_key); g_timeout_add (5 * 60 * 1000, pixbuf_uncache, orig_key); - + if (pbl->loader) { - gdk_pixbuf_loader_close (pbl->loader, NULL); - g_object_unref (pbl->loader); - camel_object_unref (pbl->mstream); + gdk_pixbuf_loader_close (pbl->loader); + gtk_object_destroy (GTK_OBJECT (pbl->loader)); + camel_object_unref (CAMEL_OBJECT (pbl->mstream)); } - - g_signal_handler_disconnect (pbl->eb, pbl->destroy_id); + gtk_signal_disconnect (GTK_OBJECT (pbl->eb), pbl->destroy_id); g_free (pbl->type); g_free (pbl->cid); g_free (pbl); - + return FALSE; } - + /* Not in cache, so get a pixbuf from the wrapper */ - + if (!GTK_IS_WIDGET (pbl->pixmap)) { /* Widget has died */ if (pbl->mstream) - camel_object_unref (pbl->mstream); - + camel_object_unref (CAMEL_OBJECT (pbl->mstream)); + if (pbl->loader) { - gdk_pixbuf_loader_close (pbl->loader, NULL); - g_object_unref (pbl->loader); + gdk_pixbuf_loader_close (pbl->loader); + gtk_object_destroy (GTK_OBJECT (pbl->loader)); } - - g_signal_handler_disconnect (pbl->eb, pbl->destroy_id); + g_free (pbl->type); g_free (pbl->cid); g_free (pbl); - return FALSE; } - + if (pbl->mstream) { if (pbl->loader == NULL) pbl->loader = gdk_pixbuf_loader_new (); - + len = camel_stream_read (pbl->mstream, tmp, 4096); if (len > 0) { - error = !gdk_pixbuf_loader_write (pbl->loader, tmp, len, NULL); + error = !gdk_pixbuf_loader_write (pbl->loader, tmp, len); if (!error) return TRUE; } else if (!camel_stream_eos (pbl->mstream)) error = TRUE; } - + if (error || !pbl->mstream) { if (pbl->type) pixbuf = pixbuf_for_mime_type (pbl->type); else - pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/pgp-signature-nokey.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/pgp-signature-nokey.png"); } else pixbuf = gdk_pixbuf_loader_get_pixbuf (pbl->loader); - if (pixbuf == NULL) { - /* pixbuf is non-existant */ - if (pbl->mstream) - camel_object_unref (pbl->mstream); - - if (pbl->loader) { - gdk_pixbuf_loader_close (pbl->loader, NULL); - g_object_unref (pbl->loader); - } - - g_signal_handler_disconnect (pbl->eb, pbl->destroy_id); - g_free (pbl->type); - g_free (pbl->cid); - g_free (pbl); - - return FALSE; - } - width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); @@ -723,27 +691,26 @@ pixbuf_gen_idle (struct _PixbufLoader *pbl) width /= ratio; } } - - mini = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR); + + mini = gdk_pixbuf_scale_simple (pixbuf, width, height, + GDK_INTERP_BILINEAR); if (error || !pbl->mstream) - g_object_unref (pixbuf); - - gtk_image_set_from_pixbuf ((GtkImage *) pbl->pixmap, mini); - + gdk_pixbuf_unref (pixbuf); + bonobo_ui_toolbar_icon_set_pixbuf ( + BONOBO_UI_TOOLBAR_ICON (pbl->pixmap), mini); + /* Add the pixbuf to the cache */ g_hash_table_insert (thumbnail_cache, pbl->cid, mini); g_timeout_add (5 * 60 * 1000, pixbuf_uncache, pbl->cid); - - g_signal_handler_disconnect (pbl->eb, pbl->destroy_id); + + gtk_signal_disconnect (GTK_OBJECT (pbl->eb), pbl->destroy_id); if (pbl->loader) { - gdk_pixbuf_loader_close (pbl->loader, NULL); - g_object_unref (pbl->loader); - camel_object_unref (pbl->mstream); + gdk_pixbuf_loader_close (pbl->loader); + gtk_object_unref (GTK_OBJECT (pbl->loader)); + camel_object_unref (CAMEL_OBJECT (pbl->mstream)); } - g_free (pbl->type); g_free (pbl); - return FALSE; } @@ -751,15 +718,16 @@ pixbuf_gen_idle (struct _PixbufLoader *pbl) as the widget that the pixbuf was to be rendered to has died on us. */ static void -embeddable_destroy_cb (GtkObject *embeddable, struct _PixbufLoader *pbl) +embeddable_destroy_cb (GtkObject *embeddable, + struct _PixbufLoader *pbl) { g_idle_remove_by_data (pbl); if (pbl->mstream) - camel_object_unref (pbl->mstream); + camel_object_unref (CAMEL_OBJECT (pbl->mstream)); if (pbl->loader) { - gdk_pixbuf_loader_close (pbl->loader, NULL); - g_object_unref (pbl->loader); + gdk_pixbuf_loader_close (pbl->loader); + gtk_object_destroy (GTK_OBJECT (pbl->loader)); } g_free (pbl->type); @@ -779,8 +747,6 @@ get_embedded_for_component (const char *iid, MailDisplay *md) */ embedded = bonobo_widget_new_control (iid, NULL); if (embedded == NULL) { -#warning "what about bonobo_widget_new_subdoc?" -#if 0 /* * No control, try an embeddable instead. */ @@ -791,22 +757,21 @@ get_embedded_for_component (const char *iid, MailDisplay *md) * destruction path that we have to balance out to * prevent problems. */ - bonobo_object_ref (BONOBO_OBJECT (bonobo_widget_get_client_site ( + bonobo_object_ref (BONOBO_OBJECT(bonobo_widget_get_client_site ( BONOBO_WIDGET (embedded)))); - + return embedded; } -#endif } - + if (embedded == NULL) return NULL; - + control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (embedded)); - - prop_bag = bonobo_control_frame_get_control_property_bag (control_frame, NULL); - - if (prop_bag != CORBA_OBJECT_NIL) { + + prop_bag = bonobo_control_frame_get_control_property_bag ( control_frame, NULL ); + + if (prop_bag != CORBA_OBJECT_NIL){ CORBA_Environment ev; /* * Now we can take care of business. Currently, the only control @@ -817,20 +782,20 @@ get_embedded_for_component (const char *iid, MailDisplay *md) */ const CamelInternetAddress *from; char *from_address; - + CORBA_exception_init (&ev); from = camel_mime_message_get_from (md->current_message); - from_address = camel_address_encode ((CamelAddress *) from); + from_address = camel_address_encode((CamelAddress *)from); bonobo_property_bag_client_set_value_string ( prop_bag, "from_address", from_address, &ev); - g_free (from_address); - + g_free(from_address); + Bonobo_Unknown_unref (prop_bag, &ev); CORBA_exception_free (&ev); } - + return embedded; } @@ -839,73 +804,63 @@ save_url (MailDisplay *md, const char *url) { GHashTable *urls; CamelMimePart *part; - + urls = g_datalist_get_data (md->data, "part_urls"); - g_return_val_if_fail (url != NULL, NULL); g_return_val_if_fail (urls != NULL, NULL); part = g_hash_table_lookup (urls, url); if (part == NULL) { - CamelDataWrapper *wrapper; - CamelStream *stream = NULL; - const char *name; + GByteArray *ba; + + urls = g_datalist_get_data (md->data, "data_urls"); + g_return_val_if_fail (urls != NULL, NULL); /* See if it's some piece of cached data if it is then pretend it - * is a mime part so that we can use the mime part saving routines. + * is a mime part so that we can use the mime part saveing routines. * It is gross but it keeps duplicated code to a minimum and helps * out with ref counting and the like. */ - name = strrchr (url, '/'); - name = name ? name : url; - - if (fetch_cache) { - /* look in the soup cache */ - stream = camel_data_cache_get(fetch_cache, FETCH_HTTP_CACHE, url, NULL); - } else { - GByteArray *ba = NULL; - - urls = g_datalist_get_data (md->data, "data_urls"); - g_return_val_if_fail (urls != NULL, NULL); - - ba = g_hash_table_lookup (urls, url); - if (ba) { - /* we have to copy the data here since the ba may be long gone - * by the time the user actually saves the file - */ - stream = camel_stream_mem_new_with_buffer (ba->data, ba->len); - } - } - - if (stream) { + ba = g_hash_table_lookup (urls, url); + if (ba) { + CamelStream *memstream; + CamelDataWrapper *wrapper; + const char *name; + + name = strrchr (url, '/'); + name = name ? name : url; + + /* we have to copy the data here since the ba may be long gone + * by the time the user actually saves the file + */ + memstream = camel_stream_mem_new_with_buffer (ba->data, ba->len); wrapper = camel_data_wrapper_new (); - camel_data_wrapper_construct_from_stream (wrapper, stream); - camel_object_unref (stream); + camel_data_wrapper_construct_from_stream (wrapper, memstream); + camel_object_unref (CAMEL_OBJECT (memstream)); part = camel_mime_part_new (); camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper); - camel_object_unref (wrapper); + camel_object_unref (CAMEL_OBJECT (wrapper)); camel_mime_part_set_filename (part, name); } } else { - camel_object_ref (part); + camel_object_ref (CAMEL_OBJECT (part)); } - + if (part) { CamelDataWrapper *data; - + g_return_val_if_fail (CAMEL_IS_MIME_PART (part), NULL); - + data = camel_medium_get_content_object ((CamelMedium *)part); if (!mail_content_loaded (data, md, TRUE, NULL, NULL, NULL)) { return NULL; } - + save_part (part); - camel_object_unref (part); + camel_object_unref (CAMEL_OBJECT (part)); return NULL; } - g_warning ("Data for url: \"%s\" not found", url); - + g_warning ("part not found"); return NULL; } @@ -920,11 +875,11 @@ drag_data_get_cb (GtkWidget *widget, CamelMimePart *part = user_data; const char *filename, *tmpdir; char *uri_list; - + switch (info) { case DND_TARGET_TYPE_TEXT_URI_LIST: /* Kludge around Nautilus requesting the same data many times */ - uri_list = g_object_get_data ((GObject *) widget, "uri-list"); + uri_list = gtk_object_get_data (GTK_OBJECT (widget), "uri-list"); if (uri_list) { gtk_selection_data_set (selection_data, selection_data->target, 8, uri_list, strlen (uri_list)); @@ -933,19 +888,15 @@ drag_data_get_cb (GtkWidget *widget, tmpdir = e_mkdtemp ("drag-n-drop-XXXXXX"); if (!tmpdir) { - GtkWidget *dialog; + char *msg; - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_RESPONSE_CLOSE, - _("Could not create temporary directory: %s"), - g_strerror (errno)); - - /* FIXME: this should be async */ - gtk_dialog_run ((GtkDialog *) dialog); - gtk_widget_destroy (dialog); + msg = g_strdup_printf (_("Could not create temporary directory: %s"), + g_strerror (errno)); + gnome_error_dialog (msg); + g_free (msg); } filename = camel_mime_part_get_filename (part); - /* This is the default filename used for dnd temporary target of attachment */ if (!filename) filename = _("Unknown"); @@ -959,13 +910,13 @@ drag_data_get_cb (GtkWidget *widget, gtk_selection_data_set (selection_data, selection_data->target, 8, uri_list, strlen (uri_list)); - g_object_set_data_full ((GObject *) widget, "uri-list", uri_list, g_free); + gtk_object_set_data_full (GTK_OBJECT (widget), "uri-list", uri_list, g_free); break; case DND_TARGET_TYPE_PART_MIME_TYPE: if (header_content_type_is (part->content_type, "text", "*")) { GByteArray *ba; - - ba = mail_format_get_data_wrapper_text ((CamelDataWrapper *) part, NULL); + + ba = mail_format_get_data_wrapper_text ((CamelDataWrapper *)part, NULL); if (ba) { gtk_selection_data_set (selection_data, selection_data->target, 8, ba->data, ba->len); @@ -973,16 +924,19 @@ drag_data_get_cb (GtkWidget *widget, } } else { CamelDataWrapper *wrapper; - CamelStreamMem *cstream; - - cstream = (CamelStreamMem *) camel_stream_mem_new (); + CamelStream *cstream; + GByteArray *ba; + + ba = g_byte_array_new (); + + cstream = camel_stream_mem_new_with_byte_array (ba); wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - camel_data_wrapper_write_to_stream (wrapper, (CamelStream *)cstream); + camel_data_wrapper_write_to_stream (wrapper, cstream); gtk_selection_data_set (selection_data, selection_data->target, 8, - cstream->buffer->data, cstream->buffer->len); + ba->data, ba->len); - camel_object_unref (cstream); + camel_object_unref (CAMEL_OBJECT (cstream)); } break; default: @@ -997,10 +951,10 @@ drag_data_delete_cb (GtkWidget *widget, { char *uri_list; - uri_list = g_object_get_data ((GObject *) widget, "uri-list"); + uri_list = gtk_object_get_data (GTK_OBJECT (widget), "uri-list"); if (uri_list) { unlink (uri_list + 7); - g_object_set_data ((GObject *) widget, "uri-list", NULL); + gtk_object_set_data (GTK_OBJECT (widget), "uri-list", NULL); } } @@ -1013,7 +967,7 @@ do_attachment_header (GtkHTML *html, GtkHTMLEmbedded *eb, struct _PixbufLoader *pbl; pbl = g_new0 (struct _PixbufLoader, 1); - if (strncasecmp (eb->type, "image/", 6) == 0) { + if (g_strncasecmp (eb->type, "image/", 6) == 0) { CamelDataWrapper *content; content = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -1023,47 +977,50 @@ do_attachment_header (GtkHTML *html, GtkHTMLEmbedded *eb, camel_stream_reset (pbl->mstream); } } - pbl->type = g_strdup (eb->type); pbl->cid = g_strdup (eb->classid + 6); - pbl->pixmap = gtk_image_new(); - gtk_widget_set_size_request (pbl->pixmap, 24, 24); + pbl->pixmap = bonobo_ui_toolbar_icon_new (); + gtk_widget_set_usize (pbl->pixmap, 24, 24); pbl->eb = eb; - pbl->destroy_id = g_signal_connect (eb, "destroy", G_CALLBACK (embeddable_destroy_cb), pbl); + pbl->destroy_id = gtk_signal_connect (GTK_OBJECT (eb), "destroy", + embeddable_destroy_cb, pbl); - g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc) pixbuf_gen_idle, pbl, NULL); + g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)pixbuf_gen_idle, + pbl, NULL); mainbox = gtk_hbox_new (FALSE, 0); button = gtk_button_new (); GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS); - g_object_set_data ((GObject *) button, "MailDisplay", md); + gtk_object_set_data (GTK_OBJECT (button), "MailDisplay", md); handler = mail_lookup_handler (eb->type); if (handler && handler->builtin) - g_signal_connect (button, "clicked", G_CALLBACK (button_press), part); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (button_press), part); /* Drag & Drop */ - drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target = header_content_type_simple (part->content_type); - camel_strdown (drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target); - + drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target = header_content_type_simple(part->content_type); + g_strdown (drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target); + gtk_drag_source_set (button, GDK_BUTTON1_MASK, drag_types, num_drag_types, GDK_ACTION_COPY); - g_signal_connect (button, "drag-data-get", G_CALLBACK (drag_data_get_cb), part); - g_signal_connect (button, "drag-data-delete", G_CALLBACK (drag_data_delete_cb), part); + gtk_signal_connect (GTK_OBJECT (button), "drag-data-get", + drag_data_get_cb, part); + gtk_signal_connect (GTK_OBJECT (button), "drag-data-delete", + drag_data_delete_cb, part); g_free (drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target); drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target = NULL; - + hbox = gtk_hbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); - /* should this be a gtk_arrow? */ if (handler && mail_part_is_displayed_inline (part, md)) - arrow = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON); + arrow = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_DOWN); else - arrow = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON); + arrow = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_FORWARD); gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), pbl->pixmap, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (button), hbox); @@ -1074,11 +1031,13 @@ do_attachment_header (GtkHTML *html, GtkHTMLEmbedded *eb, gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_ETCHED_IN)); - g_object_set_data ((GObject *) popup, "MailDisplay", md); - g_object_set_data ((GObject *) popup, "CamelMimePart", part); - g_object_set_data_full ((GObject *) popup, "mime_type", g_strdup (eb->type), (GDestroyNotify) g_free); + gtk_object_set_data (GTK_OBJECT (popup), "MailDisplay", md); + gtk_object_set_data (GTK_OBJECT (popup), "CamelMimePart", part); + gtk_object_set_data_full (GTK_OBJECT (popup), "mime_type", + g_strdup (eb->type), (GDestroyNotify)g_free); - g_signal_connect (popup, "button_press_event", G_CALLBACK (pixmap_press), md->scroll); + gtk_signal_connect (GTK_OBJECT (popup), "button_press_event", + GTK_SIGNAL_FUNC (pixmap_press), md->scroll); gtk_box_pack_start (GTK_BOX (mainbox), button, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (mainbox), popup, TRUE, TRUE, 0); @@ -1094,11 +1053,13 @@ do_external_viewer (GtkHTML *html, GtkHTMLEmbedded *eb, CamelMimePart *part, MailDisplay *md) { CamelDataWrapper *wrapper; - Bonobo_ServerInfo *component; + OAF_ServerInfo *component; GtkWidget *embedded; + BonoboObjectClient *server; Bonobo_PersistStream persist; CORBA_Environment ev; - CamelStreamMem *cstream; + GByteArray *ba; + CamelStream *cstream; BonoboStream *bstream; MailMimeHandler *handler; @@ -1109,49 +1070,50 @@ do_external_viewer (GtkHTML *html, GtkHTMLEmbedded *eb, component = gnome_vfs_mime_get_default_component (eb->type); if (!component) return FALSE; - + embedded = get_embedded_for_component (component->iid, md); CORBA_free (component); if (!embedded) return FALSE; - - persist = (Bonobo_PersistStream) Bonobo_Unknown_queryInterface ( - bonobo_widget_get_objref (BONOBO_WIDGET (embedded)), - "IDL:Bonobo/PersistStream:1.0", NULL); - + + server = bonobo_widget_get_server (BONOBO_WIDGET (embedded)); + persist = (Bonobo_PersistStream) bonobo_object_client_query_interface ( + server, "IDL:Bonobo/PersistStream:1.0", NULL); if (persist == CORBA_OBJECT_NIL) { gtk_object_sink (GTK_OBJECT (embedded)); return FALSE; } - + /* Write the data to a CamelStreamMem... */ - cstream = (CamelStreamMem *) camel_stream_mem_new (); + ba = g_byte_array_new (); + cstream = camel_stream_mem_new_with_byte_array (ba); wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - camel_data_wrapper_write_to_stream (wrapper, (CamelStream *)cstream); - + camel_data_wrapper_write_to_stream (wrapper, cstream); + /* ...convert the CamelStreamMem to a BonoboStreamMem... */ - bstream = bonobo_stream_mem_create (cstream->buffer->data, cstream->buffer->len, TRUE, FALSE); - camel_object_unref (cstream); - + bstream = bonobo_stream_mem_create (ba->data, ba->len, TRUE, FALSE); + camel_object_unref (CAMEL_OBJECT (cstream)); + /* ...and hydrate the PersistStream from the BonoboStream. */ CORBA_exception_init (&ev); Bonobo_PersistStream_load (persist, - bonobo_object_corba_objref (BONOBO_OBJECT (bstream)), + bonobo_object_corba_objref ( + BONOBO_OBJECT (bstream)), eb->type, &ev); bonobo_object_unref (BONOBO_OBJECT (bstream)); Bonobo_Unknown_unref (persist, &ev); CORBA_Object_release (persist, &ev); - + if (ev._major != CORBA_NO_EXCEPTION) { gtk_object_sink (GTK_OBJECT (embedded)); CORBA_exception_free (&ev); return FALSE; } CORBA_exception_free (&ev); - + gtk_widget_show (embedded); gtk_container_add (GTK_CONTAINER (eb), embedded); - + return TRUE; } @@ -1161,25 +1123,28 @@ do_signature (GtkHTML *html, GtkHTMLEmbedded *eb, { GtkWidget *button; struct _PixbufLoader *pbl; - + pbl = g_new0 (struct _PixbufLoader, 1); pbl->type = NULL; pbl->cid = g_strdup (eb->classid); - pbl->pixmap = gtk_image_new (); - gtk_widget_set_size_request (pbl->pixmap, 24, 24); + pbl->pixmap = bonobo_ui_toolbar_icon_new (); + gtk_widget_set_usize (pbl->pixmap, 24, 24); pbl->eb = eb; - pbl->destroy_id = g_signal_connect (eb, "destroy", G_CALLBACK (embeddable_destroy_cb), pbl); - - g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc) pixbuf_gen_idle, pbl, NULL); - + pbl->destroy_id = gtk_signal_connect (GTK_OBJECT (eb), "destroy", + embeddable_destroy_cb, pbl); + + g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)pixbuf_gen_idle, + pbl, NULL); + button = gtk_button_new (); GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS); - g_object_set_data ((GObject *) button, "MailDisplay", md); - g_signal_connect (button, "clicked", G_CALLBACK (button_press), part); + gtk_object_set_data (GTK_OBJECT (button), "MailDisplay", md); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (button_press), part); gtk_container_add (GTK_CONTAINER (button), pbl->pixmap); gtk_widget_show_all (button); gtk_container_add (GTK_CONTAINER (eb), button); - + return TRUE; } @@ -1189,10 +1154,10 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) MailDisplay *md = data; GHashTable *urls; CamelMimePart *part; - + if (!eb->classid) return FALSE; - + urls = g_datalist_get_data (md->data, "part_urls"); if (!urls) return FALSE; @@ -1213,7 +1178,7 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) return FALSE; return do_external_viewer (html, eb, part, md); } - + return FALSE; } @@ -1221,11 +1186,11 @@ static void ebook_callback (EBook *book, const gchar *addr, ECard *card, gpointer data) { MailDisplay *md = data; - + if (card && md->current_message) { const CamelInternetAddress *from = camel_mime_message_get_from (md->current_message); const char *md_name = NULL, *md_addr = NULL; - + /* We are extra anal, in case we are dealing with some sort of pathological message w/o a From: header. */ if (from != NULL && camel_internet_address_get (from, 0, &md_name, &md_addr)) { @@ -1240,13 +1205,10 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle, gpointer user_data) { MailDisplay *md = user_data; - GConfClient *gconf; GHashTable *urls; CamelMedium *medium; GByteArray *ba; - gconf = gconf_client_get_default (); - urls = g_datalist_get_data (md->data, "part_urls"); g_return_if_fail (urls != NULL); @@ -1254,30 +1216,34 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle, medium = g_hash_table_lookup (urls, url); if (medium) { CamelContentType *content_type; - CamelDataWrapper *wrapper; - CamelStream *html_stream; + CamelDataWrapper *data; g_return_if_fail (CAMEL_IS_MEDIUM (medium)); if (md->related) - g_hash_table_remove (md->related, medium); + g_hash_table_remove(md->related, medium); - wrapper = camel_medium_get_content_object (medium); - if (!mail_content_loaded (wrapper, md, FALSE, url, html, handle)) + data = camel_medium_get_content_object (medium); + if (!mail_content_loaded (data, md, FALSE, url, html, handle)) return; - content_type = camel_data_wrapper_get_mime_type_field (wrapper); - - html_stream = mail_display_stream_new (html, handle); + content_type = camel_data_wrapper_get_mime_type_field (data); if (header_content_type_is (content_type, "text", "*")) { - mail_format_data_wrapper_write_to_stream (wrapper, md, html_stream); + ba = mail_format_get_data_wrapper_text (data, md); + if (ba) { + gtk_html_write (html, handle, ba->data, ba->len); + + g_byte_array_free (ba, TRUE); + } } else { - camel_data_wrapper_write_to_stream (wrapper, html_stream); + CamelStream *html_stream; + + html_stream = mail_stream_gtkhtml_new (html, handle); + camel_data_wrapper_write_to_stream (data, html_stream); + camel_object_unref (CAMEL_OBJECT (html_stream)); } - camel_object_unref (html_stream); - gtk_html_end (html, handle, GTK_HTML_STREAM_OK); return; } @@ -1300,22 +1266,18 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle, /* See if it's something we can load. */ if (strncmp (url, "http:", 5) == 0 || strncmp (url, "https:", 6) == 0) { - int http_mode; - - http_mode = gconf_client_get_int (gconf, "/apps/evolution/mail/display/load_http_images", NULL); - if (http_mode == MAIL_CONFIG_HTTP_ALWAYS || + if (mail_config_get_http_mode () == MAIL_CONFIG_HTTP_ALWAYS || g_datalist_get_data (md->data, "load_images")) { - fetch_remote (md, url, html, handle); - } else if (http_mode == MAIL_CONFIG_HTTP_SOMETIMES && + fetch_remote(md, url, html, handle); + } else if (mail_config_get_http_mode () == MAIL_CONFIG_HTTP_SOMETIMES && !g_datalist_get_data (md->data, "checking_from")) { - const CamelInternetAddress *from; + const CamelInternetAddress *from = camel_mime_message_get_from (md->current_message); const char *name, *addr; - from = camel_mime_message_get_from (md->current_message); - g_datalist_set_data (md->data, "checking_from", GINT_TO_POINTER (1)); + g_datalist_set_data (md->data, "checking_from", + GINT_TO_POINTER (1)); - /* Make sure we aren't deal w/ some sort of a - pathological message w/o a From: header */ + /* Make sure we aren't deal w/ some sort of a pathological message w/o a From: header */ if (from != NULL && camel_internet_address_get (from, 0, &name, &addr)) e_book_query_address_default (addr, ebook_callback, md); else @@ -1329,22 +1291,20 @@ static struct _mail_msg_op fetch_fake_op = { NULL, NULL, NULL, NULL, }; -static gboolean -fetch_cancelled (GIOChannel *source, GIOCondition cond, void *user_data) +static gboolean fetch_cancelled(GIOChannel *source, GIOCondition cond, void *data) { - fetch_cancel ((MailDisplay *) user_data); - + fetch_cancel((MailDisplay *)data); + return FALSE; } -static void -fetch_next (MailDisplay *md) +static void fetch_next(MailDisplay *md) { struct _remote_data *rd; struct _MailDisplayPrivate *p = md->priv; SoupMessage *msg; SoupContext *ctx; - + /* if we're called and no more work to do, clean up, otherwise, setup */ if (e_dlist_empty(&p->fetch_active) && e_dlist_empty(&p->fetch_queue)) { if (p->fetch_msg) { @@ -1419,7 +1379,7 @@ static void fetch_remote(MailDisplay *md, const char *uri, GtkHTML *html, GtkHTM rd->md = md; /* dont ref */ rd->uri = g_strdup(uri); rd->html = html; - g_object_ref(html); + gtk_object_ref((GtkObject *)html); rd->stream = stream; rd->cstream = cstream; @@ -1474,7 +1434,7 @@ static void fetch_data(SoupMessage *req, void *data) static void fetch_free(struct _remote_data *rd) { - g_object_unref(rd->html); + gtk_object_unref((GtkObject *)rd->html); if (rd->cstream) camel_object_unref(rd->cstream); g_free(rd->uri); @@ -1573,9 +1533,9 @@ try_part_urls (struct _load_content_msg *m) return TRUE; } - html_stream = mail_display_stream_new (m->html, m->handle); + html_stream = mail_stream_gtkhtml_new (m->html, m->handle); camel_data_wrapper_write_to_stream (data, html_stream); - camel_object_unref (html_stream); + camel_object_unref (CAMEL_OBJECT (html_stream)); gtk_html_end (m->html, m->handle, GTK_HTML_STREAM_OK); return TRUE; @@ -1593,9 +1553,12 @@ try_data_urls (struct _load_content_msg *m) urls = g_datalist_get_data (m->display->data, "data_urls"); ba = g_hash_table_lookup (urls, m->url); + printf ("url: %s data: %p len: %d\n", m->url, ba, ba ? ba->len : -1); if (ba) { - if (ba->len) + if (ba->len) { + printf ("writing ...\n"); gtk_html_write (m->html, m->handle, ba->data, ba->len); + } gtk_html_end (m->html, m->handle, GTK_HTML_STREAM_OK); return TRUE; } @@ -1608,18 +1571,20 @@ load_content_loaded (struct _mail_msg *mm) { struct _load_content_msg *m = (struct _load_content_msg *)mm; - if (m->display->destroyed) + if (GTK_OBJECT_DESTROYED (m->display)) return; if (m->display->current_message == m->message) { if (m->handle) { + printf ("handle: %p orig: %d actual: %d\n", m->handle, + m->redisplay_counter, + m->display->redisplay_counter); if (m->redisplay_counter == m->display->redisplay_counter) { if (!try_part_urls (m) && !try_data_urls (m)) gtk_html_end (m->html, m->handle, GTK_HTML_STREAM_ERROR); } - } else { + } else mail_display_redisplay (m->display, FALSE); - } } } @@ -1629,9 +1594,9 @@ load_content_free (struct _mail_msg *mm) struct _load_content_msg *m = (struct _load_content_msg *)mm; g_free (m->url); - g_object_unref (m->html); - g_object_unref (m->display); - camel_object_unref (m->message); + gtk_object_unref (GTK_OBJECT (m->html)); + gtk_object_unref (GTK_OBJECT (m->display)); + camel_object_unref (CAMEL_OBJECT (m->message)); } static struct _mail_msg_op load_content_op = { @@ -1653,7 +1618,7 @@ stream_write_or_redisplay_when_loaded (MailDisplay *md, struct _load_content_msg *m; GHashTable *loading; - if (md->destroyed) + if (GTK_OBJECT_DESTROYED (md)) return; loading = g_datalist_get_data (md->data, "loading"); @@ -1663,20 +1628,20 @@ stream_write_or_redisplay_when_loaded (MailDisplay *md, } else { loading = g_hash_table_new (NULL, NULL); g_datalist_set_data_full (md->data, "loading", loading, - (GDestroyNotify) g_hash_table_destroy); + (GDestroyNotify)g_hash_table_destroy); } - g_hash_table_insert (loading, (gpointer) key, GINT_TO_POINTER (1)); + g_hash_table_insert (loading, (gpointer)key, GINT_TO_POINTER (1)); m = mail_msg_new (&load_content_op, NULL, sizeof (*m)); m->display = md; - g_object_ref((m->display)); + gtk_object_ref (GTK_OBJECT (m->display)); m->html = html; - g_object_ref((html)); + gtk_object_ref (GTK_OBJECT (html)); m->handle = handle; m->url = g_strdup (url); m->redisplay_counter = md->redisplay_counter; m->message = md->current_message; - camel_object_ref (m->message); + camel_object_ref (CAMEL_OBJECT (m->message)); m->callback = callback; m->data = data; @@ -1707,79 +1672,31 @@ mail_display_redisplay_when_loaded (MailDisplay *md, } void -mail_text_write (MailDisplayStream *stream, MailDisplay *md, CamelMimePart *part, - int idx, gboolean printing, const char *text) +mail_text_write (GtkHTML *html, GtkHTMLStream *stream, gboolean printing, const char *text) { - CamelStreamFilter *filtered_stream; - CamelMimeFilter *html_filter; - GConfClient *gconf; - guint32 flags, rgb; - GdkColor colour; - char *buf; - - gconf = gconf_client_get_default (); - - flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES; - - if (!printing) - flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; - - if (!printing && gconf_client_get_bool (gconf, "/apps/evolution/mail/display/mark_citations", NULL)) - flags |= CAMEL_MIME_FILTER_TOHTML_MARK_CITATION; - - buf = gconf_client_get_string (gconf, "/apps/evolution/mail/display/citation_colour", NULL); - gdk_color_parse (buf ? buf : "#737373", &colour); - g_free (buf); - - rgb = ((colour.red & 0xff00) << 8) | (colour.green & 0xff00) | ((colour.blue & 0xff00) >> 8); - html_filter = camel_mime_filter_tohtml_new (flags, rgb); - filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream); - camel_stream_filter_add (filtered_stream, html_filter); - camel_object_unref (html_filter); - - camel_stream_write ((CamelStream *) stream, "<tt>\n", 5); - camel_stream_write ((CamelStream *) filtered_stream, text, strlen (text)); - camel_stream_flush ((CamelStream *) filtered_stream); - camel_stream_write ((CamelStream *) stream, "</tt>\n", 6); - camel_object_unref (filtered_stream); - -#if 0 - /* this was the old way of doing it, I don't understand why we need iframes... */ - GByteArray *ba; - char *xed, *iframe; - char *btt = "<tt>\n"; - char *ett = "</tt>\n"; + guint flags; char *htmltext; - guint32 flags; - flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES; + flags = E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_SPACES; if (!printing) - flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; + flags |= E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_CONVERT_ADDRESSES; - if (!printing && mail_config_get_citation_highlight ()) - flags |= CAMEL_MIME_FILTER_TOHTML_MARK_CITATION; + if (mail_config_get_citation_highlight () && ! printing) + flags |= E_TEXT_TO_HTML_MARK_CITATION; - htmltext = camel_text_to_html (text, flags, mail_config_get_citation_color ()); + htmltext = e_text_to_html_full (text, flags, mail_config_get_citation_color ()); - ba = g_byte_array_new (); - g_byte_array_append (ba, (const guint8 *) btt, strlen (btt) + 1); - g_byte_array_append (ba, (const guint8 *) htmltext, strlen (htmltext) + 1); - g_byte_array_append (ba, (const guint8 *) ett, strlen (ett) + 1); + gtk_html_write (html, stream, "<tt>", 4); + gtk_html_write (html, stream, htmltext, strlen (htmltext)); + gtk_html_write (html, stream, "</tt>", 5); g_free (htmltext); - - xed = g_strdup_printf ("x-evolution-data:%p-%d", part, idx); - iframe = g_strdup_printf ("<iframe src=\"%s\" frameborder=0 scrolling=no>could not get %s</iframe>", xed, xed); - mail_display_add_url (md, "data_urls", xed, ba); - camel_stream_write ((CamelStream *) stream, iframe, strlen (iframe)); - g_free (iframe); -#endif } void -mail_error_printf (MailDisplayStream *stream, const char *format, ...) +mail_error_printf (GtkHTML *html, GtkHTMLStream *stream, + const char *format, ...) { - /* FIXME: it'd be nice if camel-stream had a vprintf method... */ char *buf, *htmltext; va_list ap; @@ -1787,13 +1704,12 @@ mail_error_printf (MailDisplayStream *stream, const char *format, ...) buf = g_strdup_vprintf (format, ap); va_end (ap); - htmltext = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | - CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); + htmltext = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); g_free (buf); - camel_stream_printf ((CamelStream *) stream, "<em><font color=red>"); - camel_stream_write ((CamelStream *) stream, htmltext, strlen (htmltext)); - camel_stream_printf ((CamelStream *) stream, "</font></em>"); + gtk_html_stream_printf (stream, "<em><font color=red>"); + gtk_html_stream_write (stream, htmltext, strlen (htmltext)); + gtk_html_stream_printf (stream, "</font></em>"); g_free (htmltext); } @@ -1801,31 +1717,26 @@ mail_error_printf (MailDisplayStream *stream, const char *format, ...) #define COLOR_IS_LIGHT(r, g, b) ((r + g + b) > (128 * 3)) -#define HTML_HEADER "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n" \ - "<head>\n<meta name=\"generator\" content=\"Evolution Mail Component\">\n</head>\n" - void mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) { const char *flag, *completed; - GtkHTMLStream *html_stream; - MailDisplayStream *stream; + GtkHTMLStream *stream; g_return_if_fail (IS_MAIL_DISPLAY (md)); g_return_if_fail (GTK_IS_HTML (html)); - html_stream = gtk_html_begin (html); + stream = gtk_html_begin (html); if (!reset_scroll) { /* This is a hack until there's a clean way to do this. */ GTK_HTML (md->html)->engine->newPage = FALSE; } - gtk_html_stream_write (html_stream, HTML_HEADER, sizeof (HTML_HEADER) - 1); - - if (md->current_message && md->display_style == MAIL_CONFIG_DISPLAY_SOURCE) - gtk_html_stream_write (html_stream, "<body>\n", 7); - else - gtk_html_stream_write (html_stream, "<body marginwidth=0 marginheight=0>\n", 36); + mail_html_write (html, stream, + "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n" + "<html>\n" + "<head>\n<meta name=\"generator\" content=\"Evolution Mail Component\">\n</head>\n"); + mail_html_write (html, stream, "<body marginwidth=0 marginheight=0>\n"); flag = md->info ? camel_tag_get (&md->info->user_tags, "follow-up") : NULL; completed = md->info ? camel_tag_get (&md->info->user_tags, "completed-on") : NULL; @@ -1839,7 +1750,6 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) int offset; /* my favorite thing to do... muck around with colors so we respect people's stupid themes. */ - /* FIXME: this is also in mail-format.c */ style = gtk_widget_get_style (GTK_WIDGET (html)); if (style && !md->printing) { int state = GTK_WIDGET_STATE (GTK_WIDGET (html)); @@ -1876,7 +1786,7 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) target_date = header_decode_date (due_by, &offset); now = time (NULL); if (now >= target_date) - overdue = _("Overdue:"); + overdue = U_("Overdue:"); localtime_r (&target_date, &due); @@ -1885,7 +1795,7 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) due_date[0] = '\0'; } - gtk_html_stream_printf (html_stream, "<font color=\"#%s\">" + gtk_html_stream_printf (stream, "<font color=\"#%s\">" "<table width=\"100%%\" cellpadding=0 cellspacing=0><tr><td colspan=3 height=10></td></tr>" "<tr><td width=10></td><td>" "<table cellspacing=1 cellpadding=1 bgcolor=\"#000000\" width=\"100%%\"><tr><td>" @@ -1899,18 +1809,14 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) } if (md->current_message) { - stream = (MailDisplayStream *) mail_display_stream_new (html, html_stream); - if (md->display_style == MAIL_CONFIG_DISPLAY_SOURCE) - mail_format_raw_message (md->current_message, md, stream); + mail_format_raw_message (md->current_message, md, html, stream); else - mail_format_mime_message (md->current_message, md, stream); - - camel_object_unref (stream); + mail_format_mime_message (md->current_message, md, html, stream); } - gtk_html_stream_write (html_stream, "</body></html>\n", 15); - gtk_html_end (html, html_stream, GTK_HTML_STREAM_OK); + mail_html_write (html, stream, "</body></html>\n"); + gtk_html_end (html, stream, GTK_HTML_STREAM_OK); } /** @@ -1923,15 +1829,9 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) void mail_display_redisplay (MailDisplay *md, gboolean reset_scroll) { - if (md->destroyed) + if (GTK_OBJECT_DESTROYED (md)) return; - /* we're in effect stealing the queued redisplay */ - if (md->idle_id) { - g_source_remove(md->idle_id); - md->idle_id = 0; - } - fetch_cancel(md); md->last_active = NULL; @@ -1964,7 +1864,7 @@ mail_display_set_message (MailDisplay *md, CamelMedium *medium, CamelFolder *fol /* Clean up from previous message. */ if (md->current_message) { fetch_cancel (md); - camel_object_unref (md->current_message); + camel_object_unref (CAMEL_OBJECT (md->current_message)); g_datalist_clear (md->data); } @@ -2006,7 +1906,7 @@ mail_display_set_charset (MailDisplay *mail_display, const char *charset) { g_free (mail_display->charset); mail_display->charset = g_strdup (charset); - + mail_display_queue_redisplay (mail_display); } @@ -2028,12 +1928,10 @@ mail_display_load_images (MailDisplay *md) *----------------------------------------------------------------------*/ static void -mail_display_init (GObject *object) +mail_display_init (GtkObject *object) { MailDisplay *mail_display = MAIL_DISPLAY (object); - GConfClient *gconf; - int style; - + mail_display->scroll = NULL; mail_display->html = NULL; mail_display->redisplay_counter = 0; @@ -2047,15 +1945,11 @@ mail_display_init (GObject *object) mail_display->data = NULL; mail_display->invisible = gtk_invisible_new (); - g_object_ref (mail_display->invisible); - gtk_object_sink ((GtkObject *) mail_display->invisible); - - gconf = gconf_client_get_default (); - style = gconf_client_get_int (gconf, "/apps/evolution/mail/format/message_display_style", NULL); - mail_display->display_style = style; - + + mail_display->display_style = mail_config_get_message_display_style (); + mail_display->printing = FALSE; - + mail_display->priv = g_malloc0(sizeof(*mail_display->priv)); e_dlist_init(&mail_display->priv->fetch_active); e_dlist_init(&mail_display->priv->fetch_queue); @@ -2065,48 +1959,33 @@ static void mail_display_destroy (GtkObject *object) { MailDisplay *mail_display = MAIL_DISPLAY (object); - - if (mail_display->html) { - g_object_unref (mail_display->html); - mail_display->html = NULL; - } + + gtk_object_unref (GTK_OBJECT (mail_display->html)); if (mail_display->current_message) { camel_object_unref (mail_display->current_message); g_datalist_clear (mail_display->data); fetch_cancel(mail_display); - mail_display->current_message = NULL; } g_free (mail_display->charset); - mail_display->charset = NULL; g_free (mail_display->selection); - mail_display->selection = NULL; if (mail_display->folder) { if (mail_display->info) camel_folder_free_message_info (mail_display->folder, mail_display->info); camel_object_unref (mail_display->folder); - mail_display->folder = NULL; } g_free (mail_display->data); mail_display->data = NULL; - if (mail_display->idle_id) { + if (mail_display->idle_id) gtk_timeout_remove (mail_display->idle_id); - mail_display->idle_id = 0; - } - if (mail_display->invisible) { - g_object_unref (mail_display->invisible); - mail_display->invisible = NULL; - } - - g_free (mail_display->priv); - mail_display->priv = NULL; - - mail_display->destroyed = TRUE; + gtk_widget_unref (mail_display->invisible); + + g_free(mail_display->priv); mail_display_parent_class->destroy (object); } @@ -2119,14 +1998,14 @@ invisible_selection_get_callback (GtkWidget *widget, void *data) { MailDisplay *display; - + display = MAIL_DISPLAY (data); if (!display->selection) return; g_assert (info == 1); - + gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING, 8, display->selection, strlen (display->selection)); } @@ -2137,12 +2016,12 @@ invisible_selection_clear_event_callback (GtkWidget *widget, void *data) { MailDisplay *display; - + display = MAIL_DISPLAY (data); - + g_free (display->selection); display->selection = NULL; - + return TRUE; } @@ -2150,22 +2029,21 @@ static void mail_display_class_init (GtkObjectClass *object_class) { object_class->destroy = mail_display_destroy; - + if (mail_display_parent_class == NULL) { /* blah, this is an unecessary dependency ... */ extern char *evolution_dir; - char *path; - - path = g_alloca (strlen (evolution_dir) + 16); - sprintf (path, "%s/cache", evolution_dir); - + char *path = alloca(strlen(evolution_dir)+16); + + sprintf(path, "%s/cache", evolution_dir); /* cache expiry - 2 hour access, 1 day max */ fetch_cache = camel_data_cache_new(path, 0, NULL); camel_data_cache_set_expire_age(fetch_cache, 24*60*60); camel_data_cache_set_expire_access(fetch_cache, 2*60*60); - - mail_display_parent_class = g_type_class_ref (PARENT_TYPE); + + mail_display_parent_class = gtk_type_class (PARENT_TYPE); thumbnail_cache = g_hash_table_new (g_str_hash, g_str_equal); + } } @@ -2191,18 +2069,18 @@ static void link_copy_location (GtkWidget *w, MailDisplay *mail_display) { GdkAtom clipboard_atom; - + g_free (mail_display->selection); mail_display->selection = g_strdup (mail_display->html->pointer_url); - + clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); if (clipboard_atom == GDK_NONE) return; /* failed */ - + /* We don't check the return values of the following since there is not * much we can do if we cannot assert the selection. */ - + gtk_selection_owner_set (GTK_WIDGET (mail_display->invisible), GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME); @@ -2215,8 +2093,10 @@ static void image_save_as (GtkWidget *w, MailDisplay *mail_display) { const char *src; - - src = g_object_get_data ((GObject *) mail_display, "current_src_uri"); + + src = gtk_object_get_data (GTK_OBJECT (mail_display), "current_src_uri"); + + g_warning ("loading uri=%s", src); save_url (mail_display, src); } @@ -2237,13 +2117,13 @@ enum { #define TERMINATOR { NULL, NULL, (NULL), NULL, 0 } static EPopupMenu link_menu [] = { - E_POPUP_ITEM (N_("Open Link in Browser"), G_CALLBACK (link_open_in_browser), MASK_URL), - E_POPUP_ITEM (N_("Copy Link Location"), G_CALLBACK (link_copy_location), MASK_URL), + E_POPUP_ITEM (N_("Open Link in Browser"), GTK_SIGNAL_FUNC (link_open_in_browser), MASK_URL), + E_POPUP_ITEM (N_("Copy Link Location"), GTK_SIGNAL_FUNC (link_copy_location), MASK_URL), #if 0 - E_POPUP_ITEM (N_("Save Link as (FIXME)"), G_CALLBACK (link_save_as), MASK_URL), + E_POPUP_ITEM (N_("Save Link as (FIXME)"), GTK_SIGNAL_FUNC (link_save_as), MASK_URL), #endif - E_POPUP_ITEM (N_("Save Image as..."), G_CALLBACK (image_save_as), MASK_SRC), - + E_POPUP_ITEM (N_("Save Image as..."), GTK_SIGNAL_FUNC (image_save_as), MASK_SRC), + TERMINATOR }; @@ -2259,7 +2139,7 @@ struct _PopupInfo { GtkWidget *win; guint destroy_timeout; guint widget_destroy_handle; - Bonobo_Listener listener; + Bonobo_EventSource_ListenerId listener_id; gboolean hidden; }; @@ -2267,55 +2147,64 @@ struct _PopupInfo { static GtkWidget *the_popup = NULL; static void -popup_window_destroy_cb (PopupInfo *pop, GObject *deadbeef) +popup_info_free (PopupInfo *pop) { - the_popup = NULL; + if (pop) { + if (pop->destroy_timeout) + gtk_timeout_remove (pop->destroy_timeout); - if (pop->destroy_timeout != 0) - g_source_remove(pop->destroy_timeout); + bonobo_event_source_client_remove_listener (bonobo_widget_get_objref (BONOBO_WIDGET (pop->w)), + pop->listener_id, + NULL); - bonobo_event_source_client_remove_listener (bonobo_widget_get_objref (BONOBO_WIDGET (pop->w)), - pop->listener, - NULL); - CORBA_Object_release (pop->listener, NULL); - g_object_unref(pop->w); - g_free (pop); + g_free (pop); + } } -static int +static void +popup_window_destroy_cb (GtkWidget *w, gpointer user_data) +{ + PopupInfo *pop = (PopupInfo *) user_data; + + the_popup = NULL; + + popup_info_free (pop); +} + +static gint popup_timeout_cb (gpointer user_data) { PopupInfo *pop = (PopupInfo *) user_data; pop->destroy_timeout = 0; gtk_widget_destroy (pop->win); - + return 0; } -static int +static gint popup_enter_cb (GtkWidget *w, GdkEventCrossing *ev, gpointer user_data) { PopupInfo *pop = (PopupInfo *) user_data; - + if (pop->destroy_timeout) gtk_timeout_remove (pop->destroy_timeout); pop->destroy_timeout = 0; - + return 0; } -static int +static gint popup_leave_cb (GtkWidget *w, GdkEventCrossing *ev, gpointer user_data) { PopupInfo *pop = (PopupInfo *) user_data; - + if (pop->destroy_timeout) gtk_timeout_remove (pop->destroy_timeout); - + if (!pop->hidden) pop->destroy_timeout = gtk_timeout_add (500, popup_timeout_cb, pop); - + return 0; } @@ -2323,9 +2212,9 @@ static void popup_realize_cb (GtkWidget *widget, gpointer user_data) { PopupInfo *pop = (PopupInfo *) user_data; - + gtk_widget_add_events (pop->win, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - + if (pop->destroy_timeout == 0) { if (!pop->hidden) { pop->destroy_timeout = gtk_timeout_add (5000, popup_timeout_cb, pop); @@ -2338,7 +2227,18 @@ popup_realize_cb (GtkWidget *widget, gpointer user_data) static void popup_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_data) { - gtk_window_set_position (GTK_WINDOW (widget), GTK_WIN_POS_MOUSE); + gint x, y, w, h, xmax, ymax; + + xmax = gdk_screen_width (); + ymax = gdk_screen_height (); + + gdk_window_get_pointer (NULL, &x, &y, NULL); + w = alloc->width; + h = alloc->height; + x = CLAMP (x - w/2, 0, xmax - w); + y = CLAMP (y - h/2, 0, ymax - h); + gtk_widget_set_uposition (widget, x, y); + } static PopupInfo * @@ -2346,32 +2246,45 @@ make_popup_window (GtkWidget *w) { PopupInfo *pop = g_new0 (PopupInfo, 1); GtkWidget *fr; - + /* Only allow for one popup at a time. Ugly. */ if (the_popup) gtk_widget_destroy (the_popup); - + pop->w = w; - g_object_ref(w); the_popup = pop->win = gtk_window_new (GTK_WINDOW_POPUP); fr = gtk_frame_new (NULL); - + gtk_container_add (GTK_CONTAINER (pop->win), fr); gtk_container_add (GTK_CONTAINER (fr), w); - - gtk_window_set_resizable (GTK_WINDOW (pop->win), FALSE); - - g_signal_connect (pop->win, "enter_notify_event", G_CALLBACK (popup_enter_cb), pop); - g_signal_connect (pop->win, "leave_notify_event", G_CALLBACK (popup_leave_cb), pop); - g_signal_connect_after (pop->win, "realize", G_CALLBACK (popup_realize_cb), pop); - g_signal_connect (pop->win, "size_allocate", G_CALLBACK (popup_size_allocate_cb), pop); - - g_object_weak_ref ((GObject *) pop->win, (GWeakNotify) popup_window_destroy_cb, pop); - + + gtk_window_set_policy (GTK_WINDOW (pop->win), FALSE, FALSE, FALSE); + + gtk_signal_connect (GTK_OBJECT (pop->win), + "destroy", + GTK_SIGNAL_FUNC (popup_window_destroy_cb), + pop); + gtk_signal_connect (GTK_OBJECT (pop->win), + "enter_notify_event", + GTK_SIGNAL_FUNC (popup_enter_cb), + pop); + gtk_signal_connect (GTK_OBJECT (pop->win), + "leave_notify_event", + GTK_SIGNAL_FUNC (popup_leave_cb), + pop); + gtk_signal_connect_after (GTK_OBJECT (pop->win), + "realize", + GTK_SIGNAL_FUNC (popup_realize_cb), + pop); + gtk_signal_connect (GTK_OBJECT (pop->win), + "size_allocate", + GTK_SIGNAL_FUNC (popup_size_allocate_cb), + pop); + gtk_widget_show (w); gtk_widget_show (fr); gtk_widget_show (pop->win); - + return pop; } @@ -2384,22 +2297,22 @@ listener_cb (BonoboListener *listener, { PopupInfo *pop; char *type; - + pop = user_data; - + if (pop->destroy_timeout) gtk_timeout_remove (pop->destroy_timeout); pop->destroy_timeout = 0; type = bonobo_event_subtype (event_name); - + if (!strcmp (type, "Destroy")) { gtk_widget_destroy (GTK_WIDGET (pop->win)); } else if (!strcmp (type, "Hide")) { pop->hidden = TRUE; gtk_widget_hide (GTK_WIDGET (pop->win)); } - + g_free (type); } @@ -2408,69 +2321,72 @@ html_button_press_event (GtkWidget *widget, GdkEventButton *event, MailDisplay * { g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (event != NULL, FALSE); - + if (event->type == GDK_BUTTON_PRESS) { if (event->button == 3) { HTMLEngine *e; HTMLPoint *point; GtkWidget *popup_thing; - + e = GTK_HTML (widget)->engine; point = html_engine_get_point_at (e, event->x + e->x_offset, event->y + e->y_offset, FALSE); if (point) { - const char *url, *src; - + const gchar *url; + const gchar *src; + url = html_object_get_url (point->object); src = html_object_get_src (point->object); - - if (url && !strncasecmp (url, "mailto:", 7)) { + + if (url && !g_strncasecmp (url, "mailto:", 7)) { PopupInfo *pop; - char *url_decoded; - + gchar *url_decoded; + url_decoded = gtk_html_get_url_object_relative (GTK_HTML (widget), point->object, url); camel_url_decode (url_decoded); - + popup_thing = bonobo_widget_new_control ("OAFIID:GNOME_Evolution_Addressbook_AddressPopup", CORBA_OBJECT_NIL); - + bonobo_widget_set_property (BONOBO_WIDGET (popup_thing), - "email", TC_CORBA_string, url_decoded+7, + "email", url_decoded+7, NULL); g_free (url_decoded); pop = make_popup_window (popup_thing); - - pop->listener = bonobo_event_source_client_add_listener_full( - bonobo_widget_get_objref (BONOBO_WIDGET (popup_thing)), - g_cclosure_new (G_CALLBACK (listener_cb), pop, NULL), - NULL, NULL); + + pop->listener_id = + bonobo_event_source_client_add_listener (bonobo_widget_get_objref (BONOBO_WIDGET (popup_thing)), + listener_cb, NULL, NULL, pop); + } else if (url || src) { - int hide_mask = 0; - + gint hide_mask = 0; + if (!url) hide_mask |= MASK_URL; - + if (!src) hide_mask |= MASK_SRC; - - g_free (g_object_get_data ((GObject *) mail_display, "current_src_uri")); - g_object_set_data ((GObject *) mail_display, "current_src_uri", - gtk_html_get_url_object_relative (GTK_HTML (widget), - point->object, - src)); + + g_free (gtk_object_get_data (GTK_OBJECT (mail_display), "current_src_uri")); + gtk_object_set_data (GTK_OBJECT (mail_display), "current_src_uri", + gtk_html_get_url_object_relative (GTK_HTML (widget), + point->object, + src)); e_popup_menu_run (link_menu, (GdkEvent *) event, 0, hide_mask, mail_display); + } - + html_point_destroy (point); - return TRUE; - } + } + + return TRUE; } } - + return FALSE; } @@ -2478,7 +2394,7 @@ static inline void set_underline (HTMLEngine *e, HTMLObject *o, gboolean underline) { HTMLText *text = HTML_TEXT (o); - + html_text_set_font_style (text, e, underline ? html_text_get_font_style (text) | GTK_HTML_FONT_STYLE_UNDERLINE : html_text_get_font_style (text) & ~GTK_HTML_FONT_STYLE_UNDERLINE); @@ -2491,9 +2407,9 @@ update_active (GtkWidget *widget, gint x, gint y, MailDisplay *mail_display) HTMLEngine *e; HTMLPoint *point; const gchar *email; - + e = GTK_HTML (widget)->engine; - + point = html_engine_get_point_at (e, x + e->x_offset, y + e->y_offset, FALSE); if (mail_display->last_active && (!point || mail_display->last_active != point->object)) { set_underline (e, HTML_OBJECT (mail_display->last_active), FALSE); @@ -2509,44 +2425,44 @@ update_active (GtkWidget *widget, gint x, gint y, MailDisplay *mail_display) } } -static int +static gint html_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event, MailDisplay *mail_display) { update_active (widget, event->x, event->y, mail_display); - - return FALSE; + + return TRUE; } -static int +static gint html_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, MailDisplay *mail_display) { - int x, y; - + gint x, y; + g_return_val_if_fail (widget != NULL, 0); g_return_val_if_fail (GTK_IS_HTML (widget), 0); g_return_val_if_fail (event != NULL, 0); - + if (event->is_hint) gdk_window_get_pointer (GTK_LAYOUT (widget)->bin_window, &x, &y, NULL); else { x = event->x; y = event->y; } - + update_active (widget, x, y, mail_display); - - return FALSE; + + return TRUE; } static void html_iframe_created (GtkWidget *w, GtkHTML *iframe, MailDisplay *mail_display) { - g_signal_connect (iframe, "button_press_event", - G_CALLBACK (html_button_press_event), mail_display); - g_signal_connect (iframe, "motion_notify_event", - G_CALLBACK (html_motion_notify_event), mail_display); - g_signal_connect (iframe, "enter_notify_event", - G_CALLBACK (html_enter_notify_event), mail_display); + gtk_signal_connect (GTK_OBJECT (iframe), "button_press_event", + GTK_SIGNAL_FUNC (html_button_press_event), mail_display); + gtk_signal_connect (GTK_OBJECT (iframe), "motion_notify_event", + GTK_SIGNAL_FUNC (html_motion_notify_event), mail_display); + gtk_signal_connect (GTK_OBJECT (iframe), "enter_notify_event", + GTK_SIGNAL_FUNC (html_enter_notify_event), mail_display); } static GNOME_Evolution_ShellView @@ -2555,25 +2471,25 @@ retrieve_shell_view_interface_from_control (BonoboControl *control) Bonobo_ControlFrame control_frame; GNOME_Evolution_ShellView shell_view_interface; CORBA_Environment ev; - - control_frame = bonobo_control_get_control_frame (control, NULL); - + + control_frame = bonobo_control_get_control_frame (control); + if (control_frame == NULL) return CORBA_OBJECT_NIL; - + CORBA_exception_init (&ev); shell_view_interface = Bonobo_Unknown_queryInterface (control_frame, "IDL:GNOME/Evolution/ShellView:1.0", &ev); CORBA_exception_free (&ev); - + if (shell_view_interface != CORBA_OBJECT_NIL) - g_object_set_data ((GObject *) control, - "mail_threads_shell_view_interface", - shell_view_interface); + gtk_object_set_data (GTK_OBJECT (control), + "mail_threads_shell_view_interface", + shell_view_interface); else g_warning ("Control frame doesn't have Evolution/ShellView."); - + return shell_view_interface; } @@ -2591,7 +2507,7 @@ set_status_message (const char *message, int busy) control = BONOBO_CONTROL (e_iterator_get (it)); - shell_view_interface = g_object_get_data ((GObject *) control, "mail_threads_shell_view_interface"); + shell_view_interface = gtk_object_get_data (GTK_OBJECT (control), "mail_threads_shell_view_interface"); if (shell_view_interface == CORBA_OBJECT_NIL) shell_view_interface = retrieve_shell_view_interface_from_control (control); @@ -2612,17 +2528,18 @@ set_status_message (const char *message, int busy) random ones lying around otherwise. Shrug. */ break; } - - g_object_unref (it); + gtk_object_unref (GTK_OBJECT(it)); } /* For now show every url but possibly limit it to showing only http: or ftp: urls */ static void -html_on_url (GtkHTML *html, const char *url, MailDisplay *mail_display) +html_on_url (GtkHTML *html, + const char *url, + MailDisplay *mail_display) { static char *previous_url = NULL; - + /* This all looks silly but yes, this is the proper way to mix GtkHTML's on_url with BonoboUIComponent statusbar */ if (!url || (previous_url && (strcmp (url, previous_url) != 0))) @@ -2637,7 +2554,7 @@ html_on_url (GtkHTML *html, const char *url, MailDisplay *mail_display) GtkWidget * mail_display_new (void) { - MailDisplay *mail_display = g_object_new (mail_display_get_type (), NULL); + MailDisplay *mail_display = gtk_type_new (mail_display_get_type ()); GtkWidget *scroll, *html; GdkAtom clipboard_atom; HTMLTokenizer *tok; @@ -2645,26 +2562,28 @@ mail_display_new (void) gtk_box_set_homogeneous (GTK_BOX (mail_display), FALSE); gtk_widget_show (GTK_WIDGET (mail_display)); - scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); - gtk_box_pack_start_defaults (GTK_BOX (mail_display), scroll); - gtk_widget_show (scroll); + scroll = e_scroll_frame_new (NULL, NULL); + e_scroll_frame_set_policy (E_SCROLL_FRAME (scroll), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scroll), GTK_SHADOW_IN); + gtk_box_pack_start_defaults (GTK_BOX (mail_display), GTK_WIDGET (scroll)); + gtk_widget_show (GTK_WIDGET (scroll)); html = gtk_html_new (); tok = e_searching_tokenizer_new (); html_engine_set_tokenizer (GTK_HTML (html)->engine, tok); - g_object_unref (tok); + gtk_object_unref (GTK_OBJECT (tok)); mail_display_initialize_gtkhtml (mail_display, GTK_HTML (html)); gtk_container_add (GTK_CONTAINER (scroll), html); gtk_widget_show (GTK_WIDGET (html)); - g_signal_connect (mail_display->invisible, "selection_get", - G_CALLBACK (invisible_selection_get_callback), mail_display); - g_signal_connect (mail_display->invisible, "selection_clear_event", - G_CALLBACK (invisible_selection_clear_event_callback), mail_display); + gtk_signal_connect (GTK_OBJECT (mail_display->invisible), "selection_get", + GTK_SIGNAL_FUNC (invisible_selection_get_callback), mail_display); + gtk_signal_connect (GTK_OBJECT (mail_display->invisible), "selection_clear_event", + GTK_SIGNAL_FUNC (invisible_selection_clear_event_callback), mail_display); gtk_selection_add_target (mail_display->invisible, GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING, 1); @@ -2674,9 +2593,9 @@ mail_display_new (void) gtk_selection_add_target (mail_display->invisible, clipboard_atom, GDK_SELECTION_TYPE_STRING, 1); - mail_display->scroll = GTK_SCROLLED_WINDOW (scroll); + mail_display->scroll = E_SCROLL_FRAME (scroll); mail_display->html = GTK_HTML (html); - g_object_ref (mail_display->html); + gtk_object_ref (GTK_OBJECT (mail_display->html)); mail_display->last_active = NULL; mail_display->data = g_new0 (GData *, 1); g_datalist_init (mail_display->data); @@ -2687,29 +2606,30 @@ mail_display_new (void) void mail_display_initialize_gtkhtml (MailDisplay *mail_display, GtkHTML *html) { - gtk_html_set_default_content_type (GTK_HTML (html), "text/html; charset=utf-8"); + gtk_html_set_default_content_type (GTK_HTML (html), + "text/html; charset=utf-8"); gtk_html_set_editable (GTK_HTML (html), FALSE); - g_signal_connect (html, "url_requested", - G_CALLBACK (on_url_requested), - mail_display); - g_signal_connect (html, "object_requested", - G_CALLBACK (on_object_requested), - mail_display); - g_signal_connect (html, "link_clicked", - G_CALLBACK (on_link_clicked), - mail_display); - g_signal_connect (html, "button_press_event", - G_CALLBACK (html_button_press_event), mail_display); - g_signal_connect (html, "motion_notify_event", - G_CALLBACK (html_motion_notify_event), mail_display); - g_signal_connect (html, "enter_notify_event", - G_CALLBACK (html_enter_notify_event), mail_display); - g_signal_connect (html, "iframe_created", - G_CALLBACK (html_iframe_created), mail_display); - g_signal_connect (html, "on_url", - G_CALLBACK (html_on_url), mail_display); + gtk_signal_connect (GTK_OBJECT (html), "url_requested", + GTK_SIGNAL_FUNC (on_url_requested), + mail_display); + gtk_signal_connect (GTK_OBJECT (html), "object_requested", + GTK_SIGNAL_FUNC (on_object_requested), + mail_display); + gtk_signal_connect (GTK_OBJECT (html), "link_clicked", + GTK_SIGNAL_FUNC (on_link_clicked), + mail_display); + gtk_signal_connect (GTK_OBJECT (html), "button_press_event", + GTK_SIGNAL_FUNC (html_button_press_event), mail_display); + gtk_signal_connect (GTK_OBJECT (html), "motion_notify_event", + GTK_SIGNAL_FUNC (html_motion_notify_event), mail_display); + gtk_signal_connect (GTK_OBJECT (html), "enter_notify_event", + GTK_SIGNAL_FUNC (html_enter_notify_event), mail_display); + gtk_signal_connect (GTK_OBJECT (html), "iframe_created", + GTK_SIGNAL_FUNC (html_iframe_created), mail_display); + gtk_signal_connect (GTK_OBJECT (html), "on_url", + GTK_SIGNAL_FUNC (html_on_url), mail_display); } static void @@ -2762,8 +2682,7 @@ mail_display_get_url_for_icon (MailDisplay *md, const char *icon_name) if (*icon_name == '/') icon_path = g_strdup (icon_name); else { - icon_path = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, - icon_name, TRUE, NULL); + icon_path = gnome_pixmap_file (icon_name); if (!icon_path) return "file:///dev/null"; } diff --git a/mail/mail-format.c b/mail/mail-format.c index f47ebccd4d..7ca745187a 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -3,7 +3,7 @@ * Authors: Dan Winship <danw@ximian.com> * Jeffrey Stedfast <fejj@ximian.com> * - * Copyright 2000, 2003 Ximian, Inc. + * Copyright 2000, 2001 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -30,69 +30,87 @@ #include <ctype.h> #include <fcntl.h> -#include <gconf/gconf.h> -#include <gconf/gconf-client.h> - +#include <liboaf/liboaf.h> +#include <libgnome/gnome-defs.h> #include <libgnome/gnome-util.h> +#include <libgnomevfs/gnome-vfs-mime-info.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h> -#include <shell/e-setup.h> - +#include <gal/widgets/e-unicode.h> #include <gal/util/e-iconv.h> #include <camel/camel-mime-utils.h> #include <camel/camel-pgp-mime.h> #include <camel/camel-stream-null.h> -#include <camel/camel-stream-filter.h> #include <camel/camel-multipart-signed.h> -#include <camel/camel-mime-filter-enriched.h> -#include <camel/camel-mime-filter-tohtml.h> - -#include <e-util/e-trie.h> +#include <shell/e-setup.h> +#include <e-util/e-html-utils.h> +#include <gal/util/e-unicode-i18n.h> #include "mail.h" #include "mail-tools.h" #include "mail-display.h" -#include "mail-format.h" #include "mail-mt.h" #include "mail-crypto.h" - -#define STANDARD_ISSUE_TABLE_OPEN "<table cellspacing=0 cellpadding=10 width=\"100%\">" - - -static gboolean handle_text_plain (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_text_enriched (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_text_html (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_image (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_multipart_mixed (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_multipart_related (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_multipart_alternative (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_multipart_appledouble (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_multipart_signed (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_message_rfc822 (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); -static gboolean handle_message_external_body (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); - -static gboolean handle_via_bonobo (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream); +static char *try_inline_pgp (char *start, CamelMimePart *part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static char *try_inline_pgp_sig (char *start, CamelMimePart *part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static char *try_uudecoding (char *start, CamelMimePart *part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static char *try_inline_binhex (char *start, CamelMimePart *part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); + +static gboolean handle_text_plain (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_text_plain_flowed (char *text, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_text_enriched (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_text_html (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_image (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_multipart_mixed (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_multipart_related (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_multipart_alternative (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_multipart_appledouble (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_multipart_encrypted (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_multipart_signed (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_message_rfc822 (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_message_external_body (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); + +static gboolean handle_via_bonobo (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); /* writes the header info for a mime message into an html stream */ -static void write_headers (MailDisplayStream *stream, MailDisplay *md, CamelMimeMessage *message); +static void write_headers (CamelMimeMessage *message, MailDisplay *md, + GtkHTML *html, GtkHTMLStream *stream); /* dispatch html printing via mimetype */ -static gboolean format_mime_part (CamelMimePart *part, MailDisplay *md, MailDisplayStream *stream); +static gboolean format_mime_part (CamelMimePart *part, MailDisplay *md, + GtkHTML *html, GtkHTMLStream *stream); static void free_url (gpointer key, gpointer value, gpointer data) @@ -125,12 +143,12 @@ free_data_urls (gpointer urls) **/ void mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md, - MailDisplayStream *stream) + GtkHTML *html, GtkHTMLStream *stream) { GHashTable *hash; g_return_if_fail (CAMEL_IS_MIME_MESSAGE (mime_message)); - + hash = g_datalist_get_data (md->data, "part_urls"); if (!hash) { hash = g_hash_table_new (g_str_hash, g_str_equal); @@ -157,8 +175,8 @@ mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md, (GDestroyNotify) g_hash_table_destroy); } - write_headers (stream, md, mime_message); - format_mime_part (CAMEL_MIME_PART (mime_message), md, stream); + write_headers (mime_message, md, html, stream); + format_mime_part (CAMEL_MIME_PART (mime_message), md, html, stream); } @@ -171,33 +189,32 @@ mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md, **/ void mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md, - MailDisplayStream *stream) + GtkHTML *html, GtkHTMLStream *stream) { - CamelStreamFilter *filtered_stream; - CamelMimeFilter *html_filter; - CamelDataWrapper *wrapper; - guint32 flags; + GByteArray *bytes; + char *html_str; g_return_if_fail (CAMEL_IS_MIME_MESSAGE (mime_message)); - wrapper = CAMEL_DATA_WRAPPER (mime_message); - if (!mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL)) + if (!mail_content_loaded (CAMEL_DATA_WRAPPER (mime_message), md, + TRUE, NULL, html, NULL)) return; - filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream); - - flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | - CAMEL_MIME_FILTER_TOHTML_ESCAPE_8BIT; - html_filter = camel_mime_filter_tohtml_new (flags, 0); - camel_stream_filter_add (filtered_stream, html_filter); - camel_object_unref (html_filter); + mail_html_write (html, stream, + "<table cellspacing=0 cellpadding=10 width=\"100%\"><tr><td><tt>\n"); - camel_stream_write_string ((CamelStream *) stream, STANDARD_ISSUE_TABLE_OPEN "<tr><td><tt>"); - - mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream); - camel_object_unref (filtered_stream); + bytes = mail_format_get_data_wrapper_text (CAMEL_DATA_WRAPPER (mime_message), md); + if (bytes) { + g_byte_array_append (bytes, "", 1); + html_str = e_text_to_html (bytes->data, E_TEXT_TO_HTML_CONVERT_NL | + E_TEXT_TO_HTML_CONVERT_SPACES | E_TEXT_TO_HTML_ESCAPE_8BIT); + g_byte_array_free (bytes, TRUE); + + mail_html_write (html, stream, html_str); + g_free (html_str); + } - camel_stream_write_string ((CamelStream *) stream, "</tt></td></tr></table>"); + mail_html_write (html, stream, "</tt></td></tr></table>"); } static const char * @@ -210,7 +227,8 @@ get_cid (CamelMimePart *part, MailDisplay *md) * make a (syntactically invalid, unique) fake one. */ if (camel_mime_part_get_content_id (part)) { - cid = g_strdup_printf ("cid:%s", camel_mime_part_get_content_id (part)); + cid = g_strdup_printf ("cid:%s", + camel_mime_part_get_content_id (part)); } else cid = g_strdup_printf ("cid:@@@%d", fake_cid_counter++); @@ -336,38 +354,38 @@ setup_mime_tables (void) } static gboolean -component_supports (Bonobo_ServerInfo *component, const char *mime_type) +component_supports (OAF_ServerInfo *component, const char *mime_type) { - Bonobo_ActivationProperty *prop; + OAF_Property *prop; CORBA_sequence_CORBA_string stringv; int i; - - prop = bonobo_server_info_prop_find (component, "repo_ids"); - if (!prop || prop->v._d != Bonobo_ACTIVATION_P_STRINGV) + + prop = oaf_server_info_prop_find (component, "repo_ids"); + if (!prop || prop->v._d != OAF_P_STRINGV) return FALSE; - + stringv = prop->v._u.value_stringv; for (i = 0; i < stringv._length; i++) { - if (!strcasecmp ("IDL:Bonobo/PersistStream:1.0", stringv._buffer[i])) + if (!g_strcasecmp ("IDL:Bonobo/PersistStream:1.0", stringv._buffer[i])) break; } - + /* got to end of list with no persist stream? */ - + if (i >= stringv._length) return FALSE; - - prop = bonobo_server_info_prop_find (component, - "bonobo:supported_mime_types"); - if (!prop || prop->v._d != Bonobo_ACTIVATION_P_STRINGV) + + prop = oaf_server_info_prop_find (component, + "bonobo:supported_mime_types"); + if (!prop || prop->v._d != OAF_P_STRINGV) return FALSE; - + stringv = prop->v._u.value_stringv; for (i = 0; i < stringv._length; i++) { - if (!strcasecmp (mime_type, stringv._buffer[i])) + if (!g_strcasecmp (mime_type, stringv._buffer[i])) return TRUE; } - + return FALSE; } @@ -392,15 +410,15 @@ mail_lookup_handler (const char *mime_type) char *mime_type_main; const char *p; GList *components, *iter; - + if (mime_handler_table == NULL) setup_mime_tables (); - + /* See if we've already found it. */ handler = g_hash_table_lookup (mime_handler_table, mime_type); if (handler) return handler; - + /* Special case MIME type: application/octet-stream * The point of this type is that there isn't a handler. */ @@ -416,13 +434,12 @@ mail_lookup_handler (const char *mime_type) gnome_vfs_mime_get_short_list_applications (mime_type); handler->builtin = g_hash_table_lookup (mime_function_table, mime_type); - + if (handler->builtin) { handler->generic = FALSE; - handler->is_bonobo = FALSE; goto reg; } - + /* Try for the first matching component. (we don't use get_short_list_comps * as that will return NULL if the oaf files don't have the short_list properties * defined). */ @@ -432,19 +449,19 @@ mail_lookup_handler (const char *mime_type) handler->generic = FALSE; handler->is_bonobo = TRUE; handler->builtin = handle_via_bonobo; - handler->component = Bonobo_ServerInfo_duplicate (iter->data); + handler->component = OAF_ServerInfo_duplicate (iter->data); gnome_vfs_mime_component_list_free (components); goto reg; } } - + gnome_vfs_mime_component_list_free (components); - + /* Try for a generic builtin match. */ p = strchr (mime_type, '/'); if (p == NULL) p = mime_type + strlen (mime_type); - mime_type_main = g_alloca ((p - mime_type) + 3); + mime_type_main = alloca ((p - mime_type) + 3); memcpy (mime_type_main, mime_type, p - mime_type); memcpy (mime_type_main + (p - mime_type), "/*", 3); @@ -453,36 +470,34 @@ mail_lookup_handler (const char *mime_type) if (handler->builtin) { handler->generic = TRUE; - handler->is_bonobo = FALSE; if (handler->component) { CORBA_free (handler->component); handler->component = NULL; } goto reg; } - + /* Try for a generic component match. */ if (handler->component) { handler->generic = TRUE; - handler->is_bonobo = TRUE; handler->builtin = handle_via_bonobo; + handler->is_bonobo = TRUE; goto reg; } - + /* If we at least got an application, use that. */ if (handler->applications) { handler->generic = TRUE; - handler->is_bonobo = FALSE; goto reg; } - + /* Nada. */ g_free (handler); return NULL; - + reg: - g_hash_table_insert (mime_handler_table, g_strdup (mime_type), handler); - + g_hash_table_insert (mime_handler_table, g_strdup (mime_type), + handler); return handler; } @@ -492,12 +507,11 @@ mail_lookup_handler (const char *mime_type) static gboolean is_anonymous (CamelMimePart *part, const char *mime_type) { - /* FIXME: should use CamelContentType stuff */ - if (!strncasecmp (mime_type, "multipart/", 10) || - !strncasecmp (mime_type, "message/", 8)) + if (!g_strncasecmp (mime_type, "multipart/", 10) || + !g_strncasecmp (mime_type, "message/", 8)) return TRUE; - if (!strncasecmp (mime_type, "text/", 5) && + if (!g_strncasecmp (mime_type, "text/", 5) && !camel_mime_part_get_filename (part)) return TRUE; @@ -515,13 +529,13 @@ mail_part_is_inline (CamelMimePart *part) { const char *disposition; CamelContentType *content_type; - gboolean anon; char *type; + gboolean anon; /* If it has an explicit disposition, return that. */ disposition = camel_mime_part_get_disposition (part); if (disposition) - return strcasecmp (disposition, "inline") == 0; + return g_strcasecmp (disposition, "inline") == 0; /* Certain types should default to inline. FIXME: this should * be customizable. @@ -546,28 +560,28 @@ enum inline_states { I_DISPLAYED = (1 << 2) }; -static int +static gint get_inline_flags (CamelMimePart *part, MailDisplay *md) { GHashTable *asht; - int val; - + gint val; + /* check if we already know. */ - + asht = g_datalist_get_data (md->data, "attachment_states"); val = GPOINTER_TO_INT (g_hash_table_lookup (asht, part)); if (val) return val; - + /* ok, we don't know. Figure it out. */ - + if (mail_part_is_inline (part)) val = (I_VALID | I_ACTUALLY | I_DISPLAYED); else val = (I_VALID); - + g_hash_table_insert (asht, part, GINT_TO_POINTER (val)); - + return val; } @@ -582,7 +596,7 @@ mail_part_toggle_displayed (CamelMimePart *part, MailDisplay *md) { GHashTable *asht = g_datalist_get_data (md->data, "attachment_states"); gpointer ostate, opart; - int state; + gint state; if (g_hash_table_lookup_extended (asht, part, &opart, &ostate)) { g_hash_table_remove (asht, part); @@ -605,71 +619,77 @@ mail_part_set_default_displayed_inline (CamelMimePart *part, MailDisplay *md, gboolean displayed) { GHashTable *asht = g_datalist_get_data (md->data, "attachment_states"); - int state; + gint state; if (g_hash_table_lookup (asht, part)) return; - + state = I_VALID | (displayed ? I_DISPLAYED : 0); g_hash_table_insert (asht, part, GINT_TO_POINTER (state)); } static void attachment_header (CamelMimePart *part, const char *mime_type, MailDisplay *md, - MailDisplayStream *stream) + GtkHTML *html, GtkHTMLStream *stream) { - char *htmlinfo; + char *htmlinfo, *html_str, *fmt; const char *info; /* Start the table, create the pop-up object. */ - camel_stream_write_string ((CamelStream *) stream, "<table cellspacing=0 cellpadding=0><tr><td>" - "<table width=10 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td>"); - - if (!md->printing) { - camel_stream_printf ((CamelStream *) stream, "<td><object classid=\"popup:%s\"" - "type=\"%s\"></object></td>", get_cid (part, md), mime_type); + mail_html_write (html, stream, + "<table cellspacing=0 cellpadding=0>" + "<tr><td><table width=10 cellspacing=0 cellpadding=0><tr><td></td></tr></table></td>"); + + if (! md->printing) { + gtk_html_stream_printf (stream, "<td><object classid=\"popup:%s\" type=\"%s\"></object></td>", + get_cid (part, md), mime_type); } - camel_stream_write_string ((CamelStream *) stream, "<td><table width=3 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td><td><font size=-1>"); + mail_html_write (html, stream, + "<td><table width=3 cellspacing=0 cellpadding=0><tr><td></td></tr></table></td>" + "<td><font size=-1>"); + /* Write the MIME type */ - info = gnome_vfs_mime_get_description (mime_type); - htmlinfo = camel_text_to_html (info ? info : mime_type, 0, 0); - camel_stream_printf ((CamelStream *) stream, _("%s attachment"), htmlinfo); + info = gnome_vfs_mime_get_value (mime_type, "description"); + html_str = e_text_to_html (info ? info : mime_type, 0); + htmlinfo = e_utf8_from_locale_string (html_str); + g_free (html_str); + fmt = e_utf8_from_locale_string (_("%s attachment")); + gtk_html_stream_printf (stream, fmt, htmlinfo); g_free (htmlinfo); - + g_free (fmt); + /* Write the name, if we have it. */ info = camel_mime_part_get_filename (part); if (info) { - htmlinfo = camel_text_to_html (info, 0, 0); - camel_stream_printf ((CamelStream *) stream, " (%s)", htmlinfo); + htmlinfo = e_text_to_html (info, 0); + gtk_html_stream_printf (stream, " (%s)", htmlinfo); g_free (htmlinfo); } /* Write a description, if we have one. */ info = camel_mime_part_get_description (part); if (info) { - htmlinfo = camel_text_to_html (info, md->printing ? 0 : CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_printf ((CamelStream *) stream, ", \"%s\"", htmlinfo); + htmlinfo = e_text_to_html (info, md->printing ? 0 : E_TEXT_TO_HTML_CONVERT_URLS); + gtk_html_stream_printf (stream, ", \"%s\"", htmlinfo); g_free (htmlinfo); } - camel_stream_write_string ((CamelStream *) stream, "</font></td></tr><tr><td height=10>" - "<table cellspacing=0 cellpadding=0><tr><td height=10>" - "<a name=\"glue\"></td></tr></table></td></tr></table>\n"); + mail_html_write (html, stream, "</font></td></tr><tr>" + "<td height=10><table height=10 cellspacing=0 cellpadding=0>" + "<tr><td></td></tr></table></td></tr></table>\n"); } static gboolean format_mime_part (CamelMimePart *part, MailDisplay *md, - MailDisplayStream *stream) + GtkHTML *html, GtkHTMLStream *stream) { CamelDataWrapper *wrapper; + char *mime_type; MailMimeHandler *handler; gboolean output; int inline_flags; - char *mime_type; /* Record URLs associated with this part */ get_cid (part, md); @@ -679,14 +699,15 @@ format_mime_part (CamelMimePart *part, MailDisplay *md, if (CAMEL_IS_MULTIPART (wrapper) && camel_multipart_get_number (CAMEL_MULTIPART (wrapper)) == 0) { - mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source.")); - if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL)) - handle_text_plain (part, "text/plain", md, stream); + + mail_error_printf (html, stream, "\n%s\n", U_("Could not parse MIME message. Displaying as source.")); + if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL)) + handle_text_plain (part, "text/plain", md, html, stream); return TRUE; } mime_type = camel_data_wrapper_get_mime_type (wrapper); - camel_strdown (mime_type); + g_strdown (mime_type); handler = mail_lookup_handler (mime_type); if (!handler) { @@ -713,11 +734,11 @@ format_mime_part (CamelMimePart *part, MailDisplay *md, /* No header for anonymous inline parts. */ if (!((inline_flags & I_ACTUALLY) && is_anonymous (part, mime_type))) - attachment_header (part, mime_type, md, stream); + attachment_header (part, mime_type, md, html, stream); if (handler && handler->builtin && inline_flags & I_DISPLAYED && - mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL)) - output = (*handler->builtin) (part, mime_type, md, stream); + mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL)) + output = (*handler->builtin) (part, mime_type, md, html, stream); else output = TRUE; @@ -732,119 +753,129 @@ enum { }; static void -write_field_row_begin (MailDisplayStream *stream, const char *name, int flags) +write_field_row_begin (const char *name, gint flags, GtkHTML *html, GtkHTMLStream *stream) { + char *encoded_name; gboolean bold = (flags & WRITE_BOLD); gboolean nocolumns = (flags & WRITE_NOCOLUMNS); + encoded_name = e_utf8_from_gtk_string (GTK_WIDGET (html), name); + if (nocolumns) { - camel_stream_printf ((CamelStream *) stream, "<tr><td>%s%s:%s ", - bold ? "<b>" : "", name, bold ? "</b>" : ""); + gtk_html_stream_printf (stream, "<tr><td>%s%s:%s ", + bold ? "<b>" : "", encoded_name, + bold ? "</b>" : ""); } else { - camel_stream_printf ((CamelStream *) stream, - "<tr><%s align=\"right\" valign=\"top\">%s:" - "<b> </%s><td>", bold ? "th" : "td", - name, bold ? "th" : "td"); + gtk_html_stream_printf (stream, "<tr><%s align=\"right\" valign=\"top\">%s:" + "<b> </%s><td>", bold ? "th" : "td", + encoded_name, bold ? "th" : "td"); } + + g_free (encoded_name); } static void -write_date (MailDisplayStream *stream, CamelMimeMessage *message, int flags) +write_date (CamelMimeMessage *message, int flags, GtkHTML *html, GtkHTMLStream *stream) { const char *datestr; datestr = camel_medium_get_header (CAMEL_MEDIUM (message), "Date"); if (datestr) { - write_field_row_begin (stream, _("Date"), flags); - camel_stream_printf ((CamelStream *) stream, "%s</td> </tr>", datestr); + write_field_row_begin (_("Date"), flags, html, stream); + gtk_html_stream_printf (stream, "%s</td> </tr>", datestr); } } static void -write_text_header (MailDisplayStream *stream, const char *name, const char *value, int flags) +write_text_header (const char *name, const char *value, int flags, GtkHTML *html, GtkHTMLStream *stream) { char *encoded; - + if (value && *value) - encoded = camel_text_to_html (value, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | - CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | - CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); + encoded = e_text_to_html (value, E_TEXT_TO_HTML_CONVERT_NL | + E_TEXT_TO_HTML_CONVERT_SPACES | + E_TEXT_TO_HTML_CONVERT_URLS); else encoded = ""; - write_field_row_begin (stream, name, flags); + write_field_row_begin (name, flags, html, stream); - camel_stream_printf ((CamelStream *) stream, "%s</td></tr>", encoded); + gtk_html_stream_printf (stream, "%s</td> </tr>", encoded); if (value && *value) g_free (encoded); } static void -write_address (MailDisplay *md, MailDisplayStream *stream, +write_address (MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream, const CamelInternetAddress *addr, const char *field_name, int flags) { const char *name, *email; - int i; + gint i; if (addr == NULL || !camel_internet_address_get (addr, 0, NULL, NULL)) return; - write_field_row_begin (stream, field_name, flags); + write_field_row_begin (field_name, flags, html, stream); i = 0; while (camel_internet_address_get (addr, i, &name, &email)) { CamelInternetAddress *subaddr; - char *addr_txt, *addr_url; + gchar *addr_txt, *addr_url; gboolean have_name = name && *name; gboolean have_email = email && *email; - char *name_disp = NULL; - char *email_disp = NULL; - + gchar *name_disp = NULL; + gchar *email_disp = NULL; + subaddr = camel_internet_address_new (); camel_internet_address_add (subaddr, name, email); addr_txt = camel_address_format (CAMEL_ADDRESS (subaddr)); - addr_url = camel_url_encode (addr_txt, NULL); - camel_object_unref (subaddr); + addr_url = camel_url_encode (addr_txt, TRUE, NULL); + camel_object_unref (CAMEL_OBJECT (subaddr)); if (have_name) { - name_disp = camel_text_to_html (name, 0, 0); + name_disp = e_text_to_html (name, 0); } if (have_email) { - email_disp = camel_text_to_html (email, 0, 0); + email_disp = e_text_to_html (email, 0); } if (i) - camel_stream_write_string ((CamelStream *) stream, ", "); + mail_html_write (html, stream, ", "); if (have_email || have_name) { - if (!have_email) + if (!have_email) { email_disp = g_strdup ("???"); + } if (have_name) { if (md->printing) { - camel_stream_printf ((CamelStream *) stream, - "%s <%s>", name_disp, email_disp); + gtk_html_stream_printf (stream, "%s <%s>", name_disp, email_disp); } else { - camel_stream_printf ((CamelStream *) stream, - "%s <<a href=\"mailto:%s\">%s</a>>", - name_disp, addr_url, email_disp); + gtk_html_stream_printf (stream, + "%s <<a href=\"mailto:%s\">%s</a>>", + name_disp, addr_url, email_disp); } } else { if (md->printing) { - camel_stream_write_string ((CamelStream *) stream, email_disp); + mail_html_write (html, stream, email_disp); } else { - camel_stream_printf ((CamelStream *) stream, - "<a href=\"mailto:%s\">%s</a>", - addr_url, email_disp); + gtk_html_stream_printf (stream, + "<a href=\"mailto:%s\">%s</a>", + addr_url, email_disp); } - } + } + } else { - camel_stream_printf ((CamelStream *) stream, "<i>%s</i>", _("Bad Address")); + char *str; + + str = e_utf8_from_locale_string (_("Bad Address")); + gtk_html_stream_printf (stream, "<i>%s</i>", str); + g_free (str); } - + g_free (name_disp); g_free (email_disp); g_free (addr_txt); @@ -853,7 +884,7 @@ write_address (MailDisplay *md, MailDisplayStream *stream, i++; } - camel_stream_write_string ((CamelStream *) stream, "</td></tr>"); + mail_html_write (html, stream, "</td></tr>"); } /* order of these must match write_header code */ @@ -863,12 +894,12 @@ static char *default_headers[] = { /* return index of header in default_headers array */ static int -default_header_index (const char *name) +default_header_index(const char *name) { int i; - - for (i = 0; i < sizeof (default_headers) / sizeof (default_headers[0]); i++) - if (!strcasecmp (name, default_headers[i])) + + for (i=0;i<sizeof(default_headers)/sizeof(default_headers[0]);i++) + if (!g_strcasecmp(name, default_headers[i])) return i; return -1; @@ -876,88 +907,87 @@ default_header_index (const char *name) /* index is index of header in default_headers array */ static void -write_default_header (CamelMimeMessage *message, MailDisplay *md, - MailDisplayStream *stream, - int index, int flags) +write_default_header(CamelMimeMessage *message, MailDisplay *md, + GtkHTML *html, GtkHTMLStream *stream, + int index, int flags) { - switch (index) { + switch(index) { case 0: - write_address (md, stream, + write_address (md, html, stream, camel_mime_message_get_from (message), _("From"), flags | WRITE_BOLD); break; case 1: - write_address (md, stream, + write_address (md, html, stream, camel_mime_message_get_reply_to (message), _("Reply-To"), flags | WRITE_BOLD); break; case 2: - write_address (md, stream, - camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO), + write_address(md, html, stream, + camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_TO), _("To"), flags | WRITE_BOLD); break; case 3: - write_address (md, stream, + write_address (md, html, stream, camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC), _("Cc"), flags | WRITE_BOLD); break; case 4: - write_address (md, stream, + write_address (md, html, stream, camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC), _("Bcc"), flags | WRITE_BOLD); break; case 5: - write_text_header (stream, _("Subject"), camel_mime_message_get_subject (message), - flags | WRITE_BOLD); + write_text_header (_("Subject"), camel_mime_message_get_subject (message), + flags | WRITE_BOLD, html, stream); break; case 6: - write_date (stream, message, flags | WRITE_BOLD); + write_date (message, flags | WRITE_BOLD, html, stream); break; default: - g_assert_not_reached (); + g_assert_not_reached(); } } static gboolean write_xmailer_header (CamelMimeMessage *message, MailDisplay *md, - MailDisplayStream *stream, int xmask) + GtkHTML *html, GtkHTMLStream *stream, + MailConfigXMailerDisplayStyle xm) { const char *xmailer, *evolution; - + xmailer = camel_medium_get_header (CAMEL_MEDIUM (message), "X-Mailer"); if (!xmailer) { xmailer = camel_medium_get_header (CAMEL_MEDIUM (message), "User-Agent"); if (!xmailer) return FALSE; } - + evolution = strstr (xmailer, "Evolution"); - if ((xmask & MAIL_CONFIG_XMAILER_OTHER) || - (evolution && (xmask & MAIL_CONFIG_XMAILER_EVO))) - write_text_header (stream, _("Mailer"), xmailer, WRITE_BOLD); - - return evolution != NULL && (xmask & MAIL_CONFIG_XMAILER_RUPERT_APPROVED); + if ((xm & MAIL_CONFIG_XMAILER_OTHER) || + (evolution && (xm & MAIL_CONFIG_XMAILER_EVO))) + write_text_header (_("Mailer"), xmailer, WRITE_BOLD, html, stream); + + return evolution != NULL && (xm & MAIL_CONFIG_XMAILER_RUPERT_APPROVED); } #define COLOR_IS_LIGHT(r, g, b) ((r + g + b) > (128 * 3)) static void -write_headers (MailDisplayStream *stream, MailDisplay *md, CamelMimeMessage *message) +write_headers (CamelMimeMessage *message, MailDisplay *md, + GtkHTML *html, GtkHTMLStream *stream) { + MailConfigXMailerDisplayStyle xm = mail_config_get_x_mailer_display_style (); gboolean full = (md->display_style == MAIL_CONFIG_DISPLAY_FULL_HEADERS); char bgcolor[7], fontcolor[7]; GtkStyle *style = NULL; gboolean evo_icon = FALSE; - GConfClient *gconf; - int xmask, i; - - gconf = gconf_client_get_default (); - xmask = gconf_client_get_int (gconf, "/apps/evolution/mail/display/xmailer_mask", NULL); - + int i; + /* My favorite thing to do... muck around with colors so we respect people's stupid themes. However, we only do this if we are rendering to the screen -- we ignore the theme when we are printing. */ - style = gtk_widget_get_style (GTK_WIDGET (md->html)); + style = gtk_widget_get_style (GTK_WIDGET (html)); if (style && !md->printing) { - int state = GTK_WIDGET_STATE (GTK_WIDGET (md->html)); + int state = GTK_WIDGET_STATE (GTK_WIDGET (html)); gushort r, g, b; r = style->base[state].red / 256; @@ -986,28 +1016,20 @@ write_headers (MailDisplayStream *stream, MailDisplay *md, CamelMimeMessage *mes strcpy (fontcolor, "000000"); } - camel_stream_write_string ((CamelStream *) stream, - "<table width=\"100%\" cellpadding=0 cellspacing=0>"); - - /* Top margin */ - camel_stream_write_string ((CamelStream *) stream, "<tr><td colspan=3 height=10>" - "<table cellpadding=0 cellspacing=0><tr><td height=10>" - "<a name=\"glue\"></td></tr></table></td></tr>"); - - /* Left margin */ - camel_stream_write_string ((CamelStream *) stream, "<tr><td><table width=10 " - "cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>"); - - /* Black border */ - camel_stream_write_string ((CamelStream *) stream, "<td width=\"100%\"><table bgcolor=\"#000000\" " - "width=\"100%\" cellspacing=0 cellpadding=1>"); - - /* Main header box */ - camel_stream_printf ((CamelStream *) stream, "<tr><td><table bgcolor=\"#%s\" width=\"100%%\" " - "cellpadding=0 cellspacing=0>" - /* Internal header table */ - "<tr valign=top><td><table><font color=\"#%s\">\n", - bgcolor, fontcolor); + gtk_html_stream_printf ( + stream, + "<table width=\"100%%\" cellpadding=0 cellspacing=0>" + /* Top margin */ + "<tr><td colspan=3 height=10><table height=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td></tr>" + /* Left margin */ + "<tr><td><table width=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>" + /* Black border */ + "<td width=\"100%%\"><table bgcolor=\"#000000\" width=\"100%%\" cellspacing=0 cellpadding=1>" + /* Main header box */ + "<tr><td><table bgcolor=\"#%s\" width=\"100%%\" cellpadding=0 cellspacing=0>" + /* Internal header table */ + "<tr valign=top><td><table><font color=\"#%s\">\n", + bgcolor, fontcolor); if (full) { struct _header_raw *header; @@ -1015,46 +1037,47 @@ write_headers (MailDisplayStream *stream, MailDisplay *md, CamelMimeMessage *mes CamelContentType *ct; char *value; - ct = camel_mime_part_get_content_type (CAMEL_MIME_PART (message)); - charset = header_content_type_param (ct, "charset"); - charset = e_iconv_charset_name (charset); + ct = camel_mime_part_get_content_type(CAMEL_MIME_PART(message)); + charset = header_content_type_param(ct, "charset"); + charset = e_iconv_charset_name(charset); - header = CAMEL_MIME_PART (message)->headers; + header = CAMEL_MIME_PART(message)->headers; while (header) { - i = default_header_index (header->name); + i = default_header_index(header->name); if (i == -1) { - value = header_decode_string (header->value, charset); - write_text_header (stream, header->name, value, WRITE_NOCOLUMNS); - g_free (value); + value = header_decode_string(header->value, charset); + write_text_header(header->name, value, WRITE_NOCOLUMNS, html, stream); + g_free(value); } else - write_default_header (message, md, stream, i, WRITE_NOCOLUMNS); + write_default_header(message, md, html, stream, i, WRITE_NOCOLUMNS); header = header->next; } } else { - for (i = 0; i < sizeof (default_headers) / sizeof (default_headers[0]); i++) - write_default_header (message, md, stream, i, 0); - if (xmask != MAIL_CONFIG_XMAILER_NONE) - evo_icon = write_xmailer_header (message, md, stream, xmask); + for (i=0;i<sizeof(default_headers)/sizeof(default_headers[0]);i++) + write_default_header(message, md, html, stream, i, 0); + if (xm != MAIL_CONFIG_XMAILER_NONE) + evo_icon = write_xmailer_header(message, md, html, stream, xm); } /* Close off the internal header table */ - camel_stream_write_string ((CamelStream *) stream, "</font></table></td>"); - + mail_html_write (html, stream, "</font></table></td>"); + if (!md->printing && evo_icon) { - camel_stream_printf ((CamelStream *) stream, "<td align=right><table><tr><td width=16>" - "<img src=\"%s\"></td></tr></table></td>", - mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/monkey-16.png")); + gtk_html_stream_printf (stream, + "<td align=right><table><tr><td width=16>" + "<img src=\"%s\">" + "</td></tr></table></td>", + mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/monkey-16.png")); } - - camel_stream_write_string ((CamelStream *) stream, - /* Main header box */ - "</tr></table>" - /* Black border */ - "</td></tr></table></td>" - /* Right margin */ - "<td><table width=10 cellpadding=0 cellspacing=0>" - "<tr><td></td></tr></table></td>" - "</tr></table>\n"); + + mail_html_write (html, stream, + /* Main header box */ + "</tr></table>" + /* Black border */ + "</td></tr></table></td>" + /* Right margin */ + "<td><table width=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>" + "</tr></table>\n"); } static void @@ -1065,110 +1088,86 @@ load_offline_content (MailDisplay *md, gpointer data) stream = camel_stream_null_new (); camel_data_wrapper_write_to_stream (wrapper, stream); - camel_object_unref (stream); - camel_object_unref (wrapper); + camel_object_unref (CAMEL_OBJECT (stream)); + camel_object_unref (CAMEL_OBJECT (wrapper)); } gboolean -mail_content_loaded (CamelDataWrapper *wrapper, MailDisplay *md, gboolean redisplay, const char *url, - GtkHTML *html, GtkHTMLStream *stream) +mail_content_loaded (CamelDataWrapper *wrapper, MailDisplay *md, gboolean redisplay, const gchar *url, + GtkHTML *html, GtkHTMLStream *handle) { if (!camel_data_wrapper_is_offline (wrapper)) return TRUE; - camel_object_ref (wrapper); - if (redisplay) { - mail_display_redisplay_when_loaded (md, wrapper, load_offline_content, - html, wrapper); - } else { - mail_display_stream_write_when_loaded (md, wrapper, url, load_offline_content, - html, stream, wrapper); - } + camel_object_ref (CAMEL_OBJECT (wrapper)); + if (redisplay) + mail_display_redisplay_when_loaded (md, wrapper, load_offline_content, html, wrapper); + else + mail_display_stream_write_when_loaded (md, wrapper, url, load_offline_content, html, handle, wrapper); return FALSE; } - -ssize_t -mail_format_data_wrapper_write_to_stream (CamelDataWrapper *wrapper, MailDisplay *mail_display, CamelStream *stream) +/* Return the contents of a data wrapper, or %NULL if it contains only + * whitespace. + */ +GByteArray * +mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_display) { + CamelStream *memstream; CamelStreamFilter *filtered_stream; - ssize_t written; + GByteArray *ba; + char *text, *end; + + memstream = camel_stream_mem_new (); + ba = g_byte_array_new (); + camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (memstream), ba); - filtered_stream = camel_stream_filter_new_with_stream (stream); + filtered_stream = camel_stream_filter_new_with_stream (memstream); + camel_object_unref (CAMEL_OBJECT (memstream)); if (wrapper->rawtext || (mail_display && mail_display->charset)) { CamelMimeFilterCharset *filter; - CamelContentType *content_type; - GConfClient *gconf; - char *charset; - - gconf = gconf_client_get_default (); - - content_type = camel_data_wrapper_get_mime_type_field (wrapper); + const char *charset; if (!wrapper->rawtext) { /* data wrapper had been successfully converted to UTF-8 using the mime part's charset, but the user thinks he knows best so we'll let him shoot himself in the foot here... */ + CamelContentType *content_type; /* get the original charset of the mime part */ - charset = (char *) (content_type ? header_content_type_param (content_type, "charset") : NULL); + content_type = camel_data_wrapper_get_mime_type_field (wrapper); + charset = content_type ? header_content_type_param (content_type, "charset") : NULL; if (!charset) - charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL); - else - charset = g_strdup (charset); + charset = mail_config_get_default_charset (); /* since the content is already in UTF-8, we need to decode into the original charset before we can convert back to UTF-8 using the charset the user is overriding with... */ - if ((filter = camel_mime_filter_charset_new_convert ("utf-8", charset))) { + filter = camel_mime_filter_charset_new_convert ("utf-8", charset); + if (filter) { camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (filter)); - camel_object_unref (filter); + camel_object_unref (CAMEL_OBJECT (filter)); } - - g_free (charset); } /* find out the charset the user wants to override to */ if (mail_display && mail_display->charset) - charset = g_strdup (mail_display->charset); - else if (content_type && (charset = (char *) header_content_type_param (content_type, "charset"))) - charset = g_strdup (charset); + charset = mail_display->charset; else - charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL); + charset = mail_config_get_default_charset (); - if ((filter = camel_mime_filter_charset_new_convert (charset, "utf-8"))) { + filter = camel_mime_filter_charset_new_convert (charset, "utf-8"); + if (filter) { camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (filter)); - camel_object_unref (filter); + camel_object_unref (CAMEL_OBJECT (filter)); } - - g_free (charset); } - written = camel_data_wrapper_write_to_stream (wrapper, CAMEL_STREAM (filtered_stream)); + camel_data_wrapper_write_to_stream (wrapper, CAMEL_STREAM (filtered_stream)); camel_stream_flush (CAMEL_STREAM (filtered_stream)); - camel_object_unref (filtered_stream); - - return written; -} - -/* Return the contents of a data wrapper, or %NULL if it contains only - * whitespace. - */ -GByteArray * -mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_display) -{ - CamelStream *memstream; - GByteArray *ba; - char *text, *end; - - memstream = camel_stream_mem_new (); - ba = g_byte_array_new (); - camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (memstream), ba); - - mail_format_data_wrapper_write_to_stream (wrapper, mail_display, memstream); - camel_object_unref (memstream); + camel_object_unref (CAMEL_OBJECT (filtered_stream)); for (text = ba->data, end = text + ba->len; text < end; text++) { if (!isspace ((unsigned char) *text)) @@ -1184,111 +1183,516 @@ mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_ } static void -write_hr (MailDisplayStream *stream) +write_hr (GtkHTML *html, GtkHTMLStream *stream) { - camel_stream_write_string ((CamelStream *) stream, STANDARD_ISSUE_TABLE_OPEN - "<tr><td width=\"100%\"><hr noshadow size=1>" - "</td></tr></table>\n"); + mail_html_write (html, stream, + "<table cellspacing=0 cellpadding=10 width=\"100%\"><tr><td width=\"100%\">" + "<hr noshadow size=1></td></tr></table>\n"); } /*----------------------------------------------------------------------* * Mime handling functions *----------------------------------------------------------------------*/ +struct { + char *start; + char * (*handler) (char *start, CamelMimePart *part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +} text_specials[] = { + { "-----BEGIN PGP MESSAGE-----\n", try_inline_pgp }, + { "-----BEGIN PGP SIGNED MESSAGE-----\n", try_inline_pgp_sig }, + { "begin ", try_uudecoding }, + { "(This file must be converted with BinHex 4.0)\n", try_inline_binhex } +}; + +static int num_specials = (sizeof (text_specials) / sizeof (text_specials[0])); + +static void +write_one_text_plain_chunk (const char *text, int len, GtkHTML *html, GtkHTMLStream *stream, gboolean printing) +{ + char *buf; + + mail_html_write (html, stream, + "<table cellspacing=0 cellpadding=10 width=\"100%\"><tr><td>\n"); + + buf = g_strndup (text, len); + mail_text_write (html, stream, printing, buf); + g_free (buf); + + mail_html_write (html, stream, "</td></tr></table>\n"); +} + static gboolean handle_text_plain (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { - CamelStreamFilter *filtered_stream; - CamelMimeFilter *html_filter; - CamelDataWrapper *wrapper; + CamelDataWrapper *wrapper = + camel_medium_get_content_object (CAMEL_MEDIUM (part)); CamelContentType *type; + gboolean check_specials; + char *p, *start, *text; const char *format; - GConfClient *gconf; - guint32 flags, rgb = 0; - GdkColor colour; - char *buf; + GByteArray *bytes; + int i; - gconf = gconf_client_get_default (); + bytes = mail_format_get_data_wrapper_text (wrapper, md); + if (!bytes) + return FALSE; - flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES; - if (!md->printing) { - flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; - if (gconf_client_get_bool (gconf, "/apps/evolution/mail/display/mark_citations", NULL)) { - flags |= CAMEL_MIME_FILTER_TOHTML_MARK_CITATION; - - buf = gconf_client_get_string (gconf, "/apps/evolution/mail/display/citation_colour", NULL); - gdk_color_parse (buf ? buf : "#737373", &colour); - g_free (buf); - - rgb = ((colour.red & 0xff00) << 8) | (colour.green & 0xff00) | ((colour.blue & 0xff00) >> 8); - } + g_byte_array_append (bytes, "", 1); + text = bytes->data; + g_byte_array_free (bytes, FALSE); + + /* Check to see if this is a broken text/html part with content-type text/plain */ + start = text; + while (isspace ((unsigned) *start)) + start++; + if (!g_strncasecmp (start, "<html>", 6) || !g_strncasecmp (start, "<!DOCTYPE HTML", 14)) { + g_free (text); + return handle_text_html (part, "text/html", md, html, stream); } /* Check for RFC 2646 flowed text. */ type = camel_mime_part_get_content_type (part); format = header_content_type_param (type, "format"); - if (format && !strcasecmp (format, "flowed")) - flags |= CAMEL_MIME_FILTER_TOHTML_FORMAT_FLOWED; + if (format && !g_strcasecmp (format, "flowed")) + return handle_text_plain_flowed (text, md, html, stream); - html_filter = camel_mime_filter_tohtml_new (flags, rgb); - filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream); - camel_stream_filter_add (filtered_stream, html_filter); - camel_object_unref (html_filter); + /* Only look for binhex and stuff if this is real text/plain. + * (and not, say, application/mac-binhex40 that mail-identify + * has decided to call text/plain because it starts with English + * text...) + */ + check_specials = header_content_type_is (type, "text", "plain"); + + p = text; + while (p && check_specials) { + /* Look for special cases. */ + for (i = 0; i < num_specials; i++) { + start = strstr (p, text_specials[i].start); + if (start && (start == p || start[-1] == '\n')) + break; + } + if (i == num_specials) + break; + + /* Deal with special case */ + if (start != p) + write_one_text_plain_chunk (p, start - p, html, stream, md->printing); + + p = text_specials[i].handler (start, part, start - text, md, html, stream); + if (p == start) { + /* Oops. That failed. Output this line normally and + * skip over it. + */ + p = strchr (start, '\n'); + /* Last line, drop out, and dump */ + if (p == NULL) { + p = start; + break; + } + p++; + write_one_text_plain_chunk (start, p - start, html, stream, md->printing); + } else if (p) + write_hr (html, stream); + } + /* Finish up (or do the whole thing if there were no specials). */ + if (p) + write_one_text_plain_chunk (p, strlen (p), html, stream, md->printing); - camel_stream_write_string ((CamelStream *) stream, STANDARD_ISSUE_TABLE_OPEN "<tr><td><tt>\n"); + g_free (text); - wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream); + return TRUE; +} + +static gboolean +handle_text_plain_flowed (char *buf, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) +{ + char *text, *line, *eol, *p; + int prevquoting = 0, quoting, len, br_pending = 0; + guint32 citation_color = mail_config_get_citation_color (); + + mail_html_write (html, stream, + "\n<!-- text/plain, flowed -->\n" + "<table cellspacing=0 cellpadding=10 width=\"100%\"><tr><td>\n<tt>\n"); + + for (line = buf; *line; line = eol + 1) { + /* Process next line */ + eol = strchr (line, '\n'); + if (eol) + *eol = '\0'; + + quoting = 0; + for (p = line; *p == '>'; p++) + quoting++; + if (quoting != prevquoting) { + if (prevquoting == 0) { + if (md->printing) + mail_html_write (html, stream, "<i>"); + else + gtk_html_stream_printf (stream, "<font color=\"#%06x\">", citation_color); + if (br_pending) + br_pending--; + } + while (quoting > prevquoting) { + mail_html_write (html, stream, "<blockquote type=\"cite\">"); + prevquoting++; + } + while (quoting < prevquoting) { + mail_html_write (html, stream, "</blockquote>"); + prevquoting--; + } + if (quoting == 0) { + mail_html_write (html, stream, md->printing ? "</i>" : "</font>\n"); + if (br_pending) + br_pending--; + } + } + + if (*p == ' ') + p++; + len = strlen (p); + if (len == 0) { + br_pending++; + if (!eol) + break; + continue; + } + + while (br_pending) { + mail_html_write (html, stream, "<br>\n"); + br_pending--; + } + + /* replace '<' with '<', etc. */ + text = e_text_to_html (p, + md->printing ? + E_TEXT_TO_HTML_CONVERT_SPACES : + E_TEXT_TO_HTML_CONVERT_SPACES | E_TEXT_TO_HTML_CONVERT_URLS); + if (text && *text) + mail_html_write (html, stream, text); + g_free (text); + + if ((len > 0 && p[len - 1]) != ' ' || !strcmp (p, "-- ")) + br_pending++; + + if (!eol) + break; + } - camel_stream_write_string ((CamelStream *) stream, "</tt></td></tr></table>\n"); + g_free (buf); - camel_object_unref (filtered_stream); + mail_html_write (html, stream, "</tt>\n</td></tr></table>\n"); return TRUE; } +static CamelMimePart * +fake_mime_part_from_data (const char *data, int len, const char *type, + guint offset, MailDisplay *md) +{ + GHashTable *fake_parts = g_datalist_get_data (md->data, "fake_parts"); + CamelStream *memstream; + CamelDataWrapper *wrapper; + CamelMimePart *part; + + part = g_hash_table_lookup (fake_parts, GUINT_TO_POINTER (offset)); + if (part) + return part; + + memstream = camel_stream_mem_new_with_buffer (data, len); + wrapper = camel_data_wrapper_new (); + camel_data_wrapper_construct_from_stream (wrapper, memstream); + camel_data_wrapper_set_mime_type (wrapper, type); + camel_object_unref (CAMEL_OBJECT (memstream)); + part = camel_mime_part_new (); + camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper); + camel_object_unref (CAMEL_OBJECT (wrapper)); + camel_mime_part_set_disposition (part, "inline"); + + g_hash_table_insert (fake_parts, GUINT_TO_POINTER (offset), part); + return part; +} + +static void +destroy_part (CamelObject *root, gpointer event_data, gpointer user_data) +{ + camel_object_unref (user_data); +} + +static char * +try_inline_pgp (char *start, CamelMimePart *mime_part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) +{ + return start; +} + +static char * +try_inline_pgp_sig (char *start, CamelMimePart *mime_part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) +{ + return start; +} + +static char * +try_uudecoding (char *start, CamelMimePart *mime_part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) +{ + int mode, len, state = CAMEL_UUDECODE_STATE_INIT; + char *filename, *eoln, *p, *out; + CamelMimePart *part; + guint32 save = 0; + + /* Make sure it's a real uudecode begin line: + * begin [0-7]+ .* + */ + mode = strtoul (start + 6, &p, 8); + if (p == start + 6 || *p != ' ') + return start; + + if (!(eoln = strchr (start, '\n'))) + return start; + + while (*p == ' ' || *p == '\t') + p++; + + if (p == eoln) + return start; + + filename = g_strndup (p, eoln - p); + + /* Make sure there's an end line. */ + if (!(p = strstr (p, "\nend\n"))) { + g_free (filename); + return start; + } + + eoln++; + out = g_malloc (p - eoln); + len = uudecode_step (eoln, p - eoln, out, &state, &save); + + part = fake_mime_part_from_data (out, len, "application/octet-stream", + offset, md); + g_free (out); + + camel_mime_part_set_filename (part, filename); + g_free (filename); + + camel_object_hook_event (CAMEL_OBJECT (md->current_message), + "finalize", destroy_part, part); + + write_hr (html, stream); + format_mime_part (part, md, html, stream); + + return p + 4; +} + +static char * +try_inline_binhex (char *start, CamelMimePart *mime_part, + guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) +{ + char *p; + CamelMimePart *part; + + /* Find data start. */ + p = strstr (start, "\n:"); + if (!p) + return start; + + /* And data end. */ + p = strchr (p + 2, ':'); + if (!p || (*(p + 1) != '\n' && *(p + 1) != '\0')) + return start; + p += 2; + + part = fake_mime_part_from_data (start, p - start, + "application/mac-binhex40", + offset, md); + camel_object_hook_event (CAMEL_OBJECT (md->current_message), + "finalize", destroy_part, part); + + write_hr (html, stream); + format_mime_part (part, md, html, stream); + + return p; +} + +static void +g_string_append_len (GString *string, const char *str, int len) +{ + char *tmp; + + tmp = g_malloc (len + 1); + tmp[len] = 0; + memcpy (tmp, str, len); + g_string_append (string, tmp); + g_free (tmp); +} + /* text/enriched (RFC 1896) or text/richtext (included in RFC 1341) */ static gboolean handle_text_enriched (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { - CamelStreamFilter *filtered_stream; - CamelMimeFilter *enriched; - CamelDataWrapper *wrapper; - guint32 flags = 0; + static GHashTable *translations = NULL; + CamelDataWrapper *wrapper = + camel_medium_get_content_object (CAMEL_MEDIUM (part)); + GByteArray *ba, *bytes; + char *text, *p, *xed; + int len, nofill = 0; + gboolean enriched; + GString *string; + + if (!translations) { + translations = g_hash_table_new (g_strcase_hash, g_strcase_equal); + + g_hash_table_insert (translations, "bold", "<b>"); + g_hash_table_insert (translations, "/bold", "</b>"); + g_hash_table_insert (translations, "italic", "<i>"); + g_hash_table_insert (translations, "/italic", "</i>"); + g_hash_table_insert (translations, "fixed", "<tt>"); + g_hash_table_insert (translations, "/fixed", "</tt>"); + g_hash_table_insert (translations, "smaller", "<font size=-1>"); + g_hash_table_insert (translations, "/smaller", "</font>"); + g_hash_table_insert (translations, "bigger", "<font size=+1>"); + g_hash_table_insert (translations, "/bigger", "</font>"); + g_hash_table_insert (translations, "underline", "<u>"); + g_hash_table_insert (translations, "/underline", "</u>"); + g_hash_table_insert (translations, "center", "<p align=center>"); + g_hash_table_insert (translations, "/center", "</p>"); + g_hash_table_insert (translations, "flushleft", "<p align=left>"); + g_hash_table_insert (translations, "/flushleft", "</p>"); + g_hash_table_insert (translations, "flushright", "<p align=right>"); + g_hash_table_insert (translations, "/flushright", "</p>"); + g_hash_table_insert (translations, "excerpt", "<blockquote>"); + g_hash_table_insert (translations, "/excerpt", "</blockquote>"); + g_hash_table_insert (translations, "paragraph", "<p>"); + g_hash_table_insert (translations, "signature", "<address>"); + g_hash_table_insert (translations, "/signature", "</address>"); + g_hash_table_insert (translations, "comment", "<!-- "); + g_hash_table_insert (translations, "/comment", " -->"); + g_hash_table_insert (translations, "param", "<!-- "); + g_hash_table_insert (translations, "/param", " -->"); + g_hash_table_insert (translations, "np", "<hr>"); + } - wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + bytes = mail_format_get_data_wrapper_text (wrapper, md); + if (!bytes) + return FALSE; - if (!strcasecmp (mime_type, "text/richtext")) { - flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT; - camel_stream_write_string ((CamelStream *) stream, "\n<!-- text/richtext -->\n"); + if (!g_strcasecmp (mime_type, "text/richtext")) { + enriched = FALSE; + mail_html_write (html, stream, + "\n<!-- text/richtext -->\n"); } else { - camel_stream_write_string ((CamelStream *) stream, "\n<!-- text/enriched -->\n"); + enriched = TRUE; + mail_html_write (html, stream, + "\n<!-- text/enriched -->\n"); } - enriched = camel_mime_filter_enriched_new (flags); - filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream); - camel_stream_filter_add (filtered_stream, enriched); - camel_object_unref (enriched); + /* This is not great code, but I don't feel like fixing it right + * now. I mean, it's just text/enriched... + */ + string = g_string_sized_new (2 * bytes->len); + g_byte_array_append (bytes, "", 1); + p = text = bytes->data; + g_byte_array_free (bytes, FALSE); + + while (p) { + len = strcspn (p, " <>&\n"); + if (len) + g_string_append_len (string, p, len); + + p += len; + if (!*p) + break; + + switch (*p++) { + case ' ': + while (*p == ' ') { + g_string_append (string, " "); + p++; + } + g_string_append (string, " "); + break; + case '\n': + g_string_append (string, " "); + if (enriched && nofill <= 0) { + while (*p == '\n') { + g_string_append (string, "<br>"); + p++; + } + } + break; + case '>': + g_string_append (string, ">"); + break; + case '&': + g_string_append (string, "&"); + break; + case '<': + if (enriched) { + if (*p == '<') { + g_string_append (string, "<"); + p++; + break; + } + } else { + if (strncmp (p, "lt>", 3) == 0) { + g_string_append (string, "<"); + p += 3; + break; + } else if (strncmp (p, "nl>", 3) == 0) { + g_string_append (string, "<br>"); + p += 3; + break; + } + } + + if (strncmp (p, "nofill>", 7) == 0) { + nofill++; + g_string_append (string, "<pre>"); + } else if (strncmp (p, "/nofill>", 8) == 0) { + nofill--; + g_string_append (string, "</pre>"); + } else { + char *copy, *match; + + len = strcspn (p, ">"); + copy = g_strndup (p, len); + match = g_hash_table_lookup (translations, + copy); + g_free (copy); + if (match) + g_string_append (string, match); + } + + p = strchr (p, '>'); + if (p) + p++; + } + } + g_free (text); - camel_stream_write_string ((CamelStream *) stream, STANDARD_ISSUE_TABLE_OPEN "<tr><td><tt>\n"); - wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream); + ba = g_byte_array_new (); + g_byte_array_append (ba, (const guint8 *)string->str, + string->len); + g_string_free (string, TRUE); - camel_stream_write_string ((CamelStream *) stream, "</tt></td></tr></table>\n"); - camel_object_unref (filtered_stream); + xed = g_strdup_printf ("x-evolution-data:%p", part); + gtk_html_stream_printf (stream, "<iframe src=\"%s\" frameborder=0 scrolling=no></iframe>", xed); + mail_display_add_url (md, "data_urls", xed, ba); return TRUE; } static gboolean handle_text_html (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { const char *location, *base; - camel_stream_write_string ((CamelStream *) stream, "\n<!-- text/html -->\n"); + mail_html_write (html, stream, "\n<!-- text/html -->\n"); if ((base = camel_medium_get_header (CAMEL_MEDIUM (part), "Content-Base"))) { char *base_url; @@ -1298,36 +1702,33 @@ handle_text_html (CamelMimePart *part, const char *mime_type, if (*base == '"' && *(base + len - 1) == '"') { len -= 2; - base_url = g_alloca (len + 1); + base_url = alloca (len + 1); memcpy (base_url, base + 1, len); base_url[len] = '\0'; base = base_url; } - gtk_html_set_base (md->html, base); + gtk_html_set_base (html, base); } location = get_location (part, md); if (!location) location = get_cid (part, md); - - camel_stream_printf ((CamelStream *) stream, "<iframe src=\"%s\" frameborder=0 " - "scrolling=no>could not get %s</iframe>", location, location); - + gtk_html_stream_printf (stream, "<iframe src=\"%s\" frameborder=0 scrolling=no></iframe>", location); return TRUE; } static gboolean -handle_image (CamelMimePart *part, const char *mime_type, MailDisplay *md, MailDisplayStream *stream) +handle_image (CamelMimePart *part, const char *mime_type, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { - camel_stream_printf ((CamelStream *) stream, "<img hspace=10 vspace=10 src=\"%s\">", - get_cid (part, md)); + gtk_html_stream_printf (stream, "<img hspace=10 vspace=10 src=\"%s\">", + get_cid (part, md)); return TRUE; } static gboolean handle_multipart_mixed (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -1336,30 +1737,30 @@ handle_multipart_mixed (CamelMimePart *part, const char *mime_type, gboolean output = FALSE; if (!CAMEL_IS_MULTIPART (wrapper)) { - mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source.")); - if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL)) - handle_text_plain (part, "text/plain", md, stream); + mail_error_printf (html, stream, "\n%s\n", U_("Could not parse MIME message. Displaying as source.")); + if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL)) + handle_text_plain (part, "text/plain", md, html, stream); return TRUE; } - + mp = CAMEL_MULTIPART (wrapper); - + nparts = camel_multipart_get_number (mp); for (i = 0; i < nparts; i++) { if (i != 0 && output) - write_hr (stream); - + write_hr (html, stream); + part = camel_multipart_get_part (mp, i); - output = format_mime_part (part, md, stream); + output = format_mime_part (part, md, html, stream); } - + return TRUE; } static gboolean handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { CamelMultipartEncrypted *mpe; CamelMimePart *mime_part; @@ -1370,7 +1771,7 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, /* Currently we only handle RFC2015-style PGP encryption. */ if (!camel_pgp_mime_is_rfc2015_encrypted (part)) - return handle_multipart_mixed (part, mime_type, md, stream); + return handle_multipart_mixed (part, mime_type, md, html, stream); wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -1382,12 +1783,18 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, camel_object_unref (cipher); if (camel_exception_is_set (&ex)) { - mail_error_printf (stream, "\n%s\n", camel_exception_get_description (&ex)); + char *error; + + error = e_utf8_from_locale_string (camel_exception_get_description (&ex)); + + mail_error_printf (html, stream, "\n%s\n", error); + g_free (error); + camel_exception_clear (&ex); return TRUE; } - handled = format_mime_part (mime_part, md, stream); + handled = format_mime_part (mime_part, md, html, stream); camel_object_unref (mime_part); return handled; @@ -1395,7 +1802,7 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, static gboolean handle_multipart_signed (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { CamelMimePart *subpart; CamelDataWrapper *wrapper; @@ -1405,12 +1812,12 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); if (!CAMEL_IS_MULTIPART_SIGNED (wrapper)) { - mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source.")); - if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL)) - handle_text_plain (part, "text/plain", md, stream); + mail_error_printf (html, stream, "\n%s\n", U_("Could not parse MIME message. Displaying as source.")); + if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL)) + handle_text_plain (part, "text/plain", md, html, stream); return TRUE; } - + mps = CAMEL_MULTIPART_SIGNED (wrapper); /* if subpart & signature is null, what do we do? just write it out raw? @@ -1418,18 +1825,18 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, this includes: more or less than 2 parts */ /* output the content */ - subpart = camel_multipart_get_part ((CamelMultipart *) mps, CAMEL_MULTIPART_SIGNED_CONTENT); + subpart = camel_multipart_get_part((CamelMultipart *)mps, CAMEL_MULTIPART_SIGNED_CONTENT); if (subpart == NULL) return FALSE; - output = format_mime_part (subpart, md, stream); + output = format_mime_part (subpart, md, html, stream); /* now handle the signature */ - subpart = camel_multipart_get_part ((CamelMultipart *) mps, CAMEL_MULTIPART_SIGNED_SIGNATURE); + subpart = camel_multipart_get_part((CamelMultipart *)mps, CAMEL_MULTIPART_SIGNED_SIGNATURE); if (subpart == NULL) return FALSE; - mail_part_set_default_displayed_inline (subpart, md, FALSE); + mail_part_set_default_displayed_inline(subpart, md, FALSE); if (!mail_part_is_displayed_inline (subpart, md) && !md->printing) { char *url; @@ -1437,24 +1844,23 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, /* Write out the click-for-info object */ url = g_strdup_printf ("signature:%p/%lu", subpart, (unsigned long)time (NULL)); - camel_stream_printf ((CamelStream *) stream, - "<br><table cellspacing=0 cellpadding=0>" - "<tr><td><table width=10 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td>" - "<td><object classid=\"%s\"></object></td>" - "<td><table width=3 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td>" - "<td><font size=-1>", url); + gtk_html_stream_printf (stream, + "<br><table cellspacing=0 cellpadding=0>" + "<tr><td><table width=10 cellspacing=0 cellpadding=0>" + "<tr><td></td></tr></table></td>" + "<td><object classid=\"%s\"></object></td>" + "<td><table width=3 cellspacing=0 cellpadding=0>" + "<tr><td></td></tr></table></td>" + "<td><font size=-1>", url); mail_display_add_url (md, "part_urls", url, subpart); - camel_stream_write_string ((CamelStream *) stream, - _("This message is digitally signed. " - "Click the lock icon for more information.")); + mail_html_write (html, stream, + U_("This message is digitally signed. " + "Click the lock icon for more information.")); - camel_stream_write_string ((CamelStream *) stream, "</font></td></tr><tr><td height=10>" - "<table cellspacing=0 cellpadding=0><tr>" - "<td height=10><a name=\"glue\"></td></tr>" - "</table></td></tr></table>\n"); + mail_html_write (html, stream, + "</font></td></tr><tr><td height=10><table height=10 cellspacing=0 cellpadding=0>" + "<tr><td></td></tr></table></td></tr></table>\n"); } else { CamelCipherValidity *valid = NULL; CamelException ex; @@ -1468,7 +1874,7 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, cipher = camel_gpg_context_new (session); if (cipher) { valid = camel_multipart_signed_verify (mps, cipher, &ex); - camel_object_unref (cipher); + camel_object_unref (CAMEL_OBJECT (cipher)); if (valid) { good = camel_cipher_validity_get_valid (valid); message = camel_cipher_validity_get_description (valid); @@ -1476,44 +1882,45 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, message = camel_exception_get_description (&ex); } } else { - message = _("Could not create a PGP verfication context"); + message = U_("Could not create a PGP verfication context"); } if (good) { - camel_stream_printf ((CamelStream *) stream, "<table><tr valign=top><td>" - "<img src=\"%s\"></td><td>%s<br><br>", - mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR - "/pgp-signature-ok.png"), - _("This message is digitally signed and " - "has been found to be authentic.")); + gtk_html_stream_printf (stream, + "<table><tr valign=top>" + "<td><img src=\"%s\"></td>" + "<td>%s<br><br>", + mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/pgp-signature-ok.png"), + U_("This message is digitally signed and " + "has been found to be authentic.")); } else { - camel_stream_printf ((CamelStream *) stream, "<table><tr valign=top><td>" - "<img src=\"%s\"></td><td>%s<br><br>", - mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR - "/pgp-signature-bad.png"), - _("This message is digitally signed but can " - "not be proven to be authentic.")); + gtk_html_stream_printf (stream, + "<table><tr valign=top>" + "<td><img src=\"%s\"></td>" + "<td>%s<br><br>", + mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/pgp-signature-bad.png"), + U_("This message is digitally signed but can " + "not be proven to be authentic.")); } if (message) { - camel_stream_printf ((CamelStream *) stream, "<font size=-1%s>", good || - md->printing ? "" : " color=red"); - mail_text_write (stream, md, part, 0, md->printing, message); - camel_stream_write_string ((CamelStream *) stream, "</font>"); + gtk_html_stream_printf (stream, "<font size=-1 %s>", good || md->printing ? "" : "color=red"); + mail_text_write (html, stream, md->printing, message); + mail_html_write (html, stream, "</font>"); } - camel_stream_write_string ((CamelStream *) stream, "</td></tr></table>"); + mail_html_write (html, stream, "</td></tr></table>"); camel_exception_clear (&ex); camel_cipher_validity_free (valid); } - + return TRUE; } /* As seen in RFC 2387! */ static gboolean handle_multipart_related (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); CamelMultipart *mp; @@ -1525,12 +1932,12 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type, int ret; if (!CAMEL_IS_MULTIPART (wrapper)) { - mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source.")); - if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL)) - handle_text_plain (part, "text/plain", md, stream); + mail_error_printf (html, stream, "\n%s\n", U_("Could not parse MIME message. Displaying as source.")); + if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL)) + handle_text_plain (part, "text/plain", md, html, stream); return TRUE; } - + mp = CAMEL_MULTIPART (wrapper); nparts = camel_multipart_get_number (mp); @@ -1550,7 +1957,8 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type, body_part = camel_multipart_get_part (mp, i); cid = camel_mime_part_get_content_id (body_part); - if (cid && !strncmp (cid, start + 1, len) && strlen (cid) == len) { + if (cid && !strncmp (cid, start + 1, len) && + strlen (cid) == len) { display_part = body_part; break; } @@ -1562,7 +1970,7 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type, if (!display_part) { /* Oops. Hrmph. */ - return handle_multipart_mixed (part, mime_type, md, stream); + return handle_multipart_mixed (part, mime_type, md, html, stream); } /* setup a 'stack' of related parts */ @@ -1581,11 +1989,11 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type, get_cid (body_part, md); get_location (body_part, md); - g_hash_table_insert (md->related, body_part, body_part); + g_hash_table_insert(md->related, body_part, body_part); } /* Now, display the displayed part. */ - ret = format_mime_part (display_part, md, stream); + ret = format_mime_part (display_part, md, html, stream); /* FIXME: flush html stream via gtkhtml_stream_flush which doens't exist yet ... */ while (gtk_events_pending ()) @@ -1597,10 +2005,10 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type, if (body_part == display_part) continue; - if (g_hash_table_lookup (md->related, body_part)) { + if (g_hash_table_lookup(md->related, body_part)) { if (ret) - write_hr (stream); - ret |= format_mime_part (body_part, md, stream); + write_hr (html, stream); + ret |= format_mime_part (body_part, md, html, stream); } } @@ -1620,14 +2028,14 @@ find_preferred_alternative (CamelMultipart *multipart, gboolean want_plain) int i, nparts; CamelMimePart *preferred_part = NULL; MailMimeHandler *handler; - + nparts = camel_multipart_get_number (multipart); for (i = 0; i < nparts; i++) { CamelMimePart *part = camel_multipart_get_part (multipart, i); CamelContentType *type = camel_mime_part_get_content_type (part); char *mime_type = header_content_type_simple (type); - - camel_strdown (mime_type); + + g_strdown (mime_type); if (want_plain && !strcmp (mime_type, "text/plain")) return part; handler = mail_lookup_handler (mime_type); @@ -1635,13 +2043,13 @@ find_preferred_alternative (CamelMultipart *multipart, gboolean want_plain) preferred_part = part; g_free (mime_type); } - + return preferred_part; } static gboolean handle_multipart_alternative (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -1649,9 +2057,9 @@ handle_multipart_alternative (CamelMimePart *part, const char *mime_type, CamelMimePart *mime_part; if (!CAMEL_IS_MULTIPART (wrapper)) { - mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source.")); - if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL)) - handle_text_plain (part, "text/plain", md, stream); + mail_error_printf (html, stream, "\n%s\n", U_("Could not parse MIME message. Displaying as source.")); + if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL)) + handle_text_plain (part, "text/plain", md, html, stream); return TRUE; } @@ -1659,68 +2067,69 @@ handle_multipart_alternative (CamelMimePart *part, const char *mime_type, mime_part = find_preferred_alternative (multipart, FALSE); if (mime_part) - return format_mime_part (mime_part, md, stream); + return format_mime_part (mime_part, md, html, stream); else - return handle_multipart_mixed (part, mime_type, md, stream); + return handle_multipart_mixed (part, mime_type, md, html, stream); } /* RFC 1740 */ static gboolean handle_multipart_appledouble (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); CamelMultipart *multipart; - + if (!CAMEL_IS_MULTIPART (wrapper)) { - mail_error_printf (stream, "\n%s\n", _("Could not parse MIME message. Displaying as source.")); - if (mail_content_loaded (wrapper, md, TRUE, NULL, md->html, NULL)) - handle_text_plain (part, "text/plain", md, stream); + mail_error_printf (html, stream, "\n%s\n", U_("Could not parse MIME message. Displaying as source.")); + if (mail_content_loaded (wrapper, md, TRUE, NULL, html, NULL)) + handle_text_plain (part, "text/plain", md, html, stream); return TRUE; } - + multipart = CAMEL_MULTIPART (wrapper); - + /* The first part is application/applefile and is not useful * to us. The second part _may_ be displayable data. Most * likely it's application/octet-stream though. */ part = camel_multipart_get_part (multipart, 1); - return format_mime_part (part, md, stream); + return format_mime_part (part, md, html, stream); } static gboolean handle_message_rfc822 (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (wrapper), FALSE); - camel_stream_write_string ((CamelStream *) stream, "<blockquote>"); - mail_format_mime_message (CAMEL_MIME_MESSAGE (wrapper), md, stream); - camel_stream_write_string ((CamelStream *) stream, "</blockquote>"); + mail_html_write (html, stream, "<blockquote>"); + mail_format_mime_message (CAMEL_MIME_MESSAGE (wrapper), md, html, stream); + mail_html_write (html, stream, "</blockquote>"); return TRUE; } static gboolean handle_message_external_body (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { CamelContentType *type; const char *access_type; char *url = NULL, *desc = NULL; + char *fmt; type = camel_mime_part_get_content_type (part); access_type = header_content_type_param (type, "access-type"); if (!access_type) goto fallback; - if (!strcasecmp (access_type, "ftp") || - !strcasecmp (access_type, "anon-ftp")) { + if (!g_strcasecmp (access_type, "ftp") || + !g_strcasecmp (access_type, "anon-ftp")) { const char *name, *site, *dir, *mode, *ftype; char *path; @@ -1755,8 +2164,10 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type, url = g_strdup_printf ("ftp://%s%s%s", site, path, ftype); g_free (path); - desc = g_strdup_printf (_("Pointer to FTP site (%s)"), url); - } else if (!g_ascii_strcasecmp (access_type, "local-file")) { + fmt = e_utf8_from_locale_string (_("Pointer to FTP site (%s)")); + desc = g_strdup_printf (fmt, url); + g_free (fmt); + } else if (!g_strcasecmp (access_type, "local-file")) { const char *name, *site; name = header_content_type_param (type, "name"); @@ -1764,14 +2175,19 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type, goto fallback; site = header_content_type_param (type, "site"); - url = g_strdup_printf ("file://%s%s", *name == '/' ? "" : "/", name); + url = g_strdup_printf ("file://%s%s", *name == '/' ? "" : "/", + name); if (site) { - desc = g_strdup_printf(_("Pointer to local file (%s) " - "valid at site \"%s\""), name, site); + fmt = e_utf8_from_locale_string (_("Pointer to local file (%s) " + "valid at site \"%s\"")); + desc = g_strdup_printf (fmt, name, site); + g_free (fmt); } else { - desc = g_strdup_printf(_("Pointer to local file (%s)"), name); + fmt = e_utf8_from_locale_string (_("Pointer to local file (%s)")); + desc = g_strdup_printf (fmt, name); + g_free (fmt); } - } else if (!strcasecmp (access_type, "URL")) { + } else if (!g_strcasecmp (access_type, "URL")) { const char *urlparam; char *s, *d; @@ -1796,15 +2212,20 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type, } *d = *s; - desc = g_strdup_printf (_("Pointer to remote data (%s)"), url); + fmt = e_utf8_from_locale_string (_("Pointer to remote data (%s)")); + desc = g_strdup_printf (fmt, url); + g_free (fmt); } fallback: if (!desc) { - if (access_type) - desc = g_strdup_printf (_("Pointer to unknown external data (\"%s\" type)"), access_type); - else - desc = g_strdup (_("Malformed external-body part.")); + if (access_type) { + fmt = e_utf8_from_locale_string (_("Pointer to unknown external data " + "(\"%s\" type)")); + desc = g_strdup_printf (fmt, access_type); + g_free (fmt); + } else + desc = e_utf8_from_locale_string (_("Malformed external-body part.")); } #if 0 /* FIXME */ @@ -1814,20 +2235,19 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type, g_free (desc); g_free (url); - return TRUE; } static gboolean handle_via_bonobo (CamelMimePart *part, const char *mime_type, - MailDisplay *md, MailDisplayStream *stream) + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { - if (!md->printing) { - camel_stream_printf ((CamelStream *) stream, - "<object classid=\"%s\" type=\"%s\"></object>", - get_cid (part, md), mime_type); + if (! md->printing) { + gtk_html_stream_printf (stream, + "<object classid=\"%s\" type=\"%s\"></object>", + get_cid (part, md), mime_type); } - + return TRUE; } @@ -1850,77 +2270,75 @@ mail_get_message_rfc822 (CamelMimeMessage *message, gboolean want_plain, gboolea char *text, *citation, *buf, *html; time_t date_val; int offset; - + contents = camel_medium_get_content_object (CAMEL_MEDIUM (message)); text = mail_get_message_body (contents, want_plain, cite); if (!text) text = g_strdup (""); citation = cite ? "> " : ""; retval = g_string_new (NULL); - + /* Kludge: if text starts with "<PRE>", wrap it around the * headers too so we won't get a blank line between them for the * <P> to <PRE> switch. */ - if (!strncasecmp (text, "<pre>", 5)) - g_string_append_printf (retval, "<PRE>"); - + if (!g_strncasecmp (text, "<pre>", 5)) + g_string_sprintfa (retval, "<PRE>"); + /* create credits */ cia = camel_mime_message_get_from (message); buf = camel_address_format (CAMEL_ADDRESS (cia)); if (buf) { - html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); - g_string_append_printf (retval, "%s<b>From:</b> %s<br>", - citation, html); + html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL); + g_string_sprintfa (retval, "%s<b>From:</b> %s<br>", + citation, html); g_free (html); g_free (buf); } - + cia = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); buf = camel_address_format (CAMEL_ADDRESS (cia)); if (buf) { - html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); - g_string_append_printf (retval, "%s<b>To:</b> %s<br>", - citation, html); + html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL); + g_string_sprintfa (retval, "%s<b>To:</b> %s<br>", + citation, html); g_free (html); g_free (buf); } - + cia = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); buf = camel_address_format (CAMEL_ADDRESS (cia)); if (buf) { - html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); - g_string_append_printf (retval, "%s<b>Cc:</b> %s<br>", - citation, html); + html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL); + g_string_sprintfa (retval, "%s<b>Cc:</b> %s<br>", + citation, html); g_free (html); g_free (buf); } - + buf = (char *) camel_mime_message_get_subject (message); if (buf) { - html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | - CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - g_string_append_printf (retval, "%s<b>Subject:</b> %s<br>", - citation, html); + html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); + g_string_sprintfa (retval, "%s<b>Subject:</b> %s<br>", + citation, html); g_free (html); } - + date_val = camel_mime_message_get_date (message, &offset); buf = header_format_date (date_val, offset); - html = camel_text_to_html (buf, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); - g_string_append_printf (retval, "%s<b>Date:</b> %s<br>", citation, html); + html = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL); + g_string_sprintfa (retval, "%s<b>Date:</b> %s<br>", citation, html); g_free (html); g_free (buf); - if (!strncasecmp (text, "<pre>", 5)) - g_string_append_printf (retval, "%s<br>%s", citation, text + 5); + if (!g_strncasecmp (text, "<pre>", 5)) + g_string_sprintfa (retval, "%s<br>%s", citation, text + 5); else - g_string_append_printf (retval, "%s<br>%s", citation, text); + g_string_sprintfa (retval, "%s<br>%s", citation, text); g_free (text); - + buf = retval->str; g_string_free (retval, FALSE); - return buf; } @@ -1979,9 +2397,8 @@ mail_get_message_body (CamelDataWrapper *data, gboolean want_plain, gboolean cit if (text && !header_content_type_is (mime_type, "text", "html")) { char *html; - html = camel_text_to_html (text, CAMEL_MIME_FILTER_TOHTML_PRE | - CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | - (cite ? CAMEL_MIME_FILTER_TOHTML_CITE : 0), 0); + html = e_text_to_html (text, E_TEXT_TO_HTML_PRE | E_TEXT_TO_HTML_CONVERT_URLS | + (cite ? E_TEXT_TO_HTML_CITE : 0)); g_free (text); text = html; } diff --git a/mail/mail-local.c b/mail/mail-local.c index cbec89d89e..e73dc0fc71 100644 --- a/mail/mail-local.c +++ b/mail/mail-local.c @@ -29,15 +29,17 @@ #include <config.h> #endif -#include <string.h> #include <unistd.h> #include <errno.h> -#include <libxml/xmlmemory.h> +#include <gnome-xml/xmlmemory.h> +#include <libgnomeui/gnome-dialog.h> +#include <libgnomeui/gnome-dialog-util.h> #include <glade/glade.h> #include "e-util/e-path.h" -#include "e-util/e-dialog-utils.h" +#include <gal/widgets/e-gui-utils.h> +#include <gal/util/e-unicode-i18n.h> #include <gal/util/e-xml-utils.h> #include "Evolution.h" @@ -149,11 +151,11 @@ load_metainfo(const char *path) if (doc == NULL) goto dodefault; - node = doc->children; + node = doc->root; if (strcmp(node->name, "folderinfo")) goto dodefault; - node = node->children; + node = node->childs; while (node) { if (!strcmp(node->name, "folder")) { char *index, *txt; @@ -237,11 +239,11 @@ mlf_refresh_info(CamelFolder *folder, CamelException *ex) LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); camel_folder_refresh_info(f, ex); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); } static void @@ -252,11 +254,11 @@ mlf_sync(CamelFolder *folder, gboolean expunge, CamelException *ex) LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); camel_folder_sync(f, expunge, ex); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); } static void @@ -267,11 +269,11 @@ mlf_expunge(CamelFolder *folder, CamelException *ex) LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); camel_folder_expunge(f, ex); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); } static void @@ -282,11 +284,11 @@ mlf_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMe LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); camel_folder_append_message(f, message, info, appended_uid, ex); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); } static CamelMimeMessage * @@ -298,11 +300,11 @@ mlf_get_message(CamelFolder *folder, const char *uid, CamelException *ex) LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); ret = camel_folder_get_message(f, uid, ex); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); return ret; } @@ -316,11 +318,11 @@ mlf_search_by_expression(CamelFolder *folder, const char *expression, CamelExcep LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); ret = camel_folder_search_by_expression(f, expression, ex); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); return ret; } @@ -334,11 +336,11 @@ mlf_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids, LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); ret = camel_folder_search_by_uids(f, expression, uids, ex); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); return ret; } @@ -351,11 +353,11 @@ mlf_search_free(CamelFolder *folder, GPtrArray *result) LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); camel_folder_search_free(f, result); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); } static void @@ -366,11 +368,11 @@ mlf_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); camel_folder_set_message_flags(mlf->real_folder, uid, flags, set); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); } static void @@ -381,11 +383,11 @@ mlf_set_message_user_flag(CamelFolder *folder, const char *uid, const char *name LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); camel_folder_set_message_user_flag(mlf->real_folder, uid, name, value); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); } static void @@ -396,11 +398,11 @@ mlf_set_message_user_tag(CamelFolder *folder, const char *uid, const char *name, LOCAL_FOLDER_LOCK(mlf); f = mlf->real_folder; - camel_object_ref(f); + camel_object_ref((CamelObject *)f); LOCAL_FOLDER_UNLOCK(mlf); camel_folder_set_message_user_tag(mlf->real_folder, uid, name, value); - camel_object_unref(f); + camel_object_unref((CamelObject *)f); } /* Internal store-rename call, update our strings */ @@ -435,13 +437,13 @@ mlf_rename(CamelFolder *folder, const char *new) static void mlf_proxy_message_changed(CamelObject *real_folder, gpointer event_data, gpointer user_data) { - camel_object_trigger_event(user_data, "message_changed", event_data); + camel_object_trigger_event((CamelObject *)user_data, "message_changed", event_data); } static void mlf_proxy_folder_changed(CamelObject *real_folder, gpointer event_data, gpointer user_data) { - camel_object_trigger_event(user_data, "folder_changed", event_data); + camel_object_trigger_event((CamelObject *)user_data, "folder_changed", event_data); } static void @@ -451,20 +453,20 @@ mlf_unset_folder (MailLocalFolder *mlf) g_assert(mlf->real_folder); - camel_object_unhook_event(mlf->real_folder, + camel_object_unhook_event(CAMEL_OBJECT(mlf->real_folder), "message_changed", mlf_proxy_message_changed, mlf); - camel_object_unhook_event(mlf->real_folder, + camel_object_unhook_event(CAMEL_OBJECT(mlf->real_folder), "folder_changed", mlf_proxy_folder_changed, mlf); - camel_object_unref(folder->summary); + camel_object_unref((CamelObject *)folder->summary); folder->summary = NULL; - camel_object_unref(mlf->real_folder); + camel_object_unref((CamelObject *)mlf->real_folder); mlf->real_folder = NULL; - camel_object_unref(mlf->real_store); + camel_object_unref((CamelObject *)mlf->real_store); mlf->real_store = NULL; folder->permanent_flags = 0; @@ -500,14 +502,14 @@ mlf_set_folder(MailLocalFolder *mlf, guint32 flags, CamelException *ex) if (mlf->real_folder->folder_flags & CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY) { folder->summary = mlf->real_folder->summary; - camel_object_ref(mlf->real_folder->summary); + camel_object_ref((CamelObject *)mlf->real_folder->summary); } folder->permanent_flags = mlf->real_folder->permanent_flags; folder->folder_flags = mlf->real_folder->folder_flags; - camel_object_hook_event(mlf->real_folder, "message_changed", mlf_proxy_message_changed, mlf); - camel_object_hook_event(mlf->real_folder, "folder_changed", mlf_proxy_folder_changed, mlf); + camel_object_hook_event((CamelObject *)mlf->real_folder, "message_changed", mlf_proxy_message_changed, mlf); + camel_object_hook_event((CamelObject *)mlf->real_folder, "folder_changed", mlf_proxy_folder_changed, mlf); return TRUE; } @@ -534,9 +536,9 @@ mlf_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args) /* string to describe a local folder as the location of a message */ pathlen = strlen(evolution_dir) + strlen("local") + 1; if (strlen(folder->full_name) > pathlen) - mlf->description = g_strdup_printf(_("Local folders/%s"), folder->full_name+pathlen); + mlf->description = g_strdup_printf(U_("Local folders/%s"), folder->full_name+pathlen); else - mlf->description = g_strdup_printf(_("Local folders/%s"), folder->name); + mlf->description = g_strdup_printf(U_("Local folders/%s"), folder->name); } *arg->ca_str = mlf->description; break; @@ -620,28 +622,30 @@ mail_local_folder_get_type (void) NULL, mlf_init, mlf_finalize); - mlf_parent_class = (CamelFolderClass *)CAMEL_FOLDER_TYPE; + mlf_parent_class = (CamelFolderClass *)camel_type_get_global_classfuncs (CAMEL_FOLDER_TYPE); } return mail_local_folder_type; } static MailLocalFolder * -mail_local_folder_construct(MailLocalFolder *mlf, MailLocalStore *parent_store, const char *full_name, CamelException *ex) +mail_local_folder_construct(MailLocalFolder *mlf, MailLocalStore *parent_store, const char *full_name, CamelException *ex) { - char *metapath, *name; + const char *name; + char *metapath; - name = g_path_get_basename (full_name); - d(printf ("constructing local folder: full = %s, name = %s\n", full_name, name)); - camel_folder_construct (CAMEL_FOLDER (mlf), CAMEL_STORE (parent_store), full_name, name); - g_free (name); - - mlf->real_path = g_strdup (((CamelFolder *) mlf)->full_name); - - metapath = g_strdup_printf ("%s/%s/local-metadata.xml", ((CamelService *) parent_store)->url->path, full_name); - mlf->meta = load_metainfo (metapath); - g_free (metapath); + name = g_basename (full_name); + d(printf("constructing local folder: full = %s, name = %s\n", full_name, name)); + + camel_folder_construct(CAMEL_FOLDER (mlf), CAMEL_STORE(parent_store), full_name, name); + + mlf->real_path = g_strdup(((CamelFolder *)mlf)->full_name); + + metapath = g_strdup_printf("%s/%s/local-metadata.xml", ((CamelService *)parent_store)->url->path, full_name); + mlf->meta = load_metainfo(metapath); + g_free(metapath); + return mlf; } @@ -736,7 +740,7 @@ mail_local_folder_reconfigure (MailLocalFolder *mlf, const char *new_format, int camel_folder_expunge(fromfolder, ex); d(printf("delete old mbox ...\n")); - camel_object_unref(fromfolder); + camel_object_unref(CAMEL_OBJECT(fromfolder)); fromfolder = NULL; camel_store_delete_folder(fromstore, tmpname, ex); @@ -759,9 +763,9 @@ mail_local_folder_reconfigure (MailLocalFolder *mlf, const char *new_format, int if (mlf->real_folder == NULL) mlf_set_folder (mlf, CAMEL_STORE_FOLDER_CREATE, ex); if (fromfolder) - camel_object_unref(fromfolder); + camel_object_unref((CamelObject *)fromfolder); if (fromstore) - camel_object_unref(fromstore); + camel_object_unref((CamelObject *)fromstore); g_free(tmpname); g_free(mbox); @@ -794,7 +798,7 @@ mls_get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelE return NULL; if (!mlf_set_folder(folder, flags, ex)) { - camel_object_unref(folder); + camel_object_unref(CAMEL_OBJECT(folder)); return NULL; } @@ -802,8 +806,8 @@ mls_get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelE if (save_metainfo(folder->meta) == FALSE) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot save folder metainfo to %s: %s"), - folder->meta->path, g_strerror(errno)); - camel_object_unref(folder); + folder->meta->path, strerror(errno)); + camel_object_unref(CAMEL_OBJECT (folder)); return NULL; } } @@ -832,7 +836,7 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex if (real_store == NULL) { g_free(metapath); free_metainfo(meta); - camel_object_unref(real_store); + camel_object_unref((CamelObject *)real_store); return; } @@ -843,7 +847,7 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex camel_exception_xfer(ex, &local_ex); g_free(metapath); free_metainfo(meta); - camel_object_unref(real_store); + camel_object_unref((CamelObject *)real_store); return; } @@ -854,7 +858,7 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex if (unlink(metapath) == -1) { camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot delete folder metadata %s: %s"), - metapath, g_strerror(errno)); + metapath, strerror(errno)); } g_free(metapath); @@ -934,7 +938,7 @@ mls_rename_folder(CamelStore *store, const char *old_name, const char *new_name, reninfo.new = info; reninfo.old_base = (char *)old_name; - camel_object_trigger_event(store, "folder_renamed", &reninfo); + camel_object_trigger_event((CamelObject *)store, "folder_renamed", &reninfo); } else { g_free(newuri); g_warning("Cannot find existing folder '%s' in table?\n", olduri); @@ -948,7 +952,7 @@ mls_rename_folder(CamelStore *store, const char *old_name, const char *new_name, g_free(newname); g_free(oldname); - camel_object_unref(real_store); + camel_object_unref((CamelObject *)real_store); free_metainfo(meta); @@ -1060,7 +1064,7 @@ static void mail_local_store_add_folder(MailLocalStore *mls, const char *uri, co if (info) { /* FIXME: should copy info, so we dont get a removed while we're using it? */ - camel_object_trigger_event(mls, "folder_created", info); + camel_object_trigger_event((CamelObject *)mls, "folder_created", info); /* this is just so the folder is opened at least once to setup the folder counts etc in the display. Joy eh? The result is discarded. */ @@ -1095,7 +1099,7 @@ static void mail_local_store_remove_folder(MailLocalStore *mls, const char *path LOCAL_STORE_UNLOCK(mls); if (data.info) { - camel_object_trigger_event(mls, "folder_deleted", data.info); + camel_object_trigger_event((CamelObject *)mls, "folder_deleted", data.info); g_free(data.info->url); g_free(data.info->full_name); @@ -1191,7 +1195,7 @@ local_storage_new_folder_cb (EvolutionStorageListener *storage_listener, info.unread_message_count = 0; info.path = (char *)path; - camel_object_trigger_event(global_local_store, "folder_created", &info); + camel_object_trigger_event((CamelObject *)global_local_store, "folder_created", &info); g_free(info.url); camel_url_free(url); } @@ -1232,19 +1236,18 @@ storage_listener_startup (EvolutionShellClient *shellclient) corba_local_storage_listener = evolution_storage_listener_corba_objref ( local_storage_listener); - /* FIXME: is this supposed to be destroy? */ - g_signal_connect(local_storage_listener, - "destroyed", - G_CALLBACK (local_storage_destroyed_cb), - corba_storage); - g_signal_connect(local_storage_listener, - "new_folder", - G_CALLBACK (local_storage_new_folder_cb), - corba_storage); - g_signal_connect(local_storage_listener, - "removed_folder", - G_CALLBACK (local_storage_removed_folder_cb), - corba_storage); + gtk_signal_connect (GTK_OBJECT (local_storage_listener), + "destroyed", + GTK_SIGNAL_FUNC (local_storage_destroyed_cb), + corba_storage); + gtk_signal_connect (GTK_OBJECT (local_storage_listener), + "new_folder", + GTK_SIGNAL_FUNC (local_storage_new_folder_cb), + corba_storage); + gtk_signal_connect (GTK_OBJECT (local_storage_listener), + "removed_folder", + GTK_SIGNAL_FUNC (local_storage_removed_folder_cb), + corba_storage); CORBA_exception_init (&ev); GNOME_Evolution_Storage_addListener (corba_storage, @@ -1345,15 +1348,11 @@ static void reconfigure_folder_reconfigured (struct _mail_msg *mm) { struct _reconfigure_msg *m = (struct _reconfigure_msg *)mm; - GtkWidget *dialog; /*char *uri;*/ if (camel_exception_is_set (&mm->ex)) { - dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, "%s", - _("If you can no longer open this mailbox, then\n" - "you may need to repair it manually.")); - gtk_dialog_run (GTK_DIALOG (dialog)); + gnome_error_dialog (_("If you can no longer open this mailbox, then\n" + "you may need to repair it manually.")); } if (m->done) @@ -1374,7 +1373,7 @@ reconfigure_folder_free (struct _mail_msg *mm) } if (m->folder) - camel_object_unref (m->folder); + camel_object_unref (CAMEL_OBJECT (m->folder)); g_free(m->uri); g_free (m->newtype); } @@ -1387,15 +1386,13 @@ static struct _mail_msg_op reconfigure_folder_op = { }; static void -reconfigure_response(GtkDialog *dialog, int button, struct _reconfigure_msg *m) +reconfigure_clicked (GnomeDialog *dialog, int button, struct _reconfigure_msg *m) { - switch(button) { - case GTK_RESPONSE_OK: { + if (button == 0) { GtkWidget *menu, *item; - menu = gtk_option_menu_get_menu(m->optionlist); item = gtk_menu_get_active(GTK_MENU(menu)); - m->newtype = g_strdup(g_object_get_data ((GObject *)item, "type")); + m->newtype = g_strdup(gtk_object_get_data((GtkObject *)item, "type")); m->index_body = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m->check_index_body)); gtk_widget_set_sensitive (m->frame, FALSE); @@ -1403,23 +1400,21 @@ reconfigure_response(GtkDialog *dialog, int button, struct _reconfigure_msg *m) gtk_widget_set_sensitive (m->cancel, FALSE); e_thread_put (mail_thread_queued, (EMsg *)m); - break; } - case GTK_RESPONSE_CANCEL: - default: + } else { if (m->done) m->done(m->uri, NULL, m->done_data); mail_msg_free ((struct _mail_msg *)m); - break; } - - gtk_widget_destroy((GtkWidget *)dialog); + + if (button != -1) + gnome_dialog_close (dialog); } static void reconfigure_got_folder(char *uri, CamelFolder *folder, void *data) { GladeXML *gui; - GtkDialog *gd; + GnomeDialog *gd; struct _reconfigure_msg *m = data; char *title; GList *p; @@ -1448,8 +1443,8 @@ reconfigure_got_folder(char *uri, CamelFolder *folder, void *data) return; } - gui = glade_xml_new (EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format", NULL); - gd = (GtkDialog *)glade_xml_get_widget (gui, "dialog_format"); + gui = glade_xml_new (EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format"); + gd = (GnomeDialog *)glade_xml_get_widget (gui, "dialog_format"); title = g_strdup_printf (_("Reconfigure /%s"), camel_folder_get_full_name (folder)); @@ -1465,34 +1460,34 @@ reconfigure_got_folder(char *uri, CamelFolder *folder, void *data) m->newtype = NULL; m->folder = folder; camel_object_ref(folder); - + /* dynamically create the folder type list from camel */ /* we assume the list is static and never freed */ currentformat = MAIL_LOCAL_FOLDER (folder)->meta->format; - p = camel_session_list_providers (session, TRUE); - menu = gtk_menu_new (); + p = camel_session_list_providers(session, TRUE); + menu = gtk_menu_new(); while (p) { CamelProvider *cp = p->data; - + /* we only want local providers */ if (cp->flags & CAMEL_PROVIDER_IS_LOCAL) { GtkWidget *item; char *label; - - if (!strcmp (cp->protocol, currentformat)) + + if (strcmp(cp->protocol, currentformat) == 0) history = index; - + label = g_strdup_printf("%s (%s)", cp->protocol, _(cp->name)); - item = gtk_menu_item_new_with_label (label); - g_free (label); - g_object_set_data ((GObject *) item, "type", cp->protocol); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + item = gtk_menu_item_new_with_label(label); + g_free(label); + gtk_object_set_data((GtkObject *)item, "type", cp->protocol); + gtk_widget_show(item); + gtk_menu_append(GTK_MENU(menu), item); index++; } p = p->next; } - gtk_option_menu_remove_menu (GTK_OPTION_MENU (m->optionlist)); + gtk_option_menu_remove_menu (GTK_OPTION_MENU(m->optionlist)); gtk_option_menu_set_menu (GTK_OPTION_MENU(m->optionlist), menu); gtk_option_menu_set_history(GTK_OPTION_MENU(m->optionlist), history); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m->check_index_body), MAIL_LOCAL_FOLDER (folder)->meta->indexed); @@ -1500,8 +1495,8 @@ reconfigure_got_folder(char *uri, CamelFolder *folder, void *data) gtk_label_set_text ((GtkLabel *)glade_xml_get_widget (gui, "label_format"), MAIL_LOCAL_FOLDER (folder)->meta->format); - g_signal_connect(gd, "response", G_CALLBACK(reconfigure_response), m); - g_object_unref(gui); + gtk_signal_connect (GTK_OBJECT (gd), "clicked", reconfigure_clicked, m); + gtk_object_unref (GTK_OBJECT (gui)); g_hash_table_insert (reconfigure_folder_hash, (gpointer) folder, (gpointer) gd); @@ -1514,7 +1509,7 @@ mail_local_reconfigure_folder(const char *uri, void (*done)(const char *uri, Cam struct _reconfigure_msg *m; if (strncmp(uri, "file:", 5) != 0) { - e_notice (NULL, GTK_MESSAGE_WARNING, + e_notice (NULL, GNOME_MESSAGE_BOX_WARNING, _("You cannot change the format of a non-local folder.")); if (done) done(uri, NULL, done_data); diff --git a/mail/mail-preferences.c b/mail/mail-preferences.c index 7fc9f19e6e..2046859174 100644 --- a/mail/mail-preferences.c +++ b/mail/mail-preferences.c @@ -25,14 +25,13 @@ #include <config.h> #endif -#include <string.h> - #include "mail-preferences.h" -#include <gconf/gconf.h> -#include <gal/util/e-iconv.h> +#include <gal/widgets/e-unicode.h> +#include <gal/util/e-unicode-i18n.h> #include <gtkhtml/gtkhtml-properties.h> #include "widgets/misc/e-charset-picker.h" + #include <bonobo/bonobo-generic-factory.h> #include "mail-config.h" @@ -40,7 +39,7 @@ static void mail_preferences_class_init (MailPreferencesClass *class); static void mail_preferences_init (MailPreferences *dialog); -static void mail_preferences_finalise (GObject *obj); +static void mail_preferences_finalise (GtkObject *obj); static GtkVBoxClass *parent_class = NULL; @@ -48,20 +47,20 @@ static GtkVBoxClass *parent_class = NULL; GtkType mail_preferences_get_type (void) { - static GType type = 0; + static GtkType type = 0; if (!type) { - GTypeInfo type_info = { - sizeof (MailPreferencesClass), - NULL, NULL, - (GClassInitFunc) mail_preferences_class_init, - NULL, NULL, + GtkTypeInfo type_info = { + "MailPreferences", sizeof (MailPreferences), - 0, - (GInstanceInitFunc) mail_preferences_init, + sizeof (MailPreferencesClass), + (GtkClassInitFunc) mail_preferences_class_init, + (GtkObjectInitFunc) mail_preferences_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL }; - type = g_type_register_static (gtk_vbox_get_type (), "MailPreferences", &type_info, 0); + type = gtk_type_unique (gtk_vbox_get_type (), &type_info); } return type; @@ -70,12 +69,14 @@ mail_preferences_get_type (void) static void mail_preferences_class_init (MailPreferencesClass *klass) { - GObjectClass *object_class; + GtkObjectClass *object_class; - object_class = (GObjectClass *) klass; - parent_class = g_type_class_ref (gtk_vbox_get_type ()); + object_class = (GtkObjectClass *) klass; + parent_class = gtk_type_class (gtk_vbox_get_type ()); object_class->finalize = mail_preferences_finalise; + /* override methods */ + } static void @@ -85,27 +86,21 @@ mail_preferences_init (MailPreferences *preferences) } static void -mail_preferences_finalise (GObject *obj) +mail_preferences_finalise (GtkObject *obj) { MailPreferences *prefs = (MailPreferences *) obj; - g_object_unref (prefs->gui); - g_object_unref (prefs->pman); - g_object_unref (prefs->gconf); + gtk_object_unref (GTK_OBJECT (prefs->gui)); + gtk_object_unref (GTK_OBJECT (prefs->pman)); + gtk_object_unref (GTK_OBJECT (prefs->gconf)); - ((GObjectClass *)(parent_class))->finalize (obj); + ((GtkObjectClass *)(parent_class))->finalize (obj); } static void -colorpicker_set_color (GnomeColorPicker *color, const char *str) +colorpicker_set_color (GnomeColorPicker *color, guint32 rgb) { - GdkColor colour; - guint32 rgb; - - gdk_color_parse (str, &colour); - rgb = ((colour.red & 0xff00) << 8) | (colour.green & 0xff00) | ((colour.blue & 0xff00) >> 8); - gnome_color_picker_set_i8 (color, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff); } @@ -127,7 +122,16 @@ colorpicker_get_color (GnomeColorPicker *color) } static void -settings_changed (GtkWidget *widget, gpointer user_data) +toggle_button_toggled (GtkWidget *widget, gpointer user_data) +{ + MailPreferences *prefs = (MailPreferences *) user_data; + + if (prefs->control) + evolution_config_control_changed (prefs->control); +} + +static void +entry_changed (GtkWidget *widget, gpointer user_data) { MailPreferences *prefs = (MailPreferences *) user_data; @@ -151,8 +155,8 @@ restore_labels_clicked (GtkWidget *widget, gpointer user_data) int i; for (i = 0; i < 5; i++) { - gtk_entry_set_text (prefs->labels[i].name, _(label_defaults[i].name)); - colorpicker_set_color (prefs->labels[i].color, label_defaults[i].colour); + e_utf8_gtk_entry_set_text (prefs->labels[i].name, U_(label_defaults[i].name)); + colorpicker_set_color (prefs->labels[i].color, label_defaults[i].color); } } @@ -176,7 +180,8 @@ option_menu_connect (GtkOptionMenu *omenu, gpointer user_data) items = GTK_MENU_SHELL (menu)->children; while (items) { item = items->data; - g_signal_connect (item, "activate", G_CALLBACK (menu_changed), user_data); + gtk_signal_connect (GTK_OBJECT (item), "activate", + menu_changed, user_data); items = items->next; } } @@ -186,18 +191,15 @@ mail_preferences_construct (MailPreferences *prefs) { GtkWidget *widget, *toplevel, *menu; const char *text; - GSList *list, *l; GladeXML *gui; - gboolean bool; - int i, val; - char *buf; + int i; char *names[][2] = { { "anim_check", "chkShowAnimatedImages" }, { "magic_links_check", "chkAutoDetectLinks" }, { NULL, NULL } }; - gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "preferences_tab", NULL); + gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "preferences_tab"); prefs->gui = gui; /* get our toplevel widget */ @@ -213,128 +215,122 @@ mail_preferences_construct (MailPreferences *prefs) /* Message Display */ prefs->timeout_toggle = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkMarkTimeout")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/display/mark_seen", NULL); - gtk_toggle_button_set_active (prefs->timeout_toggle, bool); - g_signal_connect (prefs->timeout_toggle, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->timeout_toggle, mail_config_get_do_seen_timeout ()); + gtk_signal_connect (GTK_OBJECT (prefs->timeout_toggle), "toggled", + toggle_button_toggled, prefs); prefs->timeout = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "spinMarkTimeout")); - val = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/display/mark_seen_timeout", NULL); - gtk_spin_button_set_value (prefs->timeout, (1.0 * val) / 1000.0); - g_signal_connect (prefs->timeout, "changed", G_CALLBACK (settings_changed), prefs); + gtk_spin_button_set_value (prefs->timeout, (1.0 * mail_config_get_mark_as_seen_timeout ()) / 1000.0); + gtk_signal_connect (GTK_OBJECT (prefs->timeout), "changed", + entry_changed, prefs); prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset")); - buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/format/charset", NULL); - menu = e_charset_picker_new (buf ? buf : e_iconv_locale_charset ()); + menu = e_charset_picker_new (mail_config_get_default_charset ()); gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu)); option_menu_connect (prefs->charset, prefs); - g_free (buf); prefs->citation_highlight = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkHighlightCitations")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/display/mark_citations", NULL); - gtk_toggle_button_set_active (prefs->citation_highlight, bool); - g_signal_connect (prefs->citation_highlight, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->citation_highlight, mail_config_get_citation_highlight ()); + gtk_signal_connect (GTK_OBJECT (prefs->citation_highlight), "toggled", + toggle_button_toggled, prefs); prefs->citation_color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, "colorpickerHighlightCitations")); - buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/citation_colour", NULL); - colorpicker_set_color (prefs->citation_color, buf ? buf : "#737373"); - g_signal_connect (prefs->citation_color, "color-set", G_CALLBACK (color_set), prefs); - g_free (buf); + colorpicker_set_color (prefs->citation_color, mail_config_get_citation_color ()); + gtk_signal_connect (GTK_OBJECT (prefs->citation_color), "color-set", + color_set, prefs); /* Deleting Mail */ prefs->empty_trash = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkEmptyTrashOnExit")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/trash/empty_on_exit", NULL); - gtk_toggle_button_set_active (prefs->empty_trash, bool); - g_signal_connect (prefs->empty_trash, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->empty_trash, mail_config_get_empty_trash_on_exit ()); + gtk_signal_connect (GTK_OBJECT (prefs->empty_trash), "toggled", + toggle_button_toggled, prefs); prefs->confirm_expunge = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkConfirmExpunge")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/prompts/expunge", NULL); - gtk_toggle_button_set_active (prefs->confirm_expunge, bool); - g_signal_connect (prefs->confirm_expunge, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->confirm_expunge, mail_config_get_confirm_expunge ()); + gtk_signal_connect (GTK_OBJECT (prefs->confirm_expunge), "toggled", + toggle_button_toggled, prefs); /* New Mail Notification */ - val = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/notify/type", NULL); prefs->notify_not = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyNot")); - gtk_toggle_button_set_active (prefs->notify_not, val == MAIL_CONFIG_NOTIFY_NOT); - g_signal_connect (prefs->notify_not, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->notify_not, mail_config_get_new_mail_notify () == MAIL_CONFIG_NOTIFY_NOT); + gtk_signal_connect (GTK_OBJECT (prefs->notify_not), "toggled", + toggle_button_toggled, prefs); prefs->notify_beep = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyBeep")); - gtk_toggle_button_set_active (prefs->notify_beep, val == MAIL_CONFIG_NOTIFY_BEEP); - g_signal_connect (prefs->notify_beep, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->notify_beep, mail_config_get_new_mail_notify () == MAIL_CONFIG_NOTIFY_BEEP); + gtk_signal_connect (GTK_OBJECT (prefs->notify_beep), "toggled", + toggle_button_toggled, prefs); prefs->notify_play_sound = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyPlaySound")); - gtk_toggle_button_set_active (prefs->notify_play_sound, val == MAIL_CONFIG_NOTIFY_PLAY_SOUND); - g_signal_connect (prefs->notify_play_sound, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->notify_play_sound, + mail_config_get_new_mail_notify () == MAIL_CONFIG_NOTIFY_PLAY_SOUND); + gtk_signal_connect (GTK_OBJECT (prefs->notify_play_sound), "toggled", + toggle_button_toggled, prefs); prefs->notify_sound_file = GNOME_FILE_ENTRY (glade_xml_get_widget (gui, "fileNotifyPlaySound")); - buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/notify/sound", NULL); - gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)), buf ? buf : ""); - g_signal_connect (gnome_file_entry_gtk_entry (prefs->notify_sound_file), "changed", - G_CALLBACK (settings_changed), prefs); - g_free (buf); + text = mail_config_get_new_mail_notify_sound_file (); + gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)), + text ? text : ""); + gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (prefs->notify_sound_file)), "changed", + entry_changed, 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); - g_signal_connect (prefs->images_never, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->images_never, mail_config_get_http_mode () == MAIL_CONFIG_HTTP_NEVER); + gtk_signal_connect (GTK_OBJECT (prefs->images_never), "toggled", + toggle_button_toggled, prefs); prefs->images_sometimes = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radImagesSometimes")); - gtk_toggle_button_set_active (prefs->images_sometimes, val == MAIL_CONFIG_HTTP_SOMETIMES); - g_signal_connect (prefs->images_sometimes, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->images_sometimes, mail_config_get_http_mode () == MAIL_CONFIG_HTTP_SOMETIMES); + gtk_signal_connect (GTK_OBJECT (prefs->images_sometimes), "toggled", + toggle_button_toggled, prefs); prefs->images_always = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radImagesAlways")); - gtk_toggle_button_set_active (prefs->images_always, val == MAIL_CONFIG_HTTP_ALWAYS); - g_signal_connect (prefs->images_always, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_toggle_button_set_active (prefs->images_always, mail_config_get_http_mode () == MAIL_CONFIG_HTTP_ALWAYS); + gtk_signal_connect (GTK_OBJECT (prefs->images_always), "toggled", + toggle_button_toggled, prefs); -#warning "gtkhtml prop manager" -#if 0 prefs->pman = GTK_HTML_PROPMANAGER (gtk_html_propmanager_new (prefs->gconf)); - g_signal_connect (prefs->pman, "changed", G_CALLBACK (settings_changed), prefs); - g_object_ref (prefs->pman); + gtk_signal_connect (GTK_OBJECT (prefs->pman), "changed", toggle_button_toggled, prefs); + gtk_object_ref (GTK_OBJECT (prefs->pman)); gtk_html_propmanager_set_names (prefs->pman, names); gtk_html_propmanager_set_gui (prefs->pman, gui, NULL); for (i = 0; names[i][0] != NULL; i++) { widget = glade_xml_get_widget (gui, names[i][1]); - g_signal_connect (widget, "toggled", G_CALLBACK (settings_changed), prefs); + gtk_signal_connect (GTK_OBJECT (widget), "toggled", + toggle_button_toggled, prefs); } -#endif prefs->prompt_unwanted_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptWantHTML")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/prompts/unwanted_html", NULL); - gtk_toggle_button_set_active (prefs->prompt_unwanted_html, bool); - g_signal_connect (prefs->prompt_unwanted_html, "toggled", G_CALLBACK (settings_changed), prefs); - - i = 0; - list = mail_config_get_labels (); - while (list != NULL && i < 5) { - MailConfigLabel *label; + gtk_toggle_button_set_active (prefs->prompt_unwanted_html, mail_config_get_confirm_unwanted_html ()); + gtk_signal_connect (GTK_OBJECT (prefs->prompt_unwanted_html), "toggled", + toggle_button_toggled, prefs); + + /* Labels and Colours tab */ + for (i = 0; i < 5; i++) { char *widget_name; - label = list->data; - widget_name = g_strdup_printf ("txtLabel%d", i); prefs->labels[i].name = GTK_ENTRY (glade_xml_get_widget (gui, widget_name)); g_free (widget_name); + text = mail_config_get_label_name (i); + e_utf8_gtk_entry_set_text (prefs->labels[i].name, text ? text : ""); + gtk_signal_connect (GTK_OBJECT (prefs->labels[i].name), "changed", + entry_changed, prefs); widget_name = g_strdup_printf ("colorLabel%d", i); prefs->labels[i].color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, widget_name)); g_free (widget_name); - - gtk_entry_set_text (prefs->labels[i].name, label->name); - g_signal_connect (prefs->labels[i].name, "changed", G_CALLBACK (settings_changed), prefs); - - colorpicker_set_color (prefs->labels[i].color, label->colour); - g_signal_connect (prefs->labels[i].color, "color_set", G_CALLBACK (color_set), prefs); - - i++; - list = list->next; + colorpicker_set_color (prefs->labels[i].color, mail_config_get_label_color (i)); + gtk_signal_connect (GTK_OBJECT (prefs->labels[i].color), "color_set", + color_set, 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); + gtk_signal_connect (GTK_OBJECT (prefs->restore_labels), "clicked", + restore_labels_clicked, prefs); } @@ -343,7 +339,7 @@ mail_preferences_new (void) { MailPreferences *new; - new = (MailPreferences *) g_object_new (mail_preferences_get_type (), NULL); + new = (MailPreferences *) gtk_type_new (mail_preferences_get_type ()); mail_preferences_construct (new); return (GtkWidget *) new; @@ -354,91 +350,70 @@ void mail_preferences_apply (MailPreferences *prefs) { GtkWidget *entry, *menu; - char *string, buf[20]; - const char *cstring; - GSList *list, *l; + char *string; guint32 rgb; int i, val; /* General tab */ /* Message Display */ - gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/display/mark_seen", - gtk_toggle_button_get_active (prefs->timeout_toggle), NULL); + mail_config_set_do_seen_timeout (gtk_toggle_button_get_active (prefs->timeout_toggle)); - val = (int) (gtk_spin_button_get_value (prefs->timeout) * 1000.0); - gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/mark_seen_timeout", val, NULL); + val = (int) (gtk_spin_button_get_value_as_float (prefs->timeout) * 1000); + mail_config_set_mark_as_seen_timeout (val); menu = gtk_option_menu_get_menu (prefs->charset); - if (!(string = e_charset_picker_get_charset (menu))) - string = g_strdup (e_iconv_locale_charset ()); - - gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/format/charset", string, NULL); - g_free (string); + string = e_charset_picker_get_charset (menu); + if (string) { + mail_config_set_default_charset (string); + g_free (string); + } - gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/display/mark_citations", - gtk_toggle_button_get_active (prefs->citation_highlight), NULL); + mail_config_set_citation_highlight (gtk_toggle_button_get_active (prefs->citation_highlight)); rgb = colorpicker_get_color (prefs->citation_color); - sprintf (buf,"#%06x", rgb & 0xffffff); - gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/display/citation_colour", buf, NULL); + mail_config_set_citation_color (rgb); /* Deleting Mail */ - gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/trash/empty_on_exit", - gtk_toggle_button_get_active (prefs->empty_trash), NULL); + mail_config_set_empty_trash_on_exit (gtk_toggle_button_get_active (prefs->empty_trash)); - gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/prompts/expunge", - gtk_toggle_button_get_active (prefs->confirm_expunge), NULL); + mail_config_set_confirm_expunge (gtk_toggle_button_get_active (prefs->confirm_expunge)); /* New Mail Notification */ if (gtk_toggle_button_get_active (prefs->notify_not)) - val = MAIL_CONFIG_NOTIFY_NOT; + mail_config_set_new_mail_notify (MAIL_CONFIG_NOTIFY_NOT); else if (gtk_toggle_button_get_active (prefs->notify_beep)) - val = MAIL_CONFIG_NOTIFY_BEEP; + mail_config_set_new_mail_notify (MAIL_CONFIG_NOTIFY_BEEP); else - val = MAIL_CONFIG_NOTIFY_PLAY_SOUND; - - gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/notify/type", val, NULL); + mail_config_set_new_mail_notify (MAIL_CONFIG_NOTIFY_PLAY_SOUND); entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (prefs->notify_sound_file)); - cstring = gtk_entry_get_text (GTK_ENTRY (entry)); - gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/notify/sound", cstring, NULL); + string = gtk_entry_get_text (GTK_ENTRY (entry)); + mail_config_set_new_mail_notify_sound_file (string); /* HTML Mail */ if (gtk_toggle_button_get_active (prefs->images_always)) - val = MAIL_CONFIG_HTTP_ALWAYS; + mail_config_set_http_mode (MAIL_CONFIG_HTTP_ALWAYS); else if (gtk_toggle_button_get_active (prefs->images_sometimes)) - val = MAIL_CONFIG_HTTP_SOMETIMES; + mail_config_set_http_mode (MAIL_CONFIG_HTTP_SOMETIMES); else - val = MAIL_CONFIG_HTTP_NEVER; - - gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/load_http_images", val, NULL); + mail_config_set_http_mode (MAIL_CONFIG_HTTP_NEVER); -#warning "gtkhtml propmanager" -#if 0 gtk_html_propmanager_apply (prefs->pman); -#endif - gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/prompts/unwanted_html", - gtk_toggle_button_get_active (prefs->prompt_unwanted_html), NULL); + mail_config_set_confirm_unwanted_html (gtk_toggle_button_get_active (prefs->prompt_unwanted_html)); /* Labels and Colours */ - list = NULL; - for (i = 4; i >= 0; i--) { - cstring = gtk_entry_get_text (prefs->labels[i].name); + for (i = 0; i < 5; i++) { + /* save the label... */ + string = e_utf8_gtk_entry_get_text (prefs->labels[i].name); + mail_config_set_label_name (i, string); + g_free (string); + + /* save the colour... */ rgb = colorpicker_get_color (prefs->labels[i].color); - string = g_strdup_printf ("%s:#%06x", cstring, rgb & 0xffffff); - list = g_slist_prepend (list, string); - } - - gconf_client_set_list (prefs->gconf, "/apps/evolution/mail/labels", GCONF_VALUE_STRING, list, NULL); - - l = list; - while (l != NULL) { - g_free (l->data); - l = l->next; + mail_config_set_label_color (i, rgb); } - g_slist_free (list); - gconf_client_suggest_sync (prefs->gconf, NULL); + mail_config_write (); } diff --git a/mail/mail-session.c b/mail/mail-session.c index c898bff2e4..ff749d90e0 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -25,16 +25,15 @@ #endif #include <stdlib.h> -#include <string.h> - -#include <gtk/gtkdialog.h> -#include <gtk/gtkstock.h> - -#include <gconf/gconf.h> -#include <gconf/gconf-client.h> - +#include <libgnome/gnome-defs.h> #include <libgnome/gnome-config.h> #include <libgnome/gnome-sound.h> +#include <libgnomeui/gnome-dialog.h> +#include <libgnomeui/gnome-dialog-util.h> +#include <libgnomeui/gnome-messagebox.h> +#include <libgnomeui/gnome-stock.h> + +#include <gal/widgets/e-unicode.h> #include "camel/camel-filter-driver.h" #include "filter/filter-context.h" @@ -80,7 +79,7 @@ typedef struct _MailSessionClass { } MailSessionClass; -static char *get_password(CamelSession *session, const char *prompt, gboolean reprompt, gboolean secret, CamelService *service, const char *item, CamelException *ex); +static char *get_password(CamelSession *session, const char *prompt, gboolean secret, CamelService *service, const char *item, CamelException *ex); static void forget_password(CamelSession *session, CamelService *service, const char *item, CamelException *ex); static gboolean alert_user(CamelSession *session, CamelSessionAlertType type, const char *prompt, gboolean cancel); static guint register_timeout(CamelSession *session, guint32 interval, CamelTimeoutCallback cb, gpointer camel_data); @@ -151,26 +150,24 @@ make_key (CamelService *service, const char *item) /* ********************************************************************** */ -static GtkDialog *password_dialog = NULL; +static GnomeDialog *password_dialogue = NULL; static EDList password_list = E_DLIST_INITIALISER(password_list); +static int password_destroy_id; struct _pass_msg { struct _mail_msg msg; - + CamelSession *session; const char *prompt; - gboolean reprompt; gboolean secret; CamelService *service; const char *item; CamelException *ex; - + char *service_url; char *key; - - EAccountService *config_service; + GtkWidget *check; - GtkWidget *entry; char *result; int ismain; }; @@ -178,28 +175,29 @@ struct _pass_msg { static void do_get_pass(struct _mail_msg *mm); static void -pass_activate (GtkEntry *entry, void *data) -{ - if (password_dialog) - gtk_dialog_response (password_dialog, GTK_RESPONSE_OK); -} - -static void -pass_response (GtkDialog *dialog, int button, void *data) +pass_got (char *string, void *data) { struct _pass_msg *m = data; - switch (button) { - case GTK_RESPONSE_OK: - { + if (string) { + MailConfigService *service = NULL; + const MailConfigAccount *mca; gboolean cache, remember; - m->result = g_strdup (gtk_entry_get_text ((GtkEntry *) m->entry)); - remember = cache = m->check ? gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m->check)) : FALSE; - + m->result = g_strdup (string); + remember = cache = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m->check)); if (m->service_url) { - if (m->config_service) { - mail_config_service_set_save_passwd (m->config_service, cache); + mca = mail_config_get_account_by_source_url (m->service_url); + if (mca) { + service = mca->source; + } else { + mca = mail_config_get_account_by_transport_url (m->service_url); + if (mca) + service = mca->transport; + } + + if (service) { + mail_config_service_set_save_passwd (service, cache); /* set `cache' to TRUE because people don't want to have to re-enter their passwords for this session even if they told @@ -217,80 +215,128 @@ pass_response (GtkDialog *dialog, int button, void *data) /* should we remember it between sessions? */ if (remember) - e_passwords_remember_password ("Mail", m->key); + e_passwords_remember_password (m->key); } - break; + } else { + camel_exception_set(m->ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled operation.")); } - default: - camel_exception_set (m->ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled operation.")); - break; + + if (password_destroy_id) { + gtk_signal_disconnect((GtkObject *)password_dialogue, password_destroy_id); + password_destroy_id = 0; } - - gtk_widget_destroy ((GtkWidget *) dialog); - - password_dialog = NULL; - e_msgport_reply ((EMsg *)m); - - if ((m = (struct _pass_msg *) e_dlist_remhead (&password_list))) - do_get_pass ((struct _mail_msg *) m); + + password_dialogue = NULL; + e_msgport_reply((EMsg *)m); + + if ((m = (struct _pass_msg *)e_dlist_remhead(&password_list))) + do_get_pass((struct _mail_msg *)m); } static void -request_password (struct _pass_msg *m) +request_password_deleted(GtkWidget *w, struct _pass_msg *m) { - EAccount *mca = NULL; + password_destroy_id = 0; + pass_got(NULL, m); +} + +static void +request_password(struct _pass_msg *m) +{ + const MailConfigAccount *mca = NULL; + GtkWidget *dialogue; + GtkWidget *check, *check_label, *entry; + GList *children, *iter; + gboolean show; char *title; - - /* If we already have a password_dialog up, save this request till later */ - if (!m->ismain && password_dialog) { - e_dlist_addtail (&password_list, (EDListNode *)m); + unsigned int accel_key; + + /* If we already have a password_dialogue up, save this request till later */ + if (!m->ismain && password_dialogue) { + e_dlist_addtail(&password_list, (EDListNode *)m); return; } + + /* FIXME: Remove this total snot */ + + /* assume we can use any widget to translate string for display */ + check_label = gtk_label_new (""); + password_dialogue = (GnomeDialog *)dialogue = gnome_request_dialog (m->secret, m->prompt, NULL, 0, pass_got, m, NULL); + password_destroy_id = gtk_signal_connect((GtkObject *)dialogue, "destroy", request_password_deleted, m); + + check = gtk_check_button_new (); + gtk_misc_set_alignment (GTK_MISC (check_label), 0.0, 0.5); + accel_key = gtk_label_parse_uline (GTK_LABEL (check_label), + m->service_url ? _("_Remember this password") : + _("_Remember this password for the remainder of this session")); + gtk_widget_add_accelerator (check, "clicked", + GNOME_DIALOG (password_dialogue)->accelerators, + accel_key, + GDK_MOD1_MASK, 0); + gtk_container_add (GTK_CONTAINER (check), check_label); + + show = TRUE; if (m->service_url) { - if ((mca = mail_config_get_account_by_source_url (m->service_url))) - m->config_service = mca->source; - else if ((mca = mail_config_get_account_by_transport_url (m->service_url))) - m->config_service = mca->transport; + mca = mail_config_get_account_by_source_url(m->service_url); + if (mca) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), mca->source->save_passwd); + else { + mca = mail_config_get_account_by_transport_url (m->service_url); + if (mca) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), mca->transport->save_passwd); + else { + d(printf ("Cannot figure out which account owns URL \"%s\"\n", m->service_url)); + show = FALSE; + } + } } - if (mca) - title = g_strdup_printf (_("Enter Password for %s"), mca->name); - else - title = g_strdup (_("Enter Password")); + if (show) + gtk_widget_show_all (check); + + /* do some dirty stuff to put the checkbutton after the entry */ + entry = NULL; + children = gtk_container_children (GTK_CONTAINER (GNOME_DIALOG (dialogue)->vbox)); + for (iter = children; iter; iter = iter->next) { + if (GTK_IS_ENTRY (iter->data)) { + entry = GTK_WIDGET (iter->data); + break; + } + } + g_list_free (children); - password_dialog = (GtkDialog *) gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_QUESTION, - GTK_BUTTONS_OK_CANCEL, "%s", m->prompt); - gtk_window_set_title (GTK_WINDOW (password_dialog), title); - g_free (title); + if (entry) { + gtk_object_ref (GTK_OBJECT (entry)); + gtk_container_remove (GTK_CONTAINER (GNOME_DIALOG (dialogue)->vbox), entry); + } - m->entry = gtk_entry_new (); - gtk_entry_set_visibility ((GtkEntry *) m->entry, !m->secret); - g_signal_connect (m->entry, "activate", G_CALLBACK (pass_activate), password_dialog); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (password_dialog)->vbox), m->entry, TRUE, FALSE, 0); - gtk_widget_show (m->entry); + gtk_box_pack_end (GTK_BOX (GNOME_DIALOG (dialogue)->vbox), check, TRUE, FALSE, 0); - if (m->reprompt && m->result) { - gtk_entry_set_text ((GtkEntry *) m->entry, m->result); - g_free (m->result); - m->result = NULL; + if (entry) { + gtk_box_pack_end (GTK_BOX (GNOME_DIALOG (dialogue)->vbox), entry, TRUE, FALSE, 0); + gtk_widget_grab_focus (entry); + gtk_object_unref (GTK_OBJECT (entry)); } - if (m->service_url == NULL || m->service != NULL) { - m->check = gtk_check_button_new_with_mnemonic (m->service_url ? _("_Remember this password") : - _("_Remember this password for the remainder of this session")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m->check), - m->config_service ? m->config_service->save_passwd : FALSE); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (password_dialog)->vbox), m->check, TRUE, FALSE, 0); - gtk_widget_show (m->check); - } + m->check = check; - if (m->ismain) { - pass_response(password_dialog, gtk_dialog_run (password_dialog), m); - } else { - g_signal_connect (password_dialog, "response", G_CALLBACK (pass_response), m); - gtk_widget_show ((GtkWidget *) password_dialog); - } + if (mca) { + char *name; + + name = e_utf8_to_gtk_string (GTK_WIDGET (dialogue), mca->name); + title = g_strdup_printf (_("Enter Password for %s"), name); + g_free (name); + } else + title = g_strdup (_("Enter Password")); + + gtk_window_set_title (GTK_WINDOW (dialogue), title); + g_free (title); + + if (m->ismain) + gnome_dialog_run_and_close ((GnomeDialog *)dialogue); + else + gtk_widget_show(dialogue); } static void @@ -300,15 +346,15 @@ do_get_pass(struct _mail_msg *mm) MailSession *mail_session = MAIL_SESSION (m->session); if (!strcmp (m->item, "popb4smtp_uri")) { - char *url = camel_url_to_string (m->service->url, 0); - EAccount *account = mail_config_get_account_by_transport_url (url); + char *url = camel_url_to_string(m->service->url, 0); + const MailConfigAccount *account = mail_config_get_account_by_transport_url(url); g_free(url); if (account) m->result = g_strdup(account->source->url); } else if (m->key) { - m->result = e_passwords_get_password ("Mail", m->key); - if (m->result == NULL || m->reprompt) { + m->result = e_passwords_get_password(m->key); + if (m->result == NULL) { if (mail_session->interactive) { request_password(m); return; @@ -336,13 +382,12 @@ static struct _mail_msg_op get_pass_op = { }; static char * -get_password (CamelSession *session, const char *prompt, gboolean reprompt, gboolean secret, - CamelService *service, const char *item, CamelException *ex) +get_password (CamelSession *session, const char *prompt, gboolean secret, CamelService *service, const char *item, CamelException *ex) { struct _pass_msg *m, *r; EMsgPort *pass_reply; char *ret; - + /* We setup an async request and send it off, and wait for it to return */ /* If we're really in main, we dont of course ... ... but this shouldn't be allowed because of locking issues */ @@ -351,7 +396,6 @@ get_password (CamelSession *session, const char *prompt, gboolean reprompt, gboo m->ismain = pthread_self() == mail_gui_thread; m->session = session; m->prompt = prompt; - m->reprompt = reprompt; m->secret = secret; m->service = service; m->item = item; @@ -360,11 +404,11 @@ get_password (CamelSession *session, const char *prompt, gboolean reprompt, gboo m->service_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL); m->key = make_key(service, item); - if (m->ismain) { + if (m->ismain) do_get_pass((struct _mail_msg *)m); - } else { + else { extern EMsgPort *mail_gui_port2; - + e_msgport_put(mail_gui_port2, (EMsg *)m); } @@ -375,7 +419,7 @@ get_password (CamelSession *session, const char *prompt, gboolean reprompt, gboo ret = m->result; mail_msg_free(m); e_msgport_destroy(pass_reply); - + return ret; } @@ -383,8 +427,8 @@ static void main_forget_password (CamelSession *session, CamelService *service, const char *item, CamelException *ex) { char *key = make_key (service, item); - - e_passwords_forget_password ("Mail", key); + + e_passwords_forget_password (key); g_free (key); } @@ -398,8 +442,9 @@ forget_password (CamelSession *session, CamelService *service, const char *item, /* ********************************************************************** */ -static GtkDialog *message_dialog; -static EDList message_list = E_DLIST_INITIALISER(message_list); +static GnomeDialog *message_dialogue; +static EDList message_list = E_DLIST_INITIALISER(password_list); +static guint message_destroy_id; struct _user_message_msg { struct _mail_msg msg; @@ -414,77 +459,88 @@ struct _user_message_msg { static void do_user_message (struct _mail_msg *mm); +/* if we dont have to wait for reply, we just check to see if any newly waiting prompts are there */ +static void +user_message_destroy_noreply(GnomeDialog *gd, void *data) +{ + struct _user_message_msg *m; + + message_dialogue = NULL; + if ((m = (struct _user_message_msg *)e_dlist_remhead(&message_list))) + do_user_message((struct _mail_msg *)m); +} + /* clicked, send back the reply */ static void -user_message_response (GtkDialog *dialog, int button, struct _user_message_msg *m) +user_message_clicked(GnomeDialog *gd, int button, struct _user_message_msg *m) { - gtk_widget_destroy ((GtkWidget *) dialog); - - message_dialog = NULL; - - /* if !allow_cancel, then we've already replied */ - if (m->allow_cancel) { - m->result = button == GTK_RESPONSE_OK; - e_msgport_reply((EMsg *)m); + message_dialogue = NULL; + + if (message_destroy_id) { + gtk_signal_disconnect((GtkObject *)gd, message_destroy_id); + message_destroy_id = 0; } - + + m->result = button == 0; + e_msgport_reply((EMsg *)m); + /* check for pendings */ if ((m = (struct _user_message_msg *)e_dlist_remhead(&message_list))) do_user_message((struct _mail_msg *)m); } static void -user_message_destroy_notify (struct _user_message_msg *m, GObject *deadbeef) +user_message_destroy(GnomeDialog *gd, struct _user_message_msg *m) { - message_dialog = NULL; + message_destroy_id = 0; + user_message_clicked(gd, -1, m); } static void do_user_message (struct _mail_msg *mm) { struct _user_message_msg *m = (struct _user_message_msg *)mm; - GtkMessageType msg_type; - - if (!m->ismain && message_dialog != NULL) { - e_dlist_addtail (&message_list, (EDListNode *)m); + const char *msg_type; + + if (!m->ismain && message_dialogue != NULL) { + e_dlist_addtail(&message_list, (EDListNode *)m); return; } - + switch (m->type) { case CAMEL_SESSION_ALERT_INFO: - msg_type = GTK_MESSAGE_INFO; + msg_type = GNOME_MESSAGE_BOX_INFO; break; case CAMEL_SESSION_ALERT_WARNING: - msg_type = GTK_MESSAGE_WARNING; + msg_type = GNOME_MESSAGE_BOX_WARNING; break; case CAMEL_SESSION_ALERT_ERROR: - msg_type = GTK_MESSAGE_ERROR; + msg_type = GNOME_MESSAGE_BOX_ERROR; break; default: - msg_type = GTK_MESSAGE_INFO; + msg_type = NULL; } - - message_dialog = (GtkDialog *) gtk_message_dialog_new ( - NULL, 0, msg_type, - m->allow_cancel ? GTK_BUTTONS_OK_CANCEL : GTK_BUTTONS_OK, - "%s", m->prompt); - gtk_dialog_set_default_response (message_dialog, m->allow_cancel ? GTK_RESPONSE_CANCEL : GTK_RESPONSE_OK); - g_object_set ((GObject *) message_dialog, "allow_shrink", TRUE, "allow_grow", TRUE, NULL); - + + message_dialogue = (GnomeDialog *)gnome_message_box_new(m->prompt, msg_type, GNOME_STOCK_BUTTON_OK, + m->allow_cancel ? GNOME_STOCK_BUTTON_CANCEL : NULL, + NULL); + gnome_dialog_set_default(message_dialogue, 1); + gnome_dialog_set_close(message_dialogue, TRUE); + gtk_window_set_policy (GTK_WINDOW (message_dialogue), TRUE, TRUE, TRUE); + /* We only need to wait for the result if we allow cancel otherwise show but send result back instantly */ if (m->allow_cancel) { - if (m->ismain) { - user_message_response(message_dialog, gtk_dialog_run (message_dialog), m); - } else { - g_signal_connect (message_dialog, "response", G_CALLBACK (user_message_response), m); - gtk_widget_show ((GtkWidget *) message_dialog); - } + gtk_signal_connect((GtkObject*)message_dialogue, "clicked", user_message_clicked, m); + message_destroy_id = gtk_signal_connect((GtkObject*)message_dialogue, "destroy", user_message_destroy, m); + if (m->ismain) + gnome_dialog_run_and_close ((GnomeDialog *)message_dialogue); + else + gtk_widget_show((GtkWidget *)message_dialogue); } else { - g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), message_dialog); - g_object_weak_ref ((GObject *) message_dialog, (GWeakNotify) user_message_destroy_notify, m); - gtk_widget_show ((GtkWidget *) message_dialog); + gtk_signal_connect((GtkObject *)message_dialogue, "destroy", user_message_destroy_noreply, NULL); + gtk_widget_show((GtkWidget *)message_dialogue); m->result = TRUE; - e_msgport_reply ((EMsg *)m); + e_msgport_reply((EMsg *)m); } } @@ -595,31 +651,31 @@ timeout_timeout (struct _mail_msg *mm) } static void -timeout_done (struct _mail_msg *mm) +timeout_done(struct _mail_msg *mm) { - struct _timeout_msg *m = (struct _timeout_msg *) mm; - MailSession *ms = (MailSession *) m->session; + struct _timeout_msg *m = (struct _timeout_msg *)mm; + MailSession *ms = (MailSession *)m->session; struct _timeout_data *td; - + if (!m->result) { MAIL_SESSION_LOCK(ms, lock); - td = find_timeout (&ms->timeouts, m->id); + td = find_timeout(&ms->timeouts, m->id); if (td) { - e_dlist_remove ((EDListNode *) td); + e_dlist_remove((EDListNode *)td); if (td->timeout_id) - gtk_timeout_remove (td->timeout_id); - g_free (td); + gtk_timeout_remove(td->timeout_id); + g_free(td); } MAIL_SESSION_UNLOCK(ms, lock); } } static void -timeout_free (struct _mail_msg *mm) +timeout_free(struct _mail_msg *mm) { struct _timeout_msg *m = (struct _timeout_msg *)mm; - - camel_object_unref (m->session); + + camel_object_unref((CamelObject *)m->session); } static struct _mail_msg_op timeout_op = { @@ -634,63 +690,63 @@ camel_timeout (gpointer data) { struct _timeout_data *td = data; struct _timeout_msg *m; - + /* stop if we are removed pending */ if (td->removed) return FALSE; - m = mail_msg_new (&timeout_op, NULL, sizeof (*m)); - + m = mail_msg_new(&timeout_op, NULL, sizeof (*m)); + m->session = td->session; - camel_object_ref (td->session); + camel_object_ref((CamelObject *)td->session); m->id = td->id; - e_thread_put (mail_thread_queued, (EMsg *)m); + e_thread_put(mail_thread_queued, (EMsg *)m); return TRUE; } static void -main_register_timeout (CamelSession *session, void *event_data, void *data) +main_register_timeout(CamelSession *session, void *event_data, void *data) { MailSession *ms = (MailSession *)session; unsigned int handle = (unsigned int)event_data; struct _timeout_data *td; - + MAIL_SESSION_LOCK(session, lock); - td = find_timeout (&ms->timeouts, handle); + td = find_timeout(&ms->timeouts, handle); if (td) { if (td->removed) { - e_dlist_remove ((EDListNode *) td); + e_dlist_remove((EDListNode *)td); if (td->timeout_id) - gtk_timeout_remove (td->timeout_id); - g_free (td); + gtk_timeout_remove(td->timeout_id); + g_free(td); } else { - td->timeout_id = gtk_timeout_add (td->interval, camel_timeout, td); + td->timeout_id = gtk_timeout_add(td->interval, camel_timeout, td); } } MAIL_SESSION_UNLOCK(session, lock); - - camel_object_unref (ms); + + camel_object_unref((CamelObject *)ms); } static guint register_timeout (CamelSession *session, guint32 interval, CamelTimeoutCallback cb, gpointer camel_data) { struct _timeout_data *td; - MailSession *ms = (MailSession *) session; + MailSession *ms = (MailSession *)session; guint ret; - + MAIL_SESSION_LOCK(session, lock); - + ret = ms->timeout_id; - ms->timeout_id++; - + ms->timeout_id ++; + /* just debugging, the timeout code now ignores excessive events anyway */ if (interval < 100) - g_warning ("Timeout requested %d is small, may cause performance problems", interval); - - td = g_malloc (sizeof (*td)); + g_warning("Timeout requested %d is small, may cause performance problems", interval); + + td = g_malloc(sizeof(*td)); td->cb = cb; td->camel_data = camel_data; td->interval = interval; @@ -698,35 +754,34 @@ register_timeout (CamelSession *session, guint32 interval, CamelTimeoutCallback td->session = session; td->removed = FALSE; td->busy = FALSE; - e_dlist_addhead (&ms->timeouts, (EDListNode *) td); - + e_dlist_addhead(&ms->timeouts, (EDListNode *)td); + MAIL_SESSION_UNLOCK(session, lock); - - camel_object_ref (ms); - mail_async_event_emit (ms->async, MAIL_ASYNC_GUI, (MailAsyncFunc) main_register_timeout, - (CamelObject *) session, (void *) ret, NULL); + + camel_object_ref((CamelObject *)ms); + mail_async_event_emit(ms->async, MAIL_ASYNC_GUI, (MailAsyncFunc)main_register_timeout, (CamelObject *)session, (void *)ret, NULL); return ret; } static void -main_remove_timeout (CamelSession *session, void *event_data, void *data) +main_remove_timeout(CamelSession *session, void *event_data, void *data) { - MailSession *ms = (MailSession *) session; - unsigned int handle = (unsigned int) event_data; + MailSession *ms = (MailSession *)session; + unsigned int handle = (unsigned int)event_data; struct _timeout_data *td; - + MAIL_SESSION_LOCK(session, lock); - td = find_timeout (&ms->timeouts, handle); + td = find_timeout(&ms->timeouts, handle); if (td) { - e_dlist_remove ((EDListNode *) td); + e_dlist_remove((EDListNode *)td); if (td->timeout_id) - gtk_timeout_remove (td->timeout_id); - g_free (td); + gtk_timeout_remove(td->timeout_id); + g_free(td); } MAIL_SESSION_UNLOCK(session, lock); - - camel_object_unref (ms); + + camel_object_unref((CamelObject *)ms); } static gboolean @@ -735,21 +790,21 @@ remove_timeout (CamelSession *session, guint handle) MailSession *ms = (MailSession *)session; struct _timeout_data *td; int remove = FALSE; - + MAIL_SESSION_LOCK(session, lock); - td = find_timeout (&ms->timeouts, handle); + td = find_timeout(&ms->timeouts, handle); if (td && !td->removed) { td->removed = TRUE; remove = TRUE; } MAIL_SESSION_UNLOCK(session, lock); - + if (remove) { - camel_object_ref (ms); - mail_async_event_emit (ms->async, MAIL_ASYNC_GUI, (MailAsyncFunc) main_remove_timeout, - (CamelObject *) session, (void *) handle, NULL); + camel_object_ref((CamelObject *)ms); + mail_async_event_emit(ms->async, MAIL_ASYNC_GUI, + (MailAsyncFunc)main_remove_timeout, (CamelObject *)session, (void *)handle, NULL); } else - g_warning ("Removing a timeout i dont know about (or twice): %d", handle); + g_warning("Removing a timeout i dont know about (or twice): %d", handle); return TRUE; } @@ -779,37 +834,30 @@ static CamelFilterDriver * main_get_filter_driver (CamelSession *session, const char *type, CamelException *ex) { CamelFilterDriver *driver; + RuleContext *fc; GString *fsearch, *faction; FilterRule *rule = NULL; char *user, *system; - GConfClient *gconf; - RuleContext *fc; - long notify; - - gconf = gconf_client_get_default (); user = g_strdup_printf ("%s/filters.xml", evolution_dir); - system = EVOLUTION_PRIVDATADIR "/filtertypes.xml"; - fc = (RuleContext *) filter_context_new (); + system = EVOLUTION_DATADIR "/evolution/filtertypes.xml"; + fc = (RuleContext *)filter_context_new (); rule_context_load (fc, system, user); g_free (user); driver = camel_filter_driver_new (session); camel_filter_driver_set_folder_func (driver, get_folder, NULL); - if (gconf_client_get_bool (gconf, "/apps/evolution/mail/filters/log", NULL)) { - MailSession *ms = (MailSession *) session; + if (mail_config_get_filter_log ()) { + MailSession *ms = (MailSession *)session; if (ms->filter_logfile == NULL) { - char *filename; + const char *filename; - filename = gconf_client_get_string (gconf, "/apps/evolution/mail/filters/logfile", NULL); - if (filename) { + filename = mail_config_get_filter_log_path (); + if (filename) ms->filter_logfile = fopen (filename, "a+"); - g_free (filename); - } } - if (ms->filter_logfile) camel_filter_driver_set_logfile (driver, ms->filter_logfile); } @@ -826,26 +874,19 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException /* FIXME: we need a way to distinguish between filtering new mail and re-filtering a folder because both use the "incoming" filter type */ - notify = gconf_client_get_int (gconf, "/apps/evolution/mail/notify/type", NULL); - if (notify != MAIL_CONFIG_NOTIFY_NOT && !strcmp (type, "incoming")) { - char *filename; - + if (mail_config_get_new_mail_notify () && !strcmp (type, "incoming")) { g_string_truncate (faction, 0); g_string_append (faction, "(only-once \"new-mail-notification\" "); - switch (notify) { - case MAIL_CONFIG_NOTIFY_PLAY_SOUND: - filename = gconf_client_get_string (gconf, "/apps/evolution/mail/notify/sound", NULL); - if (filename) { - g_string_append_printf (faction, "\"(play-sound \\\"%s\\\")\"", filename); - g_free (filename); - break; - } - /* fall through */ + switch (mail_config_get_new_mail_notify ()) { case MAIL_CONFIG_NOTIFY_BEEP: g_string_append (faction, "\"(beep)\""); break; + case MAIL_CONFIG_NOTIFY_PLAY_SOUND: + g_string_sprintfa (faction, "\"(play-sound \\\"%s\\\")\"", + mail_config_get_new_mail_notify_sound_file ()); + break; default: break; } @@ -861,15 +902,16 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException g_string_truncate (faction, 0); filter_rule_build_code (rule, fsearch); - filter_filter_build_action ((FilterFilter *) rule, faction); + filter_filter_build_action ((FilterFilter *)rule, faction); - camel_filter_driver_add_rule (driver, rule->name, fsearch->str, faction->str); + camel_filter_driver_add_rule (driver, rule->name, + fsearch->str, faction->str); } g_string_free (fsearch, TRUE); g_string_free (faction, TRUE); - g_object_unref (fc); + gtk_object_unref (GTK_OBJECT (fc)); return driver; } @@ -877,8 +919,8 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException static CamelFilterDriver * get_filter_driver (CamelSession *session, const char *type, CamelException *ex) { - return (CamelFilterDriver *) mail_call_main (MAIL_CALL_p_ppp, (MailMainFunc) main_get_filter_driver, - session, type, ex); + return (CamelFilterDriver *)mail_call_main(MAIL_CALL_p_ppp, (MailMainFunc)main_get_filter_driver, + session, type, ex); } char * @@ -887,15 +929,15 @@ mail_session_get_password (const char *url_string) CamelURL *url; char *simple_url; char *passwd; - + url = camel_url_new (url_string, NULL); simple_url = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS); camel_url_free (url); - - passwd = e_passwords_get_password ("Mail", simple_url); - + + passwd = e_passwords_get_password (simple_url); + g_free (simple_url); - + return passwd; } @@ -905,13 +947,13 @@ mail_session_add_password (const char *url_string, { CamelURL *url; char *simple_url; - + url = camel_url_new (url_string, NULL); simple_url = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS); camel_url_free (url); - + e_passwords_add_password (simple_url, passwd); - + g_free (simple_url); } @@ -924,16 +966,16 @@ mail_session_remember_password (const char *url_string) url = camel_url_new (url_string, NULL); simple_url = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS); camel_url_free (url); - - e_passwords_remember_password ("Mail", simple_url); - + + e_passwords_remember_password (simple_url); + g_free (simple_url); } void mail_session_forget_password (const char *key) { - e_passwords_forget_password ("Mail", key); + e_passwords_forget_password (key); } void @@ -948,10 +990,10 @@ mail_session_init (void) camel_dir = g_strdup_printf ("%s/mail", evolution_dir); camel_session_construct (session, camel_dir); - + /* The shell will tell us to go online. */ - camel_session_set_online ((CamelSession *) session, FALSE); - + camel_session_set_online ((CamelSession *)session, FALSE); + g_free (camel_dir); } @@ -969,31 +1011,31 @@ mail_session_set_interactive (gboolean interactive) if (!interactive) { struct _pass_msg *pm; struct _user_message_msg *um; - - d(printf ("Gone non-interactive, checking for outstanding interactive tasks\n")); - + + d(printf("Gone non-interactive, checking for outstanding interactive tasks\n")); + /* clear out pending password requests */ - while ((pm = (struct _pass_msg *) e_dlist_remhead (&password_list))) { - d(printf ("Flushing password request : %s\n", pm->prompt)); - e_msgport_reply ((EMsg *) pm); + while ((pm = (struct _pass_msg *)e_dlist_remhead(&password_list))) { + d(printf("Flushing password request : %s\n", pm->prompt)); + e_msgport_reply((EMsg *)pm); } - + /* destroy the current */ - if (password_dialog) { - d(printf ("Destroying password dialogue\n")); - gtk_widget_destroy ((GtkWidget *) password_dialog); + if (password_dialogue) { + d(printf("Destroying password dialogue\n")); + gtk_object_destroy((GtkObject *)password_dialogue); } - + /* same for pending user messages */ - while ((um = (struct _user_message_msg *) e_dlist_remhead (&message_list))) { - d(printf ("Flusing message request: %s\n", um->prompt)); - e_msgport_reply((EMsg *) um); + while ((um = (struct _user_message_msg *)e_dlist_remhead(&message_list))) { + d(printf("Flusing message request: %s\n", um->prompt)); + e_msgport_reply((EMsg *)um); } - + /* and the current */ - if (message_dialog) { + if (message_dialogue) { d(printf("Destroying message dialogue\n")); - gtk_widget_destroy ((GtkWidget *) message_dialog); + gtk_object_destroy((GtkObject *)message_dialogue); } } } diff --git a/mail/mail.h b/mail/mail.h index 1c40b52107..046c873e4d 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -29,12 +29,45 @@ #include "mail-callbacks.h" #include "mail-config.h" #include "mail-config-druid.h" -#include "mail-display-stream.h" +/*#include "folder-browser.h"*/ #include "mail-session.h" #include "mail-types.h" extern char *evolution_dir; +/* mail-format */ +GByteArray *mail_format_get_data_wrapper_text (CamelDataWrapper *data, + MailDisplay *mail_display); + +void mail_format_mime_message (CamelMimeMessage *mime_message, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +void mail_format_raw_message (CamelMimeMessage *mime_message, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +gboolean mail_content_loaded (CamelDataWrapper *wrapper, + MailDisplay *display, + gboolean redisplay, + const gchar *url, + GtkHTML *html, + GtkHTMLStream *handle); + +typedef gboolean (*MailMimeHandlerFn) (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +typedef struct { + OAF_ServerInfo *component; + GList *applications; + MailMimeHandlerFn builtin; + guint generic : 1; + guint is_bonobo : 1; +} MailMimeHandler; +MailMimeHandler *mail_lookup_handler (const char *mime_type); + +gboolean mail_part_is_inline (CamelMimePart *part); +gboolean mail_part_is_displayed_inline (CamelMimePart *part, MailDisplay *md); +void mail_part_toggle_displayed (CamelMimePart *part, MailDisplay *md); + +char *mail_get_message_body (CamelDataWrapper *data, gboolean want_plain, gboolean cite); + /* mail-identify */ char *mail_identify_mime_part (CamelMimePart *part, MailDisplay *md); @@ -42,7 +75,7 @@ char *mail_identify_mime_part (CamelMimePart *part, MailDisplay *md); void mail_add_storage (CamelStore *store, const char *name, const char *uri); void mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const char *name); /*takes a GSList of MailConfigServices */ -void mail_load_storages (GNOME_Evolution_Shell shell, EAccountList *sources); +void mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources); void mail_hash_storage (CamelService *store, EvolutionStorage *storage); EvolutionStorage *mail_lookup_storage (CamelStore *store); diff --git a/mail/subscribe-dialog.glade b/mail/subscribe-dialog.glade index 0cbeb7ac59..f86596530b 100644 --- a/mail/subscribe-dialog.glade +++ b/mail/subscribe-dialog.glade @@ -1,256 +1,335 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> +<?xml version="1.0"?> +<GTK-Interface> -<glade-interface> -<requires lib="gnome"/> -<requires lib="bonobo"/> +<project> + <name>Evolution</name> + <program_name>evolution</program_name> + <directory></directory> + <source_directory>src</source_directory> + <pixmaps_directory>pixmaps</pixmaps_directory> + <language>C</language> + <gnome_support>True</gnome_support> + <gettext_support>True</gettext_support> + <translatable_strings_file>subscribe-dialog.glade.h</translatable_strings_file> +</project> -<widget class="GnomeApp" id="app"> - <property name="visible">True</property> - <property name="title" translatable="yes">Manage Subscriptions</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="enable_layout_config">True</property> +<widget> + <class>GnomeApp</class> + <name>app</name> + <title>Manage Subscriptions</title> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_NONE</position> + <modal>False</modal> + <allow_shrink>False</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>False</auto_shrink> + <enable_layout_config>True</enable_layout_config> - <child internal-child="dock"> - <widget class="BonoboDock" id="dock2"> - <property name="border_width">3</property> - <property name="visible">True</property> - <property name="allow_floating">True</property> + <widget> + <class>GnomeDock</class> + <child_name>GnomeApp:dock</child_name> + <name>dock2</name> + <border_width>3</border_width> + <allow_floating>True</allow_floating> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> - <child> - <widget class="BonoboDockItem" id="dockitem2"> - <property name="border_width">1</property> - <property name="visible">True</property> - <property name="shadow_type">GTK_SHADOW_OUT</property> + <widget> + <class>GnomeDockItem</class> + <name>dockitem2</name> + <border_width>1</border_width> + <placement>GNOME_DOCK_TOP</placement> + <band>0</band> + <position>0</position> + <offset>0</offset> + <locked>False</locked> + <exclusive>True</exclusive> + <never_floating>False</never_floating> + <never_vertical>False</never_vertical> + <never_horizontal>False</never_horizontal> + <shadow_type>GTK_SHADOW_OUT</shadow_type> + <widget> + <class>GtkToolbar</class> + <name>toolbar1</name> + <border_width>1</border_width> + <orientation>GTK_ORIENTATION_HORIZONTAL</orientation> + <type>GTK_TOOLBAR_BOTH</type> + <space_size>16</space_size> + <space_style>GTK_TOOLBAR_SPACE_LINE</space_style> + <relief>GTK_RELIEF_NONE</relief> + <tooltips>True</tooltips> + + <widget> + <class>GtkButton</class> + <child_name>Toolbar:button</child_name> + <name>refresh_button</name> + <tooltip>Refresh folder listing</tooltip> + <label>Refresh List</label> + <stock_pixmap>GNOME_STOCK_PIXMAP_REFRESH</stock_pixmap> + </widget> + + <widget> + <class>GtkButton</class> + <child_name>Toolbar:button</child_name> + <name>close_button</name> + <label>Close</label> + <stock_pixmap>GNOME_STOCK_PIXMAP_CLOSE</stock_pixmap> <child> - <widget class="GtkToolbar" id="toolbar1"> - <property name="border_width">1</property> - <property name="visible">True</property> - <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> - <property name="toolbar_style">GTK_TOOLBAR_BOTH</property> - <property name="tooltips">True</property> + <new_group>True</new_group> + </child> + </widget> + </widget> + </widget> - <child> - <widget class="button" id="refresh_button"> - <property name="visible">True</property> - <property name="label" translatable="yes">Refresh List</property> - <property name="use_underline">True</property> - <property name="stock_pixmap">gtk-refresh</property> - </widget> - </child> + <widget> + <class>GtkVBox</class> + <child_name>GnomeDock:contents</child_name> + <name>vbox6</name> + <border_width>3</border_width> + <homogeneous>False</homogeneous> + <spacing>3</spacing> - <child> - <widget class="button" id="close_button"> - <property name="visible">True</property> - <property name="label" translatable="yes">Close</property> - <property name="use_underline">True</property> - <property name="stock_pixmap">gtk-close</property> - </widget> - <packing> - <property name="new_group">True</property> - </packing> - </child> - </widget> + <widget> + <class>GtkHBox</class> + <name>hbox7</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkLabel</class> + <name>label5</name> + <label>S_elect server: </label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <default_focus_target>store_menu</default_focus_target> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> </child> </widget> - <packing> - <property name="placement">BONOBO_DOCK_TOP</property> - <property name="band">0</property> - <property name="position">0</property> - <property name="offset">0</property> - <property name="behavior">BONOBO_DOCK_ITEM_BEH_EXCLUSIVE</property> - </packing> - </child> - <child> - <widget class="GtkVBox" id="vbox6"> - <property name="border_width">3</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">3</property> + <widget> + <class>GtkOptionMenu</class> + <name>store_menu</name> + <can_focus>True</can_focus> + <items></items> + <initial_choice>0</initial_choice> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> + </widget> + <widget> + <class>GtkHBox</class> + <name>tree_box</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>Placeholder</class> + </widget> + + <widget> + <class>GtkVBox</class> + <name>vbox7</name> + <border_width>3</border_width> + <homogeneous>False</homogeneous> + <spacing>3</spacing> <child> - <widget class="GtkHBox" id="hbox7"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + <pack>GTK_PACK_END</pack> + </child> - <child> - <widget class="GtkLabel" id="label5"> - <property name="visible">True</property> - <property name="label" translatable="yes">S_elect server: </property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">store_menu</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <widget> + <class>GtkLabel</class> + <name>label6</name> + <label> +</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> - <child> - <widget class="GtkOptionMenu" id="store_menu"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> + <widget> + <class>GtkVButtonBox</class> + <name>vbuttonbox6</name> + <layout_style>GTK_BUTTONBOX_SPREAD</layout_style> + <spacing>0</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> - <child internal-child="menu"> - <widget class="GtkMenu" id="convertwidget1"> - <property name="visible">True</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <widget> + <class>GtkButton</class> + <name>subscribe_button</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>_Subscribe</label> + <relief>GTK_RELIEF_NORMAL</relief> </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - <child> - <widget class="GtkHBox" id="tree_box"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <widget> + <class>GtkButton</class> + <name>unsubscribe_button</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <label>_Unsubscribe</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> + </widget> - <child> - <placeholder/> - </child> + <widget> + <class>GtkVButtonBox</class> + <name>vbuttonbox7</name> + <layout_style>GTK_BUTTONBOX_START</layout_style> + <spacing>10</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> + </widget> + </widget> - <child> - <widget class="GtkVBox" id="vbox7"> - <property name="border_width">3</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">3</property> + <widget> + <class>GtkFrame</class> + <name>frame3</name> + <label>Display Options</label> + <label_xalign>0</label_xalign> + <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + </child> - <child> - <widget class="GtkLabel" id="label6"> - <property name="visible">True</property> - <property name="label" translatable="yes"> -</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <widget> + <class>GtkHBox</class> + <name>hbox9</name> + <border_width>3</border_width> + <homogeneous>False</homogeneous> + <spacing>3</spacing> - <child> - <widget class="GtkVButtonBox" id="vbuttonbox6"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_SPREAD</property> - <property name="spacing">0</property> + <widget> + <class>GtkRadioButton</class> + <name>all_radio</name> + <can_focus>True</can_focus> + <label>All folders</label> + <active>False</active> + <draw_indicator>True</draw_indicator> + <group>view_type</group> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> - <child> - <widget class="GtkButton" id="subscribe_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Subscribe</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - </child> + <widget> + <class>GtkRadioButton</class> + <name>filter_radio</name> + <can_focus>True</can_focus> + <label>Folders whose names begin with:</label> + <active>False</active> + <draw_indicator>True</draw_indicator> + <group>view_type</group> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> - <child> - <widget class="GtkButton" id="unsubscribe_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Unsubscribe</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <widget> + <class>GtkEntry</class> + <name>search_entry</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + </widget> - <child> - <widget class="GtkVButtonBox" id="vbuttonbox7"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_START</property> - <property name="spacing">10</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <widget> + <class>GtkHButtonBox</class> + <name>hbuttonbox3</name> + <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style> + <spacing>30</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>False</fill> + </child> + </widget> </widget> - </child> + </widget> </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + </widget> - <child internal-child="appbar"> - <widget class="GnomeAppBar" id="appbar2"> - <property name="visible">True</property> - <property name="has_progress">True</property> - <property name="has_status">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> + <widget> + <class>GnomeAppBar</class> + <child_name>GnomeApp:appbar</child_name> + <name>appbar2</name> + <has_progress>True</has_progress> + <has_status>True</has_status> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + </widget> </widget> -</glade-interface> +</GTK-Interface> |