diff options
Diffstat (limited to 'e-util')
82 files changed, 0 insertions, 24039 deletions
diff --git a/e-util/.cvsignore b/e-util/.cvsignore deleted file mode 100644 index fac587630c..0000000000 --- a/e-util/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -*.lo -*.la -e-error-tool -e-util-marshal.c -e-util-marshal.h -test-source-list
\ No newline at end of file diff --git a/e-util/ChangeLog b/e-util/ChangeLog deleted file mode 100644 index d5fc3efb4a..0000000000 --- a/e-util/ChangeLog +++ /dev/null @@ -1,1276 +0,0 @@ -2005-05-25 Not Zed <NotZed@Ximian.com> - - * e-plugin-mono.[ch]: Removed, these are now implemented as a - plugin. - - * e-plugin.c (ep_load_plugin): separate out plugin xml loading - code from the loading loop. If a plugin type doesn't exist, then - save it in a list for later checking. - (ep_load): call above to do the work. - (e_plugin_register_type): check the pending doc list, if any - plugins now have a type, load them. - (e_plugin_type_hook_get_type): a plugin hook for registering new - plugin types ('loaders') at runtime. - -2005-05-19 Not Zed <NotZed@Ximian.com> - - * e-import.[ch]: Initial, and un-finished work on importer plugin - hooks. - -2005-05-16 Not Zed <NotZed@Ximian.com> - - * Makefile.am: added e-error.[ch], removed e-error-tool, and added - e-system.error.xml - -2005-05-13 Not Zed <NotZed@Ximian.com> - - * e-popup.c (emph_popup_factory): if we have a factory method - supplied, call that as well. More flexible popup building. - (emph_construct_menu): load factory def. - -2005-05-03 Not Zed <NotZed@Ximian.com> - - * e-profile-event.c (e_profile_event_emit): undefine - e_profile_event_emit if we are compiled without profiling. The - 'abi' is not, nor was ever changed. - - * e-profile-event.h: revert previous patch, the assumptions were - incorrect & the code misunderstood. - -2005-05-02 Rodney Dawes <dobey@novell.com> - - * e-profile-event.h (e_profile_event_emit): This method is a no-op if - we are building without ENABLE_PROFILE defined, so we don't need to - define a macro to no-op it, and change ABI at compile time - -2005-04-28 Not Zed <NotZed@Ximian.com> - - * e-profile-event.[ch]: A profiling plugin hook. - -2005-04-27 Mengjie Yu <meng-jie.yu@sun.com> - - * e-config.c: (e_config_create_window): - We should set the title of the window. - - Fixes #300477 - -2005-03-14 Not Zed <NotZed@Ximian.com> - - ** See bug #73550 (related for config pages) - - * e-config.c (ech_config_widget_factory): if we are disabled, then - noop. - (ech_config_factory, ech_commit, ech_abort): same. - -2005-03-01 Not Zed <NotZed@Ximian.com> - - * *.c: Remove/disable debug. - -2005-02-23 Hans Petter Jansson <hpj@novell.com> - - * Makefile.am (eutilinclude_HEADERS) - (libeutil_la_SOURCES): Remove e-passwords from here, it now - lives in libedataserverui. - - * e-passwords.[ch]: Removed. - -2005-02-10 Not Zed <NotZed@Ximian.com> - - ** See bug #61363 & mail/ChangeLog - - * e-config.c (ec_rebuild): work properly if the page factory - returns NULL, so the code can selectivly turn off pages. - (ec_druid_next, ec_druid_prev): skip non-created pages. - - * e-config.c (ec_rebuild): re-order notebook child properly. - Connect to destroy events so we update the widget-node widget - pointer properly for linked ui reconfigures. - -2005-02-17 Not Zed <NotZed@Ximian.com> - - * e-popup.c (ep_prune_tree, ep_build_tree, e_popup_create_menu): - completely rewritten. Simpler and more robust. - -2005-02-16 Not Zed <NotZed@Ximian.com> - - * e-popup.c (e_popup_create_menu): do the visibility mask test - before sorting. don't perform it on bar's or submenu's anymore, - calculate when not to show/create them. - -2005-02-14 Rodney Dawes <dobey@novell.com> - - * e-menu.c (emph_construct): If the plug-in is not enabled, do nothing - -2005-02-07 Not Zed <NotZed@Ximian.com> - - * e-popup.c (emph_construct_menu): - * e-menu.c (emph_construct_menu): - * e-config.c (emph_construct_menu): Don't let the 'id' field, - which identifies the target menu/whatever, to be NULL, otherwise - it gets added to all. - -2005-02-04 Rodney Dawes <dobey@novell.com> - - * e-passwords.c (ep_ask_password): Set the border widths for the - dialog containers to be HIG compliant - Fix the padding/spacing on the internal vbox to be HIG compliant - -2005-01-27 Mengjie Yu <meng-jie.yu@sun.com> - - * e-request.c: (e_request_string):add a11y description for the - entry. - -2005-01-26 Jeffrey Stedfast <fejj@novell.com> - - * e-config.c (ech_check): If the plugin isn't enabled, return TRUE - so that the suer doesn't get locked in one of the account druid - pages. - -2005-01-21 JP Rosevear <jpr@novell.com> - - Fixes #46404 - - * Makefile.am: build new files - - * e-print.[hc]: print related config and dialog routines - -2005-01-17 Rodrigo Moya <rodrigo@novell.com> - - * e-url.[ch]: - * Makefile.am: removed e-url.[ch], which are now in libedataserver. - -2005-01-08 Not Zed <NotZed@Ximian.com> - - * e-url.c (e_url_shroud): dont' use '%.*s' for truncating string - output. - -2005-01-09 JP Rosevear <jpr@novell.com> - - * e-url.c (e_uri_new): fix parsing of query string - -2005-01-07 Rodrigo Moya <rodrigo@novell.com> - - * e-categories-config.c (e_categories_config_open_dialog_for_entry): - set the dialog's parent. - -2005-01-07 Rodrigo Moya <rodrigo@novell.com> - - * e-categories-config.c (e_categories_config_open_dialog_for_entry): - use the new ECategoriesDialog in libedataserverui. - -2005-01-06 Rodney Dawes <dobey@novell.com> - - * e-config.c (e_config_create_window): Add the GTK_DIALOG_NOSEPARATOR - flag, and set appropriate border widths around the main dialog vbox, - and action area, to be more HIG compliant - -2005-01-06 JP Rosevear <jpr@novell.com> - - * e-error-tool.c (main): use the base name only, so if a full path - is passed to us we still write out to the current directory, for - when builddir != srcdir - -2005-01-04 Rodrigo Moya <rodrigo@novell.com> - - * e-categories-config.[ch]: removed most of the API. The rest will - be removed as the GAL dependencies are sorted out. - -2004-12-22 Not Zed <NotZed@Ximian.com> - - * e-plugin.c: include config.h. - -2004-12-17 Not Zed <NotZed@Ximian.com> - - * e-popup.c (e_popup_add_items): add a translation domain to api. - (e_popup_create_menu): translate the label using the supplied - domain. - (emph_popup_factory): pass domain to popup_add_items. - - * e-plugin.c (ep_construct): if we have a localedir set, then - bindtextdomain so gettext can find it. - -2004-12-21 JP Rosevear <jpr@novell.com> - - Fixes #30992 - - * e-config.c (e_config_create_window): use cancel rather than - close button - -2004-12-21 JP Rosevear <jpr@novell.com> - - * e-account.c: convert to G_DEFINE_TYPE - - * e-account-list.c: ditto - -2004-12-08 Not Zed <NotZed@Ximian.com> - - * e-plugin.c (e_plugin_load_plugins): kill warning if we can't - open the path. - -2004-12-06 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_rebuild): set the table spacings to 6 for - generated tables. - -2004-11-22 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_rebuild): if the table existed before and we have - no factory, destroy it always. - -2004-12-03 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_rebuild): revert the patch from chenthill, this - wont work yet. - -2004-11-29 Mengjie Yu <meng-jie.yu@sun.com> - - * e-config.c: (ec_rebuild):add mnemonic for label. - * e-passwords.c: (ep_ask_password):add description for password dialog. - -2004-11-26 JP Rosevear <jpr@novell.com> - - * e-gui-utils.c (e_create_image_widget): get the image directly - from the icon factory - - * e-config.c: insert debug defines so we can - turn spew on and off - - * e-event.c: insert debug defines so we can turn spew on and off - - * e-menu.c: insert debug defines so we can turn spew on and off - - * e-plugin.c: insert debug defines and set to off for now - - * e-popup.c: insert debug defines so we can turn spew on and off - (e_popup_create_menu): get the image directly from the icon - factory - -2004-11-26 JP Rosevear <jpr@novell.com> - - * e-icon-factory.h: add proto - - * e-icon-factory.c (e_icon_factory_init): cast to kill warning - (e_icon_factory_get_image): new function to return a GtkImage - widget give an icon name and size - -2004-11-25 Chenthill Palanisamy <pchenthill@novell.com> - - * e-config.c (ec_rebuild): Set the row and column spacings as - tweleve while creating the table to make it HIG compliant. - -2004-11-19 Not Zed <NotZed@Ximian.com> - - * e-plugin.c (ep_load): if the plugin fails to load just disable - it, don't unref it (it may be referenced elsewhere). - -2004-11-18 Not Zed <NotZed@Ximian.com> - - * e-plugin.c (epl_loadmodule): split out module loadng code. - (epl_construct): if we're enabled, and load-on-startup is set, - load the module right away. Not to be abused! - -2004-11-16 Not Zed <NotZed@Ximian.com> - - * e-host-utils.[ch]: removed, code moved into - camel-net-utils.[ch]. - -2004-11-15 Not Zed <NotZed@Ximian.com> - - * e-trie.[ch], e-memory.[ch], e-sexp.[ch], e-msgport.[ch]: Moved - to eds/libedataserver. - - * e-path.[ch]: removed & deleted. - -2004-11-03 Not Zed <NotZed@Ximian.com> - - * e-plugin.c (e_plugin_list_plugins): added helper api to list all - plugins. - (ep_construct): load authors into new list for them. - (e_plugin_register_type): setup disabled list. - (ep_construct): dont load the hooks if we're not enabled. - (e_plugin_enable): make this a virutal method. - (e_plugin_invoke): if we're disabled, noop. - -2004-11-01 Not Zed <NotZed@Ximian.com> - - ** See bug #68787 - - * e-account.c (xml_set_content): check the new val isn't null - before dereferencing it. - * e-account.c (xml_set_prop): same here. - -2004-10-28 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_rebuild): revert the last change. - -2004-10-28 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_rebuild): set the default row/col spacings of the - table. - -2004-10-20 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_rebuild): check for empty trailing sections/pages - after we exit the main loop. - - * e-plugin.c (e_plugin_get_type): make ~/.eplugins the default - eplugin location, not ~/.eplug. - -2004-10-18 Not Zed <NotZed@Ximian.com> - - * e-config.h: fix some forward decls. - -2004-10-19 JP Rosevear <jpr@novell.com> - - * e-config.c, e-event.c, e-menu.c, e-plugin.c, e-plugin.h, - e-popup.c: convert to org.gnome hook names - -2004-10-07 Jeffrey Stedfast <fejj@novell.com> - - * e-passwords.c (ep_ask_password): Use "%s" as the formatter - argument and msg->prompt as a printf-style argument rather than - using it as the format string. Fixes bug #67622. - -2004-10-12 Not Zed <NotZed@Ximian.com> - - * e-config.c (ech_check, ech_config_factory, emph_construct_menu): - setup a "check" handler, page-check/validation callback. - - * e-popup.c (e_popup_new): new method to create a targetless popup - menu. - -2004-10-08 JP Rosevear <jpr@novell.com> - - * e-plugin.c (ep_load): fix typo - -2004-10-08 Not Zed <NotZed@Ximian.com> - - * e-plugin.c (ep_load): handle wrong root element properly. From - David Trowbridge <David.Trowbridge@Colorado.edu> - -2004-10-07 Not Zed <NotZed@Ximian.com> - - * e-plugin.h: Fix the function pointer types! - - * e-plugin.c (epl_invoke): noop if we're disabled, and do some - lifecycle stuff now, call e_plugin_lib_enable on the module if it - exists. - -2004-10-07 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_rebuild): show the toplevel notebook if we - had to create one, always. - - * e-menu.c (e_menu_add_items): initialise node->menu properly. - - * e-plugin.c (ep_load): read/initialise a unique id for all - plugins and track them in a hashtable. - (ep_construct): refactor so we have more control over what - happens. if the hook handling class isn't registered yet, just - note it and keep going. - (e_plugin_hook_new): remove this, its handled internally by above. - -2004-10-06 Not Zed <NotZed@Ximian.com> - - * e-popup.c (e_popup_create_menu): only take one mask parameter, - and implement EPopupItem->enable to do what the other mask did. - (ep_activate): if this is a toggle or radiobutton, set the active - state on the item->type. - (e_popup_create_menu): if a menu image starts with gtk-, then - assume it is a gtk stock image instead. - -2004-08-27 Not Zed <NotZed@Ximian.com> - - * e-passwords.c (e_passwords_ask_password): return cancelled if - we're in an offline state. - -2004-08-26 Rodrigo Moya <rodrigo@novell.com> - - * eggtrayicon.[ch]: updated from libegg. - -2004-08-20 Frederic Crozat <fcrozat@mandrakesoft.com> - - * e-dialog-utils.c: (e_notice): - * e-passwords.c: (ep_ask_password): - Don't call gtk_dialog_set_has_separator on Gtk Message Dialog - with GTK+ >= 2.4.0. - -2004-08-13 Rodrigo Moya <rodrigo@novell.com> - - * e-categories-config.c: include gtkdialog.h rather than gnome-dialog.h. - -2004-08-12 Carlos Garnacho Parro <carlosg@gnome.org> - - * e-dialog-utils.c: Optionally use GtkFileChooser if compiled - against Gtk+ >= 2.4.0 - -2004-08-10 Not Zed <NotZed@Ximian.com> - - ** See bug #61840, and others. - - * e-passwords.c: Lots of changes. The api is now fully - multi-thread safe, all calls are serialised internally, even - recursive main-loop calls. Small api changes to the - ask_password call to add some new features required by the mailer - and to clean up some of the names. - (e_passwords_cancel): new procedure to cancel any outstanding - password requests, for when we need to go uninteractive. - -2004-08-09 Rodney Dawes <dobey@novell.com> - - * e-icon-factory.c (icon_foreach_remove): We must return TRUE here - so that things actually get removed from the list - -2004-08-07 ERDI Gergo <cactus@cactus.rulez.org> - - * e-account.h: Added new receipt_policy field to services - -2004-08-05 Rodrigo Moya <rodrigo@novell.com> - - * e-icon-factory.c (e_icon_factory_init): connect to "changed" - signal on the GnomeIconTheme object. - (icon_theme_changed_cb): g_hash_table_foreach_remove all items in the - hash table. - (icon_foreach_remove): callback for removing hash table items. - -2004-08-05 Rodrigo Moya <rodrigo@novell.com> - - Fixes #62030 - - * e-icon-factory.c (load_icon): get the icon_key as a new argument - and use that in the call to icon_new(). - (e_icon_factory_get_icon): pass icon_key to load_icon(). - (e_icon_factory_get_icon_list): ditto. - -2004-08-01 JP Rosevear <jpr@novell.com> - - * e-pilot-util.c (e_pilot_get_sync_source): find the source with - the pilot-sync property - (e_pilot_set_sync_source): give the source the pilot-sync property - and make sure its the only one - - * e-pilot-util.h: add prototypes - - * Makefile.am (eutilincludedir): don't build pilot settings - -2004-07-20 Not Zed <NotZed@Ximian.com> - - * e-dialog-utils.c: include config.h. See #61395. - -2004-07-12 Dan Winship <danw@novell.com> - - * e-mktemp.c (e_mktemp, e_mkdtemp): un-const the return values, - since they need to be freed - (d): turn off debugging - (expire_dir_rec): remove debug printfs - -2004-08-24 JP Rosevear <jpr@novell.com> - - * Makefile.am: define EVOLUTION_PLUGINDIR - - * e-plugin.c (e_plugin_get_type): add both a global and user - specifc eplug path as defaults - (e_plugin_load_plugins): just skip a directory if it can't be - opened - -2004-09-10 Not Zed <NotZed@Ximian.com> - - * e-popup.c (emph_construct_menu): duh, setup the hook pointer. - - * e-menu.c (e_menu_add_items): pass pixmaps and ui files to this - function now. - (e_menu_add_pixmap): removed, covered by above. - (e_menu_add_ui): removed, covered by above. - (emph_construct_menu): setup the hook pointer properly. - - * e-menu.h: moved the pixmap and ui file structures to be public, - removed hte hook equivalents. - -2004-09-09 Not Zed <NotZed@Ximian.com> - - * e-event.c (e_event_remove_items): implement a remove function. - (e_event_add_items): return a handle to pass to above. - (emph_event_handle): noop if we're disabled. - - * e-popup.c (emph_popup_factory): noop if the - plugin is disabled. - - * e-plugin.c (ep_init): setup an enabled bit for the plugin. - Preliminary work on being able to manage plugins. - (e_plugin_hook_enable): set hook enable state. - (e_plugin_enable): set plugin enable state. - -2004-09-07 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_rebuild): pass the right old widget to the page - factory. - (ec_widget_destroy): unref the config and the target when done. - (e_config_create_widget): force the notebook to page 0, workaround - some other bug i don't understand. - (e_config_create_window): set dialog hint on druid. - -2004-09-06 Not Zed <NotZed@Ximian.com> - - * e-account.c (e_account_import): emit a changed event on the dest. - (e_account_set_from_xml): emit a changed event if we were. - - * e-config.c (ec_rebuild): add a table item for some type-safety. - remove/alter the asserts so the code attemps to fail gracefully - rather than just fail. - -2004-09-01 Not Zed <NotZed@Ximian.com> - - * e-menu.[ch]: - * e-popup.[ch]: - * e-config.[ch]: - * e-event.[ch]: API syncrhonisation. Item callbacks now get the - root object, the item, and user-supplied data. Removed - now-redundant data and structures. Documentation updates. - -2004-08-30 Not Zed <NotZed@Ximian.com> - - * e-popup.c (emph_construct_item): just build a popupitem - directly, use user_data to pass the activate method name. - - * e-popup.h: removed epopuphookitem. - - * e-popup.c (emph_construct_item): dont set hook on hookitem - anymore, dont need to set user_data either. - - * e-popup.h: no longer pass parent pointer in EPopupHookItem, its - handled by add_items's data now. - - * e-popup.c (ep_finalise): re-arrange and call freefunc with the - new args. - (e_popup_create_menu): change the activate data so we can pass the - new api arguments. - (ep_activate): changes for api changes. - (emph_popup_factory): no longer takes target arg, taken from the - popup, pass the popuphook to the add_items call. - (emph_popup_activate): changed for new argument types. - - * e-popup.h: removed popup from epopupitem. - - * e-popup.c (e_popup_add_static_items): make private/rename to - ep_add_static_items. - (ep_add_static_items): dont pass target, it is set on the epopup - structure. - (e_popup_add_items): change the freefunc to be an EPopupItemsFunc - and add a user-data field, and track the parent epopup. - - * e-popup.h: change the activatefunc to pass the target and data - supplied to add_items. - -2004-08-25 Not Zed <NotZed@Ximian.com> - - * e-config.c (e_config_new): removed, this shouldn't be here for - an abstract class. - (*): Added doco. - -2004-08-24 Not Zed <NotZed@Ximian.com> - - * e-config.c (emph_construct_item): translate the label text. - - * e-popup.c (emph_construct_item): translate the label text. - - * e-plugin.c (e_plugin_xml_prop_domain): helper to get a property - translated. - (ep_construct): translate the name and description based on the - new domain tag. get the description as tag content not property. - (e_plugin_xml_content_domain): similar for xml node content. - -2004-08-24 Not Zed <NotZed@Ximian.com> - - * e-account.c (init): setup some defaults for the account. - - * e-config.c (e_config_create_widget): remove target arg actually. - (ec_rebuild): add druid page start/end pages. fixes. - (ec_druid_finish, ec_druid_cancel): handle finishing the druid. - -2004-08-23 Not Zed <NotZed@Ximian.com> - - * e-config.c (ec_druid_prepare, ec_druid_prev, ec_druid_next): - handle druid navigation. - -2004-08-20 Not Zed <NotZed@Ximian.com> - - * e-config.c (e_config_target_changed): add 'how' changed arg. - (e_config_create_widget): dont take target anymore, set that - separately. - (e_config_set_target): new virtual method to set the target. - (ec_set_target): implementation. - -2004-08-19 Not Zed <NotZed@Ximian.com> - - * e-account.c (e_account_set_bool): only emit changed if it did. - -2004-08-17 Not Zed <NotZed@Ximian.com> - - * e-config.c (e_config_page_check): fix a past-o. - (e_config_target_changed): treat the returned page for a druid - page factory as a gnomedruidpagestandard, so get_page works, etc. - -2004-08-16 Not Zed <NotZed@Ximian.com> - - * e-event.[ch]: Added event hook and dispatch router. - -2004-08-13 Not Zed <NotZed@Ximian.com> - - * e-plugin.c (e_plugin_load_plugins): don't take a path, load all - paths set. - (e_plugin_add_load_path): add a load path to the search path. - (e_plugin_get_type): setup the initial load path from environment - or defaults. - (e_plugin_xml_int): helper to get a prop in int format. - -2004-08-11 Not Zed <NotZed@Ximian.com> - - * e-config.c (e_config_target_changed): handle DRUID root type. - -2004-08-05 Not Zed <NotZed@Ximian.com> - - * e-account.c (class_init): add a changed signal. - (e_account_set_string, e_account_set_int, e_account_set_bool): - emit changed signal if it did. - - * e-config.c (e_config_add_page_check): add a page verification - function. It will be called for the given page, or all pages, to - verify the page contains valid data. - -2004-07-29 Not Zed <NotZed@Ximian.com> - - * e-account.c (e_account_get_string, e_account_get_int) - (e_account_get_bool, e_account_set_string, e_account_set_int) - (e_account_set_bool): implement. completely table driven. - -2004-07-02 Chris Toshok <toshok@ximian.com> - - [ fixes #60691 ] - - * e-iterator.h: rename the "delete" member to - "remove", to fix c++ build. - - * e-iterator.c (e_iterator_delete): same. - (e_iterator_class_init): same. - - * e-list-iterator.c (e_list_iterator_class_init): same. - (e_list_iterator_remove): same. - -2004-06-03 Dan Winship <danw@novell.com> - - * e-icon-factory.c (load_icon): If the icon_name is an abolute - path, just load it. - (e_icon_factory_get_icon): Update the docs to reflect that - -2004-06-01 Not Zed <NotZed@Ximian.com> - - * e-fsutils.c (e_fsutils_avail): use statvfs if available. Should - make it actually work, if not portable. This is for a bug but I - can't recall the number. - -2004-05-27 Rodney Dawes <dobey@novell.com> - - * Makefile.am (dist-hook): Require e-error-tool - -2004-05-19 Jeffrey Stedfast <fejj@novell.com> - - * e-icon-factory.c: Lots of re-working action. We no longer load a - pixbuf for each and every available size when requesting the icon - for the first time, instead we simply load the requested icon of - the requested size and cache only that. - (e_icon_factory_get_icon): Always return a broken image icon if we - fail to load the requested icon. - (e_icon_factory_get_icon_list): Only bother with adding icons of - the sizes that are suggested by ghe gtk documentation for - gtk_window_set_icon_list rather than the sizes of the standard - icons (since it isn't the same list of sizes). - (load_icon): Fall back to EVOLUTION_ICONSDIR/WWxHH/icon_name if - the icon-theme lookup fails. Also now takes a 'scale' argument - which, if non-zero, allows us to look for images of the same name - with a larger size in order to scale them back down to what we - need. - -2004-05-19 Jeffrey Stedfast <fejj@novell.com> - - * e-gui-utils.c (e_icon_for_mime_type): We always have - GnomeIconTheme nowadays, get rid of the old unused code. - (e_create_image_widget): Use E_ICON_SIZE_DIALOG - -2004-05-17 Jeffrey Stedfast <fejj@novell.com> - - * e-icon-factory.h (E_ICON_SIZE_LIST/STATUS): New #define aliases - for common icon usage cases where it may not be obvious that they - are the same size as menu icons. - -2004-05-12 Jeffrey Stedfast <fejj@novell.com> - - * e-icon-factory.c (e_icon_factory_shutdown): New function to - clean up the cached icons. - -2004-05-12 Not Zed <NotZed@Ximian.com> - - * e-error-tool.c: Tool to do i18n string extraction for error xml - files. - -2004-05-10 Not Zed <NotZed@Ximian.com> - - * e-fsutils.c (e_fsutils_usage): new file/function, get disk usage - of a path, in 1024 byte blocks. - (e_fsutils_avail): new file/function, get disk space available for - a given path, in 1024 byte blocks. - - * e-meta.[ch]: Removed. Poor idea badly executed, and no longer used. - - * e-path.h: add a fixme about deprecation. - -2004-04-30 Not Zed <NotZed@Ximian.com> - - * e-lang-utils.[ch]: Removed. This is covered by - gnome_i18n_get_language_list, which is more complete. - -2004-04-30 Dan Winship <danw@ximian.com> - - * e-icon-factory.c (load_icon): Make this work for non-stock icons - too. - -2004-04-22 Not Zed <NotZed@Ximian.com> - - * e-icon-factory.c (e_icon_factory_get_icon_list): make sure we - unlock if we fail to find an icon. - -2004-04-21 Jeffrey Stedfast <fejj@ximian.com> - - * e-icon-factory.c: Remove the warnings about using E_ICON_SIZE - enums. - -2004-04-20 Jeffrey Stedfast <fejj@ximian.com> - - * e-icon-factory.c (e_icon_factory_get_icon): Make - thread-safe. Fixes a crash I encountered this morning. - (e_icon_factory_get_icon_filename): Same. - (e_icon_factory_get_icon_list): Here too. - -2004-04-19 Jeffrey Stedfast <fejj@ximian.com> - - * e-icon-factory.h: Add an enum for icon sizes (temporarily has - absolute pixel sizes assigned to it until I commit - e-icon-factory.c changes - but only after all other code has been - updated to use the enums). - -2004-04-16 Michael Terry <mike@mterry.name> - - * Makefile.am: Add e-icon-factory.[ch] - * e-gui-utils.c: Use the icon theme via EIconFactory - * e-icon-factory.[ch]: Move EIconFactory to e-util, and add icon theme - support to the object so evolution uses them - -2004-04-13 Jeffrey Stedfast <fejj@ximian.com> - - * e-signature-list.c (gconf_signatures_changed): Don't add an - autogen signature if the new signature is the autogen signature. - -2004-04-13 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyname_r): Implemented a similar - workaround to the one I did for a gethostbyaddr_r() glibc bug - here. Glibc will apparently return success for addresses such as - "192..168.1.1" (note the double dot) and yet not have filled in - the hostent properly. - -2004-04-12 Jeffrey Stedfast <fejj@ximian.com> - - Really fixes bug #56623 - - * e-signature-list.c (gconf_signatures_changed): If we've had to - "fix" any signatures by adding a uid, set the resave state on the - list (only cared about if this is at initial load time). - (e_signature_list_construct): If we've set any uids in - signatures_changed(), then save the signature list back out. - -2004-04-09 Jeffrey Stedfast <fejj@ximian.com> - - * e-account.c (xml_set_identity): If we fail to set a sig_uid then - try to extract the old style signature id and assume the migration - code will fix us up (if not, nothing bad will happen anyway). - - * e-signature-list.c (gconf_signatures_changed): If the autogen - signature isn't in the list (or isn't the first in the list), add - it to the head of the list. - -2004-04-07 Jeffrey Stedfast <fejj@ximian.com> - - Probably fixes bug #56623 and others? - - * e-signature-list.c (gconf_signatures_changed): Fixed to not use - free'd iter memory. Also reverse the new_sigs list before adding - them to the signature list (so they are in the same order they - appeared in the gconf key). - -2004-04-05 Jeffrey Stedfast <fejj@ximian.com> - - * e-signature-list.c (gconf_signatures_changed): Fixed to not - ignore signatures without uids (e.g. signatures that were from - prior versions). - -2004-04-02 Jeffrey Stedfast <fejj@ximian.com> - - * e-signature.c (e_signature_to_xml): Always set a format prop so - that 1.4 and older 1.5 versions won't strcmp() on a NULL value. - -2004-04-01 Jeffrey Stedfast <fejj@ximian.com> - - * e-account.c: Reference signatures by their UID rather than by an - integer id. Also removed the need to have 2 signature settings (no - need for the "auto" signature boolean anymore). - -2004-03-31 Jeffrey Stedfast <fejj@ximian.com> - - * e-signature.[c,h]: New class similar to EAccount but for - signatures. - - * e-signature-list.[c,h]: New class similar to EAccountList only - for signatures. - -2004-03-31 Not Zed <NotZed@Ximian.com> - - * e-account-list.h: similar to below. - - * e-account.h: define struct _EAccount* so you can properly forward - declare it. - -2004-03-18 Not Zed <NotZed@Ximian.com> - - * e-account.c: Added options for transport_url and source_url - permissions. - -2004-03-18 Not Zed <NotZed@Ximian.com> - - * e-account.c (e_account_writable, e_account_writable_option): - added interface to find out if various fields or server options - are writable. to work around gconf limitations. - -2004-03-04 William Jon McCann <mccann@jhu.edu> - - * e-dialog-utils.c (e_notice, e_notice_with_xid, save_ok): - * e-request.c (e_request_string): - * e-passwords.c (e_passwords_ask_password): - Remove separator from dialogs per HIG. - -2004-03-04 Not Zed <NotZed@Ximian.com> - - * e-sexp.c: Added some debug stuff. - -2004-02-27 Not Zed <NotZed@Ximian.com> - - ** See Bug #37329. - - * e-mktemp.c (get_dir): setup a comjpile time option for storing - in the homedir, and also just use the uid as the key for a /tmp - dir option. - (e_mktemp_cleanup): removed entirely. - (e_mkstemp, e_mkdtemp, e_mktemp): dont save the file/dirname in a - list anymore. - (expire_dir_rec): expire old temp data from previous runs/old data - lying around. Based on access time. - (get_dir): run an expirey every now and then. - -2004-02-25 Jeffrey Stedfast <fejj@ximian.com> - - * e-gui-utils.c (e_icon_for_mime_type): Protect against feeding - gdk_pixbuf_new_from_file() a NULL path. Clears up some console - warning spewage. - -2004-02-19 Not Zed <NotZed@Ximian.com> - - * e-pilot-util.c: include string.h, fixes 64 bit crash. From - David Mosberger. - -2004-02-03 Chris Toshok <toshok@ximian.com> - - * e-html-utils.c (e_text_to_html_full): add callto:, h323:, and - webcal: schemes. - -2004-01-26 JP Rosevear <jpr@ximian.com> - - * e-folder-map.c (e_folder_map_dir): use g_file_test instead of - stat and pass the type e_folder_map_dir when recursing - -2004-01-24 JP Rosevear <jpr@ximian.com> - - * e-folder-map.c: turn off debugging - -2004-01-24 Chris Toshok <toshok@ximian.com> - - * e-folder-map.c (e_folder_map_dir): use GDir/g_build_filename, - and g_file_test. - (e_folder_map_local_folders): same. - -2004-01-23 JP Rosevear <jpr@ximian.com> - - * Makefile.am: build new sources - - * e-folder-map.[hc]: builds a list of 1.4 folder paths of a - certain type - -2004-01-20 JP Rosevear <jpr@ximian.com> - - * Makefile.am: don't build dead files - - * e-xml-hash-utils.[hc]: kill, these were moved to e-d-s long ago - -2004-01-14 Jeffrey Stedfast <fejj@ximian.com> - - * e-bconf-map.[c,h]: New source files for mapping bonobo-conf keys - to gconf keys. Moved out of shell/e-config-upgrade.c - -2004-01-13 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (em_cache*): A time-based thread-safe in-memory - cache thing. Called em_cache 'cause there's an e_cache in gal. - -2004-01-05 Not Zed <NotZed@Ximian.com> - - * e-memory.c (e_mempool_destroy): Fix from Zan Lynx - <zlynx@acm.org> to lock the memchunk before freeing the pool - header. - -2003-12-06 JP Rosevear <jpr@ximian.com> - - * Makefile.am: Remove hard coded disable deprecated flags - -2003-11-23 JP Rosevear <jpr@ximian.com> - - * Makefile.am (INCLUDES): remove gtk deprecated flag - -2003-11-18 JP Rosevear <jpr@ximian.com> - - * Makefile.am: remove db3 library, if you really want it, get it - from e-d-s - -2003-11-14 JP Rosevear <jpr@ximian.com> - - * Makefile.am: don't build the e-source stuff anymore, its in - e-d-s now - -2003-11-14 JP Rosevear <jpr@ximian.com> - - * test-source-list.c (on_idle_do_stuff): we only need the uid to - remove and peek at stuff - - * e-source-list.h: update proto types - - * e-source-list.c (e_source_list_peek_source_by_uid): allow peek - by uid only - (e_source_list_remove_source_by_uid): allow removal by uid only - -2003-11-07 Dan Winship <danw@ximian.com> - - * ename/*: Removed. No longer used by evolution except via - evolution-data-server. - - * Makefile.am (SUBDIRS): Remove ename - -2003-11-07 JP Rosevear <jpr@ximian.com> - - * Makefile.am: remove build sources from dist - -2003-11-07 JP Rosevear <jpr@ximian.com> - - * Makefile.am: make sure the marshal header and source are in the - source list - -2003-10-31 Hans Petter Jansson <hpj@ximian.com> - - * e-source.c (e_source_get_uri): Don't compress trailing slashes in - URI elements. - -2003-10-31 Not Zed <NotZed@Ximian.com> - - * e-account.c (e_account_(sg)et_from_xml): add encrypt_key id, and - change some of the names around to be more meaningful. - -2003-10-17 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyname_r): If the system defines - AI_ADDRCONFIG, set this flag on the hints.ai_flags member as well - so that we don't resolve a host to an IPv6 addr when the node - doesn't have any IPv6 source addresses. - -2003-10-24 Dan Winship <danw@ximian.com> - - * Makefile.am (libedb3util_la_LIBADD): add $(DB3_LDADD) - -2003-10-22 Dan Winship <danw@ximian.com> - - * e-bonobo-factory-util.[ch]: Gone; unused since 1.2 - - * e-proxy.[ch]: Gone; nothing in evo uses soup any more. - - * Makefile.am (eutilinclude_HEADERS, libeutil_la_SOURCES): Remove - e-proxy.[ch] - -2003-10-20 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (pilot_compile) [! ENABLE_PILOT_CONDUITS]: Add - md5-utils.c so it compiles even if you have no Pilot support. - -2003-10-16 Rodrigo Moya <rodrigo@ximian.com> - - * e-source-list.c (e_source_list_sync): use gconf_client_notify_remove - instead of g_source_remove for GConf notification IDs. - (impl_finalize): remove the GConf notification also here. - -2003-10-13 Rodrigo Moya <rodrigo@ximian.com> - - * e-source-group.[ch] (e_source_group_peek_source_by_name): added - new function. - -2003-10-10 Not Zed <NotZed@Ximian.com> - - * e-account-list.c (e_account_list_find): add FIND_UID find type. - -2003-09-26 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyaddr_r): IPv6 implementation - rewritten to use getnameinfo() which is the proper function to use - in this case. Fixes bug #46006 the Right Way (tm). - -2003-09-25 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyaddr_r): Make sure that - res->ai_canonname is non-NULL and that it doesn't match the - numeric host address that we were trying to resolve. Fixes the - second half of bug #46006. - -2003-09-19 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyaddr_r): Work around a bug in glibc - 2.3.2's gethostbyaddr_r() implementation. - -2003-09-15 Larry Ewing <lewing@ximian.com> - - * e-source.c (e_source_dump_to_xml_node): make sure declarations - precede the body. - -2003-09-11 Dan Winship <danw@ximian.com> - - * Makefile.am (noinst_LTLIBRARIES): Remove libeutil-static.la and - libeconduit-static.la - - * ename/Makefile.am (noinst_LTLIBRARIES): Remove - libename-static.la - -2003-08-28 Hans Petter Jansson <hpj@ximian.com> - - * eggtrayicon.[ch]: Added for tray icon support. To be removed when - libgnomeui sports this functionality. - - * Makefile.am: Include eggtrayicon. - -2003-08-27 Jeffrey Stedfast <fejj@ximian.com> - - * e-mktemp.c (e_mktemp_cleanup): We need to unlink the full paths - in the tmpdirs, not just the base path. - -2003-08-20 Suresh Chandrasekharan <suresh.chandrasekharan@sun.com> - - * e-time-utils.c (parse_with_strptime): Fixes #43558 Appointment - Editor always gives time validation error for apptmnts in non - UTF-8/non ASCII locales. - -2003-08-17 Ettore Perazzoli <ettore@ximian.com> - - * test-source-list.c: No short letter for --key. - -2003-08-15 Ettore Perazzoli <ettore@ximian.com> - - * e-uid.c: #include <glib/gstrfuncs.h> - - * test-source-list.c: Add options to display, set and unset the - color as well. - - * e-source.c: New members has_color, color in struct - ESourcePrivate. - (e_source_update_from_xml_node): Parse a color property from the - XML node. Protect from NULL name and relative_uri members as - well. - (e_source_dump_to_xml_node): Set a color property on the XML node. - (e_source_get_color): New. - (e_source_set_color): New. - (e_source_unset_color): New. - (e_source_new_from_xml_node): Use e_source_update_from_xml_node() - instead of getting the data from the XML yourself. - -2003-08-14 Ettore Perazzoli <ettore@ximian.com> - - Add UIDs to ESource* items so we can distinguish renames from - removals/additions. - - * test-source-list.c: Made --source and --group get UIDs instead - of names. - (on_idle_do_stuff): Updated behavior accordingly. - (dump_list): Print "(No items)" if there are no groups. - (dump_group): Print the UID of the group. - (dump_source): Print the UID of the source. - - * e-source-list.c (load_from_gconf): Match with group UIDs instead - of group names. - (e_source_list_peek_source_by_uid): New. - (e_source_list_peek_source_by_name): Removed. - (e_source_list_peek_group_by_uid): New. - (e_source_list_peek_group_by_name): Removed. - (e_source_list_remove_group_by_uid): New. - (e_source_list_remove_group_by_name): Removed. - (e_source_list_remove_source_by_uid): New. - (e_source_list_remove_source_by_name): Removed. - - * e-source-group.c: New member uid in struct ESourceGroupPrivate. - (impl_finalize): Free it. - (e_source_group_new): Set the uid member using e_uid_new(). - (e_source_group_peek_source_by_uid): New. - (e_source_group_peek_source_by_name): Removed. - (e_source_group_add_source): Check that the UID is unique, instead - of the name. - (e_source_group_remove_source_by_uid): New. - (e_source_group_remove_source_by_name): Removed. - (e_source_group_update_from_xmldoc): Use the UID to figure out - which source has changed, instead of the name. - (e_source_group_uid_from_xmldoc): New. - (e_source_group_name_from_xmldoc): Removed. - (e_source_group_new_from_xmldoc): Set the UID in the new group - from the XML. - (e_source_group_to_xml): Set a UID property in the XML. - - * e-source.c: New member uid in struct ESourcePrivate. - (e_source_new): Initialize using e_uid_new(). - (impl_finalize): Free. - (e_source_peek_uid): New. - (e_source_new_from_xml_node): Set the UID from the XML node. - (e_source_name_from_xml_node): Removed. - (e_source_uid_from_xml_node): New. - (e_source_dump_to_xml_node): Set the "uid" property on the XML - node. - - * e-account.c (e_account_gen_uid): Removed. - (e_account_new): Use e_uid_new() instead of e_account_gen_uid(). - - * e-uid.c (e_uid_new): New file, new function. - -2003-08-13 Ettore Perazzoli <ettore@ximian.com> - - Fix up the semantics of "changed" signals on GConf changes. - - * e-source-group.c (e_source_group_update_from_xmldoc): Added new - member ignore_source_changed in struct _ESourceGroupPrivate. - (e_source_group_update_from_xmldoc): Increment - ignore_source_changed before calling - e_source_update_from_xml_node(), decrement afterwards. - (source_changed_callback): Only emit "changed" if - ignore_source_changed is zero. - (e_source_group_update_from_xmldoc): Properly emit the "changed" - signal when the base_uri or the name change. - - * e-source-list.c: Changed type of sync_idle_id from gboolean (!) - to int and added new member ignore_group_changed in struct - _ESourceListPrivate. - (load_from_gconf): Increment ignore_group_changed before calling - e_source_group_update_from_xmldoc() and decrement it afterwards. - (group_changed_callback): Only emit the signal if - ignore_group_changed is zero. - - * e-source.c (e_source_update_from_xml_node): Removed arg - emit_signals. Always emit signals. - - * e-source-group.c (e_source_group_update_from_xmldoc): Removed - arg emit_signals. Always emit signals. - (e_source_group_update_from_xml): Likewise. - -2003-08-11 Ettore Perazzoli <ettore@ximian.com> - - * e-source.c (e_source_set_group): Weak_unref the current group if - not NULL and properly handle the case where a NULL group is being - passed in. - -2003-08-11 Ettore Perazzoli <ettore@ximian.com> - - * e-source-group.c: New file. - * e-source-group.h: New file. - * e-source-list.h: New file. - * e-source-list.c: New file. - * e-source.c: New file. - * e-source.h: New file. - * test-source-list.c: New file to test the above. - -2003-08-11 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (e_thread_put): check pthread_create return code - properly. - (e_mutex_lock): check pthread* return codes properly. - (e_mutex_unlock): Same here. - (e_mutex_cond_wait): and here. - -2003-08-05 Dan Winship <danw@ximian.com> - - * e-html-utils.c (special_chars): add a flag for non-url chars - (controls, whitespace, ", and |) - (url_extract): Use that. When urlifying just a hostname, make sure - it really is a hostname, and not just something like "www.c". - (e_text_to_html_full): Deal with url_extract returning NULL in the - "www." case - (main): add a regression test, #ifdef E_HTML_UTILS_TEST - -2003-07-24 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.c (add_key): just preload one level of GConf keys, - since preloading all makes the calendar startup slow. - -2003-07-23 Dan Winship <danw@ximian.com> - - * Makefile.am: Use EVO_MARSHAL_RULE - - * e-component-listener.c (connection_listen_cb): Fix a non-ANSI - switch label. - - * e-gui-utils.c: only include "art/empty.xpm" if - HAVE_LIBGNOMEUI_GNOME_ICON_LOOKUP_H isn't defined - - * e-xml-hash-utils.c (e_xml_to_hash): Deconstify a non-const - variable to fix a warning. - -2003-07-03 JP Rosevear <jpr@ximian.com> - - * e-xml-hash-utils.c (foreach_save_func): encode the text - (e_xml_from_hash): pass xmlDoc to foreach method - (e_xmlhash_new): check for file existence - (e_xmlhash_destroy): only destroy the hash if it exists - -2003-07-01 Dan Winship <danw@ximian.com> - - * e-gui-utils.c (e_icon_for_mime_type): New function to return an - icon for a MIME type, using GnomeIconTheme if available or - gnome-vfs and gnome-mime-data if not. - -2003-06-19 Dan Winship <danw@ximian.com> - - * e-xml-hash-utils.c (e_xml_to_hash): don't leak an extra copy of - the values - -2003-06-14 Larry Ewing <lewing@ximian.com> - - * e-name-western.c (e_name_western_get_suffix_at_str_end): free - word before breaking out of the loop. - -2003-06-12 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.c (add_key): use GCONF_CLIENT_PRELOAD_RECURSIVE - when adding watched directories to avoid GConfd round-trips. - -2003-06-12 Jeffrey Stedfast <fejj@ximian.com> - - * e-trie.c (e_trie_free): Free the fail_states array. - -2003-05-30 Jeffrey Stedfast <fejj@ximian.com> - - * e-meta.c (meta_load): Stat the file to make sure it exists - before trying to parse it using xmlParseFile(). - diff --git a/e-util/ChangeLog.pre-1-4 b/e-util/ChangeLog.pre-1-4 deleted file mode 100644 index 3cbac0eade..0000000000 --- a/e-util/ChangeLog.pre-1-4 +++ /dev/null @@ -1,2649 +0,0 @@ -2003-05-29 JP Rosevear <jpr@ximian.com> - - Fixes #43775 - - * e-time-utils.c (locale_supports_12_hour_format): use e_utf8_strftime - (e_time_format_date_and_time): ditto - (e_time_format_time): ditto - -2003-05-16 Dan Winship <danw@ximian.com> - - * e-proxy.c (e_proxy_init): Removing trailing / in key name passed - to gconf_client_notify_add to kill a warning. (Part of #43159) - -2003-05-16 Jeremy Katz <katzj@redhat.com> - - * e-sexp.c (term_eval_and): Use glib macros for pointer/int - conversion. - -2003-05-07 Rodrigo Moya <rodrigo@ximian.com> - - Fixes crash in #42212 - - * e-url.c (e_uri_new): check for 'uri_string' being NULL. - -2003-05-02 Not Zed <NotZed@Ximian.com> - - * e-request.c (e_request_string): remove the assert, if we dont - understand the response, assume it's a cancel. - GTK_RESPONSE_DELETE_EVENT wasn't handled [#42038]. - -2003-04-30 Ettore Perazzoli <ettore@ximian.com> - - * e-request.c (e_request_string): Handle GTK_RESPONSE_NONE. - [#42038] - -2003-04-24 Chris Toshok <toshok@ximian.com> - - [ for bug #41211 ] - - * e-gui-utils.h (e_button_new_with_stock_icon): add prototype. - - * e-gui-utils.c (e_button_new_with_stock_icon): new function, - allow us to create a custom labeled button with a stock icon. - -2003-04-28 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c: Added #include <netinet/in.h> for the - sockaddr_in6 typedef for at least MacOS X. - -2003-04-17 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyname_r): Keep our buf ptr aligned to - sizeof (char *). Should fix bug #41362. - (e_gethostbyaddr_r): Same. - -2003-04-18 Anna Marie Dirks <anna@ximian.com> - - * e-request.c (e_request_string): Added appropriate spacing/padding - to the rename dialogs. Fixes bugs #41040, #41036, #41038 - -2003-04-18 Ettore Perazzoli <ettore@ximian.com> - - * e-gtk-utils.c (e_gtk_button_new_with_icon): Remove debugging - message. - -2003-04-14 Jeffrey Stedfast <fejj@ximian.com> - - * e-sexp.c: Finished an #if 0'd out port to GObject from an #if - 0'd out GtkObject subclassing. - -2003-04-15 Hans Petter Jansson <hpj@ximian.com> - - * e-sexp.c (e_sexp_add_function) - (e_sexp_add_ifunction): Make sure any old symbol with the same name - as the one being added, is removed first. - -2003-04-14 Not Zed <NotZed@Ximian.com> - - * e-gtk-utils.c (e_gtk_button_new_with_icon): Utility function to - create a button with a stock icon. - -2003-04-09 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyaddr_r): Change the 'len' argument to - 'addrlen' so that when IPv6 is enabled, our temp vriable (also - named len) does not cause confusion. Fixes bug #40979. - -2003-04-05 Ettore Perazzoli <ettore@ximian.com> - - * e-passwords.c (e_passwords_remember_password): Removed debugging - message that would spit out the actual password, albeit in encoded - form. - -2003-04-04 Dan Winship <danw@ximian.com> - - * e-account-list.c (gconf_accounts_changed): Don't start emitting - ACCOUNT_ADDED signals until we've added all of the new accounts to - our list. Otherwise if the signal handler calls - e_account_list_get_default_account() it will end up causing the - first account in the list to become the default. #40675 - -2003-04-04 Chris Toshok <toshok@ximian.com> - - * ename/e-name-western.c (e_name_western_extract_middle): fix abr. - (e_name_western_get_suffix_at_str_end): same. - -2003-04-02 Not Zed <NotZed@Ximian.com> - - * e-passwords.c (e_passwords_forget_passwords): Delete all - Passwords-* sections. Should make this work. - -2003-03-31 Chris Toshok <toshok@ximian.com> - - * ename/test-ename-western.c (do_name): print "" if the value is - NULL. - (main): add a couple of utf8 test cases (that still use western - orderings). - - * ename/e-name-western.c (e_name_western_str_count_words): - utf8-ize this. - (e_name_western_cleanup_string): same. - (e_name_western_get_words_at_idx): same. - (e_name_western_get_one_prefix_at_str): same. - (e_name_western_get_prefix_at_str): same. - (e_name_western_extract_first): same. - (e_name_western_extract_middle): same. - (e_name_western_extract_nickname): same. - (e_name_western_extract_last): same. - (e_name_western_get_preceding_word): same. - (e_name_western_get_suffix_at_str_end): same. - (e_name_western_detect_backwards): same. - (e_name_western_reorder_asshole): same. - (FINISH_CHECK_MIDDLE_NAME_FOR_CONJUNCTION): same. - (e_name_western_fixup): same. - (e_name_western_parse): validate the string and truncate it if - need be. - -2003-03-27 JP Rosevear <jpr@ximian.com> - - * e-account-list.c (e_account_list_find): guard against NULL keys - -2003-03-25 Dan Winship <danw@ximian.com> - - * e-dialog-utils.c (e_notice): Move this here from gal. Use - e_dialog_set_transient_for so it DTRT for out-of-proc components. - (e_notice_with_xid): Like e_notice but with an X Window ID as the - parent window - (e_gnome_dialog_set_parent): Remove this, since it was marked - deprecated and only used in one place. - (e_file_dialog_save): Make this use GtkMessageDialog instead of - GnomeDialog - (e_dialog_set_transient_for_xid): #ifdef out gtk 2.2 api usage - -2003-03-25 Not Zed <NotZed@Ximian.com> - - * e-meta.c (meta_filename): fix a typo & some missing headers. - -2003-03-24 Dan Winship <danw@ximian.com> - - * e-dialog-utils.c (e_dialog_set_transient_for, - e_dialog_set_transient_for_xid): Rename, rewrite, make them - actually work. - -2003-03-25 Not Zed <NotZed@Ximian.com> - - * Makefile.am: Added e-meta.[ch] to libeutil - - * e-meta.[ch]: simple api to implement meta-data for keyed - objects. - -2003-03-20 Jeffrey Stedfast <fejj@ximian.com> - - * e-trie.c (e_trie_search): If the gunichar is 0xfffe, just skip - processing it. Maybe this will fix bug #39900. - (trie_utf8_getc): Removed unused labels to shutup the compiler. - -2003-03-19 Jeffrey Stedfast <fejj@ximian.com> - - * e-sexp.h: Fix ESExpClass to never be an empty struct. Also make - ESExp optionally a subclass of GObject rather than GtkObject (not - that we'll probably ever make it so, but for completeness sake?). - -2003-03-18 Jeffrey Stedfast <fejj@ximian.com> - - * e-trie.c (trie_utf8_getc): Don't use __inline__ as it is not - always defined. - -2003-03-13 Dan Winship <danw@ximian.com> - - * ename/e-address-western.c (e_address_western_parse): When - declaring a line to be part of "extended" because we don't know - what else to call it, keep the preceding "\n" so that the address - still looks the same when we reassemble the pieces later. Fixes - handling of non-US addresses - -2003-03-12 Dan Winship <danw@ximian.com> - - * e-xml-hash-utils.c (e_xml_to_hash): Update for a libxml2 change - that was making this code g_warn a lot - -2003-03-06 Ettore Perazzoli <ettore@ximian.com> - - * e-request.c (e_request_string): Make the entry activate the - default response in the dialog. - -2003-03-03 Rodney Dawes <dobey@ximian.com> - - * e-proxy.c: Use gnome2 proxy settings - -2003-03-02 Rodney Dawes <dobey@ximian.com> - - * e-pilot-util.c: s/gnome-xml/libxml/ - -2003-02-27 JP Rosevear <jpr@ximian.com> - - * Makefile.am: include gnome-pilot cflags - -2003-02-23 Jeffrey Stedfast <fejj@ximian.com> - - * e-account-list.c (gconf_accounts_changed): 'uid' should not be - const. - -2003-02-20 Not Zed <NotZed@Ximian.com> - - * e-account-list.c (e_account_list_get_default): helper to get the - dfault account. - (e_account_list_set_default): helper to set the default account. - (e_account_list_find): Helper to find accounts based on differnet - key types. - (e_account_list_add): helper to add account + emit added event. - (e_account_list_change): helper to emit changed event. - (e_account_list_remove): herlper to remove account + emit changed event. - -2003-02-22 Hans Petter Jansson <hpj@ximian.com> - - * e-categories-config.c (e_categories_config_open_dialog_for_entry): - A result of 0 no longer indicates success; GTK_RESPONSE_OK does. - -2003-02-17 Chris Toshok <toshok@ximian.com> - - * e-account-list.c (gconf_accounts_changed): fix memleak - free - uid. - -2003-02-11 Not Zed <NotZed@Ximian.com> - - * e-trie.c (trie_utf8_getc): Instead of simply ignoring bad chars, - return the sentinal invalid char 0xfffe, so that we properly track - the start of sequences. - -2003-02-10 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (libeutil_static_la_DEPENDENCIES): Make - libeutil-static.la depend on libeutil.la so that parallel - compilations work; building them at the same time confuses - libtool. - (e-util-marshal.h, e-util-marshal.c): Use different tmp files so - these rules can happen in parallel. - -2003-02-05 Dan Winship <danw@ximian.com> - - * Makefile.am (eutilincludedir, etc): define in terms of - privincludedir. - - * ename/Makefile.am (libenameincludedir): Likewise - - * e-account.c: Fix warnings - * e-account-list.c: Likewise - * e-config-listener.c: Likewise - * e-gui-utils.c: Likewise. - * e-lang-utils.c: Likewise - * e-msgport.c: Likewise - * e-passwords.c: Likewise - - * e-categories-config.c - (e_categories_config_open_dialog_for_entry): Use g_object_get/_set - rather than gtk_ - - * e-url.c (e_uri_new): Use g_ascii_strdown instead of deprecated - g_strdown. - -2003-01-27 Ettore Perazzoli <ettore@ximian.com> - - * e-request.c (e_request_string): Port to GtkDialog. Strdup the - text returned by GtkEntry after destroying the dialog, not before. - Use gtk_editable_select_region() instead of - gtk_entry_select_region(). Add a little bit of padding to make it - look less crampy and set a default width. - - * e-dialog-utils.h (e_gnome_dialog_set_parent): Declare only if - GNOME_DISABLE_DEPRECATED is not #defined. - (e_gnome_warning_dialog_parented): Likewise. - (e_gnome_ok_cancel_dialog_parented): Likewise. - -2003-01-26 Chris Toshok <toshok@ximian.com> - - * e-pilot-settings.c (e_pilot_settings_new): ref/sink the pilot - settings to clear up that gtk warning. - -2003-01-25 Chris Toshok <toshok@ximian.com> - - * e-pilot-map.c (e_pilot_map_read): g_file_exists -> g_file_test. - (e_pilot_map_write): don't use doc->root. - -2003-01-25 Chris Toshok <toshok@ximian.com> - - * e-pilot-settings.[ch]: GObjectify this. - -2003-01-24 Hans Petter Jansson <hpj@ximian.com> - - * e-categories-config.c (initialize_categories_config): Enable - getting the categories master list from wombat. - (e_categories_config_open_dialog_for_entry): It's now a GtkDialog. - -2003-01-22 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (eutilincludedir): Version using $(BASE_VERSION). - (econdincludedir): Likewise. - (edb3includedir): Likewise. - (imagesdir): Likewise. - - * ename/Makefile.am: Install libename in $(privlibdir) and - $(includedir)/evolution-$(BASE_VERSION)/ename. - -2003-01-17 Jeffrey Stedfast <fejj@ximian.com> - - * e-account-list.c: Changed signal names to use - instead of _ - like the rest of Gtk2. - - * e-account.c (e_account_import): New function that is basically - the old account_copy(). - -2003-01-17 Dan Winship <danw@ximian.com> - - * e-xml-hash-utils.c: New, sort of from evolution-recurid-branch. - -2003-01-16 Dan Winship <danw@ximian.com> - - * e-account.c: New class, based on MailConfigAccount, for - describing an evolution (mail) account. - - * e-account-list.c: New class for tracking the list of configured - accounts. (Also uses some code from mail-config.) - - * e-list.c (e_list_construct, e_list_remove): New - -2003-01-14 Ettore Perazzoli <ettore@ximian.com> - - * e-dialog-utils.c: Do not #include <e-bonobo-widget.h>. - (e_set_dialog_parent): Remove the BonoboWidget handling stuff (it - doesn't really work anyways). - -2003-01-14 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (eutilinclude_HEADERS): Add e-dialog-utils.h. - -2003-01-09 Chris Toshok <toshok@ximian.com> - - * e-gui-utils.c (e_create_image_widget): change this to use - GtkImage instead of GnomeCanvas. - -2003-01-08 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Images are now in $(datadir)/evolution/images - instead of $(datadir)/images/evolution. - -2003-01-07 Dan Winship <danw@ximian.com> - - * e-config-listener.c (e_config_listener_remove_value): New. - - * e-passwords.c (e_passwords_get_password): Don't look at the - passwords hash until calling e_passwords_init(). - -2003-01-06 Dan Winship <danw@ximian.com> - - * e-html-utils.c: Add this back: Connector needs it, and there's - no reason for addressbook and calendar to be using camel to get - this functionality. - - * Makefile.am (libeutil_la_SOURCES): re-add e-html-utils - -2003-01-02 Jeffrey Stedfast <fejj@ximian.com> - - A bunch of fixes to make e-util build with -DG_DISABLE_DEPRECATED - and -DGTK_DISABLE_DEPRECATED. - -2003-01-02 Ettore Perazzoli <ettore@ximian.com> - - * e-gtk-utils.c (e_signal_connect_full_while_alive): Get to - compile. - (e_signal_connect_while_alive): Like. - -2002-12-19 Ettore Perazzoli <ettore@ximian.com> - - * e-gtk-utils.c (e_signal_connect_while_alive): New. - (e_signal_connect_full_while_alive): Renamed from - e_gtk_signal_connect_full_while_alive(). - -2002-12-16 Jeffrey Stedfast <fejj@ximian.com> - - * e-html-utils.[c,h]: Removed. Back to the fiery depths of hell - from whence ye came! - -2002-12-10 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.[ch] (e_config_listener_remove_dir): new - function. - -2002-12-09 Jeffrey Stedfast <fejj@ximian.com> - - * e-trie.c: New implementation of an Aho-Corasick trie. - -2002-12-09 Chris Toshok <toshok@ximian.com> - - * e-passwords.h: track changes to api (e_passwords_init is gone, - and several functions take the component name as an arg.) - - * e-passwords.c (e_passwords_init): make this static, and allow - multiple calls. Also, it no longer takes the component name. - (e_passwords_shutdown): make this deal with the case where - e_passwords_init wasn't called (no hashtable), and it no longer - needs to free component_name. - (e_passwords_forget_passwords): call e_passwords_init. - (e_passwords_clear_component_passwords): take component_name as an - arg, and call e_passwords_init. - (password_path): take component_name as an arg. - (e_passwords_remember_password): same, and call e_passwords_init. - (e_passwords_forget_password): same. - (e_passwords_get_password): same. - (e_passwords_add_password): call e_passwords_init. - (e_passwords_ask_password): take component_name as an arg. - -2002-12-07 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (e_mutex_cond_wait): Allow an e-mutex to be used - with standard condition variables. - -2002-12-06 Chris Toshok <toshok@ximian.com> - - * e-categories-master-list-wombat.c (ecmlw_load): change to a more - gconf-like path (with underscores, etc.) - (ecmlw_save): same. - -2002-11-26 Dan Winship <danw@ximian.com> - - * e-lang-utils.c (e_get_language_list): If the language is - something like "fr_FR", return both "fr_FR" and "fr" in the list. - Oaf doesn't consider "fr_FR" to match a "-fr" translation. - -2002-11-22 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (EMsgPort): Added an optional nspr pipe field. - (e_msgport_new): Init nspr pipe to null. - (e_msgport_destroy): close prfiledesc's if they're open. - (e_msgport_prfd): get the prfiledesc to wait asynchronously on. - (e_msgport_put): Write notify to nspr pipe if it exists. - (e_msgport_wait): poll nspr pipe fd if it is set, and the pipe fd - isn't. - (e_msgport_get): skim off a notify byte on the pr pipe if set. - (): Include config.h, and nspr stuff if HAVE_NSS is set. - -2002-11-13 Ettore Perazzoli <ettore@ximian.com> - - * e-config-listener.c (e_config_listener_get_string_with_default): - Make sure we don't use a string value from a GConfValue that got - freed. - -2002-11-12 Chris Toshok <toshok@ximian.com> - - * Makefile.am - (eutilinclude_HEADERS): add e-password.h - (libeutil_la_SOURCES): add e-password.c - - * e-passwords.[ch]: port this to gnome2's gnome-config-private. - -2002-11-11 Ettore Perazzoli <ettore@ximian.com> - - * e-config-listener.c (add_key): g_strdup() the value in the case - of a string value. - -2002-11-11 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am: Re-add e-proxy.c to the build. - -2002-11-08 Chris Toshok <toshok@ximian.com> - - * Makefile.am (eutilinclude_HEADERS): add e-categories-config.h - and e-categories-master-list-wombat.h - (libeutil_la_SOURCES): add e-categories-master-list-wombat.c - - * e-categories-master-list-wombat.[ch]: port work. - -2002-11-07 JP Rosevear <jpr@ximian.com> - - * e-categories-config.c (e_categories_config_get_icon_for): pass - extra pixbuf param - - * e-categories-config.h: use G_*_DECLS - - * e-dialog-utils.c (save_ok): update g_file_test params - - * Makefile.am: Compile some additional files - -2002-11-06 Chris Toshok <toshok@ximian.com> - - * e-config-listener.c (e_config_listener_set_boolean): init err to - NULL so if there isn't an error we aren't left with an unitialized - GError. Fixes crash. - (e_config_listener_set_float): same. - (e_config_listener_set_long): same. - (e_config_listener_set_string): same. - -2002-11-05 Rodrigo Moya <rodrigo@ximian.com> - - * e-component-listener.[ch]: ported to GObject. - - * Makefile.am: re-enabled e-component-listener.[ch] - -2002-11-03 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.[ch] (e_config_listener_get_boolean, - e_config_listener_get_float, e_config_listener_get_long, - e_config_listener_get_string): new simpler functions, without - a default value. - -2002-11-03 Ettore Perazzoli <ettore@ximian.com> - - * e-config-listener.c (e_config_listener_get_float_with_default): - Removed unused variable. - (e_config_listener_get_long_with_default): Likewise. - (e_config_listener_get_string_with_default): Likewise. - - * Makefile.am: Compile e-config-listener.[ch]. - -2002-11-02 Chris Toshok <toshok@ximian.com> - - * Makefile.am: add marshal building stuff, add e-util-marshal.c to - SOURCES, and add e-util-marshal.list to EXTRA_DIST. - - * e-util-marshal.list: add marshallers for e-util. - - * e-list.c: convert to GObject. - - * e-list.h: convert to GObject. - - * e-iterator.c: convert to GObject. - - * e-iterator.h: convert to GObject. - - * e-list-iterator.c: convert to GObject. - - * e-list-iterator.h: convert to GObject. - - * .cvsignore: ignore e-util-marshal.[ch] - -2002-11-02 Ettore Perazzoli <ettore@ximian.com> - - * ename/Makefile.am (INCLUDES): Removed -I$(includedir). - - * ename/test-ename-western-gtk.c: #include - <libgnomeui/gnome-ui-init.h> instead of <libgnomeui/gnome-init.h>. - (create_window): Added GTK_SIGNAL_FUNC() cast. - (main): Use gnome_program_init(). - - * e-db3-utils.c: Do not #include <libgnome/gnome-defs.h>. - - * e-request.c: Do not #include <libgnomeui/gnome-stock.h>. - - * e-memory.c (e_memchunk_clean): Replace GSearchFunc with - GCompareFunc. - - * e-iterator.c (e_iterator_class_init): GTK2-ified. - (ECI_CLASS): Likewise. - - * e-html-utils.c: Do not #include <gal/unicode/gunicode.h>. - - * e-gui-utils.c: Don't #include <libgnome/gnome-defs.h>. - (e_create_image_widget): Pass NULL to gdk_pixbuf_new_from_file() - for the error arg. - - * e-corba-utils.h: #include <orbit/orbit.h> instead of - <orb/orbit.h>. - - * Makefile.am: Removed bonobo-factory-util.c, - bonobo-factory-util.h, e-categories-master-list-wombat.h, - e-categories-master-list-wombat.c, e-dialog-utils.c, - e-dialog-utils.h, e-proxy.c e-proxy.h for now. - -2002-11-02 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.[ch]: ported to GConf and GObject. - -2002-11-01 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.[ch]: - * e-component-listener.[ch]: compilation fixes for GNOME 2 porting. - -2002-10-24 Rodrigo Moya <rodrigo@ximian.com> - - Fixes #32764 - - * e-config-listener.c (add_key): store the value returned by - bonobo_event_source_client_add_listener, so that we can remove it - later, when freeing the key structure. - (free_key_hash): remove listener. - (e_config_listener_set_boolean): - (e_config_listener_set_float): - (e_config_listener_set_long): - (e_config_listener_set_string): only set the cache values if there's - no exception. - (e_config_listener_destroy): remove all keys before unrefing the db - component. - -2002-10-23 Dan Winship <danw@ximian.com> - - * ename/e-name-western.c: Cast chars to unsigned char before - passing to ctype macros since they are not defined on negative - numbers. Fixes parsing problems with names with accented - characters on Solaris. (At least part of #32146) - -2002-09-25 Rodrigo Moya <rodrigo@ximian.com> - - * e-component-listener.c (ping_component_callback): added a comment - about the fix for #30918. - -2002-09-23 Rodrigo Moya <rodrigo@ximian.com> - - * e-component-listener.c (ping_component_callback): gtk_object_ref the - component listener before emitting the "component_died" signal, since - in most cases, the component listener will be destroyed in the - callbacks for that signal. - -2002-09-22 Dan Winship <danw@ximian.com> - - * e-config-listener.c: Fix some non-ANSI switch statements - - * e-path.c: #include <sys/types.h> for OS X - -2002-09-11 Chris Toshok <toshok@ximian.com> - - [ Fixes #27546 ] - * ename/e-name-western-tables.h - (e_name_western_complex_last_table): add "di" to - e_name_western_complex_last_table. - -2002-09-05 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.c (e_config_listener_set_boolean, - e_config_listener_set_float, e_config_listener_set_long, - e_config_listener_set_string): update the local copy (if we've - got one) so that we don't return values if asked before getting - the change notification. - -2002-09-04 Dan Winship <danw@ximian.com> - - * e-time-utils.c (e_mktime_utc): New. Like mktime(3), but assumes - the input time is UTC. - (e_localtime_with_offset): New. Like localtime_r(3), but also - returns an offset from UTC. - -2002-08-29 Dan Winship <danw@ximian.com> - - * e-list.c (e_list_destroy): Don't call g_list_foreach with the - free func if the free func is NULL. - -2002-08-28 Jeffrey Stedfast <fejj@ximian.com> - - * e-html-utils.c (e_text_to_html_full): Convert file: urls - too. Fixes bug #29557. - - * e-proxy.[c,h] (e_proxy_init): New convenience function to - initialise the proxy settings for soup to use. - -2002-08-27 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.c[ch] (e_config_listener_get_float_with_default, - e_config_listener_set_boolean, e_config_listener_set_float): new - functions. - (property_change_cb, add_key): added support for FLOAT values. - (e_config_listener_set_string): free strings before returning. - -2002-08-26 Peter Williams <peterw@ximian.com> - - * e-dialog-utils.c (set_transient_for_gdk): If gdk_window_foreign_new - returned NULL, we're probably screwed, but try to avoid a segfault. - (Preemptive fix suggested by kmaraas). - -2002-08-26 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.c (e_config_listener_get_string_with_default): - call g_strdup in the correct place, or we'll return the internal copy. - -2002-08-26 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.c (e_config_listener_set_long): only set the key - if the value is different from what we've already read from the - database, to avoid extra change notifications. - (e_config_listener_set_string): likewise. - -2002-08-22 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.[ch]: added "key_changed" signal to class. - (property_change_cb): emit "key_changed" signal. - (e_config_listener_set_long): new function. - (e_config_listener_get_long_with_default): new function. - -2002-08-22 Dan Winship <danw@ximian.com> - - * e-path.c (e_path_rmdir): Remove an e_path directory, and its - parent "subfolders" dir if it's now empty. - -2002-08-22 JP Rosevear <jpr@ximian.com> - - * e-time-utils.c (e_time_parse_date): if the year was two digits, - add the current century - - Fixes # 17252 - -2002-08-16 Rodrigo Moya <rodrigo@ximian.com> - - * e-config-listener.[ch]: new class for config database access and - monitoring. - - * Makefile.am: added new files. - -2002-08-14 Rodrigo Moya <rodrigo@ximian.com> - - * e-component-listener.[ch]: new class for controlling a component, - to detect when it dies. - -2002-08-01 Dan Winship <danw@ximian.com> - - * e-html-utils.c (is_citation): Remove the logic that assumes - "Rupert> " is a citation, since it misfires more often than it - hits. - -2002-07-31 Dan Winship <danw@ximian.com> - - * e-html-utils.c (is_addr_char, is_trailing_garbage): Don't use - "isprint(c)" to mean "c >= 32 && c < 128" since it doesn't in most - locales. - (is_domain_name_char): new macro for dns-valid characters - (email_address_extract): Use is_domain_name_char rather than - is_addr_char for the part after the @. - -2002-07-30 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyname_r): If the user has enabled IPv6 - support, use getaddrinfo to resolve hostnames and then manually - fit the result into a struct hostent. - (e_gethostbyaddr_r): Same. - -2002-07-25 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (e_dlist_length): Return the actual count, rather - than always 0! - -2002-07-03 Peter Williams <peterw@ximian.com> - - * Makefile.am: Install libeutil, libeconduit, and libedb3util and - their headers. - -2002-07-15 Not Zed <NotZed@Ximian.com> - - * e-sexp.c (term_eval_caststring): Cast to a string type. - (term_eval_castint): Cast to an int type. - (symbols[]): Add to symbol table. - -2002-07-09 Dan Winship <danw@ximian.com> - - * e-categories-config.c: #include <string.h> - -2002-07-02 Rodrigo Moya <rodrigo@ximian.com> - - * e-categories-config.c (e_categories_config_get_icon_for): changed to - return a gboolean (TRUE if the icon is found, FALSE if not). - -2002-06-07 Not Zed <NotZed@Ximian.com> - - * e-dialog-utils.c (e_gnome_warning_dialog_parented): - (e_gnome_ok_cancel_dialog_parented): Use connect_while_alive, so - we're not called after we've quit. See bug #15397. - -2002-06-03 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (e_msgport_wait): Protect against EINTR (irix?), see - bug #24086. - -2002-05-07 Ettore Perazzoli <ettore@ximian.com> - - * e-corba-utils.c (e_safe_corba_string_dup): New. - -2002-05-06 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (e_thread_destroy): Destroy our mutex too. - (e_thread_new): Add thread to a new list of all threads. - (e_thread_destroy): Remove thread from list of all threads. - (e_thread_busy): New function, returh true if we're busy somewhere - processing work. - -2002-04-19 Jeffrey Stedfast <fejj@ximian.com> - - * e-passwords.c (e_passwords_get_password): Don't leak the base64 - encoded password buffer. - -2002-04-16 Jeffrey Stedfast <fejj@ximian.com> - - * e-host-utils.c (e_gethostbyaddr_r): New wrapper around - gethostbyaddr_r if the system has it, else a whole new - implementation. - -2002-04-11 Jeffrey Stedfast <fejj@ximian.com> - - * e-sexp.c (parse_value): Handle parsing negative integers. - -2002-03-29 JP Rosevear <jpr@ximian.com> - - * e-dialog-utils.c (e_file_dialog_save): open a file selection - dialog with the given title and return the selected file name - (save_ok): if the ok button is clicked, make sure the file doesn't - already exist and if it does, see if the user wants to over write - it - - * e-dialog-utils.h: new proto - -2002-03-22 Ettore Perazzoli <ettore@ximian.com> - - * e-lang-utils.c: New. - * e-lang-utils.h: New. - -2002-03-22 Dan Winship <danw@ximian.com> - - * e-request.c (e_request_string): Document the fact that this - takes two locale charset strings and one UTF8 string and returns a - UTF8 string. (Huh.) - -2002-03-04 Jeffrey Stedfast <fejj@ximian.com> - - * e-mktemp.c: #include <string.h> for strcmp. - -2002-02-22 Dan Winship <danw@ximian.com> - - * e-html-utils.c (e_text_to_html_full): Fix for if the buffer ends - with an email address (and no newline). - -2002-02-09 JP Rosevear <jpr@ximian.com> - - * e-pilot-settings.h: add row and column defines - -2002-01-27 Ettore Perazzoli <ettore@ximian.com> - - * ename/Makefile.am: Use E_NAME_CFLAGS and E_NAME_LIBS. - - * Makefile.am: Use E_UTIL_CFLAGS and E_UTIL_LIBS. - -2002-01-14 JP Rosevear <jpr@ximian.com> - - * Makefile.am: compile new files - - * e-pilot-settings.[hc]: beginnings of a general conduit - configuration gui - -2002-01-10 Christopher James Lahey <clahey@ximian.com> - - * ename/e-name-western.c (e_name_western_word_is_suffix): Allow - for a period after suffixes. Fixes Ximian bug #17012. - -2002-01-04 Jeffrey Stedfast <fejj@ximian.com> - - * e-memory.c (e_memchunk_clean): Prune free'd nodes from our free - list otherwise we'll end up re-using free'd memory blocks and - that's not a Good Thing (tm). - -2002-01-02 Jeffrey Stedfast <fejj@ximian.com> - - * md5-utils.h: Reverted. - -2002-01-02 Jeffrey Stedfast <fejj@ximian.com> - - * md5-utils.h: Move the struct into md5-utils.c - this is a - kludgey hack around the fact that NSS also defines - MD5Context. Besides, this should be a private struct anyway. - -2002-01-02 JP Rosevear <jpr@ximian.com> - - * e-dialog-utils.c (e_gnome_dialog_set_parent): util function - moved from mail-callbacks, also destroys the dialog if the parent - is destroyed - (e_gnome_warning_dialog_parented): similarly - (e_gnome_ok_cancel_dialog_parented): ditto - - * e-dialog-utils.h: new protos - -2001-12-17 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.c (e_pilot_map_clear): clear all info from the map - - * e-pilot-map.h: add proto - -2001-12-10 JP Rosevear <jpr@ximian.com> - - * e-pilot-util.c (e_pilot_utf8_to_pchar): use UTF-8 instead of - UTF8 as the source char set - (e_pilot_utf8_from_pchar): use UTF-8 instead of UTF8 as the - destination char set - -2001-11-20 Dan Winship <danw@ximian.com> - - * e-passwords.c (e_passwords_forget_password): Clear the password - in bonobo-conf as well. Fixes ximian 14893. - -2001-11-13 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (libeutil_la_LIBADD): Remove `-lc'. It makes the - mailer do strange things when it calls `fork()', thus breaking - e.g. mail sending through sendmail. - -2001-11-13 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.c (real_e_pilot_map_insert): only insert non-0 pids - into the pid map - (e_pilot_map_insert): remove and free old keys/values here - - including possibly orphaned keys - (e_pilot_map_remove_by_uid): only free things if they should have - been found - -2001-11-13 JP Rosevear <jpr@ximian.com> - - * Makefile.am (libeutil_la_LIBADD): Explicitly add -lc - -2001-10-30 Damon Chaplin <damon@ximian.com> - - * e-time-utils.c (e_time_parse_date): added a 2nd format, with the - weekday and the date. We need this so we can try to parse DATE values - in the ECalendarTable. - -2001-10-29 Ettore Perazzoli <ettore@ximian.com> - - * e-dialog-utils.c (e_set_dialog_parent): Remove a g_warning. - -2001-10-29 Christopher James Lahey <clahey@ximian.com> - - * ename/e-name-western.c (e_name_western_fixup): Added French - conjunction. - - * e-host-utils.c: Don't define gethost_mutex unless we need it. - -2001-10-29 Christopher James Lahey <clahey@ximian.com> - - * ename/e-name-western.c: Cleaned this up a bit. - -2001-10-29 Christopher James Lahey <clahey@ximian.com> - - * ename/e-name-western.c (e_name_western_fixup): Check for - compound first names here (X & Y). Fixes Ximian bug #13859. - -2001-10-28 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.c (e_pilot_map_remove_by_pid): make sure to free the - keys as well - (e_pilot_map_remove_by_uid): ditto - -2001-10-27 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.h: update proto - - * e-pilot-map.c (e_pilot_map_lookup_pid): touch the nodes if - indicated and found - (e_pilot_map_lookup_uid): ditto - -2001-10-26 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.c (real_e_pilot_map_insert): take an extra param on - whether to mark touched - (map_sax_start_element): use above - (e_pilot_map_insert): ditto - (e_pilot_map_write): pass in extra info to foreach call - (map_write_foreach): if we are in touched only mode, write out the - map only if its been touched - - * e-pilot-map.h: add new member - -2001-10-26 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.c (map_sax_start_element): add archived records - with pilot id of 0 - (map_write_foreach): use the uid map for writing - (e_pilot_map_write): write using the uid map - -2001-10-26 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.c (e_pilot_map_insert): free up old memory first - (e_pilot_map_destroy): free allocated memory when destroying - -2001-10-22 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.c (map_set_node_timet): plug leak - -2001-10-23 Dan Winship <danw@ximian.com> - - * e-html-utils.c (e_text_to_html_full): Change " " to " " at - start of line. - -2001-10-22 Dan Winship <danw@ximian.com> - - * e-passwords.c (e_passwords_get_password): Pass a - CORBA_Environment to bonobo_config_get_string so it doesn't g_warn - on error. (Since the "error" is most likely just that the password - isn't cached.) - (e_passwords_remember_password, e_passwords_get_password, - e_passwords_add_password): Change "if (foo) { entire function; }" - to "if (!foo) return;" - - * e-html-utils.c (special_chars): Don't allow single quote or - backtick in email addresses, or pipes following URLs. - -2001-10-22 JP Rosevear <jpr@ximian.com> - - * e-dbhash.c (e_dbhash_foreach_key): null out DBT memory prior to - usage (from Edd Dumbill <edd@usefulinc.com>) - -2001-10-17 Ettore Perazzoli <ettore@ximian.com> - - * e-dialog-utils.c (e_set_dialog_parent_from_xid): New. - -2001-10-12 Chris Toshok <toshok@ximian.com> - - * e-passwords.h: new parameter to e_passwords_init, and add - prototype for e_passwords_clear_component_passwords. - - * e-passwords.c (e_passwords_init): copy off the component name. - (e_passwords_shutdown): free/NULL the component name. - (e_passwords_clear_component_passwords): new function. remove the - subtree rooted at /Passwords/<ComponentName>. - (e_passwords_remember_password): use component_name when building - up the path. - (e_passwords_get_password): same. - (e_passwords_add_password): remove/free the currently stored - session password for this key if there is one, before adding the - new one. - -2001-10-11 Chris Toshok <toshok@ximian.com> - - * e-passwords.h: change prototype for e_passwords_get_password. - - * e-passwords.c (e_passwords_get_password): remove 'const' from - return type - the return type is now allocated and must be freed - by the caller. - -2001-10-11 Chris Toshok <toshok@ximian.com> - - * e-passwords.c (e_passwords_init): open the bonobo config db for - our passwords. - (e_passwords_shutdown): sync and unref the bonobo db, and clear - out the per session hash. - (e_passwords_forget_passwords): remove the bonobo config db - /Passwords path, and free up the session hash (but don't destroy - it). - (e_passwords_remember_password): remove the key/value from the - session hash, after inserting it into the bonobo db. - (e_passwords_get_password): look up a session password for the - uri, and if it's not there, consult the bonobo db. - (e_passwords_ask_password): quiet gcc's warnings, and only consult - the toggle button state if we actaully created it. - -2001-10-09 Rodrigo Moya <rodrigo@ximian.com> - - * e-url.c (e_uri_to_string): don't add the host if it's null - -2001-10-06 Christopher James Lahey <clahey@ximian.com> - - * ename/e-address-western.c (e_address_western_parse): Made this - refuse to parse more than 2047 characters of address. - -2001-10-04 Dan Winship <danw@ximian.com> - - * e-passwords.c (e_passwords_add_password): Make this dup the - strings it's passed. - (*) Add lots of docs. - -2001-10-03 Rodrigo Moya <rodrigo@ximian.com> - - * e-url.c (e_uri_new): default protocol to file: if not specified - -2001-10-02 Rodrigo Moya <rodrigo@ximian.com> - - * e-url.c (e_uri_copy): duplicate also the params member - -2001-10-02 Rodrigo Moya <rodrigo@ximian.com> - - * e-url.[ch] (e_uri_copy, e_uri_to_string): new functions - -2001-10-01 Rodrigo Moya <rodrigo@ximian.com> - - * e-url.[ch]: added basic URI management functions - - * Makefile.am: added BONOBO flags to make it compile with latest - Bonobo, which installs headers in a version-based directory - -2001-10-01 Dan Winship <danw@ximian.com> - - * e-passwords.c (e_passwords_ask_password): New, copied/renamed - from mailer and gnome-libs. - -2001-09-30 Chris Toshok <toshok@ximian.com> - - * Makefile.am (libeutil_la_SOURCES): add e-passwords.[ch] - -2001-09-30 Chris Toshok <toshok@ximian.com> - - * e-passwords.c: copy/rename the mail specific password stuff - here. - - * e-passwords.h: same. - -2001-09-28 <NotZed@Ximian.com> - - * e-msgport.c (e_msgport_put): Write the pipe notification outside - the lock. This way if the pipe fills up because of too many - outstanding request, the queue isn't deadlocked. This only - happens wiht 4096 outstanding messages, so something is getting - VERY busy! Fixes #11121. - -2001-09-24 Christopher James Lahey <clahey@ximian.com> - - * e-categories-master-list-wombat.c (ecmlw_load, ecmlw_save): Make - the printouts here conditionally compiled out. - -2001-09-21 <NotZed@Ximian.com> - - * e-msgport.c (e_thread_destroy): Instead of using - pthread_cancel() which seems to have numerous implementation - issues, send a special quit message to the subordinate thread. - (thread_dispatch): When it gets a quit message, well, quit! - -2001-09-18 Ettore Perazzoli <ettore@ximian.com> - - * e-gtk-utils.c (widget_realize_callback_for_backing_store): Use - ->bin_window [instead of ->window] if the widget is a GtkLayout. - -2001-09-17 Damon Chaplin <damon@ximian.com> - - * e-time-utils.c (e_time_parse_date): only use 1 format, so we are - consistent everywhere. If we support multiple formats we have to - support that in e_time_parse_date_and_time() which means an explosion - of different formats. I don't think the alternatives are that useful, - anyway. - (e_time_parse_date_and_time): parse everything in one go, to avoid - i18n problems. Also only use '%p' if the locale has am/pm strings. - (e_time_parse_time): Only use '%p' if locale has am/pm strings. - -2001-09-17 Ettore Perazzoli <ettore@ximian.com> - - * e-gtk-utils.c (gtk_radio_button_get_nth_selected): Removed. - (gtk_radio_button_select_nth): Removed. - (e_make_widget_backing_stored): New. - -2001-09-13 Jeffrey Stedfast <fejj@ximian.com> - - * e-mktemp.c (e_mktemp_cleanup): Make sure the dir pointer is - non-NULL before using it. - -2001-09-08 Dan Winship <danw@ximian.com> - - * e-html-utils.c (e_text_to_html_full): Fix some broken calls to - check_size that could result in memory corruption displaying short - replies. - -2001-09-06 Dan Winship <danw@ximian.com> - - * e-html-utils.c (e_text_to_html_full): Add E_TEXT_TO_HTML_CITE, - to prepend "> " to each line. - -2001-09-05 Dan Winship <danw@ximian.com> - - * e-mktemp.c (get_path): Fix the check for the case when mkdir() - returns EEXIST to check S_ISDIR on the right structure component. - Fixes bug #8775. - -2001-08-31 Federico Mena Quintero <federico@ximian.com> - - * e-time-utils.c (e_time_parse_date_and_time): Added format for - "7 PM" and equivalents. Fixes bug #7456. - (e_time_parse_time): Likewise. - -2001-08-28 Not Zed <NotZed@Ximian.com> - - * e-categories-master-list-wombat.c (ecmlw_load): Dont call - g_print with a NULL string. See bug #7396. - -2001-08-24 Jeffrey Stedfast <fejj@ximian.com> - - * e-mktemp.c (get_path): Make more robust. - -2001-08-24 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am: Added e-mktemp.[c,h] to the build. - - * e-mktemp.c (e_mktemp): A new wrapper around mktemp so that we - can keep track of temp files for later cleanup. - (e_mkstemp): Same but obviously for the mkstemp call. - (e_mkdtemp): And finally a mkdtemp wrapper. - -2001-08-24 Zbigniew Chyla <cyba@gnome.pl> - - * Makefile.am (libeutil_la_SOURCES): Added e-unicode-i18n.c and - e-unicode-i18n.h. - - * e-unicode-i18n.[ch]: New files with two extra functions - (e_utf8_gettext, e_utf8_dgettext) and U_() macro. - Should be used instead of _() if we need UTF-8 string. - -2001-08-23 Zbigniew Chyla <cyba@gnome.pl> - - * e-request.c (e_request_string): Modified to accept and return - UTF-8 string. It's currently used only in - shell/e-shortcuts-view.c and we need UTF-8 there. - -2001-08-20 Damon Chaplin <damon@ximian.com> - - * e-time-utils.c (e_time_parse_date): added comments to help - translators a bit. - -2001-08-09 Rodrigo Moya <rodrigo@ximian.com> - - * e-categories-config.c (e_categories_config_get_icon_for): return - when there's no icon associated with the category - - * e-categories-config.c: reworked to use the - ECategoriesMasterListWombat class. Also, load correctly images - (fixes #6794) - -2001-08-09 Federico Mena Quintero <federico@ximian.com> - - * e-categories-master-list-wombat.c (ecmlw_destroy): Chain to the - destroy handler in the parent class! - - * e-list-iterator.c (e_list_iterator_destroy): Likewise. Sigh. - - * e-list.c (e_list_destroy): Likewise. Double sigh. - -2001-08-08 Ettore Perazzoli <ettore@ximian.com> - - * e-dialog-utils.h: New. - * e-dialog-utils.c: New. - -2001-08-04 Ettore Perazzoli <ettore@ximian.com> - - * e-bonobo-factory-util.c - (e_bonobo_generic_factory_multi_display_new): New function to - create a factory that creates separate component instances for - different displays. - -2001-08-03 Christopher James Lahey <clahey@ximian.com> - - * e-list-iterator.c (e_list_iterator_next): Made it so that - e_list_iterator_next goes to the first element if it's set to - NULL. This makes deleting the first element and then doing - e_list_iterator_next go to the new first element. Did the analogy - for e_list_iterator_prev for completeness and consistency's sakes. - Fixes Ximian bug #6057. - -2001-08-01 Christopher James Lahey <clahey@ximian.com> - - * e-categories-master-list-wombat.c (ecmlw_load): Fixed the load - statement here by just using array_from_string. - (ecmlw_save): Removed the part where we save the icons and colors - since that's handled in the array_to_string function. Fixes - Ximian bug #4451. - -2001-07-27 JP Rosevear <jpr@ximian.com> - - * e-dbhash.c (string_to_dbt): memset everything to 0 - (md5_to_dbt): ditto - -2001-07-20 Rodrigo Moya <rodrigo@ximian.com> - - * e-categories-config.c (initialize_categories_config): use the 2 - new category icons (16_category_suppliers.png and - 16_category_time-and-expenses.png) - -2001-07-19 Rodrigo Moya <rodrigo@ximian.com> - - * e-categories-config.c (initialize_categories_config): use the 2 - new category icons - - * Makefile.am: s/imagedir/imagesdir - -2001-07-17 Rodrigo Moya <rodrigo@ximian.com> - - * e-categories-config.c (initialize_categories_config): generate - default configuration for icons-per-category the first time. And - use a global (for this file) Bonobo_ConfigDatabase - -2001-07-16 Rodrigo Moya <rodrigo@ximian.com> - - * e-categories-config.c (e_categories_config_get_icon_for): - (e_categories_config_get_icon_file_for): - (e_categories_config_set_icon_file_for): use GdkPixbuf to load images - -2001-07-16 Federico Mena Quintero <federico@ximian.com> - - * e-time-utils.c (parse_with_strptime): Generalized function for - trying a number of strptime() formats on a string. - (e_time_parse_time): Use parse_with_strptime(). - (e_time_parse_date): New function, analogous to the previous one, - but uses a number of date formats. - -2001-07-12 Federico Mena Quintero <federico@ximian.com> - - * e-time-utils.c (e_time_parse_date_and_time): If the string is - empty, clear the struct tm before returning. - -2001-07-12 Jon Trowbridge <trow@ximian.com> - - * e-html-utils.c: Added is_addr_char_no_pipes macro, which specifically - does not consider '|' ("pipe") to be a legal address character. - (email_address_extract): Use is_addr_char_no_pipes when looking for - e-mail addresses to turn into HTML links. (Bug #3940) - -2001-07-05 Not Zed <NotZed@Ximian.com> - - * e-memory.c: Added some malloc check stuff. - -2001-07-04 Rodrigo Moya <rodrigo@ximian.com> - - * e-categories-master-list-wombat.c (ecmlw_load): load all icons - and colors for each category - - (ecmlw_save): save all icons and categories associated with - each category - - * e-categories-config.c: use BonoboConf to store/retrieve settings, - and use ECategoriesMasterListWombat when creating a ECategories - dialog widget - -2001-07-02 Christopher James Lahey <clahey@ximian.com> - - * Makefile.am (libeutil_la_SOURCES): Added - e-categories-master-list-wombat.c and - e-categories-master-list-wombat.h. - (INCLUDES): Added $(BONOBO_CONF_CFLAGS). - - * e-categories-master-list-wombat.c, - e-categories-master-list-wombat.h: New class implementing a master - list that stores its state using bonobo-conf. - -2001-07-02 Rodrigo Moya <rodrigo@ximian.com> - - * e-categories-config.[ch]: new file for a set of functions for - managing category-related (icons, colors) configuration - -2001-07-01 Ettore Perazzoli <ettore@ximian.com> - - * e-request.c: New. - * e-request.h: New. - -2001-06-25 Jeffrey Stedfast <fejj@ximian.com> - - * e-sexp.c (term_eval_and): When ANDing two bools, don't use a - bitwise AND. - -2001-06-18 Dan Winship <danw@ximian.com> - - * Makefile.am: Split e-db3-utils and e-dbhash off into libedb3util - so eutil won't depend on db3. - -2001-06-15 Not Zed <NotZed@Ximian.com> - - * e-sexp.c (parse_values): REmove a silly hardcoded term limit, - oops forgot about that. - -2001-06-11 Damon Chaplin <damon@ximian.com> - - * e-time-utils.c (e_time_parse_date_and_time): skip any non-digits - while looking for dates and times. This should fix some translation - problems. Though there is still a problem with Japanese, where the - am/pm flag comes before the time so we will skip it incorrectly. - -2001-06-10 Damon Chaplin <damon@ximian.com> - - * e-time-utils.c (e_time_parse_date_and_time): - (e_time_parse_time): got rid of '%n' at end of each format string - for strptime. I don't know how I managed to put them in there. - -2001-05-31 Christopher James Lahey <clahey@ximian.com> - - * Makefile.am (INCLUDES): Added db3 cflags. - - * e-dbhash.c: Made this use db3. - - * e-db3-utils.c, e-db3-utils.h: New files with some helper - functions. - -2001-05-27 Dan Winship <danw@ximian.com> - - * e-gui-utils.c: Remove e_pixmaps_update (moved to libeshell) so - libeutil won't depend on bonobo. - -2001-05-19 Ettore Perazzoli <ettore@ximian.com> - - * e-host-utils.c (e_gethostbyname_r) - [HAVE_GETHOSTBYNAME_R && GETHOSTBYNAME_R_FIVE_ARGS]: Set `*herr' - to zero if the function returns a non-NULL pointer to the hostent. - According to the docs, a returned non-NULL hostent always means - "no error" no matter what the returned value of `herr' is. [And - in fact, at least on libc 2.2.3, trying to resolve `localhost' - sets herr to `HOST_NOT_FOUND' even if the name is resolved - correctly and the returned hostent is non-NULL.] - -2001-05-16 Dan Winship <danw@ximian.com> - - * e-html-utils.c (e_text_to_html_full): add - E_TEXT_TO_HTML_ESCAPE_8BIT to turn non-US-ASCII characters into - "?"s. - -2001-05-14 Jon Trowbridge <trow@ximian.com> - - * e-html-utils.c (is_citation): Check for bad utf8. - -2001-05-08 Dan Winship <danw@ximian.com> - - * e-path.c (e_path_find_folders): Walk a hierarchy using the - "/subfolders/" convention and call a callback for each folder - found. - -2001-05-01 Dan Winship <danw@ximian.com> - - * e-msgport.c (e_mutex_assert_locked): Debugging routine. (Only - works for recursive mutexes right now.) - - * e-html-utils.c (e_text_to_html_full): Don't use g_utf8_next_char - on text that isn't valid UTF8, since it won't work (and might even - get into an infinite loop). - -2001-04-29 Dan Winship <danw@ximian.com> - - * e-html-utils.c (email_address_extract): Make this smarter. Now - e_text_to_html_full calls it when it sees a '@', and - email_address_extract deals with scanning both forward and - backward to find the bounds of the email address. It's still - fooled by Message-IDs, but there's not a whole lot we can do - there... - -2001-04-26 Dan Winship <danw@ximian.com> - - * e-host-utils.c (e_gethostbyname_r): Make the Solaris and - no-gethostbyname_r implementations behave more like the Linux one. - Document. - - * Makefile.am (INCLUDES): Remove UNICODE_CFLAGS - (libeutil_la_LIBADD): Change UNICODE_LIBS to GAL_LIBS - -2001-04-26 Not Zed <NotZed@Ximian.com> - - * e-memory.c (e_poolv_get): Modified to match e_strv_get - behaviour. Assert on bad cases, and return "" rather than NULL - for empty/unset strings. - (e_poolv_new): Simplify the mutex cases, only have a single mutex - for mempool and hashtable references. - (e_poolv_set): Simplify mutex code. Fixed a #ifdef orde prob in - profile stuff. Always copy string to our own memory when we add - it to the hash, even if we free it; I think this would have led to - dangling references otherwise. - (e_poolv_destroy): Renamed from poolv_free, for consistency with - the rest of the allocators here. - (e_poolv_set): Add optional refcounting code here, not currently - enabled/used, but should make proper string collection work - easily. - (e_poolv_destroy): Unrefcount the strings here. - (e_poolv_cpy): Add refcounting code here. - - * e-memory.[ch]: Applied Jacob's patches <jacob@ximian.com> for - 'e-poolv' type, added his name to the authors list. - -2001-04-24 Dan Winship <danw@ximian.com> - - * e-html-utils.c (check_size): If the buffer is too small, making - it twice as big does not guarantee it will be big enough. "Duh". - Also, a bunch of the check_size calls don't seem to be taking - trailing NULs into account, so add in a +1 here. - -2001-04-24 Kjartan Maraas <kmaraas@gnome.org> - - * e-gui-utils.c, e-memory, e-msgport.c, e-pilot-map, e-sexp.c: - Added #include <glib.h> and move corresponding local headers - to the top to catch missing includes in them. Tip from clahey. - -2001-04-24 Chris Toshok <toshok@ximian.com> - - * e-host-utils.h: remove prototype for e_gethostbyname_init. - - * e-host-utils.c (e_gethostbyname_r): don't dynamically allocate - anything - store everything in the buffer that's passed in. Also, - stop using EMutex. Switch to a static GMutex (so we can - initialize it without having e_gethostbyname_init). - (e_gethostbyname_init): removed. - -2001-04-23 Jon Trowbridge <trow@ximian.com> - - * e-html-utils.c (e_text_to_html_full): Removed attempts to use - Radek's evil <DATA> hacks, which were just causing me - (and GtkHTML) grief. - -2001-04-23 Jon Trowbridge <trow@ximian.com> - - * e-host-utils.c: Include glib.h, so that the g_warning in - e_gethostbyname_r will be treated as a macro and not as an - unresolved symbol. - -2001-04-22 Chris Toshok <toshok@ximian.com> - - * Makefile.am (libeutil_la_SOURCES): add e-host-utils.[ch] - - * e-host-utils.c: new file, with e_gethostbyname_r. - - * e-host-utils.h: new file. - -2001-04-19 Dan Winship <danw@ximian.com> - - * e-html-utils.c (is_citation): ">From" is not a citation unless - the previous or following line is a citation. - (e_text_to_html_full): Update for is_citation change. Also, when - marking citations, unmangle mbox From-mangling. - -2001-04-15 Federico Mena Quintero <federico@ximian.com> - - * e-sexp.c (e_sexp_parse): Start parsing the sexp with - parse_value(), not parse_list(), because we may have immediate - values (e.g. "#f") as the whole sexp. - -2001-04-08 JP Rosevear <jpr@ximian.com> - - * Makefile.am: Setup up the conduit library building better so the - files get disted - -2001-04-06 Federico Mena Quintero <federico@ximian.com> - - * e-sexp.c (scanner_config): Added a question mark to the set of - valid characters for symbol names. - (parse_value): Fixed parsing of boolean values. - (parse_term_free): Added missing clause for ESEXP_TERM_BOOL. - -2001-04-04 Kjartan Maraas <kmaraas@gnome.org> - - * ename/test-ename-western-gtk.c: Fix headers. - -2001-04-03 Federico Mena Quintero <federico@ximian.com> - - * e-sexp.h (ESExpResultType): Added ESEXP_RES_TIME for time - values. - (ESExpResult): Added a "time_t value.time" field. - (ESExpTermType): Added ESEXP_TERM_TIME. - (ESExpTerm): Added a "time_t value.time" field. - - * e-sexp.c (e_sexp_result_free): Deal with time values. Also, be - more paranoid; added a default clause with g_assert_not_reached(). - (term_eval_lt): Deal with time values. - (term_eval_gt): Likewise. - (term_eval_eq): Likewise. - (term_eval_plus): Likewise. - (term_eval_sub): Likewise. - (e_sexp_term_eval): Likewise. - (eval_dump_result): Likewise. - (parse_dump_term): Likewise. - (parse_term_free): Likewise. - -2001-04-01 Gediminas Paulauskas <menesis@delfi.lt> - - * e-gui-utils.h: new type EPixmap, which is used to cache pixmaps for - bonobo components. use e_pixmaps_update to load icons into ui - component. - * e-gui-utils.c: implementation of EPixmap cache, moved here from - mail/folder-browser-factory.c. - -2001-03-31 Jon Trowbridge <trow@ximian.com> - - * e-url.c (e_url_shroud): Check that first_colon < last_at, - to prevent horrible things from happening. Removed spew. - (e_url_equal): Removed spew. - -2001-03-30 Jon Trowbridge <trow@ximian.com> - - * e-html-utils.c (e_text_to_html_full): Add support for converting - e-mail addresses to links. - (is_email_address): Added. Identifies e-mail addresses. - (email_address_extract): Added. Extracts a copy of the e-mail - address from the text. - - * e-html-utils.h (E_TEXT_TO_HTML_CONVERT_ADDRESSES): Added. - - * e-url.c (e_url_shroud): Added. Copy a url, replacing - any plaintext passwords with a single *. - (e_url_equal): Compare two urls, taking into account that - they may or may not be shrouded. - -2001-03-29 Kjartan Maraas <kmaraas@gnome.org> - - * e-corba-utils.h: Remove #include <glib.h> - * e-dialog-widgets.c: Shuffle some headers. - * e-dialog-widgets.h: Remove #include <libgnomeui/gnome-propertybox.h> - * e-gtk-utils.c: #include <gtk/gtksignal.h> - * e-gtk-utils.h: Replace #include <gtk/gtk.h> - * e-gui-utils.c: Replace #include <gnome.h> - * e-html-utils.c: Shuffle headers. - * e-iterator.c: Replace #include <gtk/gtk.h> - * e-iterator.h: Replace #include <gtk/gtk.h> - * e-list-iterator.c: Remove #include <gtk/gtk.h> - * e-list-iterator.h: Replace #include <gtk/gtk.h> - * e-list.c: Remove #include <gtk/gtk.h> - * e-list.h: Replace #include <gtk/gtk.h> - * e-memory.c: #include <string.h> and <stdlib.h> - * e-msgport.c: Move around some includes. s/%d/%ld/g in a printf() - call to fix a warning. - * e-pilot-map.c: #include <string.h>. Replace #include <gnome.h> - * e-pilot-util.c: Remove #include <gnome.h> - * e-sexp.c: Remove #include <glib.h> - * e-sexp.h: Replace #include <gtk/gtk.h> - * e-time-utils.c: #include <string.h> - * md5-utils.c: Shuffle headers. - * test-ename-western-gtk.c: Replace #include <gnome.h> - * test-ename-western.c: Same here. - -2001-03-20 Radek Doulik <rodo@ximian.com> - - * e-html-utils.c (e_text_to_html_full): new function, extracted - from e_text_to_html, added color parameter - -2001-03-19 Radek Doulik <rodo@ximian.com> - - * e-html-utils.c (e_text_to_html): support mark citation - - * e-html-utils.h (E_TEXT_TO_HTML_MARK_CITATION): added - E_TEXT_TO_HTML_MARK_CITATION - -2001-03-18 Damon Chaplin <damon@ximian.com> - - * e-time-utils.c (e_time_format_time): added function to format just - the time. - -2001-03-16 Dan Winship <danw@ximian.com> - - * e-path.c (e_path_to_physical): Fix a bug noticed by kmaraas - -2001-03-15 Dan Winship <danw@ximian.com> - - * e-html-utils.c (url_extract): Fix a bit: [mailto:foo] shouldn't - grab the ']' - -2001-03-12 JP Rosevear <jpr@ximian.com> - - * Makefile.am: update cflag macros - -2001-03-07 Dan Winship <danw@ximian.com> - - * e-html-utils.c (url_extract): Fix an off-by-one in the "is this - for real?" check so that "http:// " won't get URLified - -2001-03-04 Damon Chaplin <damon@ximian.com> - - * e-time-utils.[hc]: new files to contain functions to parse and - format dates and times for various calendar widgets. - -2001-03-01 Dan Winship <danw@ximian.com> - - * e-path.c (e_path_to_physical): New function to turn foo/bar into - foo/subfolders/bar. The inverse function doesn't exist yet because - I didn't need it. Also, if the shell were going to use this, we'd - need a few more tools... - - * Makefile.am (libeutil_la_SOURCES): Add e-path.[ch] - -2001-03-01 Not Zed <NotZed@Ximian.com> - - * e-sexp.c (e_sexp_encode_string): Make it handle a NULL string as - an empty string. - -2001-02-23 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (e_thread_destroy): Wait a lot lot longer for - threads to finish. - : Turned off some of the debug. - -2001-02-08 Not Zed <NotZed@Ximian.com> - - * e-memory.c (EMemChunk): Changed to allocate raw blocks for the - data, and keep track of them with an array, this is so the native - malloc alignment is not lost at the allocation stage. - -2001-01-30 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (e_thread_destroy): Turn on joining of cancelled threads. - (e_msgport_wait): Put a cleanup handler to clear the mp lock if it - happens in cond_wait, since it will be locked again. - -2001-01-29 Not Zed <NotZed@Ximian.com> - - * e-msgport.c (e_thread_put): If we have waiting threads, then - dont start a new one for the NEW case. - (thread_dispatch): For the NEW case, dont exit, just keep running, - waiting for a new message to come along. - (e_thread_destroy): When cleaning up NEW threads, cancel any - non-busy threads. - -2001-01-24 Not Zed <NotZed@Ximian.com> - - * e-sexp.h (ESExp): Add chunk allocators. - - * e-sexp.c: Removed some redundant debug printfs. - (e_sexp_term_eval): Dont allocate result till we have it. so we - can have a fatal error, and not leak it. - (term_eval_plus): If we have to abort, free our arguments. - (term_eval_sub): Same. - (parse_new_term): Renamed to parse_term_new for consistency. - Fixed callers. - (e_sexp_result_new): Add the esexp as an argument. Ouch, lots of - code to change for this. Allocate blocks from an ememchunk. - Fixed all callers. - (e_sexp_result_free): Same as above, free blocks from the - ememchunk. Fixed all callers. - (parse_term_new): - (parse_term_free): Similarly, add the esexp to the argument, and - alloc/free from memchunks. Fixed all local callers. - (e_sexp_init): Setup the memory chunk allocators. - (e_sexp_finalise): Destroy memchunk allocators. - -2001-01-23 Not Zed <NotZed@Ximian.com> - - * e-sexp.c (e_sexp_parse): Setup error return and return error on - parse error. - (parse_list): Fail if we have a problem. - (parse_value): Here too. - (fatal_error): Fatal error handling function, jumps back to the - top caller. - (term_eval_and): - (e_sexp_term_eval): - (term_eval_sub): - (term_eval_plus): - (term_eval_gt): - (term_eval_lt): - (term_eval_or): Fail on error. - (e_sexp_term_eval): Added a comment about where this can be - called, which is only from inside e_sexp_eval(). - (e_sexp_eval): Setup setjmp error handler. - (e_sexp_error): Error accessor function. - - * e-sexp.h: Added a longjmp environment to the structure, and an - error return to parse. - -2001-01-22 JP Rosevear <jpr@ximian.com> - - * e-dbhash.c (md5_to_dbt): New function, can't use strlen on the md5 - hash because it might have null chars in it. - (e_dbhash_add): use md5_to_dbt - -2001-01-19 JP Rosevear <jpr@ximian.com> - - * e-pilot-map.c (e_pilot_map_remove_by_pid): Remove an item by pid - (e_pilot_map_remove_by_uid): ditto for uid - - * e-pilot-map.h: new protos - -2001-01-17 Jason Leach <jasonleach@usa.net> - - * e-gtk-utils.c (gtk_radio_button_get_nth_selected): New function, - name describes it well. - (gtk_radio_button_select_nth): New function. - -2001-01-17 Federico Mena Quintero <federico@ximian.com> - - * e-dialog-widgets.[ch]: Ximianified. - -2001-01-15 JP Roseveaer <jpr@ximian.com> - - * e-pilot-util.c (e_pilot_utf8_from_pchar): Dup the string passed - in, not the temporary string. d'oh. - -2001-01-04 Dan Winship <danw@helixcode.com> - - * e-msgport.c: #define E_THREAD_NONE as ((pthread_t)~0) and use - that instead of ~0 throughout. (pthread_t is a pointer type on my - system, so there are lots of warnings without the cast.) - -2000-12-24 Not Zed <NotZed@HelixCode.com> - - * Merge from camel-mt-branch. - -2000-12-20 JP Rosevear <jpr@helixcode.com> - - * e-pilot-util.c (e_pilot_utf8_to_pchar): Check for null strings - (e_pilot_utf8_from_pchar): ditto - -2000-12-19 JP Rosevear <jpr@helixcode.com> - - * e-pilot-util.c (e_pilot_utf8_to_pchar): Convert utf8 strings to - pilot character set - (e_pilot_utf8_from_pchar): vice versa - - * Makefile.am: Conditionally build e-pilot-util.[hc] because - they depend on pilot-link stuff - -2000-12-23 Not Zed <NotZed@HelixCode.com> - - * e-msgport.c (e_dlist_length): Util function. - (e_thread_new): Another new thread primitive. This one is a - re-usable 'server thread' thingy. - -2000-12-21 Not Zed <NotZed@HelixCode.com> - - * Makefile.am (libeutil_la_SOURCES): Added msgport stuff. - - * e-msgport.[ch]: Some thread primitives. e_dlist, a - double-linked list (ok, not a thread primitive, but used in ...), - e_msgport - an asynchronous, non-copying message passing - rendesvous port, and e_mutex, a portably configurable mutex. - -2000-12-19 Not Zed <NotZed@HelixCode.com> - - * e-sexp.c: Make the code compile without being a gtk object (the - old code can still be built as a gtk object if required). Also - removed some dead code. - (e_sexp_ref): New function to ref if we're not a gkt object. - (e_sexp_unref): Same for unref. - -2000-12-13 Larry Ewing <lewing@helixcode.com> - - * e-html-utils.c (e_text_to_html): make sure we actually make - enough space for " ". - -2000-12-08 Federico Mena Quintero <federico@helixcode.com> - - * e-dialog-widgets.c (e_dialog_editable_get): Updated - documentation comment. - -2000-12-04 Ettore Perazzoli <ettore@helixcode.com> - - * e-corba-utils.h: New. - - * e-corba-utils.c: New. - (e_safe_corba_string): New. - -2000-11-30 Not Zed <NotZed@HelixCode.com> - - * e-memory.c (e_strv_new): Fix typename of args (for all funcs). - (e_strv_set_ref): Assert the index is in range. - (e_strv_set_ref_free): " - (e_strv_set): " - (e_strv_get): " - -2000-11-29 Not Zed <NotZed@HelixCode.com> - - * e-sexp.c (term_eval_lt): Plug a memleak, need to free results - from term_eval(). - (term_eval_gt): - (term_eval_eq): - -2000-11-27 Not Zed <NotZed@HelixCode.com> - - * e-memory.c (e_mempool_new): Added some locking to global data. - This should make the interfaces mt-safe, although each object is - only per-thread safe. - -2000-11-22 Not Zed <NotZed@HelixCode.com> - - * e-memory.c (e_mempool_alloc): If we dont get a big enough chunk - in the first node, give up. Otherwise we spend too much time - searching. - (e_mempool_strdup): Doh, and allocate enough for the terminating - NUL at that. - (e_strv_set_ref_free): New function, set a reference to a string - that is then owned/free'd by the strv. - (e_strv_destroy): If there are any strings to destroy, free them - here. - -2000-11-21 Not Zed <NotZed@HelixCode.com> - - * e-memory.c (e_memchunk_alloc0): New function to allocate a - zero'd out chunk. - (e_mempool_strdup): New function to strdup into a mempool. - -2000-11-20 Not Zed <NotZed@HelixCode.com> - - * e-memory.[ch]: New routines for fast memory management and - compact string array storage. - - * Makefile.am (libeutil_la_SOURCES): Added e-memory.[ch]. - -2000-11-09 JP Rosevear <jpr@helixcode.com> - - * e-dbhash.h: oops thats func not *func - - * e-dbhash.c (e_dbhash_foreach_key): Memset the data DBT to 0 - -2000-11-07 JP Rosevear <jpr@helixcode.com> - - * Makefile.am: Build e-dbhash.[hc] - - * e-dbhash.[hc]: New routines to manage a db database on disk that - contains md5 hashed data and indexed by uids. Provides comparison - functions and such so the caller does not have to do the md5 bits. - -200-10-30 Kjartan Maraas <kmaraas@gnome.org> - - * e-dialog-widgets.c: #include <string.h> to quench warning. - * e-sexp.c: #include <stdlib.h> for same reason. - -2000-10-27 <jpr@helixcode.com> - - * Makefile.am: build md5-utils - - * md5-utils.c: Make part of util, get rid of camel stream util - function include string.h - - * md5-utils.h: ditto - -2000-10-27 <jpr@helixcode.com> - - * e-pilot-map.c (e_pilot_map_lookup_uid): Return null if no - pnode was found. - -2000-10-27 JP Rosevear <jpr@helixcode.com> - - * e-pilot-map.c (map_sax_start_element): Get archive field while - parsing - (map_write_foreach): Write out archive field - (e_pilot_map_pid_is_archived): implement - (e_pilot_map_uid_is_archived): ditto - (e_pilot_map_insert): Insert new node structures - (e_pilot_map_lookup_pid): Take into account the list is now - a list of structures - (e_pilot_map_lookup_uid): ditto - -2000-10-26 Michael Meeks <michael@helixcode.com> - - * ename/e-address-western.c (e_address_western_is_postal): - unsigned chars. - - * ename/e-name-western.c (e_name_western_get_one_prefix_at_str): - cast to unsigned char. - -2000-10-25 Dan Winship <danw@helixcode.com> - - * e-html-utils.c (e_text_to_html): Deal properly with URLs at the - end of the buffer. (The old code would append a "�" to the - text.) - -2000-10-23 JP Rosevear <jpr@helixcode.com> - - * e-pilot-map.c (e_pilot_map_lookup_pid): Lookup a pid by uid. - (e_pilot_map_lookup_uid): Lookup a uid by pid. - Now this is wrapped, we can store archive info internally - - * e-pilot-map.h: New accessor prototypes - -2000-10-23 Dan Winship <danw@helixcode.com> - - * ename/Makefile.am (INCLUDES): Remove unused GNOMELOCALEDIR - setting. - -2000-10-23 JP Rosevear <jpr@helixcode.com> - - * e-pilot-map.c: Operate with EPilotMap structure so things are - abstract to the caller - (e_pilot_map_pid_is_archived): Infrastructure for marking records - as archived - (e_pilot_map_uid_is_archived): ditto - - * e-pilot-map.h: Add more to public interface, including EPilotMap - structure - -2000-10-23 JP Rosevear <jpr@helixcode.com> - - * e-pilot-map.c: Pilot map functions grabbed from existing conduits - - * e-pilot-map.h (e_pilot_map_write): Header - -2000-10-18 Dan Winship <danw@helixcode.com> - - * e-html-utils.c (e_text_to_html): If unicode_get_utf8 returns -1, - assume it was actually undeclared iso-8859-1 text. - -2000-10-17 Jesse Pavel <jpavel@helixcode.com> - - * ename/e-address-western.c: made the routines use the stardard - e_strstrcase instead of the included function that existed - earlier. - -2000-10-11 Iain Holmes <iain@helixcode.com> - - * ename/e-address-western.c (e_address_western_parse): g_strconcat - needs to be NULL terminated or it goes funny. - -Tue Sep 26 16:48:49 2000 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Added $(EXTRA_GNOME_CFLAGS). - -2000-09-25 Jeffrey Stedfast <fejj@helixcode.com> - - * Makefile.am: add ename as a SUBDIR - -2000-09-18 Christopher James Lahey <clahey@helixcode.com> - - * e-list-iterator.c, e-list.c, e-list.h: Made e_list a bit more - reentrant. If a iterator gets its data pulled out from under it - while in a loop, it goes back one so that loops will be able to - continue. - -2000-09-18 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Removed all the files moved to gal. - - * e-dialog-widgets.c: Fixed the #include lines to deal properly - with gal. - - * e-gui-utils.c, e-gui-utils.h: Removed all of the functionality - that was moved to gal. - - * e-canvas-utils.c, e-canvas-utils.h, e-canvas-vbox.c, - e-canvas-vbox.h, e-canvas.c, e-canvas.h, e-cursors.c, e-cursors.h, - e-font.c, e-font.h, e-popup-menu.c, e-popup-menu.h, e-printable.c, - e-printable.h, e-unicode.c, e-unicode.h, e-util.c, e-util.h, - e-xml-utils.c, e-xml-utils.h: Moved to gal. - -2000-09-13 Christopher James Lahey <clahey@helixcode.com> - - * e-font.c: Fixed an uninitialized variable. - -2000-09-12 Lauris Kaplinski <lauris@helixcode.com> - - * e-unicode.c (e_utf8_to_gtk_string_sized): Use underscores - for untranslatable characters - (e_utf8_from_gtk_string_sized): Ditto - -2000-09-12 Dan Winship <danw@helixcode.com> - - * e-font.c (e_font_from_gdk_font): Change this a bit so that if - you pass it a bold font, it puts that in font->bold and finds a - lighter font for font->font (if it can). This is for themes like - Metal where the default font is bold. - (find_variants): renamed from find_best_bold - -2000-09-11 Dan Winship <danw@helixcode.com> - - * e-font.c (find_best_bold): Thou shalt leave space for the - trailing \0. - - * e-util.c (e_strstrcase): The return value should not be - const. (Well, unless the input was, but you can't know that.) - -2000-09-11 Christopher James Lahey <clahey@helixcode.com> - - * e-unicode.c, e-unicode.h: Added e_utf8_gtk_editable_get_text and - e_utf8_gtk_editable_set_text. - -2000-09-11 Lauris Kaplinski <lauris@helixcode.com> - - * e-font.c: Try to find real bold variant of X font, fall - to double stroke only if not found - -2000-09-10 Ettore Perazzoli <ettore@helixcode.com> - - * e-gtk-utils.c: New. - (e_gtk_signal_connect_full_while_alive): New. - - * e-gtk-utils.h: New. - -2000-09-08 Lauris Kaplinski <lauris@helixcode.com> - - * e-font.c: Use experimental 16-bit font stuff for EFonts - -2000-09-08 Dan Winship <danw@helixcode.com> - - * e-popup-menu.h: remove consts from the EPopupMenu structure: the - caller may want to modify its own EPopupMenu before calling - e_popup_menu_run. - -2000-09-07 Lauris Kaplinski <lauris@helixcode.com> - - * e-dialog-widgets.c (e_dialog_editable_get): Use UTF-8 - (e_dialog_editable_set): Use UTF-8 - - * e-font.c (translate_encoding): More encodings - (e_gdk_font_encoding): Use experimental stuff - - * e-unicode.* (e_utf8_gtk_editable_insert_text): New wrapper - -2000-09-07 Federico Mena Quintero <federico@helixcode.com> - - * e-canvas.c (emit_event): Remove incorrect optimization. Events - are read-only! - -2000-09-04 Lauris Kaplinski <lauris@helixcode.com> - - * e-unicode.c: Added new font code, but comment it out now - * e-font.h, e-font.c: Test code for font analyzing - -2000-09-02 Lauris Kaplinski <lauris@helixcode.com> - - * e-unicode.h, e-unicode.c: New functions - e_utf8_gtk_clist_append, e_utf8_gtk_clist_set_text - e_unicode_init - -2000-08-31 Lauris Kaplinski <lauris@helixcode.com> - - * e-html-utils.c (e_text_to_html): Use UTF-8 - - * e-unicode.h: - * e-unicode.c (g_unichar_to_utf8): glib 1.3 function - (gdk_keyval_to_unicode): gdk 1.3 function - (e_utf8_from_gdk_event_key): Use keyval, not string - -2000-08-30 Lauris Kaplinski <lauris@helixcode.com> - - * e-unicode.h: #define gnome_font_get_size and - gnome_font_get_width, and gnome_font_lookup_default, - if compiling with gnome-print 0.20 - -2000-08-30 Dan Winship <danw@helixcode.com> - - * Makefile.am (libeutil_la_LIBADD): make e-util depend on - libunicode - - * e-popup-menu.c (make_item): Use GtkMenuItem rather than - GtkPixmapMenuItem for items with no pixmaps, so that if the whole - menu is pixmapless, you don't get a column of blank pixmaps. - -2000-08-24 Lauris Kaplinski <lauris@helixcode.com> - - * e-unicode.h: - * e-unicode.c (e_utf8_gtk_menu_item_new_with_label): New wrapper - -2000-08-23 Lauris Kaplinski <lauris@helixcode.com> - - * e-unicode.h: - * e-unicode.c (e_utf8_strstrcase): New function - -2000-08-23 Federico Mena Quintero <federico@helixcode.com> - - * e-dialog-widgets.c (e_dialog_editable_set): Constify. - -2000-08-22 Lauris Kaplinski <lauris@helixcode.com> - - * e-unicode.h: - * e-unicode.c: e_utf8_gtk_editable_get_chars - e_utf8_gtk_entry_get_text - e_utf8_gtk_entry_set_text - e_utf8_to_gtk_string: New convenience functions - -2000-08-22 Lauris Kaplinski <lauris@helixcode.com> - - * e-unicode.h: - * e-unicode.c: Some convenience functions to deal with Gtk+ and UTF-8 - - * Makefile.am: Added e-unicode.h, e-unicode.c - -2000-08-21 Lauris Kaplinski <lauris@helixcode.com> - - * e-font.h: - * e-font.c: Changed UTF-8 syntax from char-based to byte-based - -2000-08-21 Peter Williams <peterw@helixcode.com> - - * e-html-utils.c (e_text_to_html): Fix a booboo in the tab - expansion code (didn't use the new value of 'out'). - -2000-08-19 Lauris Kaplinski lauris@helixcode.com - - * e-font.h: #define e_font_height(f) to save some space - -2000-08-19 Lauris Kaplinski lauris@helixcode.com - - * e-font.h: - * e-font.c: Thin wrapper around GdkFont to deal with UTF-8 directly - Also handles bold/italic styling - -2000-08-14 Peter Williams <peterw@helixcode.com> - - * e-sexp.c (scanner_config): Add "-" to be an acceptable - first character for an operation -- yaaay subtraction! - -2000-08-11 Peter Williams <peterw@helixcode.com> - - * e-html-utils.c (e_text_to_html): Fix the tab expansion - for when the length would exceed the ten characters that - we allocated. - -2000-08-10 Dan Winship <danw@helixcode.com> - - * e-setup.[ch]: Remove. The shell tells the components where - the evolution homedir is now. - - * Makefile.am (libeutil_la_SOURCES): Remove e-setup.c - - * e-html-utils.c (e_text_to_html): If converting both spaces and - newlines, then convert tabs too. The joys of pseudo-<PRE>. - -2000-08-09 Christopher James Lahey <clahey@helixcode.com> - - * e-popup-menu.c: Fix the bug where it truncates the last item - -2000-08-09 Christopher James Lahey <clahey@helixcode.com> - - * e-popup-menu.c: Ooops. - -2000-08-09 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c, e-util.h: Added uncompiled e_read_uri function. - -2000-08-09 Christopher James Lahey <clahey@helixcode.com> - - * e-popup-menu.c, e-popup-menu.h: Added a hide_mask argument to - the two popup menu functions. - -2000-08-07 Christopher James Lahey <clahey@helixcode.com> - - * e-gui-utils.c, e-gui-utils.c: Added - e_container_change_tab_order. - -2000-07-27 Peter Williams <peterw@helixcode.com> - - * e-canvas.c (e_canvas_destroy): Chain the - destroy handler. - -2000-07-25 Peter Williams <peterw@helixcode.com> - - * e-canvas.c (emit_event): Don't bother with - dereferencing the event pointer. - (e_canvas_item_set_cursor): Reference our selection - item; print a debug message. Deref when destroying - (e_canvas_item_add_selection): Same. - (e_canvas_item_remove_selection): Same. - -2000-07-25 Peter Williams <peterw@helixcode.com> - - * Makefile.am (libeutil_static_la_LDFLAGS): Build both libraries - (a typo didn't build libeutil.la, only -static.) - -2000-07-25 Seth Alves <alves@hungry.com> - - * Makefile.am (libeutil_static_la_LDFLAGS): build static version - of library for conduit to use - -2000-07-25 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c, e-util.h: Added a bunch of e_marshal functions. - -2000-07-12 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c, e-util.h: Added e_strstrcase function. - -2000-07-11 Christopher James Lahey <clahey@helixcode.com> - - * e-canvas-vbox.c: Removed some debugging printfs. - - * e-canvas.c (e_canvas_unrealize): Call parent unrealize method. - -2000-07-10 Ettore Perazzoli <ettore@helixcode.com> - - * e-sexp.c (eval_dump_result): `#if 0'ed out. - - * e-popup-menu.h (e_popup_menu_create): New prototype. - -2000-07-10 Dan Winship <danw@helixcode.com> - - * e-html-utils.c: Fix warnings. - -2000-07-08 Christopher James Lahey <clahey@helixcode.com> - - * e-list.c, e-list.h: Added e_list_duplicate. - -2000-07-07 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c, e-util.h: Added e_strsplit to work around a bug in - g_strsplit. - -2000-07-07 Christopher James Lahey <clahey@helixcode.com> - - * e-iterator.c, e-iterator.h, e-list-iterator.c, - e-list-iterator.h: Added last and insert functions. - -2000-07-06 Federico Mena Quintero <federico@helixcode.com> - - * e-dialog-widgets.c: Added docstrings. This file did not have - them at all. EEEEEEK! - -2000-07-05 Dan Winship <danw@helixcode.com> - - * e-sexp.c (e_sexp_parse): Kill debugging message - -2000-07-03 Christopher James Lahey <clahey@helixcode.com> - - * e-iterator.c, e-iterator.h, e-list-iterator.c, - e-list-iterator.h, e-list.c, e-list.h: New list class with - iterators. - - * e-canvas.c: Made it so that you don't get the same selection in - the selection list more than once. - -2000-07-01 Ettore Perazzoli <ettore@helixcode.com> - - * e-gui-utils.h: #include <libgnomeui/gnome-messagebox.h>. It's - needed to be able to pass an appropriate @type arg to - `e_notice()'. - -2000-06-29 Jody Goldberg <jgoldberg@home.com> - - * e-canvas.c (e_canvas_init) : Init the InputContext members - (e_canvas_class_init) : Add a handler for unrealize. - (e_canvas_focus_in) : enable the input context. - (e_canvas_focus_out) : enable the input context. - (e_canvas_realize) : Create an input context. - (e_canvas_unrealize) : New function to release the input context. - -2000-06-28 Dan Winship <danw@helixcode.com> - - * e-html-utils.c (url_extract): add ")" to the set of characters - to back up over at the end of a potential URL. - -2000-06-27 Ettore Perazzoli <ettore@helixcode.com> - - * e-dialog-widgets.c (get_toggle_value): Use `value_var', not - `value'. - -2000-06-27 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am (INCLUDES): `-I$(top_srcdir)' to fix compilation - with builddir != srcdir. - -2000-06-26 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Added e-canvas-vbox.c and e-canvas-vbox.h. - - * e-canvas-vbox.c, e-canvas-vbox.h: New canvas object to act like - a vbox using the reflow system. - -2000-06-20 Christopher James Lahey <clahey@helixcode.com> - - * e-canvas.c, e-canvas.h: Added a variable to keep track of the - cursor. Set the cursor when selection_add is called. Properly - unset the cursor at the right times. - -2000-06-20 Christopher James Lahey <clahey@helixcode.com> - - * e-canvas.c: Grab the focus when setting the cursor. - -2000-06-20 Christopher James Lahey <clahey@helixcode.com> - - * e-canvas.c, e-canvas.h: Built a system for doing selections - and/or a cursor in canvas. - -2000-06-13 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c, e-util.h: Changed the needed e_marshal functions. - - * e-printable.c, e-printable.h: Added a quantize parameter to - e_printable_height. Also, added a e_printable_will_fit function. - -2000-06-10 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Added e-printable.c and e-printable.h. - - * e-printable.c, e-printable.h: This new class is a printing - context. Other classes return an EPrintable which represents a - context for printing that object. - - * e-util.c, e-util.h: Added - e_marshal_NONE__OBJECT_DOUBLE_DOUBLE_BOOL and - e_marshal_DOUBLE__OBJECT_DOUBLE_DOUBLE. - -2000-06-01 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c: Fixed e_marshal_INT__INT_INT_POINTER. - -2000-06-01 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c, e-util.h: Added e_marshal_INT__INT_INT_POINTER. - -2000-06-01 Dan Winship <danw@helixcode.com> - - * e-util.c (g_int_compare): Duh! -1 != 1. :) - -2000-06-01 Christopher James Lahey <clahey@helixcode.com> - - * e-sexp.c (e_sexp_term_eval): g_return_val_if_fail to prevent a crash. - -2000-05-30 Not Zed <NotZed@HelixCode.com> - - * e-sexp.c (e_sexp_encode_bool): Utility function to build a bool - as part of an expression string. - (e_sexp_encode_string): Likewise for strings. - -2000-05-30 Christopher James Lahey <clahey@helixcode.com> - - * e-canvas-utils.c, e-canvas-utils.h: Added - e_canvas_item_show_area which makes sure that a particular area of - a given item is in the scroll area. - -2000-05-30 Federico Mena Quintero <federico@helixcode.com> - - * e-dialog-widgets.c (hook_radio): Use the exported function to - set the value. - (get_radio_value): Likewise. - (hook_option_menu): Likewise. - (get_option_menu_value): Likewise. - (hook_toggle): Likewise. - (get_toggle_value): Likewise. - (hook_spin_button): Likewise. - (get_spin_button_value): Likewise. - (hook_editable): Likewise. - (get_editable_value): Likewise. - (e_dialog_radio_set): Radio buttons are prepended to their parent - group's list, so we need to flip the index around when - getting/setting the value. - (e_dialog_radio_get): Likewise. - -2000-05-27 Federico Mena Quintero <federico@helixcode.com> - - * e-dialog-widgets.c (e_dialog_editable_set): Moved over from - event-editor-utils.c. - (e_dialog_editable_get): Likewise. - (e_dialog_toggle_set): Likewise. - (e_dialog_toggle_get): Likewise. - (e_dialog_spin_set): Likewise. - (e_dialog_spin_get_double): Likewise. - (e_dialog_spin_get_int): Likewise. - (e_dialog_option_menu_set): Likewise, and added a value map. - (e_dialog_option_menu_get): Likewise. - (e_dialog_dateedit_set): Likewise. - (e_dialog_dateedit_get): Likewise. - (e_dialog_radio_set): New function. - (e_dialog_radio_get): New function. - -2000-05-24 Christopher James Lahey <clahey@helixcode.com> - - * e-paned.c, e-paned.h: Removed. - -2000-05-23 Federico Mena Quintero <federico@helixcode.com> - - * e-dialog-widgets.c (get_radio_value): Implemented. Amazing that - one has to go through so much pain to get a stupid value from - GTK+. - (hook_option_menu): Implemented. Same complaint. - (get_toggle_value): Implemented. - (get_spin_button_value): Implemented. - (get_entry_value): Implemented. - (e_dialog_widget_hook_value): Function to hook a widget to the - variable it will modify. - (e_dialog_get_values): Function to feed the variables from a - dialog's widgets. - (e_dialog_xml_widget_hook_value): Function to hook a widget from - a Glade file. - -2000-05-23 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c, e-util.h: Added e_write_file. - -2000-05-19 Federico Mena Quintero <federico@helixcode.com> - - * e-dialog-widgets.[ch]: New files with utilities for hooking up - widgets in Glade-generated dialogs. - - * Makefile.am (libeutil_la_SOURCES): Added e-dialog-widgets.[ch]. - -2000-05-19 Christopher James Lahey <clahey@helixcode.com> - - * e-gui-utils.c, e-gui-utils.h: Added e_container_foreach_leaf. - -2000-05-18 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Add imagesdir support. - - * e-gui-utils.c, e-gui-utils.h: Added e_create_image_widget for - glade use. - -2000-05-16 Christopher James Lahey <clahey@helixcode.com> - - * e-xml-utils.c: xmlGetProp appears to return malloced memory. - Thus we must free it. - -2000-05-15 Ettore Perazzoli <ettore@helixcode.com> - - * e-util.c (e_free_string_list): New function. - -2000-05-14 Christopher James Lahey <clahey@helixcode.com> - - * e-util.c, e-util.h: Added e_strdup_strip which returns a copy of - the string with the leading and trailing spaces removed. - -2000-05-11 NotZed <NotZed@HelixCode.com> - - * e-sexp.c (e_sexp_finalise): Destroy the g_scanner when cleaning up. - (e_sexp_finalise): Free symbol table on finalise. - -2000-05-09 Christopher James Lahey <clahey@helixcode.com> - - * e-canvas.c: Remove reflow idle when being destroyed. - -2000-05-06 Christopher James Lahey <clahey@helixcode.com> - - * e-html-utils.c: Got rid of some warnings. - - * e-util.c, e-util.h: Added e_read_file which takes a filename and - returns a newly allocated string containing the contents of that - file. - -2000-05-03 Ettore Perazzoli <ettore@helixcode.com> - - * e-util.h: #include <glib.h> and <gtk/gtktypeutils.h>. - - * e-util.c (e_free_object_list): New utility function. - -2000-05-02 Damon Chaplin <damon@helixcode.com> - - * e-canvas.c (e_canvas_focus_in): - (e_canvas_focus_out): set and reset the GTK_HAS_FOCUS flag. We now get - focus_out events correctly. - -2000-05-02 NotZed <NotZed@HelixCode.com> - - * e-sexp.c (e_sexp_finalise): Free the parse tree if we have one. - (e_sexp_parse): If we already have a parse tree, free it. - -2000-05-02 Matt Loper <matt@helixcode.com> - - * Makefile.am: set G_LOG_DOMAIN. - -2000-05-01 Ettore Perazzoli <ettore@helixcode.com> - - * e-xml-utils.c, e-xml-utils.h: Constified all the functions. - -2000-04-27 Dan Winship <danw@helixcode.com> - - * e-html-utils.c (e_text_to_html): Moved here from the mailer, - since it's of general use, and the composer needs it too. - -2000-04-24 Miguel de Icaza <miguel@helixcode.com> - - * e-popup-menu.c: New file. Implements easy to use popup menus. - -2000-04-24 Matt Loper <matt@helixcode.com> - - * e-paned.c: New file. Makes a GtkPaned with more than two - children. - * e-paned.h: same. - - * Makefile.am: added e-paned.[ch]. - -2000-04-19 Christopher James Lahey <clahey@helixcode.com> - - * e-xml-utils.c, e-xml-utils.h: Added - e_xml_get_child_by_name_by_lang. - -2000-04-16 Anders Carlsson <andersca@gnu.org> - - * e-canvas.c (e_canvas_class_init): Add realize. - (e_canvas_realize): Set the back pixmap to NULL to reduce flicker. - -2000-04-14 Christopher James Lahey <clahey@helixcode.com> - - * e-xml-utils.c: Fixing a warning. - -2000-04-14 Christopher James Lahey <clahey@helixcode.com> - - * e-xml-utils.c: Add g_return_if_fails. - -2000-04-12 Miguel de Icaza <miguel@gnu.org> - - * e-cursors.c (e_cursor_get): Prevent next hacker to get bitten by this. - -2000-04-10 Christopher James Lahey <clahey@helixcode.com> - - * e-canvas.c: Added proper keyboard focus handling. - -2000-04-06 Matt Loper <matt@helixcode.com> - - * e-setup.c (e_setup_base_dir): Get/set Evolution's base directory - via gnome-config. - (mkdir_if_necessary): New function. - (e_setup_base_dir): Use mkdir_if_necessary(). - -2000-03-22 NotZed <NotZed@HelixCode.com> - - * e-util/e-sexp.h: Formatting cleanup. - -2000-03-07 NotZed <NotZed@HelixCode.com> - - * e-util/Makefile.am (libeutil_la_SOURCES): s-sexp.h -> e-sexp.h. - -2000-03-12 Christopher James Lahey <clahey@helixcode.com> - - * e-util/e-canvas.c, e-util/e-canvas.h: Fixed some bugs here to - speed up reflow and to make it fail less often. - -2000-03-10 Christopher James Lahey <clahey@helixcode.com> - - * e-util/e-canvas.c, e-util/e-canvas.h: Designed a new system for - doing hierarchical displays in the canvas. Adds an extra idle - loop to the canvas system. - -2000-03-05 Christopher James Lahey <clahey@helixcode.com> - - * e-util/e-xml-utils.c: Fixed e_xml_set_integer_prop_by_name. - -2000-03-04 Christopher James Lahey <clahey@helixcode.com> - - * e-util/e-xml-utils.c, e-util/e-xml-utils.h: Added - e_xml_set_integer_prop_by_name. - -2000-02-28 NotZed <NotZed@HelixCode.com> - - * e-util/e-sexp.[ch]: Added. moved from filter-sexp.[ch] - - * e-util/Makefile.am (libeutil_a_SOURCES): Add e-sexp. - (noinst_LTLIBRARIES): Changed to a libtool library. - -2000-02-24 Christopher James Lahey <clahey@helixcode.com> - - * e-util/e-xml-utils.c, e-util/e-xml-utils.h: Added - e_xml_get_integer_prop_by_name. - - * e-util/Makefile.am: Added e-util.c. - - * e-util/e-util.h: Added e-util.c functions. - - * e-util/e-util.c: New file for compare functions - -2000-02-24 Christopher James Lahey <clahey@helixcode.com> - - * e-util/e-canvas-utils.h: Fixed the comment at the top and added - #ifndef __E_CANVAS_UTILS__. - - * e-util/Makefile.am: Added e-xml-utils.c and - e-xml-utils.h. - - * e-util/e-xml-utils.h, e-util/e-xml-utils.c: Added files for some - xml utilities. - - * e-util/e-util.h: Added type EFocus which describes which - direction the focus will be coming from. - -2000-02-23 Dan Winship <danw@helixcode.com> - - * e-util/e-setup.c (e_setup_base_dir): Make ~/evolution mode 700 - rather than mode 600 (and use the symbolic name rather than the - number). - -2000-02-09 Christopher James Lahey <clahey@helixcode.com> - - * e-util/Makefile.am: Add canvas utilities to libeutil. - diff --git a/e-util/Makefile.am b/e-util/Makefile.am deleted file mode 100644 index e6182ce2b7..0000000000 --- a/e-util/Makefile.am +++ /dev/null @@ -1,131 +0,0 @@ -eutilincludedir = $(privincludedir)/e-util -econdincludedir = $(privincludedir)/e-conduit - -INCLUDES = \ - -I$(top_srcdir) \ - -DEVOLUTION_IMAGES=\""$(imagesdir)"\" \ - -DEVOLUTION_ICONSDIR=\""$(imagesdir)"\" \ - -DEVOLUTION_CATEGORY_ICONS=\""$(imagesdir)/categories"\" \ - -DEVOLUTION_PLUGINDIR=\""$(plugindir)"\" \ - -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \ - -DG_LOG_DOMAIN=\"e-utils\" \ - $(GNOME_PILOT_CFLAGS) \ - $(E_UTIL_CFLAGS) - -privlib_LTLIBRARIES = libeutil.la libeconduit.la - -eutilinclude_HEADERS = \ - e-account-list.h \ - e-account.h \ - e-bconf-map.h \ - e-categories-config.h \ - e-categories-master-list-wombat.h \ - e-component-listener.h \ - e-config.h \ - e-config-listener.h \ - e-corba-utils.h \ - e-dialog-utils.h \ - e-dialog-widgets.h \ - e-error.h \ - e-event.h \ - e-folder-map.h \ - e-fsutils.h \ - e-gtk-utils.h \ - e-gui-utils.h \ - e-html-utils.h \ - e-icon-factory.h \ - e-import.h \ - e-iterator.h \ - e-list-iterator.h \ - e-list.h \ - e-menu.h \ - e-mktemp.h \ - e-print.h \ - e-plugin.h \ - e-popup.h \ - e-profile-event.h \ - e-request.h \ - e-signature.h \ - e-signature-list.h \ - e-time-utils.h \ - e-uid.h \ - md5-utils.h - -libeutil_la_SOURCES = \ - $(MARSHAL_GENERATED) \ - $(eutilinclude_HEADERS) \ - e-account-list.c \ - e-account.c \ - e-bconf-map.c \ - e-categories-config.c \ - e-categories-master-list-wombat.c \ - e-component-listener.c \ - e-config.c \ - e-config-listener.c \ - e-corba-utils.c \ - e-dialog-utils.c \ - e-dialog-widgets.c \ - e-error.c \ - e-event.c \ - e-folder-map.c \ - e-fsutils.c \ - e-gtk-utils.c \ - e-gui-utils.c \ - e-html-utils.c \ - e-icon-factory.c \ - e-import.c \ - e-iterator.c \ - e-list-iterator.c \ - e-list.c \ - e-menu.c \ - e-mktemp.c \ - e-plugin.c \ - e-popup.c \ - e-print.c \ - e-profile-event.c \ - e-request.c \ - e-signature.c \ - e-signature-list.c \ - e-time-utils.c \ - e-uid.c \ - eggtrayicon.c \ - eggtrayicon.h \ - md5-utils.c - -MARSHAL_GENERATED = e-util-marshal.c e-util-marshal.h -@EVO_MARSHAL_RULE@ - -libeutil_la_LIBADD = $(E_UTIL_LIBS) - -econdinclude_HEADERS = \ - e-pilot-map.h \ - e-pilot-util.h - -pilot_sources = \ - $(econdinclude_HEADERS) \ - e-pilot-map.c \ - e-pilot-util.c - -if ENABLE_PILOT_CONDUITS -pilot_compile = $(pilot_sources) -else -pilot_compile = md5-utils.c -endif - -libeconduit_la_SOURCES = $(pilot_compile) - -error_DATA = e-system.error -errordir = $(privdatadir)/errors -@EVO_PLUGIN_RULE@ - -EXTRA_DIST = \ - e-system.error.xml \ - $(pilot_sources) \ - ChangeLog.pre-1-4 \ - e-util-marshal.list - -BUILT_SOURCES = $(MARSHAL_GENERATED) $(error_DATA) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) diff --git a/e-util/e-account-list.c b/e-util/e-account-list.c deleted file mode 100644 index c4968d82b3..0000000000 --- a/e-util/e-account-list.c +++ /dev/null @@ -1,466 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2003 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-account-list.h" -#include "e-account.h" -#include "e-util-marshal.h" - -#include <string.h> - -struct EAccountListPrivate { - GConfClient *gconf; - guint notify_id; -}; - -enum { - ACCOUNT_ADDED, - ACCOUNT_CHANGED, - ACCOUNT_REMOVED, - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL] = { 0 }; - -static void e_account_list_dispose (GObject *); -static void e_account_list_finalize (GObject *); - -G_DEFINE_TYPE (EAccountList, e_account_list, E_TYPE_LIST) - -static void -e_account_list_class_init (EAccountListClass *klass) -{ - GObjectClass *object_class; - - /* virtual method override */ - object_class = G_OBJECT_CLASS (klass); - object_class->dispose = e_account_list_dispose; - object_class->finalize = e_account_list_finalize; - - /* signals */ - signals[ACCOUNT_ADDED] = - g_signal_new ("account-added", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAccountListClass, account_added), - NULL, NULL, - e_util_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_ACCOUNT); - signals[ACCOUNT_CHANGED] = - g_signal_new ("account-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAccountListClass, account_changed), - NULL, NULL, - e_util_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_ACCOUNT); - signals[ACCOUNT_REMOVED] = - g_signal_new ("account-removed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAccountListClass, account_removed), - NULL, NULL, - e_util_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_ACCOUNT); -} - -static void -e_account_list_init (EAccountList *account_list) -{ - account_list->priv = g_new0 (EAccountListPrivate, 1); -} - -static void -e_account_list_dispose (GObject *object) -{ - EAccountList *account_list = E_ACCOUNT_LIST (object); - - if (account_list->priv->gconf) { - if (account_list->priv->notify_id) { - gconf_client_notify_remove (account_list->priv->gconf, - account_list->priv->notify_id); - } - g_object_unref (account_list->priv->gconf); - account_list->priv->gconf = NULL; - } - - G_OBJECT_CLASS (e_account_list_parent_class)->dispose (object); -} - -static void -e_account_list_finalize (GObject *object) -{ - EAccountList *account_list = E_ACCOUNT_LIST (object); - - g_free (account_list->priv); - - G_OBJECT_CLASS (e_account_list_parent_class)->finalize (object); -} - -static void -gconf_accounts_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) -{ - EAccountList *account_list = user_data; - GSList *list, *l, *new_accounts = NULL; - EAccount *account; - EList *old_accounts; - EIterator *iter; - char *uid; - - old_accounts = e_list_duplicate (E_LIST (account_list)); - - list = gconf_client_get_list (client, "/apps/evolution/mail/accounts", - GCONF_VALUE_STRING, NULL); - for (l = list; l; l = l->next) { - uid = e_account_uid_from_xml (l->data); - if (!uid) - continue; - - /* See if this is an existing account */ - for (iter = e_list_get_iterator (old_accounts); - e_iterator_is_valid (iter); - e_iterator_next (iter)) { - account = (EAccount *)e_iterator_get (iter); - if (!strcmp (account->uid, uid)) { - /* The account still exists, so remove - * it from "old_accounts" and update it. - */ - e_iterator_delete (iter); - if (e_account_set_from_xml (account, l->data)) - g_signal_emit (account_list, signals[ACCOUNT_CHANGED], 0, account); - goto next; - } - } - - /* Must be a new account */ - account = e_account_new_from_xml (l->data); - e_list_append (E_LIST (account_list), account); - new_accounts = g_slist_prepend (new_accounts, account); - - next: - g_free (uid); - g_object_unref (iter); - } - - /* Now emit signals for each added account. (We do this after - * adding all of them because otherwise if the signal handler - * calls e_account_list_get_default_account() it will end up - * causing the first account in the list to become the - * default.) - */ - for (l = new_accounts; l; l = l->next) { - account = l->data; - g_signal_emit (account_list, signals[ACCOUNT_ADDED], 0, account); - g_object_unref (account); - } - g_slist_free (new_accounts); - - /* Anything left in old_accounts must have been deleted */ - for (iter = e_list_get_iterator (old_accounts); - e_iterator_is_valid (iter); - e_iterator_next (iter)) { - account = (EAccount *)e_iterator_get (iter); - e_list_remove (E_LIST (account_list), account); - g_signal_emit (account_list, signals[ACCOUNT_REMOVED], 0, account); - } - g_object_unref (iter); - g_object_unref (old_accounts); -} - -static void * -copy_func (const void *data, void *closure) -{ - GObject *object = (GObject *)data; - - g_object_ref (object); - return object; -} - -static void -free_func (void *data, void *closure) -{ - g_object_unref (data); -} - -/** - * e_account_list_new: - * @gconf: a #GConfClient - * - * Reads the list of accounts from @gconf and listens for changes. - * Will emit %account_added, %account_changed, and %account_removed - * signals according to notifications from GConf. - * - * You can modify the list using e_list_append(), e_list_remove(), and - * e_iterator_delete(). After adding, removing, or changing accounts, - * you must call e_account_list_save() to push the changes back to - * GConf. - * - * Return value: the list of accounts - **/ -EAccountList * -e_account_list_new (GConfClient *gconf) -{ - EAccountList *account_list; - - g_return_val_if_fail (GCONF_IS_CLIENT (gconf), NULL); - - account_list = g_object_new (E_TYPE_ACCOUNT_LIST, NULL); - e_account_list_construct (account_list, gconf); - - return account_list; -} - -void -e_account_list_construct (EAccountList *account_list, GConfClient *gconf) -{ - g_return_if_fail (GCONF_IS_CLIENT (gconf)); - - e_list_construct (E_LIST (account_list), copy_func, free_func, NULL); - account_list->priv->gconf = gconf; - g_object_ref (gconf); - - gconf_client_add_dir (account_list->priv->gconf, - "/apps/evolution/mail/accounts", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - account_list->priv->notify_id = - gconf_client_notify_add (account_list->priv->gconf, - "/apps/evolution/mail/accounts", - gconf_accounts_changed, account_list, - NULL, NULL); - - gconf_accounts_changed (account_list->priv->gconf, - account_list->priv->notify_id, - NULL, account_list); -} - -/** - * e_account_list_save: - * @account_list: an #EAccountList - * - * Saves @account_list to GConf. Signals will be emitted for changes. - **/ -void -e_account_list_save (EAccountList *account_list) -{ - GSList *list = NULL; - EAccount *account; - EIterator *iter; - char *xmlbuf; - - for (iter = e_list_get_iterator (E_LIST (account_list)); - e_iterator_is_valid (iter); - e_iterator_next (iter)) { - account = (EAccount *)e_iterator_get (iter); - - xmlbuf = e_account_to_xml (account); - if (xmlbuf) - list = g_slist_append (list, xmlbuf); - } - g_object_unref (iter); - - gconf_client_set_list (account_list->priv->gconf, - "/apps/evolution/mail/accounts", - GCONF_VALUE_STRING, list, NULL); - - while (list) { - g_free (list->data); - list = g_slist_remove (list, list->data); - } - - gconf_client_suggest_sync (account_list->priv->gconf, NULL); -} - -/** - * e_account_list_add: - * @accounts: - * @account: - * - * Add an account to the account list. Will emit the account-changed - * event. - **/ -void -e_account_list_add(EAccountList *accounts, EAccount *account) -{ - /* FIXME: should we check for duplicate accounts? */ - - e_list_append ((EList *)accounts, account); - g_signal_emit(accounts, signals[ACCOUNT_ADDED], 0, account); -} - -/** - * e_account_list_change: - * @accounts: - * @account: - * - * Signal that the details of an account have changed. - **/ -void -e_account_list_change(EAccountList *accounts, EAccount *account) -{ - /* maybe the account should do this itself ... */ - g_signal_emit(accounts, signals[ACCOUNT_CHANGED], 0, account); -} - -/** - * e_account_list_remove: - * @accounts: - * @account: - * - * Remove an account from the account list, and emit the - * account-removed signal. If the account was the default account, - * then reset the default to the first account. - **/ -void -e_account_list_remove(EAccountList *accounts, EAccount *account) -{ - if (account == e_account_list_get_default(accounts)) - gconf_client_unset (accounts->priv->gconf, "/apps/evolution/mail/default_account", NULL); - - /* not sure if need to ref but no harm */ - g_object_ref (account); - e_list_remove ((EList *) accounts, account); - g_signal_emit(accounts, signals[ACCOUNT_REMOVED], 0, account); - g_object_unref (account); -} - -/** - * e_account_list_get_default: - * @accounts: - * - * Get the default account. If no default is specified, or the default - * has become stale, then the first account is made the default. - * - * Return value: The account or NULL if no accounts are defined. - **/ -const EAccount * -e_account_list_get_default(EAccountList *accounts) -{ - char *uid; - EIterator *it; - const EAccount *account = NULL; - - uid = gconf_client_get_string (accounts->priv->gconf, "/apps/evolution/mail/default_account", NULL); - it = e_list_get_iterator ((EList *)accounts); - - if (uid) { - for (;e_iterator_is_valid (it);e_iterator_next (it)) { - account = (const EAccount *)e_iterator_get (it); - - if (!strcmp(uid, account->uid)) - break; - account = NULL; - } - e_iterator_reset(it); - } - - /* no uid or uid not found, @it will be at the first account */ - if (account == NULL && e_iterator_is_valid(it)) { - account = (const EAccount *) e_iterator_get (it); - gconf_client_set_string (accounts->priv->gconf, "/apps/evolution/mail/default_account", account->uid, NULL); - } - - g_object_unref(it); - g_free(uid); - - return account; -} - -/** - * e_account_list_set_default: - * @accounts: - * @account: - * - * Set the account @account to be the default account. - **/ -void -e_account_list_set_default(EAccountList *accounts, EAccount *account) -{ - gconf_client_set_string (accounts->priv->gconf, "/apps/evolution/mail/default_account", account->uid, NULL); -} - -/** - * e_account_list_find: - * @accounts: - * @type: Type of search. - * @key: Search key. - * - * Perform a search of the account list on a single key. - * - * @type must be set from one of the following search types: - * E_ACCOUNT_FIND_NAME - Find an account by account name. - * E_ACCOUNT_FIND_ID_NAME - Find an account by the owner's identity name. - * E_ACCOUNT_FIND_ID_ADDRESS - Find an account by the owner's identity address. - * - * Return value: The account or NULL if it doesn't exist. - **/ -const EAccount * -e_account_list_find(EAccountList *accounts, e_account_find_t type, const char *key) -{ - char *val; - EIterator *it; - const EAccount *account = NULL; - - /* this could use a callback for more flexibility ... - ... but this makes the common cases easier */ - - if (!key) - return NULL; - - for (it = e_list_get_iterator ((EList *)accounts); - e_iterator_is_valid (it); - e_iterator_next (it)) { - int found = 0; - - account = (const EAccount *)e_iterator_get (it); - - val = NULL; - switch(type) { - case E_ACCOUNT_FIND_NAME: - found = strcmp(account->name, key) == 0; - break; - case E_ACCOUNT_FIND_UID: - found = strcmp(account->uid, key) == 0; - break; - case E_ACCOUNT_FIND_ID_NAME: - if (account->id) - found = strcmp(account->id->name, key) == 0; - break; - case E_ACCOUNT_FIND_ID_ADDRESS: - if (account->id) - found = g_ascii_strcasecmp(account->id->address, key) == 0; - break; - } - - if (found) - break; - - account = NULL; - } - g_object_unref(it); - - return account; -} - diff --git a/e-util/e-account-list.h b/e-util/e-account-list.h deleted file mode 100644 index f2b17af360..0000000000 --- a/e-util/e-account-list.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2003 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __E_ACCOUNT_LIST__ -#define __E_ACCOUNT_LIST__ - -#include "e-list.h" -#include "e-account.h" -#include <gconf/gconf-client.h> - -#define E_TYPE_ACCOUNT_LIST (e_account_list_get_type ()) -#define E_ACCOUNT_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_ACCOUNT_LIST, EAccountList)) -#define E_ACCOUNT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_ACCOUNT_LIST, EAccountListClass)) -#define E_IS_ACCOUNT_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_ACCOUNT_LIST)) -#define E_IS_ACCOUNT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_ACCOUNT_LIST)) - -typedef struct EAccountListPrivate EAccountListPrivate; - -/* search options for the find command */ -typedef enum _e_account_find_t { - E_ACCOUNT_FIND_NAME, - E_ACCOUNT_FIND_UID, - E_ACCOUNT_FIND_ID_NAME, - E_ACCOUNT_FIND_ID_ADDRESS, -} e_account_find_t; - -typedef struct _EAccountList { - EList parent_object; - - EAccountListPrivate *priv; -} EAccountList; - -typedef struct { - EListClass parent_class; - - /* signals */ - void (*account_added) (EAccountList *, EAccount *); - void (*account_changed) (EAccountList *, EAccount *); - void (*account_removed) (EAccountList *, EAccount *); -} EAccountListClass; - - -GType e_account_list_get_type (void); - -EAccountList *e_account_list_new (GConfClient *gconf); -void e_account_list_construct (EAccountList *account_list, - GConfClient *gconf); - -void e_account_list_save (EAccountList *account_list); - -void e_account_list_add (EAccountList *, EAccount *); -void e_account_list_change (EAccountList *, EAccount *); -void e_account_list_remove (EAccountList *, EAccount *); - -const EAccount *e_account_list_get_default(EAccountList *); -void e_account_list_set_default(EAccountList *, EAccount *); -const EAccount *e_account_list_find (EAccountList *, e_account_find_t type, const char *key); - -#endif /* __E_ACCOUNT_LIST__ */ diff --git a/e-util/e-account.c b/e-util/e-account.c deleted file mode 100644 index 4ede2375e2..0000000000 --- a/e-util/e-account.c +++ /dev/null @@ -1,976 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2003 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-account.h" - -#include "e-uid.h" - -#include <string.h> - -#include <libxml/parser.h> -#include <libxml/tree.h> -#include <libxml/xmlmemory.h> - -#include <gconf/gconf-client.h> - -#define d(x) - -enum { - CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -G_DEFINE_TYPE (EAccount, e_account, G_TYPE_OBJECT) - -/* -lock mail accounts Relatively difficult -- involves redesign of the XML blobs which describe accounts -disable adding mail accounts Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable -disable editing mail accounts Relatively difficult -- involves redesign of the XML blobs which describe accounts -disable removing mail accounts -lock default character encoding Simple -- Gconf key + a little UI work to desensitize widgets, etc -disable free busy publishing -disable specific mime types (from being viewed) 90% done already (Unknown MIME types still pose a problem) -lock image loading preference -lock junk mail filtering settings -** junk mail per account -lock work week -lock first day of work week -lock working hours -disable forward as icalendar -lock color options for tasks -lock default contact filing format -* forbid signatures Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable -* lock user to having 1 specific signature Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable -* forbid adding/removing signatures Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable -* lock each account to a certain signature Relatively difficult -- involved redesign of the XML blobs which describe accounts -* set default folders -set trash emptying frequency -* lock displayed mail headers Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable -* lock authentication type (for incoming mail) Relatively difficult -- involves redesign of the XML blobs which describe accounts -* lock authentication type (for outgoing mail) Relatively difficult -- involves redesign of the XML blobs which describe accounts -* lock minimum check mail on server frequency Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable -** lock save password -* require ssl always Relatively difficult -- involves redesign of the XML blobs which describe accounts -** lock imap subscribed folder option -** lock filtering of inbox -** lock source account/options -** lock destination account/options -*/ - -static void e_account_finalize (GObject *); - -static void -e_account_class_init (EAccountClass *klass) -{ - GObjectClass *object_class; - - /* virtual method override */ - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = e_account_finalize; - - signals[CHANGED] = - g_signal_new("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAccountClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, 1, - G_TYPE_INT); -} - -static void -e_account_init (EAccount *account) -{ - account->id = g_new0 (EAccountIdentity, 1); - account->source = g_new0 (EAccountService, 1); - account->transport = g_new0 (EAccountService, 1); - - account->source->auto_check = FALSE; - account->source->auto_check_time = 10; -} - -static void -identity_destroy (EAccountIdentity *id) -{ - if (!id) - return; - - g_free (id->name); - g_free (id->address); - g_free (id->reply_to); - g_free (id->organization); - g_free (id->sig_uid); - - g_free (id); -} - -static void -service_destroy (EAccountService *service) -{ - if (!service) - return; - - g_free (service->url); - - g_free (service); -} - -static void -e_account_finalize (GObject *object) -{ - EAccount *account = E_ACCOUNT (object); - - g_free (account->name); - g_free (account->uid); - - identity_destroy (account->id); - service_destroy (account->source); - service_destroy (account->transport); - - g_free (account->drafts_folder_uri); - g_free (account->sent_folder_uri); - - g_free (account->cc_addrs); - g_free (account->bcc_addrs); - - g_free (account->pgp_key); - g_free (account->smime_sign_key); - g_free (account->smime_encrypt_key); - - G_OBJECT_CLASS (e_account_parent_class)->finalize (object); -} - -/** - * e_account_new: - * - * Return value: a blank new account which can be filled in and - * added to an #EAccountList. - **/ -EAccount * -e_account_new (void) -{ - EAccount *account; - - account = g_object_new (E_TYPE_ACCOUNT, NULL); - account->uid = e_uid_new (); - - return account; -} - -/** - * e_account_new_from_xml: - * @xml: an XML account description - * - * Return value: a new #EAccount based on the data in @xml, or %NULL - * if @xml could not be parsed as valid account data. - **/ -EAccount * -e_account_new_from_xml (const char *xml) -{ - EAccount *account; - - account = g_object_new (E_TYPE_ACCOUNT, NULL); - if (!e_account_set_from_xml (account, xml)) { - g_object_unref (account); - return NULL; - } - - return account; -} - - -static gboolean -xml_set_bool (xmlNodePtr node, const char *name, gboolean *val) -{ - gboolean bool; - char *buf; - - if ((buf = xmlGetProp (node, name))) { - bool = (!strcmp (buf, "true") || !strcmp (buf, "yes")); - xmlFree (buf); - - if (bool != *val) { - *val = bool; - return TRUE; - } - } - - return FALSE; -} - -static gboolean -xml_set_int (xmlNodePtr node, const char *name, int *val) -{ - int number; - char *buf; - - if ((buf = xmlGetProp (node, name))) { - number = strtol (buf, NULL, 10); - xmlFree (buf); - - if (number != *val) { - *val = number; - return TRUE; - } - } - - return FALSE; -} - -static gboolean -xml_set_prop (xmlNodePtr node, const char *name, char **val) -{ - char *buf; - int res; - - buf = xmlGetProp(node, name); - if (buf == NULL) { - res = (*val != NULL); - if (res) { - g_free(*val); - *val = NULL; - } - } else { - res = *val == NULL || strcmp(*val, buf) != 0; - if (res) { - g_free(*val); - *val = g_strdup(buf); - } - xmlFree(buf); - } - - return res; -} - -static EAccountReceiptPolicy -str_to_receipt_policy (const char *str) -{ - if (!strcmp (str, "ask")) - return E_ACCOUNT_RECEIPT_ASK; - if (!strcmp (str, "always")) - return E_ACCOUNT_RECEIPT_ALWAYS; - - return E_ACCOUNT_RECEIPT_NEVER; -} - -static char* -receipt_policy_to_str (EAccountReceiptPolicy val) -{ - char *ret = 0; - - switch (val) { - case E_ACCOUNT_RECEIPT_NEVER: - ret = "never"; - break; - case E_ACCOUNT_RECEIPT_ASK: - ret = "ask"; - break; - case E_ACCOUNT_RECEIPT_ALWAYS: - ret = "always"; - break; - } - - return ret; -} - -static gboolean -xml_set_receipt_policy (xmlNodePtr node, const char *name, EAccountReceiptPolicy *val) -{ - EAccountReceiptPolicy new_val; - char *buf; - - if ((buf = xmlGetProp (node, name))) { - new_val = str_to_receipt_policy (buf); - xmlFree (buf); - - if (new_val != *val) { - *val = new_val; - return TRUE; - } - } - - return FALSE; -} - -static gboolean -xml_set_content (xmlNodePtr node, char **val) -{ - char *buf; - int res; - - buf = xmlNodeGetContent(node); - if (buf == NULL) { - res = (*val != NULL); - if (res) { - g_free(*val); - *val = NULL; - } - } else { - res = *val == NULL || strcmp(*val, buf) != 0; - if (res) { - g_free(*val); - *val = g_strdup(buf); - } - xmlFree(buf); - } - - return res; -} - -static gboolean -xml_set_identity (xmlNodePtr node, EAccountIdentity *id) -{ - gboolean changed = FALSE; - - for (node = node->children; node; node = node->next) { - if (!strcmp (node->name, "name")) - changed |= xml_set_content (node, &id->name); - else if (!strcmp (node->name, "addr-spec")) - changed |= xml_set_content (node, &id->address); - else if (!strcmp (node->name, "reply-to")) - changed |= xml_set_content (node, &id->reply_to); - else if (!strcmp (node->name, "organization")) - changed |= xml_set_content (node, &id->organization); - else if (!strcmp (node->name, "signature")) { - changed |= xml_set_prop (node, "uid", &id->sig_uid); - if (!id->sig_uid) { - - /* WTF is this shit doing here? Migrate is supposed to "handle this" */ - - /* set a fake sig uid so the migrate code can handle this */ - gboolean autogen = FALSE; - int sig_id = 0; - - xml_set_bool (node, "auto", &autogen); - xml_set_int (node, "default", &sig_id); - - if (autogen) { - id->sig_uid = g_strdup ("::0"); - changed = TRUE; - } else if (sig_id) { - id->sig_uid = g_strdup_printf ("::%d", sig_id + 1); - changed = TRUE; - } - } - } - } - - return changed; -} - -static gboolean -xml_set_service (xmlNodePtr node, EAccountService *service) -{ - gboolean changed = FALSE; - - changed |= xml_set_bool (node, "save-passwd", &service->save_passwd); - changed |= xml_set_bool (node, "keep-on-server", &service->keep_on_server); - - changed |= xml_set_bool (node, "auto-check", &service->auto_check); - changed |= xml_set_int (node, "auto-check-timeout", &service->auto_check_time); - if (service->auto_check && service->auto_check_time <= 0) { - service->auto_check = FALSE; - service->auto_check_time = 0; - } - - for (node = node->children; node; node = node->next) { - if (!strcmp (node->name, "url")) { - changed |= xml_set_content (node, &service->url); - break; - } - } - - return changed; -} - -/** - * e_account_set_from_xml: - * @account: an #EAccount - * @xml: an XML account description. - * - * Changes @account to match @xml. - * - * Return value: %TRUE if @account was changed, %FALSE if @account - * already matched @xml or @xml could not be parsed - **/ -gboolean -e_account_set_from_xml (EAccount *account, const char *xml) -{ - xmlNodePtr node, cur; - xmlDocPtr doc; - gboolean changed = FALSE; - - if (!(doc = xmlParseDoc ((char *)xml))) - return FALSE; - - node = doc->children; - if (strcmp (node->name, "account") != 0) { - xmlFreeDoc (doc); - return FALSE; - } - - if (!account->uid) - xml_set_prop (node, "uid", &account->uid); - - changed |= xml_set_prop (node, "name", &account->name); - changed |= xml_set_bool (node, "enabled", &account->enabled); - - for (node = node->children; node; node = node->next) { - if (!strcmp (node->name, "identity")) { - changed |= xml_set_identity (node, account->id); - } else if (!strcmp (node->name, "source")) { - changed |= xml_set_service (node, account->source); - } else if (!strcmp (node->name, "transport")) { - changed |= xml_set_service (node, account->transport); - } else if (!strcmp (node->name, "drafts-folder")) { - changed |= xml_set_content (node, &account->drafts_folder_uri); - } else if (!strcmp (node->name, "sent-folder")) { - changed |= xml_set_content (node, &account->sent_folder_uri); - } else if (!strcmp (node->name, "auto-cc")) { - changed |= xml_set_bool (node, "always", &account->always_cc); - changed |= xml_set_content (node, &account->cc_addrs); - } else if (!strcmp (node->name, "auto-bcc")) { - changed |= xml_set_bool (node, "always", &account->always_bcc); - changed |= xml_set_content (node, &account->bcc_addrs); - } else if (!strcmp (node->name, "receipt-policy")) { - changed |= xml_set_receipt_policy (node, "policy", &account->receipt_policy); - } else if (!strcmp (node->name, "pgp")) { - changed |= xml_set_bool (node, "encrypt-to-self", &account->pgp_encrypt_to_self); - changed |= xml_set_bool (node, "always-trust", &account->pgp_always_trust); - changed |= xml_set_bool (node, "always-sign", &account->pgp_always_sign); - changed |= xml_set_bool (node, "no-imip-sign", &account->pgp_no_imip_sign); - - if (node->children) { - for (cur = node->children; cur; cur = cur->next) { - if (!strcmp (cur->name, "key-id")) { - changed |= xml_set_content (cur, &account->pgp_key); - break; - } - } - } - } else if (!strcmp (node->name, "smime")) { - changed |= xml_set_bool (node, "sign-default", &account->smime_sign_default); - changed |= xml_set_bool (node, "encrypt-to-self", &account->smime_encrypt_to_self); - changed |= xml_set_bool (node, "encrypt-default", &account->smime_encrypt_default); - - if (node->children) { - for (cur = node->children; cur; cur = cur->next) { - if (!strcmp (cur->name, "sign-key-id")) { - changed |= xml_set_content (cur, &account->smime_sign_key); - } else if (!strcmp (cur->name, "encrypt-key-id")) { - changed |= xml_set_content (cur, &account->smime_encrypt_key); - break; - } - } - } - } - } - - xmlFreeDoc (doc); - - g_signal_emit(account, signals[CHANGED], 0, -1); - - return changed; -} - -/** - * e_account_import: - * @dest: destination account object - * @src: source account object - * - * Import the settings from @src to @dest. - **/ -void -e_account_import (EAccount *dest, EAccount *src) -{ - g_free (dest->name); - dest->name = g_strdup (src->name); - - dest->enabled = src->enabled; - - g_free (dest->id->name); - dest->id->name = g_strdup (src->id->name); - g_free (dest->id->address); - dest->id->address = g_strdup (src->id->address); - g_free (dest->id->reply_to); - dest->id->reply_to = g_strdup (src->id->reply_to); - g_free (dest->id->organization); - dest->id->organization = g_strdup (src->id->organization); - dest->id->sig_uid = g_strdup (src->id->sig_uid); - - g_free (dest->source->url); - dest->source->url = g_strdup (src->source->url); - dest->source->keep_on_server = src->source->keep_on_server; - dest->source->auto_check = src->source->auto_check; - dest->source->auto_check_time = src->source->auto_check_time; - dest->source->save_passwd = src->source->save_passwd; - - g_free (dest->transport->url); - dest->transport->url = g_strdup (src->transport->url); - dest->transport->save_passwd = src->transport->save_passwd; - - g_free (dest->drafts_folder_uri); - dest->drafts_folder_uri = g_strdup (src->drafts_folder_uri); - - g_free (dest->sent_folder_uri); - dest->sent_folder_uri = g_strdup (src->sent_folder_uri); - - dest->always_cc = src->always_cc; - g_free (dest->cc_addrs); - dest->cc_addrs = g_strdup (src->cc_addrs); - - dest->always_bcc = src->always_bcc; - g_free (dest->bcc_addrs); - dest->bcc_addrs = g_strdup (src->bcc_addrs); - - dest->receipt_policy = src->receipt_policy; - - g_free (dest->pgp_key); - dest->pgp_key = g_strdup (src->pgp_key); - dest->pgp_encrypt_to_self = src->pgp_encrypt_to_self; - dest->pgp_always_sign = src->pgp_always_sign; - dest->pgp_no_imip_sign = src->pgp_no_imip_sign; - dest->pgp_always_trust = src->pgp_always_trust; - - dest->smime_sign_default = src->smime_sign_default; - g_free (dest->smime_sign_key); - dest->smime_sign_key = g_strdup (src->smime_sign_key); - - dest->smime_encrypt_default = src->smime_encrypt_default; - dest->smime_encrypt_to_self = src->smime_encrypt_to_self; - g_free (dest->smime_encrypt_key); - dest->smime_encrypt_key = g_strdup (src->smime_encrypt_key); - - g_signal_emit(dest, signals[CHANGED], 0, -1); -} - -/** - * e_account_to_xml: - * @account: an #EAccount - * - * Return value: an XML representation of @account, which the caller - * must free. - **/ -char * -e_account_to_xml (EAccount *account) -{ - xmlNodePtr root, node, id, src, xport; - char *tmp, buf[20]; - xmlChar *xmlbuf; - xmlDocPtr doc; - int n; - - doc = xmlNewDoc ("1.0"); - - root = xmlNewDocNode (doc, NULL, "account", NULL); - xmlDocSetRootElement (doc, root); - - xmlSetProp (root, "name", account->name); - xmlSetProp (root, "uid", account->uid); - xmlSetProp (root, "enabled", account->enabled ? "true" : "false"); - - id = xmlNewChild (root, NULL, "identity", NULL); - if (account->id->name) - xmlNewTextChild (id, NULL, "name", account->id->name); - if (account->id->address) - xmlNewTextChild (id, NULL, "addr-spec", account->id->address); - if (account->id->reply_to) - xmlNewTextChild (id, NULL, "reply-to", account->id->reply_to); - if (account->id->organization) - xmlNewTextChild (id, NULL, "organization", account->id->organization); - - node = xmlNewChild (id, NULL, "signature",NULL); - xmlSetProp (node, "uid", account->id->sig_uid); - - src = xmlNewChild (root, NULL, "source", NULL); - xmlSetProp (src, "save-passwd", account->source->save_passwd ? "true" : "false"); - xmlSetProp (src, "keep-on-server", account->source->keep_on_server ? "true" : "false"); - xmlSetProp (src, "auto-check", account->source->auto_check ? "true" : "false"); - sprintf (buf, "%d", account->source->auto_check_time); - xmlSetProp (src, "auto-check-timeout", buf); - if (account->source->url) - xmlNewTextChild (src, NULL, "url", account->source->url); - - xport = xmlNewChild (root, NULL, "transport", NULL); - xmlSetProp (xport, "save-passwd", account->transport->save_passwd ? "true" : "false"); - if (account->transport->url) - xmlNewTextChild (xport, NULL, "url", account->transport->url); - - xmlNewTextChild (root, NULL, "drafts-folder", account->drafts_folder_uri); - xmlNewTextChild (root, NULL, "sent-folder", account->sent_folder_uri); - - node = xmlNewChild (root, NULL, "auto-cc", NULL); - xmlSetProp (node, "always", account->always_cc ? "true" : "false"); - if (account->cc_addrs) - xmlNewTextChild (node, NULL, "recipients", account->cc_addrs); - - node = xmlNewChild (root, NULL, "auto-bcc", NULL); - xmlSetProp (node, "always", account->always_bcc ? "true" : "false"); - if (account->bcc_addrs) - xmlNewTextChild (node, NULL, "recipients", account->bcc_addrs); - - node = xmlNewChild (root, NULL, "receipt-policy", NULL); - xmlSetProp (node, "policy", receipt_policy_to_str (account->receipt_policy)); - - node = xmlNewChild (root, NULL, "pgp", NULL); - xmlSetProp (node, "encrypt-to-self", account->pgp_encrypt_to_self ? "true" : "false"); - xmlSetProp (node, "always-trust", account->pgp_always_trust ? "true" : "false"); - xmlSetProp (node, "always-sign", account->pgp_always_sign ? "true" : "false"); - xmlSetProp (node, "no-imip-sign", account->pgp_no_imip_sign ? "true" : "false"); - if (account->pgp_key) - xmlNewTextChild (node, NULL, "key-id", account->pgp_key); - - node = xmlNewChild (root, NULL, "smime", NULL); - xmlSetProp (node, "sign-default", account->smime_sign_default ? "true" : "false"); - xmlSetProp (node, "encrypt-default", account->smime_encrypt_default ? "true" : "false"); - xmlSetProp (node, "encrypt-to-self", account->smime_encrypt_to_self ? "true" : "false"); - if (account->smime_sign_key) - xmlNewTextChild (node, NULL, "sign-key-id", account->smime_sign_key); - if (account->smime_encrypt_key) - xmlNewTextChild (node, NULL, "encrypt-key-id", account->smime_encrypt_key); - - xmlDocDumpMemory (doc, &xmlbuf, &n); - xmlFreeDoc (doc); - - /* remap to glib memory */ - tmp = g_malloc (n + 1); - memcpy (tmp, xmlbuf, n); - tmp[n] = '\0'; - xmlFree (xmlbuf); - - return tmp; -} - -/** - * e_account_uid_from_xml: - * @xml: an XML account description - * - * Return value: the permanent UID of the account described by @xml - * (or %NULL if @xml could not be parsed or did not contain a uid). - * The caller must free this string. - **/ -char * -e_account_uid_from_xml (const char *xml) -{ - xmlNodePtr node; - xmlDocPtr doc; - char *uid = NULL; - - if (!(doc = xmlParseDoc ((char *)xml))) - return NULL; - - node = doc->children; - if (strcmp (node->name, "account") != 0) { - xmlFreeDoc (doc); - return NULL; - } - - xml_set_prop (node, "uid", &uid); - xmlFreeDoc (doc); - - return uid; -} - -enum { - EAP_IMAP_SUBSCRIBED = 0, - EAP_IMAP_NAMESPACE, - EAP_FILTER_INBOX, - EAP_FILTER_JUNK, - EAP_FORCE_SSL, - EAP_LOCK_SIGNATURE, - EAP_LOCK_AUTH, - EAP_LOCK_AUTOCHECK, - EAP_LOCK_DEFAULT_FOLDERS, - EAP_LOCK_SAVE_PASSWD, - EAP_LOCK_SOURCE, - EAP_LOCK_TRANSPORT, -}; - -static struct _system_info { - const char *key; - guint32 perm; -} system_perms[] = { - { "imap_subscribed", 1<<EAP_IMAP_SUBSCRIBED }, - { "imap_namespace", 1<<EAP_IMAP_NAMESPACE }, - { "filter_inbox", 1<<EAP_FILTER_INBOX }, - { "filter_junk", 1<<EAP_FILTER_JUNK }, - { "ssl", 1<<EAP_FORCE_SSL }, - { "signature", 1<<EAP_LOCK_SIGNATURE }, - { "authtype", 1<<EAP_LOCK_AUTH }, - { "autocheck", 1<<EAP_LOCK_AUTOCHECK }, - { "default_folders", 1<<EAP_LOCK_DEFAULT_FOLDERS }, - { "save_passwd" , 1<<EAP_LOCK_SAVE_PASSWD }, - { "source", 1<<EAP_LOCK_SOURCE }, - { "transport", 1<<EAP_LOCK_TRANSPORT }, -}; - -#define TYPE_STRING (1) -#define TYPE_INT (2) -#define TYPE_BOOL (3) -#define TYPE_MASK (0xff) -#define TYPE_STRUCT (1<<8) - -static struct _account_info { - guint32 perms; - guint32 type; - unsigned int offset; - unsigned int struct_offset; -} account_info[E_ACCOUNT_ITEM_LAST] = { - { /* E_ACCOUNT_NAME */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, name) }, - - { /* E_ACCOUNT_ID_NAME, */ 0, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, id), G_STRUCT_OFFSET(EAccountIdentity, name) }, - { /* E_ACCOUNT_ID_ADDRESS, */ 0, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, id), G_STRUCT_OFFSET(EAccountIdentity, address) }, - { /* E_ACCOUNT_ID_REPLY_TO, */ 0, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, id), G_STRUCT_OFFSET(EAccountIdentity, reply_to) }, - { /* E_ACCOUNT_ID_ORGANIZATION */ 0, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, id), G_STRUCT_OFFSET(EAccountIdentity, organization) }, - { /* E_ACCOUNT_ID_SIGNATURE */ 1<<EAP_LOCK_SIGNATURE, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, id), G_STRUCT_OFFSET(EAccountIdentity, sig_uid) }, - - { /* E_ACCOUNT_SOURCE_URL */ 1<<EAP_LOCK_SOURCE, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, source), G_STRUCT_OFFSET(EAccountService, url) }, - { /* E_ACCOUNT_SOURCE_KEEP_ON_SERVER */ 0, TYPE_BOOL|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, source), G_STRUCT_OFFSET(EAccountService, keep_on_server) }, - { /* E_ACCOUNT_SOURCE_AUTO_CHECK */ 1<<EAP_LOCK_AUTOCHECK, TYPE_BOOL|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, source), G_STRUCT_OFFSET(EAccountService, auto_check) }, - { /* E_ACCOUNT_SOURCE_AUTO_CHECK_TIME */ 1<<EAP_LOCK_AUTOCHECK, TYPE_INT|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, source), G_STRUCT_OFFSET(EAccountService, auto_check_time) }, - { /* E_ACCOUNT_SOURCE_SAVE_PASSWD */ 1<<EAP_LOCK_SAVE_PASSWD, TYPE_BOOL|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, source), G_STRUCT_OFFSET(EAccountService, save_passwd) }, - - { /* E_ACCOUNT_TRANSPORT_URL */ 1<<EAP_LOCK_TRANSPORT, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, transport), G_STRUCT_OFFSET(EAccountService, url) }, - { /* E_ACCOUNT_TRANSPORT_SAVE_PASSWD */ 1<<EAP_LOCK_SAVE_PASSWD, TYPE_BOOL|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, transport), G_STRUCT_OFFSET(EAccountService, save_passwd) }, - - { /* E_ACCOUNT_DRAFTS_FOLDER_URI */ 1<<EAP_LOCK_DEFAULT_FOLDERS, TYPE_STRING, G_STRUCT_OFFSET(EAccount, drafts_folder_uri) }, - { /* E_ACCOUNT_SENT_FOLDER_URI */ 1<<EAP_LOCK_DEFAULT_FOLDERS, TYPE_STRING, G_STRUCT_OFFSET(EAccount, sent_folder_uri) }, - - { /* E_ACCOUNT_CC_ALWAYS */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, always_cc) }, - { /* E_ACCOUNT_CC_ADDRS */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, cc_addrs) }, - - { /* E_ACCOUNT_BCC_ALWAYS */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, always_bcc) }, - { /* E_ACCOUNT_BCC_ADDRS */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, bcc_addrs) }, - - { /* E_ACCOUNT_RECEIPT_POLICY */ 0, TYPE_INT, G_STRUCT_OFFSET(EAccount, receipt_policy) }, - - { /* E_ACCOUNT_PGP_KEY */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, pgp_key) }, - { /* E_ACCOUNT_PGP_ENCRYPT_TO_SELF */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, pgp_encrypt_to_self) }, - { /* E_ACCOUNT_PGP_ALWAYS_SIGN */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, pgp_always_sign) }, - { /* E_ACCOUNT_PGP_NO_IMIP_SIGN */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, pgp_no_imip_sign) }, - { /* E_ACCOUNT_PGP_ALWAYS_TRUST */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, pgp_always_trust) }, - - { /* E_ACCOUNT_SMIME_SIGN_KEY */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, smime_sign_key) }, - { /* E_ACCOUNT_SMIME_ENCRYPT_KEY */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, smime_encrypt_key) }, - { /* E_ACCOUNT_SMIME_SIGN_DEFAULT */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, smime_sign_default) }, - { /* E_ACCOUNT_SMIME_ENCRYPT_TO_SELF */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, smime_encrypt_to_self) }, - { /* E_ACCOUNT_SMIME_ENCRYPT_DEFAULT */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, smime_encrypt_default) }, -}; - -static GHashTable *ea_option_table; -static GHashTable *ea_system_table; -static guint32 ea_perms; - -static struct _option_info { - char *key; - guint32 perms; -} ea_option_list[] = { - { "imap_use_lsub", 1<<EAP_IMAP_SUBSCRIBED }, - { "imap_override_namespace", 1<<EAP_IMAP_NAMESPACE }, - { "imap_filter", 1<<EAP_FILTER_INBOX }, - { "imap_filter_junk", 1<<EAP_FILTER_JUNK }, - { "imap_filter_junk_inbox", 1<<EAP_FILTER_JUNK }, - { "*_use_ssl", 1<<EAP_FORCE_SSL }, - { "*_auth", 1<<EAP_LOCK_AUTH }, -}; - -#define LOCK_BASE "/apps/evolution/lock/mail/accounts" - -static void -ea_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, void *crap) -{ - GConfValue *value; - char *tkey; - struct _system_info *info; - - g_return_if_fail (gconf_entry_get_key (entry) != NULL); - - if (!(value = gconf_entry_get_value (entry))) - return; - - tkey = strrchr(entry->key, '/'); - g_return_if_fail (tkey != NULL); - - info = g_hash_table_lookup(ea_system_table, tkey+1); - if (info) { - if (gconf_value_get_bool(value)) - ea_perms |= info->perm; - else - ea_perms &= ~info->perm; - } -} - -static void -ea_setting_setup(void) -{ - GConfClient *gconf = gconf_client_get_default(); - GConfEntry *entry; - GError *err = NULL; - int i; - char key[64]; - - if (ea_option_table != NULL) - return; - - ea_option_table = g_hash_table_new(g_str_hash, g_str_equal); - for (i=0;i<sizeof(ea_option_list)/sizeof(ea_option_list[0]);i++) - g_hash_table_insert(ea_option_table, ea_option_list[i].key, &ea_option_list[i]); - - gconf_client_add_dir(gconf, LOCK_BASE, GCONF_CLIENT_PRELOAD_NONE, NULL); - - ea_system_table = g_hash_table_new(g_str_hash, g_str_equal); - for (i=0;i<sizeof(system_perms)/sizeof(system_perms[0]);i++) { - g_hash_table_insert(ea_system_table, (char *)system_perms[i].key, &system_perms[i]); - sprintf(key, LOCK_BASE "/%s", system_perms[i].key); - entry = gconf_client_get_entry(gconf, key, NULL, TRUE, &err); - if (entry) - ea_setting_notify(gconf, 0, entry, NULL); - gconf_entry_free(entry); - } - - if (err) { - g_warning("Could not load account lock settings: %s", err->message); - g_error_free(err); - } - - gconf_client_notify_add(gconf, LOCK_BASE, (GConfClientNotifyFunc)ea_setting_notify, NULL, NULL, NULL); - g_object_unref(gconf); -} - -/* look up the item in the structure or the substructure using our table of reflection data */ -#define addr(ea, type) \ - ((account_info[type].type & TYPE_STRUCT)? \ - (((char **)(((char *)ea)+account_info[type].offset))[0] + account_info[type].struct_offset): \ - (((char *)ea)+account_info[type].offset)) - -const char *e_account_get_string(EAccount *ea, e_account_item_t type) -{ - return *((const char **)addr(ea, type)); -} - -int e_account_get_int(EAccount *ea, e_account_item_t type) -{ - return *((int *)addr(ea, type)); -} - -gboolean e_account_get_bool(EAccount *ea, e_account_item_t type) -{ - return *((gboolean *)addr(ea, type)); -} - -#if d(!)0 -static void -dump_account(EAccount *ea) -{ - char *xml; - - printf("Account changed\n"); - xml = e_account_to_xml(ea); - printf(" ->\n%s\n", xml); - g_free(xml); -} -#endif - -/* TODO: should it return true if it changed? */ -void e_account_set_string(EAccount *ea, e_account_item_t type, const char *val) -{ - char **p; - - if (!e_account_writable(ea, type)) { - g_warning("Trying to set non-writable option account value"); - } else { - p = (char **)addr(ea, type); - d(printf("Setting string %d: old '%s' new '%s'\n", type, *p, val)); - if (*p != val - && (*p == NULL || val == NULL || strcmp(*p, val) != 0)) { - g_free(*p); - *p = g_strdup(val); - d(dump_account(ea)); - g_signal_emit(ea, signals[CHANGED], 0, type); - } - } -} - -void e_account_set_int(EAccount *ea, e_account_item_t type, int val) -{ - if (!e_account_writable(ea, type)) { - g_warning("Trying to set non-writable option account value"); - } else { - int *p = (int *)addr(ea, type); - - if (*p != val) { - *p = val; - d(dump_account(ea)); - g_signal_emit(ea, signals[CHANGED], 0, type); - } - } -} - -void e_account_set_bool(EAccount *ea, e_account_item_t type, gboolean val) -{ - if (!e_account_writable(ea, type)) { - g_warning("Trying to set non-writable option account value"); - } else { - gboolean *p = (gboolean *)addr(ea, type); - - if (*p != val) { - *p = val; - d(dump_account(ea)); - g_signal_emit(ea, signals[CHANGED], 0, type); - } - } -} - -gboolean -e_account_writable_option(EAccount *ea, const char *protocol, const char *option) -{ - char *key; - struct _option_info *info; - - ea_setting_setup(); - - key = alloca(strlen(protocol)+strlen(option)+2); - sprintf(key, "%s_%s", protocol, option); - - info = g_hash_table_lookup(ea_option_table, key); - if (info == NULL) { - sprintf(key, "*_%s", option); - info = g_hash_table_lookup(ea_option_table, key); - } - - d(printf("checking writable option '%s' perms=%08x\n", option, info?info->perms:0)); - - return info == NULL - || (info->perms & ea_perms) == 0; -} - -gboolean -e_account_writable(EAccount *ea, e_account_item_t type) -{ - ea_setting_setup(); - - return (account_info[type].perms & ea_perms) == 0; -} diff --git a/e-util/e-account.h b/e-util/e-account.h deleted file mode 100644 index 4e5de875d5..0000000000 --- a/e-util/e-account.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2003 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __E_ACCOUNT__ -#define __E_ACCOUNT__ - -#include <glib-object.h> - -#define E_TYPE_ACCOUNT (e_account_get_type ()) -#define E_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_ACCOUNT, EAccount)) -#define E_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_ACCOUNT, EAccountClass)) -#define E_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_ACCOUNT)) -#define E_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_ACCOUNT)) - -typedef enum _e_account_item_t { - E_ACCOUNT_NAME, - - E_ACCOUNT_ID_NAME, - E_ACCOUNT_ID_ADDRESS, - E_ACCOUNT_ID_REPLY_TO, - E_ACCOUNT_ID_ORGANIZATION, - E_ACCOUNT_ID_SIGNATURE, - - E_ACCOUNT_SOURCE_URL, /* what about separating out host/user/path settings?? sigh */ - E_ACCOUNT_SOURCE_KEEP_ON_SERVER, - E_ACCOUNT_SOURCE_AUTO_CHECK, - E_ACCOUNT_SOURCE_AUTO_CHECK_TIME, - E_ACCOUNT_SOURCE_SAVE_PASSWD, - - E_ACCOUNT_TRANSPORT_URL, - E_ACCOUNT_TRANSPORT_SAVE_PASSWD, - - E_ACCOUNT_DRAFTS_FOLDER_URI, - E_ACCOUNT_SENT_FOLDER_URI, - - E_ACCOUNT_CC_ALWAYS, - E_ACCOUNT_CC_ADDRS, - - E_ACCOUNT_BCC_ALWAYS, - E_ACCOUNT_BCC_ADDRS, - - E_ACCOUNT_RECEIPT_POLICY, - - E_ACCOUNT_PGP_KEY, - E_ACCOUNT_PGP_ENCRYPT_TO_SELF, - E_ACCOUNT_PGP_ALWAYS_SIGN, - E_ACCOUNT_PGP_NO_IMIP_SIGN, - E_ACCOUNT_PGP_ALWAYS_TRUST, - - E_ACCOUNT_SMIME_SIGN_KEY, - E_ACCOUNT_SMIME_ENCRYPT_KEY, - E_ACCOUNT_SMIME_SIGN_DEFAULT, - E_ACCOUNT_SMIME_ENCRYPT_TO_SELF, - E_ACCOUNT_SMIME_ENCRYPT_DEFAULT, - - E_ACCOUNT_ITEM_LAST -} e_account_item_t; - -typedef enum _e_account_access_t { - E_ACCOUNT_ACCESS_WRITE = 1<<0, -} e_account_access_t; - -typedef struct _EAccountIdentity { - char *name; - char *address; - char *reply_to; - char *organization; - char *sig_uid; -} EAccountIdentity; - -typedef enum _EAccountReceiptPolicy { - E_ACCOUNT_RECEIPT_NEVER, - E_ACCOUNT_RECEIPT_ASK, - E_ACCOUNT_RECEIPT_ALWAYS -} EAccountReceiptPolicy; - -typedef struct _EAccountService { - char *url; - gboolean keep_on_server; - gboolean auto_check; - int auto_check_time; - gboolean save_passwd; -} EAccountService; - -typedef struct _EAccount { - GObject parent_object; - - char *name; - char *uid; - - gboolean enabled; - - EAccountIdentity *id; - EAccountService *source; - EAccountService *transport; - - char *drafts_folder_uri, *sent_folder_uri; - - gboolean always_cc; - char *cc_addrs; - gboolean always_bcc; - char *bcc_addrs; - - EAccountReceiptPolicy receipt_policy; - - char *pgp_key; - gboolean pgp_encrypt_to_self; - gboolean pgp_always_sign; - gboolean pgp_no_imip_sign; - gboolean pgp_always_trust; - - char *smime_sign_key; - char *smime_encrypt_key; - gboolean smime_sign_default; - gboolean smime_encrypt_to_self; - gboolean smime_encrypt_default; -} EAccount; - -typedef struct { - GObjectClass parent_class; - - void (*changed)(EAccount *, int field); -} EAccountClass; - - -GType e_account_get_type (void); - -EAccount *e_account_new (void); - -EAccount *e_account_new_from_xml (const char *xml); -gboolean e_account_set_from_xml (EAccount *account, const char *xml); -void e_account_import (EAccount *dest, EAccount *src); -char *e_account_to_xml (EAccount *account); -char *e_account_uid_from_xml (const char *xml); - -const char *e_account_get_string(EAccount *, e_account_item_t type); -int e_account_get_int(EAccount *, e_account_item_t type); -gboolean e_account_get_bool(EAccount *, e_account_item_t type); - -void e_account_set_string(EAccount *, e_account_item_t type, const char *); -void e_account_set_int(EAccount *, e_account_item_t type, int); -void e_account_set_bool(EAccount *, e_account_item_t type, gboolean); - -gboolean e_account_writable(EAccount *ea, e_account_item_t type); -gboolean e_account_writable_option(EAccount *ea, const char *protocol, const char *option); - -#endif /* __E_ACCOUNT__ */ diff --git a/e-util/e-bconf-map.c b/e-util/e-bconf-map.c deleted file mode 100644 index f4d57bbbcc..0000000000 --- a/e-util/e-bconf-map.c +++ /dev/null @@ -1,544 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <glib.h> - -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -#include "e-bconf-map.h" - - -#define d(x) - - -static char hexnib[256] = { - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, - -1,10,11,12,13,14,15,16,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,10,11,12,13,14,15,16,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -}; - -char * -e_bconf_hex_decode (const char *val) -{ - const unsigned char *p = (const unsigned char *) val; - char *o, *res; - - o = res = g_malloc (strlen (val) / 2 + 1); - for (p = val; (p[0] && p[1]); p += 2) - *o++ = (hexnib[p[0]] << 4) | hexnib[p[1]]; - *o = 0; - - return res; -} - -char * -e_bconf_url_decode (const char *val) -{ - const unsigned char *p = (const unsigned char *) val; - char *o, *res, c; - - o = res = g_malloc (strlen (val) + 1); - while (*p) { - c = *p++; - if (c == '%' - && hexnib[p[0]] != -1 && hexnib[p[1]] != -1) { - *o++ = (hexnib[p[0]] << 4) | hexnib[p[1]]; - p+=2; - } else - *o++ = c; - } - *o = 0; - - return res; -} - - -xmlNodePtr -e_bconf_get_path (xmlDocPtr doc, const char *path) -{ - xmlNodePtr root; - char *val; - int found; - - root = doc->children; - if (strcmp (root->name, "bonobo-config") != 0) { - g_warning ("not bonobo-config xml file"); - return NULL; - } - - root = root->children; - while (root) { - if (!strcmp (root->name, "section")) { - val = xmlGetProp (root, "path"); - found = val && strcmp (val, path) == 0; - xmlFree (val); - if (found) - break; - } - root = root->next; - } - - return root; -} - -xmlNodePtr -e_bconf_get_entry (xmlNodePtr root, const char *name) -{ - xmlNodePtr node = root->children; - int found; - char *val; - - while (node) { - if (!strcmp (node->name, "entry")) { - val = xmlGetProp (node, "name"); - found = val && strcmp (val, name) == 0; - xmlFree (val); - if (found) - break; - } - node = node->next; - } - - return node; -} - -char * -e_bconf_get_value (xmlNodePtr root, const char *name) -{ - xmlNodePtr node = e_bconf_get_entry (root, name); - char *prop, *val = NULL; - - if (node && (prop = xmlGetProp (node, "value"))) { - val = g_strdup (prop); - xmlFree (prop); - } - - return val; -} - -char * -e_bconf_get_bool (xmlNodePtr root, const char *name) -{ - char *val, *res; - - if ((val = e_bconf_get_value (root, name))) { - res = g_strdup (val[0] == '1' ? "true" : "false"); - g_free (val); - } else - res = NULL; - - return res; -} - -char * -e_bconf_get_long (xmlNodePtr root, const char *name) -{ - char *val, *res; - - if ((val = e_bconf_get_value (root, name))) { - res = g_strdup (val); - g_free (val); - } else - res = NULL; - - return res; -} - -char * -e_bconf_get_string (xmlNodePtr root, const char *name) -{ - char *val, *res; - - if ((val = e_bconf_get_value (root, name))) { - res = e_bconf_hex_decode (val); - g_free (val); - } else - res = NULL; - - return res; -} - - -/* lookup functions */ -typedef char * (* bconf_lookup_func) (xmlNodePtr root, const char *name, e_bconf_map_t *nap); - -static char * -bconf_lookup_bool (xmlNodePtr root, const char *name, e_bconf_map_t *map) -{ - return e_bconf_get_bool (root, name); -} - -static char * -bconf_lookup_long (xmlNodePtr root, const char *name, e_bconf_map_t *map) -{ - return e_bconf_get_long (root, name); -} - -static char * -bconf_lookup_string (xmlNodePtr root, const char *name, e_bconf_map_t *map) -{ - return e_bconf_get_string (root, name); -} - -static char * -bconf_lookup_enum (xmlNodePtr root, const char *name, e_bconf_map_t *map) -{ - int index = 0, i; - char *val; - - if ((val = e_bconf_get_value (root, name))) { - index = atoi (val); - g_free (val); - } - - for (i = 0; map->child[i].from; i++) { - if (i == index) - return g_strdup (map->child[i].from); - } - - return NULL; -} - - -static bconf_lookup_func lookup_table[] = { - bconf_lookup_bool, bconf_lookup_long, bconf_lookup_string, bconf_lookup_enum -}; - -static char * -get_name (const char *in, int index) -{ - GString *out = g_string_new (""); - char c, *res; - - while ((c = *in++)) { - if (c == '%') { - c = *in++; - switch (c) { - case '%': - g_string_append_c (out, '%'); - break; - case 'i': - g_string_append_printf (out, "%d", index); - break; - } - } else { - g_string_append_c (out, c); - } - } - - res = out->str; - g_string_free (out, FALSE); - - return res; -} - -static void -build_xml (xmlNodePtr root, e_bconf_map_t *map, int index, xmlNodePtr source) -{ - char *name, *value; - xmlNodePtr node; - - while (map->type != E_BCONF_MAP_END) { - if ((map->type & E_BCONF_MAP_MASK) == E_BCONF_MAP_CHILD) { - node = xmlNewChild (root, NULL, map->to, NULL); - build_xml (node, map->child, index, source); - } else { - name = get_name (map->from, index); - value = lookup_table[(map->type & E_BCONF_MAP_MASK) - 1] (source, name, map); - - d(printf ("key '%s=%s' -> ", name, value)); - - if (map->type & E_BCONF_MAP_CONTENT) { - if (value && value[0]) - xmlNewTextChild (root, NULL, map->to, value); - } else { - xmlSetProp (root, map->to, value); - } - - g_free (value); - g_free (name); - } - map++; - } -} - - -int -e_bconf_import_xml_blob (GConfClient *gconf, xmlDocPtr config_xmldb, e_bconf_map_t *map, - const char *bconf_path, const char *gconf_path, - const char *name, const char *idparam) -{ - xmlNodePtr source; - int count = 0, i; - GSList *list, *l; - char *val; - - source = e_bconf_get_path (config_xmldb, bconf_path); - if (source) { - list = NULL; - if ((val = e_bconf_get_value (source, "num"))) { - count = atoi (val); - g_free (val); - } - - d(printf("Found %d blobs at %s\n", count, bconf_path)); - - for (i = 0; i < count; i++) { - xmlDocPtr doc; - xmlNodePtr root; - xmlChar *xmlbuf; - int n; - - doc = xmlNewDoc ("1.0"); - root = xmlNewDocNode (doc, NULL, name, NULL); - xmlDocSetRootElement (doc, root); - - /* This could be set with a MAP_UID type ... */ - if (idparam) { - char buf[16]; - - sprintf (buf, "%d", i); - xmlSetProp (root, idparam, buf); - } - - build_xml (root, map, i, source); - - xmlDocDumpMemory (doc, &xmlbuf, &n); - xmlFreeDoc (doc); - - list = g_slist_append (list, xmlbuf); - } - - gconf_client_set_list (gconf, gconf_path, GCONF_VALUE_STRING, list, NULL); - - while (list) { - l = list->next; - xmlFree (list->data); - g_slist_free_1 (list); - list = l; - } - } else { - g_warning ("could not find '%s' in old config database, skipping", bconf_path); - } - - return 0; -} - - -static int gconf_type[] = { GCONF_VALUE_BOOL, GCONF_VALUE_BOOL, GCONF_VALUE_INT, GCONF_VALUE_STRING, GCONF_VALUE_STRING }; - -int -e_bconf_import (GConfClient *gconf, xmlDocPtr config_xmldb, e_gconf_map_list_t *remap_list) -{ - char *path, *val, *tmp; - e_gconf_map_t *map; - xmlNodePtr source; - GSList *list, *l; - char buf[32]; - int i, j, k; - - /* process all flat config */ - for (i = 0; remap_list[i].root; i++) { - d(printf ("Path: %s\n", remap_list[i].root)); - if (!(source = e_bconf_get_path (config_xmldb, remap_list[i].root))) - continue; - - map = remap_list[i].map; - for (j = 0; map[j].from; j++) { - if (map[j].type & E_GCONF_MAP_LIST) { - /* collapse a multi-entry indexed field into a list */ - list = NULL; - k = 0; - do { - path = get_name (map[j].from, k); - val = e_bconf_get_value (source, path); - d(printf ("finding path '%s' = '%s'\n", path, val)); - g_free (path); - if (val) { - switch (map[j].type & E_GCONF_MAP_MASK) { - case E_GCONF_MAP_BOOL: - case E_GCONF_MAP_INT: - list = g_slist_append (list, GINT_TO_POINTER (atoi (val))); - break; - case E_GCONF_MAP_STRING: - d(printf (" -> '%s'\n", e_bconf_hex_decode (val))); - list = g_slist_append (list, e_bconf_hex_decode (val)); - break; - } - - g_free (val); - k++; - } - } while (val); - - if (list) { - path = g_strdup_printf ("/apps/evolution/%s", map[j].to); - gconf_client_set_list (gconf, path, gconf_type[map[j].type & E_GCONF_MAP_MASK], list, NULL); - g_free (path); - if ((map[j].type & E_GCONF_MAP_MASK) == E_GCONF_MAP_STRING) - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); - } - - continue; - } else if (map[j].type == E_GCONF_MAP_ANYLIST) { - val = NULL; - } else { - if (!(val = e_bconf_get_value (source, map[j].from))) - continue; - } - - d(printf (" %s = '%s' -> %s [%d]\n", - map[j].from, - val == NULL ? "(null)" : val, - map[j].to, - map[j].type)); - - path = g_strdup_printf ("/apps/evolution/%s", map[j].to); - switch (map[j].type) { - case E_GCONF_MAP_BOOL: - gconf_client_set_bool (gconf, path, atoi (val), NULL); - break; - case E_GCONF_MAP_BOOLNOT: - gconf_client_set_bool (gconf, path, !atoi (val), NULL); - break; - case E_GCONF_MAP_INT: - gconf_client_set_int (gconf, path, atoi (val), NULL); - break; - case E_GCONF_MAP_STRING: - tmp = e_bconf_hex_decode (val); - gconf_client_set_string (gconf, path, tmp, NULL); - g_free (tmp); - break; - case E_GCONF_MAP_SIMPLESTRING: - gconf_client_set_string (gconf, path, val, NULL); - break; - case E_GCONF_MAP_FLOAT: - gconf_client_set_float (gconf, path, strtod (val, NULL), NULL); - break; - case E_GCONF_MAP_STRLIST: { - char *v = e_bconf_hex_decode (val); - char **t = g_strsplit (v, " !<-->! ", 8196); - - list = NULL; - for (k = 0; t[k]; k++) { - list = g_slist_append (list, t[k]); - d(printf (" [%d] = '%s'\n", k, t[k])); - } - - gconf_client_set_list (gconf, path, GCONF_VALUE_STRING, list, NULL); - g_slist_free (list); - g_strfreev (t); - g_free (v); - break; } - case E_GCONF_MAP_ANYLIST: { - xmlNodePtr node = source->children; - list = NULL; - - /* find the entry node */ - while (node) { - if (!strcmp (node->name, "entry")) { - int found; - - if ((tmp = xmlGetProp (node, "name"))) { - found = strcmp (tmp, map[j].from) == 0; - xmlFree (tmp); - if (found) - break; - } - } - - node = node->next; - } - - /* find the the any block */ - if (node) { - node = node->children; - while (node) { - if (strcmp (node->name, "any") == 0) - break; - node = node->next; - } - } - - /* skip to the value inside it */ - if (node) { - node = node->children; - while (node) { - if (strcmp (node->name, "value") == 0) - break; - node = node->next; - } - } - - if (node) { - node = node->children; - while (node) { - if (strcmp (node->name, "value") == 0) - list = g_slist_append (list, xmlNodeGetContent (node)); - node = node->next; - } - } - - /* & store */ - if (list) { - gconf_client_set_list (gconf, path, GCONF_VALUE_STRING, list, NULL); - while (list) { - l = list->next; - xmlFree (list->data); - g_slist_free_1 (list); - list = l; - } - } - - break; } - case E_GCONF_MAP_COLOUR: - sprintf (buf, "#%06x", atoi (val) & 0xffffff); - gconf_client_set_string (gconf, path, buf, NULL); - break; - } - - /* FIXME: handle errors */ - g_free (path); - g_free (val); - } - } - - return 0; -} diff --git a/e-util/e-bconf-map.h b/e-util/e-bconf-map.h deleted file mode 100644 index 8db5771401..0000000000 --- a/e-util/e-bconf-map.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef __E_BCONF_MAP_H__ -#define __E_BCONF_MAP_H__ - -#include <gconf/gconf-client.h> - -#include <libxml/tree.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -enum { - E_BCONF_MAP_END = 0, /* end of table */ - E_BCONF_MAP_BOOL, /* bool -> prop of name 'to' value true or false */ - E_BCONF_MAP_LONG, /* long -> prop of name 'to' value a long */ - E_BCONF_MAP_STRING, /* string -> prop of name 'to' */ - E_BCONF_MAP_ENUM, /* long/bool -> prop of name 'to', with the value indexed into the child map table's from field */ - E_BCONF_MAP_CHILD, /* a new child of name 'to' */ - E_BCONF_MAP_MASK = 0x3f, - E_BCONF_MAP_CONTENT = 0x80, /* if set, create a new node of name 'to' instead of a property */ -}; - -typedef struct _e_bconf_map { - char *from; - char *to; - int type; - struct _e_bconf_map *child; -} e_bconf_map_t; - - -char *e_bconf_hex_decode (const char *val); -char *e_bconf_url_decode (const char *val); - -xmlNodePtr e_bconf_get_path (xmlDocPtr doc, const char *path); -xmlNodePtr e_bconf_get_entry (xmlNodePtr root, const char *name); - -char *e_bconf_get_value (xmlNodePtr root, const char *name); -char *e_bconf_get_bool (xmlNodePtr root, const char *name); -char *e_bconf_get_long (xmlNodePtr root, const char *name); -char *e_bconf_get_string (xmlNodePtr root, const char *name); - -int e_bconf_import_xml_blob (GConfClient *gconf, xmlDocPtr config_xmldb, e_bconf_map_t *map, - const char *bconf_path, const char *gconf_path, - const char *name, const char *idparam); - - -enum { - E_GCONF_MAP_BOOL, - E_GCONF_MAP_BOOLNOT, - E_GCONF_MAP_INT, - E_GCONF_MAP_STRING, - E_GCONF_MAP_SIMPLESTRING, /* a non-encoded string */ - E_GCONF_MAP_COLOUR, - E_GCONF_MAP_FLOAT, /* bloody floats, who uses floats ... idiots */ - E_GCONF_MAP_STRLIST, /* strings separated to !<-->! -> gconf list */ - E_GCONF_MAP_ANYLIST, /* corba sequence corba string -> gconf list */ - E_GCONF_MAP_MASK = 0x7f, - E_GCONF_MAP_LIST = 0x80 /* from includes a %i field for the index of the key, to be converted to a list of type MAP_* */ -}; - -typedef struct { - char *from; - char *to; - int type; -} e_gconf_map_t; - -typedef struct { - char *root; - e_gconf_map_t *map; -} e_gconf_map_list_t; - -int e_bconf_import (GConfClient *gconf, xmlDocPtr config_xmldb, e_gconf_map_list_t *remap_list); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_BCONF_MAP_H__ */ diff --git a/e-util/e-categories-config.c b/e-util/e-categories-config.c deleted file mode 100644 index af5961ef5d..0000000000 --- a/e-util/e-categories-config.c +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Categories configuration. - * - * Author: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright 2001, Ximian, Inc. - */ - -#include <string.h> -#include <gtk/gtkdialog.h> -#include <libgnome/gnome-i18n.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <libedataserver/e-categories.h> -#include <libedataserverui/e-categories-dialog.h> -#include "e-categories-config.h" - -static GHashTable *icons_table = NULL; - -/** - * e_categories_config_get_icon_for: - * @category: Category for which to get the icon. - * @icon: A pointer to where the pixmap will be returned. - * @mask: A pointer to where the mask will be returned. - * - * Returns the icon (and associated mask) configured for the - * given category. - */ -gboolean -e_categories_config_get_icon_for (const char *category, GdkPixmap **pixmap, GdkBitmap **mask) -{ - char *icon_file; - GdkPixbuf *pixbuf; - GdkBitmap *tmp_mask; - - g_return_val_if_fail (pixmap != NULL, FALSE); - - icon_file = (char *) e_categories_get_icon_file_for (category); - if (!icon_file) { - *pixmap = NULL; - if (mask != NULL) - *mask = NULL; - return FALSE; - } - - /* load the icon in our list */ - pixbuf = gdk_pixbuf_new_from_file (icon_file, NULL); - if (!pixbuf) { - *pixmap = NULL; - if (mask != NULL) - *mask = NULL; - return FALSE; - } - - /* render the pixbuf to the pixmap and mask passed */ - gdk_pixbuf_render_pixmap_and_mask (pixbuf, pixmap, &tmp_mask, 1); - if (mask != NULL) - *mask = tmp_mask; - - return TRUE; -} - -/** - * e_categories_config_open_dialog_for_entry: - * entry: A GtkEntry on which to get/set the categories list. - * - * This is a self-contained function that lets you open a popup dialog for - * the user to select a list of categories. - * - * The @entry parameter is used, at initialization time, as the list of - * initial categories that are selected in the categories selection dialog. - * Then, when the user commits its changes, the list of selected categories - * is put back on the entry widget. - */ -void -e_categories_config_open_dialog_for_entry (GtkEntry *entry) -{ - GtkDialog *dialog; - const char *text; - char *categories; - int result; - - g_return_if_fail (entry != NULL); - g_return_if_fail (GTK_IS_ENTRY (entry)); - - text = gtk_entry_get_text (GTK_ENTRY (entry)); - dialog = GTK_DIALOG (e_categories_dialog_new (text)); - - gtk_window_set_transient_for (GTK_WINDOW (dialog), gtk_widget_get_toplevel (GTK_WIDGET (entry))); - - /* run the dialog */ - result = gtk_dialog_run (dialog); - - if (result == GTK_RESPONSE_OK) { - categories = e_categories_dialog_get_categories (E_CATEGORIES_DIALOG (dialog)); - gtk_entry_set_text (GTK_ENTRY (entry), categories); - } - - gtk_object_destroy (GTK_OBJECT (dialog)); -} diff --git a/e-util/e-categories-config.h b/e-util/e-categories-config.h deleted file mode 100644 index ed6b5639ae..0000000000 --- a/e-util/e-categories-config.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Categories configuration. - * - * Author: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright 2001, Ximian, Inc. - */ - -#ifndef __E_CATEGORIES_CONFIG_H__ -#define __E_CATEGORIES_CONFIG_H__ - -#include <glib.h> -#include <gdk/gdk.h> -#include <gtk/gtkentry.h> - -G_BEGIN_DECLS - -gboolean e_categories_config_get_icon_for (const char *category, - GdkPixmap **icon, - GdkBitmap **mask); -void e_categories_config_open_dialog_for_entry (GtkEntry *entry); - -G_END_DECLS - -#endif diff --git a/e-util/e-categories-master-list-wombat.c b/e-util/e-categories-master-list-wombat.c deleted file mode 100644 index 9e45199877..0000000000 --- a/e-util/e-categories-master-list-wombat.c +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-categories-master-list.c: the master list of categories. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 1999, 2000 Ximian, Inc. - */ -#include <config.h> - -#include "e-categories-master-list-wombat.h" -#include "e-categories-config.h" -#include "e-config-listener.h" - -#include <libxml/tree.h> -#include <libxml/parser.h> - -#define PARENT_TYPE e_categories_master_list_array_get_type () - -#define d(x) - -struct _ECategoriesMasterListWombatPriv { - EConfigListener *listener; - guint listener_id; -}; - -static ECategoriesMasterListArrayClass *parent_class; - -static void -ecmlw_load (ECategoriesMasterListWombat *ecmlw) -{ - char *string; - gboolean def; - - string = e_config_listener_get_string_with_default (ecmlw->priv->listener, - "/apps/evolution/general/category_master_list", - NULL, - &def); - /* parse the XML string */ - if (!def) { - e_categories_master_list_array_from_string (E_CATEGORIES_MASTER_LIST_ARRAY (ecmlw), - string); - } - - d(g_print ("load: %s\n", string?string:"(nil)")); - - g_free (string); -} - -static void -ecmlw_save (ECategoriesMasterListWombat *ecmlw) -{ - char *string; - - string = e_categories_master_list_array_to_string (E_CATEGORIES_MASTER_LIST_ARRAY (ecmlw)); - - d(g_print ("save: %s\n", string)); - - e_config_listener_set_string (ecmlw->priv->listener, - "/apps/evolution/general/category_master_list", - string); - - g_free (string); -} - -/** - * ecmlw_commit: - * @ecml: the master list to remove from. - */ -static void -ecmlw_commit (ECategoriesMasterList *ecml) -{ - ECategoriesMasterListWombat *ecmlw = E_CATEGORIES_MASTER_LIST_WOMBAT (ecml); - - ((ECategoriesMasterListClass *) parent_class)->commit (ecml); - - ecmlw_save (ecmlw); -} - - -/** - * ecmlw_reset: - * @ecml: the master list to reset. - */ -static void -ecmlw_reset (ECategoriesMasterList *ecml) -{ - ECategoriesMasterListWombat *ecmlw = E_CATEGORIES_MASTER_LIST_WOMBAT (ecml); - - ((ECategoriesMasterListClass *) parent_class)->reset (ecml); - - ecmlw_save (ecmlw); -} - -static void -ecmlw_dispose (GObject *object) -{ - ECategoriesMasterListWombat *ecmlw = E_CATEGORIES_MASTER_LIST_WOMBAT (object); - - if (ecmlw->priv) { - /* remove the listener */ - g_signal_handler_disconnect (ecmlw->priv->listener, - ecmlw->priv->listener_id); - - g_object_unref (ecmlw->priv->listener); - - g_free (ecmlw->priv); - ecmlw->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - - -static void -ecmlw_class_init (GObjectClass *object_class) -{ - ECategoriesMasterListClass *ecml_class = E_CATEGORIES_MASTER_LIST_CLASS(object_class); - - parent_class = g_type_class_ref (PARENT_TYPE); - - ecml_class->commit = ecmlw_commit; - - ecml_class->reset = ecmlw_reset ; - - object_class->dispose = ecmlw_dispose; -} - -static void -property_change_cb (EConfigListener *listener, - char *key, - gpointer user_data) -{ - ecmlw_load (user_data); -} - -static void -ecmlw_init (ECategoriesMasterListWombat *ecmlw) -{ - ecmlw->priv = g_new (ECategoriesMasterListWombatPriv, 1); - ecmlw->priv->listener = e_config_listener_new (); - - /* add a listener */ - ecmlw->priv->listener_id = - g_signal_connect (ecmlw->priv->listener, - "key_changed", - G_CALLBACK (property_change_cb), - ecmlw); - - ecmlw_load (ecmlw); -} - -GType -e_categories_master_list_wombat_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ECategoriesMasterListWombatClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ecmlw_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ECategoriesMasterListWombat), - 0, /* n_preallocs */ - (GInstanceInitFunc) ecmlw_init, - }; - - type = g_type_register_static (PARENT_TYPE, "ECategoriesMasterListWombat", &info, 0); - } - - return type; -} - -ECategoriesMasterList * -e_categories_master_list_wombat_new (void) -{ - return E_CATEGORIES_MASTER_LIST (g_object_new (E_TYPE_CATEGORIES_MASTER_LIST_WOMBAT, NULL)); -} diff --git a/e-util/e-categories-master-list-wombat.h b/e-util/e-categories-master-list-wombat.h deleted file mode 100644 index 024d7644e7..0000000000 --- a/e-util/e-categories-master-list-wombat.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_CATEGORIES_MASTER_LIST_WOMBAT_H_ -#define _E_CATEGORIES_MASTER_LIST_WOMBAT_H_ - -#include <gal/widgets/e-categories-master-list-array.h> - -G_BEGIN_DECLS - -#define E_TYPE_CATEGORIES_MASTER_LIST_WOMBAT (e_categories_master_list_wombat_get_type ()) -#define E_CATEGORIES_MASTER_LIST_WOMBAT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_CATEGORIES_MASTER_LIST_WOMBAT, ECategoriesMasterListWombat)) -#define E_CATEGORIES_MASTER_LIST_WOMBAT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_CATEGORIES_MASTER_LIST_WOMBAT, ECategoriesMasterListWombatClass)) -#define E_IS_CATEGORIES_MASTER_LIST_WOMBAT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_CATEGORIES_MASTER_LIST_WOMBAT)) -#define E_IS_CATEGORIES_MASTER_LIST_WOMBAT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_CATEGORIES_MASTER_LIST_WOMBAT)) - -typedef struct _ECategoriesMasterListWombatPriv ECategoriesMasterListWombatPriv; - -typedef struct { - ECategoriesMasterListArray base; - ECategoriesMasterListWombatPriv *priv; -} ECategoriesMasterListWombat; - -typedef struct { - ECategoriesMasterListArrayClass parent_class; -} ECategoriesMasterListWombatClass; - -GType e_categories_master_list_wombat_get_type (void); -ECategoriesMasterList *e_categories_master_list_wombat_new (void); - -G_END_DECLS - -#endif /* _E_CATEGORIES_MASTER_LIST_WOMBAT_H_ */ diff --git a/e-util/e-component-listener.c b/e-util/e-component-listener.c deleted file mode 100644 index 1e7027f33d..0000000000 --- a/e-util/e-component-listener.c +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Component listener. - * - * Author: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright 2002, Ximian, Inc. - */ - -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-object.h> -#include "e-component-listener.h" -#include <libgnome/gnome-i18n.h> - -#define PARENT_TYPE GTK_TYPE_OBJECT - -struct _EComponentListenerPrivate { - Bonobo_Unknown component; -}; - -static void e_component_listener_class_init (EComponentListenerClass *klass); -static void e_component_listener_init (EComponentListener *cl, EComponentListenerClass *klass); -static void e_component_listener_finalize (GObject *object); - -static GObjectClass *parent_class = NULL; -static GList *watched_connections = NULL; - -enum { - COMPONENT_DIED, - LAST_SIGNAL -}; - -static guint comp_listener_signals[LAST_SIGNAL]; - -static void -connection_listen_cb (gpointer object, gpointer user_data) -{ - GList *l, *next = NULL; - EComponentListener *cl; - - for (l = watched_connections; l != NULL; l = next) { - next = l->next; - cl = l->data; - - switch (ORBit_small_get_connection_status (cl->priv->component)) { - case ORBIT_CONNECTION_DISCONNECTED : - watched_connections = g_list_delete_link (watched_connections, l); - - g_object_ref (cl); - g_signal_emit (cl, comp_listener_signals[COMPONENT_DIED], 0); - cl->priv->component = CORBA_OBJECT_NIL; - g_object_unref (cl); - break; - default : - break; - } - } -} - -static void -e_component_listener_class_init (EComponentListenerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = e_component_listener_finalize; - klass->component_died = NULL; - - comp_listener_signals[COMPONENT_DIED] = - g_signal_new ("component_died", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EComponentListenerClass, component_died), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -e_component_listener_init (EComponentListener *cl, EComponentListenerClass *klass) -{ - /* allocate internal structure */ - cl->priv = g_new (EComponentListenerPrivate, 1); - cl->priv->component = CORBA_OBJECT_NIL; -} - -static void -e_component_listener_finalize (GObject *object) -{ - EComponentListener *cl = (EComponentListener *) object; - - g_return_if_fail (E_IS_COMPONENT_LISTENER (cl)); - - watched_connections = g_list_remove (watched_connections, cl); - - if (cl->priv->component != CORBA_OBJECT_NIL) - cl->priv->component = CORBA_OBJECT_NIL; - - /* free memory */ - g_free (cl->priv); - cl->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -GType -e_component_listener_get_type (void) -{ - static GType type = 0; - - if (!type) { - static GTypeInfo info = { - sizeof (EComponentListenerClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) e_component_listener_class_init, - NULL, NULL, - sizeof (EComponentListener), - 0, - (GInstanceInitFunc) e_component_listener_init - }; - type = g_type_register_static (G_TYPE_OBJECT, "EComponentListener", &info, 0); - } - - return type; -} - -/** - * e_component_listener_new - * @comp: Component to listen for. - * - * Create a new #EComponentListener object, which allows to listen - * for a given component and get notified when that component dies. - * - * Returns: a component listener object. - */ -EComponentListener * -e_component_listener_new (Bonobo_Unknown comp) -{ - EComponentListener *cl; - - g_return_val_if_fail (comp != NULL, NULL); - - cl = g_object_new (E_COMPONENT_LISTENER_TYPE, NULL); - cl->priv->component = comp; - - /* watch the connection */ - ORBit_small_listen_for_broken (comp, G_CALLBACK (connection_listen_cb), cl); - watched_connections = g_list_prepend (watched_connections, cl); - - return cl; -} - -Bonobo_Unknown -e_component_listener_get_component (EComponentListener *cl) -{ - g_return_val_if_fail (E_IS_COMPONENT_LISTENER (cl), CORBA_OBJECT_NIL); - return cl->priv->component; -} - -void -e_component_listener_set_component (EComponentListener *cl, Bonobo_Unknown comp) -{ - g_return_if_fail (E_IS_COMPONENT_LISTENER (cl)); - - cl->priv->component = comp; - ORBit_small_listen_for_broken (comp, G_CALLBACK (connection_listen_cb), cl); -} diff --git a/e-util/e-component-listener.h b/e-util/e-component-listener.h deleted file mode 100644 index 3f5694ecd0..0000000000 --- a/e-util/e-component-listener.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Component listener - * - * Author: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright 2002, Ximian, Inc. - */ - -#ifndef __E_COMPONENT_LISTENER_H__ -#define __E_COMPONENT_LISTENER_H__ - -#include <glib-object.h> -#include <bonobo/Bonobo.h> - -G_BEGIN_DECLS - -#define E_COMPONENT_LISTENER_TYPE (e_component_listener_get_type ()) -#define E_COMPONENT_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_COMPONENT_LISTENER_TYPE, EComponentListener)) -#define E_COMPONENT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_COMPONENT_LISTENER_TYPE, EComponentListenerClass)) -#define E_IS_COMPONENT_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_COMPONENT_LISTENER_TYPE)) -#define E_IS_COMPONENT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_COMPONENT_LISTENER_TYPE)) - -typedef struct _EComponentListenerPrivate EComponentListenerPrivate; - -typedef struct { - GObject object; - EComponentListenerPrivate *priv; -} EComponentListener; - -typedef struct { - GObjectClass parent_class; - - void (* component_died) (EComponentListener *cl); -} EComponentListenerClass; - -GType e_component_listener_get_type (void); -EComponentListener *e_component_listener_new (Bonobo_Unknown comp); - -Bonobo_Unknown e_component_listener_get_component (EComponentListener *cl); -void e_component_listener_set_component (EComponentListener *cl, - Bonobo_Unknown comp); - -G_END_DECLS - -#endif diff --git a/e-util/e-config-listener.c b/e-util/e-config-listener.c deleted file mode 100644 index ecc1b45fce..0000000000 --- a/e-util/e-config-listener.c +++ /dev/null @@ -1,607 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Configuration component listener - * - * Author: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright 2002, Ximian, Inc. - */ - -#include <string.h> -#include <gconf/gconf-client.h> -#include "e-config-listener.h" - -#define PARENT_TYPE G_TYPE_OBJECT - -typedef struct { - EConfigListener *cl; - guint lid; - char *key; - GConfValueType type; - union { - gboolean v_bool; - float v_float; - long v_long; - char *v_str; - } value; - gboolean used_default; -} KeyData; - -struct _EConfigListenerPrivate { - GConfClient *db; - GHashTable *keys; -}; - -static void e_config_listener_class_init (EConfigListenerClass *klass); -static void e_config_listener_init (EConfigListener *cl, EConfigListenerClass *klass); -static void e_config_listener_finalize (GObject *object); - -static GObjectClass *parent_class = NULL; - -enum { - KEY_CHANGED, - LAST_SIGNAL -}; - -static guint config_listener_signals[LAST_SIGNAL]; - -static void -e_config_listener_class_init (EConfigListenerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = e_config_listener_finalize; - klass->key_changed = NULL; - - config_listener_signals[KEY_CHANGED] = - g_signal_new ("key_changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EConfigListenerClass, key_changed), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - - /* make sure GConf is initialized */ - if (!gconf_is_initialized ()) - gconf_init (0, NULL, NULL); -} - -static void -e_config_listener_init (EConfigListener *cl, EConfigListenerClass *klass) -{ - /* allocate internal structure */ - cl->priv = g_new0 (EConfigListenerPrivate, 1); - - cl->priv->keys = g_hash_table_new (g_str_hash, g_str_equal); - cl->priv->db = gconf_client_get_default (); -} - -static void -free_key_hash (gpointer key, gpointer value, gpointer user_data) -{ - KeyData *kd = (KeyData *) value; - - g_return_if_fail (kd != NULL); - - gconf_client_notify_remove (kd->cl->priv->db, kd->lid); - - g_free (kd->key); - switch (kd->type) { - case GCONF_VALUE_STRING : - g_free (kd->value.v_str); - break; - default : - break; - } - - g_free (kd); -} - -static void -e_config_listener_finalize (GObject *object) -{ - EConfigListener *cl = (EConfigListener *) object; - - g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); - - g_hash_table_foreach (cl->priv->keys, (GHFunc) free_key_hash, NULL); - g_hash_table_destroy (cl->priv->keys); - cl->priv->keys = NULL; - - if (cl->priv->db != NULL) { - g_object_unref (G_OBJECT (cl->priv->db)); - cl->priv->db = NULL; - } - - g_free (cl->priv); - cl->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -GType -e_config_listener_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EConfigListenerClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) e_config_listener_class_init, - NULL, - NULL, - sizeof (EConfigListener), - 0, - (GInstanceInitFunc) e_config_listener_init - }; - type = g_type_register_static (PARENT_TYPE, "EConfigListener", &info, 0); - } - - return type; -} - -/** - * e_config_listener_new - * - * Create a new configuration listener, which is an object which - * allows to listen for changes in the configuration database. It keeps - * an updated copy of all requested configuration entries, so that - * access is much quicker and instantaneous. - * - * Returns: the newly created listener. - */ -EConfigListener * -e_config_listener_new (void) -{ - EConfigListener *cl; - - cl = g_object_new (E_CONFIG_LISTENER_TYPE, NULL); - return cl; -} - -static void -property_change_cb (GConfEngine *engine, - guint cnxn_id, - GConfEntry *entry, - gpointer user_data) -{ - KeyData *kd = (KeyData *) user_data; - - g_return_if_fail (entry != NULL); - g_return_if_fail (kd != NULL); - - /* free previous value */ - if (kd->type == GCONF_VALUE_STRING) - g_free (kd->value.v_str); - - /* set new value */ - if (entry->value->type == GCONF_VALUE_BOOL) { - kd->type = GCONF_VALUE_BOOL; - kd->value.v_bool = gconf_value_get_bool (entry->value); - } else if (entry->value->type == GCONF_VALUE_FLOAT) { - kd->type = GCONF_VALUE_FLOAT; - kd->value.v_float = gconf_value_get_float (entry->value); - } else if (entry->value->type == GCONF_VALUE_INT) { - kd->type = GCONF_VALUE_INT; - kd->value.v_long = gconf_value_get_int (entry->value); - } else if (entry->value->type == GCONF_VALUE_STRING) { - kd->type = GCONF_VALUE_STRING; - kd->value.v_str = g_strdup (gconf_value_get_string (entry->value)); - } else - return; - - g_signal_emit (G_OBJECT (kd->cl), config_listener_signals[KEY_CHANGED], 0, kd->key); -} - -static KeyData * -add_key (EConfigListener *cl, const char *key, GConfValueType type, - gpointer value, gboolean used_default) -{ - KeyData *kd; - - /* add the key to our hash table */ - kd = g_new0 (KeyData, 1); - kd->cl = cl; - kd->key = g_strdup (key); - kd->type = type; - switch (type) { - case GCONF_VALUE_BOOL : - memcpy (&kd->value.v_bool, value, sizeof (gboolean)); - break; - case GCONF_VALUE_FLOAT : - memcpy (&kd->value.v_float, value, sizeof (float)); - break; - case GCONF_VALUE_INT : - memcpy (&kd->value.v_long, value, sizeof (long)); - break; - case GCONF_VALUE_STRING : - kd->value.v_str = g_strdup ((const char *) value); - break; - default : - break; - } - - kd->used_default = used_default; - - /* add the listener for changes */ - gconf_client_add_dir (cl->priv->db, key, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - kd->lid = gconf_client_notify_add (cl->priv->db, key, - (GConfClientNotifyFunc) property_change_cb, - kd, NULL, NULL); - - g_hash_table_insert (cl->priv->keys, kd->key, kd); - - return kd; -} - -gboolean -e_config_listener_get_boolean (EConfigListener *cl, const char *key) -{ - return e_config_listener_get_boolean_with_default (cl, key, FALSE, NULL); -} - -gboolean -e_config_listener_get_boolean_with_default (EConfigListener *cl, - const char *key, - gboolean def, - gboolean *used_default) -{ - GConfValue *conf_value; - gboolean value; - KeyData *kd; - gpointer orig_key, orig_value; - - g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), FALSE); - g_return_val_if_fail (key != NULL, FALSE); - - /* search for the key in our hash table */ - if (!g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) { - /* not found, so retrieve it from the configuration database */ - conf_value = gconf_client_get (cl->priv->db, key, NULL); - if (conf_value) { - value = gconf_value_get_bool (conf_value); - kd = add_key (cl, key, GCONF_VALUE_BOOL, &value, FALSE); - gconf_value_free (conf_value); - - if (used_default != NULL) - *used_default = FALSE; - } else { - value = def; - kd = add_key (cl, key, GCONF_VALUE_BOOL, &def, TRUE); - - if (used_default != NULL) - *used_default = TRUE; - } - } else { - kd = (KeyData *) orig_value; - g_assert (kd != NULL); - - if (kd->type == GCONF_VALUE_BOOL) { - value = kd->value.v_bool; - if (used_default != NULL) - *used_default = kd->used_default; - } else - return FALSE; - } - - return value; -} - -float -e_config_listener_get_float (EConfigListener *cl, const char *key) -{ - return e_config_listener_get_float_with_default (cl, key, 0.0, NULL); -} - -float -e_config_listener_get_float_with_default (EConfigListener *cl, - const char *key, - float def, - gboolean *used_default) -{ - GConfValue *conf_value; - float value; - KeyData *kd; - gpointer orig_key, orig_value; - - g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), -1); - g_return_val_if_fail (key != NULL, -1); - - /* search for the key in our hash table */ - if (!g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) { - /* not found, so retrieve it from the configuration database */ - conf_value = gconf_client_get (cl->priv->db, key, NULL); - if (conf_value) { - value = gconf_value_get_float (conf_value); - kd = add_key (cl, key, GCONF_VALUE_FLOAT, &value, FALSE); - gconf_value_free (conf_value); - - if (used_default != NULL) - *used_default = FALSE; - } else { - value = def; - kd = add_key (cl, key, GCONF_VALUE_FLOAT, &def, TRUE); - - if (used_default != NULL) - *used_default = TRUE; - } - } else { - kd = (KeyData *) orig_value; - g_assert (kd != NULL); - - if (kd->type == GCONF_VALUE_FLOAT) { - value = kd->value.v_float; - if (used_default != NULL) - *used_default = kd->used_default; - } else - return -1; - } - - return value; -} - -long -e_config_listener_get_long (EConfigListener *cl, const char *key) -{ - return e_config_listener_get_long_with_default (cl, key, 0, NULL); -} - -long -e_config_listener_get_long_with_default (EConfigListener *cl, - const char *key, - long def, - gboolean *used_default) -{ - GConfValue *conf_value; - long value; - KeyData *kd; - gpointer orig_key, orig_value; - - g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), -1); - g_return_val_if_fail (key != NULL, -1); - - /* search for the key in our hash table */ - if (!g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) { - /* not found, so retrieve it from the configuration database */ - conf_value = gconf_client_get (cl->priv->db, key, NULL); - if (conf_value) { - value = gconf_value_get_int (conf_value); - kd = add_key (cl, key, GCONF_VALUE_INT, &value, FALSE); - gconf_value_free (conf_value); - - if (used_default != NULL) - *used_default = FALSE; - } else { - value = def; - kd = add_key (cl, key, GCONF_VALUE_INT, &def, TRUE); - - if (used_default != NULL) - *used_default = TRUE; - } - } else { - kd = (KeyData *) orig_value; - g_assert (kd != NULL); - - if (kd->type == GCONF_VALUE_INT) { - value = kd->value.v_long; - if (used_default != NULL) - *used_default = kd->used_default; - } else - return -1; - } - - return value; -} - -char * -e_config_listener_get_string (EConfigListener *cl, const char *key) -{ - return e_config_listener_get_string_with_default (cl, key, NULL, NULL); -} - -char * -e_config_listener_get_string_with_default (EConfigListener *cl, - const char *key, - const char *def, - gboolean *used_default) -{ - GConfValue *conf_value; - char *str; - KeyData *kd; - gpointer orig_key, orig_value; - - g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), NULL); - g_return_val_if_fail (key != NULL, NULL); - - /* search for the key in our hash table */ - if (!g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) { - /* not found, so retrieve it from the configuration database */ - conf_value = gconf_client_get (cl->priv->db, key, NULL); - if (conf_value) { - str = g_strdup (gconf_value_get_string (conf_value)); - kd = add_key (cl, key, GCONF_VALUE_STRING, (gpointer) str, FALSE); - gconf_value_free (conf_value); - - if (used_default != NULL) - *used_default = FALSE; - } else { - str = g_strdup (def); - kd = add_key (cl, key, GCONF_VALUE_STRING, (gpointer) str, TRUE); - - if (used_default != NULL) - *used_default = TRUE; - } - } else { - kd = (KeyData *) orig_value; - g_assert (kd != NULL); - - if (kd->type == GCONF_VALUE_STRING) { - str = g_strdup (kd->value.v_str); - if (used_default != NULL) - *used_default = kd->used_default; - } else - return NULL; - } - - return str; -} - -void -e_config_listener_set_boolean (EConfigListener *cl, const char *key, gboolean value) -{ - KeyData *kd; - GError *err = NULL; - - g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); - g_return_if_fail (key != NULL); - - /* check that the value is not the same */ - if (value == e_config_listener_get_boolean_with_default (cl, key, 0, NULL)) - return; - - gconf_client_set_bool (cl->priv->db, key, value, &err); - if (err) { - g_warning ("e_config_listener_set_bool: %s", err->message); - g_error_free (err); - } else { - /* update the internal copy */ - kd = g_hash_table_lookup (cl->priv->keys, key); - if (kd) - kd->value.v_bool = value; - } -} - -void -e_config_listener_set_float (EConfigListener *cl, const char *key, float value) -{ - KeyData *kd; - GError *err = NULL; - - g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); - g_return_if_fail (key != NULL); - - /* check that the value is not the same */ - if (value == e_config_listener_get_float_with_default (cl, key, 0, NULL)) - return; - - gconf_client_set_float (cl->priv->db, key, value, &err); - if (err) { - g_warning ("e_config_listener_set_float: %s", err->message); - g_error_free (err); - } else { - /* update the internal copy */ - kd = g_hash_table_lookup (cl->priv->keys, key); - if (kd) - kd->value.v_float = value; - } -} - -void -e_config_listener_set_long (EConfigListener *cl, const char *key, long value) -{ - KeyData *kd; - GError *err = NULL; - - g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); - g_return_if_fail (key != NULL); - - /* check that the value is not the same */ - if (value == e_config_listener_get_long_with_default (cl, key, 0, NULL)) - return; - - gconf_client_set_int (cl->priv->db, key, value, &err); - if (err) { - g_warning ("e_config_listener_set_long: %s", err->message); - g_error_free (err); - } else { - /* update the internal copy */ - kd = g_hash_table_lookup (cl->priv->keys, key); - if (kd) - kd->value.v_long = value; - } -} - -void -e_config_listener_set_string (EConfigListener *cl, const char *key, const char *value) -{ - char *s1, *s2; - KeyData *kd; - GError *err = NULL; - - g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); - g_return_if_fail (key != NULL); - - /* check that the value is not the same */ - s1 = (char *) value; - s2 = e_config_listener_get_string_with_default (cl, key, NULL, NULL); - if (!strcmp (s1 ? s1 : "", s2 ? s2 : "")) { - g_free (s2); - return; - } - - g_free (s2); - - gconf_client_set_string (cl->priv->db, key, value, &err); - if (err) { - g_warning ("e_config_listener_set_bool: %s", err->message); - g_error_free (err); - } else { - /* update the internal copy */ - kd = g_hash_table_lookup (cl->priv->keys, key); - if (kd) { - g_free (kd->value.v_str); - kd->value.v_str = g_strdup (value); - } - } -} - -void -e_config_listener_remove_value (EConfigListener *cl, const char *key) -{ - gpointer orig_key, orig_value; - - g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); - g_return_if_fail (key != NULL); - - if (g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) { - KeyData *kd = orig_value; - - g_hash_table_remove (cl->priv->keys, key); - g_free (kd->key); - if (kd->type == GCONF_VALUE_STRING) - g_free (kd->value.v_str); - gconf_client_notify_remove (cl->priv->db, kd->lid); - - g_free (kd); - } - - gconf_client_unset (cl->priv->db, key, NULL); -} - -void -e_config_listener_remove_dir (EConfigListener *cl, const char *dir) -{ - GSList *slist, *iter; - const gchar *key; - - g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); - g_return_if_fail (dir != NULL); - - slist = gconf_client_all_entries (cl->priv->db, dir, NULL); - for (iter = slist; iter != NULL; iter = iter->next) { - GConfEntry *entry = iter->data; - - key = gconf_entry_get_key (entry); - gconf_client_unset (cl->priv->db, key, NULL); - gconf_entry_free (entry); - } - - g_slist_free (slist); -} diff --git a/e-util/e-config-listener.h b/e-util/e-config-listener.h deleted file mode 100644 index 9b331a7c8a..0000000000 --- a/e-util/e-config-listener.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Configuration component listener - * - * Author: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright 2002, Ximian, Inc. - */ - -#ifndef __E_CONFIG_LISTENER_H__ -#define __E_CONFIG_LISTENER_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define E_CONFIG_LISTENER_TYPE (e_config_listener_get_type ()) -#define E_CONFIG_LISTENER(o) (G_TYPE_CHECK_INSTANCECAST ((o), E_CONFIG_LISTENER_TYPE, EConfigListener)) -#define E_CONFIG_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_CONFIG_LISTENER_TYPE, EConfigListenerClass)) -#define E_IS_CONFIG_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CONFIG_LISTENER_TYPE)) -#define E_IS_CONFIG_LISTENER_CLASS(k) (GT_TYPE_CHECK_CLASS_TYPE ((k), E_CONFIG_LISTENER_TYPE)) - -typedef struct _EConfigListenerPrivate EConfigListenerPrivate; - -typedef struct { - GObject object; - EConfigListenerPrivate *priv; -} EConfigListener; - -typedef struct { - GObjectClass parent_class; - - void (* key_changed) (EConfigListener *cl, const char *key); -} EConfigListenerClass; - -GType e_config_listener_get_type (void); -EConfigListener *e_config_listener_new (void); - -gboolean e_config_listener_get_boolean (EConfigListener *cl, const char *key); -gboolean e_config_listener_get_boolean_with_default (EConfigListener *cl, - const char *key, - gboolean def, - gboolean *used_default); -float e_config_listener_get_float (EConfigListener *cl, const char *key); -float e_config_listener_get_float_with_default (EConfigListener *cl, - const char *key, - float def, - gboolean *used_default); -long e_config_listener_get_long (EConfigListener *cl, const char *key); -long e_config_listener_get_long_with_default (EConfigListener *cl, - const char *key, - long def, - gboolean *used_default); -char *e_config_listener_get_string (EConfigListener *cl, const char *key); -char *e_config_listener_get_string_with_default (EConfigListener *cl, - const char *key, - const char *def, - gboolean *used_default); -void e_config_listener_set_boolean (EConfigListener *cl, - const char *key, - gboolean value); -void e_config_listener_set_float (EConfigListener *cl, - const char *key, - float value); -void e_config_listener_set_long (EConfigListener *cl, - const char *key, - long value); -void e_config_listener_set_string (EConfigListener *cl, - const char *key, - const char *value); - -void e_config_listener_remove_value (EConfigListener *cl, - const char *key); -void e_config_listener_remove_dir (EConfigListener *cl, - const char *dir); - -G_END_DECLS - -#endif diff --git a/e-util/e-config.c b/e-util/e-config.c deleted file mode 100644 index 064ca44a79..0000000000 --- a/e-util/e-config.c +++ /dev/null @@ -1,1508 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include <gtk/gtknotebook.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtktable.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkalignment.h> - -#include <libgnomeui/gnome-druid.h> -#include <libgnomeui/gnome-druid-page-standard.h> -#include <libgnomeui/gnome-druid-page-edge.h> - -#include "e-config.h" - -#include <e-util/e-icon-factory.h> - -#include <libgnome/gnome-i18n.h> - -#define d(x) - -struct _EConfigFactory { - struct _EConfigFactory *next, *prev; - - char *id; - EConfigFactoryFunc factory; - void *factory_data; -}; - -struct _menu_node { - struct _menu_node *next, *prev; - - GSList *menu; - EConfigItemsFunc free; - EConfigItemsFunc abort; - EConfigItemsFunc commit; - void *data; -}; - -struct _widget_node { - struct _widget_node *next, *prev; - - EConfig *config; - - struct _menu_node *context; - EConfigItem *item; - struct _GtkWidget *widget; /* widget created by the factory, if any */ - struct _GtkWidget *frame; /* if created by us */ - - int empty:1; /* set if empty (i.e. hidden) */ -}; - -struct _check_node { - struct _check_node *next, *prev; - - char *pageid; - EConfigCheckFunc check; - void *data; -}; - -struct _EConfigPrivate { - EDList menus; - EDList widgets; - EDList checks; - - struct _widget_node *druid_page; /* current druid page if using the druid */ -}; - -static GObjectClass *ep_parent; - -static void -ep_init(GObject *o) -{ - EConfig *emp = (EConfig *)o; - struct _EConfigPrivate *p; - - p = emp->priv = g_malloc0(sizeof(struct _EConfigPrivate)); - - e_dlist_init(&p->menus); - e_dlist_init(&p->widgets); - e_dlist_init(&p->checks); -} - -static void -ep_finalise(GObject *o) -{ - EConfig *emp = (EConfig *)o; - struct _EConfigPrivate *p = emp->priv; - struct _menu_node *mnode; - struct _widget_node *wn; - struct _check_node *cn; - - d(printf("finalising EConfig %p\n", o)); - - g_free(emp->id); - - while ((mnode = (struct _menu_node *)e_dlist_remhead(&p->menus))) { - if (mnode->free) - mnode->free(emp, mnode->menu, mnode->data); - - g_free(mnode); - } - - while ( (wn = (struct _widget_node *)e_dlist_remhead(&p->widgets)) ) { - g_free(wn); - } - - while ( (cn = (struct _check_node *)e_dlist_remhead(&p->widgets)) ) { - g_free(cn->pageid); - g_free(cn); - } - - g_free(p); - - ((GObjectClass *)ep_parent)->finalize(o); -} - -static void -ec_target_free(EConfig *ep, EConfigTarget *t) -{ - g_free(t); - g_object_unref(ep); -} - -static void -ec_set_target(EConfig *emp, EConfigTarget *target) -{ - if (emp->target) - e_config_target_free(emp, target); - - emp->target = target; -} - -static void -ep_class_init(GObjectClass *klass) -{ - d(printf("EConfig class init %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - klass->finalize = ep_finalise; - ((EConfigClass *)klass)->set_target = ec_set_target; - ((EConfigClass *)klass)->target_free = ec_target_free; -} - -static void -ep_base_init(GObjectClass *klass) -{ - e_dlist_init(&((EConfigClass *)klass)->factories); -} - -/** - * e_config_get_type: - * - * Standard GObject method. Used to subclass for the concrete - * implementations. - * - * Return value: EConfig type. - **/ -GType -e_config_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EConfigClass), - (GBaseInitFunc)ep_base_init, NULL, - (GClassInitFunc)ep_class_init, NULL, NULL, - sizeof(EConfig), 0, - (GInstanceInitFunc)ep_init - }; - ep_parent = g_type_class_ref(G_TYPE_OBJECT); - type = g_type_register_static(G_TYPE_OBJECT, "EConfig", &info, 0); - } - - return type; -} - -/** - * e_config_construct: - * @ep: The instance to initialise. - * @type: The type of configuration manager, @E_CONFIG_BOOK or - * @E_CONFIG_DRUID. - * @id: The name of the configuration window this manager drives. - * - * Used by implementing classes to initialise base parameters. - * - * Return value: @ep is returned. - **/ -EConfig *e_config_construct(EConfig *ep, int type, const char *id) -{ - g_assert(type == E_CONFIG_BOOK || type == E_CONFIG_DRUID); - - ep->type = type; - ep->id = g_strdup(id); - - return ep; -} - -/** - * e_config_add_items: - * @ec: An initialised implementing instance of EConfig. - * @items: A list of EConfigItem's to add to the configuration manager - * @ec. - * @commitfunc: If supplied, called to commit the configuration items - * to persistent storage. - * @abortfunc: If supplied, called to abort/undo the storage of these - * items permanently. - * @freefunc: If supplied, called to free the item list (and/or items) - * once they are no longer needed. - * @data: Data for the callback methods. - * - * Add new EConfigItems to the configuration window. Nothing will be - * done with them until the widget is built. - * - * TODO: perhaps commit and abort should just be signals. - **/ -void -e_config_add_items(EConfig *ec, GSList *items, EConfigItemsFunc commitfunc, EConfigItemsFunc abortfunc, EConfigItemsFunc freefunc, void *data) -{ - struct _menu_node *node; - - node = g_malloc(sizeof(*node)); - node->menu = items; - node->commit = commitfunc; - node->abort = abortfunc; - node->free = freefunc; - node->data = data; - e_dlist_addtail(&ec->priv->menus, (EDListNode *)node); -} - -/** - * e_config_add_page_check: - * @ec: Initialised implemeting instance of EConfig. - * @pageid: pageid to check. - * @check: checking callback. - * @data: user-data for the callback. - * - * Add a page-checking function callback. It will be called to validate the - * data in the given page or pages. If @pageid is NULL then it will be called - * to validate every page, or the whole configuration window. - * - * In the latter case, the pageid in the callback will be either the - * specific page being checked, or NULL when the whole config window - * is being checked. - * - * The page check function is used to validate input before allowing - * the druid to continue or the notebook to close. - **/ -void -e_config_add_page_check(EConfig *ec, const char *pageid, EConfigCheckFunc check, void *data) -{ - struct _check_node *cn; - - cn = g_malloc0(sizeof(*cn)); - cn->pageid = g_strdup(pageid); - cn->check = check; - cn->data = data; - - e_dlist_addtail(&ec->priv->checks, (EDListNode *)cn); -} - -static void -ec_add_static_items(EConfig *ec) -{ - struct _EConfigFactory *f; - EConfigClass *klass = (EConfigClass *)G_OBJECT_GET_CLASS(ec); - - f = (struct _EConfigFactory *)klass->factories.head; - while (f->next) { - if (f->id == NULL - || !strcmp(f->id, ec->id)) { - f->factory(ec, f->factory_data); - } - f = f->next; - } -} - -static int -ep_cmp(const void *ap, const void *bp) -{ - struct _widget_node *a = *((void **)ap); - struct _widget_node *b = *((void **)bp); - - return strcmp(a->item->path, b->item->path); -} - -static void -ec_druid_check_current(EConfig *ec) -{ - g_return_if_fail(ec->priv->druid_page != NULL); - - if (e_config_page_check(ec, ec->priv->druid_page->item->path)) { - gtk_widget_set_sensitive(((GnomeDruid *)ec->widget)->next, TRUE); - } else { - gtk_widget_set_sensitive(((GnomeDruid *)ec->widget)->next, FALSE); - } -} - -static void -ec_druid_cancel(GnomeDruid *druid, struct _widget_node *wn) -{ - d(printf("finishing druid, calling abort\n")); - e_config_abort(wn->config); - - if (wn->config->window) - gtk_widget_destroy(wn->config->window); -} - -static void -ec_druid_finish(GnomeDruidPage *page, GnomeDruid *druid, struct _widget_node *wn) -{ - d(printf("finishing druid, calling commit\n")); - e_config_commit(wn->config); - - /* TODO: allow the commit to fail? Do we care? */ - if (wn->config->window) - gtk_widget_destroy(wn->config->window); -} - -static void -ec_druid_prepare(GnomeDruidPage *page, GnomeDruid *druid, struct _widget_node *wn) -{ - d(printf("prepare page '%s'\n", wn->item->path)); - wn->config->priv->druid_page = wn; - ec_druid_check_current(wn->config); -} - -static gboolean -ec_druid_prev(GnomeDruidPage *page, GnomeDruid *druid, struct _widget_node *wn) -{ - EConfig *ec = wn->config; - - d(printf("prev page from '%s'\n", wn->item->path)); - if (wn->prev) { - for (wn = wn->prev;wn->prev;wn=wn->prev) { - if (!wn->empty && wn->frame != NULL - && (wn->item->type == E_CONFIG_PAGE - || wn->item->type == E_CONFIG_PAGE_START - || wn->item->type == E_CONFIG_PAGE_FINISH)) - break; - } - } - - if (wn->prev) { - d(printf(" is %s\n",wn->item->path)); - gnome_druid_set_page((GnomeDruid *)ec->widget, (GnomeDruidPage *)wn->frame); - ec->priv->druid_page = wn; - } else { - /* do we need to indicate first? */ - ec->priv->druid_page = NULL; - } - - return wn->prev != NULL; -} - -static gboolean -ec_druid_next(GnomeDruidPage *page, GnomeDruid *druid, struct _widget_node *wn) -{ - EConfig *ec = wn->config; - - d(printf("next page from '%s'\n", wn->item->path)); - if (wn->next) { - for (wn = wn->next;wn->next;wn=wn->next) { - if (!wn->empty && wn->frame != NULL - && (wn->item->type == E_CONFIG_PAGE - || wn->item->type == E_CONFIG_PAGE_START - || wn->item->type == E_CONFIG_PAGE_FINISH)) - break; - } - } - - if (wn->next) { - d(printf(" is %s\n",wn->item->path)); - gnome_druid_set_page((GnomeDruid *)ec->widget, (GnomeDruidPage *)wn->frame); - ec->priv->druid_page = wn; - } else { - /* do we need to indicate last? */ - ec->priv->druid_page = NULL; - } - - return wn->next != NULL; -} - -static void -ec_rebuild(EConfig *emp) -{ - struct _EConfigPrivate *p = emp->priv; - struct _widget_node *wn, *sectionnode = NULL, *pagenode = NULL; - GtkWidget *book = NULL, *page = NULL, *section = NULL, *root = NULL, *druid = NULL; - int pageno = 0, sectionno = 0, itemno = 0; - - d(printf("target changed, rebuilding:\n")); - - /* TODO: This code is pretty complex, and will probably just - * become more complex with time. It could possibly be split - * into the two base types, but there would be a lot of code - * duplication */ - - for (wn = (struct _widget_node *)p->widgets.head;wn->next;wn=wn->next) { - struct _EConfigItem *item = wn->item; - GtkWidget *w; - - d(printf(" '%s'\n", item->path)); - - /* If the last section doesn't contain anything, hide it */ - if (sectionnode != NULL - && sectionnode->frame != NULL - && (item->type == E_CONFIG_PAGE_START - || item->type == E_CONFIG_PAGE_FINISH - || item->type == E_CONFIG_PAGE - || item->type == E_CONFIG_SECTION - || item->type == E_CONFIG_SECTION_TABLE)) { - if ( (sectionnode->empty = itemno == 0) ) { - gtk_widget_hide(sectionnode->frame); - sectionno--; - } else - gtk_widget_show(sectionnode->frame); - d(printf("%s section '%s' [sections=%d]\n", sectionnode->empty?"hiding":"showing", sectionnode->item->path, sectionno)); - } - - /* If the last page doesn't contain anything, hide it */ - if (pagenode != NULL - && pagenode->frame != NULL - && (item->type == E_CONFIG_PAGE_START - || item->type == E_CONFIG_PAGE_FINISH - || item->type == E_CONFIG_PAGE)) { - if ( (pagenode->empty = sectionno == 0) ) { - gtk_widget_hide(pagenode->frame); - pageno--; - } else - gtk_widget_show(pagenode->frame); - d(printf("%s page '%s' [section=%d]\n", pagenode->empty?"hiding":"showing", pagenode->item->path, pageno)); - } - - /* Now process the item */ - switch (item->type) { - case E_CONFIG_BOOK: - case E_CONFIG_DRUID: - /* Only one of BOOK or DRUID may be define, it - is used by the defining code to mark the - type of the config window. It is - cross-checked with the code's defined - type. */ - if (root != NULL) { - g_warning("EConfig book/druid redefined at: %s", item->path); - break; - } - - if (wn->widget == NULL) { - if (item->type != emp->type) { - g_warning("EConfig book/druid type mismatch"); - break; - } - if (item->factory) { - root = item->factory(emp, item, NULL, wn->widget, wn->context->data); - } else if (item->type == E_CONFIG_BOOK) { - root = book = gtk_notebook_new(); - gtk_widget_show(book); - } else if (item->type == E_CONFIG_DRUID) { - root = druid = gnome_druid_new(); - gtk_widget_show(druid); - } else - abort(); - - if (item->type == E_CONFIG_DRUID) - g_signal_connect(root, "cancel", G_CALLBACK(ec_druid_cancel), wn); - - emp->widget = root; - wn->widget = root; - } else { - root = wn->widget; - } - - if (item->type == E_CONFIG_BOOK) - book = root; - else - druid = root; - - page = NULL; - pagenode = NULL; - section = NULL; - sectionnode = NULL; - pageno = 0; - sectionno = 0; - break; - case E_CONFIG_PAGE_START: - case E_CONFIG_PAGE_FINISH: - if (root == NULL) { - g_warning("EConfig page defined before container widget: %s", item->path); - break; - } - if (emp->type != E_CONFIG_DRUID) { - g_warning("EConfig druid start/finish pages can't be used on E_CONFIG_BOOKs"); - break; - } - - if (wn->widget == NULL) { - if (item->factory) { - page = item->factory(emp, item, root, wn->frame, wn->context->data); - } else { - page = gnome_druid_page_edge_new(item->type == E_CONFIG_PAGE_START?GNOME_EDGE_START:GNOME_EDGE_FINISH); - gtk_widget_show(page); - gnome_druid_page_edge_set_title((GnomeDruidPageEdge *)page, item->label); - gnome_druid_insert_page((GnomeDruid *)druid, pagenode?(GnomeDruidPage *)pagenode->frame:NULL, (GnomeDruidPage *)page); - } - if (item->type == E_CONFIG_PAGE_FINISH) { - g_signal_connect(page, "back", G_CALLBACK(ec_druid_prev), wn); - g_signal_connect(page, "finish", G_CALLBACK(ec_druid_finish), wn); - } else - g_signal_connect(page, "next", G_CALLBACK(ec_druid_next), wn); - wn->frame = page; - wn->widget = page; - } - pageno++; - page = NULL; - pagenode = wn; /* need this for previous page linking */ - section = NULL; - sectionnode = NULL; - sectionno = 1; /* never want to hide these */ - break; - case E_CONFIG_PAGE: { - int connect = 0; /* connect druid signals */ - - /* CONFIG_PAGEs depend on the config type. - E_CONFIG_BOOK: - The page is a VBox, stored in the notebook. - E_CONFIG_DRUID - The page is a GnomeDruidPageStandard, - any sections automatically added are added to - the vbox inside it. */ - sectionno = 0; - if (root == NULL) { - g_warning("EConfig page defined before container widget: %s", item->path); - break; - } - - if (item->factory) { - page = item->factory(emp, item, root, wn->frame, wn->context->data); - if (emp->type == E_CONFIG_DRUID) { - if (page) { - g_assert(GNOME_IS_DRUID_PAGE_STANDARD(page)); - connect = wn->frame != page; - wn->frame = page; - page = ((GnomeDruidPageStandard *)page)->vbox; - } else - wn->frame = page; - } else { - wn->frame = page; - if (page) - gtk_notebook_reorder_child((GtkNotebook *)book, page, pageno); - } - if (page) - sectionno = 1; - } else if (wn->widget == NULL) { - if (emp->type == E_CONFIG_DRUID) { - w = gnome_druid_page_standard_new(); - gtk_widget_show(w); - gnome_druid_page_standard_set_title((GnomeDruidPageStandard *)w, item->label); - gnome_druid_insert_page((GnomeDruid *)druid, pagenode?(GnomeDruidPage *)pagenode->frame:NULL, (GnomeDruidPage *)w); - wn->frame = w; - page = ((GnomeDruidPageStandard *)w)->vbox; - connect = TRUE; - } else { - w = gtk_label_new_with_mnemonic (item->label); - gtk_widget_show(w); - page = gtk_vbox_new(FALSE, 12); - gtk_container_set_border_width((GtkContainer *)page, 12); - gtk_widget_show(page); - gtk_notebook_insert_page((GtkNotebook *)book, page, w, pageno); - wn->frame = page; - } - } else - page = wn->widget; - - d(printf("page %d:%s widget %p\n", pageno, item->path, page)); - - if (wn->widget && wn->widget != page) { - d(printf("destroy old widget for page '%s'\n", item->path)); - gtk_widget_destroy(wn->widget); - } - - if (connect) { - g_signal_connect(wn->frame, "next", G_CALLBACK(ec_druid_next), wn); - g_signal_connect(wn->frame, "back", G_CALLBACK(ec_druid_prev), wn); - /* GnomeDruid bug, need to connect_after */ - g_signal_connect_after(wn->frame, "prepare", G_CALLBACK(ec_druid_prepare), wn); - } - - pageno++; - pagenode = wn; - section = NULL; - sectionnode = NULL; - wn->widget = page; - if (page) - g_signal_connect(page, "destroy", G_CALLBACK(gtk_widget_destroyed), &wn->widget); - break; } - case E_CONFIG_SECTION: - case E_CONFIG_SECTION_TABLE: - /* The section factory is always called with - the parent vbox object. Even for druid - pages. */ - if (page == NULL) { - /*g_warning("EConfig section '%s' has no parent page", item->path);*/ - section = NULL; - wn->widget = NULL; - wn->frame = NULL; - goto nopage; - } - - itemno = 0; - if (item->factory) { - section = item->factory(emp, item, page, wn->widget, wn->context->data); - wn->frame = section; - if (section) - itemno = 1; - - if (section - && ((item->type == E_CONFIG_SECTION && !GTK_IS_BOX(section)) - || (item->type == E_CONFIG_SECTION_TABLE && !GTK_IS_TABLE(section)))) - g_warning("EConfig section type is wrong"); - } else { - GtkWidget *frame; - GtkWidget *label = NULL; - - if (wn->frame) { - d(printf("Item %s, clearing generated section widget\n", wn->item->path)); - gtk_widget_destroy(wn->frame); - wn->widget = NULL; - wn->frame = NULL; - } - - if (item->label) { - char *txt = g_strdup_printf("<span weight=\"bold\">%s</span>", item->label); - - label = g_object_new(gtk_label_get_type(), - "label", txt, - "use_markup", TRUE, - "xalign", 0.0, NULL); - g_free(txt); - } - - if (item->type == E_CONFIG_SECTION) - section = gtk_vbox_new(FALSE, 6); - else { - section = gtk_table_new(1, 1, FALSE); - gtk_table_set_col_spacings((GtkTable *)section, 6); - gtk_table_set_row_spacings((GtkTable *)section, 6); - } - - frame = g_object_new(gtk_frame_get_type(), - "shadow_type", GTK_SHADOW_NONE, - "label_widget", label, - "child", g_object_new(gtk_alignment_get_type(), - "left_padding", 12, - "top_padding", 6, - "child", section, NULL), - NULL); - gtk_widget_show_all(frame); - gtk_box_pack_start((GtkBox *)page, frame, FALSE, FALSE, 0); - wn->frame = frame; - } - nopage: - if (wn->widget && wn->widget != section) { - d(printf("destroy old widget for section '%s'\n", item->path)); - gtk_widget_destroy(wn->widget); - } - - d(printf("Item %s, setting section widget\n", wn->item->path)); - - sectionno++; - wn->widget = section; - if (section) - g_signal_connect(section, "destroy", G_CALLBACK(gtk_widget_destroyed), &wn->widget); - sectionnode = wn; - break; - case E_CONFIG_ITEM: - case E_CONFIG_ITEM_TABLE: - /* generated sections never retain their widgets on a rebuild */ - if (sectionnode->item->factory == NULL) - wn->widget = NULL; - - /* ITEMs are called with the section parent. - The type depends on the section type, - either a GtkTable, or a GtkVBox */ - w = NULL; - if (section == NULL) { - wn->widget = NULL; - wn->frame = NULL; - g_warning("EConfig item has no parent section: %s", item->path); - } else if ((item->type == E_CONFIG_ITEM && !GTK_IS_BOX(section)) - || (item->type == E_CONFIG_ITEM_TABLE && !GTK_IS_TABLE(section))) - g_warning("EConfig item parent type is incorrect: %s", item->path); - else if (item->factory) - w = item->factory(emp, item, section, wn->widget, wn->context->data); - - d(printf("item %d:%s widget %p\n", itemno, item->path, w)); - - if (wn->widget && wn->widget != w) { - d(printf("destroy old widget for item '%s'\n", item->path)); - gtk_widget_destroy(wn->widget); - } - - wn->widget = w; - if (w) { - g_signal_connect(w, "destroy", G_CALLBACK(gtk_widget_destroyed), &wn->widget); - itemno++; - } - break; - } - } - - /* If the last section doesn't contain anything, hide it */ - if (sectionnode != NULL && sectionnode->frame != NULL) { - if ( (sectionnode->empty = itemno == 0) ) { - gtk_widget_hide(sectionnode->frame); - sectionno--; - } else - gtk_widget_show(sectionnode->frame); - d(printf("%s section '%s' [sections=%d]\n", sectionnode->empty?"hiding":"showing", sectionnode->item->path, sectionno)); - } - - /* If the last page doesn't contain anything, hide it */ - if (pagenode != NULL && pagenode->frame != NULL) { - if ( (pagenode->empty = sectionno == 0) ) { - gtk_widget_hide(pagenode->frame); - pageno--; - } else - gtk_widget_show(pagenode->frame); - d(printf("%s page '%s' [section=%d]\n", pagenode->empty?"hiding":"showing", pagenode->item->path, pageno)); - } - - if (book) { - /* make this depend on flags?? */ - if (gtk_notebook_get_n_pages((GtkNotebook *)book) == 1) { - gtk_notebook_set_show_tabs((GtkNotebook *)book, FALSE); - gtk_notebook_set_show_border((GtkNotebook *)book, FALSE); - } - } -} - -/** - * e_config_set_target: - * @emp: An initialised EConfig. - * @target: A target allocated from @emp. - * - * Sets the target object for the config window. Generally the target - * is set only once, and will supply its own "changed" signal which - * can be used to drive the modal. This is a virtual method so that - * the implementing class can connect to the changed signal and - * initiate a e_config_target_changed() call where appropriate. - **/ -void -e_config_set_target(EConfig *emp, EConfigTarget *target) -{ - if (emp->target != target) - ((EConfigClass *)G_OBJECT_GET_CLASS(emp))->set_target(emp, target); -} - -static void -ec_widget_destroy(GtkWidget *w, EConfig *ec) -{ - if (ec->target) { - e_config_target_free(ec, ec->target); - ec->target = NULL; - } - - g_object_unref(ec); -} - -/** - * e_config_create_widget: - * @emp: An initialised EConfig object. - * - * Create the widget described by @emp. Only the core widget - * appropriate for the given type is created, i.e. a GtkNotebook for - * the E_CONFIG_BOOK type and a GnomeDruid for the E_CONFIG_DRUID - * type. - * - * This object will be self-driving, but will not close itself once - * complete. - * - * Unless reffed otherwise, the management object @emp will be - * finalised when the widget is. - * - * Return value: The widget, also available in @emp.widget - **/ -GtkWidget * -e_config_create_widget(EConfig *emp) -{ - struct _EConfigPrivate *p = emp->priv; - struct _menu_node *mnode; - GPtrArray *items = g_ptr_array_new(); - GSList *l; - /*char *domain = NULL;*/ - int i; - - g_assert(emp->target != NULL); - - ec_add_static_items(emp); - - /* FIXME: need to override old ones with new names */ - for (mnode = (struct _menu_node *)p->menus.head;mnode->next;mnode=mnode->next) - for (l=mnode->menu; l; l = l->next) { - struct _EConfigItem *item = l->data; - struct _widget_node *wn = g_malloc0(sizeof(*wn)); - - wn->item = item; - wn->context = mnode; - wn->config = emp; - g_ptr_array_add(items, wn); - } - - qsort(items->pdata, items->len, sizeof(items->pdata[0]), ep_cmp); - - for (i=0;i<items->len;i++) { - struct _widget_node *wn = items->pdata[i]; - - e_dlist_addtail(&p->widgets, (EDListNode *)wn); - } - - g_ptr_array_free(items, TRUE); - ec_rebuild(emp); - - /* auto-unref it */ - g_signal_connect(emp->widget, "destroy", G_CALLBACK(ec_widget_destroy), emp); - - /* FIXME: for some reason ec_rebuild puts the widget on page 1, this is just to override that */ - if (emp->type == E_CONFIG_BOOK) - gtk_notebook_set_current_page((GtkNotebook *)emp->widget, 0); - - return emp->widget; -} - -static void -ec_dialog_response(GtkWidget *d, int id, EConfig *ec) -{ - if (id == GTK_RESPONSE_OK) - e_config_commit(ec); - else - e_config_abort(ec); - - gtk_widget_destroy(d); -} - -/** - * e_config_create_window: - * @emp: Initialised and configured EMConfig derived instance. - * @parent: Parent window or NULL. - * @title: Title of window or dialog. - * - * Create a managed GtkWindow object from @emp. This window will be - * fully driven by the EConfig @emp. If @emp.type is - * @E_CONFIG_DRUID, then this will be a toplevel GtkWindow containing - * a GnomeDruid. If it is @E_CONFIG_BOOK then it will be a GtkDialog - * containing a Nnotebook. - * - * Unless reffed otherwise, the management object @emp will be - * finalised when the widget is. - * - * Return value: The window widget. This is also stored in @emp.window. - **/ -GtkWidget * -e_config_create_window(EConfig *emp, struct _GtkWindow *parent, const char *title) -{ - GtkWidget *w; - - e_config_create_widget(emp); - - if (emp->type == E_CONFIG_BOOK) { - w = gtk_dialog_new_with_buttons(title, parent, - GTK_DIALOG_DESTROY_WITH_PARENT | - GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - g_signal_connect(w, "response", G_CALLBACK(ec_dialog_response), emp); - - gtk_widget_ensure_style (w); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (w)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (w)->action_area), 12); - - gtk_box_pack_start((GtkBox *)((GtkDialog *)w)->vbox, emp->widget, TRUE, TRUE, 0); - } else { - /* response is handled directly by the druid stuff */ - w = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title ((GtkWindow *)w, title); - gtk_container_add((GtkContainer *)w, emp->widget); - gtk_window_set_type_hint((GtkWindow *)w, GDK_WINDOW_TYPE_HINT_DIALOG); - } - - emp->window = w; - gtk_widget_show(w); - - return w; -} - -/** - * e_config_target_changed: - * @emp: - * @how: - * - * Indicate that the target has changed. This may be called by the - * self-aware target itself, or by the driving code. If @how is - * %E_CONFIG_TARGET_CHANGED_REBUILD, then the entire configuration - * widget may be recreated based on the changed target. - * - * This is used to sensitise Druid next/back buttons and the Apply - * button for the Notebook mode. - **/ -void e_config_target_changed(EConfig *emp, e_config_target_change_t how) -{ - if (how == E_CONFIG_TARGET_CHANGED_REBUILD) - ec_rebuild(emp); - - if (emp->type == E_CONFIG_DRUID) { - if (emp->priv->druid_page) { - gnome_druid_set_page((GnomeDruid *)emp->widget, (GnomeDruidPage *)emp->priv->druid_page->frame); - ec_druid_check_current(emp); - } - } else { - if (emp->window) { - if (e_config_page_check(emp, NULL)) { - gtk_dialog_set_response_sensitive((GtkDialog *)emp->window, GTK_RESPONSE_OK, TRUE); - } else { - gtk_dialog_set_response_sensitive((GtkDialog *)emp->window, GTK_RESPONSE_OK, FALSE); - } - } - } - - /* virtual method/signal? */ -} - -/** - * e_config_abort: - * @ec: - * - * Signify that the stateful configuration changes must be discarded - * to all listeners. This is used by self-driven druid or notebook, or - * may be used by code using the widget directly. - **/ -void e_config_abort(EConfig *ec) -{ - struct _EConfigPrivate *p = ec->priv; - struct _menu_node *mnode; - - /* TODO: should these just be signals? */ - - for (mnode = (struct _menu_node *)p->menus.head;mnode->next;mnode=mnode->next) - if (mnode->abort) - mnode->abort(ec, mnode->menu, mnode->data); -} - -/** - * e_config_commit: - * @ec: - * - * Signify that the stateful configuration changes should be saved. - * This is used by the self-driven druid or notebook, or may be used - * by code driving the widget directly. - **/ -void e_config_commit(EConfig *ec) -{ - struct _EConfigPrivate *p = ec->priv; - struct _menu_node *mnode; - - /* TODO: should these just be signals? */ - - for (mnode = (struct _menu_node *)p->menus.head;mnode->next;mnode=mnode->next) - if (mnode->commit) - mnode->commit(ec, mnode->menu, mnode->data); -} - -/** - * e_config_page_check: - * @ec: - * @pageid: The path of the page item. - * - * Check that a given page is complete. If @pageid is NULL, then check - * the whole config. No check is made that the page actually exists. - * - * Return value: FALSE if the data is inconsistent/incomplete. - **/ -gboolean e_config_page_check(EConfig *ec, const char *pageid) -{ - struct _EConfigPrivate *p = ec->priv; - struct _check_node *mnode; - - for (mnode = (struct _check_node *)p->checks.head;mnode->next;mnode=mnode->next) - if ((pageid == NULL - || mnode->pageid == NULL - || strcmp(mnode->pageid, pageid) == 0) - && !mnode->check(ec, pageid, mnode->data)) - return FALSE; - - return TRUE; -} - -/** - * e_config_page_get: - * @ec: - * @pageid: The path of the page item. - * - * Retrieve the page widget corresponding to @pageid. - * - * Return value: The page widget. It will be the root GtkNotebook - * container or the GnomeDruidPage object. - **/ -GtkWidget *e_config_page_get(EConfig *ec, const char *pageid) -{ - struct _widget_node *wn; - - for (wn = (struct _widget_node *)ec->priv->widgets.head;wn->next;wn=wn->next) - if (!wn->empty - && (wn->item->type == E_CONFIG_PAGE - || wn->item->type == E_CONFIG_PAGE_START - || wn->item->type == E_CONFIG_PAGE_FINISH) - && !strcmp(wn->item->path, pageid)) - return wn->frame; - - return NULL; -} - -/** - * e_config_page_next: - * @ec: - * @pageid: The path of the page item. - * - * Find the path of the next visible page after @pageid. If @pageid - * is NULL then find the first visible page. - * - * Return value: The path of the next page, or @NULL if @pageid was the - * last configured and visible page. - **/ -const char *e_config_page_next(EConfig *ec, const char *pageid) -{ - struct _widget_node *wn; - int found; - - found = pageid == NULL ? 1:0; - for (wn = (struct _widget_node *)ec->priv->widgets.head;wn->next;wn=wn->next) - if (!wn->empty - && (wn->item->type == E_CONFIG_PAGE - || wn->item->type == E_CONFIG_PAGE_START - || wn->item->type == E_CONFIG_PAGE_FINISH)) { - if (found) - return wn->item->path; - else if (strcmp(wn->item->path, pageid) == 0) - found = 1; - } - - return NULL; -} - -/** - * e_config_page_next: - * @ec: - * @pageid: The path of the page item. - * - * Find the path of the previous visible page before @pageid. If @pageid - * is NULL then find the last visible page. - * - * Return value: The path of the previous page, or @NULL if @pageid was the - * first configured and visible page. - **/ -const char *e_config_page_prev(EConfig *ec, const char *pageid) -{ - struct _widget_node *wn; - int found; - - found = pageid == NULL ? 1:0; - for (wn = (struct _widget_node *)ec->priv->widgets.tailpred;wn->prev;wn=wn->prev) - if (!wn->empty - && (wn->item->type == E_CONFIG_PAGE - || wn->item->type == E_CONFIG_PAGE_START - || wn->item->type == E_CONFIG_PAGE_FINISH)) { - if (found) - return wn->item->path; - else if (strcmp(wn->item->path, pageid) == 0) - found = 1; - } - - return NULL; -} - -/* ********************************************************************** */ - -/** - * e_config_class_add_factory: - * @klass: Implementing class pointer. - * @id: The name of the configuration window you're interested in. - * This may be NULL to be called for all windows. - * @func: An EConfigFactoryFunc to call when the window @id is being - * created. - * @data: Callback data. - * - * Add a config factory which will be called to add_items() any - * extra items's if wants to, to the current Config window. - * - * TODO: Make the id a pattern? - * - * Return value: A handle to the factory. - **/ -EConfigFactory * -e_config_class_add_factory(EConfigClass *klass, const char *id, EConfigFactoryFunc func, void *data) -{ - struct _EConfigFactory *f = g_malloc0(sizeof(*f)); - - f->id = g_strdup(id); - f->factory = func; - f->factory_data = data; - e_dlist_addtail(&klass->factories, (EDListNode *)f); - - return f; -} - -/** - * e_config_class_remove_factory: - * @f: Handle from :class_add_factory() call. - * - * Remove a config factory. The handle @f may only be removed once. - **/ -void -e_config_class_remove_factory(EConfigClass *klass, EConfigFactory *f) -{ - e_dlist_remove((EDListNode *)f); - g_free(f->id); - g_free(f); -} - -/** - * e_config_target_new: - * @ep: Parent EConfig object. - * @type: type, up to implementor - * @size: Size of object to allocate. - * - * Allocate a new config target suitable for this class. Implementing - * classes will define the actual content of the target. - **/ -void *e_config_target_new(EConfig *ep, int type, size_t size) -{ - EConfigTarget *t; - - g_assert(size >= sizeof(EConfigTarget)); - - t = g_malloc0(size); - t->config = ep; - g_object_ref(ep); - t->type = type; - - return t; -} - -/** - * e_config_target_free: - * @ep: Parent EConfig object. - * @o: The target to fre. - * - * Free a target. The implementing class can override this method to - * free custom targets. - **/ -void -e_config_target_free(EConfig *ep, void *o) -{ - EConfigTarget *t = o; - - ((EConfigClass *)G_OBJECT_GET_CLASS(ep))->target_free(ep, t); -} - -/* ********************************************************************** */ - -/* Config menu plugin handler */ - -/* -<e-plugin - class="org.gnome.mail.plugin.config:1.0" - id="org.gnome.mail.plugin.config.item:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelimap.so" - name="imap" - description="IMAP4 and IMAP4v1 mail store"> - <hook class="org.gnome.mail.configMenu:1.0" - handler="HandleConfig"> - <menu id="any" target="select"> - <item - type="item|toggle|radio|image|submenu|bar" - active - path="foo/bar" - label="label" - icon="foo" - activate="ep_view_emacs"/> - </menu> - </extension> - -*/ - -static void *emph_parent_class; -#define emph ((EConfigHook *)eph) - -static const EPluginHookTargetKey ech_item_types[] = { - { "book", E_CONFIG_BOOK }, - { "druid", E_CONFIG_DRUID }, - - { "page", E_CONFIG_PAGE }, - { "page_start", E_CONFIG_PAGE_START }, - { "page_finish", E_CONFIG_PAGE_FINISH }, - { "section", E_CONFIG_SECTION }, - { "section_table", E_CONFIG_SECTION_TABLE }, - { "item", E_CONFIG_ITEM }, - { "item_table", E_CONFIG_ITEM_TABLE }, - { 0 }, -}; - -static void -ech_commit(EConfig *ec, GSList *items, void *data) -{ - struct _EConfigHookGroup *group = data; - - if (group->commit && group->hook->hook.plugin->enabled) - e_plugin_invoke(group->hook->hook.plugin, group->commit, ec->target); -} - -static void -ech_abort(EConfig *ec, GSList *items, void *data) -{ - struct _EConfigHookGroup *group = data; - - if (group->abort && group->hook->hook.plugin->enabled) - e_plugin_invoke(group->hook->hook.plugin, group->abort, ec->target); -} - -static gboolean -ech_check(EConfig *ec, const char *pageid, void *data) -{ - struct _EConfigHookGroup *group = data; - EConfigHookPageCheckData hdata; - - if (!group->hook->hook.plugin->enabled) - return TRUE; - - hdata.config = ec; - hdata.target = ec->target; - hdata.pageid = pageid?pageid:""; - - return GPOINTER_TO_INT(e_plugin_invoke(group->hook->hook.plugin, group->check, &hdata)); -} - -static void -ech_config_factory(EConfig *emp, void *data) -{ - struct _EConfigHookGroup *group = data; - - d(printf("config factory called %s\n", group->id?group->id:"all menus")); - - if (emp->target->type != group->target_type - || !group->hook->hook.plugin->enabled) - return; - - if (group->items) - e_config_add_items(emp, group->items, ech_commit, ech_abort, NULL, group); - - if (group->check) - e_config_add_page_check(emp, NULL, ech_check, group); -} - -static void -emph_free_item(struct _EConfigItem *item) -{ - g_free(item->path); - g_free(item->label); - g_free(item->user_data); - g_free(item); -} - -static void -emph_free_group(struct _EConfigHookGroup *group) -{ - g_slist_foreach(group->items, (GFunc)emph_free_item, NULL); - g_slist_free(group->items); - - g_free(group->id); - g_free(group); -} - -static struct _GtkWidget * -ech_config_widget_factory(EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget *old, void *data) -{ - struct _EConfigHookGroup *group = data; - - if (group->hook->hook.plugin->enabled) { - EConfigHookItemFactoryData hdata; - - hdata.config = ec; - hdata.item = item; - hdata.target = ec->target; - hdata.parent = parent; - hdata.old = old; - - return (struct _GtkWidget *)e_plugin_invoke(group->hook->hook.plugin, (char *)item->user_data, &hdata); - } else - return NULL; -} - -static struct _EConfigItem * -emph_construct_item(EPluginHook *eph, EConfigHookGroup *menu, xmlNodePtr root, EConfigHookTargetMap *map) -{ - struct _EConfigItem *item; - - d(printf(" loading config item\n")); - item = g_malloc0(sizeof(*item)); - if ((item->type = e_plugin_hook_id(root, ech_item_types, "type")) == -1) - goto error; - item->path = e_plugin_xml_prop(root, "path"); - item->label = e_plugin_xml_prop_domain(root, "label", eph->plugin->domain); - item->user_data = e_plugin_xml_prop(root, "factory"); - - if (item->path == NULL - || (item->label == NULL && item->user_data == NULL)) - goto error; - - if (item->user_data) - item->factory = ech_config_widget_factory; - - d(printf(" path=%s label=%s factory=%s\n", item->path, item->label, (char *)item->user_data)); - - return item; -error: - d(printf("error!\n")); - emph_free_item(item); - return NULL; -} - -static struct _EConfigHookGroup * -emph_construct_menu(EPluginHook *eph, xmlNodePtr root) -{ - struct _EConfigHookGroup *menu; - xmlNodePtr node; - EConfigHookTargetMap *map; - EConfigHookClass *klass = (EConfigHookClass *)G_OBJECT_GET_CLASS(eph); - char *tmp; - - d(printf(" loading menu\n")); - menu = g_malloc0(sizeof(*menu)); - - tmp = xmlGetProp(root, "target"); - if (tmp == NULL) - goto error; - map = g_hash_table_lookup(klass->target_map, tmp); - xmlFree(tmp); - if (map == NULL) - goto error; - - menu->target_type = map->id; - menu->id = e_plugin_xml_prop(root, "id"); - if (menu->id == NULL) { - g_warning("Plugin '%s' missing 'id' field in group for '%s'\n", eph->plugin->name, - ((EPluginHookClass *)G_OBJECT_GET_CLASS(eph))->id); - goto error; - } - menu->check = e_plugin_xml_prop(root, "check"); - menu->commit = e_plugin_xml_prop(root, "commit"); - menu->abort = e_plugin_xml_prop(root, "abort"); - menu->hook = (EConfigHook *)eph; - node = root->children; - while (node) { - if (0 == strcmp(node->name, "item")) { - struct _EConfigItem *item; - - item = emph_construct_item(eph, menu, node, map); - if (item) - menu->items = g_slist_append(menu->items, item); - } - node = node->next; - } - - return menu; -error: - emph_free_group(menu); - return NULL; -} - -static int -emph_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) -{ - xmlNodePtr node; - EConfigClass *klass; - - d(printf("loading config hook\n")); - - if (((EPluginHookClass *)emph_parent_class)->construct(eph, ep, root) == -1) - return -1; - - klass = ((EConfigHookClass *)G_OBJECT_GET_CLASS(eph))->config_class; - - node = root->children; - while (node) { - if (strcmp(node->name, "group") == 0) { - struct _EConfigHookGroup *group; - - group = emph_construct_menu(eph, node); - if (group) { - e_config_class_add_factory(klass, group->id, ech_config_factory, group); - emph->groups = g_slist_append(emph->groups, group); - } - } - node = node->next; - } - - eph->plugin = ep; - - return 0; -} - -static void -emph_finalise(GObject *o) -{ - EPluginHook *eph = (EPluginHook *)o; - - g_slist_foreach(emph->groups, (GFunc)emph_free_group, NULL); - g_slist_free(emph->groups); - - ((GObjectClass *)emph_parent_class)->finalize(o); -} - -static void -emph_class_init(EPluginHookClass *klass) -{ - ((GObjectClass *)klass)->finalize = emph_finalise; - klass->construct = emph_construct; - - /* this is actually an abstract implementation but list it anyway */ - klass->id = "org.gnome.evolution.config:1.0"; - - d(printf("EConfigHook: init class %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - ((EConfigHookClass *)klass)->target_map = g_hash_table_new(g_str_hash, g_str_equal); - ((EConfigHookClass *)klass)->config_class = g_type_class_ref(e_config_get_type()); -} - -/** - * e_config_hook_get_type: - * - * Standard GObject function to get the object type. - * - * Return value: The EConfigHook class type. - **/ -GType -e_config_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EConfigHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL, - sizeof(EConfigHook), 0, (GInstanceInitFunc) NULL, - }; - - emph_parent_class = g_type_class_ref(e_plugin_hook_get_type()); - type = g_type_register_static(e_plugin_hook_get_type(), "EConfigHook", &info, 0); - } - - return type; -} - -/** - * e_config_hook_class_add_target_map: - * - * @klass: The dervied EconfigHook class. - * @map: A map used to describe a single EConfigTarget type for this - * class. - * - * Add a targe tmap to a concrete derived class of EConfig. The - * target map enumates the target types available for the implenting - * class. - **/ -void e_config_hook_class_add_target_map(EConfigHookClass *klass, const EConfigHookTargetMap *map) -{ - g_hash_table_insert(klass->target_map, (void *)map->type, (void *)map); -} diff --git a/e-util/e-config.h b/e-util/e-config.h deleted file mode 100644 index d2ba37ee5c..0000000000 --- a/e-util/e-config.h +++ /dev/null @@ -1,392 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michel Zucchi <notzed@ximian.com> - * - * Copyright 2003 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __E_CONFIG_H__ -#define __E_CONFIG_H__ - -#include <glib-object.h> -#include "libedataserver/e-msgport.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -struct _GtkWindow; -struct _GtkWidget; - -/* This is a config window management/merging class. */ - -typedef struct _EConfig EConfig; -typedef struct _EConfigClass EConfigClass; - -typedef struct _EConfigItem EConfigItem; -typedef struct _EConfigFactory EConfigFactory; -typedef struct _EConfigTarget EConfigTarget; - -typedef void (*EConfigFactoryFunc)(EConfig *ec, void *data); - -typedef gboolean (*EConfigCheckFunc)(EConfig *ec, const char *pageid, void *data); - -typedef void (*EConfigItemsFunc)(EConfig *ec, GSList *items, void *data); - -typedef struct _GtkWidget * (*EConfigItemFactoryFunc)(EConfig *ec, EConfigItem *, struct _GtkWidget *parent, struct _GtkWidget *old, void *data); - -/* ok so this is all a bit bogussy - we need to map to glade stuff instead */ - -/* Add types? - if no factory, setup appropriate container ? - if factory, then assume that returns the right sort of object? - what about pages ? -*/ - -/** - * enum _e_config_target_changed_t - Target changed mode. - * - * @E_CONFIG_TARGET_CHANGED_STATE: A state of the target has changed. - * @E_CONFIG_TARGET_CHANGED_REBUILD: A state of the target has - * changed, and the UI must be reconfigured as a result. - * - * How the target has changed. If @E_CONFIG_TARGET_CHANGED_REBUILD then a - * widget reconfigure is necessary, otherwise it is used to check if - * the widget is complete yet. - **/ -typedef -enum _e_config_target_change_t { - E_CONFIG_TARGET_CHANGED_STATE, - E_CONFIG_TARGET_CHANGED_REBUILD, -} e_config_target_change_t; - -/** - * enum _e_config_t - configuration item type. - * - * @E_CONFIG_BOOK: A notebook item. Only one of this or - * @E_CONFIG_DRUID may be included in the item list for the entire - * configuration description. - * @E_CONFIG_DRUID: A druid item. Only one of this or @E_CONFIG_BOOK - * may be included in the item list for the entire configutation - * description. - * @E_CONFIG_PAGE: A configuration page. The item @label will be - * either the notebook tab label or the druid page title if no factory - * is supplied. - * @E_CONFIG_PAGE_START: A druid start page. Only one of these may be - * supplied for a druid and it should be the first page in the druid. - * @E_CONFIG_PAGE_FINISH: A druid finish page. Only one of these may - * be supplied for a druid and it should be the last page of the druid. - * @E_CONFIG_SECTION: A section in the configuration page. A page for - * this section must have already been defined. The item @label if - * supplied will be setup as a borderless hig-compliant frame title. - * The content of the section will be a GtkVBox. If a factory is used - * then it is up to the factory method to create the section and add - * it to the parent page, and return a GtkVBox for following sections. - * @E_CONFIG_SECTION_TABLE: A table section. The same as an - * @E_CONFIG_SECTION but the content object is a GtkTable instead. - * @E_CONFIG_ITEM: A configuration item. It must have a parent - * section defined in the configuration system. - * @E_CONFIG_ITEM_TABLE: A configuration item with a parent - * @E_CONFIG_SECTION_TABLE. - * - * A configuration item type for each configuration item added to the - * EConfig object. These are merged from all contributors to the - * configuration window, and then processed to form the combined - * display. - **/ -enum _e_config_t { - /* use one and only one of these for any given config-window id */ - E_CONFIG_BOOK, - E_CONFIG_DRUID, - - E_CONFIG_PAGE, - E_CONFIG_PAGE_START, /* only allowed in druid types */ - E_CONFIG_PAGE_FINISH, /* only allowed in druid types */ - E_CONFIG_SECTION, - E_CONFIG_SECTION_TABLE, - E_CONFIG_ITEM, - E_CONFIG_ITEM_TABLE, /* only allowed in table sections */ -}; - -/** - * struct _EConfigItem - A configuration item. - * - * @type: The configuration item type. - * @path: An absolute path positioning this item in the configuration - * window. This will be used as a sort key for an ASCII sort to - * position the item in the layout tree. - * @label: A label or section title string which is used if no factory - * is supplied to title the page or section. - * @factory: If supplied, this will be invoked instead to create the - * appropriate item. - * @user_data: User data for the factory. - * - * The basic descriptor of a configuration item. This may be - * subclassed to store extra context information for each item. - **/ -struct _EConfigItem { - enum _e_config_t type; - char *path; /* absolute path, must sort ascii-lexographically into the right spot */ - char *label; - EConfigItemFactoryFunc factory; - void *user_data; -}; - -/** - * struct _EConfigTarget - configuration context. - * - * @config: The parent object. - * @widget: A target-specific parent widget. - * @type: The type of target, defined by implementing classes. - * - * The base target object is used as the parent and placeholder for - * configuration context for a given configuration window. It is - * subclassed by implementing classes to provide domain-specific - * context. - **/ -struct _EConfigTarget { - struct _EConfig *config; - struct _GtkWidget *widget; /* used if you need a parent toplevel, if available */ - - guint32 type; - - /* implementation fields follow, depends on window type */ -}; - -/** - * struct _EConfig - A configuration management object. - * - * @object: Superclass. - * @priv: Private data. - * @type: Either @E_CONFIG_BOOK or @E_CONFIG_DRIUD, describing the - * root window type. - * @id: The globally unique identifider for this configuration window, - * used for hooking into it. - * @target: The current target. - * @widget: The GtkNoteBook or GnomeDruid created after - * :create_widget() is called that represents the merged and combined - * configuration window. - * @window: If :create_window() is called, then the containing - * toplevel GtkDialog or GtkWindow appropriate for the @type of - * configuration window created. - * - **/ -struct _EConfig { - GObject object; - - struct _EConfigPrivate *priv; - - int type; /* E_CONFIG_BOOK or E_CONFIG_DRUID */ - - char *id; - - EConfigTarget *target; - - struct _GtkWidget *widget; /* the generated internal */ - struct _GtkWidget *window; /* the window widget, GtkWindow or GtkDialog */ -}; - -/** - * struct _EConfigClass - Configuration management abstract class. - * - * @object_class: Superclass. - * @factories: A list of factories registered on this type of - * configuration manager. - * @set_target: A virtual method used to set the target on the - * configuration manager. This is used by subclasses so they may hook - * into changes on the target to propery drive the manager. - * @target_free: A virtual method used to free the target in an - * implementation-defined way. - * - **/ -struct _EConfigClass { - GObjectClass object_class; - - EDList factories; - - void (*set_target)(EConfig *ep, EConfigTarget *t); - - void (*target_free)(EConfig *ep, EConfigTarget *t); -}; - -GType e_config_get_type(void); - -/* Static class methods */ -EConfigFactory *e_config_class_add_factory(EConfigClass *klass, const char *id, EConfigFactoryFunc func, void *data); -void e_config_class_remove_factory(EConfigClass *klass, EConfigFactory *f); - -EConfig *e_config_construct(EConfig *, int type, const char *id); - -void e_config_add_items(EConfig *, GSList *items, EConfigItemsFunc commitfunc, EConfigItemsFunc abortfunc, EConfigItemsFunc freefunc, void *data); -void e_config_add_page_check(EConfig *, const char *pageid, EConfigCheckFunc, void *data); - -void e_config_set_target(EConfig *emp, EConfigTarget *target); -struct _GtkWidget *e_config_create_widget(EConfig *); -struct _GtkWidget *e_config_create_window(EConfig *emp, struct _GtkWindow *parent, const char *title); - -void e_config_target_changed(EConfig *emp, e_config_target_change_t how); - -gboolean e_config_page_check(EConfig *, const char *); - -struct _GtkWidget *e_config_page_get(EConfig *ec, const char *pageid); -const char *e_config_page_next(EConfig *ec, const char *pageid); -const char *e_config_page_prev(EConfig *ec, const char *pageid); - -void e_config_abort(EConfig *); -void e_config_commit(EConfig *); - -void *e_config_target_new(EConfig *, int type, size_t size); -void e_config_target_free(EConfig *, void *); - -/* ********************************************************************** */ - -/* config plugin target, they are closely integrated */ - -/* To implement a basic config plugin, you just need to subclass - this and initialise the class target type tables */ - -#include "e-util/e-plugin.h" - -typedef struct _EConfigHookGroup EConfigHookGroup; -typedef struct _EConfigHook EConfigHook; -typedef struct _EConfigHookClass EConfigHookClass; - -typedef struct _EPluginHookTargetMap EConfigHookTargetMap; -typedef struct _EPluginHookTargetKey EConfigHookTargetMask; - -typedef struct _EConfigHookItemFactoryData EConfigHookItemFactoryData; -typedef struct _EConfigHookPageCheckData EConfigHookPageCheckData; - -typedef void (*EConfigHookFunc)(struct _EPlugin *plugin, EConfigTarget *target); -typedef void (*EConfigHookItemFactoryFunc)(struct _EPlugin *plugin, EConfigHookItemFactoryData *data); - -/** - * struct _EConfigHookItemFactoryData - Factory marshalling structure. - * - * @config: The parent EConfig. This is also available in - * @target->config but is here as a convenience. (TODO: do we need this). - * @item: The corresponding configuration item. - * @target: The current configuration target. This is also available - * on @config->target. - * @parent: The parent widget for this item. Depends on the item - * type. - * @old: The last widget created by this factory. The factory is only - * re-invoked if a reconfigure request is invoked on the EConfig. - * - * Used to marshal the callback data for the EConfigItemFactory method - * to a single pointer for the EPlugin system. - **/ -struct _EConfigHookItemFactoryData { - EConfig *config; - EConfigItem *item; - EConfigTarget *target; - struct _GtkWidget *parent; - struct _GtkWidget *old; -}; - -/** - * struct _EConfigHookPageCheckData - Check callback data. - * - * @config: - * @target: The current configuration target. This is also available - * on @config->target. - * @pageid: Name of page to validate, or "" means check all configuration. - * - **/ -struct _EConfigHookPageCheckData { - EConfig *config; - EConfigTarget *target; - const char *pageid; -}; - -/** - * struct _EConfigHookGroup - A group of configuration items. - * - * @hook: Parent object. - * @id: The configuration window to which these items apply. - * @target_type: The target type expected by the items. This is - * defined by implementing classes. - * @items: A list of EConfigHookItem's for this group. - * @check: A validate page handler. - * @commit: The name of the commit function for this group of items, or NULL - * for instant-apply configuration windows. Its format is plugin-type defined. - * @abort: Similar to the @commit function but for aborting or - * cancelling a configuration edit. - * - * Each plugin that hooks into a given configuration page will define - * all of the items for that page in a single group. - **/ -struct _EConfigHookGroup { - struct _EConfigHook *hook; /* parent pointer */ - char *id; /* target menu id for these config items */ - int target_type; /* target type of this group */ - GSList *items; /* items to add to group */ - char *check; /* validate handler, if set */ - char *commit; /* commit handler, if set */ - char *abort; /* abort handler, if set */ -}; - -/** - * struct _EConfigHook - Plugin hook for configuration windows. - * - * @hook: Superclass. - * @groups: A list of EConfigHookGroup's of all configuration windows - * this plugin hooks into. - * - **/ -struct _EConfigHook { - EPluginHook hook; - - GSList *groups; -}; - -/** - * struct _EConfigHookClass - Abstract class for configuration window - * plugin hooks. - * - * @hook_class: Superclass. - * @target_map: A table of EConfigHookTargetMap structures describing - * the possible target types supported by this class. - * @config_class: The EConfig derived class that this hook - * implementation drives. - * - * This is an abstract class defining the plugin hook point for - * configuration windows. - * - **/ -struct _EConfigHookClass { - EPluginHookClass hook_class; - - /* EConfigHookTargetMap by .type */ - GHashTable *target_map; - /* the config class these configs's belong to */ - EConfigClass *config_class; -}; - -GType e_config_hook_get_type(void); - -/* for implementors */ -void e_config_hook_class_add_target_map(EConfigHookClass *klass, const EConfigHookTargetMap *); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_CONFIG_H__ */ diff --git a/e-util/e-corba-utils.c b/e-util/e-corba-utils.c deleted file mode 100644 index b92b247656..0000000000 --- a/e-util/e-corba-utils.c +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-html-utils.c -* - * Copyright (C) 2000 Ximian, Inc. - * Author: Ettore Perazzoli <ettore@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-corba-utils.h" - - -const CORBA_char * -e_safe_corba_string (const char *s) -{ - if (s == NULL) - return (CORBA_char *) ""; - - return s; -} - -CORBA_char * -e_safe_corba_string_dup (const char *s) -{ - return CORBA_string_dup (e_safe_corba_string (s)); -} diff --git a/e-util/e-corba-utils.h b/e-util/e-corba-utils.h deleted file mode 100644 index b48a6e2dab..0000000000 --- a/e-util/e-corba-utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-corba-utils.h - * - * Copyright (C) 2000 Ximian, Inc. - * Author: Ettore Perazzoli <ettore@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef E_CORBA_UTILS_H -#define E_CORBA_UTILS_H - -#include <orbit/orbit.h> - -const CORBA_char *e_safe_corba_string (const char *s); -CORBA_char *e_safe_corba_string_dup (const char *s); - -#endif diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c deleted file mode 100644 index 63d3f1d74c..0000000000 --- a/e-util/e-dialog-utils.c +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-dialog-utils.h - * - * Copyright (C) 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Michael Meeks <michael@ximian.com> - * Ettore Perazzoli <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-dialog-utils.h" - -#include <gdk/gdkx.h> - -#include <gtk/gtkmain.h> -#include <gtk/gtkplug.h> -#include <gtk/gtkversion.h> - -#ifdef USE_GTKFILECHOOSER -#include <gtk/gtkfilechooser.h> -#include <gtk/gtkfilechooserdialog.h> -#include <gtk/gtkstock.h> -#else -#include <gtk/gtkfilesel.h> -#endif - -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-util.h> - - -/** - * e_notice: - * @parent: the dialog's parent window, or %NULL - * @type: the type of dialog (%GTK_MESSAGE_INFO, %GTK_MESSAGE_WARNING, - * or %GTK_MESSAGE_ERROR) - * @format: printf-style format string, followed by arguments - * - * Convenience function to show a dialog with a message and an "OK" - * button. - **/ -void -e_notice (gpointer parent, GtkMessageType type, const char *format, ...) -{ - GtkWidget *dialog; - va_list args; - char *str; - - va_start (args, format); - str = g_strdup_vprintf (format, args); - dialog = gtk_message_dialog_new (NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - type, - GTK_BUTTONS_OK, - "%s", - str); -#if !GTK_CHECK_VERSION (2,4,0) - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); -#endif - va_end (args); - g_free (str); - - if (parent) - e_dialog_set_transient_for (GTK_WINDOW (dialog), parent); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -/** - * e_notice_with_xid: - * @parent: the dialog's parent window, or %NULL - * @type: the type of dialog (%GTK_MESSAGE_INFO, %GTK_MESSAGE_WARNING, - * or %GTK_MESSAGE_ERROR) - * @format: printf-style format string, followed by arguments - * - * Like e_notice(), but takes a GdkNativeWindow for the parent - * window argument. - **/ -void -e_notice_with_xid (GdkNativeWindow parent, GtkMessageType type, const char *format, ...) -{ - GtkWidget *dialog; - va_list args; - char *str; - - va_start (args, format); - str = g_strdup_vprintf (format, args); - dialog = gtk_message_dialog_new (NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - type, - GTK_BUTTONS_OK, - "%s", - str); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - va_end (args); - g_free (str); - - if (parent) - e_dialog_set_transient_for_xid (GTK_WINDOW (dialog), parent); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - - -/* Tests whether or not an X Window is being managed by the - * window manager. - */ -static gboolean -window_is_wm_toplevel (Display *display, Window window) -{ - static Atom WM_STATE = None; - unsigned long nitems, after; - unsigned char *data = NULL; - Atom type = None; - int format; - - if (!WM_STATE) - WM_STATE = XInternAtom (display, "WM_STATE", False); - - if (XGetWindowProperty (display, window, WM_STATE, 0, 0, False, - AnyPropertyType, &type, &format, - &nitems, &after, &data) == Success) { - if (data) - XFree((char*)data); - if (type) - return TRUE; - } - return FALSE; -} - -/** - * e_dialog_set_transient_for: - * @dialog: a dialog window - * @parent_widget: the parent for @dialog - * - * This sets the parent for @dialog to be @parent_widget. Unlike - * gtk_window_set_transient_for(), this doesn't need @parent_widget to - * be the actual toplevel, and also works if @parent_widget is - * embedded as a Bonobo control by an out-of-process container. - * @parent_widget must already be realized before calling this - * function, but @dialog does not need to be. - **/ -void -e_dialog_set_transient_for (GtkWindow *dialog, - GtkWidget *parent_widget) -{ - GtkWidget *toplevel; - Window parent, root_ret, *children; - unsigned int numchildren; - Display *display; - Status status; - - g_return_if_fail (GTK_IS_WINDOW (dialog)); - g_return_if_fail (GTK_IS_WIDGET (parent_widget)); - - toplevel = gtk_widget_get_toplevel (parent_widget); - if (toplevel == NULL) - return; - - if (!GTK_IS_PLUG (toplevel)) { - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (toplevel)); - return; - } - - /* Find the top-level windowmanager-managed X Window */ - display = GDK_WINDOW_XDISPLAY (parent_widget->window); - parent = GDK_WINDOW_XID (parent_widget->window); - - while (parent && !window_is_wm_toplevel (display, parent)) { - status = XQueryTree (display, parent, &root_ret, - &parent, &children, &numchildren); - if (status != 0) - XFree (children); - } - - e_dialog_set_transient_for_xid (dialog, parent); -} - -static void -dialog_realized (GtkWindow *dialog, gpointer xid) -{ - e_dialog_set_transient_for_xid (dialog, (GdkNativeWindow)xid); -} - -/** - * e_dialog_set_transient_for_xid: - * @dialog: a dialog window - * @xid: the X Window parent - * - * Like e_dialog_set_transient_for(), but use an XID to specify the - * parent window. - **/ -void -e_dialog_set_transient_for_xid (GtkWindow *dialog, - GdkNativeWindow xid) -{ -#ifdef GDK_MULTIHEAD_SAFE - GdkDisplay *display; -#endif - GdkWindow *parent; - - g_return_if_fail (GTK_IS_WINDOW (dialog)); - - if (!GTK_WIDGET_REALIZED (dialog)) { - g_signal_connect (dialog, "realize", - G_CALLBACK (dialog_realized), - (gpointer) xid); - return; - } - -#ifdef GDK_MULTIHEAD_SAFE - display = gdk_drawable_get_display (GDK_DRAWABLE (GTK_WIDGET (dialog)->window)); - parent = gdk_window_lookup_for_display (display, xid); - if (!parent) - parent = gdk_window_foreign_new_for_display (display, xid); -#else - parent = gdk_window_lookup (xid); - if (!parent) - parent = gdk_window_foreign_new (xid); -#endif - g_return_if_fail (parent != NULL); - - gdk_window_set_transient_for (GTK_WIDGET (dialog)->window, parent); -} - - - -static void -save_ok (GtkWidget *widget, gpointer data) -{ - GtkWidget *fs; - char **filename = data; - const char *path; - int btn = GTK_RESPONSE_YES; - - fs = gtk_widget_get_toplevel (widget); -#ifdef USE_GTKFILECHOOSER - path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs)); -#else - path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); -#endif - - if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) { - GtkWidget *dlg; - - dlg = gtk_message_dialog_new (GTK_WINDOW (fs), 0, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("A file by that name already exists.\n" - "Overwrite it?")); - gtk_window_set_title (GTK_WINDOW (dlg), _("Overwrite file?")); - gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE); - - btn = gtk_dialog_run (GTK_DIALOG (dlg)); - gtk_widget_destroy (dlg); - } - - if (btn == GTK_RESPONSE_YES) - *filename = g_strdup (path); - - gtk_main_quit (); -} - -#ifdef USE_GTKFILECHOOSER -static void -filechooser_response (GtkWidget *fc, gint response_id, gpointer data) -{ - if (response_id == GTK_RESPONSE_ACCEPT) - save_ok (fc, data); - else - gtk_widget_destroy (fc); -} -#endif - -char * -e_file_dialog_save (const char *title) -{ - GtkWidget *selection; - char *path, *filename = NULL; - -#ifdef USE_GTKFILECHOOSER - selection = gtk_file_chooser_dialog_new (title, - NULL, - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_ACCEPT); - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), g_get_home_dir ()); - - g_signal_connect (G_OBJECT (selection), "response", G_CALLBACK (filechooser_response), &filename); -#else - selection = gtk_file_selection_new (title); - path = g_strdup_printf ("%s/", g_get_home_dir ()); - gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection), path); - g_free (path); - - g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (selection)->ok_button), "clicked", G_CALLBACK (save_ok), &filename); - g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (selection)->cancel_button), "clicked", G_CALLBACK (gtk_main_quit), NULL); -#endif - - gtk_widget_show (GTK_WIDGET (selection)); - gtk_grab_add (GTK_WIDGET (selection)); - gtk_main (); - - gtk_widget_destroy (GTK_WIDGET (selection)); - - return filename; -} - - diff --git a/e-util/e-dialog-utils.h b/e-util/e-dialog-utils.h deleted file mode 100644 index 6e6cff8fb9..0000000000 --- a/e-util/e-dialog-utils.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-dialog-utils.h - * - * Copyright (C) 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli <ettore@ximian.com> - */ - -#ifndef E_DIALOG_UTILS_H -#define E_DIALOG_UTILS_H - -#include <gtk/gtkmessagedialog.h> - -void e_notice (gpointer parent, - GtkMessageType type, - const char *format, - ...); -void e_notice_with_xid (GdkNativeWindow parent, - GtkMessageType type, - const char *format, - ...); - -void e_dialog_set_transient_for (GtkWindow *dialog, - GtkWidget *parent_widget); -void e_dialog_set_transient_for_xid (GtkWindow *dialog, - GdkNativeWindow xid); - -char *e_file_dialog_save (const char *title); - - -#endif diff --git a/e-util/e-dialog-widgets.c b/e-util/e-dialog-widgets.c deleted file mode 100644 index d245917682..0000000000 --- a/e-util/e-dialog-widgets.c +++ /dev/null @@ -1,811 +0,0 @@ -/* Evolution internal utilities - Glade dialog widget utilities - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <math.h> -#include <string.h> -#include <time.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkoptionmenu.h> -#include <gtk/gtkradiobutton.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkspinbutton.h> -#include <libgnomeui/gnome-dateedit.h> -#include <libgnomeui/gnome-propertybox.h> - -#include "e-dialog-widgets.h" - - - -/* A widget, a pointer to the variable it will modify, and extra information */ -typedef struct { - GtkWidget *widget; - gpointer value_var; - gpointer info; -} WidgetHook; - -/* Hook information for a complete dialog */ -typedef struct { - GSList *whooks; -} DialogHooks; - - - -/* Destroy handler for the dialog; frees the dialog hooks */ -static void -dialog_destroy_cb (DialogHooks *hooks, GObject *dialog) -{ - g_slist_free (hooks->whooks); - hooks->whooks = NULL; - - g_free (hooks); - g_object_set_data (dialog, "dialog-hooks", NULL); -} - -/* Ensures that the dialog has the necessary attached data to store the widget - * hook information. - */ -static DialogHooks * -get_dialog_hooks (GtkWidget *dialog) -{ - DialogHooks *hooks; - - hooks = g_object_get_data ((GObject *) dialog, "dialog-hooks"); - if (!hooks) { - hooks = g_new0 (DialogHooks, 1); - g_object_set_data ((GObject *) dialog, "dialog-hooks", hooks); - g_object_weak_ref ((GObject *) dialog, (GWeakNotify) dialog_destroy_cb, hooks); - } - - return hooks; -} - -/* Converts an mapped value to the appropriate index in an item group. The - * values for the items are provided as a -1-terminated array. - */ -static int -value_to_index (const int *value_map, int value) -{ - int i; - - for (i = 0; value_map[i] != -1; i++) - if (value_map[i] == value) - return i; - - return -1; -} - -/* Converts an index in an item group to the appropriate mapped value. See the - * function above. - */ -static int -index_to_value (const int *value_map, int index) -{ - int i; - - /* We do this the hard way, i.e. not as a simple array reference, to - * check for correctness. - */ - - for (i = 0; value_map[i] != -1; i++) - if (i == index) - return value_map[i]; - - return -1; -} - -/* Callback for the "toggled" signal of toggle buttons */ -static void -toggled_cb (GtkToggleButton *toggle, gpointer data) -{ - GnomePropertyBox *pbox; - - pbox = GNOME_PROPERTY_BOX (data); - - /* For radio buttons, we only notify the property box if the button is - * active, because we'll get one call for each of the changed buttons in - * the radio group. - */ - if (!GTK_IS_RADIO_BUTTON (toggle) || toggle->active) - gnome_property_box_changed (pbox); -} - -/* Hooks a radio button group */ -static void -hook_radio (GtkWidget *dialog, GtkRadioButton *radio, gpointer value_var, gpointer info) -{ - const int *value_map; - GSList *group, *l; - int *value; - - group = gtk_radio_button_get_group (radio); - - /* Set the value */ - - value = (int *) value_var; - value_map = (const int *) info; - - e_dialog_radio_set (GTK_WIDGET (radio), *value, value_map); - - /* Hook to changed */ - - if (GNOME_IS_PROPERTY_BOX (dialog)) - for (l = group; l; l = l->next) - g_signal_connect (l->data, "toggled", G_CALLBACK (toggled_cb), dialog); -} - -/* Gets the value of a radio button group */ -static void -get_radio_value (GtkRadioButton *radio, gpointer value_var, gpointer info) -{ - int *value; - const int *value_map; - - value = (int *) value_var; - value_map = (const int *) info; - - *value = e_dialog_radio_get (GTK_WIDGET (radio), value_map); -} - -/* Callback for the "activate" signal of menu items */ -static void -activate_cb (GtkMenuItem *item, gpointer data) -{ - GnomePropertyBox *pbox; - - pbox = GNOME_PROPERTY_BOX (data); - gnome_property_box_changed (pbox); -} - -/* Hooks an option menu */ -static void -hook_option_menu (GtkWidget *dialog, GtkOptionMenu *omenu, gpointer value_var, gpointer info) -{ - const int *value_map; - int *value; - - /* Set the value */ - - value = (int *) value_var; - value_map = (const int *) info; - - e_dialog_option_menu_set (GTK_WIDGET (omenu), *value, value_map); - - /* Hook to changed */ - - if (GNOME_IS_PROPERTY_BOX (dialog)) { - GtkMenu *menu; - GList *l; - - menu = GTK_MENU (gtk_option_menu_get_menu (omenu)); - - for (l = GTK_MENU_SHELL (menu)->children; l; l = l->next) - g_signal_connect (l->data, "activate", G_CALLBACK (activate_cb), dialog); - } -} - -/* Gets the value of an option menu */ -static void -get_option_menu_value (GtkOptionMenu *omenu, gpointer value_var, gpointer info) -{ - const int *value_map; - int *value; - - value = (int *) value_var; - value_map = (const int *) info; - - *value = e_dialog_option_menu_get (GTK_WIDGET (omenu), value_map); -} - -/* Hooks a toggle button */ -static void -hook_toggle (GtkWidget *dialog, GtkToggleButton *toggle, gpointer value_var, gpointer info) -{ - gboolean *value; - - /* Set the value */ - - value = (gboolean *) value_var; - e_dialog_toggle_set (GTK_WIDGET (toggle), *value); - - /* Hook to changed */ - - if (GNOME_IS_PROPERTY_BOX (dialog)) - g_signal_connect (toggle, "toggled", G_CALLBACK (toggled_cb), dialog); -} - -/* Gets the value of a toggle button */ -static void -get_toggle_value (GtkToggleButton *toggle, gpointer value_var, gpointer info) -{ - gboolean *value; - - value = (gboolean *) value_var; - *value = e_dialog_toggle_get (GTK_WIDGET (toggle)); -} - -/* Callback for the "value_changed" signal of the adjustment of a spin button */ -static void -value_changed_cb (GtkAdjustment *adj, gpointer data) -{ - GnomePropertyBox *pbox; - - pbox = GNOME_PROPERTY_BOX (data); - gnome_property_box_changed (pbox); -} - -/* Hooks a spin button */ -static void -hook_spin_button (GtkWidget *dialog, GtkSpinButton *spin, gpointer value_var, gpointer info) -{ - double *value; - GtkAdjustment *adj; - - /* Set the value */ - - value = (double *) value_var; - e_dialog_spin_set (GTK_WIDGET (spin), *value); - - /* Hook to changed */ - - adj = gtk_spin_button_get_adjustment (spin); - - if (GNOME_IS_PROPERTY_BOX (dialog)) - g_signal_connect (adj, "value_changed", G_CALLBACK (value_changed_cb), dialog); -} - -/* Gets the value of a spin button */ -static void -get_spin_button_value (GtkSpinButton *spin, gpointer value_var, gpointer info) -{ - double *value; - - value = (double *) value_var; - *value = e_dialog_spin_get_double (GTK_WIDGET (spin)); -} - -/* Callback for the "changed" signal of a GtkEditable widget */ -static void -changed_cb (GtkEditable *editable, gpointer data) -{ - GnomePropertyBox *pbox; - - pbox = GNOME_PROPERTY_BOX (data); - gnome_property_box_changed (pbox); -} - -/* Hooks a GtkEditable widget */ -static void -hook_editable (GtkWidget *dialog, GtkEditable *editable, gpointer value_var, gpointer info) -{ - char **value; - - /* Set the value */ - - value = (char **) value_var; - - e_dialog_editable_set (GTK_WIDGET (editable), *value); - - /* Hook to changed */ - - if (GNOME_IS_PROPERTY_BOX (dialog)) - g_signal_connect (editable, "changed", G_CALLBACK (changed_cb), dialog); -} - -/* Gets the value of a GtkEditable widget */ -static void -get_editable_value (GtkEditable *editable, gpointer value_var, gpointer data) -{ - char **value; - - value = (char **) value_var; - if (*value) - g_free (*value); - - *value = e_dialog_editable_get (GTK_WIDGET (editable)); -} - -/** - * e_dialog_editable_set: - * @widget: A #GtkEditable widget. - * @value: String value. - * - * Sets the string value inside a #GtkEditable-derived widget. - **/ -void -e_dialog_editable_set (GtkWidget *widget, const char *value) -{ - int pos = 0; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_EDITABLE (widget)); - - gtk_editable_delete_text (GTK_EDITABLE (widget), 0, -1); - - if (value) - gtk_editable_insert_text (GTK_EDITABLE (widget), value, strlen (value), &pos); -} - -/** - * e_dialog_editable_get: - * @widget: A #GtkEditable widget. - * - * Queries the string value inside a #GtkEditable-derived widget. - * - * Return value: String value. You should free it when you are done with it. - * This function can return NULL if the string could not be converted from - * GTK+'s encoding into UTF8. - **/ -char * -e_dialog_editable_get (GtkWidget *widget) -{ - g_return_val_if_fail (widget != NULL, NULL); - g_return_val_if_fail (GTK_IS_EDITABLE (widget), NULL); - - return gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); -} - -/** - * e_dialog_radio_set: - * @widget: A #GtkRadioButton in a radio button group. - * @value: Enumerated value. - * @value_map: Map from enumeration values to array indices. - * - * Sets the selected item in a radio group. The specified @widget can be any of - * the #GtkRadioButtons in the group. Each radio button should correspond to an - * enumeration value; the specified @value will be mapped to an integer from - * zero to the number of items in the group minus 1 by using a mapping table - * specified in @value_map. The last element in this table should be -1. Thus - * a table to map three possible interpolation values to integers could be - * specified as { NEAREST_NEIGHBOR, BILINEAR, HYPERBOLIC, -1 }. - **/ -void -e_dialog_radio_set (GtkWidget *widget, int value, const int *value_map) -{ - GSList *group, *l; - int i; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_RADIO_BUTTON (widget)); - g_return_if_fail (value_map != NULL); - - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget)); - - i = value_to_index (value_map, value); - if (i != -1) { - /* Groups are built by prepending items, so the list ends up in reverse - * order; we need to flip the index around. - */ - i = g_slist_length (group) - i - 1; - - l = g_slist_nth (group, i); - if (!l) - g_message ("e_dialog_radio_set(): could not find index %d in radio group!", i); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l->data), TRUE); - } else - g_message ("e_dialog_radio_set(): could not find value %d in value map!", value); -} - -/** - * e_dialog_radio_get: - * @widget: A #GtkRadioButton in a radio button group. - * @value_map: Map from enumeration values to array indices. - * - * Queries the selected item in a #GtkRadioButton group. Please read the - * description of e_dialog_radio_set() to see how @value_map maps enumeration - * values to button indices. - * - * Return value: Enumeration value which corresponds to the selected item in the - * radio group. - **/ -int -e_dialog_radio_get (GtkWidget *widget, const int *value_map) -{ - GSList *group, *l; - int i, v; - - g_return_val_if_fail (widget != NULL, -1); - g_return_val_if_fail (GTK_IS_RADIO_BUTTON (widget), -1); - g_return_val_if_fail (value_map != NULL, -1); - - group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget)); - - for (i = 0, l = group; l; l = l->next, i++) { - widget = GTK_WIDGET (l->data); - - if (GTK_TOGGLE_BUTTON (widget)->active) - break; - } - - g_assert (l != NULL); - - /* Groups are built by prepending items, so the list ends up in reverse - * order; we need to flip the index around. - */ - i = g_slist_length (group) - i - 1; - - v = index_to_value (value_map, i); - if (v == -1) { - g_message ("e_dialog_radio_get(): could not find index %d in value map!", i); - return -1; - } - - return v; -} - -/** - * e_dialog_toggle_set: - * @widget: A #GtkToggleButton. - * @value: Toggle value. - * - * Sets the value of a #GtkToggleButton-derived widget. This should not be used - * for radio buttons; it is more convenient to use use e_dialog_radio_set() - * instead. - **/ -void -e_dialog_toggle_set (GtkWidget *widget, gboolean value) -{ - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget)); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value); -} - -/** - * e_dialog_toggle_get: - * @widget: A #GtkToggleButton. - * - * Queries the value of a #GtkToggleButton-derived widget. This should not be - * used for radio buttons; it is more convenient to use e_dialog_radio_get() - * instead. - * - * Return value: Toggle value. - **/ -gboolean -e_dialog_toggle_get (GtkWidget *widget) -{ - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (widget), FALSE); - - return GTK_TOGGLE_BUTTON (widget)->active; -} - -/** - * e_dialog_spin_set: - * @widget: A #GtkSpinButton. - * @value: Numeric value. - * - * Sets the value of a #GtkSpinButton widget. - **/ -void -e_dialog_spin_set (GtkWidget *widget, double value) -{ - GtkAdjustment *adj; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_SPIN_BUTTON (widget)); - - adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)); - - adj->value = value; - g_signal_emit_by_name (adj, "value_changed", 0); -} - -/** - * e_dialog_spin_get_double: - * @widget: A #GtkSpinButton. - * - * Queries the floating-point value of a #GtkSpinButton widget. - * - * Return value: Numeric value. - **/ -double -e_dialog_spin_get_double (GtkWidget *widget) -{ - GtkAdjustment *adj; - - g_return_val_if_fail (widget != NULL, 0.0); - g_return_val_if_fail (GTK_IS_SPIN_BUTTON (widget), 0.0); - - adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)); - return adj->value; -} - -/** - * e_dialog_spin_get_int: - * @widget: A #GtkSpinButton. - * - * Queries the integer value of a #GtkSpinButton widget. - * - * Return value: Numeric value. - **/ -int -e_dialog_spin_get_int (GtkWidget *widget) -{ - double value; - - g_return_val_if_fail (widget != NULL, -1); - g_return_val_if_fail (GTK_IS_SPIN_BUTTON (widget), -1); - - value = e_dialog_spin_get_double (widget); - return (int) floor (value); -} - -/** - * e_dialog_option_menu_set: - * @widget: A #GtkOptionMenu. - * @value: Enumerated value. - * @value_map: Map from enumeration values to array indices. - * - * Sets the selected item in a #GtkOptionMenu. Please read the description of - * e_dialog_radio_set() to see how @value_map maps enumeration values to item - * indices. - **/ -void -e_dialog_option_menu_set (GtkWidget *widget, int value, const int *value_map) -{ - int i; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_OPTION_MENU (widget)); - g_return_if_fail (value_map != NULL); - - i = value_to_index (value_map, value); - - if (i != -1) - gtk_option_menu_set_history (GTK_OPTION_MENU (widget), i); - else - g_message ("e_dialog_option_menu_set(): could not find value %d in value map!", - value); -} - -/** - * e_dialog_option_menu_get: - * @widget: A #GtkOptionMenu. - * @value_map: Map from enumeration values to array indices. - * - * Queries the selected item in a #GtkOptionMenu. Please read the description - * of e_dialog_radio_set() to see how @value_map maps enumeration values to item - * indices. - * - * Return value: Enumeration value which corresponds to the selected item in the - * option menu. - **/ -int -e_dialog_option_menu_get (GtkWidget *widget, const int *value_map) -{ - GtkMenu *menu; - GtkWidget *active; - GList *children; - GList *l; - int i; - int v; - - g_return_val_if_fail (widget != NULL, -1); - g_return_val_if_fail (GTK_IS_OPTION_MENU (widget), -1); - g_return_val_if_fail (value_map != NULL, -1); - - menu = GTK_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (widget))); - - active = gtk_menu_get_active (menu); - g_assert (active != NULL); - - children = GTK_MENU_SHELL (menu)->children; - - for (i = 0, l = children; l; l = l->next, i++) { - if (GTK_WIDGET (l->data) == active) - break; - } - - g_assert (l != NULL); - - v = index_to_value (value_map, i); - if (v == -1) { - g_message ("e_dialog_option_menu_get(): could not find index %d in value map!", i); - return -1; - } - - return v; -} - -/** - * e_dialog_dateedit_set: - * @widget: A #GnomeDateEdit widget. - * @t: Date/time value. - * - * Sets the value of a #GnomeDateEdit widget. - **/ -void -e_dialog_dateedit_set (GtkWidget *widget, time_t t) -{ - g_return_if_fail (widget != NULL); - g_return_if_fail (GNOME_IS_DATE_EDIT (widget)); - - gnome_date_edit_set_time (GNOME_DATE_EDIT (widget), t); -} - -/** - * e_dialog_dateedit_get: - * @widget: A #GnomeDateEdit widget. - * - * Queries the value of a #GnomeDateEdit widget. - * - * Return value: Date/time value. - **/ -time_t -e_dialog_dateedit_get (GtkWidget *widget) -{ - g_return_val_if_fail (widget != NULL, -1); - g_return_val_if_fail (GNOME_IS_DATE_EDIT (widget), -1); - - return gnome_date_edit_get_date (GNOME_DATE_EDIT (widget)); -} - -/** - * e_dialog_widget_hook_value: - * @dialog: Dialog box in which the @widget lives in. - * @widget: A widget that will control a variable. - * @value_var: Pointer to the variable that the @widget will control. - * @info: NULL for most widgets, or an integer value map array (see - * e_dialog_radio_set() for details). - * - * Hooks a widget from a dialog box to the variable it will modify. Supported - * widgets are: #GtkEditable (char *), #GtkRadioButton (int/value_map pair; see - * e_dialog_radio_set() for more information), #GtkTogglebutton (gboolean), - * #GtkSpinButton (double), #GtkOptionMenu (int/value_map pair), and - * #GnomeDateEdit (time_t). - * - * A pointer to the appropriate variable to modify should be passed in @value_var. - * For values that take a value_map array as well, it should be passed in @info. - * - * The widgets within a dialog that are hooked with this function will set their - * respective variables only when e_dialog_get_values() is called. The typical - * use is to call that function in the handler for the "OK" button of a dialog - * box. - * - * In addition, if the specified @dialog is a #GnomePropertyBox, the widgets wil - * automatically turn on the "Apply" button of the property box when they are - * modified by the user. - * - * Return value: TRUE if the type of the specified @widget is supported, FALSE - * otherwise. - **/ -gboolean -e_dialog_widget_hook_value (GtkWidget *dialog, GtkWidget *widget, - gpointer value_var, gpointer info) -{ - DialogHooks *hooks; - WidgetHook *wh; - - g_return_val_if_fail (dialog != NULL, FALSE); - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - g_return_val_if_fail (value_var != NULL, FALSE); - - hooks = get_dialog_hooks (dialog); - - /* First check if it is a "group" widget, like a radio button or an - * option menu. Then we check for normal ungrouped widgets. - */ - - if (GTK_IS_RADIO_BUTTON (widget)) - hook_radio (dialog, GTK_RADIO_BUTTON (widget), value_var, info); - else if (GTK_IS_OPTION_MENU (widget)) - hook_option_menu (dialog, GTK_OPTION_MENU (widget), value_var, info); - else if (GTK_IS_TOGGLE_BUTTON (widget)) - hook_toggle (dialog, GTK_TOGGLE_BUTTON (widget), value_var, info); - else if (GTK_IS_SPIN_BUTTON (widget)) - hook_spin_button (dialog, GTK_SPIN_BUTTON (widget), value_var, info); - else if (GTK_IS_EDITABLE (widget)) - hook_editable (dialog, GTK_EDITABLE (widget), value_var, info); - else - return FALSE; - - wh = g_new (WidgetHook, 1); - wh->widget = widget; - wh->value_var = value_var; - wh->info = info; - - hooks->whooks = g_slist_prepend (hooks->whooks, wh); - - return TRUE; -} - -/** - * e_dialog_get_values: - * @dialog: A dialog box whose widgets have been hooked to the appropriate - * variables with e_dialog_widget_hook_value(). - * - * Makes every widget in a @dialog that was hooked with - * e_dialog_widget_hook_value() apply its value to its corresponding variable. - * The typical usage is to call this function in the handler for the "OK" button - * of a dialog box. - **/ -void -e_dialog_get_values (GtkWidget *dialog) -{ - DialogHooks *hooks; - GSList *l; - - g_return_if_fail (dialog != NULL); - - hooks = get_dialog_hooks (dialog); - - for (l = hooks->whooks; l; l = l->next) { - WidgetHook *wh; - - wh = l->data; - - if (GTK_IS_RADIO_BUTTON (wh->widget)) - get_radio_value (GTK_RADIO_BUTTON (wh->widget), wh->value_var, wh->info); - else if (GTK_IS_OPTION_MENU (wh->widget)) - get_option_menu_value (GTK_OPTION_MENU (wh->widget), wh->value_var, wh->info); - else if (GTK_IS_TOGGLE_BUTTON (wh->widget)) - get_toggle_value (GTK_TOGGLE_BUTTON (wh->widget), wh->value_var, wh->info); - else if (GTK_IS_SPIN_BUTTON (wh->widget)) - get_spin_button_value (GTK_SPIN_BUTTON (wh->widget), wh->value_var, wh->info); - else if (GTK_IS_EDITABLE (wh->widget)) - get_editable_value (GTK_EDITABLE (wh->widget), wh->value_var, wh->info); - else - g_assert_not_reached (); - } -} - -/** - * e_dialog_xml_widget_hook_value: - * @xml: Glade XML description of a dialog box. - * @dialog: Dialog box in which the widget lives in. - * @widget_name: Name of the widget in the Glade XML data. - * @value_var: Pointer to the variable that the widget will control. - * @info: NULL for most widgets, or an integer value map array (see - * e_dialog_radio_set() for details). - * - * Similar to e_dialog_widget_hook_value(), but uses the widget from a #GladeXML - * data structure. - * - * Return value: TRUE if the type of the specified widget is supported, FALSE - * otherwise. - **/ -gboolean -e_dialog_xml_widget_hook_value (GladeXML *xml, GtkWidget *dialog, const char *widget_name, - gpointer value_var, gpointer info) -{ - GtkWidget *widget; - - g_return_val_if_fail (xml != NULL, FALSE); - g_return_val_if_fail (GLADE_IS_XML (xml), FALSE); - g_return_val_if_fail (dialog != NULL, FALSE); - g_return_val_if_fail (widget_name != NULL, FALSE); - g_return_val_if_fail (value_var != NULL, FALSE); - - widget = glade_xml_get_widget (xml, widget_name); - if (!widget) { - g_message ("e_dialog_xml_widget_hook_value(): could not find widget `%s' in " - "Glade data!", widget_name); - return FALSE; - } - - return e_dialog_widget_hook_value (dialog, widget, value_var, info); -} diff --git a/e-util/e-dialog-widgets.h b/e-util/e-dialog-widgets.h deleted file mode 100644 index a006092e04..0000000000 --- a/e-util/e-dialog-widgets.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Evolution internal utilities - Glade dialog widget utilities - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef E_DIALOG_WIDGETS_H -#define E_DIALOG_WIDGETS_H - -#include <time.h> -#include <glade/glade.h> - - - -void e_dialog_editable_set (GtkWidget *widget, const char *value); -char *e_dialog_editable_get (GtkWidget *widget); - -void e_dialog_radio_set (GtkWidget *widget, int value, const int *value_map); -int e_dialog_radio_get (GtkWidget *widget, const int *value_map); - -void e_dialog_toggle_set (GtkWidget *widget, gboolean value); -gboolean e_dialog_toggle_get (GtkWidget *widget); - -void e_dialog_spin_set (GtkWidget *widget, double value); -double e_dialog_spin_get_double (GtkWidget *widget); -int e_dialog_spin_get_int (GtkWidget *widget); - -void e_dialog_option_menu_set (GtkWidget *widget, int value, const int *value_map); -int e_dialog_option_menu_get (GtkWidget *widget, const int *value_map); - -void e_dialog_dateedit_set (GtkWidget *widget, time_t t); -time_t e_dialog_dateedit_get (GtkWidget *widget); - -gboolean e_dialog_widget_hook_value (GtkWidget *dialog, GtkWidget *widget, - gpointer value_var, gpointer info); - -void e_dialog_get_values (GtkWidget *dialog); - -gboolean e_dialog_xml_widget_hook_value (GladeXML *xml, GtkWidget *dialog, const char *widget_name, - gpointer value_var, gpointer info); - - - -#endif diff --git a/e-util/e-error.c b/e-util/e-error.c deleted file mode 100644 index f7dc888609..0000000000 --- a/e-util/e-error.c +++ /dev/null @@ -1,628 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell Inc. (www.novell.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <sys/types.h> -#include <dirent.h> - -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -#include <glib.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkimage.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-url.h> - -#include "e-error.h" - -#define d(x) - -struct _e_error_button { - struct _e_error_button *next; - char *stock; - char *label; - int response; -}; - -struct _e_error { - guint32 flags; - char *id; - int type; - int default_response; - char *title; - char *primary; - char *secondary; - char *help_uri; - struct _e_error_button *buttons; -}; - -struct _e_error_table { - char *domain; - char *translation_domain; - GHashTable *errors; -}; - -static GHashTable *error_table; -static GSList *ee_parent_list; - -/* ********************************************************************** */ - -static struct _e_error_button default_ok_button = { - NULL, "gtk-ok", NULL, GTK_RESPONSE_OK -}; - -static struct _e_error default_errors[] = { - { GTK_DIALOG_MODAL, "error", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", "{1}", NULL, &default_ok_button }, - { GTK_DIALOG_MODAL, "error-primary", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", NULL, NULL, &default_ok_button }, - { GTK_DIALOG_MODAL, "warning", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", "{1}", NULL, &default_ok_button }, - { GTK_DIALOG_MODAL, "warning-primary", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", NULL, NULL, &default_ok_button }, -}; - -/* ********************************************************************** */ - -static struct { - char *name; - int id; -} response_map[] = { - { "GTK_RESPONSE_REJECT", GTK_RESPONSE_REJECT }, - { "GTK_RESPONSE_ACCEPT", GTK_RESPONSE_ACCEPT }, - { "GTK_RESPONSE_OK", GTK_RESPONSE_OK }, - { "GTK_RESPONSE_CANCEL", GTK_RESPONSE_CANCEL }, - { "GTK_RESPONSE_CLOSE", GTK_RESPONSE_CLOSE }, - { "GTK_RESPONSE_YES", GTK_RESPONSE_YES }, - { "GTK_RESPONSE_NO", GTK_RESPONSE_NO }, - { "GTK_RESPONSE_APPLY", GTK_RESPONSE_APPLY }, - { "GTK_RESPONSE_HELP", GTK_RESPONSE_HELP }, -}; - -static int -map_response(const char *name) -{ - int i; - - for (i=0;i<sizeof(response_map)/sizeof(response_map[0]);i++) - if (!strcmp(name, response_map[i].name)) - return response_map[i].id; - - return 0; -} - -static struct { - const char *name; - const char *icon; - const char *title; -} type_map[] = { - { "info", GTK_STOCK_DIALOG_INFO, N_("Evolution Information") }, - { "warning", GTK_STOCK_DIALOG_WARNING, N_("Evolution Warning") }, - { "question", GTK_STOCK_DIALOG_QUESTION, N_("Evolution Query") }, - { "error", GTK_STOCK_DIALOG_ERROR, N_("Evolution Error") }, -}; - -static int -map_type(const char *name) -{ - int i; - - if (name) { - for (i=0;i<sizeof(type_map)/sizeof(type_map[0]);i++) - if (!strcmp(name, type_map[i].name)) - return i; - } - - return 3; -} - -/* - XML format: - - <error id="error-id" type="info|warning|question|error"? response="default_response"? modal="true"? > - <title>Window Title</title>? - <primary>Primary error text.</primary>? - <secondary>Secondary error text.</secondary>? - <help uri="help uri"/> ? - <button stock="stock-button-id"? label="button label"? response="response_id"? /> * - </error> - - The tool e-error-tool is used to extract the translatable strings for - translation. - -*/ -static void -ee_load(const char *path) -{ - xmlDocPtr doc; - xmlNodePtr root, error, scan; - struct _e_error *e; - struct _e_error_button *lastbutton; - struct _e_error_table *table; - char *tmp; - - d(printf("loading error file %s\n", path)); - - doc = xmlParseFile(path); - if (doc == NULL) { - g_warning("Error file '%s' not found", path); - return; - } - - root = xmlDocGetRootElement(doc); - if (root == NULL - || strcmp(root->name, "error-list") != 0 - || (tmp = xmlGetProp(root, "domain")) == NULL) { - g_warning("Error file '%s' invalid format", path); - xmlFreeDoc(doc); - return; - } - - table = g_hash_table_lookup(error_table, tmp); - if (table == NULL) { - char *tmp2; - - table = g_malloc0(sizeof(*table)); - table->domain = g_strdup(tmp); - table->errors = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_insert(error_table, table->domain, table); - - tmp2 = xmlGetProp(root, "translation-domain"); - if (tmp2) { - table->translation_domain = g_strdup(tmp2); - xmlFree(tmp2); - - tmp2 = xmlGetProp(root, "translation-localedir"); - if (tmp2) { - bindtextdomain(table->translation_domain, tmp2); - xmlFree(tmp2); - } - } - } else - g_warning("Error file '%s', domain '%s' already used, merging", path, tmp); - xmlFree(tmp); - - for (error = root->children;error;error = error->next) { - if (!strcmp(error->name, "error")) { - tmp = xmlGetProp(error, "id"); - if (tmp == NULL) - continue; - - e = g_malloc0(sizeof(*e)); - e->id = g_strdup(tmp); - xmlFree(tmp); - lastbutton = (struct _e_error_button *)&e->buttons; - - tmp = xmlGetProp(error, "modal"); - if (tmp) { - if (!strcmp(tmp, "true")) - e->flags |= GTK_DIALOG_MODAL; - xmlFree(tmp); - } - - tmp = xmlGetProp(error, "type"); - e->type = map_type(tmp); - if (tmp) - xmlFree(tmp); - - tmp = xmlGetProp(error, "default"); - if (tmp) { - e->default_response = map_response(tmp); - xmlFree(tmp); - } - - for (scan = error->children;scan;scan=scan->next) { - if (!strcmp(scan->name, "primary")) { - if ((tmp = xmlNodeGetContent(scan))) { - e->primary = g_strdup(dgettext(table->translation_domain, tmp)); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "secondary")) { - if ((tmp = xmlNodeGetContent(scan))) { - e->secondary = g_strdup(dgettext(table->translation_domain, tmp)); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "title")) { - if ((tmp = xmlNodeGetContent(scan))) { - e->title = g_strdup(dgettext(table->translation_domain, tmp)); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "help")) { - tmp = xmlGetProp(scan, "uri"); - if (tmp) { - e->help_uri = g_strdup(tmp); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "button")) { - struct _e_error_button *b; - - b = g_malloc0(sizeof(*b)); - tmp = xmlGetProp(scan, "stock"); - if (tmp) { - b->stock = g_strdup(tmp); - xmlFree(tmp); - } - tmp = xmlGetProp(scan, "label"); - if (tmp) { - b->label = g_strdup(dgettext(table->translation_domain, tmp)); - xmlFree(tmp); - } - tmp = xmlGetProp(scan, "response"); - if (tmp) { - b->response = map_response(tmp); - xmlFree(tmp); - } - - if (b->stock == NULL && b->label == NULL) { - g_warning("Error file '%s': missing button details in error '%s'", path, e->id); - g_free(b->stock); - g_free(b->label); - g_free(b); - } else { - lastbutton->next = b; - lastbutton = b; - } - } - } - - g_hash_table_insert(table->errors, e->id, e); - } - } - - xmlFreeDoc(doc); -} - -static void -ee_load_tables(void) -{ - DIR *dir; - struct dirent *d; - const char *base = EVOLUTION_PRIVDATADIR "/errors"; - struct _e_error_table *table; - int i; - - if (error_table != NULL) - return; - - error_table = g_hash_table_new(g_str_hash, g_str_equal); - - /* setup system error types */ - table = g_malloc0(sizeof(*table)); - table->domain = "builtin"; - table->errors = g_hash_table_new(g_str_hash, g_str_equal); - for (i=0;i<sizeof(default_errors)/sizeof(default_errors[0]);i++) - g_hash_table_insert(table->errors, default_errors[i].id, &default_errors[i]); - g_hash_table_insert(error_table, table->domain, table); - - /* look for installed error tables */ - dir = opendir(base); - if (dir == NULL) - return; - - while ( (d = readdir(dir)) ) { - char *path; - - if (d->d_name[0] == '.') - continue; - - path = g_build_filename(base, d->d_name, NULL); - ee_load(path); - g_free(path); - } - - closedir(dir); -} - -/* unfortunately, gmarkup_escape doesn't expose its gstring based api :( */ -static void -ee_append_text(GString *out, const char *text) -{ - char c; - - while ( (c=*text++) ) { - if (c == '<') - g_string_append(out, "<"); - else if (c == '>') - g_string_append(out, ">"); - else if (c == '"') - g_string_append(out, """); - else if (c == '\'') - g_string_append(out, "'"); - else if (c == '&') - g_string_append(out, "&"); - else - g_string_append_c(out, c); - } -} - -static void -ee_build_label(GString *out, const char *fmt, GPtrArray *args) -{ - const char *end, *newstart; - int id; - - while (fmt - && (newstart = strchr(fmt, '{')) - && (end = strchr(newstart+1, '}'))) { - g_string_append_len(out, fmt, newstart-fmt); - id = atoi(newstart+1); - if (id < args->len) - ee_append_text(out, args->pdata[id]); - else - g_warning("Error references argument %d not supplied by caller", id); - fmt = end+1; - } - - g_string_append(out, fmt); -} - -static void -ee_response(GtkWidget *w, guint button, struct _e_error *e) -{ - GError *err = NULL; - - if (button == GTK_RESPONSE_HELP) { - g_signal_stop_emission_by_name(w, "response"); - gnome_url_show(e->help_uri, &err); - if (err) { - g_warning("Unable to run help uri: %s", err->message); - g_error_free(err); - } - } -} - -GtkWidget * -e_error_newv(GtkWindow *parent, const char *tag, const char *arg0, va_list ap) -{ - struct _e_error_table *table; - struct _e_error *e; - struct _e_error_button *b; - GtkWidget *hbox, *w; - char *tmp, *domain, *id; - GString *out; - GPtrArray *args; - GtkDialog *dialog; - - if (error_table == NULL) - ee_load_tables(); - - dialog = (GtkDialog *)gtk_dialog_new(); - gtk_dialog_set_has_separator(dialog, FALSE); - - gtk_widget_ensure_style ((GtkWidget *)dialog); - gtk_container_set_border_width ((GtkContainer *)(dialog->vbox), 0); - gtk_container_set_border_width ((GtkContainer *)(dialog->action_area), 12); - - if (parent == NULL && ee_parent_list) - parent = (GtkWindow *)ee_parent_list->data; - if (parent) - gtk_window_set_transient_for((GtkWindow *)dialog, parent); - else - g_warning("No parent set, or default parent available for error dialog"); - - domain = alloca(strlen(tag)+1); - strcpy(domain, tag); - id = strchr(domain, ':'); - if (id) - *id++ = 0; - - if ( id == NULL - || (table = g_hash_table_lookup(error_table, domain)) == NULL - || (e = g_hash_table_lookup(table->errors, id)) == NULL) { - /* setup a dummy error */ - tmp = g_strdup_printf(_("<span weight=\"bold\">Internal error, unknown error '%s' requested</span>"), tag); - w = gtk_label_new(NULL); - gtk_label_set_selectable((GtkLabel *)w, TRUE); - gtk_label_set_line_wrap((GtkLabel *)w, TRUE); - gtk_label_set_markup((GtkLabel *)w, tmp); - gtk_widget_show(w); - gtk_box_pack_start((GtkBox *)dialog->vbox, w, TRUE, TRUE, 12); - - return (GtkWidget *)dialog; - } - - if (e->flags & GTK_DIALOG_MODAL) - gtk_window_set_modal((GtkWindow *)dialog, TRUE); - gtk_window_set_destroy_with_parent((GtkWindow *)dialog, TRUE); - - if (e->help_uri) { - w = gtk_dialog_add_button(dialog, GTK_STOCK_HELP, GTK_RESPONSE_HELP); - g_signal_connect(dialog, "response", G_CALLBACK(ee_response), e); - } - - b = e->buttons; - if (b == NULL) { - gtk_dialog_add_button(dialog, GTK_STOCK_OK, GTK_RESPONSE_OK); - } else { - for (b = e->buttons;b;b=b->next) { - if (b->stock) { - if (b->label) { -#if 0 - /* FIXME: So although this looks like it will work, it wont. - Need to do it the hard way ... it also breaks the - default_response stuff */ - w = gtk_button_new_from_stock(b->stock); - gtk_button_set_label((GtkButton *)w, b->label); - gtk_widget_show(w); - gtk_dialog_add_action_widget(dialog, w, b->response); -#endif - gtk_dialog_add_button(dialog, b->label, b->response); - } else - gtk_dialog_add_button(dialog, b->stock, b->response); - } else - gtk_dialog_add_button(dialog, b->label, b->response); - } - } - - if (e->default_response) - gtk_dialog_set_default_response(dialog, e->default_response); - - hbox = gtk_hbox_new(FALSE, 0); - gtk_container_set_border_width((GtkContainer *)hbox, 12); - - w = gtk_image_new_from_stock(type_map[e->type].icon, GTK_ICON_SIZE_DIALOG); - gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.0); - gtk_box_pack_start((GtkBox *)hbox, w, TRUE, TRUE, 12); - - args = g_ptr_array_new(); - tmp = (char *)arg0; - while (tmp) { - g_ptr_array_add(args, tmp); - tmp = va_arg(ap, char *); - } - - out = g_string_new(""); - - if (e->title) { - ee_build_label(out, dgettext(table->translation_domain, e->title), args); - gtk_window_set_title((GtkWindow *)dialog, out->str); - g_string_truncate(out, 0); - } else - gtk_window_set_title((GtkWindow *)dialog, dgettext(table->translation_domain, type_map[e->type].title)); - - - if (e->primary) { - g_string_append(out, "<span weight=\"bold\" size=\"larger\">"); - ee_build_label(out, dgettext(table->translation_domain, e->primary), args); - g_string_append(out, "</span>\n\n"); - } - - if (e->secondary) - ee_build_label(out, dgettext(table->translation_domain, e->secondary), args); - - g_ptr_array_free(args, TRUE); - - w = gtk_label_new(NULL); - gtk_label_set_selectable((GtkLabel *)w, TRUE); - gtk_label_set_line_wrap((GtkLabel *)w, TRUE); - gtk_label_set_markup((GtkLabel *)w, out->str); - g_string_free(out, TRUE); - gtk_box_pack_start((GtkBox *)hbox, w, FALSE, FALSE, 0); - gtk_widget_show_all(hbox); - - gtk_box_pack_start((GtkBox *)dialog->vbox, hbox, TRUE, TRUE, 0); - - return (GtkWidget *)dialog; -} - -/** - * e_error_new: - * @parent: - * @tag: error identifier - * @arg0: The first argument for the error formatter. The list must - * be NULL terminated. - * - * Creates a new error widget. The @tag argument is used to determine - * which error to use, it is in the format domain:error-id. The NULL - * terminated list of arguments, starting with @arg0 is used to fill - * out the error definition. - * - * Return value: A GtkDialog which can be used for showing an error - * dialog asynchronously. - **/ -struct _GtkWidget * -e_error_new(struct _GtkWindow *parent, const char *tag, const char *arg0, ...) -{ - GtkWidget *w; - va_list ap; - - va_start(ap, arg0); - w = e_error_newv(parent, tag, arg0, ap); - va_end(ap); - - return w; -} - -int -e_error_runv(GtkWindow *parent, const char *tag, const char *arg0, va_list ap) -{ - GtkWidget *w; - int res; - - w = e_error_newv(parent, tag, arg0, ap); - - res = gtk_dialog_run((GtkDialog *)w); - gtk_widget_destroy(w); - - return res; -} - -/** - * e_error_run: - * @parent: - * @tag: - * @arg0: - * - * Sets up, displays, runs and destroys a standard evolution error - * dialog based on @tag, which is in the format domain:error-id. - * - * Return value: The response id of the button pressed. - **/ -int -e_error_run(GtkWindow *parent, const char *tag, const char *arg0, ...) -{ - GtkWidget *w; - va_list ap; - int res; - - va_start(ap, arg0); - w = e_error_newv(parent, tag, arg0, ap); - va_end(ap); - - res = gtk_dialog_run((GtkDialog *)w); - gtk_widget_destroy(w); - - return res; -} - -static void -remove_parent(GtkWidget *w, GtkWidget *parent) -{ - ee_parent_list = g_slist_remove(ee_parent_list, parent); -} - -/** - * e_error_default_parent: - * @parent: - * - * Bit of a hack, set a default parent that will be used to parent any - * error boxes if none is supplied. - * - * This may be called multiple times, and the last call will be the - * main default. This function will keep track of the parents - * destruction state. - **/ -void -e_error_default_parent(struct _GtkWindow *parent) -{ - if (g_slist_find(ee_parent_list, parent) == NULL) { - ee_parent_list = g_slist_prepend(ee_parent_list, parent); - g_signal_connect(parent, "destroy", G_CALLBACK(remove_parent), parent); - } -} - diff --git a/e-util/e-error.h b/e-util/e-error.h deleted file mode 100644 index fe097656ab..0000000000 --- a/e-util/e-error.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell Inc. (www.novell.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _E_ERROR_H -#define _E_ERROR_H - -#include <stdarg.h> - -struct _GtkWindow; - -/* - * Some standard errors, if these are altered or added to, - * update devel-docs/misc/errors.txt - * - * Several more basic ones are needed. - */ - -#define E_ERROR_WARNING "builtin:warning" -#define E_ERROR_WARNING_PRIMARY "builtin:warning-primary" -#define E_ERROR_ERROR "builtin:error" -#define E_ERROR_ERROR_PRIMARY "builtin:error-primary" - -/* takes filename, returns OK if yes */ -#define E_ERROR_ASK_FILE_EXISTS_OVERWRITE "system:ask-save-file-exists-overwrite" -/* takes filename, reason */ -#define E_ERROR_NO_SAVE_FILE "system:no-save-file" -/* takes filename, reason */ -#define E_ERROR_NO_LOAD_FILE "system:no-save-file" - -/* Note that all errors returned are standard GtkDialoge's */ -struct _GtkWidget *e_error_new(struct _GtkWindow *parent, const char *tag, const char *arg0, ...); -struct _GtkWidget *e_error_newv(struct _GtkWindow *parent, const char *tag, const char *arg0, va_list ap); - -int e_error_run(struct _GtkWindow *parent, const char *tag, const char *arg0, ...); -int e_error_runv(struct _GtkWindow *parent, const char *tag, const char *arg0, va_list ap); - -void e_error_default_parent(struct _GtkWindow *parent); - -#endif /* !_E_ERROR_H */ diff --git a/e-util/e-event.c b/e-util/e-event.c deleted file mode 100644 index 99d8876058..0000000000 --- a/e-util/e-event.c +++ /dev/null @@ -1,560 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkimagemenuitem.h> -#include <gtk/gtkcheckmenuitem.h> -#include <gtk/gtkradiomenuitem.h> -#include <gtk/gtkseparatormenuitem.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkimage.h> - -#include "e-event.h" - -#include <e-util/e-icon-factory.h> - -#include <libgnome/gnome-i18n.h> -#include <libedataserver/e-msgport.h> - -#define d(x) - -struct _EEventFactory { - struct _EEventFactory *next, *prev; - - char *menuid; - EEventFactoryFunc factory; - void *factory_data; -}; - -struct _event_node { - struct _event_node *next, *prev; - - GSList *events; - void *data; - EEventItemsFunc freefunc; -}; - -struct _event_info { - struct _event_node *parent; - EEventItem *item; -}; - -struct _EEventPrivate { - EDList events; - - GSList *sorted; /* sorted list of struct _event_info's */ -}; - -static GObjectClass *ep_parent; - -static void -ep_init(GObject *o) -{ - EEvent *emp = (EEvent *)o; - struct _EEventPrivate *p; - - p = emp->priv = g_malloc0(sizeof(struct _EEventPrivate)); - - e_dlist_init(&p->events); -} - -static void -ep_finalise(GObject *o) -{ - EEvent *emp = (EEvent *)o; - struct _EEventPrivate *p = emp->priv; - struct _event_node *node; - - if (emp->target) - e_event_target_free(emp, emp->target); - - g_free(emp->id); - - while ((node = (struct _event_node *)e_dlist_remhead(&p->events))) { - if (node->freefunc) - node->freefunc(emp, node->events, node->data); - - g_free(node); - } - - g_slist_foreach(p->sorted, (GFunc)g_free, NULL); - g_slist_free(p->sorted); - - g_free(p); - - ((GObjectClass *)ep_parent)->finalize(o); -} - -static void -ep_target_free(EEvent *ep, EEventTarget *t) -{ - g_free(t); - g_object_unref(ep); -} - -static void -ep_class_init(GObjectClass *klass) -{ - d(printf("EEvent class init %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - klass->finalize = ep_finalise; - ((EEventClass *)klass)->target_free = ep_target_free; -} - -/** - * e_event_get_type: - * - * Standard GObject type function. Used to subclass EEvent. - * - * Return value: The EEvent type. - **/ -GType -e_event_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EEventClass), - (GBaseInitFunc)NULL, NULL, - (GClassInitFunc)ep_class_init, NULL, NULL, - sizeof(EEvent), 0, - (GInstanceInitFunc)ep_init - }; - ep_parent = g_type_class_ref(G_TYPE_OBJECT); - type = g_type_register_static(G_TYPE_OBJECT, "EEvent", &info, 0); - } - - return type; -} - -/** - * e_event_construct: - * @ep: An instantiated but uninitialised EEvent. - * @id: Event manager id. - * - * Construct the base event instance with standard parameters. - * - * Return value: Returns @ep. - **/ -EEvent *e_event_construct(EEvent *ep, const char *id) -{ - ep->id = g_strdup(id); - - return ep; -} - -/** - * e_event_add_items: - * @emp: An initialised EEvent structure. - * @items: A list of EEventItems event listeners to register on this event manager. - * @freefunc: A function called when the @items list is no longer needed. - * @data: callback data for @freefunc and for item event handlers. - * - * Adds @items to the list of events listened to on the event manager @emp. - * - * Return value: An opaque key which can later be passed to remove_items. - **/ -void * -e_event_add_items(EEvent *emp, GSList *items, EEventItemsFunc freefunc, void *data) -{ - struct _event_node *node; - - node = g_malloc(sizeof(*node)); - node->events = items; - node->freefunc = freefunc; - node->data = data; - e_dlist_addtail(&emp->priv->events, (EDListNode *)node); - - if (emp->priv->sorted) { - g_slist_foreach(emp->priv->sorted, (GFunc)g_free, NULL); - g_slist_free(emp->priv->sorted); - emp->priv->sorted = NULL; - } - - return (void *)node; -} - -/** - * e_event_remove_items: - * @emp: - * @handle: - * - * Remove items previously added. They MUST have been previously - * added, and may only be removed once. - **/ -void -e_event_remove_items(EEvent *emp, void *handle) -{ - struct _event_node *node = handle; - - e_dlist_remove((EDListNode *)node); - if (node->freefunc) - node->freefunc(emp, node->events, node->data); - g_free(node); - - if (emp->priv->sorted) { - g_slist_foreach(emp->priv->sorted, (GFunc)g_free, NULL); - g_slist_free(emp->priv->sorted); - emp->priv->sorted = NULL; - } -} - -static int -ee_cmp(const void *ap, const void *bp) -{ - int a = ((struct _event_info **)ap)[0]->item->priority; - int b = ((struct _event_info **)bp)[0]->item->priority; - - if (a < b) - return 1; - else if (a > b) - return -1; - else - return 0; -} - -/** - * e_event_emit: - * @ee: An initialised EEvent, potentially with registered event listeners. - * @id: Event name. This will be compared against EEventItem.id. - * @target: The target describing the event context. This will be implementation defined. - * - * Emit an event. @target will automatically be freed once its - * emission is complete. - **/ -void -e_event_emit(EEvent *emp, const char *id, EEventTarget *target) -{ - struct _EEventPrivate *p = emp->priv; - GSList *events; - - d(printf("emit event %s\n", id)); - - g_assert(emp->target == NULL); - - emp->target = target; - events = p->sorted; - if (events == NULL) { - struct _event_node *node = (struct _event_node *)p->events.head; - - for (;node->next;node=node->next) { - GSList *l = node->events; - - for (;l;l=g_slist_next(l)) { - struct _event_info *info; - - info = g_malloc0(sizeof(*info)); - info->parent = node; - info->item = l->data; - events = g_slist_prepend(events, info); - } - } - - p->sorted = events = g_slist_sort(events, ee_cmp); - } - - for (;events;events=g_slist_next(events)) { - struct _event_info *info = events->data; - EEventItem *event = info->item; - - d(printf("event '%s' mask %08x target %08x\n", event->id, event->enable, target->mask)); - - if (event->enable & target->mask) - continue; - - if (strcmp(event->id, id) == 0) { - event->handle(emp, event, info->parent->data); - - if (event->type == E_EVENT_SINK) - break; - } - } - - e_event_target_free(emp, target); - emp->target = NULL; -} - -/** - * e_event_target_new: - * @ep: An initialised EEvent instance. - * @type: type, up to implementor - * @size: The size of memory to allocate. This must be >= sizeof(EEventTarget). - * - * Allocate a new event target suitable for this class. It is up to - * the implementation to define the available target types and their - * structure. - **/ -void *e_event_target_new(EEvent *ep, int type, size_t size) -{ - EEventTarget *t; - - g_assert(size >= sizeof(EEventTarget)); - - t = g_malloc0(size); - t->event = ep; - g_object_ref(ep); - t->type = type; - - return t; -} - -/** - * e_event_target_free: - * @ep: An initialised EEvent instance on which this target was allocated. - * @o: The target to free. - * - * Free a target. This invokes the virtual free method on the EEventClass. - **/ -void -e_event_target_free(EEvent *ep, void *o) -{ - EEventTarget *t = o; - - ((EEventClass *)G_OBJECT_GET_CLASS(ep))->target_free(ep, t); -} - -/* ********************************************************************** */ - -/* Event menu plugin handler */ - -/* -<e-plugin - class="org.gnome.mail.plugin.event:1.0" - id="org.gnome.mail.plugin.event.item:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelimap.so" - name="imap" - description="IMAP4 and IMAP4v1 mail store"> - <hook class="org.gnome.mail.eventMenu:1.0" - handler="HandleEvent"> - <menu id="any" target="select"> - <item - type="item|toggle|radio|image|submenu|bar" - active - path="foo/bar" - label="label" - icon="foo" - mask="select_one" - activate="ep_view_emacs"/> - </menu> - </extension> - - <hook class="org.gnome.evolution.mail.events:1.0"> - <event id=".folder.changed" - target="" - priority="0" - handle="gotevent" - enable="new" - /> - <event id=".message.read" - priority="0" - handle="gotevent" - mask="new" - /> - </hook> - -*/ - -static void *emph_parent_class; -#define emph ((EEventHook *)eph) - -/* must have 1:1 correspondence with e-event types in order */ -static const EPluginHookTargetKey emph_item_types[] = { - { "pass", E_EVENT_PASS }, - { "sink", E_EVENT_SINK }, - { 0 } -}; - -static void -emph_event_handle(EEvent *ee, EEventItem *item, void *data) -{ - struct _EEventHook *hook = data; - - /* FIXME: we could/should just remove the items we added to the event handler */ - if (!hook->hook.plugin->enabled) - return; - - e_plugin_invoke(hook->hook.plugin, (char *)item->user_data, ee->target); -} - -static void -emph_free_item(struct _EEventItem *item) -{ - g_free((char *)item->id); - g_free(item->user_data); - g_free(item); -} - -static void -emph_free_items(EEvent *ee, GSList *items, void *data) -{ - /*EPluginHook *eph = data;*/ - - g_slist_foreach(items, (GFunc)emph_free_item, NULL); - g_slist_free(items); -} - -static struct _EEventItem * -emph_construct_item(EPluginHook *eph, xmlNodePtr root, EEventHookClass *klass) -{ - struct _EEventItem *item; - EEventHookTargetMap *map; - char *tmp; - - item = g_malloc0(sizeof(*item)); - - tmp = xmlGetProp(root, "target"); - if (tmp == NULL) - goto error; - map = g_hash_table_lookup(klass->target_map, tmp); - xmlFree(tmp); - if (map == NULL) - goto error; - item->target_type = map->id; - item->type = e_plugin_hook_id(root, emph_item_types, "type"); - if (item->type == -1) - item->type = E_EVENT_PASS; - item->priority = e_plugin_xml_int(root, "priority", 0); - item->id = e_plugin_xml_prop(root, "id"); - item->enable = e_plugin_hook_mask(root, map->mask_bits, "enable"); - item->user_data = e_plugin_xml_prop(root, "handle"); - - if (item->user_data == NULL || item->id == NULL) - goto error; - - item->handle = emph_event_handle; - - return item; -error: - emph_free_item(item); - return NULL; -} - -static int -emph_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) -{ - xmlNodePtr node; - EEventHookClass *klass; - GSList *items = NULL; - - g_return_val_if_fail(((EEventHookClass *)G_OBJECT_GET_CLASS(eph))->event != NULL, -1); - - d(printf("loading event hook\n")); - - if (((EPluginHookClass *)emph_parent_class)->construct(eph, ep, root) == -1) - return -1; - - klass = (EEventHookClass *)G_OBJECT_GET_CLASS(eph); - - node = root->children; - while (node) { - if (strcmp(node->name, "event") == 0) { - struct _EEventItem *item; - - item = emph_construct_item(eph, node, klass); - if (item) - items = g_slist_prepend(items, item); - } - node = node->next; - } - - eph->plugin = ep; - - if (items) - e_event_add_items(klass->event, items, emph_free_items, eph); - - return 0; -} - -static void -emph_finalise(GObject *o) -{ - /*EPluginHook *eph = (EPluginHook *)o;*/ - - ((GObjectClass *)emph_parent_class)->finalize(o); -} - -static void -emph_class_init(EPluginHookClass *klass) -{ - ((GObjectClass *)klass)->finalize = emph_finalise; - klass->construct = emph_construct; - - /* this is actually an abstract implementation but list it anyway */ - klass->id = "org.gnome.evolution.event:1.0"; - - d(printf("EEventHook: init class %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - ((EEventHookClass *)klass)->target_map = g_hash_table_new(g_str_hash, g_str_equal); -} - -/** - * e_event_hook_get_type: - * - * Standard GObject function to get the EEvent object type. Used to - * subclass EEventHook. - * - * Return value: The type of the event hook class. - **/ -GType -e_event_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EEventHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL, - sizeof(EEventHook), 0, (GInstanceInitFunc) NULL, - }; - - emph_parent_class = g_type_class_ref(e_plugin_hook_get_type()); - type = g_type_register_static(e_plugin_hook_get_type(), "EEventHook", &info, 0); - } - - return type; -} - -/** - * e_event_hook_class_add_target_map: - * @klass: The derived EEventHook class. - * @map: A map used to describe a single EEventTarget type for this - * class. - * - * Add a target map to a concrete derived class of EEvent. The target - * map enumerates a single target type and th eenable mask bit names, - * so that the type can be loaded automatically by the base EEvent class. - **/ -void e_event_hook_class_add_target_map(EEventHookClass *klass, const EEventHookTargetMap *map) -{ - g_hash_table_insert(klass->target_map, (void *)map->type, (void *)map); -} diff --git a/e-util/e-event.h b/e-util/e-event.h deleted file mode 100644 index e2d9590c94..0000000000 --- a/e-util/e-event.h +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michel Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -/* - This a bit 'whipped together', so is likely to change mid-term -*/ - -#ifndef __E_EVENT_H__ -#define __E_EVENT_H__ - -#include <glib-object.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* This is an abstract event management class. */ - -typedef struct _EEvent EEvent; -typedef struct _EEventClass EEventClass; - -typedef struct _EEventItem EEventItem; -typedef struct _EEventFactory EEventFactory; /* anonymous type */ -typedef struct _EEventTarget EEventTarget; - -typedef void (*EEventItemsFunc)(EEvent *ee, GSList *items, void *data); -typedef void (*EEventFunc)(EEvent *ee, EEventItem *item, void *data); -typedef void (*EEventFactoryFunc)(EEvent *ee, void *); - -/** - * enum _e_event_t - Event type. - * - * @E_EVENT_PASS: A passthrough event handler which only receives the event. - * @E_EVENT_SINK: A sink event handler swallows all events it processes. - * - * The event type defines what type of event listener this is. - * - * Events should normally be @E_EVENT_PASS. - **/ -enum _e_event_t { - E_EVENT_PASS, /* passthrough */ - E_EVENT_SINK, /* sink events */ -}; - -/** - * struct _EEventItem - An event listener item. - * - * @type: The type of the event listener. - * @priority: A signed number signifying the priority of the event - * listener. 0 should be used normally. This is used to order event - * receipt when multiple listners are present. - * @id: The name of the event to listen to. By convention events are of the form - * "component.subcomponent". The target mask provides further - * sub-event type qualification. - * @target_type: Target type for this event. This is implementation - * specific. - * @handle: Event handler callback. - * @user_data: Callback data. - * @enable: Target-specific mask to qualify the receipt of events. - * This is target and implementation specific. - * - * An EEventItem defines a specific event listening point on a given - * EEvent object. When an event is broadcast onto an EEvent handler, - * any matching EEventItems will be invoked in priority order. - **/ -struct _EEventItem { - enum _e_event_t type; - int priority; /* priority of event */ - const char *id; /* event id */ - int target_type; - EEventFunc handle; - void *user_data; - guint32 enable; /* enable mask */ -}; - -/** - * struct _EEventTarget - Base EventTarget. - * - * @event: Parent object. - * @type: Target type. Defined by the implementation. - * @mask: Mask of this target. This is defined by the implementation, - * the type, and the actual content of the target. - * - * This defined a base EventTarget. This must be subclassed by - * implementations to provide contextual data for events, and define - * the enablement qualifiers. - * - **/ -struct _EEventTarget { - struct _EEvent *event; /* used for virtual methods */ - - guint32 type; /* targe type, for implementors */ - guint32 mask; /* depends on type, enable mask */ - - /* implementation fields follow */ -}; - -/** - * struct _EEvent - An Event Manager. - * - * @object: Superclass. - * @priv: Private data. - * @id: Id of this event manager. - * @target: The current target, only set during event emission. - * - * The EEvent manager object. Each component which defines event - * types supplies a single EEvent manager object. This manager routes - * all events invoked on this object to all registered listeners based - * on their qualifiers. - **/ -struct _EEvent { - GObject object; - - struct _EEventPrivate *priv; - char *id; - EEventTarget *target; /* current target during event emission */ -}; - -/** - * struct _EEventClass - Event management type. - * - * @object_class: Superclass. - * @target_free: Virtual method to free the target. - * - * The EEvent class definition. This must be sub-classed for each - * component that wishes to provide hookable events. The subclass - * only needs to know how to allocate and free each target type it - * supports. - **/ -struct _EEventClass { - GObjectClass object_class; - - void (*target_free)(EEvent *ep, EEventTarget *t); -}; - -GType e_event_get_type(void); - -EEvent *e_event_construct(EEvent *, const char *id); - -void *e_event_add_items(EEvent *emp, GSList *items, EEventItemsFunc freefunc, void *data); -void e_event_remove_items(EEvent *emp, void *handle); - -void e_event_emit(EEvent *, const char *id, EEventTarget *); - -void *e_event_target_new(EEvent *, int type, size_t size); -void e_event_target_free(EEvent *, void *); - -/* ********************************************************************** */ - -/* event plugin target, they are closely integrated */ - -/* To implement a basic event menu plugin, you just need to subclass - this and initialise the class target type tables */ - -/* For events, the plugin item talks to a specific instance, rather than - a set of instances of the hook handler */ - -#include "e-util/e-plugin.h" - -typedef struct _EEventHook EEventHook; -typedef struct _EEventHookClass EEventHookClass; - -typedef struct _EPluginHookTargetMap EEventHookTargetMap; -typedef struct _EPluginHookTargetKey EEventHookTargetMask; - -typedef void (*EEventHookFunc)(struct _EPlugin *plugin, EEventTarget *target); - -/** - * struct _EEventHook - An event hook. - * - * @hook: Superclass. - * - * The EEventHook class loads and manages the meta-data required to - * track event listeners. Unlike other hook types, there is a 1:1 - * match between an EEventHook instance class and its EEvent instance. - * - * When the hook is loaded, all of its event hooks are stored directly - * on the corresponding EEvent which is stored in its class static area. - **/ -struct _EEventHook { - EPluginHook hook; -}; - -/** - * struct _EEventHookClass - - * - * @hook_class: - * @target_map: Table of EPluginHookTargetMaps which enumerate the - * target types and enable bits of the implementing class. - * @event: The EEvent instance on which all loaded events must be registered. - * - * The EEventHookClass is an empty event hooking class, which must be - * subclassed and initialised before use. - * - * The EPluginHookClass.id must be set to the name and version of the - * hook handler itself, and then the type must be registered with the - * EPlugin hook list before any plugins are loaded. - **/ -struct _EEventHookClass { - EPluginHookClass hook_class; - - /* EEventHookTargetMap by .type */ - GHashTable *target_map; - /* the event router these events's belong to */ - EEvent *event; -}; - -GType e_event_hook_get_type(void); - -/* for implementors */ -void e_event_hook_class_add_target_map(EEventHookClass *klass, const EEventHookTargetMap *); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_EVENT_H__ */ diff --git a/e-util/e-folder-map.c b/e-util/e-folder-map.c deleted file mode 100644 index 8643152a06..0000000000 --- a/e-util/e-folder-map.c +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -#include "e-folder-map.h" - -#define d(x) - -static gboolean -is_type_folder (const char *metadata, const char *search_type) -{ - xmlNodePtr node; - xmlDocPtr doc; - char *type; - - if (!(doc = xmlParseFile (metadata))) { - g_warning ("Cannot parse `%s'", metadata); - return FALSE; - } - - if (!(node = xmlDocGetRootElement (doc))) { - g_warning ("`%s' corrupt: document contains no root node", metadata); - xmlFreeDoc (doc); - return FALSE; - } - - if (!node->name || strcmp (node->name, "efolder") != 0) { - g_warning ("`%s' corrupt: root node is not 'efolder'", metadata); - xmlFreeDoc (doc); - return FALSE; - } - - node = node->children; - while (node != NULL) { - if (node->name && !strcmp (node->name, "type")) { - type = xmlNodeGetContent (node); - if (!strcmp (type, search_type)) { - xmlFreeDoc (doc); - xmlFree (type); - - return TRUE; - } - - xmlFree (type); - - break; - } - - node = node->next; - } - - xmlFreeDoc (doc); - - return FALSE; -} - -static void -e_folder_map_dir (const char *dirname, const char *type, GSList **dir_list) -{ - char *path; - const char *name; - GDir *dir; - GError *error = NULL; - - path = g_build_filename (dirname, "folder-metadata.xml", NULL); - if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) { - g_free (path); - return; - } - - if (!is_type_folder (path, type)) { - g_free (path); - goto try_subdirs; - } - - d(g_message ("Found '%s'", dirname)); - *dir_list = g_slist_prepend (*dir_list, g_strdup (dirname)); - - g_free (path); - - try_subdirs: - - path = g_build_filename (dirname, "subfolders", NULL); - if (!g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - g_free (path); - return; - } - - if (!(dir = g_dir_open (path, 0, &error))) { - g_warning ("cannot open `%s': %s", path, error->message); - g_error_free (error); - g_free (path); - return; - } - - while ((name = g_dir_read_name (dir))) { - char *full_path; - - if (*name == '.') - continue; - - full_path = g_build_filename (path, name, NULL); - if (!g_file_test (full_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - g_free (full_path); - continue; - } - - e_folder_map_dir (full_path, type, dir_list); - g_free (full_path); - } - - g_dir_close (dir); - - g_free (path); -} - -GSList * -e_folder_map_local_folders (char *local_dir, char *type) -{ - const char *name; - GDir *dir; - GSList *dir_list = NULL; - GError *error = NULL; - - if (!(dir = g_dir_open (local_dir, 0, &error))) { - g_warning ("cannot open `%s': %s", local_dir, error->message); - g_error_free (error); - return NULL; - } - - while ((name = g_dir_read_name (dir))) { - char *full_path; - - if (*name == '.') - continue; - - full_path = g_build_filename (local_dir, name, NULL); - d(g_message ("Looking in %s", full_path)); - if (!g_file_test (full_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - g_free (full_path); - continue; - } - - e_folder_map_dir (full_path, type, &dir_list); - - g_free (full_path); - } - - g_dir_close (dir); - - return dir_list; -} diff --git a/e-util/e-folder-map.h b/e-util/e-folder-map.h deleted file mode 100644 index aeb5b39811..0000000000 --- a/e-util/e-folder-map.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef __E_FOLDER_MAP_H__ -#define __E_FOLDER_MAP_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -GSList *e_folder_map_local_folders (char *local_dir, char *type); - -G_END_DECLS - -#endif /* __E_FOLDER_MAP_H__ */ diff --git a/e-util/e-fsutils.c b/e-util/e-fsutils.c deleted file mode 100644 index 923dd5ec42..0000000000 --- a/e-util/e-fsutils.c +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <dirent.h> - -/* This isn't as portable as, say, the stuff in GNU coreutils. But I care not for OSF1. */ -#ifdef HAVE_STATVFS -# ifdef HAVE_SYS_STATVFS_H -# include <sys/statvfs.h> -# endif -#else -#ifdef HAVE_STATFS -# ifdef HAVE_SYS_PARAM_H -# include <sys/param.h> /* bsd interface */ -# endif -# ifdef HAVE_SYS_MOUNT_H -# include <sys/mount.h> -# endif -#endif -#endif - -#include <errno.h> -#include <string.h> - -#include "e-fsutils.h" - -/** - * e_fsutils_usage: - * @path: - * - * Calculate the amount of disk space used by a given path. - * - * Return value: The number of 1024 byte blocks used by the - * filesystem. - **/ -long e_fsutils_usage(const char *inpath) -{ - DIR *dir; - struct dirent *d; - long size = 0; - GSList *paths; - - /* iterative, depth-first scan, because i can ... */ - paths = g_slist_prepend(NULL, g_strdup(inpath)); - - while (paths) { - char *path = paths->data; - - paths = g_slist_remove_link(paths, paths); - - dir = opendir(path); - if (dir == NULL) { - g_free(path); - goto fail; - } - - while ((d = readdir(dir))) { - char *full_path; - struct stat st; - - if (strcmp(d->d_name, ".") == 0 - || strcmp(d->d_name, "..") == 0) - continue; - - full_path = g_build_filename(path, d->d_name, NULL); - if (stat(full_path, &st) == -1) { - g_free(full_path); - closedir(dir); - g_free(path); - goto fail; - } else if (S_ISDIR(st.st_mode)) { - paths = g_slist_prepend(paths, full_path); - full_path = NULL; - } else if (S_ISREG(st.st_mode)) { - /* This is in 512 byte blocks. st_blksize is page size on linux, - on *BSD it might be significant. */ - size += st.st_blocks/2; - } - - g_free(full_path); - } - - closedir(dir); - g_free(path); - } - - return size; - -fail: - g_slist_foreach(paths, (GFunc)g_free, NULL); - g_slist_free(paths); - - return -1; -} - -/** - * e_fsutils_avail: - * @path: - * - * Find the available disk space at the given path. - * - * Return value: -1 if it could not be determined, otherwise the - * number of disk blocks, expressed as system-independent, 1024 byte - * blocks. - **/ -long -e_fsutils_avail(const char *path) -{ -#if defined(HAVE_STATVFS) - struct statvfs stfs; - - if (statvfs(path, &stfs) == -1) - return -1; - - /* Assumes that frsize === power of 2 */ - if (stfs.f_frsize >= 1024) - return stfs.f_bavail * (stfs.f_frsize / 1024); - else - return stfs.f_bavail / (1024 / stfs.f_frsize); -#elif defined(HAVE_STATFS) - struct statfs stfs; - - if (statfs(path, &stfs) == -1) - return -1; - - /* For BSD this isn't clear, it may be dependent on f_bsize */ - return stfs.f_bavail / 2; -#else - errno = ENOSYS; - return -1; -#endif -} - diff --git a/e-util/e-fsutils.h b/e-util/e-fsutils.h deleted file mode 100644 index 915e702a9a..0000000000 --- a/e-util/e-fsutils.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef E_FSUTILS_H -#define E_FSUTILS_H - -#include <glib.h> - -G_BEGIN_DECLS - -long e_fsutils_usage(const char *path); -long e_fsutils_avail(const char *path); - -G_END_DECLS - -#endif /* !E_FOLDER_MAP_H */ diff --git a/e-util/e-gtk-utils.c b/e-util/e-gtk-utils.c deleted file mode 100644 index 99df6fe923..0000000000 --- a/e-util/e-gtk-utils.c +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-gtk-utils.c - * - * Copyright (C) 2000 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtklayout.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkstock.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkalignment.h> - -#include <gdk/gdkx.h> - -#include <X11/Xlib.h> - -#include "e-gtk-utils.h" - - -void -e_signal_connect_while_alive (void *instance, - const char *name, - GCallback callback, - void *callback_data, - void *alive_instance) -{ - GClosure *closure; - - g_return_if_fail (GTK_IS_OBJECT (instance)); - - closure = g_cclosure_new (callback, callback_data, NULL); - g_object_watch_closure (alive_instance, closure); - g_signal_connect_closure_by_id (instance, g_signal_lookup (name, G_OBJECT_TYPE (instance)), 0, - closure, FALSE); -} - - -/* (Cut and pasted from Gtk.) */ - -typedef struct DisconnectInfo { - unsigned int signal_handler; - - GtkObject *object1; - unsigned int disconnect_handler1; - - GtkObject *object2; - unsigned int disconnect_handler2; -} DisconnectInfo; - -static unsigned int -alive_disconnecter (GtkObject *object, - DisconnectInfo *info) -{ - g_assert (info != NULL); - - g_signal_handler_disconnect (info->object1, info->disconnect_handler1); - g_signal_handler_disconnect (info->object1, info->signal_handler); - g_signal_handler_disconnect (info->object2, info->disconnect_handler2); - - g_free (info); - - return 0; -} - -/** - * e_gtk_signal_connect_full_while_alive: - * @object: - * @name: - * @func: - * @marshal: - * @data: - * @destroy_func: - * @object_signal: - * @after: - * @alive_object: - * - * Connect a signal like `gtk_signal_connect_while_alive()', but with full - * params like `gtk_signal_connect_full()'. - **/ -void -e_signal_connect_full_while_alive (void *instance, - const char *name, - GtkSignalFunc func, - GtkCallbackMarshal marshal, - void *data, - GtkDestroyNotify destroy_func, - gboolean instance_signal, - gboolean after, - void *alive_instance) -{ - DisconnectInfo *info; - - g_return_if_fail (GTK_IS_OBJECT (instance)); - g_return_if_fail (name != NULL); - g_return_if_fail (func != NULL); - g_return_if_fail (GTK_IS_OBJECT (alive_instance)); - - info = g_new (DisconnectInfo, 1); - - info->signal_handler = gtk_signal_connect_full (instance, name, - func, marshal, data, - destroy_func, - instance_signal, after); - - info->object1 = instance; - info->disconnect_handler1 = g_signal_connect (instance, "destroy", - G_CALLBACK (alive_disconnecter), info); - - info->object2 = alive_instance; - info->disconnect_handler2 = g_signal_connect (alive_instance, "destroy", - G_CALLBACK (alive_disconnecter), info); -} - - -/* BackingStore support. */ - -static void -widget_realize_callback_for_backing_store (GtkWidget *widget, - void *data) -{ - XSetWindowAttributes attributes; - GdkWindow *window; - - if (GTK_IS_LAYOUT (widget)) - window = GTK_LAYOUT (widget)->bin_window; - else - window = widget->window; - - attributes.backing_store = Always; - XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XWINDOW (window), - CWBackingStore, &attributes); -} - -/** - * e_make_widget_backing_stored: - * @widget: A GtkWidget - * - * Make sure that the window for @widget has the BackingStore attribute set to - * Always when realized. This will allow the widget to be refreshed by the X - * server even if the application is currently not responding to X events (this - * is e.g. very useful for the splash screen). - * - * Notice that this will not work 100% in all cases as the server might not - * support that or just refuse to do so. - **/ -void -e_make_widget_backing_stored (GtkWidget *widget) -{ - g_signal_connect (widget, "realize", G_CALLBACK (widget_realize_callback_for_backing_store), NULL); -} - - -/** - * e_gtk_button_new_with_icon: - * @text: The mnemonic text for the label. - * @stock: The name of the stock item to get the icon from. - * - * Create a gtk button with a custom label and a stock icon. - * - * - * Return value: The widget. - **/ -GtkWidget * -e_gtk_button_new_with_icon(const char *text, const char *stock) -{ - GtkWidget *button, *label; - GtkStockItem item; - - button = gtk_button_new(); - label = gtk_label_new_with_mnemonic(text); - gtk_label_set_mnemonic_widget((GtkLabel *)label, button); - - if (gtk_stock_lookup(stock, &item)) { - GtkWidget *image, *hbox, *align; - - image = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_BUTTON); - hbox = gtk_hbox_new(FALSE, 2); - align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); - gtk_box_pack_start((GtkBox *)hbox, image, FALSE, FALSE, 0); - gtk_box_pack_end((GtkBox *)hbox, label, FALSE, FALSE, 0); - gtk_container_add((GtkContainer *)align, hbox); - gtk_container_add((GtkContainer *)button, align); - gtk_widget_show_all(align); - } else { - gtk_misc_set_alignment((GtkMisc *)label, 0.5, 0.5); - gtk_container_add((GtkContainer *)button, label); - gtk_widget_show(label); - } - - return button; -} diff --git a/e-util/e-gtk-utils.h b/e-util/e-gtk-utils.h deleted file mode 100644 index cebb5b757d..0000000000 --- a/e-util/e-gtk-utils.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-gtk-utils.c - * - * Copyright (C) 2000 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef E_GTK_UTILS_H -#define E_GTK_UTILS_H - -#include <gtk/gtkobject.h> -#include <gtk/gtkradiobutton.h> - -void e_signal_connect_while_alive (void *object, - const char *name, - GCallback callback, - void *data, - void *alive_instance); - -void e_signal_connect_full_while_alive (void *instance, - const char *name, - GtkSignalFunc func, - GtkCallbackMarshal marshal, - void *data, - GtkDestroyNotify destroy_func, - gboolean object_signal, - gboolean after, - void *alive_instance); - -void e_make_widget_backing_stored (GtkWidget *widget); - -GtkWidget *e_gtk_button_new_with_icon(const char *text, const char *stock); - -#endif diff --git a/e-util/e-gui-utils.c b/e-util/e-gui-utils.c deleted file mode 100644 index 3e8849fe93..0000000000 --- a/e-util/e-gui-utils.c +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * GUI utility functions - * - * Authors: - * Miguel de Icaza (miguel@ximian.com) - * Chris Toshok (toshok@ximian.com) - * - * Copyright (C) 1999 Miguel de Icaza - * Copyright (C) 2000-2003 Ximian, Inc. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include "e-gui-utils.h" -#include <e-util/e-icon-factory.h> - -#include <glib.h> -#include <gtk/gtkalignment.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkhbox.h> - -#include <libgnome/gnome-program.h> -#include <libgnomevfs/gnome-vfs-mime-handlers.h> -#include <libgnomeui/gnome-icon-lookup.h> - -GtkWidget *e_create_image_widget(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - GtkWidget *alignment = NULL; - GdkPixbuf *pixbuf; - GtkWidget *w; - - if (string1) { - w = e_icon_factory_get_image (string1, E_ICON_SIZE_DIALOG); - - gtk_misc_set_alignment (GTK_MISC (w), 0.5, 0.5); - - alignment = gtk_widget_new(gtk_alignment_get_type(), - "child", w, - "xalign", (double) 0, - "yalign", (double) 0, - "xscale", (double) 0, - "yscale", (double) 0, - NULL); - - gtk_widget_show_all (alignment); - } - - return alignment; -} - -GtkWidget * -e_button_new_with_stock_icon (const char *label_str, const char *stockid) -{ - GtkWidget *button, *hbox, *label, *align, *image; - - button = gtk_button_new (); - - label = gtk_label_new_with_mnemonic (label_str); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), button); - - image = gtk_image_new_from_stock (stockid, GTK_ICON_SIZE_BUTTON); - hbox = gtk_hbox_new (FALSE, 2); - - align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); - - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - gtk_container_add (GTK_CONTAINER (button), align); - gtk_container_add (GTK_CONTAINER (align), hbox); - gtk_widget_show_all (align); - - return button; -} - -/** - * e_icon_for_mime_type: - * @mime_type: a MIME type - * @size_hint: the size the caller plans to display the icon at - * - * Tries to find an icon representing @mime_type that will display - * nicely at @size_hint by @size_hint pixels. The returned icon - * may or may not actually be that size. - * - * Return value: a pixbuf, which the caller must unref when it is done - **/ -GdkPixbuf * -e_icon_for_mime_type (const char *mime_type, int size_hint) -{ - static GnomeIconTheme *icon_theme = NULL; - char *icon_name, *icon_path = NULL; - GdkPixbuf *pixbuf = NULL; - - /* Try the icon theme. (GNOME 2.2 or Sun GNOME 2.0). - * This will also look in GNOME VFS. - */ - - if (!icon_theme) - icon_theme = gnome_icon_theme_new (); - - icon_name = gnome_icon_lookup (icon_theme, NULL, NULL, NULL, NULL, - mime_type, 0, NULL); - if (icon_name) { - /* FIXME: should we take size_hint as being the same - * as e-icon-factory.c? or should we just leave this - * as pixel size? */ - icon_path = gnome_icon_theme_lookup_icon ( - icon_theme, icon_name, size_hint, NULL, NULL); - g_free (icon_name); - } - - if (icon_path == NULL) - return NULL; - - pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL); - g_free (icon_path); - - return pixbuf; -} - diff --git a/e-util/e-gui-utils.h b/e-util/e-gui-utils.h deleted file mode 100644 index 8701949cb0..0000000000 --- a/e-util/e-gui-utils.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef E_GUI_UTILS_H -#define E_GUI_UTILS_H - -#include <gtk/gtkwidget.h> -#include <bonobo/bonobo-ui-util.h> -#include <bonobo/bonobo-control.h> - -GtkWidget *e_create_image_widget (gchar *name, gchar *string1, gchar *string2, gint int1, gint int2); - -GtkWidget *e_button_new_with_stock_icon (const char *label_str, const char *stockid); - -GdkPixbuf *e_icon_for_mime_type (const char *mime_type, int size); - -#endif /* E_GUI_UTILS_H */ diff --git a/e-util/e-html-utils.c b/e-util/e-html-utils.c deleted file mode 100644 index 535d772dc4..0000000000 --- a/e-util/e-html-utils.c +++ /dev/null @@ -1,524 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-html-utils.c - * Copyright (C) 2000-2003 Ximian, Inc. - * Author: Dan Winship <danw@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <glib.h> - -#include "e-html-utils.h" - -static char * -check_size (char **buffer, int *buffer_size, char *out, int len) -{ - if (out + len + 1> *buffer + *buffer_size) { - int index = out - *buffer; - - *buffer_size = MAX (index + len + 1, *buffer_size * 2); - *buffer = g_realloc (*buffer, *buffer_size); - out = *buffer + index; - } - return out; -} - -/* auto-urlification hints: the goal is not to be strictly RFC-compliant, - * but rather to accurately distinguish urls/addresses from non-urls/ - * addresses in real-world email. - * - * 1 = non-email-address chars: ()<>@,;:\"[]`'{}| - * 2 = trailing url garbage: ,.!?;:>)]}`'-_ - * 4 = allowed dns chars - * 8 = non-url chars: "| - */ -static int special_chars[] = { - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* nul - 0x0f */ - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 0x10 - 0x1f */ - 9, 2, 9, 0, 0, 0, 0, 3, 1, 3, 0, 0, 3, 6, 6, 0, /* sp - / */ - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 1, 0, 3, 2, /* 0 - ? */ - 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, /* @ - O */ - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 3, 0, 2, /* P - _ */ - 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, /* ` - o */ - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 9, 3, 0, 3 /* p - del */ -}; - -#define is_addr_char(c) (c < 128 && !(special_chars[c] & 1)) -#define is_url_char(c) (c < 128 && !(special_chars[c] & 8)) -#define is_trailing_garbage(c) (c > 127 || (special_chars[c] & 2)) -#define is_domain_name_char(c) (c < 128 && (special_chars[c] & 4)) - -/* (http|https|ftp|nntp)://[^ "|/]+\.([^ "|]*[^ ,.!?;:>)\]}`'"|_-])+ */ -/* www\.[A-Za-z0-9.-]+(/([^ "|]*[^ ,.!?;:>)\]}`'"|_-])+) */ - -static char * -url_extract (const unsigned char **text, gboolean full_url) -{ - const unsigned char *end = *text, *p; - char *out; - - while (*end && is_url_char (*end)) - end++; - - /* Back up if we probably went too far. */ - while (end > *text && is_trailing_garbage (*(end - 1))) - end--; - - if (full_url) { - /* Make sure this really looks like a URL. */ - p = memchr (*text, ':', end - *text); - if (!p || end - p < 4) - return NULL; - } else { - /* Make sure this really looks like a hostname. */ - p = memchr (*text, '.', end - *text); - if (!p || p >= end - 2) - return NULL; - p = memchr (p + 2, '.', end - (p + 2)); - if (!p || p >= end - 2) - return NULL; - } - - out = g_strndup (*text, end - *text); - *text = end; - return out; -} - -static char * -email_address_extract (const unsigned char **cur, char **out, const unsigned char *linestart) -{ - const unsigned char *start, *end, *dot; - char *addr; - - /* *cur points to the '@'. Look backward for a valid local-part */ - for (start = *cur; start - 1 >= linestart && is_addr_char (*(start - 1)); start--) - ; - if (start == *cur) - return NULL; - if (start > linestart + 2 && - start[-1] == ':' && start[0] == '/' && start[1] == '/') - return NULL; - - /* Now look forward for a valid domain part */ - for (end = *cur + 1, dot = NULL; is_domain_name_char (*end); end++) { - if (*end == '.' && !dot) - dot = end; - } - if (!dot) - return NULL; - - /* Remove trailing garbage */ - while (is_trailing_garbage (*(end - 1))) - end--; - if (dot > end) - return NULL; - - addr = g_strndup (start, end - start); - *out -= *cur - start; - *cur = end; - - return addr; -} - -static gboolean -is_citation (const unsigned char *c, gboolean saw_citation) -{ - const unsigned char *p; - - if (*c != '>') - return FALSE; - - /* A line that starts with a ">" is a citation, unless it's - * just mbox From-mangling... - */ - if (strncmp (c, ">From ", 6) != 0) - return TRUE; - - /* If the previous line was a citation, then say this - * one is too. - */ - if (saw_citation) - return TRUE; - - /* Same if the next line is */ - p = (const unsigned char *)strchr ((const char *)c, '\n'); - if (p && *++p == '>') - return TRUE; - - /* Otherwise, it was just an isolated ">From" line. */ - return FALSE; -} - -/** - * e_text_to_html_full: - * @input: a NUL-terminated input buffer - * @flags: some combination of the E_TEXT_TO_HTML_* flags defined - * in e-html-utils.h - * @color: color for citation highlighting - * - * This takes a buffer of text as input and produces a buffer of - * "equivalent" HTML, subject to certain transformation rules. - * - * The set of possible flags is: - * - * - E_TEXT_TO_HTML_PRE: wrap the output HTML in <PRE> and </PRE>. - * Should only be used if @input is the entire buffer to be - * converted. If e_text_to_html is being called with small pieces - * of data, you should wrap the entire result in <PRE> yourself. - * - * - E_TEXT_TO_HTML_CONVERT_NL: convert "\n" to "<BR>\n" on output. - * (should not be used with E_TEXT_TO_HTML_PRE, since that would - * result in double-newlines). - * - * - E_TEXT_TO_HTML_CONVERT_SPACES: convert a block of N spaces - * into N-1 non-breaking spaces and one normal space. A space - * at the start of the buffer is always converted to a - * non-breaking space, regardless of the following character, - * which probably means you don't want to use this flag on - * pieces of data that aren't delimited by at least line breaks. - * - * If E_TEXT_TO_HTML_CONVERT_NL and E_TEXT_TO_HTML_CONVERT_SPACES - * are both defined, then TABs will also be converted to spaces. - * - * - E_TEXT_TO_HTML_CONVERT_URLS: wrap <a href="..."> </a> around - * strings that look like URLs. - * - * - E_TEXT_TO_HTML_CONVERT_ADDRESSES: wrap <a href="mailto:..."> </a> around - * strings that look like mail addresses. - * - * - E_TEXT_TO_HTML_MARK_CITATION: wrap <font color="..."> </font> around - * citations (lines beginning with "> ", etc). - * - * - E_TEXT_TO_HTML_ESCAPE_8BIT: flatten everything to US-ASCII - * - * - E_TEXT_TO_HTML_CITE: quote the text with "> " at the start of each - * line. - **/ -char * -e_text_to_html_full (const char *input, unsigned int flags, guint32 color) -{ - const unsigned char *cur, *next, *linestart; - char *buffer = NULL; - char *out = NULL; - int buffer_size = 0, col; - gboolean colored = FALSE, saw_citation = FALSE; - - /* Allocate a translation buffer. */ - buffer_size = strlen (input) * 2 + 5; - buffer = g_malloc (buffer_size); - - out = buffer; - if (flags & E_TEXT_TO_HTML_PRE) - out += sprintf (out, "<PRE>"); - - col = 0; - - for (cur = linestart = input; cur && *cur; cur = next) { - gunichar u; - - if (flags & E_TEXT_TO_HTML_MARK_CITATION && col == 0) { - saw_citation = is_citation (cur, saw_citation); - if (saw_citation) { - if (!colored) { - gchar font [25]; - - g_snprintf (font, 25, "<FONT COLOR=\"#%06x\">", color); - - out = check_size (&buffer, &buffer_size, out, 25); - out += sprintf (out, "%s", font); - colored = TRUE; - } - } else if (colored) { - gchar *no_font = "</FONT>"; - - out = check_size (&buffer, &buffer_size, out, 9); - out += sprintf (out, "%s", no_font); - colored = FALSE; - } - - /* Display mbox-mangled ">From" as "From" */ - if (*cur == '>' && !saw_citation) - cur++; - } else if (flags & E_TEXT_TO_HTML_CITE && col == 0) { - out = check_size (&buffer, &buffer_size, out, 5); - out += sprintf (out, "> "); - } - - u = g_utf8_get_char (cur); - if (g_unichar_isalpha (u) && - (flags & E_TEXT_TO_HTML_CONVERT_URLS)) { - char *tmpurl = NULL, *refurl = NULL, *dispurl = NULL; - - if (!strncasecmp (cur, "http://", 7) || - !strncasecmp (cur, "https://", 8) || - !strncasecmp (cur, "ftp://", 6) || - !strncasecmp (cur, "nntp://", 7) || - !strncasecmp (cur, "mailto:", 7) || - !strncasecmp (cur, "news:", 5) || - !strncasecmp (cur, "file:", 5) || - !strncasecmp (cur, "callto:", 7) || - !strncasecmp (cur, "h323:", 5) || - !strncasecmp (cur, "webcal:", 7)) { - tmpurl = url_extract (&cur, TRUE); - if (tmpurl) { - refurl = e_text_to_html (tmpurl, 0); - dispurl = g_strdup (refurl); - } - } else if (!strncasecmp (cur, "www.", 4) && - is_url_char (*(cur + 4))) { - tmpurl = url_extract (&cur, FALSE); - if (tmpurl) { - dispurl = e_text_to_html (tmpurl, 0); - refurl = g_strdup_printf ("http://%s", - dispurl); - } - } - - if (tmpurl) { - out = check_size (&buffer, &buffer_size, out, - strlen (refurl) + - strlen (dispurl) + 15); - out += sprintf (out, - "<a href=\"%s\">%s</a>", - refurl, dispurl); - col += strlen (tmpurl); - g_free (tmpurl); - g_free (refurl); - g_free (dispurl); - } - - if (!*cur) - break; - u = g_utf8_get_char (cur); - } - - if (u == '@' && (flags & E_TEXT_TO_HTML_CONVERT_ADDRESSES)) { - char *addr, *dispaddr, *outaddr; - - addr = email_address_extract (&cur, &out, linestart); - if (addr) { - dispaddr = e_text_to_html (addr, 0); - outaddr = g_strdup_printf ("<a href=\"mailto:%s\">%s</a>", - addr, dispaddr); - out = check_size (&buffer, &buffer_size, out, strlen (outaddr)); - out += sprintf (out, "%s", outaddr); - col += strlen (addr); - g_free (addr); - g_free (dispaddr); - g_free (outaddr); - - if (!*cur) - break; - u = g_utf8_get_char (cur); - } - } - - if (!g_unichar_validate (u)) { - /* Sigh. Someone sent undeclared 8-bit data. - * Assume it's iso-8859-1. - */ - u = *cur; - next = cur + 1; - } else - next = g_utf8_next_char (cur); - - out = check_size (&buffer, &buffer_size, out, 10); - - switch (u) { - case '<': - strcpy (out, "<"); - out += 4; - col++; - break; - - case '>': - strcpy (out, ">"); - out += 4; - col++; - break; - - case '&': - strcpy (out, "&"); - out += 5; - col++; - break; - - case '"': - strcpy (out, """); - out += 6; - col++; - break; - - case '\n': - if (flags & E_TEXT_TO_HTML_CONVERT_NL) { - strcpy (out, "<br>"); - out += 4; - } - *out++ = *cur; - linestart = cur; - col = 0; - break; - - case '\t': - if (flags & (E_TEXT_TO_HTML_CONVERT_SPACES | - E_TEXT_TO_HTML_CONVERT_NL)) { - do { - out = check_size (&buffer, &buffer_size, - out, 7); - strcpy (out, " "); - out += 6; - col++; - } while (col % 8); - break; - } - /* otherwise, FALL THROUGH */ - - case ' ': - if (flags & E_TEXT_TO_HTML_CONVERT_SPACES) { - if (cur == (const unsigned char *)input || - *(cur + 1) == ' ' || *(cur + 1) == '\t' || - *(cur - 1) == '\n') { - strcpy (out, " "); - out += 6; - col++; - break; - } - } - /* otherwise, FALL THROUGH */ - - default: - if ((u >= 0x20 && u < 0x80) || - (u == '\r' || u == '\t')) { - /* Default case, just copy. */ - *out++ = u; - } else { - if (flags & E_TEXT_TO_HTML_ESCAPE_8BIT) - *out++ = '?'; - else - out += g_snprintf(out, 9, "&#%d;", u); - } - col++; - break; - } - } - - out = check_size (&buffer, &buffer_size, out, 7); - if (flags & E_TEXT_TO_HTML_PRE) - strcpy (out, "</PRE>"); - else - *out = '\0'; - - return buffer; -} - -char * -e_text_to_html (const char *input, unsigned int flags) -{ - return e_text_to_html_full (input, flags, 0); -} - - -#ifdef E_HTML_UTILS_TEST - -struct { - char *text, *url; -} url_tests[] = { - { "bob@foo.com", "mailto:bob@foo.com" }, - { "Ends with bob@foo.com", "mailto:bob@foo.com" }, - { "bob@foo.com at start", "mailto:bob@foo.com" }, - { "bob@foo.com.", "mailto:bob@foo.com" }, - { "\"bob@foo.com\"", "mailto:bob@foo.com" }, - { "<bob@foo.com>", "mailto:bob@foo.com" }, - { "(bob@foo.com)", "mailto:bob@foo.com" }, - { "bob@foo.com, 555-9999", "mailto:bob@foo.com" }, - { "|bob@foo.com|555-9999|", "mailto:bob@foo.com" }, - { "bob@ no match bob@", NULL }, - { "@foo.com no match @foo.com", NULL }, - { "\"bob\"@foo.com", NULL }, - { "M@ke money fast!", NULL }, - { "ASCII art @_@ @>->-", NULL }, - - { "http://www.foo.com", "http://www.foo.com" }, - { "Ends with http://www.foo.com", "http://www.foo.com" }, - { "http://www.foo.com at start", "http://www.foo.com" }, - { "http://www.foo.com.", "http://www.foo.com" }, - { "http://www.foo.com/.", "http://www.foo.com/" }, - { "<http://www.foo.com>", "http://www.foo.com" }, - { "(http://www.foo.com)", "http://www.foo.com" }, - { "http://www.foo.com, 555-9999", "http://www.foo.com" }, - { "|http://www.foo.com|555-9999|", "http://www.foo.com" }, - { "foo http://www.foo.com/ bar", "http://www.foo.com/" }, - { "foo http://www.foo.com/index.html bar", "http://www.foo.com/index.html" }, - { "foo http://www.foo.com/q?99 bar", "http://www.foo.com/q?99" }, - { "foo http://www.foo.com/;foo=bar&baz=quux bar", "http://www.foo.com/;foo=bar&baz=quux" }, - { "foo http://www.foo.com/index.html#anchor bar", "http://www.foo.com/index.html#anchor" }, - { "http://www.foo.com/index.html; foo", "http://www.foo.com/index.html" }, - { "http://www.foo.com/index.html: foo", "http://www.foo.com/index.html" }, - { "http://www.foo.com/index.html-- foo", "http://www.foo.com/index.html" }, - { "http://www.foo.com/index.html?", "http://www.foo.com/index.html" }, - { "http://www.foo.com/index.html!", "http://www.foo.com/index.html" }, - { "\"http://www.foo.com/index.html\"", "http://www.foo.com/index.html" }, - { "'http://www.foo.com/index.html'", "http://www.foo.com/index.html" }, - { "http://bob@www.foo.com/bar/baz/", "http://bob@www.foo.com/bar/baz/" }, - { "http no match http", NULL }, - { "http: no match http:", NULL }, - { "http:// no match http://", NULL }, - { "unrecognized://bob@foo.com/path", NULL }, - - { "src/www.c", NULL }, - { "Ewwwwww.Gross.", NULL }, - -}; -int num_url_tests = G_N_ELEMENTS (url_tests); - -int -main (int argc, char **argv) -{ - int i, errors = 0; - char *html, *url, *p; - - for (i = 0; i < num_url_tests; i++) { - html = e_text_to_html (url_tests[i].text, E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_CONVERT_ADDRESSES); - - url = strstr (html, "href=\""); - if (url) { - url += 6; - p = strchr (url, '"'); - if (p) - *p = '\0'; - - while ((p = strstr (url, "&"))) - memmove (p + 1, p + 5, strlen (p + 5) + 1); - } - - if ((url && (!url_tests[i].url || strcmp (url, url_tests[i].url) != 0)) || - (!url && url_tests[i].url)) { - printf ("FAILED on \"%s\" -> %s\n (got %s)\n\n", - url_tests[i].text, - url_tests[i].url ? url_tests[i].url : "(nothing)", - url ? url : "(nothing)"); - errors++; - } - - g_free (html); - } - - printf ("\n%d errors\n", errors); - return errors; -} -#endif diff --git a/e-util/e-html-utils.h b/e-util/e-html-utils.h deleted file mode 100644 index 551996e089..0000000000 --- a/e-util/e-html-utils.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-html-utils.c */ -/* - * Copyright (C) 2000 Ximian, Inc. - * Author: Dan Winship <danw@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __E_HTML_UTILS__ -#define __E_HTML_UTILS__ - -#include <glib.h> - -#define E_TEXT_TO_HTML_PRE (1 << 0) -#define E_TEXT_TO_HTML_CONVERT_NL (1 << 1) -#define E_TEXT_TO_HTML_CONVERT_SPACES (1 << 2) -#define E_TEXT_TO_HTML_CONVERT_URLS (1 << 3) -#define E_TEXT_TO_HTML_MARK_CITATION (1 << 4) -#define E_TEXT_TO_HTML_CONVERT_ADDRESSES (1 << 5) -#define E_TEXT_TO_HTML_ESCAPE_8BIT (1 << 6) -#define E_TEXT_TO_HTML_CITE (1 << 7) - -char *e_text_to_html_full (const char *input, unsigned int flags, guint32 color); -char *e_text_to_html (const char *input, unsigned int flags); - -#endif /* __E_HTML_UTILS__ */ diff --git a/e-util/e-icon-factory.c b/e-util/e-icon-factory.c deleted file mode 100644 index eac14f4e9f..0000000000 --- a/e-util/e-icon-factory.c +++ /dev/null @@ -1,391 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@novell.com> - * - * Copyright 2004 Novell, Inc. (www.novell.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <dirent.h> - -#include <pthread.h> - -#include <gtk/gtkimage.h> -#include <libgnomeui/gnome-icon-theme.h> -#include <e-util/e-icon-factory.h> - -#include "art/broken-image-16.xpm" -#include "art/broken-image-24.xpm" - -static int sizes[E_ICON_NUM_SIZES] = { - 16, /* menu */ - 20, /* button */ - 18, /* small toolbar */ - 24, /* large toolbar */ - 32, /* dnd */ - 48, /* dialog */ -}; - - -typedef struct { - char *name; - GdkPixbuf *pixbuf; -} Icon; - -static GdkPixbuf *broken16_pixbuf = NULL; -static GdkPixbuf *broken24_pixbuf = NULL; - -static GHashTable *name_to_icon = NULL; -static GnomeIconTheme *icon_theme = NULL; -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - - -/* Note: takes ownership of the pixbufs (eg. does not ref them) */ -static Icon * -icon_new (const char *name, GdkPixbuf *pixbuf) -{ - Icon *icon; - - icon = g_malloc0 (sizeof (Icon)); - icon->name = g_strdup (name); - icon->pixbuf = pixbuf; - - return icon; -} - -static void -icon_free (Icon *icon) -{ - g_free (icon->name); - if (icon->pixbuf) - g_object_unref (icon->pixbuf); - g_free (icon); -} - -static Icon * -load_icon (const char *icon_key, const char *icon_name, int size, int scale) -{ - GdkPixbuf *pixbuf, *unscaled = NULL; - char *filename = NULL; - - if (icon_name[0] == '/') - filename = g_strdup (icon_name); - else - filename = gnome_icon_theme_lookup_icon (icon_theme, icon_name, size, NULL, NULL); - - if (!filename || !(unscaled = gdk_pixbuf_new_from_file (filename, NULL))) { - if (scale) { - struct dirent *dent; - int width, height; - size_t baselen; - GString *path; - DIR *dir; - char *x; - - path = g_string_new (EVOLUTION_ICONSDIR); - if (path->str[path->len - 1] != '/') - g_string_append_c (path, '/'); - - baselen = path->len; - - if (!(dir = opendir (path->str))) { - g_string_free (path, TRUE); - goto done; - } - - /* scan icon directories looking for an icon with a size >= the size we need. */ - while ((dent = readdir (dir))) { - if (!(dent->d_name[0] >= '1' && dent->d_name[0] <= '9')) - continue; - - if (((width = strtol (dent->d_name, &x, 10)) < size) || *x != 'x') - continue; - - if (((height = strtol (x + 1, &x, 10)) != width) || *x != '\0') - continue; - - /* if the icon exists in this directory, we can [use/scale] it */ - g_string_truncate (path, baselen); - g_string_append_printf (path, "%s/%s.png", dent->d_name, icon_name); - if ((unscaled = gdk_pixbuf_new_from_file (path->str, NULL))) - break; - } - - g_string_free (path, TRUE); - closedir (dir); - } else { - g_free (filename); - filename = g_strdup_printf (EVOLUTION_ICONSDIR "/%dx%d/%s.png", size, size, icon_name); - unscaled = gdk_pixbuf_new_from_file (filename, NULL); - } - } - - done: - - g_free (filename); - if (unscaled != NULL) { - pixbuf = gdk_pixbuf_scale_simple (unscaled, size, size, GDK_INTERP_BILINEAR); - g_object_unref (unscaled); - } else { - pixbuf = NULL; - } - - return icon_new (icon_key, pixbuf); -} - - -/* temporary workaround for code that has not yet been ported to the new icon_size API */ -static int -pixel_size_to_icon_size (int pixel_size) -{ - int i, icon_size = -1; - - for (i = 0; i < E_ICON_NUM_SIZES; i++) { - if (pixel_size == sizes[i]) { - icon_size = i; - break; - } - } - - return icon_size; -} - -static gboolean -icon_foreach_remove (gpointer key, gpointer value, gpointer user_data) -{ - icon_free (value); - - return TRUE; -} - -static void -icon_theme_changed_cb (GnomeIconTheme *object, gpointer user_data) -{ - g_hash_table_foreach_remove (name_to_icon, (GHRFunc) icon_foreach_remove, NULL); -} - -/** - * e_icon_factory_init: - * - * Initialises the icon factory. - **/ -void -e_icon_factory_init (void) -{ - if (name_to_icon != NULL) - return; - - icon_theme = gnome_icon_theme_new (); - name_to_icon = g_hash_table_new (g_str_hash, g_str_equal); - g_signal_connect (G_OBJECT (icon_theme), "changed", G_CALLBACK (icon_theme_changed_cb), NULL); - - broken16_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) broken_image_16_xpm); - broken24_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) broken_image_24_xpm); -} - -static void -icon_foreach_free (gpointer key, gpointer value, gpointer user_data) -{ - icon_free (value); -} - -/** - * e_icon_factory_shutdown: - * - * Shuts down the icon factory (cleans up all cached icons, etc). - **/ -void -e_icon_factory_shutdown (void) -{ - if (name_to_icon == NULL) - return; - - g_hash_table_foreach (name_to_icon, (GHFunc) icon_foreach_free, NULL); - g_hash_table_destroy (name_to_icon); - g_object_unref (broken16_pixbuf); - g_object_unref (broken24_pixbuf); - g_object_unref (icon_theme); - name_to_icon = NULL; -} - - -/** - * e_icon_factory_get_icon_filename: - * @icon_name: name of the icon - * @size: MENU/SMALL_TOOLBAR/etc - * - * Looks up the icon to use based on name and size. - * - * Returns the requested icon pixbuf. - **/ -char * -e_icon_factory_get_icon_filename (const char *icon_name, int icon_size) -{ - char *filename; - - g_return_val_if_fail (icon_name != NULL, NULL); - g_return_val_if_fail (strcmp (icon_name, ""), NULL); - - if (icon_size >= E_ICON_NUM_SIZES) { - g_warning ("calling e_icon_factory_get_icon_filename with unknown icon_size value (%d)", icon_size); - if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1) - return NULL; - } - - pthread_mutex_lock (&lock); - filename = gnome_icon_theme_lookup_icon (icon_theme, icon_name, sizes[icon_size], NULL, NULL); - pthread_mutex_unlock (&lock); - - return filename; -} - - -/** - * e_icon_factory_get_icon: - * @icon_name: name of the icon - * @icon_size: size of the icon (one of the E_ICON_SIZE_* enum values) - * - * Returns the specified icon of the requested size (may perform - * scaling to achieve this). If @icon_name is a full path, that file - * is used directly. Otherwise it is looked up in the user's current - * icon theme. If the icon cannot be found in the icon theme, it falls - * back to loading the requested icon from Evolution's icon set - * installed from the art/ srcdir. If even that fails to find the - * requested icon, then a "broken-image" icon is returned. - **/ -GdkPixbuf * -e_icon_factory_get_icon (const char *icon_name, int icon_size) -{ - GdkPixbuf *pixbuf; - char *icon_key; - Icon *icon; - int size; - - if (icon_size >= E_ICON_NUM_SIZES) { - g_warning ("calling e_icon_factory_get_icon with unknown icon_size value (%d)", icon_size); - if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1) - return NULL; - } - - size = sizes[icon_size]; - - if (icon_name == NULL || !strcmp (icon_name, "")) { - if (size >= 24) - return gdk_pixbuf_scale_simple (broken24_pixbuf, size, size, GDK_INTERP_NEAREST); - else - return gdk_pixbuf_scale_simple (broken16_pixbuf, size, size, GDK_INTERP_NEAREST); - } - - icon_key = g_alloca (strlen (icon_name) + 7); - sprintf (icon_key, "%dx%d/%s", size, size, icon_name); - - pthread_mutex_lock (&lock); - - if (!(icon = g_hash_table_lookup (name_to_icon, icon_key))) { - if (!(icon = load_icon (icon_key, icon_name, size, TRUE))) { - g_warning ("Icon not found -- %s", icon_name); - - /* Create an empty icon so that we don't keep spitting - out the same warning over and over, every time this - icon is requested. */ - - icon = icon_new (icon_key, NULL); - g_hash_table_insert (name_to_icon, icon->name, icon); - } else { - g_hash_table_insert (name_to_icon, icon->name, icon); - } - } - - if ((pixbuf = icon->pixbuf)) { - g_object_ref (pixbuf); - } else { - if (size >= 24) - pixbuf = gdk_pixbuf_scale_simple (broken24_pixbuf, size, size, GDK_INTERP_NEAREST); - else - pixbuf = gdk_pixbuf_scale_simple (broken16_pixbuf, size, size, GDK_INTERP_NEAREST); - } - - pthread_mutex_unlock (&lock); - - return pixbuf; -} - -GtkWidget * -e_icon_factory_get_image (const char *icon_name, int icon_size) -{ - GdkPixbuf *pixbuf; - GtkWidget *image; - - pixbuf = e_icon_factory_get_icon (icon_name, icon_size); - image = gtk_image_new_from_pixbuf (pixbuf); - g_object_unref (pixbuf); - - return image; -} - -/** - * e_icon_factory_get_icon_list: - * @icon_name: name of the icon - * - * Returns a list of GdkPixbufs of the requested name suitable for - * gtk_window_set_icon_list(). - **/ -GList * -e_icon_factory_get_icon_list (const char *icon_name) -{ - static int icon_list_sizes[] = { 128, 64, 48, 32, 16 }; - GList *list = NULL; - char *icon_key; - Icon *icon; - int size, i; - - if (!icon_name || !strcmp (icon_name, "")) - return NULL; - - pthread_mutex_lock (&lock); - - icon_key = g_alloca (strlen (icon_name) + 9); - - for (i = 0; i < G_N_ELEMENTS (icon_list_sizes); i++) { - size = icon_list_sizes[i]; - sprintf (icon_key, "%dx%d/%s", size, size, icon_name); - - if (!(icon = g_hash_table_lookup (name_to_icon, icon_key))) { - if ((icon = load_icon (icon_key, icon_name, size, FALSE))) - g_hash_table_insert (name_to_icon, icon->name, icon); - } - - if (icon && icon->pixbuf) { - list = g_list_prepend (list, icon->pixbuf); - g_object_ref (icon->pixbuf); - } - } - - pthread_mutex_unlock (&lock); - - return list; -} diff --git a/e-util/e-icon-factory.h b/e-util/e-icon-factory.h deleted file mode 100644 index 966e1f56e4..0000000000 --- a/e-util/e-icon-factory.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-icon-factory.h - Icon factory for the Evolution shell. - * - * Copyright (C) 2002-2004 Novell, 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli <ettore@ximian.com> - */ - -#ifndef _E_ICON_FACTORY_H_ -#define _E_ICON_FACTORY_H_ - -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gtk/gtkwidget.h> - -enum { - E_ICON_SIZE_MENU, - E_ICON_SIZE_BUTTON, - E_ICON_SIZE_SMALL_TOOLBAR, - E_ICON_SIZE_LARGE_TOOLBAR, - E_ICON_SIZE_DND, - E_ICON_SIZE_DIALOG, - E_ICON_NUM_SIZES -}; - -/* standard size for list/tree widgets (16x16) */ -#define E_ICON_SIZE_LIST E_ICON_SIZE_MENU - -/* standard size for status bar icons (16x16) */ -#define E_ICON_SIZE_STATUS E_ICON_SIZE_MENU - - - -void e_icon_factory_init (void); -void e_icon_factory_shutdown (void); - -char *e_icon_factory_get_icon_filename (const char *icon_name, int icon_size); - -GdkPixbuf *e_icon_factory_get_icon (const char *icon_name, int icon_size); - -GtkWidget *e_icon_factory_get_image (const char *icon_name, int icon_size); - -GList *e_icon_factory_get_icon_list (const char *icon_name); - -#endif /* _E_ICON_FACTORY_H_ */ diff --git a/e-util/e-import.c b/e-util/e-import.c deleted file mode 100644 index 717805203e..0000000000 --- a/e-util/e-import.c +++ /dev/null @@ -1,639 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2005 Novell Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_IMPORT_H -#include <import.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include <gtk/gtknotebook.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtktable.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkalignment.h> - -#include <libgnomeui/gnome-druid.h> -#include <libgnomeui/gnome-druid-page-standard.h> -#include <libgnomeui/gnome-druid-page-edge.h> - -#include "e-import.h" - -#include <e-util/e-icon-factory.h> - -#include <libgnome/gnome-i18n.h> - -#define d(x) - -#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, e_import_get_type())) - -struct _EImportImporters { - struct _EImportImporters *next, *prev; - - EImportImporter *importer; - EImportImporterFunc free; - void *data; -}; - -struct _EImportPrivate { - int dummy; -}; - -static GObjectClass *ep_parent; - -static void -ep_init(GObject *o) -{ - /*EImport *emp = (EImport *)o;*/ - struct _EImportPrivate *p; - - p = _PRIVATE(o); -} - -static void -ep_finalise(GObject *o) -{ - EImport *emp = (EImport *)o; - struct _EImportPrivate *p; - - p = _PRIVATE(emp); - - d(printf("finalising EImport %p\n", o)); - - g_free(emp->id); - - ((GObjectClass *)ep_parent)->finalize(o); -} - -static void -ec_target_free(EImport *ep, EImportTarget *t) -{ - switch (t->type) { - case E_IMPORT_TARGET_URI: { - EImportTargetURI *s = (EImportTargetURI *)t; - - g_free(s->uri_src); - g_free(s->uri_dest); - break; } - case E_IMPORT_TARGET_HOME: { - EImportTargetHome *s = (EImportTargetHome *)t; - - g_free(s->homedir); - break; } - } - - g_free(t); - g_object_unref(ep); -} - -static void -ec_set_target(EImport *emp, EImportTarget *target) -{ - EImportClass *k = (EImportClass *)G_OBJECT_GET_CLASS(emp); - struct _EImportImporters *ei; - - if (emp->target) - e_import_target_free(emp, target); - - emp->target = target; - emp->importer = NULL; - - if (target== NULL) - return; - - for (ei = (struct _EImportImporters *)k->importers.head; - ei->next; - ei = ei->next) { - if (ei->importer->type == target->type - && ei->importer->supported(emp, ei->importer, ei->importer->user_data)) { - emp->importer = ei->importer; - break; - } - } -} - -static void -ep_class_init(GObjectClass *klass) -{ - d(printf("EImport class init %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - g_type_class_add_private(klass, sizeof(struct _EImportPrivate)); - - klass->finalize = ep_finalise; - ((EImportClass *)klass)->set_target = ec_set_target; - ((EImportClass *)klass)->target_free = ec_target_free; -} - -static void -ep_base_init(GObjectClass *klass) -{ - e_dlist_init(&((EImportClass *)klass)->importers); -} - -/** - * e_import_get_type: - * - * Standard GObject method. Used to subclass for the concrete - * implementations. - * - * Return value: EImport type. - **/ -GType -e_import_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EImportClass), - (GBaseInitFunc)ep_base_init, NULL, - (GClassInitFunc)ep_class_init, NULL, NULL, - sizeof(EImport), 0, - (GInstanceInitFunc)ep_init - }; - ep_parent = g_type_class_ref(G_TYPE_OBJECT); - type = g_type_register_static(G_TYPE_OBJECT, "EImport", &info, 0); - } - - return type; -} - -/** - * e_import_construct: - * @ep: The instance to initialise. - * @id: The name of the instance. - * - * Used by implementing classes to initialise base parameters. - * - * Return value: @ep is returned. - **/ -EImport *e_import_construct(EImport *ep, const char *id) -{ - ep->id = g_strdup(id); - - return ep; -} - -/** - * e_import_import: - * @ei: - * @done: - * @data: - * - * Run the import function of the selected importer. Once the - * importer has finished, it MUST call the e_import_complete() - * function. This allows importers to run in synchronous or - * asynchronous mode. - * - * When complete, the @done callback will be called. - **/ -void -e_import_import(EImport *ei, EImportCompleteFunc done, void *data) -{ - g_return_if_fail(ei->importer != NULL); - g_return_if_fail(ei->target != NULL); - - ei->done = done; - ei->done_data = data; - - ei->importer->import(ei, ei->importer, ei->importer->user_data); -} - -/** - * e_import_get_widget: - * @ei: An import object on which the target has been set. - * - * Gets a widget that the importer uses to configure its - * destination. This widget should be packed into a container - * widget. - * - * Return value: NULL if the importer doesn't support/require - * a destination. - **/ -struct _GtkWidget * -e_import_get_widget(EImport *ei) -{ - g_return_val_if_fail(ei->importer != NULL, NULL); - g_return_val_if_fail(ei->target != NULL, NULL); - - return ei->importer->get_widget(ei, ei->importer, ei->importer->user_data); -} - -/** - * e_import_complete: - * @ei: - * - * Signify that an import is complete. This must be called by - * importer implementations when they are done. - **/ -void e_import_complete(EImport *ei) -{ - if (ei->done) - ei->done(ei, ei->done_data); -} - -/** - * e_import_set_target: - * @emp: An initialised EImport. - * @target: A target allocated from @emp. - * - * Sets the target object for the import window. Generally the target - * is set only once, and will supply its own "changed" signal which - * can be used to drive the modal. This is a virtual method so that - * the implementing class can connect to the changed signal and - * initiate a e_import_target_changed() call where appropriate. - **/ -void -e_import_set_target(EImport *emp, EImportTarget *target) -{ - if (emp->target != target) - ((EImportClass *)G_OBJECT_GET_CLASS(emp))->set_target(emp, target); -} - -/** - * e_import_get_importers: - * @emp: - * @target: - * - * Get a list of importers. If @target is supplied, then only - * importers which support the location specified by the target are - * listed. If @target is NULL, then all importers are listed. - * - * Return value: A list of importers. The list should be freed when - * no longer needed. - **/ -GSList * -e_import_get_importers(EImport *emp, EImportTarget *target) -{ - EImportClass *k = (EImportClass *)G_OBJECT_GET_CLASS(emp); - struct _EImportImporters *ei; - GSList *importers = NULL; - - for (ei = (struct _EImportImporters *)k->importers.head; - ei->next; - ei = ei->next) { - if (target == NULL - || (ei->importer->type == target->type - && ei->importer->supported(emp, ei->importer, ei->importer->user_data))) { - importers = g_slist_append(importers, ei->importer); - break; - } - } - - return importers; -} - -/* ********************************************************************** */ - -/** - * e_import_class_add_importer: - * @ec: An initialised implementing instance of EImport. - * @importer: Importer to add. - * @freefunc: If supplied, called to free the importer node - * when it is no longer needed. - * @data: Data for the callback. - * - **/ -void -e_import_class_add_importer(EImportClass *klass, EImportImporter *importer, EImportImporterFunc freefunc, void *data) -{ - struct _EImportImporters *node, *ei, *en; - - node = g_malloc(sizeof(*node)); - node->importer = importer; - node->free = freefunc; - node->data = data; - ei = (struct _EImportImporters *)klass->importers.head; - en = ei->next; - while (en && ei->importer->pri < importer->pri) { - ei = en; - en = en->next; - } - - node->next = ei->next; - node->next->prev = node; - node->prev = ei; - ei->next = node; -} - -void e_import_class_remove_importer(EImportClass *klass, EImportImporter *f) -{ - struct _EImportImporters *ei, *en; - - ei = (struct _EImportImporters *)klass->importers.head; - en = ei->next; - while (en) { - if (ei->importer == f) { - e_dlist_remove((EDListNode *)ei); - if (ei->free) - ei->free(f, ei->data); - g_free(ei); - } - ei = en; - en = en->next; - } -} - -/** - * e_import_target_new: - * @ep: Parent EImport object. - * @type: type, up to implementor - * @size: Size of object to allocate. - * - * Allocate a new import target suitable for this class. Implementing - * classes will define the actual content of the target. - **/ -void *e_import_target_new(EImport *ep, int type, size_t size) -{ - EImportTarget *t; - - g_assert(size >= sizeof(EImportTarget)); - - t = g_malloc0(size); - t->import = ep; - g_object_ref(ep); - t->type = type; - - return t; -} - -/** - * e_import_target_free: - * @ep: Parent EImport object. - * @o: The target to fre. - * - * Free a target. The implementing class can override this method to - * free custom targets. - **/ -void -e_import_target_free(EImport *ep, void *o) -{ - EImportTarget *t = o; - - ((EImportClass *)G_OBJECT_GET_CLASS(ep))->target_free(ep, t); -} - -EImportTargetURI *e_import_target_new_uri(EImport *ei, const char *suri, const char *duri) -{ - EImportTargetURI *t = e_import_target_new(ei, E_IMPORT_TARGET_URI, sizeof(*t)); - - t->uri_src = g_strdup(suri); - t->uri_dest = g_strdup(duri); - - return t; -} - -EImportTargetHome *e_import_target_new_home(EImport *ei, const char *home) -{ - EImportTargetHome *t = e_import_target_new(ei, E_IMPORT_TARGET_HOME, sizeof(*t)); - - t->homedir = g_strdup(home); - - return t; -} - -/* ********************************************************************** */ - -/* Import menu plugin handler */ - -/* -<e-plugin - class="org.gnome.mail.plugin.import:1.0" - id="org.gnome.mail.plugin.import.item:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelimap.so" - name="imap" - description="IMAP4 and IMAP4v1 mail store"> - <hook class="org.gnome.mail.importMenu:1.0" - handler="HandleImport"> - <menu id="any" target="select"> - <item - type="item|toggle|radio|image|submenu|bar" - active - path="foo/bar" - label="label" - icon="foo" - activate="ep_view_emacs"/> - </menu> - </extension> - -*/ - -static void *emph_parent_class; -#define emph ((EImportHook *)eph) - -static const EImportHookTargetMask eih_no_masks[] = { - { 0 } -}; - -static const EImportHookTargetMap eih_targets[] = { - { "uri", E_IMPORT_TARGET_URI, eih_no_masks }, - { "home", E_IMPORT_TARGET_URI, eih_no_masks }, - { 0 } -}; - -static gboolean eih_supported(EImport *ei, EImportImporter *im, void *data) -{ - struct _EImportHookImporter *ihook = (EImportHookImporter *)im; - EImportHook *hook = im->user_data; - - return e_plugin_invoke(hook->hook.plugin, ihook->supported, ei) != NULL; -} - -static struct _GtkWidget *eih_get_widget(EImport *ei, EImportImporter *im, void *data) -{ - struct _EImportHookImporter *ihook = (EImportHookImporter *)im; - EImportHook *hook = im->user_data; - - return e_plugin_invoke(hook->hook.plugin, ihook->get_widget, ei); -} - -static void eih_import(EImport *ei, EImportImporter *im, void *data) -{ - struct _EImportHookImporter *ihook = (EImportHookImporter *)im; - EImportHook *hook = im->user_data; - - e_plugin_invoke(hook->hook.plugin, ihook->import, ei); -} - -static void -eih_free_importer(EImportImporter *im, void *data) -{ - EImportHookImporter *ihook = (EImportHookImporter *)im; - - g_free(ihook->supported); - g_free(ihook->get_widget); - g_free(ihook->import); - g_free(ihook); -} - -static struct _EImportHookImporter * -emph_construct_importer(EPluginHook *eph, xmlNodePtr root) -{ - struct _EImportHookImporter *item; - EImportHookTargetMap *map; - EImportHookClass *klass = (EImportHookClass *)G_OBJECT_GET_CLASS(eph); - char *tmp; - - d(printf(" loading import item\n")); - item = g_malloc0(sizeof(*item)); - - tmp = xmlGetProp(root, "target"); - if (tmp == NULL) - goto error; - map = g_hash_table_lookup(klass->target_map, tmp); - xmlFree(tmp); - if (map == NULL) - goto error; - - item->importer.type = map->id; - item->supported = e_plugin_xml_prop(root, "supported"); - item->get_widget = e_plugin_xml_prop(root, "get-widget"); - item->import = e_plugin_xml_prop(root, "import"); - - item->importer.name = e_plugin_xml_prop(root, "name"); - item->importer.description = e_plugin_xml_prop(root, "description"); - - item->importer.user_data = eph; - - if (item->import == NULL || item->supported == NULL) - goto error; - - item->importer.supported = eih_supported; - item->importer.import = eih_import; - if (item->get_widget) - item->importer.get_widget = eih_get_widget; - - return item; -error: - d(printf("error!\n")); - eih_free_importer((EImportImporter *)item, NULL); - return NULL; -} - -static int -emph_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) -{ - xmlNodePtr node; - EImportClass *klass; - - d(printf("loading import hook\n")); - - if (((EPluginHookClass *)emph_parent_class)->construct(eph, ep, root) == -1) - return -1; - - klass = ((EImportHookClass *)G_OBJECT_GET_CLASS(eph))->import_class; - - node = root->children; - while (node) { - if (strcmp(node->name, "importer") == 0) { - struct _EImportHookImporter *ihook; - - ihook = emph_construct_importer(eph, node); - if (ihook) { - e_import_class_add_importer(klass, &ihook->importer, eih_free_importer, eph); - emph->importers = g_slist_append(emph->importers, ihook); - } - } - node = node->next; - } - - eph->plugin = ep; - - return 0; -} - -static void -emph_finalise(GObject *o) -{ - /*EPluginHook *eph = (EPluginHook *)o;*/ - - /* free importers? */ - - ((GObjectClass *)emph_parent_class)->finalize(o); -} - -static void -emph_class_init(EPluginHookClass *klass) -{ - int i; - - ((GObjectClass *)klass)->finalize = emph_finalise; - klass->construct = emph_construct; - - /* this is actually an abstract implementation but list it anyway */ - klass->id = "org.gnome.evolution.import:1.0"; - - d(printf("EImportHook: init class %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - ((EImportHookClass *)klass)->target_map = g_hash_table_new(g_str_hash, g_str_equal); - ((EImportHookClass *)klass)->import_class = g_type_class_ref(e_import_get_type()); - - for (i=0;eih_targets[i].type;i++) - e_import_hook_class_add_target_map((EImportHookClass *)klass, &eih_targets[i]); -} - -/** - * e_import_hook_get_type: - * - * Standard GObject function to get the object type. - * - * Return value: The EImportHook class type. - **/ -GType -e_import_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EImportHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL, - sizeof(EImportHook), 0, (GInstanceInitFunc) NULL, - }; - - emph_parent_class = g_type_class_ref(e_plugin_hook_get_type()); - type = g_type_register_static(e_plugin_hook_get_type(), "EImportHook", &info, 0); - } - - return type; -} - -/** - * e_import_hook_class_add_target_map: - * - * @klass: The dervied EimportHook class. - * @map: A map used to describe a single EImportTarget type for this - * class. - * - * Add a targe tmap to a concrete derived class of EImport. The - * target map enumates the target types available for the implenting - * class. - **/ -void e_import_hook_class_add_target_map(EImportHookClass *klass, const EImportHookTargetMap *map) -{ - g_hash_table_insert(klass->target_map, (void *)map->type, (void *)map); -} diff --git a/e-util/e-import.h b/e-util/e-import.h deleted file mode 100644 index e5bf9b393a..0000000000 --- a/e-util/e-import.h +++ /dev/null @@ -1,262 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michel Zucchi <notzed@ximian.com> - * - * Copyright 2003 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __E_IMPORT_H__ -#define __E_IMPORT_H__ - -#include <glib-object.h> -#include "libedataserver/e-msgport.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -struct _GtkWindow; -struct _GtkWidget; - -/* This is an importer function */ - -typedef struct _EImport EImport; -typedef struct _EImportClass EImportClass; - -typedef struct _EImportImporter EImportImporter; -typedef struct _EImportFactory EImportFactory; -typedef struct _EImportTarget EImportTarget; - -typedef void (*EImportCompleteFunc)(EImport *ei, void *data); - -typedef void (*EImportFactoryFunc)(EImport *ei, void *data); -typedef void (*EImportImporterFunc)(EImportImporter *importer, void *data); -typedef gboolean (*EImportSupportedFunc)(EImport *ei, EImportImporter *im, void *data); -typedef struct _GtkWidget *(*EImportWidgetFunc)(EImport *ei, EImportImporter *im, void *data); -typedef void (*EImportImportFunc)(EImport *ei, EImportImporter *im, void *data); - -/* The global target types, implementors may add additional ones */ -enum _e_import_target_t { - E_IMPORT_TARGET_URI, /* simple file */ - E_IMPORT_TARGET_HOME, /* a home-directory thing, i.e. old applications */ - E_IMPORT_TARGET_LAST = 256 -}; - -/** - * struct _EImportImporter - - * - * @type: target type - * @priority: Priority of importer. Higher values will be processed first. - * @supported: Callback to see if this target is supported by the importer. - * @get_widget: A widget factory for this importer, if it needs any extra information in the druid. It will update the target. - * @import: Run the import. - * @user_data: User data for the callbacks; - * - * Base importer description. - **/ -struct _EImportImporter { - enum _e_import_target_t type; - - int pri; - - EImportSupportedFunc supported; - EImportWidgetFunc get_widget; - EImportImportFunc import; - - void *user_data; - - /* ?? */ - char *name; - char *description; -}; - -/** - * struct _EImportTarget - importation context. - * - * @import: The parent object. - * @type: The type of target, defined by implementing classes. - * - * The base target object is used as the parent and placeholder for - * import context for a given importer. - **/ -struct _EImportTarget { - struct _EImport *import; - - guint32 type; - - /* implementation fields follow, depends on target type */ -}; - -typedef struct _EImportTargetURI EImportTargetURI; -typedef struct _EImportTargetHome EImportTargetHome; - -struct _EImportTargetURI { - struct _EImportTarget target; - - char *uri_src; - char *uri_dest; -}; - -struct _EImportTargetHome { - struct _EImportTarget target; - - char *homedir; -}; - -/** - * struct _EImport - An importer management object. - * - * @object: Superclass. - * @id: ID of importer. - * @target: The current target. - * @importer: The chosen importer for the target. - * - **/ -struct _EImport { - GObject object; - - char *id; - - EImportTarget *target; - EImportImporter *importer; - - EImportCompleteFunc done; - void *done_data; -}; - -/** - * struct _EImportClass - Importer manager abstract class. - * - * @object_class: Superclass. - * @factories: A list of factories registered on this type of - * importuration manager. - * @set_target: A virtual method used to set the target on the - * importuration manager. This is used by subclasses so they may hook - * into changes on the target to propery drive the manager. - * @target_free: A virtual method used to free the target in an - * implementation-defined way. - * - **/ -struct _EImportClass { - GObjectClass object_class; - - EDList importers; - - void (*set_target)(EImport *ep, EImportTarget *t); - void (*target_free)(EImport *ep, EImportTarget *t); -}; - -GType e_import_get_type(void); - -/* Static class methods */ -void e_import_class_add_importer(EImportClass *klass, EImportImporter *importer, EImportImporterFunc freefunc, void *data); -void e_import_class_remove_importer(EImportClass *klass, EImportImporter *f); - -GSList *e_import_get_importers(EImport *emp, EImportTarget *target); - -EImport *e_import_construct(EImport *, const char *id); -void e_import_import(EImport *ei, EImportCompleteFunc done, void *data); - -struct _GtkWidget *e_import_get_widget(EImport *ei); - -void e_import_set_target(EImport *emp, EImportTarget *target); -struct _GtkWidget *e_import_create_window(EImport *emp, struct _GtkWindow *parent, const char *title); -void e_import_complete(EImport *); - -void *e_import_target_new(EImport *ep, int type, size_t size); -void e_import_target_free(EImport *ep, void *o); - -EImportTargetURI *e_import_target_new_uri(EImport *ei, const char *suri, const char *duri); -EImportTargetHome *e_import_target_new_home(EImport *ei, const char *home); - -/* ********************************************************************** */ - -/* import plugin target, they are closely integrated */ - -/* To implement a basic import plugin, you just need to subclass - this and initialise the class target type tables */ - -#include "e-util/e-plugin.h" - -typedef struct _EPluginHookTargetMap EImportHookTargetMap; -typedef struct _EPluginHookTargetKey EImportHookTargetMask; - -typedef struct _EImportHook EImportHook; -typedef struct _EImportHookClass EImportHookClass; - -typedef struct _EImportHookImporter EImportHookImporter; - -struct _EImportHookImporter { - EImportImporter importer; - - /* user_data == EImportHook */ - - char *supported; - char *get_widget; - char *import; -}; - -/** - * struct _EImportHook - Plugin hook for importuration windows. - * - * @hook: Superclass. - * @groups: A list of EImportHookGroup's of all importuration windows - * this plugin hooks into. - * - **/ -struct _EImportHook { - EPluginHook hook; - - GSList *importers; -}; - -/** - * struct _EImportHookClass - Abstract class for importuration window - * plugin hooks. - * - * @hook_class: Superclass. - * @target_map: A table of EImportHookTargetMap structures describing - * the possible target types supported by this class. - * @import_class: The EImport derived class that this hook - * implementation drives. - * - * This is an abstract class defining the plugin hook point for - * importuration windows. - * - **/ -struct _EImportHookClass { - EPluginHookClass hook_class; - - /* EImportHookTargetMap by .type */ - GHashTable *target_map; - /* the import class these imports's belong to */ - EImportClass *import_class; -}; - -GType e_import_hook_get_type(void); - -/* for implementors */ -void e_import_hook_class_add_target_map(EImportHookClass *klass, const EImportHookTargetMap *); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_IMPORT_H__ */ diff --git a/e-util/e-iterator.c b/e-util/e-iterator.c deleted file mode 100644 index aa7a338eff..0000000000 --- a/e-util/e-iterator.c +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Christopher James Lahey <clahey@umich.edu> - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#include <config.h> - -#include "e-iterator.h" -#include "e-util-marshal.h" - -static void e_iterator_init (EIterator *card); -static void e_iterator_class_init (EIteratorClass *klass); - -#define PARENT_TYPE G_TYPE_OBJECT - -static GObjectClass *parent_class; - -enum { - INVALIDATE, - LAST_SIGNAL -}; - -static guint e_iterator_signals [LAST_SIGNAL] = { 0, }; - -/** - * e_iterator_get_type: - * @void: - * - * Registers the &EIterator class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &EIterator class. - **/ -GType -e_iterator_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (EIteratorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) e_iterator_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EIterator), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_iterator_init - }; - - type = g_type_register_static (PARENT_TYPE, "EIterator", &info, 0); - } - - return type; -} - -static void -e_iterator_class_init (EIteratorClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS(klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - e_iterator_signals [INVALIDATE] = - g_signal_new ("invalidate", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EIteratorClass, invalidate), - NULL, NULL, - e_util_marshal_NONE__NONE, /* XXX need a new marshaller here */ - G_TYPE_NONE, 0); - - klass->invalidate = NULL; - klass->get = NULL; - klass->reset = NULL; - klass->last = NULL; - klass->next = NULL; - klass->prev = NULL; - klass->remove = NULL; - klass->insert = NULL; - klass->set = NULL; - klass->is_valid = NULL; -} - -/** - * e_iterator_init: - */ -static void -e_iterator_init (EIterator *card) -{ -} - -/* - * Virtual functions: - */ -const void * -e_iterator_get (EIterator *iterator) -{ - if (E_ITERATOR_GET_CLASS(iterator)->get) - return E_ITERATOR_GET_CLASS(iterator)->get(iterator); - else - return NULL; -} - -void -e_iterator_reset (EIterator *iterator) -{ - if (E_ITERATOR_GET_CLASS(iterator)->reset) - E_ITERATOR_GET_CLASS(iterator)->reset(iterator); -} - -void -e_iterator_last (EIterator *iterator) -{ - if (E_ITERATOR_GET_CLASS(iterator)->last) - E_ITERATOR_GET_CLASS(iterator)->last(iterator); -} - -gboolean -e_iterator_next (EIterator *iterator) -{ - if (E_ITERATOR_GET_CLASS(iterator)->next) - return E_ITERATOR_GET_CLASS(iterator)->next(iterator); - else - return FALSE; -} - -gboolean -e_iterator_prev (EIterator *iterator) -{ - if (E_ITERATOR_GET_CLASS(iterator)->prev) - return E_ITERATOR_GET_CLASS(iterator)->prev(iterator); - else - return FALSE; -} - -void -e_iterator_delete (EIterator *iterator) -{ - if (E_ITERATOR_GET_CLASS(iterator)->remove) - E_ITERATOR_GET_CLASS(iterator)->remove(iterator); -} - -void e_iterator_insert (EIterator *iterator, - const void *object, - gboolean before) -{ - if (E_ITERATOR_GET_CLASS(iterator)->insert) - E_ITERATOR_GET_CLASS(iterator)->insert(iterator, object, before); -} - -void -e_iterator_set (EIterator *iterator, - const void *object) -{ - if (E_ITERATOR_GET_CLASS(iterator)->set) - E_ITERATOR_GET_CLASS(iterator)->set(iterator, object); -} - -gboolean -e_iterator_is_valid (EIterator *iterator) -{ - if (E_ITERATOR_GET_CLASS(iterator)->is_valid) - return E_ITERATOR_GET_CLASS(iterator)->is_valid(iterator); - else - return FALSE; -} - -void -e_iterator_invalidate (EIterator *iterator) -{ - g_return_if_fail (iterator != NULL); - g_return_if_fail (E_IS_ITERATOR (iterator)); - - g_signal_emit (iterator, e_iterator_signals [INVALIDATE], 0); -} diff --git a/e-util/e-iterator.h b/e-util/e-iterator.h deleted file mode 100644 index da25bd8ab6..0000000000 --- a/e-util/e-iterator.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#ifndef __E_ITERATOR_H__ -#define __E_ITERATOR_H__ - -#include <stdio.h> -#include <time.h> -#include <glib.h> -#include <glib-object.h> - -#define E_TYPE_ITERATOR (e_iterator_get_type ()) -#define E_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_ITERATOR, EIterator)) -#define E_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_ITERATOR, EIteratorClass)) -#define E_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_ITERATOR)) -#define E_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_ITERATOR)) -#define E_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_ITERATOR, EIteratorClass)) - -typedef struct _EIterator EIterator; -typedef struct _EIteratorClass EIteratorClass; - -struct _EIterator { - GObject object; -}; - -struct _EIteratorClass { - GObjectClass parent_class; - - /* Signals */ - void (*invalidate) (EIterator *iterator); - - /* Virtual functions */ - const void * (*get) (EIterator *iterator); - void (*reset) (EIterator *iterator); - void (*last) (EIterator *iterator); - gboolean (*next) (EIterator *iterator); - gboolean (*prev) (EIterator *iterator); - void (*remove) (EIterator *iterator); - void (*insert) (EIterator *iterator, - const void *object, - gboolean before); - void (*set) (EIterator *iterator, - const void *object); - gboolean (*is_valid) (EIterator *iterator); -}; - -const void *e_iterator_get (EIterator *iterator); -void e_iterator_reset (EIterator *iterator); -void e_iterator_last (EIterator *iterator); -gboolean e_iterator_next (EIterator *iterator); -gboolean e_iterator_prev (EIterator *iterator); -void e_iterator_delete (EIterator *iterator); -void e_iterator_insert (EIterator *iterator, - const void *object, - gboolean before); -void e_iterator_set (EIterator *iterator, - const void *object); -gboolean e_iterator_is_valid (EIterator *iterator); - -void e_iterator_invalidate (EIterator *iterator); - -/* Standard Glib function */ -GType e_iterator_get_type (void); - -#endif /* ! __E_ITERATOR_H__ */ diff --git a/e-util/e-list-iterator.c b/e-util/e-list-iterator.c deleted file mode 100644 index 2f7e2aa953..0000000000 --- a/e-util/e-list-iterator.c +++ /dev/null @@ -1,249 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Christopher James Lahey <clahey@umich.edu> - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#include <config.h> - -#include "e-list-iterator.h" -#include "e-list.h" - - -static void e_list_iterator_init (EListIterator *list); -static void e_list_iterator_class_init (EListIteratorClass *klass); - -static void e_list_iterator_invalidate (EIterator *iterator); -static gboolean e_list_iterator_is_valid (EIterator *iterator); -static void e_list_iterator_set (EIterator *iterator, - const void *object); -static void e_list_iterator_remove (EIterator *iterator); -static void e_list_iterator_insert (EIterator *iterator, - const void *object, - gboolean before); -static gboolean e_list_iterator_prev (EIterator *iterator); -static gboolean e_list_iterator_next (EIterator *iterator); -static void e_list_iterator_reset (EIterator *iterator); -static void e_list_iterator_last (EIterator *iterator); -static const void *e_list_iterator_get (EIterator *iterator); -static void e_list_iterator_dispose (GObject *object); - -#define PARENT_TYPE E_TYPE_ITERATOR - -static EIteratorClass *parent_class; - -/** - * e_list_iterator_get_type: - * @void: - * - * Registers the &EListIterator class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &EListIterator class. - **/ -GType -e_list_iterator_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (EListIteratorClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) e_list_iterator_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EListIterator), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_list_iterator_init - }; - - type = g_type_register_static (PARENT_TYPE, "EListIterator", &info, 0); - } - - return type; -} - -static void -e_list_iterator_class_init (EListIteratorClass *klass) -{ - GObjectClass *object_class; - EIteratorClass *iterator_class; - - object_class = G_OBJECT_CLASS(klass); - iterator_class = E_ITERATOR_CLASS(klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = e_list_iterator_dispose; - - iterator_class->invalidate = e_list_iterator_invalidate; - iterator_class->get = e_list_iterator_get; - iterator_class->reset = e_list_iterator_reset; - iterator_class->last = e_list_iterator_last; - iterator_class->next = e_list_iterator_next; - iterator_class->prev = e_list_iterator_prev; - iterator_class->remove = e_list_iterator_remove; - iterator_class->insert = e_list_iterator_insert; - iterator_class->set = e_list_iterator_set; - iterator_class->is_valid = e_list_iterator_is_valid; -} - - - -/** - * e_list_iterator_init: - */ -static void -e_list_iterator_init (EListIterator *list) -{ -} - -EIterator * -e_list_iterator_new (EList *list) -{ - EListIterator *iterator = g_object_new (E_TYPE_LIST_ITERATOR, NULL); - - iterator->list = list; - g_object_ref(list); - iterator->iterator = list->list; - - return E_ITERATOR(iterator); -} - -/* - * Virtual functions: - */ -static void -e_list_iterator_dispose (GObject *object) -{ - EListIterator *iterator = E_LIST_ITERATOR(object); - e_list_remove_iterator(iterator->list, E_ITERATOR(iterator)); - g_object_unref(iterator->list); - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static const void * -e_list_iterator_get (EIterator *_iterator) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - if (iterator->iterator) - return iterator->iterator->data; - else - return NULL; -} - -static void -e_list_iterator_reset (EIterator *_iterator) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - iterator->iterator = iterator->list->list; -} - -static void -e_list_iterator_last (EIterator *_iterator) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - iterator->iterator = g_list_last(iterator->list->list); -} - -static gboolean -e_list_iterator_next (EIterator *_iterator) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - if (iterator->iterator) - iterator->iterator = g_list_next(iterator->iterator); - else - iterator->iterator = iterator->list->list; - return (iterator->iterator != NULL); -} - -static gboolean -e_list_iterator_prev (EIterator *_iterator) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - if (iterator->iterator) - iterator->iterator = g_list_previous(iterator->iterator); - else - iterator->iterator = g_list_last(iterator->list->list); - return (iterator->iterator != NULL); -} - -static void -e_list_iterator_insert (EIterator *_iterator, - const void *object, - gboolean before) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - void *data; - if (iterator->list->copy) - data = iterator->list->copy(object, iterator->list->closure); - else - data = (void *) object; - if (iterator->iterator) { - if (before) { - iterator->list->list = g_list_first(g_list_prepend(iterator->iterator, data)); - iterator->iterator = iterator->iterator->prev; - } else { - if (iterator->iterator->next) - g_list_prepend(iterator->iterator->next, data); - else - g_list_append(iterator->iterator, data); - iterator->iterator = iterator->iterator->next; - } - e_list_invalidate_iterators(iterator->list, E_ITERATOR(iterator)); - } else { - if (before) { - iterator->list->list = g_list_append(iterator->list->list, data); - iterator->iterator = g_list_last(iterator->list->list); - } else { - iterator->list->list = g_list_prepend(iterator->list->list, data); - iterator->iterator = iterator->list->list; - } - e_list_invalidate_iterators(iterator->list, E_ITERATOR(iterator)); - } -} - -static void -e_list_iterator_remove (EIterator *_iterator) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - if (iterator->iterator) { - e_list_remove_link (iterator->list, iterator->iterator); - } -} - -static void -e_list_iterator_set (EIterator *_iterator, - const void *object) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - if (iterator->iterator) { - if (iterator->list->free) - iterator->list->free(iterator->iterator->data, iterator->list->closure); - if (iterator->list->copy) - iterator->iterator->data = iterator->list->copy(object, iterator->list->closure); - else - iterator->iterator->data = (void *) object; - } -} - -static gboolean -e_list_iterator_is_valid (EIterator *_iterator) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - return iterator->iterator != NULL; -} - -static void -e_list_iterator_invalidate (EIterator *_iterator) -{ - EListIterator *iterator = E_LIST_ITERATOR(_iterator); - iterator->iterator = NULL; -} diff --git a/e-util/e-list-iterator.h b/e-util/e-list-iterator.h deleted file mode 100644 index b3a8953d80..0000000000 --- a/e-util/e-list-iterator.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#ifndef __E_LIST_ITERATOR_H__ -#define __E_LIST_ITERATOR_H__ - -typedef struct _EListIterator EListIterator; -typedef struct _EListIteratorClass EListIteratorClass; - -#include <stdio.h> -#include <time.h> -#include <glib.h> -#include <glib-object.h> - -#include <e-util/e-iterator.h> -#include <e-util/e-list.h> - -#define E_TYPE_LIST_ITERATOR (e_list_iterator_get_type ()) -#define E_LIST_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_LIST_ITERATOR, EListIterator)) -#define E_LIST_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_LIST_ITERATOR, EListIteratorClass)) -#define E_IS_LIST_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_LIST_ITERATOR)) -#define E_IS_LIST_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_LIST_ITERATOR)) - -struct _EListIterator { - EIterator parent; - - EList *list; - GList *iterator; -}; - -struct _EListIteratorClass { - EIteratorClass parent_class; -}; - -EIterator *e_list_iterator_new (EList *list); - -/* Standard Glib function */ -GType e_list_iterator_get_type (void); - -#endif /* ! __E_LIST_ITERATOR_H__ */ diff --git a/e-util/e-list.c b/e-util/e-list.c deleted file mode 100644 index f1b190b16a..0000000000 --- a/e-util/e-list.c +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Christopher James Lahey <clahey@umich.edu> - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#include <config.h> - -#include "e-list.h" -#include "e-list-iterator.h" - -static void e_list_init (EList *list); -static void e_list_class_init (EListClass *klass); -static void e_list_dispose (GObject *object); - -static GObjectClass *parent_class; - -/** - * e_list_get_type: - * @void: - * - * Registers the &EList class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &EList class. - **/ -GType -e_list_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (EListClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) e_list_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EList), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_list_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, "EList", &info, 0); - } - - return type; -} - -static void -e_list_class_init (EListClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS(klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - object_class->dispose = e_list_dispose; -} - -/** - * e_list_init: - */ -static void -e_list_init (EList *list) -{ - list->list = NULL; - list->iterators = NULL; -} - -EList * -e_list_new (EListCopyFunc copy, EListFreeFunc free, void *closure) -{ - EList *list = g_object_new (E_TYPE_LIST, NULL); - e_list_construct (list, copy, free, closure); - return list; -} - -void -e_list_construct (EList *list, EListCopyFunc copy, EListFreeFunc free, void *closure) -{ - list->copy = copy; - list->free = free; - list->closure = closure; -} - -EList * -e_list_duplicate (EList *old) -{ - EList *list = g_object_new (E_TYPE_LIST, NULL); - - list->copy = old->copy; - list->free = old->free; - list->closure = old->closure; - list->list = g_list_copy(old->list); - if (list->copy) { - GList *listlist; - for (listlist = list->list; listlist; listlist = listlist->next) { - listlist->data = list->copy (listlist->data, list->closure); - } - } - return list; -} - -EIterator * -e_list_get_iterator (EList *list) -{ - EIterator *iterator = e_list_iterator_new(list); - list->iterators = g_list_append(list->iterators, iterator); - return iterator; -} - -int -e_list_length (EList *list) -{ - return g_list_length(list->list); -} - -void -e_list_append (EList *list, const void *data) -{ - e_list_invalidate_iterators(list, NULL); - if (list->copy) - list->list = g_list_append(list->list, list->copy(data, list->closure)); - else - list->list = g_list_append(list->list, (void *) data); -} - -void -e_list_remove (EList *list, const void *data) -{ - GList *link; - link = g_list_find (list->list, data); - if (link) - e_list_remove_link(list, link); -} - -void -e_list_invalidate_iterators (EList *list, EIterator *skip) -{ - GList *iterators = list->iterators; - for (; iterators; iterators = iterators->next) { - if (iterators->data != skip) { - e_iterator_invalidate(E_ITERATOR(iterators->data)); - } - } -} - -/* FIXME: This doesn't work properly if the iterator is the first - iterator in the list. Well, the iterator doesn't continue on after - the next time next is called, at least. */ -void -e_list_remove_link (EList *list, GList *link) -{ - GList *iterators = list->iterators; - for (; iterators; iterators = iterators->next) { - if (((EListIterator *)iterators->data)->iterator == link) { - e_iterator_prev(iterators->data); - } - } - if (list->free) - list->free(link->data, list->closure); - list->list = g_list_remove_link(list->list, link); - g_list_free_1(link); -} - -void -e_list_remove_iterator (EList *list, EIterator *iterator) -{ - list->iterators = g_list_remove(list->iterators, iterator); -} - -/* - * Virtual functions - */ -static void -e_list_dispose (GObject *object) -{ - EList *list = E_LIST(object); - if (list->free) - g_list_foreach(list->list, (GFunc) list->free, list->closure); - g_list_free(list->list); - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - diff --git a/e-util/e-list.h b/e-util/e-list.h deleted file mode 100644 index d249fcfa4a..0000000000 --- a/e-util/e-list.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#ifndef __E_LIST_H__ -#define __E_LIST_H__ - -typedef struct _EList EList; -typedef struct _EListClass EListClass; - -#include <stdio.h> -#include <time.h> -#include <glib.h> -#include <glib-object.h> -#include <e-util/e-list-iterator.h> - -#define E_TYPE_LIST (e_list_get_type ()) -#define E_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_LIST, EList)) -#define E_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_LIST, EListClass)) -#define E_IS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_LIST)) -#define E_IS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_LIST)) -#define E_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_LIST, EListClass)) - -typedef void *(*EListCopyFunc) (const void *data, void *closure); -typedef void (*EListFreeFunc) (void *data, void *closure); - -struct _EList { - GObject object; - GList *list; - GList *iterators; - EListCopyFunc copy; - EListFreeFunc free; - void *closure; -}; - -struct _EListClass { - GObjectClass parent_class; -}; - -EList *e_list_new (EListCopyFunc copy, - EListFreeFunc free, - void *closure); -void e_list_construct (EList *list, - EListCopyFunc copy, - EListFreeFunc free, - void *closure); -EList *e_list_duplicate (EList *list); -EIterator *e_list_get_iterator (EList *list); -void e_list_append (EList *list, - const void *data); -void e_list_remove (EList *list, - const void *data); -int e_list_length (EList *list); - -/* For iterators to call. */ -void e_list_remove_link (EList *list, - GList *link); -void e_list_remove_iterator (EList *list, - EIterator *iterator); -void e_list_invalidate_iterators (EList *list, - EIterator *skip); - -/* Standard Glib function */ -GType e_list_get_type (void); - -#endif /* ! __E_LIST_H__ */ diff --git a/e-util/e-menu.c b/e-util/e-menu.c deleted file mode 100644 index 68c1f65c5e..0000000000 --- a/e-util/e-menu.c +++ /dev/null @@ -1,910 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include "e-menu.h" - -#include <e-util/e-icon-factory.h> - -#include <libgnome/gnome-i18n.h> -#include <bonobo/bonobo-ui-util.h> - -#define d(x) - -struct _EMenuFactory { - struct _EMenuFactory *next, *prev; - - char *menuid; - EMenuFactoryFunc factory; - void *factory_data; -}; - -struct _item_node { - struct _item_node *next; - - EMenuItem *item; - struct _menu_node *menu; -}; - -struct _menu_node { - struct _menu_node *next, *prev; - - EMenu *parent; - - GSList *items; - GSList *uis; - GSList *pixmaps; - - EMenuItemsFunc freefunc; - void *data; - - /* a copy of items wrapped in an item_node, for bonobo - * callback mapping */ - struct _item_node *menu; -}; - -struct _EMenuPrivate { - EDList menus; -}; - -static GObjectClass *em_parent; - -static void -em_init(GObject *o) -{ - EMenu *emp = (EMenu *)o; - struct _EMenuPrivate *p; - - p = emp->priv = g_malloc0(sizeof(struct _EMenuPrivate)); - - e_dlist_init(&p->menus); -} - -static void -em_finalise(GObject *o) -{ - EMenu *em = (EMenu *)o; - struct _EMenuPrivate *p = em->priv; - struct _menu_node *mnode; - - if (em->target) - e_menu_target_free(em, em->target); - g_free(em->menuid); - - while ((mnode = (struct _menu_node *)e_dlist_remhead(&p->menus))) { - struct _item_node *inode; - - if (mnode->freefunc) - mnode->freefunc(em, mnode->items, mnode->uis, mnode->pixmaps, mnode->data); - - inode = mnode->menu; - while (inode) { - struct _item_node *nnode = inode->next; - - g_free(inode); - inode = nnode; - } - - g_free(mnode); - } - - g_free(p); - - ((GObjectClass *)em_parent)->finalize(o); -} - -static void -em_target_free(EMenu *ep, EMenuTarget *t) -{ - g_free(t); - /* look funny but t has a reference to us */ - g_object_unref(ep); -} - -static void -em_class_init(GObjectClass *klass) -{ - d(printf("EMenu class init %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - klass->finalize = em_finalise; - ((EMenuClass *)klass)->target_free = em_target_free; -} - -static void -em_base_init(GObjectClass *klass) -{ - /* each class instance must have its own list, it isn't inherited */ - d(printf("%p: list init\n", klass)); - e_dlist_init(&((EMenuClass *)klass)->factories); -} - -/** - * e_menu_get_type: - * - * Standard GObject type function. Used to subclass this type only. - * - * Return value: The EMenu object type. - **/ -GType -e_menu_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EMenuClass), - (GBaseInitFunc)em_base_init, NULL, - (GClassInitFunc)em_class_init, - NULL, NULL, - sizeof(EMenu), 0, - (GInstanceInitFunc)em_init - }; - em_parent = g_type_class_ref(G_TYPE_OBJECT); - type = g_type_register_static(G_TYPE_OBJECT, "EMenu", &info, 0); - } - - return type; -} - -/** - * e_menu_construct: - * @em: An instantiated but uninitislied EPopup. - * @menuid: The unique identifier for this menu. - * - * Construct the base menu instance based on the parameters. - * - * Return value: Returns @em. - **/ -EMenu *e_menu_construct(EMenu *em, const char *menuid) -{ - struct _EMenuFactory *f; - EMenuClass *klass; - - d(printf("constructing menu '%s'\n", menuid)); - - klass = (EMenuClass *)G_OBJECT_GET_CLASS(em); - - d(printf(" class is %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - em->menuid = g_strdup(menuid); - - /* setup the menu itself based on factories */ - f = (struct _EMenuFactory *)klass->factories.head; - if (f->next == NULL) { - d(printf("%p no factories registered on menu\n", klass)); - } - - while (f->next) { - if (f->menuid == NULL - || !strcmp(f->menuid, em->menuid)) { - d(printf(" calling factory\n")); - f->factory(em, f->factory_data); - } - f = f->next; - } - - return em; -} - -/** - * e_menu_add_items: - * @emp: An initialised EMenu. - * @items: A list of EMenuItems or derived structures defining a group - * of menu items for this menu. - * @uifiles: A list of EMenuUIFile objects describing all ui files - * associated with the items. - * @pixmaps: A list of EMenuPixmap objects describing all pixmaps - * associated with the menus. - * @freefunc: If supplied, called when the menu items are no longer needed. - * @data: user-data passed to @freefunc and activate callbacks. - * - * Add new EMenuItems to the menu's. This may be called any number of - * times before the menu is first activated to hook onto any of the - * menu items defined for that view. - * - * Return value: A handle that can be passed to remove_items as required. - **/ -void * -e_menu_add_items(EMenu *emp, GSList *items, GSList *uifiles, GSList *pixmaps, EMenuItemsFunc freefunc, void *data) -{ - struct _menu_node *node; - GSList *l; - - node = g_malloc0(sizeof(*node)); - node->parent = emp; - node->items = items; - node->uis = uifiles; - node->pixmaps = pixmaps; - node->freefunc = freefunc; - node->data = data; - - for (l=items;l;l=g_slist_next(l)) { - struct _item_node *inode = g_malloc0(sizeof(*inode)); - EMenuItem *item = l->data; - - inode->item = item; - inode->menu = node; - inode->next = node->menu; - node->menu = inode; - } - - for (l=pixmaps;l;l=g_slist_next(l)) { - EMenuPixmap *pixmap = l->data; - - if (pixmap->pixmap == NULL) { - GdkPixbuf *pixbuf; - - pixbuf = e_icon_factory_get_icon(pixmap->name, pixmap->size); - if (pixbuf == NULL) { - g_warning("Unable to load icon '%s'", pixmap->name); - } else { - pixmap->pixmap = bonobo_ui_util_pixbuf_to_xml(pixbuf); - g_object_unref(pixbuf); - } - } - } - - e_dlist_addtail(&emp->priv->menus, (EDListNode *)node); - - /* FIXME: add the menu's to a running menu if it is there? */ - - return (void *)node; -} - -/** - * e_menu_remove_items: - * @emp: - * @handle: - * - * Remove menu items previously added. - **/ -void -e_menu_remove_items(EMenu *emp, void *handle) -{ - struct _menu_node *node = handle; - struct _item_node *inode; - GSList *l; - - e_dlist_remove((EDListNode *)node); - - if (emp->uic) { - for (l = node->items;l;l=g_slist_next(l)) { - EMenuItem *item = l->data; - - bonobo_ui_component_remove_verb(emp->uic, item->verb); - } - } - - if (node->freefunc) - node->freefunc(emp, node->items, node->uis, node->pixmaps, node->data); - - inode = node->menu; - while (inode) { - struct _item_node *nnode = inode->next; - - g_free(inode); - inode = nnode; - } - - g_free(node); -} - -static void -em_activate_toggle(BonoboUIComponent *component, const char *path, Bonobo_UIComponent_EventType type, const char *state, void *data) -{ - struct _item_node *inode = data; - - if (type != Bonobo_UIComponent_STATE_CHANGED) - return; - - ((EMenuToggleActivateFunc)inode->item->activate)(inode->menu->parent, inode->item, state[0] != '0', inode->menu->data); -} - -static void -em_activate(BonoboUIComponent *uic, void *data, const char *cname) -{ - struct _item_node *inode = data; - - ((EMenuActivateFunc)inode->item->activate)(inode->menu->parent, inode->item, inode->menu->data); -} - -/** - * e_menu_activate: - * @em: An initialised EMenu. - * @uic: The BonoboUI component for this views menu's. - * @act: If %TRUE, then the control is being activated. - * - * This is called by the owner of the component, control, or view to - * pass on the activate or deactivate control signals. If the view is - * being activated then the callbacks and menu items are setup, - * otherwise they are removed. - * - * This should always be called in the strict sequence of activate, then - * deactivate, repeated any number of times. - **/ -void e_menu_activate(EMenu *em, struct _BonoboUIComponent *uic, int act) -{ - struct _EMenuPrivate *p = em->priv; - struct _menu_node *mw; - GSList *l; - - if (act) { - GArray *verbs; - int i; - - em->uic = uic; - - verbs = g_array_new(TRUE, FALSE, sizeof(BonoboUIVerb)); - for (mw = (struct _menu_node *)p->menus.head;mw->next;mw=mw->next) { - struct _item_node *inode; - - for (l = mw->uis; l ; l = g_slist_next(l)) { - EMenuUIFile *ui = l->data; - - bonobo_ui_util_set_ui(uic, ui->appdir, ui->filename, ui->appname, NULL); - } - - for (l = mw->pixmaps; l ; l = g_slist_next(l)) { - EMenuPixmap *pm = l->data; - - if (pm->pixmap) - bonobo_ui_component_set_prop(uic, pm->command, "pixmap", pm->pixmap, NULL); - } - - for (inode = mw->menu; inode; inode=inode->next) { - EMenuItem *item = inode->item; - BonoboUIVerb *verb; - - d(printf("adding menu verb '%s'\n", item->verb)); - - switch (item->type & E_MENU_TYPE_MASK) { - case E_MENU_ITEM: - i = verbs->len; - verbs = g_array_set_size(verbs, i+1); - verb = &((BonoboUIVerb *)verbs->data)[i]; - - verb->cname = item->verb; - verb->cb = em_activate; - verb->user_data = inode; - break; - case E_MENU_TOGGLE: - bonobo_ui_component_set_prop(uic, item->path, "state", item->type & E_MENU_ACTIVE?"1":"0", NULL); - bonobo_ui_component_add_listener(uic, item->verb, em_activate_toggle, inode); - break; - } - } - } - - if (verbs->len) - bonobo_ui_component_add_verb_list(uic, (BonoboUIVerb *)verbs->data); - - g_array_free(verbs, TRUE); - } else { - for (mw = (struct _menu_node *)p->menus.head;mw->next;mw=mw->next) { - for (l = mw->items;l;l=g_slist_next(l)) { - EMenuItem *item = l->data; - - bonobo_ui_component_remove_verb(uic, item->verb); - } - } - - em->uic = NULL; - } -} - -/** - * e_menu_update_target: - * @em: An initialised EMenu. - * @tp: Target, after this call the menu owns the target. - * - * Change the target for the menu. Once the target is changed, the - * sensitivity state of the menu items managed by @em is re-evaluated - * and the physical menu's updated to reflect it. - * - * This is used by the owner of the menu and view to update the menu - * system based on user input or changed system state. - **/ -void e_menu_update_target(EMenu *em, void *tp) -{ - struct _EMenuPrivate *p = em->priv; - EMenuTarget *t = tp; - guint32 mask = ~0; - struct _menu_node *mw; - GSList *l; - - if (em->target && em->target != t) - e_menu_target_free(em, em->target); - - /* if we unset the target, should we disable/hide all the menu items? */ - em->target = t; - if (t == NULL) - return; - - mask = t->mask; - - /* canna do any more capt'n */ - if (em->uic == NULL) - return; - - for (mw = (struct _menu_node *)p->menus.head;mw->next;mw=mw->next) { - for (l = mw->items;l;l=g_slist_next(l)) { - EMenuItem *item = l->data; - int state; - - d(printf("checking item '%s' mask %08x against target %08x\n", item->verb, item->enable, mask)); - - state = (item->enable & mask) == 0; - bonobo_ui_component_set_prop(em->uic, item->path, "sensitive", state?"1":"0", NULL); - /* visible? */ - } - } -} - -/* ********************************************************************** */ - -/** - * e_menu_class_add_factory: - * @klass: An EMenuClass type to which this factory applies. - * @menuid: The identifier of the menu for this factory, or NULL to be - * called on all menus. - * @func: An EMenuFactoryFunc callback. - * @data: Callback data for @func. - * - * Add a menu factory which will be called when the menu @menuid is - * created. The factory is free to add new items as it wishes to the - * menu provided in the callback. - * - * TODO: Make the menuid a pattern? - * - * Return value: A handle to the factory. - **/ -EMenuFactory * -e_menu_class_add_factory(EMenuClass *klass, const char *menuid, EMenuFactoryFunc func, void *data) -{ - struct _EMenuFactory *f = g_malloc0(sizeof(*f)); - - d(printf("%p adding factory '%s' to class '%s'\n", klass, menuid?menuid:"<all menus>", g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - f->menuid = g_strdup(menuid); - f->factory = func; - f->factory_data = data; - e_dlist_addtail(&klass->factories, (EDListNode *)f); - - /* setup the menu itself based on factories */ - { - struct _EMenuFactory *j; - - j = (struct _EMenuFactory *)klass->factories.head; - if (j->next == NULL) { - d(printf("%p no factories registered on menu???\n", klass)); - } - } - - return f; -} - -/** - * e_menu_class_remove_factory: - * @klass: Class on which the factory was originally added. - * @f: Factory handle. - * - * Remove a popup factory. This must only be called once, and must - * only be called using a valid factory handle @f. After this call, - * @f is undefined. - **/ -void -e_menu_class_remove_factory(EMenuClass *klass, EMenuFactory *f) -{ - e_dlist_remove((EDListNode *)f); - g_free(f->menuid); - g_free(f); -} - -/** - * e_menu_target_new: - * @ep: An EMenu to which this target applies. - * @type: Target type, up to implementation. - * @size: Size of memory to allocate. Must be >= sizeof(EMenuTarget). - * - * Allocate a new menu target suitable for this class. @size is used - * to specify the actual target size, which may vary depending on the - * implementing class. - **/ -void *e_menu_target_new(EMenu *ep, int type, size_t size) -{ - EMenuTarget *t; - - g_assert(size >= sizeof(EMenuTarget)); - - t = g_malloc0(size); - t->menu = ep; - g_object_ref(ep); - t->type = type; - - return t; -} - -/** - * e_menu_target_free: - * @ep: EMenu on which the target was allocated. - * @o: Tareget to free. - * - * Free a target. - **/ -void -e_menu_target_free(EMenu *ep, void *o) -{ - EMenuTarget *t = o; - - ((EMenuClass *)G_OBJECT_GET_CLASS(ep))->target_free(ep, t); -} - -/* ********************************************************************** */ - -/* Main menu plugin handler */ - -/* NB: This has significant overlap with EPopupHook */ - -/* -<e-plugin - class="org.gnome.mail.plugin.popup:1.0" - id="org.gnome.mail.plugin.popup.item:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelimap.so" - name="imap" - description="Main menu plugin"> - <hook class="org.gnome.evolution.bonobomenu:1.0"> - <menu id="any" target="select" view="org.gnome.mail"> - <ui file="ui file1"/> - <ui file="ui file2"/> - <pixmap command="command" pixmap="stockname" size="menu|button|small_toolbar|large_toolbar|dnd|dialog"/> - <item - type="item|toggle" - verb="verb" - enable="select_one" - visible="select_one" - activate="doactivate"/> - </menu> - </hook> - </extension> - -*/ - -static void *emph_parent_class; -#define emph ((EMenuHook *)eph) - -/* must have 1:1 correspondence with e-menu types in order */ -static const EPluginHookTargetKey emph_item_types[] = { - { "item", E_MENU_ITEM }, - { "toggle", E_MENU_TOGGLE }, - { "radio", E_MENU_RADIO }, - { 0 } -}; - -/* 1:1 with e-icon-factory sizes */ -static const EPluginHookTargetKey emph_pixmap_sizes[] = { - { "menu", 0 }, - { "button", 1}, - { "small_toolbar", 2}, - { "large_toolbar", 3}, - { "dnd", 4}, - { "dialog", 5}, - { 0 } -}; - -static void -emph_menu_activate(EMenu *em, EMenuItem *item, void *data) -{ - EMenuHook *hook = data; - - d(printf("invoking plugin hook '%s' %p\n", (char *)item->user_data, em->target)); - - e_plugin_invoke(hook->hook.plugin, item->user_data, em->target); -} - -static void -emph_menu_toggle_activate(EMenu *em, EMenuItem *item, int state, void *data) -{ - EMenuHook *hook = data; - - /* FIXME: where does the toggle state go? */ - d(printf("invoking plugin hook '%s' %p\n", (char *)item->user_data, em->target)); - - e_plugin_invoke(hook->hook.plugin, item->user_data, em->target); -} - -static void -emph_menu_factory(EMenu *emp, void *data) -{ - struct _EMenuHookMenu *menu = data; - - d(printf("menu factory, adding %d items\n", g_slist_length(menu->items))); - - if (menu->items) - e_menu_add_items(emp, menu->items, menu->uis, menu->pixmaps, NULL, menu->hook); -} - -static void -emph_free_item(struct _EMenuItem *item) -{ - g_free(item->path); - g_free(item->verb); - g_free(item->user_data); - g_free(item); -} - -static void -emph_free_ui(struct _EMenuUIFile *ui) -{ - g_free(ui->appdir); - g_free(ui->appname); - g_free(ui->filename); -} - -static void -emph_free_pixmap(struct _EMenuPixmap *pixmap) -{ - g_free(pixmap->command); - g_free(pixmap->name); - g_free(pixmap->pixmap); - g_free(pixmap); -} - -static void -emph_free_menu(struct _EMenuHookMenu *menu) -{ - g_slist_foreach(menu->items, (GFunc)emph_free_item, NULL); - g_slist_free(menu->items); - g_slist_foreach(menu->uis, (GFunc)emph_free_ui, NULL); - g_slist_free(menu->uis); - g_slist_foreach(menu->pixmaps, (GFunc)emph_free_pixmap, NULL); - g_slist_free(menu->pixmaps); - - g_free(menu->id); - g_free(menu); -} - -static struct _EMenuItem * -emph_construct_item(EPluginHook *eph, EMenuHookMenu *menu, xmlNodePtr root, EMenuHookTargetMap *map) -{ - struct _EMenuItem *item; - - d(printf(" loading menu item\n")); - item = g_malloc0(sizeof(*item)); - item->type = e_plugin_hook_id(root, emph_item_types, "type"); - item->path = e_plugin_xml_prop(root, "path"); - item->verb = e_plugin_xml_prop(root, "verb"); - item->visible = e_plugin_hook_mask(root, map->mask_bits, "visible"); - item->enable = e_plugin_hook_mask(root, map->mask_bits, "enable"); - item->user_data = e_plugin_xml_prop(root, "activate"); - if ((item->type & E_MENU_TYPE_MASK) == E_MENU_TOGGLE) - item->activate = G_CALLBACK(emph_menu_toggle_activate); - else - item->activate = G_CALLBACK(emph_menu_activate); - - if (item->type == -1 || item->user_data == NULL) - goto error; - - d(printf(" path=%s\n", item->path)); - d(printf(" verb=%s\n", item->verb)); - - return item; -error: - d(printf("error!\n")); - emph_free_item(item); - return NULL; -} - -static struct _EMenuPixmap * -emph_construct_pixmap(EPluginHook *eph, EMenuHookMenu *menu, xmlNodePtr root) -{ - struct _EMenuPixmap *pixmap; - - d(printf(" loading menu pixmap\n")); - pixmap = g_malloc0(sizeof(*pixmap)); - pixmap->command = e_plugin_xml_prop(root, "command"); - pixmap->name = e_plugin_xml_prop(root, "pixmap"); - pixmap->size = e_plugin_hook_id(root, emph_pixmap_sizes, "size"); - - if (pixmap->command == NULL || pixmap->name == NULL || pixmap->size == -1) - goto error; - - return pixmap; -error: - d(printf("error!\n")); - emph_free_pixmap(pixmap); - return NULL; -} - -static struct _EMenuHookMenu * -emph_construct_menu(EPluginHook *eph, xmlNodePtr root) -{ - struct _EMenuHookMenu *menu; - xmlNodePtr node; - EMenuHookTargetMap *map; - EMenuHookClass *klass = (EMenuHookClass *)G_OBJECT_GET_CLASS(eph); - char *tmp; - - d(printf(" loading menu\n")); - menu = g_malloc0(sizeof(*menu)); - menu->hook = (EMenuHook *)eph; - - tmp = xmlGetProp(root, "target"); - if (tmp == NULL) - goto error; - map = g_hash_table_lookup(klass->target_map, tmp); - xmlFree(tmp); - if (map == NULL) - goto error; - - menu->target_type = map->id; - menu->id = e_plugin_xml_prop(root, "id"); - if (menu->id == NULL) { - g_warning("Plugin '%s' missing 'id' field in menu for '%s'\n", eph->plugin->name, - ((EPluginHookClass *)G_OBJECT_GET_CLASS(eph))->id); - goto error; - } - node = root->children; - while (node) { - if (0 == strcmp(node->name, "item")) { - struct _EMenuItem *item; - - item = emph_construct_item(eph, menu, node, map); - if (item) - menu->items = g_slist_append(menu->items, item); - } else if (0 == strcmp(node->name, "ui")) { - tmp = xmlGetProp(node, "file"); - if (tmp) { - EMenuUIFile *ui = g_malloc0(sizeof(*ui)); - - ui->filename = tmp; - ui->appdir = g_strdup("/tmp"); - ui->appname = g_strdup("Evolution"); - menu->uis = g_slist_append(menu->uis, ui); - } - } else if (0 == strcmp(node->name, "pixmap")) { - struct _EMenuPixmap *pixmap; - - pixmap = emph_construct_pixmap(eph, menu, node); - if (pixmap) - menu->pixmaps = g_slist_append(menu->pixmaps, pixmap); - } - node = node->next; - } - - return menu; -error: - d(printf("error loading menu hook\n")); - emph_free_menu(menu); - return NULL; -} - -static int -emph_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) -{ - xmlNodePtr node; - EMenuClass *klass; - - d(printf("loading menu hook\n")); - - if (!ep->enabled) - return 0; - - if (((EPluginHookClass *)emph_parent_class)->construct(eph, ep, root) == -1) - return -1; - - klass = ((EMenuHookClass *)G_OBJECT_GET_CLASS(eph))->menu_class; - - node = root->children; - while (node) { - if (strcmp(node->name, "menu") == 0) { - struct _EMenuHookMenu *menu; - - menu = emph_construct_menu(eph, node); - if (menu) { - d(printf(" plugin adding factory %p\n", klass)); - e_menu_class_add_factory(klass, menu->id, emph_menu_factory, menu); - emph->menus = g_slist_append(emph->menus, menu); - } - } - - node = node->next; - } - - eph->plugin = ep; - - return 0; -} - -static void -emph_finalise(GObject *o) -{ - EPluginHook *eph = (EPluginHook *)o; - - g_slist_foreach(emph->menus, (GFunc)emph_free_menu, NULL); - g_slist_free(emph->menus); - - ((GObjectClass *)emph_parent_class)->finalize(o); -} - -static void -emph_class_init(EPluginHookClass *klass) -{ - d(printf("EMenuHook class init %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - ((GObjectClass *)klass)->finalize = emph_finalise; - klass->construct = emph_construct; - - /* this is actually an abstract implementation but list it anyway */ - klass->id = "org.gnome.evolution.bonobomenu:1.0"; - - ((EMenuHookClass *)klass)->target_map = g_hash_table_new(g_str_hash, g_str_equal); - ((EMenuHookClass *)klass)->menu_class = g_type_class_ref(e_menu_get_type()); -} - -/** - * e_menu_hook_get_type: - * - * Standard GObject function to get the object type. Used to subclass - * EMenuHook. - * - * Return value: The type of the menu hook class. - **/ -GType -e_menu_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EMenuHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL, - sizeof(EMenuHook), 0, (GInstanceInitFunc) NULL, - }; - - emph_parent_class = g_type_class_ref(e_plugin_hook_get_type()); - type = g_type_register_static(e_plugin_hook_get_type(), "EMenuHook", &info, 0); - } - - return type; -} - -/** - * e_menu_hook_class_add_target_map: - * @klass: The derived EMenuHook class. - * @map: A map used to describe a single EMenuTarget for this class. - * - * Adds a target map to a concrete derived class of EMenu. The target - * map enumerates a single target type, and the enable mask bit names, - * so that the type can be loaded automatically by the EMenu class. - **/ -void e_menu_hook_class_add_target_map(EMenuHookClass *klass, const EMenuHookTargetMap *map) -{ - g_hash_table_insert(klass->target_map, (void *)map->type, (void *)map); -} diff --git a/e-util/e-menu.h b/e-util/e-menu.h deleted file mode 100644 index 80bac35470..0000000000 --- a/e-util/e-menu.h +++ /dev/null @@ -1,323 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michel Zucchi <notzed@ximian.com> - * - * Copyright 2003 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __E_MENU_H__ -#define __E_MENU_H__ - -#include <glib-object.h> -#include "libedataserver/e-msgport.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* This is an abstract popup menu management/merging class. - - To implement your own popup menu system, just create your own - target types and implement the target free method. */ - -typedef struct _EMenu EMenu; -typedef struct _EMenuClass EMenuClass; - -typedef struct _EMenuItem EMenuItem; -typedef struct _EMenuUIFile EMenuUIFile; -typedef struct _EMenuPixmap EMenuPixmap; - -typedef struct _EMenuFactory EMenuFactory; /* anonymous type */ -typedef struct _EMenuTarget EMenuTarget; - -typedef void (*EMenuFactoryFunc)(EMenu *emp, void *data); -typedef void (*EMenuActivateFunc)(EMenu *, EMenuItem *, void *data); -typedef void (*EMenuToggleActivateFunc)(EMenu *, EMenuItem *, int state, void *data); -typedef void (*EMenuItemsFunc)(EMenu *, GSList *items, GSList *uifiles, GSList *pixmaps, void *data); - -/** - * enum _e_menu_t - Menu item type. - * - * @E_MENU_ITEM: Normal menu item. - * @E_MENU_TOGGLE: Toggle menu item. - * @E_MENU_RADIO: unimplemented. - * @E_MENU_TYPE_MASK: Mask used to separate item type from option bits. - * @E_MENU_ACTIVE: Whether a toggle item is active. - * - * The type of menu items which are supported by the menu system. - **/ -enum _e_menu_t { - E_MENU_ITEM = 0, - E_MENU_TOGGLE, - E_MENU_RADIO, - E_MENU_TYPE_MASK = 0xffff, - E_MENU_ACTIVE = 0x10000, -}; - -/** - * struct _EMenuItem - A BonoboUI menu item. - * - * @type: Menu item type. %E_MENU_ITEM or %E_MENU_TOGGLE. - * @path: BonoboUI Path to the menu item. - * @verb: BonoboUI verb for the menu item. - * @activate: Callback when the menu item is selected. This will be a - * EMenuToggleActivateFunc for toggle items or EMenuActivateFunc for - * normal items. - * @user_data: User data for item. - * @visible: Visibility mask, unimplemented. - * @enable: Sensitivity mask, combined with the target mask. - * - * An EMenuItem defines a single menu item. This menu item is used to - * hook onto callbacks from the bonobo menus, but not to build or - * merge the menu itself. - **/ -struct _EMenuItem { - enum _e_menu_t type; - char *path; /* full path? can we just create it from verb? */ - char *verb; /* command verb */ - GCallback activate; /* depends on type, the bonobo activate callback */ - void *user_data; /* up to caller to use */ - guint32 visible; /* is visible mask */ - guint32 enable; /* is enable mask */ -}; - -/** - * struct _EMenuPixmap - A menu icon holder. - * - * @command: The path to the command or verb to which this pixmap belongs. - * @name: The name of the icon. Either an icon-theme name or the full - * pathname of the icon. - * @size: The e-icon-factory icon size. - * @pixmap: The pixmap converted to XML format. If not set, then EMenu will - * create it as required. This must be freed if set in the free function. - * - * Used to track all pixmap items used in menus. These need to be - * supplied separately from the menu definition. - **/ -struct _EMenuPixmap { - char *command; - char *name; - int size; - char *pixmap; -}; - -/** - * struct _EMenuUIFile - A meu UI file holder. - * - * @appdir: TODO; should this be handled internally. - * @appname: TODO; should this be handled internally. - * @filename: The filename of the BonoboUI XML menu definition. - * - * These values are passed directly to bonobo_ui_util_set_ui() when - * the menu is activated. - **/ -struct _EMenuUIFile { - char *appdir; - char *appname; - char *filename; -}; - -/** - * struct _EMenuTarget - A BonoboUI menu target definition. - * - * @menu: The parent menu object, used for virtual methods on the target. - * @widget: The parent widget where available. In some cases the type - * of this object is part of the published api for the target, in - * others it is merely a GtkWidget from which you can find the - * toplevel widget. - * @type: Target type. This will be defined by the implementation. - * @mask: Target mask. This is used to sensitise show items based on - * their definition in EMenuItem. - * - * An EMenuTarget defines the context for a specific view instance. - * It is used to enable and show menu items, and to provide contextual - * data to menu invocations. - **/ -struct _EMenuTarget { - struct _EMenu *menu; /* used for virtual methods */ - - struct _GtkWidget *widget; /* used if you need a parent toplevel, if available */ - guint32 type; /* for implementors */ - - guint32 mask; /* enable/visible mask */ - - /* implementation fields follow */ -}; - -/** - * struct _EMenu - A BonoboUI menu manager object. - * - * @object: Superclass. - * @priv: Private data. - * @menuid: The id of this menu instance. - * @uic: The current BonoboUIComponent which stores the actual menu - * items this object manages. - * @target: The current target for the view. - * - * The EMenu manager object manages the mappings between EMenuItems - * and the BonoboUI menus loaded from UI files. - **/ -struct _EMenu { - GObject object; - struct _EMenuPrivate *priv; - - char *menuid; - struct _BonoboUIComponent *uic; - EMenuTarget *target; -}; - -/** - * struct _EMenuClass - - * - * @object_class: Superclass type. - * @factories: A list of factories for this particular class of main menu. - * @target_free: Virtual method to free the menu target. The base - * class free method frees the allocation and unrefs the EMenu parent - * pointer. - * - * The EMenu class definition. This should be sub-classed for each - * component that wants to provide hookable main menus. The subclass - * only needs to know how to allocate and free the various target - * types it supports. - **/ -struct _EMenuClass { - GObjectClass object_class; - - EDList factories; - - void (*target_free)(EMenu *ep, EMenuTarget *t); -}; - -GType e_menu_get_type(void); - -/* Static class methods */ -EMenuFactory *e_menu_class_add_factory(EMenuClass *klass, const char *menuid, EMenuFactoryFunc func, void *data); -void e_menu_class_remove_factory(EMenuClass *klass, EMenuFactory *f); - -EMenu *e_menu_construct(EMenu *menu, const char *menuid); - -void e_menu_add_ui(EMenu *, const char *appdir, const char *appname, const char *filename); -void e_menu_add_pixmap(EMenu *, const char *cmd, const char *name, int size); - -void *e_menu_add_items(EMenu *emp, GSList *items, GSList *uifiles, GSList *pixmaps, EMenuItemsFunc freefunc, void *data); -void e_menu_remove_items(EMenu *emp, void *handle); - -void e_menu_activate(EMenu *, struct _BonoboUIComponent *uic, int act); -void e_menu_update_target(EMenu *, void *); - -void *e_menu_target_new(EMenu *, int type, size_t size); -void e_menu_target_free(EMenu *, void *); - -/* ********************************************************************** */ - -/* menu plugin, they are closely integrated */ - -/* To implement a basic menu plugin, you just need to subclass - this and initialise the class target type tables */ - -#include "e-util/e-plugin.h" - -typedef struct _EMenuHookPixmap EMenuHookPixmap; -typedef struct _EMenuHookMenu EMenuHookMenu; -typedef struct _EMenuHook EMenuHook; -typedef struct _EMenuHookClass EMenuHookClass; - -typedef struct _EPluginHookTargetMap EMenuHookTargetMap; -typedef struct _EPluginHookTargetKey EMenuHookTargetMask; - -typedef void (*EMenuHookFunc)(struct _EPlugin *plugin, EMenuTarget *target); - -/** - * struct _EMenuHookMenu - A group of items targetting a specific menu. - * - * @hook: Parent pointer. - * @id: The identifier of the menu or view to which these items belong. - * @target_type: The target number of the type of target these menu - * items expect. This will be defined by menu itself. - * @items: A list of EMenuItems. - * @uis: A list of filenames of the BonoboUI files that need to be - * loaded for an active view. - * @pixmaps: A list of EMenuHookPixmap structures for the menus. - * - * This structure is used to keep track of all of the items that a - * plugin wishes to add to specific menu. This is used internally by - * a factory method defined by the EMenuHook to add the right menu - * items to a given view. - **/ -struct _EMenuHookMenu { - struct _EMenuHook *hook; /* parent pointer */ - char *id; /* target menu id for these menu items */ - int target_type; /* target type, not used */ - GSList *items; /* items to add to menu */ - GSList *uis; /* ui files */ - GSList *pixmaps; /* pixmap descriptors */ -}; - -/** - * struct _EMenuHook - A BonoboUI menu hook. - * - * @hook: Superclass. - * @menus: A list of EMenuHookMenus for all menus registered on this - * hook type. - * - * The EMenuHook class loads and manages the meta-data to required to - * map plugin definitions to physical menus. - **/ -struct _EMenuHook { - EPluginHook hook; - - GSList *menus; -}; - -/** - * struct _EMenuHookClass - Menu hook type. - * - * @hook_class: Superclass type. - * @target_map: Table of EluginHookTargetMaps which enumerate the - * target types and enable bits of the implementing class. - * @menu_class: The EMenuClass of the corresponding popup manager for - * implementing the class. - * - * The EMenuHookClass is an empty concrete class. It must be - * subclassed and initialised appropriately to perform useful work. - * - * The EPluginHookClass.id must be set to the name and version of the - * hook handler the implementation defines. The @target_map must be - * initialised with the data required to enumerate the target types - * and enable flags supported by the implementing class. - **/ -struct _EMenuHookClass { - EPluginHookClass hook_class; - - /* EMenuHookTargetMap by .type */ - GHashTable *target_map; - /* the menu class these menus belong to */ - EMenuClass *menu_class; -}; - -GType e_menu_hook_get_type(void); - -/* for implementors */ -void e_menu_hook_class_add_target_map(EMenuHookClass *klass, const EMenuHookTargetMap *); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_MENU_H__ */ diff --git a/e-util/e-mktemp.c b/e-util/e-mktemp.c deleted file mode 100644 index 67a9a5adf8..0000000000 --- a/e-util/e-mktemp.c +++ /dev/null @@ -1,241 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2001 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> -#include <dirent.h> -#include <errno.h> -#include <stdio.h> -#include <time.h> - -#include <gal/util/e-util.h> - -#include "e-mktemp.h" - -#define d(x) - -/* define to put temporary files in ~/evolution/cache/tmp */ -#define TEMP_HOME (1) - -/* how old things need to be to expire */ -#define TEMP_EXPIRE (60*60*2) -/* dont scan more often than this */ -#define TEMP_SCAN (60) - -static int -expire_dir_rec(const char *base, time_t now) -{ - DIR *dir; - struct dirent *d; - GString *path; - size_t len; - struct stat st; - int count = 0; - - d(printf("expire dir '%s'\n", base)); - - dir = opendir(base); - if (dir == NULL) - return 0; - - path = g_string_new(base); - len = path->len; - - while ( (d = readdir(dir)) ) { - if (strcmp(d->d_name, ".") == 0 - || strcmp(d->d_name, "..") == 0) - continue; - - g_string_truncate(path, len); - g_string_append_printf(path, "/%s", d->d_name); - d(printf("Checking '%s' for expiry\n", path->str)); - - if (stat(path->str, &st) == 0 - && st.st_atime + TEMP_EXPIRE < now) { - if (S_ISDIR(st.st_mode)) { - if (expire_dir_rec(path->str, now) == 0) { - d(printf("Removing dir '%s'\n", path->str)); - rmdir(path->str); - } else { - count++; - } - } else if (unlink(path->str) == -1) { - d(printf("expiry failed: %s\n", strerror(errno))); - count++; - } else { - d(printf("expired %s\n", path->str)); - } - } else { - count++; - } - } - g_string_free(path, TRUE); - closedir(dir); - - d(printf("expire dir '%s' %d remaining files\n", base, count)); - - return count; -} - -static GString * -get_dir (gboolean make) -{ - GString *path; - time_t now = time(0); - static time_t last = 0; - -#ifdef TEMP_HOME - path = g_string_new (g_get_home_dir()); - g_string_append_printf(path, "/.evolution/cache/tmp"); - if (make && e_mkdir_hier(path->str, 0777) == -1) { - g_string_free(path, TRUE); - path = NULL; - } -#else - path = g_string_new("/tmp/evolution-"); - g_string_append_printf (path, "%d", (int) getuid ()); - if (make) { - int ret; - - /* shoot now, ask questions later */ - ret = mkdir (path->str, S_IRWXU); - if (ret == -1) { - if (errno == EEXIST) { - struct stat st; - - if (stat (path->str, &st) == -1) { - /* reset errno */ - errno = EEXIST; - g_string_free (path, TRUE); - return NULL; - } - - /* make sure this is a directory and belongs to us... */ - if (!S_ISDIR (st.st_mode) || st.st_uid != getuid ()) { - /* eek! this is bad... */ - g_string_free (path, TRUE); - return NULL; - } - } else { - /* some other error...do not pass go, do not collect $200 */ - g_string_free (path, TRUE); - return NULL; - } - } - } -#endif - - d(printf("temp dir '%s'\n", path ? path->str : "(null)")); - - /* fire off an expirey attempt no more often than TEMP_SCAN seconds */ - if (path && (last+TEMP_SCAN) < now) { - last = now; - expire_dir_rec(path->str, now); - } - - return path; -} - -char * -e_mktemp (const char *template) -{ - GString *path; - char *ret; - - path = get_dir (TRUE); - if (!path) - return NULL; - - g_string_append_c (path, '/'); - if (template) - g_string_append (path, template); - else - g_string_append (path, "unknown-XXXXXX"); - - ret = mktemp (path->str); - g_string_free(path, ret == NULL); - - return ret; -} - - -int -e_mkstemp (const char *template) -{ - GString *path; - int fd; - - path = get_dir (TRUE); - if (!path) - return -1; - - g_string_append_c (path, '/'); - if (template) - g_string_append (path, template); - else - g_string_append (path, "unknown-XXXXXX"); - - fd = mkstemp (path->str); - g_string_free(path, TRUE); - - return fd; -} - - -char * -e_mkdtemp (const char *template) -{ - GString *path; - char *tmpdir; - - path = get_dir (TRUE); - if (!path) - return NULL; - - g_string_append_c (path, '/'); - if (template) - g_string_append (path, template); - else - g_string_append (path, "unknown-XXXXXX"); - -#ifdef HAVE_MKDTEMP - tmpdir = mkdtemp (path->str); -#else - tmpdir = mktemp (path->str); - if (tmpdir) { - if (mkdir (tmpdir, S_IRWXU) == -1) - tmpdir = NULL; - } -#endif - g_string_free(path, tmpdir == NULL); - - return tmpdir; -} diff --git a/e-util/e-mktemp.h b/e-util/e-mktemp.h deleted file mode 100644 index 14fbb9bcc8..0000000000 --- a/e-util/e-mktemp.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2001 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef __E_MKTEMP_H__ -#define __E_MKTEMP_H__ - -char *e_mktemp (const char *template); - -int e_mkstemp (const char *template); - -char *e_mkdtemp (const char *template); - -#endif /* __E_MKTEMP_H__ */ diff --git a/e-util/e-pilot-map.c b/e-util/e-pilot-map.c deleted file mode 100644 index e155657732..0000000000 --- a/e-util/e-pilot-map.c +++ /dev/null @@ -1,448 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution Conduits - Pilot Map routines - * - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: JP Rosevear <jpr@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "e-pilot-map.h" - -#include <string.h> /* memset(), strcmp() */ -#include <stdlib.h> -#include <glib.h> -#include <libxml/parser.h> - -typedef struct -{ - char *uid; - gboolean archived; - gboolean touched; -} EPilotMapPidNode; - -typedef struct -{ - guint32 pid; - gboolean archived; - gboolean touched; -} EPilotMapUidNode; - -typedef struct -{ - gboolean touched_only; - xmlNodePtr root; -} EPilotMapWriteData; - -static void -real_e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archived, gboolean touch) -{ - char *new_uid; - guint32 *new_pid; - EPilotMapPidNode *pnode; - EPilotMapUidNode *unode; - - g_return_if_fail (map != NULL); - g_return_if_fail (uid != NULL); - - /* Keys */ - if (pid != 0) { - new_pid = g_new (guint32, 1); - *new_pid = pid; - } - new_uid = g_strdup (uid); - - /* Values */ - if (pid != 0) { - pnode = g_new0 (EPilotMapPidNode, 1); - pnode->uid = new_uid; - pnode->archived = archived; - if (touch) - pnode->touched = TRUE; - } - - unode = g_new0 (EPilotMapUidNode, 1); - unode->pid = pid; - unode->archived = archived; - if (touch) - unode->touched = TRUE; - - /* Insertion */ - if (pid != 0) - g_hash_table_insert (map->pid_map, new_pid, pnode); - g_hash_table_insert (map->uid_map, new_uid, unode); -} - -static void -map_set_node_timet (xmlNodePtr node, const char *name, time_t t) -{ - char *tstring; - - tstring = g_strdup_printf ("%ld", t); - xmlSetProp (node, name, tstring); - g_free (tstring); -} - -static void -map_sax_start_element (void *data, const xmlChar *name, - const xmlChar **attrs) -{ - EPilotMap *map = (EPilotMap *)data; - - if (!strcmp (name, "PilotMap")) { - while (attrs && *attrs != NULL) { - const xmlChar **val = attrs; - - val++; - if (!strcmp (*attrs, "timestamp")) - map->since = (time_t)strtoul (*val, NULL, 0); - - attrs = ++val; - } - } - - if (!strcmp (name, "map")) { - const char *uid = NULL; - guint32 pid = 0; - gboolean archived = FALSE; - - while (attrs && *attrs != NULL) { - const xmlChar **val = attrs; - - val++; - if (!strcmp (*attrs, "uid")) - uid = *val; - - if (!strcmp (*attrs, "pilot_id")) - pid = strtoul (*val, NULL, 0); - - if (!strcmp (*attrs, "archived")) - archived = strtoul (*val, NULL, 0)== 1 ? TRUE : FALSE; - - attrs = ++val; - } - - g_assert (uid != NULL); - g_assert (pid != 0 || archived); - - real_e_pilot_map_insert (map, pid, uid, archived, FALSE); - } -} - -static void -map_write_foreach (gpointer key, gpointer value, gpointer data) -{ - EPilotMapWriteData *wd = data; - xmlNodePtr root = wd->root; - char *uid = key; - EPilotMapUidNode *unode = value; - xmlNodePtr mnode; - - if (wd->touched_only && !unode->touched) - return; - - mnode = xmlNewChild (root, NULL, "map", NULL); - xmlSetProp (mnode, "uid", uid); - - if (unode->archived) { - xmlSetProp (mnode, "archived", "1"); - } else { - char *pidstr; - - pidstr = g_strdup_printf ("%d", unode->pid); - xmlSetProp (mnode, "pilot_id", pidstr); - g_free (pidstr); - xmlSetProp (mnode, "archived", "0"); - } -} - -gboolean -e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pid) -{ - EPilotMapPidNode *pnode; - - g_return_val_if_fail (map != NULL, FALSE); - - pnode = g_hash_table_lookup (map->pid_map, &pid); - - if (pnode == NULL) - return FALSE; - - return pnode->archived; -} - -gboolean -e_pilot_map_uid_is_archived (EPilotMap *map, const char *uid) -{ - EPilotMapUidNode *unode; - - g_return_val_if_fail (map != NULL, FALSE); - g_return_val_if_fail (uid != NULL, FALSE); - - unode = g_hash_table_lookup (map->uid_map, uid); - - if (unode == NULL) - return FALSE; - - return unode->archived; -} - -void -e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archived) -{ - gpointer key, value; - - if (g_hash_table_lookup_extended (map->pid_map, &pid, &key, &value)) { - EPilotMapPidNode *pnode = value; - gpointer other_key, other_value; - - g_hash_table_remove (map->pid_map, &pid); - - /* In case the pid<->uid mapping is not the same anymore */ - if (g_hash_table_lookup_extended (map->uid_map, pnode->uid, &other_key, &other_value)) { - g_hash_table_remove (map->uid_map, pnode->uid); - g_free (other_key); - g_free (other_value); - } - - g_free (key); - g_free (value); - } - if (g_hash_table_lookup_extended (map->uid_map, uid, &key, &value)) { - EPilotMapUidNode *unode = value; - gpointer other_key, other_value; - - g_hash_table_remove (map->uid_map, uid); - - /* In case the pid<->uid mapping is not the same anymore */ - if (g_hash_table_lookup_extended (map->pid_map, &unode->pid, &other_key, &other_value)) { - g_hash_table_remove (map->pid_map, &unode->pid); - g_free (other_key); - g_free (other_value); - } - - g_free (key); - g_free (value); - } - - real_e_pilot_map_insert (map, pid, uid, archived, TRUE); -} - -void -e_pilot_map_remove_by_pid (EPilotMap *map, guint32 pid) -{ - EPilotMapPidNode *pnode = NULL; - EPilotMapUidNode *unode = NULL; - gpointer pkey, ukey; - - g_return_if_fail (map != NULL); - - if (!g_hash_table_lookup_extended (map->pid_map, &pid, - &pkey, (gpointer *)&pnode)) - return; - - g_hash_table_lookup_extended (map->uid_map, pnode->uid, &ukey, - (gpointer *)&unode); - g_assert (unode != NULL); - - g_hash_table_remove (map->pid_map, &pid); - g_hash_table_remove (map->uid_map, pnode->uid); - - g_free (pkey); - g_free (ukey); - g_free (pnode); - g_free (unode); -} - -void -e_pilot_map_remove_by_uid (EPilotMap *map, const char *uid) -{ - EPilotMapPidNode *pnode = NULL; - EPilotMapUidNode *unode = NULL; - gpointer pkey, ukey; - - g_return_if_fail (map != NULL); - g_return_if_fail (uid != NULL); - - if (!g_hash_table_lookup_extended (map->uid_map, uid, &ukey, (gpointer *)&unode)) - return; - - g_hash_table_lookup_extended (map->pid_map, &unode->pid, &pkey, (gpointer *)&pnode); - - g_hash_table_remove (map->uid_map, uid); - g_hash_table_remove (map->pid_map, &unode->pid); - - if (unode->pid != 0) - g_free (pkey); - g_free (ukey); - - if (unode->pid != 0) - g_free (pnode); - g_free (unode); -} - - -guint32 -e_pilot_map_lookup_pid (EPilotMap *map, const char *uid, gboolean touch) -{ - EPilotMapUidNode *unode = NULL; - - g_return_val_if_fail (map != NULL, 0); - g_return_val_if_fail (uid != NULL, 0); - - unode = g_hash_table_lookup (map->uid_map, uid); - - if (unode == NULL) - return 0; - - if (touch) { - EPilotMapPidNode *pnode = NULL; - - pnode = g_hash_table_lookup (map->pid_map, &unode->pid); - if (pnode != NULL) - pnode->touched = TRUE; - unode->touched = TRUE; - } - - return unode->pid; -} - -const char * -e_pilot_map_lookup_uid (EPilotMap *map, guint32 pid, gboolean touch) -{ - EPilotMapPidNode *pnode = NULL; - - g_return_val_if_fail (map != NULL, NULL); - - pnode = g_hash_table_lookup (map->pid_map, &pid); - - if (pnode == NULL) - return NULL; - - if (touch) { - EPilotMapUidNode *unode = NULL; - - unode = g_hash_table_lookup (map->uid_map, pnode->uid); - g_assert (unode != NULL); - - unode->touched = TRUE; - pnode->touched = TRUE; - } - - return pnode->uid; -} - -int -e_pilot_map_read (const char *filename, EPilotMap **map) -{ - xmlSAXHandler handler; - EPilotMap *new_map; - - g_return_val_if_fail (filename != NULL, -1); - g_return_val_if_fail (map != NULL, -1); - - *map = NULL; - new_map = g_new0 (EPilotMap, 1); - - memset (&handler, 0, sizeof (xmlSAXHandler)); - handler.startElement = map_sax_start_element; - - new_map->pid_map = g_hash_table_new (g_int_hash, g_int_equal); - new_map->uid_map = g_hash_table_new (g_str_hash, g_str_equal); - - if (g_file_test (filename, G_FILE_TEST_EXISTS)) { - if (xmlSAXUserParseFile (&handler, new_map, filename) < 0) { - g_free (new_map); - return -1; - } - } - - new_map->write_touched_only = FALSE; - - *map = new_map; - - return 0; -} - -int -e_pilot_map_write (const char *filename, EPilotMap *map) -{ - EPilotMapWriteData wd; - xmlDocPtr doc; - int ret; - - g_return_val_if_fail (filename != NULL, -1); - g_return_val_if_fail (map != NULL, -1); - - doc = xmlNewDoc ("1.0"); - if (doc == NULL) { - g_warning ("Pilot map file could not be created\n"); - return -1; - } - xmlDocSetRootElement (doc, xmlNewDocNode(doc, NULL, "PilotMap", NULL)); - map->since = time (NULL); - map_set_node_timet (xmlDocGetRootElement (doc), "timestamp", map->since); - - wd.touched_only = map->write_touched_only; - wd.root = xmlDocGetRootElement(doc); - g_hash_table_foreach (map->uid_map, map_write_foreach, &wd); - - /* Write the file */ - xmlSetDocCompressMode (doc, 0); - ret = xmlSaveFile (filename, doc); - if (ret < 0) { - g_warning ("Pilot map file '%s' could not be saved\n", filename); - return -1; - } - - xmlFreeDoc (doc); - - return 0; -} - -static gboolean -foreach_remove (gpointer key, gpointer value, gpointer data) -{ - g_free (key); - g_free (value); - - return TRUE; -} - -void -e_pilot_map_clear (EPilotMap *map) -{ - g_return_if_fail (map != NULL); - - g_hash_table_foreach_remove (map->pid_map, foreach_remove, NULL); - g_hash_table_foreach_remove (map->uid_map, foreach_remove, NULL); - - map->since = 0; - map->write_touched_only = FALSE; -} - -void -e_pilot_map_destroy (EPilotMap *map) -{ - g_return_if_fail (map != NULL); - - g_hash_table_foreach_remove (map->pid_map, foreach_remove, NULL); - g_hash_table_foreach_remove (map->uid_map, foreach_remove, NULL); - - g_hash_table_destroy (map->pid_map); - g_hash_table_destroy (map->uid_map); - g_free (map); -} diff --git a/e-util/e-pilot-map.h b/e-util/e-pilot-map.h deleted file mode 100644 index ff02994645..0000000000 --- a/e-util/e-pilot-map.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution Conduits - Pilot Map routines - * - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: JP Rosevear <jpr@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef E_PILOT_MAP_H -#define E_PILOT_MAP_H - -#include <glib.h> -#include <time.h> - -typedef struct _EPilotMap EPilotMap; - -struct _EPilotMap -{ - GHashTable *pid_map; - GHashTable *uid_map; - - time_t since; - - gboolean write_touched_only; -}; - -gboolean e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pid); -gboolean e_pilot_map_uid_is_archived (EPilotMap *map, const char *uid); - -void e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archived); -void e_pilot_map_remove_by_pid (EPilotMap *map, guint32 pid); -void e_pilot_map_remove_by_uid (EPilotMap *map, const char *uid); - -guint32 e_pilot_map_lookup_pid (EPilotMap *map, const char *uid, gboolean touch); -const char * e_pilot_map_lookup_uid (EPilotMap *map, guint32 pid, gboolean touch); - -int e_pilot_map_read (const char *filename, EPilotMap **map); -int e_pilot_map_write (const char *filename, EPilotMap *map); - -void e_pilot_map_clear (EPilotMap *map); - -void e_pilot_map_destroy (EPilotMap *map); - -#endif /* E_PILOT_MAP_H */ diff --git a/e-util/e-pilot-util.c b/e-util/e-pilot-util.c deleted file mode 100644 index 7d82ef290b..0000000000 --- a/e-util/e-pilot-util.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution Conduits - Pilot Map routines - * - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: JP Rosevear <jpr@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <string.h> -#include <stdlib.h> -#include <time.h> -#include <libxml/parser.h> -#include <pi-util.h> - -#include "e-pilot-util.h" - -char * -e_pilot_utf8_to_pchar (const char *string) -{ - char *pstring = NULL; - int res; - - if (!string) - return NULL; - - res = convert_ToPilotChar ("UTF-8", string, strlen (string), &pstring); - - if (res != 0) - pstring = strdup (string); - - return pstring; -} - -char * -e_pilot_utf8_from_pchar (const char *string) -{ - char *ustring = NULL; - int res; - - if (!string) - return NULL; - - res = convert_FromPilotChar ("UTF-8", string, strlen (string), &ustring); - - if (res != 0) - ustring = strdup (string); - - return ustring; -} - -ESource * -e_pilot_get_sync_source (ESourceList *source_list) -{ - GSList *g; - - g_return_val_if_fail (source_list != NULL, NULL); - g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL); - - for (g = e_source_list_peek_groups (source_list); g; g = g->next) { - ESourceGroup *group = E_SOURCE_GROUP (g->data); - GSList *s; - - for (s = e_source_group_peek_sources (group); s; s = s->next) { - ESource *source = E_SOURCE (s->data); - - if (e_source_get_property (source, "pilot-sync")) - return source; - } - } - - return NULL; -} - -void -e_pilot_set_sync_source (ESourceList *source_list, ESource *source) -{ - GSList *g; - - g_return_if_fail (source_list != NULL); - g_return_if_fail (E_IS_SOURCE_LIST (source_list)); - - for (g = e_source_list_peek_groups (source_list); g; g = g->next) { - GSList *s; - for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); - s; s = s->next) { - e_source_set_property (E_SOURCE (s->data), "pilot-sync", NULL); - } - } - - if (source) - e_source_set_property (source, "pilot-sync", "true"); - e_source_list_sync (source_list, NULL); -} diff --git a/e-util/e-pilot-util.h b/e-util/e-pilot-util.h deleted file mode 100644 index 7953536a5b..0000000000 --- a/e-util/e-pilot-util.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution Conduits - Pilot Map routines - * - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: JP Rosevear <jpr@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <libedataserver/e-source-list.h> -#include <libedataserver/e-source.h> - -#ifndef E_PILOT_UTIL_H -#define E_PILOT_UTIL_H - -char *e_pilot_utf8_to_pchar (const char *string); -char *e_pilot_utf8_from_pchar (const char *string); - -ESource *e_pilot_get_sync_source (ESourceList *source_list); -void e_pilot_set_sync_source (ESourceList *source_list, ESource *source); - - -#endif /* E_PILOT_UTIL_H */ diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c deleted file mode 100644 index a60aa7bafd..0000000000 --- a/e-util/e-plugin.c +++ /dev/null @@ -1,1283 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <sys/types.h> -#include <dirent.h> -#include <string.h> - -#include <glib/gi18n.h> -#include <gconf/gconf-client.h> - -#include "e-plugin.h" -#include "libedataserver/e-msgport.h" - -/* plugin debug */ -#define pd(x) -/* plugin hook debug */ -#define phd(x) - -/* -<camel-plugin - class="org.gnome.camel.plugin.provider:1.0" - id="org.gnome.camel.provider.imap:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelimap.so" - factory="camel_imap_provider_new"> - <name>imap</name> - <description>IMAP4 and IMAP4v1 mail store</description> - <class-data class="org.gnome.camel.plugin.provider:1.0" - protocol="imap" - domain="mail" - flags="remote,source,storage,ssl"/> -</camel-plugin> - -<camel-plugin - class="org.gnome.camel.plugin.sasl:1.0" - id="org.gnome.camel.sasl.plain:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelsasl.so" - factory="camel_sasl_plain_new"> - <name>PLAIN</name> - <description>SASL PLAIN authentication mechanism</description> -</camel-plugin> -*/ - -/* EPlugin stuff */ -static GObjectClass *ep_parent_class; - -/* global table of plugin types by pluginclass.type */ -static GHashTable *ep_types; -/* plugin load path */ -static GSList *ep_path; -/* global table of plugins by plugin.id */ -static GHashTable *ep_plugins; -/* a table of GSLists of plugins by hook class for hooks not loadable yet */ -static GHashTable *ep_plugins_pending_hooks; -/* list of all cached xml docs:struct _plugin_doc's */ -static EDList ep_plugin_docs = E_DLIST_INITIALISER(ep_plugin_docs); -/* gconf client */ -static GConfClient *ep_gconf; -/* the list of disabled plugins from gconf */ -static GSList *ep_disabled; - -/* EPluginHook stuff */ -static void *eph_parent_class; -/* All classes which implement EPluginHooks, by class.id */ -static GHashTable *eph_types; - -struct _plugin_doc { - struct _plugin_doc *next; - struct _plugin_doc *prev; - - char *filename; - xmlDocPtr doc; - - GSList *plugin_hooks; /* EPlugin objects with pending hooks */ - GSList *plugins; /* xmlNodePtr's of plugins with unknown type (mono,etc) */ -}; - -static gboolean -ep_check_enabled(const char *id) -{ - GSList *l = ep_disabled; - - for (;l;l = g_slist_next(l)) - if (!strcmp((char *)l->data, id)) - return FALSE; - - return TRUE; -} - -static void -ep_set_enabled(const char *id, int state) -{ - if ((state == 0) == ep_check_enabled(id) == 0) - return; - - if (state) { - GSList *l = ep_disabled; - - while (l) { - GSList *n = l->next; - - if (!strcmp((char *)l->data, id)) { - g_free(l->data); - ep_disabled = g_slist_remove_link(ep_disabled, l); - } - l = n; - } - } else { - ep_disabled = g_slist_prepend(ep_disabled, g_strdup(id)); - } - - gconf_client_set_list(ep_gconf, "/apps/evolution/eplugin/disabled", GCONF_VALUE_STRING, ep_disabled, NULL); -} - -static int -ep_construct(EPlugin *ep, xmlNodePtr root) -{ - xmlNodePtr node; - int res = -1; - char *localedir; - - ep->domain = e_plugin_xml_prop(root, "domain"); - if (ep->domain - && (localedir = e_plugin_xml_prop(root, "localedir"))) { - bindtextdomain(ep->domain, localedir); - g_free(localedir); - } - - ep->name = e_plugin_xml_prop_domain(root, "name", ep->domain); - - pd(printf("creating plugin '%s' '%s'\n", ep->name?ep->name:"un-named", ep->id)); - - node = root->children; - while (node) { - if (strcmp(node->name, "hook") == 0) { - struct _EPluginHook *hook; - EPluginHookClass *type; - char *class = e_plugin_xml_prop(node, "class"); - - if (class == NULL) { - g_warning("Plugin '%s' load failed in '%s', missing class property for hook", ep->id, ep->path); - goto fail; - } - - if (ep->enabled - && eph_types != NULL - && (type = g_hash_table_lookup(eph_types, class)) != NULL) { - g_free(class); - hook = g_object_new(G_OBJECT_CLASS_TYPE(type), NULL); - res = type->construct(hook, ep, node); - if (res == -1) { - g_warning("Plugin '%s' failed to load hook", ep->name); - g_object_unref(hook); - goto fail; - } else { - ep->hooks = g_slist_append(ep->hooks, hook); - } - } else { - GSList *l; - char *oldclass; - - if (ep_plugins_pending_hooks == NULL) - ep_plugins_pending_hooks = g_hash_table_new(g_str_hash, g_str_equal); - if (!g_hash_table_lookup_extended(ep_plugins_pending_hooks, class, (void **)&oldclass, (void **)&l)) { - oldclass = class; - l = NULL; - } - l = g_slist_prepend(l, ep); - g_hash_table_insert(ep_plugins_pending_hooks, oldclass, l); - ep->hooks_pending = g_slist_prepend(ep->hooks_pending, node); - } - } else if (strcmp(node->name, "description") == 0) { - ep->description = e_plugin_xml_content_domain(node, ep->domain); - } else if (strcmp(node->name, "author") == 0) { - char *name = e_plugin_xml_prop(node, "name"); - char *email = e_plugin_xml_prop(node, "email"); - - if (name || email) { - EPluginAuthor *epa = g_malloc0(sizeof(*epa)); - - epa->name = name; - epa->email = email; - ep->authors = g_slist_append(ep->authors, epa); - } - } - node = node->next; - } - res = 0; -fail: - return res; -} - -static void -ep_enable(EPlugin *ep, int state) -{ - GSList *l; - - ep->enabled = state; - for (l=ep->hooks;l;l = g_slist_next(l)) - e_plugin_hook_enable((EPluginHook *)l->data, state); - - ep_set_enabled(ep->id, state); -} - -static void -ep_finalise(GObject *o) -{ - EPlugin *ep = (EPlugin *)o; - - g_free(ep->id); - g_free(ep->description); - g_free(ep->name); - g_free(ep->domain); - g_slist_free(ep->hooks_pending); - - g_slist_foreach(ep->hooks, (GFunc)g_object_unref, NULL); - g_slist_free(ep->hooks); - - ((GObjectClass *)ep_parent_class)->finalize(o); -} - -static void -ep_init(GObject *o) -{ - EPlugin *ep = (EPlugin *)o; - - ep->enabled = TRUE; -} - -static void -ep_class_init(EPluginClass *klass) -{ - ((GObjectClass *)klass)->finalize = ep_finalise; - klass->construct = ep_construct; - klass->enable = ep_enable; -} - -/** - * e_plugin_get_type: - * - * Standard GObject type function. This is only an abstract class, so - * you can only use this to subclass EPlugin. - * - * Return value: The type. - **/ -GType -e_plugin_get_type(void) -{ - static GType type = 0; - - if (!type) { - char *path, *col, *p; - - static const GTypeInfo info = { - sizeof(EPluginClass), NULL, NULL, (GClassInitFunc)ep_class_init, NULL, NULL, - sizeof(EPlugin), 0, (GInstanceInitFunc)ep_init, - }; - - ep_parent_class = g_type_class_ref(G_TYPE_OBJECT); - type = g_type_register_static(G_TYPE_OBJECT, "EPlugin", &info, 0); - - /* Add paths in the environment variable or default global and user specific paths */ - path = g_strdup(getenv("EVOLUTION_PLUGIN_PATH")); - if (path == NULL) { - /* Add the global path */ - e_plugin_add_load_path(EVOLUTION_PLUGINDIR); - - path = g_build_filename(g_get_home_dir(), ".eplugins", NULL); - } - - p = path; - while ((col = strchr(p, ':'))) { - *col++ = 0; - e_plugin_add_load_path(p); - p = col; - } - e_plugin_add_load_path(p); - g_free(path); - } - - return type; -} - -static EPlugin * -ep_load_plugin(xmlNodePtr root, struct _plugin_doc *pdoc) -{ - char *prop, *id; - EPluginClass *klass; - EPlugin *ep; - - id = e_plugin_xml_prop(root, "id"); - if (id == NULL) { - g_warning("Invalid e-plugin entry in '%s': no id", pdoc->filename); - return NULL; - } - - if (g_hash_table_lookup(ep_plugins, id)) { - g_warning("Plugin '%s' already defined", id); - g_free(id); - return NULL; - } - - prop = xmlGetProp(root, "type"); - if (prop == NULL) { - g_free(id); - g_warning("Invalid e-plugin entry in '%s': no type", pdoc->filename); - return NULL; - } - - /* If we can't find a plugin, add it to a pending list which is checked when a new type is registered */ - klass = g_hash_table_lookup(ep_types, prop); - if (klass == NULL) { - pd(printf("Delaying loading of plugin '%s' unknown type '%s'\n", id, prop)); - g_free(id); - xmlFree(prop); - pdoc->plugins = g_slist_prepend(pdoc->plugins, root); - return NULL; - } - xmlFree(prop); - - ep = g_object_new(G_TYPE_FROM_CLASS(klass), NULL); - ep->id = id; - ep->path = g_strdup(pdoc->filename); - ep->enabled = ep_check_enabled(id); - if (e_plugin_construct(ep, root) == -1) - e_plugin_enable(ep, FALSE); - g_hash_table_insert(ep_plugins, ep->id, ep); - - return ep; -} - -static int -ep_load(const char *filename) -{ - xmlDocPtr doc; - xmlNodePtr root; - int res = -1; - EPlugin *ep; - int cache = FALSE; - struct _plugin_doc *pdoc; - - doc = xmlParseFile(filename); - if (doc == NULL) { - return -1; - } - - root = xmlDocGetRootElement(doc); - if (strcmp(root->name, "e-plugin-list") != 0) { - g_warning("No <e-plugin-list> root element: %s", filename); - xmlFreeDoc(doc); - return -1; - } - - pdoc = g_malloc0(sizeof(*pdoc)); - pdoc->doc = doc; - pdoc->filename = g_strdup(filename); - - for (root = root->children; root ; root = root->next) { - if (strcmp(root->name, "e-plugin") == 0) { - ep = ep_load_plugin(root, pdoc); - if (ep) { - pdoc->plugin_hooks = g_slist_prepend(pdoc->plugin_hooks, ep); - cache |= (ep->hooks_pending != NULL); - } - cache |= pdoc->plugins != NULL; - } - } - - res = 0; - - if (cache) { - pd(printf("Caching plugin description '%s' for unknown future hooks\n", filename)); - e_dlist_addtail(&ep_plugin_docs, (EDListNode *)pdoc); - } else { - pd(printf("freeing plugin description '%s', nothing uses it\n", filename)); - xmlFreeDoc(pdoc->doc); - g_free(pdoc->filename); - g_free(pdoc); - } - - return res; -} - -/* This loads a hook that was pending on a given plugin but the type wasn't registered yet */ -/* This works in conjunction with ep_construct and e_plugin_hook_register_type to make sure - everything works nicely together. Apparently. */ -static int -ep_load_pending(EPlugin *ep, EPluginHookClass *type) -{ - int res = 0; - GSList *l, *p; - - phd(printf("New hook type registered '%s', loading pending hooks on plugin '%s'\n", type->id, ep->id)); - - l = ep->hooks_pending; - p = NULL; - while (l) { - GSList *n = l->next; - xmlNodePtr node = l->data; - char *class = xmlGetProp(node, "class"); - EPluginHook *hook; - - phd(printf(" checking pending hook '%s'\n", class?class:"<unknown>")); - - if (class) { - if (strcmp(class, type->id) == 0) { - hook = g_object_new(G_OBJECT_CLASS_TYPE(type), NULL); - res = type->construct(hook, ep, node); - if (res == -1) { - g_warning("Plugin '%s' failed to load hook '%s'", ep->name, type->id); - g_object_unref(hook); - } else { - ep->hooks = g_slist_append(ep->hooks, hook); - } - - if (p) - p->next = n; - else - ep->hooks_pending = n; - g_slist_free_1(l); - l = p; - } - - xmlFree(class); - } - - p = l; - l = n; - } - - return res; -} - -/** - * e_plugin_add_load_path: - * @path: The path to add to search for plugins. - * - * Add a path to be searched when e_plugin_load_plugins() is called. - * By default the system plugin directory and ~/.eplugins is used as - * the search path unless overriden by the environmental variable - * %EVOLUTION_PLUGIN_PATH. - * - * %EVOLUTION_PLUGIN_PATH is a : separated list of paths to search for - * plugin definitions in order. - * - * Plugin definitions are XML files ending in the extension ".eplug". - **/ -void -e_plugin_add_load_path(const char *path) -{ - ep_path = g_slist_append(ep_path, g_strdup(path)); -} - -/** - * e_plugin_load_plugins: - * - * Scan the search path, looking for plugin definitions, and load them - * into memory. - * - * Return value: Returns -1 if an error occured. - **/ -int -e_plugin_load_plugins(void) -{ - GSList *l; - - if (ep_types == NULL) { - g_warning("no plugin types defined"); - return 0; - } - - for (l = ep_path;l;l = g_slist_next(l)) { - DIR *dir; - struct dirent *d; - char *path = l->data; - - pd(printf("scanning plugin dir '%s'\n", path)); - - dir = opendir(path); - if (dir == NULL) { - /*g_warning("Could not find plugin path: %s", path);*/ - continue; - } - - while ( (d = readdir(dir)) ) { - if (strlen(d->d_name) > 6 - && !strcmp(d->d_name + strlen(d->d_name) - 6, ".eplug")) { - char * name = g_build_filename(path, d->d_name, NULL); - - ep_load(name); - g_free(name); - } - } - - closedir(dir); - } - - return 0; -} - -/** - * e_plugin_register_type: - * @type: The GObject type of the plugin loader. - * - * Register a new plugin type with the plugin system. Each type must - * subclass EPlugin and must override the type member of the - * EPluginClass with a unique name. - **/ -void -e_plugin_register_type(GType type) -{ - EPluginClass *klass; - struct _plugin_doc *pdoc, *ndoc; - - if (ep_types == NULL) { - ep_types = g_hash_table_new(g_str_hash, g_str_equal); - ep_plugins = g_hash_table_new(g_str_hash, g_str_equal); - /* TODO: notify listening */ - ep_gconf = gconf_client_get_default(); - ep_disabled = gconf_client_get_list(ep_gconf, "/apps/evolution/eplugin/disabled", GCONF_VALUE_STRING, NULL); - } - - klass = g_type_class_ref(type); - - pd(printf("register plugin type '%s'\n", klass->type)); - - g_hash_table_insert(ep_types, (void *)klass->type, klass); - - /* check for pending plugins */ - pdoc = (struct _plugin_doc *)ep_plugin_docs.head; - ndoc = pdoc->next; - while (ndoc) { - if (pdoc->plugins) { - GSList *l, *add = NULL; - - for (l=pdoc->plugins;l;l=g_slist_next(l)) { - xmlNodePtr root = l->data; - char *type; - - type = xmlGetProp(root, "type"); - if (!strcmp(type, klass->type)) - add = g_slist_append(add, l->data); - xmlFree(type); - } - - for (l=add;l;l=g_slist_next(l)) { - xmlNodePtr root = l->data; - EPlugin *ep; - - pdoc->plugins = g_slist_remove(pdoc->plugins, root); - ep = ep_load_plugin(root, pdoc); - if (ep) - pdoc->plugin_hooks = g_slist_prepend(pdoc->plugin_hooks, ep); - /* TODO: garbage collect plugin doc? */ - } - - g_slist_free(add); - } - - pdoc = ndoc; - ndoc = ndoc->next; - } -} - -static void -ep_list_plugin(void *key, void *val, void *dat) -{ - GSList **l = (GSList **)dat; - - *l = g_slist_prepend(*l, g_object_ref(val)); -} - -/** - * e_plugin_list_plugins: List all plugins. - * - * Static class method to retrieve a list of all current plugins. They - * are listed in no particular order. - * - * Return value: A GSList of all plugins, they must be - * g_object_unref'd and the list freed. - **/ -GSList * -e_plugin_list_plugins(void) -{ - GSList *l = NULL; - - if (ep_plugins) - g_hash_table_foreach(ep_plugins, ep_list_plugin, &l); - - return l; -} - -/** - * e_plugin_construct: - * @ep: An EPlugin derived object. - * @root: The XML root node of the sub-tree containing the plugin - * definition. - * - * Helper to invoke the construct virtual method. - * - * Return value: The return from the construct virtual method. - **/ -int -e_plugin_construct(EPlugin *ep, xmlNodePtr root) -{ - return ((EPluginClass *)G_OBJECT_GET_CLASS(ep))->construct(ep, root); -} - -/** - * e_plugin_invoke: - * @ep: - * @name: The name of the function to invoke. The format of this name - * will depend on the EPlugin type and its language conventions. - * @data: The argument to the function. Its actual type depends on - * the hook on which the function resides. It is up to the called - * function to get this right. - * - * Helper to invoke the invoke virtual method. - * - * Return value: The return of the plugin invocation. - **/ -void * -e_plugin_invoke(EPlugin *ep, const char *name, void *data) -{ - if (!ep->enabled) { - g_warning("Invoking method on disabled plugin, ignored"); - return NULL; - } - - return ((EPluginClass *)G_OBJECT_GET_CLASS(ep))->invoke(ep, name, data); -} - -/** - * e_plugin_enable: - * @ep: - * @state: - * - * Set the enable state of a plugin. - * - * THIS IS NOT FULLY IMPLEMENTED YET - **/ -void -e_plugin_enable(EPlugin *ep, int state) -{ - if ((ep->enabled == 0) == (state == 0)) - return; - - ((EPluginClass *)G_OBJECT_GET_CLASS(ep))->enable(ep, state); -} - -/** - * e_plugin_xml_prop: - * @node: An XML node. - * @id: The name of the property to retrieve. - * - * A static helper function to look up a property on an XML node, and - * ensure it is allocated in GLib system memory. If GLib isn't using - * the system malloc then it must copy the property value. - * - * Return value: The property, allocated in GLib memory, or NULL if no - * such property exists. - **/ -char * -e_plugin_xml_prop(xmlNodePtr node, const char *id) -{ - char *p = xmlGetProp(node, id); - - if (g_mem_is_system_malloc()) { - return p; - } else { - char * out = g_strdup(p); - - if (p) - xmlFree(p); - return out; - } -} - -/** - * e_plugin_xml_prop_domain: - * @node: An XML node. - * @id: The name of the property to retrieve. - * @domain: The translation domain for this string. - * - * A static helper function to look up a property on an XML node, and - * translate it based on @domain. - * - * Return value: The property, allocated in GLib memory, or NULL if no - * such property exists. - **/ -char * -e_plugin_xml_prop_domain(xmlNodePtr node, const char *id, const char *domain) -{ - char *p, *out; - - p = xmlGetProp(node, id); - if (p == NULL) - return NULL; - - out = g_strdup(dgettext(domain, p)); - xmlFree(p); - - return out; -} - -/** - * e_plugin_xml_int: - * @node: An XML node. - * @id: The name of the property to retrieve. - * @def: A default value if the property doesn't exist. Can be used - * to determine if the property isn't set. - * - * A static helper function to look up a property on an XML node as an - * integer. If the property doesn't exist, then @def is returned as a - * default value instead. - * - * Return value: The value if set, or @def if not. - **/ -int -e_plugin_xml_int(xmlNodePtr node, const char *id, int def) -{ - char *p = xmlGetProp(node, id); - - if (p) - return atoi(p); - else - return def; -} - -/** - * e_plugin_xml_content: - * @node: - * - * A static helper function to retrieve the entire textual content of - * an XML node, and ensure it is allocated in GLib system memory. If - * GLib isn't using the system malloc them it must copy the content. - * - * Return value: The node content, allocated in GLib memory. - **/ -char * -e_plugin_xml_content(xmlNodePtr node) -{ - char *p = xmlNodeGetContent(node); - - if (g_mem_is_system_malloc()) { - return p; - } else { - char * out = g_strdup(p); - - if (p) - xmlFree(p); - return out; - } -} - -/** - * e_plugin_xml_content_domain: - * @node: - * @domain: - * - * A static helper function to retrieve the entire textual content of - * an XML node, and ensure it is allocated in GLib system memory. If - * GLib isn't using the system malloc them it must copy the content. - * - * Return value: The node content, allocated in GLib memory. - **/ -char * -e_plugin_xml_content_domain(xmlNodePtr node, const char *domain) -{ - char *p, *out; - - p = xmlNodeGetContent(node); - if (p == NULL) - return NULL; - - out = g_strdup(dgettext(domain, p)); - xmlFree(p); - - return out; -} - -/* ********************************************************************** */ -static void *epl_parent_class; - -/* this looks weird, but it saves a lot of typing */ -#define epl ((EPluginLib *)ep) - -/* TODO: - We need some way to manage lifecycle. - We need some way to manage state. - - Maybe just the g module init method will do, or we could add - another which returns context. - - There is also the question of per-instance context, e.g. for config - pages. -*/ - -static int -epl_loadmodule(EPlugin *ep) -{ - if (epl->module == NULL) { - EPluginLibEnableFunc enable; - - if ((epl->module = g_module_open(epl->location, 0)) == NULL) { - g_warning("can't load plugin '%s'", g_module_error()); - return -1; - } - - if (g_module_symbol(epl->module, "e_plugin_lib_enable", (void *)&enable)) { - if (enable(epl, TRUE) != 0) { - ep->enabled = FALSE; - g_module_close(epl->module); - epl->module = NULL; - return -1; - } - } - } - - return 0; -} - -static void * -epl_invoke(EPlugin *ep, const char *name, void *data) -{ - EPluginLibFunc cb; - - if (!ep->enabled) { - g_warning("trying to invoke '%s' on disabled plugin '%s'", name, ep->id); - return NULL; - } - - if (epl_loadmodule(ep) != 0) - return NULL; - - if (!g_module_symbol(epl->module, name, (void *)&cb)) { - g_warning("Cannot resolve symbol '%s' in plugin '%s' (not exported?)", name, epl->location); - return NULL; - } - - return cb(epl, data); -} - -static int -epl_construct(EPlugin *ep, xmlNodePtr root) -{ - if (((EPluginClass *)epl_parent_class)->construct(ep, root) == -1) - return -1; - - epl->location = e_plugin_xml_prop(root, "location"); - - if (epl->location == NULL) { - g_warning("Library plugin '%s' has no location", ep->id); - return -1; - } - - /* If we're enabled, check for the load-on-startup property */ - if (ep->enabled) { - xmlChar *tmp; - - tmp = xmlGetProp(root, "load-on-startup"); - if (tmp) { - xmlFree(tmp); - if (epl_loadmodule(ep) != 0) - return -1; - } - } - - return 0; -} - -static void -epl_enable(EPlugin *ep, int state) -{ - EPluginLibEnableFunc enable; - - ((EPluginClass *)epl_parent_class)->enable(ep, state); - - /* if we're disabling and it isn't loaded, nothing to do */ - if (!state && epl->module == NULL) - return; - - /* this will noop if we're disabling since we tested it above */ - if (epl_loadmodule(ep) != 0) - return; - - if (g_module_symbol(epl->module, "e_plugin_lib_enable", (void *)&enable)) { - if (enable(epl, state) != 0) - return; - } -#if 0 - if (!state) { - g_module_close(epl->module); - epl->module = NULL; - } -#endif -} - -static void -epl_finalise(GObject *o) -{ - EPlugin *ep = (EPlugin *)o; - - g_free(epl->location); - - if (epl->module) - g_module_close(epl->module); - - ((GObjectClass *)epl_parent_class)->finalize(o); -} - -static void -epl_class_init(EPluginClass *klass) -{ - ((GObjectClass *)klass)->finalize = epl_finalise; - klass->construct = epl_construct; - klass->invoke = epl_invoke; - klass->enable = epl_enable; - klass->type = "shlib"; -} - -/** - * e_plugin_lib_get_type: - * - * Standard GObject function to retrieve the EPluginLib type. Use to - * register the type with the plugin system if you want to use shared - * library plugins. - * - * Return value: The EPluginLib type. - **/ -GType -e_plugin_lib_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EPluginLibClass), NULL, NULL, (GClassInitFunc) epl_class_init, NULL, NULL, - sizeof(EPluginLib), 0, (GInstanceInitFunc) NULL, - }; - - epl_parent_class = g_type_class_ref(e_plugin_get_type()); - type = g_type_register_static(e_plugin_get_type(), "EPluginLib", &info, 0); - } - - return type; -} - -/* ********************************************************************** */ - -static int -eph_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) -{ - eph->plugin = ep; - - return 0; -} - -static void -eph_enable(EPluginHook *eph, int state) -{ - /* NOOP */ -} - -static void -eph_finalise(GObject *o) -{ - ((GObjectClass *)eph_parent_class)->finalize((GObject *)o); -} - -static void -eph_class_init(EPluginHookClass *klass) -{ - ((GObjectClass *)klass)->finalize = eph_finalise; - klass->construct = eph_construct; - klass->enable = eph_enable; -} - -/** - * e_plugin_hook_get_type: - * - * Standard GObject function to retrieve the EPluginHook type. Since - * EPluginHook is an abstract class, this is only used to subclass it. - * - * Return value: The EPluginHook type. - **/ -GType -e_plugin_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EPluginHookClass), NULL, NULL, (GClassInitFunc) eph_class_init, NULL, NULL, - sizeof(EPluginHook), 0, (GInstanceInitFunc) NULL, - }; - - eph_parent_class = g_type_class_ref(G_TYPE_OBJECT); - type = g_type_register_static(G_TYPE_OBJECT, "EPluginHook", &info, 0); - } - - return type; -} - -/** - * e_plugin_hook_enable: Set hook enabled state. - * @eph: - * @state: - * - * Set the enabled state of the plugin hook. This is called by the - * plugin code. - * - * THIS IS NOT FULY IMEPLEMENTED YET - **/ -void -e_plugin_hook_enable(EPluginHook *eph, int state) -{ - ((EPluginHookClass *)G_OBJECT_GET_CLASS(eph))->enable(eph, state); -} - -/** - * e_plugin_hook_register_type: - * @type: - * - * Register a new plugin hook type with the plugin system. Each type - * must subclass EPluginHook and must override the id member of the - * EPluginHookClass with a unique identification string. - **/ -void -e_plugin_hook_register_type(GType type) -{ - EPluginHookClass *klass, *oldklass; - GSList *l, *plugins; - char *class; - - if (eph_types == NULL) - eph_types = g_hash_table_new(g_str_hash, g_str_equal); - - klass = g_type_class_ref(type); - - oldklass = g_hash_table_lookup(eph_types, (void *)klass->id); - if (oldklass == klass) { - g_type_class_unref(klass); - return; - } else if (oldklass != NULL) { - g_warning("Trying to re-register hook type '%s'", klass->id); - return; - } - - phd(printf("register plugin hook type '%s'\n", klass->id)); - g_hash_table_insert(eph_types, (void *)klass->id, klass); - - /* if we've already loaded a plugin that needed this hook but it didn't exist, re-load it now */ - - if (ep_plugins_pending_hooks - && g_hash_table_lookup_extended(ep_plugins_pending_hooks, klass->id, (void **)&class, (void **)&plugins)) { - struct _plugin_doc *pdoc, *ndoc; - - g_hash_table_remove(ep_plugins_pending_hooks, class); - g_free(class); - for (l = plugins; l; l = g_slist_next(l)) { - EPlugin *ep = l->data; - - ep_load_pending(ep, klass); - } - g_slist_free(plugins); - - /* See if we can now garbage collect the xml definition since its been fully loaded */ - - /* This is all because libxml doesn't refcount! */ - - pdoc = (struct _plugin_doc *)ep_plugin_docs.head; - ndoc = pdoc->next; - while (ndoc) { - if (pdoc->doc) { - int cache = pdoc->plugins != NULL; - - for (l=pdoc->plugin_hooks;!cache && l;l=g_slist_next(l)) - cache |= (((EPlugin *)l->data)->hooks_pending != NULL); - - if (!cache) { - pd(printf("Gargabe collecting plugin description '%s'\n", pdoc->filename)); - e_dlist_remove((EDListNode *)pdoc); - xmlFreeDoc(pdoc->doc); - g_free(pdoc->filename); - g_free(pdoc); - } - } - - pdoc = ndoc; - ndoc = ndoc->next; - } - } -} - -/** - * e_plugin_hook_mask: - * @root: An XML node. - * @map: A zero-fill terminated array of EPluginHookTargeKeys used to - * map a string with a bit value. - * @prop: The property name. - * - * This is a static helper function which looks up a property @prop on - * the XML node @root, and then uses the @map table to convert it into - * a bitmask. The property value is a comma separated list of - * enumeration strings which are indexed into the @map table. - * - * Return value: A bitmask representing the inclusive-or of all of the - * integer values of the corresponding string id's stored in the @map. - **/ -guint32 -e_plugin_hook_mask(xmlNodePtr root, const struct _EPluginHookTargetKey *map, const char *prop) -{ - char *val, *p, *start, c; - guint32 mask = 0; - - val = xmlGetProp(root, prop); - if (val == NULL) - return 0; - - p = val; - do { - start = p; - while (*p && *p != ',') - p++; - c = *p; - *p = 0; - if (start != p) { - int i; - - for (i=0;map[i].key;i++) { - if (!strcmp(map[i].key, start)) { - mask |= map[i].value; - break; - } - } - } - *p++ = c; - } while (c); - - xmlFree(val); - - return mask; -} - -/** - * e_plugin_hook_id: - * @root: - * @map: - * @prop: - * - * This is a static helper function which looks up a property @prop on - * the XML node @root, and then uses the @map table to convert it into - * an integer. - * - * This is used as a helper wherever you need to represent an - * enumerated value in the XML. - * - * Return value: If the @prop value is in @map, then the corresponding - * integer value, if not, then ~0. - **/ -guint32 -e_plugin_hook_id(xmlNodePtr root, const struct _EPluginHookTargetKey *map, const char *prop) -{ - char *val; - int i; - - val = xmlGetProp(root, prop); - if (val == NULL) - return ~0; - - for (i=0;map[i].key;i++) { - if (!strcmp(map[i].key, val)) { - xmlFree(val); - return map[i].value; - } - } - - xmlFree(val); - - return ~0; -} - -/* ********************************************************************** */ -/* Plugin plugin */ - -static void *epth_parent_class; -#define epth ((EPluginTypeHook *)eph) - -static int -epth_load_plugin(void *d) -{ - EPluginHook *eph = d; - GType type; - - epth->idle = 0; - - type = GPOINTER_TO_UINT(e_plugin_invoke(eph->plugin, epth->get_type, eph->plugin)); - if (type != 0) - e_plugin_register_type(type); - - return FALSE; -} - -static int -epth_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) -{ - xmlNodePtr node; - - phd(printf("loading plugin hook\n")); - - if (((EPluginHookClass *)epth_parent_class)->construct(eph, ep, root) == -1) - return -1; - - node = root->children; - while (node) { - if (strcmp(node->name, "plugin-type") == 0) { - epth->get_type = e_plugin_xml_prop(node, "get-type"); - /* We need to run this in an idle handler, - * since at this point the parent EPlugin wont - * be fully initialised ... darn */ - if (epth->get_type) - epth->idle = g_idle_add(epth_load_plugin, epth); - else - g_warning("Plugin type plugin missing get-type callback"); - } - node = node->next; - } - - eph->plugin = ep; - - return 0; -} - -static void -epth_finalise(GObject *o) -{ - EPluginHook *eph = (EPluginHook *)o; - - if (epth->idle != 0) - g_source_remove(epth->idle); - - g_free(epth->get_type); - - ((GObjectClass *)eph_parent_class)->finalize((GObject *)o); -} - -static void -epth_class_init(EPluginHookClass *klass) -{ - ((GObjectClass *)klass)->finalize = epth_finalise; - klass->construct = epth_construct; - - klass->id = "org.gnome.evolution.plugin.type:1.0"; -} - -/** - * e_plugin_type_hook_get_type: - * - * Get the type for the plugin plugin hook. - * - * Return value: The type of the plugin type hook. - **/ -GType -e_plugin_type_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EPluginTypeHookClass), NULL, NULL, (GClassInitFunc) epth_class_init, NULL, NULL, - sizeof(EPluginTypeHook), 0, (GInstanceInitFunc) NULL, - }; - - epth_parent_class = g_type_class_ref(e_plugin_hook_get_type()); - type = g_type_register_static(e_plugin_hook_get_type(), "EPluginTypeHook", &info, 0); - } - - return type; -} diff --git a/e-util/e-plugin.h b/e-util/e-plugin.h deleted file mode 100644 index 7e4bfbc24b..0000000000 --- a/e-util/e-plugin.h +++ /dev/null @@ -1,273 +0,0 @@ - -#ifndef _E_PLUGIN_H -#define _E_PLUGIN_H - -#include <glib.h> -#include <glib-object.h> -#include <libxml/tree.h> - -/* ********************************************************************** */ - -typedef struct _EPlugin EPlugin; -typedef struct _EPluginClass EPluginClass; - -#define E_PLUGIN_CLASSID "org.gnome.evolution.plugin" - -/* Structure to define the author(s) names and addresses */ -typedef struct _EPluginAuthor EPluginAuthor; -struct _EPluginAuthor { - char *name; - char *email; -}; - -/** - * struct _EPlugin - An EPlugin instance. - * - * @object: Superclass. - * @id: Unique identifier for plugin instance. - * @path: Filename where the xml definition resides. - * @hooks_pending: A list hooks which can't yet be loaded. This is - * the xmlNodePtr to the root node of the hook definition. - * @description: A description of the plugin's purpose. - * @name: The name of the plugin. - * @domain: The translation domain for this plugin. - * @hooks: A list of the EPluginHooks this plugin requires. - * @enabled: Whether the plugin is enabled or not. This is not fully - * implemented. - * - * The base EPlugin object is used to represent each plugin directly. - * All of the plugin's hooks are loaded and managed through this - * object. - **/ -struct _EPlugin { - GObject object; - - char *id; - char *path; - GSList *hooks_pending; - - char *description; - char *name; - char *domain; - GSList *hooks; - GSList *authors; /* EPluginAuthor structures */ - - int enabled:1; -}; - -/** - * struct _EPluginClass - - * - * @class: Superclass. - * @type: The plugin type. This is used by the plugin loader to - * determine which plugin object to instantiate to handle the plugin. - * This must be overriden by each subclass to provide a unique name. - * @construct: The construct virtual method scans the XML tree to - * initialise itself. - * @invoke: The invoke virtual method loads the plugin code, resolves - * the function name, and marshals a simple pointer to execute the - * plugin. - * @enable: Virtual method to enable/disable the plugin. - * - * The EPluginClass represents each plugin type. The type of each class is - * registered in a global table and is used to instantiate a - * container for each plugin. - * - * It provides two main functions, to load the plugin definition, and - * to invoke a function. Each plugin class is used to handle mappings - * to different languages. - **/ -struct _EPluginClass { - GObjectClass class; - - const char *type; - - int (*construct)(EPlugin *, xmlNodePtr root); - void *(*invoke)(EPlugin *, const char *name, void *data); - void (*enable)(EPlugin *, int state); -}; - -GType e_plugin_get_type(void); - -int e_plugin_construct(EPlugin *ep, xmlNodePtr root); -void e_plugin_add_load_path(const char *); -int e_plugin_load_plugins(void); -GSList * e_plugin_list_plugins(void); - -void e_plugin_register_type(GType type); - -void *e_plugin_invoke(EPlugin *ep, const char *name, void *data); -void e_plugin_enable(EPlugin *eph, int state); - -/* static helpers */ -/* maps prop or content to 'g memory' */ -char *e_plugin_xml_prop(xmlNodePtr node, const char *id); -char *e_plugin_xml_prop_domain(xmlNodePtr node, const char *id, const char *domain); -int e_plugin_xml_int(xmlNodePtr node, const char *id, int def); -char *e_plugin_xml_content(xmlNodePtr node); -char *e_plugin_xml_content_domain(xmlNodePtr node, const char *domain); - -/* ********************************************************************** */ -#include <gmodule.h> - -typedef struct _EPluginLib EPluginLib; -typedef struct _EPluginLibClass EPluginLibClass; - -/* The callback signature used for epluginlib methods */ -typedef void *(*EPluginLibFunc)(EPluginLib *ep, void *data); -/* The setup method, this will be called when the plugin is - * initialised. In the future it may also be called when the plugin - * is disabled. */ -typedef int (*EPluginLibEnableFunc)(EPluginLib *ep, int enable); - -/** - * struct _EPluginLib - - * - * @plugin: Superclass. - * @location: The filename of the shared object. - * @module: The GModule once it is loaded. - * - * This is a concrete EPlugin class. It loads and invokes dynamically - * loaded libraries using GModule. The shared object isn't loaded - * until the first callback is invoked. - * - * When the plugin is loaded, and if it exists, "e_plugin_lib_enable" - * will be invoked to initialise the - **/ -struct _EPluginLib { - EPlugin plugin; - - char *location; - GModule *module; -}; - -/** - * struct _EPluginLibClass - - * - * @plugin_class: Superclass. - * - * The plugin library needs no additional class data. - **/ -struct _EPluginLibClass { - EPluginClass plugin_class; -}; - -GType e_plugin_lib_get_type(void); - -/* ********************************************************************** */ - -typedef struct _EPluginHook EPluginHook; -typedef struct _EPluginHookClass EPluginHookClass; - -/* utilities for subclasses to use */ -typedef struct _EPluginHookTargetMap EPluginHookTargetMap; -typedef struct _EPluginHookTargetKey EPluginHookTargetKey; - -/** - * struct _EPluginHookTargetKey - - * - * @key: Enumeration value as a string. - * @value: Enumeration value as an integer. - * - * A multi-purpose string to id mapping structure used with various - * helper functions to simplify plugin hook subclassing. - **/ -struct _EPluginHookTargetKey { - const char *key; - guint32 value; -}; - -/** - * struct _EPluginHookTargetMap - - * - * @type: The string id of the target. - * @id: The integer id of the target. Maps directly to the type field - * of the various plugin type target id's. - * @mask_bits: A zero-fill terminated array of EPluginHookTargetKeys. - * - * Used by EPluginHook to define mappings of target type enumerations - * to and from strings. Also used to define the mask option names - * when reading the XML plugin hook definitions. - **/ -struct _EPluginHookTargetMap { - const char *type; - int id; - const struct _EPluginHookTargetKey *mask_bits; /* null terminated array */ -}; - -/** - * struct _EPluginHook - A plugin hook. - * - * @object: Superclass. - * @plugin: The parent object. - * - * An EPluginHook is used as a container for each hook a given plugin - * is listening to. - **/ -struct _EPluginHook { - GObject object; - - struct _EPlugin *plugin; -}; - -/** - * struct _EPluginHookClass - - * - * @class: Superclass. - * @id: The plugin hook type. This must be overriden by each subclass - * and is used as a key when loading hook definitions. This string - * should contain a globally unique name followed by a : and a version - * specification. This is to ensure plugins only hook into hooks with - * the right API. - * @construct: Virtual method used to initialise the object when - * loaded. - * @enable: Virtual method used to enable or disable the hook. - * - * The EPluginHookClass represents each hook type. The type of the - * class is registered in a global table and is used to instantiate a - * container for each hook. - **/ -struct _EPluginHookClass { - GObjectClass class; - - const char *id; - - int (*construct)(EPluginHook *eph, EPlugin *ep, xmlNodePtr root); - void (*enable)(EPluginHook *eph, int state); -}; - -GType e_plugin_hook_get_type(void); - -void e_plugin_hook_register_type(GType type); - -EPluginHook * e_plugin_hook_new(EPlugin *ep, xmlNodePtr root); -void e_plugin_hook_enable(EPluginHook *eph, int state); - -/* static methods */ -guint32 e_plugin_hook_mask(xmlNodePtr root, const struct _EPluginHookTargetKey *map, const char *prop); -guint32 e_plugin_hook_id(xmlNodePtr root, const struct _EPluginHookTargetKey *map, const char *prop); - -/* ********************************************************************** */ - -/* EPluginTypeHook lets a plugin register a new plugin type. - <hook class="org.gnome.evolution.plugin.type:1.0"> - <plugin-type get-type="e_plugin_mono_get_type/> - </hook> -*/ -typedef struct _EPluginTypeHook EPluginTypeHook; -typedef struct _EPluginTypeHookClass EPluginTypeHookClass; - -struct _EPluginTypeHook { - EPluginHook hook; - - char *get_type; - guint idle; -}; - -struct _EPluginTypeHookClass { - EPluginHookClass hook_class; -}; - -GType e_plugin_type_hook_get_type(void); - -#endif /* ! _E_PLUGIN_H */ diff --git a/e-util/e-popup.c b/e-util/e-popup.c deleted file mode 100644 index d812e01d31..0000000000 --- a/e-util/e-popup.c +++ /dev/null @@ -1,942 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkimagemenuitem.h> -#include <gtk/gtkcheckmenuitem.h> -#include <gtk/gtkradiomenuitem.h> -#include <gtk/gtkseparatormenuitem.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkimage.h> - -#include "e-popup.h" - -#include <e-util/e-icon-factory.h> - -#include <libgnome/gnome-i18n.h> - -#define d(x) - -struct _EPopupFactory { - struct _EPopupFactory *next, *prev; - - char *menuid; - EPopupFactoryFunc factory; - void *factory_data; -}; - -/* Used for the "activate" signal callback data to re-map to the api */ -struct _item_node { - struct _item_node *next; /* tree pointers */ - struct _item_node *prev; - struct _item_node *parent; - EDList children; - - struct _item_node *link; /* for freeing */ - - EPopupItem *item; - struct _menu_node *menu; -}; - -/* Stores all the items added */ -struct _menu_node { - struct _menu_node *next, *prev; - - EPopup *popup; - - GSList *menu; - char *domain; - EPopupItemsFunc freefunc; - void *data; - - struct _item_node *items; -}; - -struct _EPopupPrivate { - EDList menus; -}; - -static GObjectClass *ep_parent; - -static void -ep_init(GObject *o) -{ - EPopup *emp = (EPopup *)o; - struct _EPopupPrivate *p; - - p = emp->priv = g_malloc0(sizeof(struct _EPopupPrivate)); - - e_dlist_init(&p->menus); -} - -static void -ep_finalise(GObject *o) -{ - EPopup *emp = (EPopup *)o; - struct _EPopupPrivate *p = emp->priv; - struct _menu_node *mnode, *nnode; - - mnode = (struct _menu_node *)p->menus.head; - nnode = mnode->next; - while (nnode) { - struct _item_node *inode; - - if (mnode->freefunc) - mnode->freefunc(emp, mnode->menu, mnode->data); - - g_free(mnode->domain); - - /* free item activate callback data */ - inode = mnode->items; - while (inode) { - struct _item_node *nnode = inode->link; - - g_free(inode); - inode = nnode; - } - - g_free(mnode); - mnode = nnode; - nnode = nnode->next; - } - - if (emp->target) - e_popup_target_free(emp, emp->target); - - g_free(emp->menuid); - - g_free(p); - - ((GObjectClass *)ep_parent)->finalize(o); -} - -static void -ep_target_free(EPopup *ep, EPopupTarget *t) -{ - g_free(t); - g_object_unref(ep); -} - -static void -ep_class_init(GObjectClass *klass) -{ - d(printf("EPopup class init %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - klass->finalize = ep_finalise; - ((EPopupClass *)klass)->target_free = ep_target_free; -} - -static void -ep_base_init(GObjectClass *klass) -{ - e_dlist_init(&((EPopupClass *)klass)->factories); -} - -/** - * e_popup_get_type: - * - * Standard GObject type function. - * - * Return value: The EPopup object type. - **/ -GType -e_popup_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EPopupClass), - (GBaseInitFunc)ep_base_init, NULL, - (GClassInitFunc)ep_class_init, NULL, NULL, - sizeof(EPopup), 0, - (GInstanceInitFunc)ep_init - }; - ep_parent = g_type_class_ref(G_TYPE_OBJECT); - type = g_type_register_static(G_TYPE_OBJECT, "EPopup", &info, 0); - } - - return type; -} - -/** - * e_popup_new - Create an targetless popup menu manager. - * @menuid: Unique ID for this menu. - * - * Create a targetless popup menu object. This can be used as a - * helper for creating popup menu's with no target. Such popup menu's - * wont be very pluggable. - * - * Return value: A new EPopup. - **/ -EPopup *e_popup_new(const char *menuid) -{ - EPopup *ep = g_object_new(e_popup_get_type(), NULL); - - e_popup_construct(ep, menuid); - - return ep; -} - -/** - * e_popup_construct: - * @ep: An instantiated but uninitialised EPopup. - * @menuid: The menu identifier. - * - * Construct the base popup instance with standard parameters. - * - * Return value: Returns @ep. - **/ -EPopup *e_popup_construct(EPopup *ep, const char *menuid) -{ - ep->menuid = g_strdup(menuid); - - return ep; -} - -/** - * e_popup_add_items: - * @emp: An EPopup derived object. - * @items: A list of EPopupItem's to add to the current popup menu. - * @domain: Translation domain for translating labels. - * @freefunc: A function which will be called when the items are no - * longer needed. - * @data: user-data passed to @freefunc, and passed to all activate - * methods. - * - * Add new EPopupItems to the menus. Any with the same path - * will override previously defined menu items, at menu building - * time. This may be called any number of times before the menu is - * built to create a complex heirarchy of menus. - **/ -void -e_popup_add_items(EPopup *emp, GSList *items, const char *domain, EPopupItemsFunc freefunc, void *data) -{ - struct _menu_node *node; - - node = g_malloc0(sizeof(*node)); - node->menu = items; - node->domain = g_strdup(domain); - node->freefunc = freefunc; - node->data = data; - node->popup = emp; - - e_dlist_addtail(&emp->priv->menus, (EDListNode *)node); -} - -static void -ep_add_static_items(EPopup *emp) -{ - struct _EPopupFactory *f; - EPopupClass *klass = (EPopupClass *)G_OBJECT_GET_CLASS(emp); - - if (emp->menuid == NULL || emp->target == NULL) - return; - - /* setup the menu itself */ - f = (struct _EPopupFactory *)klass->factories.head; - while (f->next) { - if (f->menuid == NULL - || !strcmp(f->menuid, emp->menuid)) { - f->factory(emp, f->factory_data); - } - f = f->next; - } -} - -static int -ep_cmp(const void *ap, const void *bp) -{ - struct _item_node *a = *((void **)ap); - struct _item_node *b = *((void **)bp); - - return strcmp(a->item->path, b->item->path); -} - -static void -ep_activate(GtkWidget *w, struct _item_node *inode) -{ - EPopupItem *item = inode->item; - guint32 type = item->type & E_POPUP_TYPE_MASK; - - /* this is a bit hackish, use the item->type to transmit the - active state, presumes we can write to this memory ... The - alternative is the EMenu idea of different callbacks, but - thats painful for breaking type-safety on callbacks */ - - if (type == E_POPUP_TOGGLE || type == E_POPUP_RADIO) { - if (gtk_check_menu_item_get_active((GtkCheckMenuItem *)w)) - item->type |= E_POPUP_ACTIVE; - else - item->type &= ~E_POPUP_ACTIVE; - } - - item->activate(inode->menu->popup, item, inode->menu->data); -} - -static void -ep_prune_tree(EDList *head) -{ - struct _item_node *inode, *nnode; - - /* need to do two scans, first to find out if the subtree's - * are empty, then to remove any unecessary bars which may - * become unecessary after the first scan */ - - inode = (struct _item_node *)head->head; - nnode = inode->next; - while (nnode) { - struct _EPopupItem *item = inode->item; - - ep_prune_tree(&inode->children); - - if ((item->type & E_POPUP_TYPE_MASK) == E_POPUP_SUBMENU) { - if (e_dlist_empty(&inode->children)) - e_dlist_remove((EDListNode *)inode); - } - - inode = nnode; - nnode = nnode->next; - } - - inode = (struct _item_node *)head->head; - nnode = inode->next; - while (nnode) { - struct _EPopupItem *item = inode->item; - - if ((item->type & E_POPUP_TYPE_MASK) == E_POPUP_BAR) { - if (inode->prev->prev == NULL - || nnode->next == NULL - || (nnode->item->type & E_POPUP_TYPE_MASK) == E_POPUP_BAR) - e_dlist_remove((EDListNode *)inode); - } - - inode = nnode; - nnode = nnode->next; - } -} - -static GtkMenu * -ep_build_tree(struct _item_node *inode, guint32 mask) -{ - struct _item_node *nnode; - GtkMenu *topmenu; - GHashTable *group_hash = g_hash_table_new(g_str_hash, g_str_equal); - - topmenu = (GtkMenu *)gtk_menu_new(); - - nnode = inode->next; - while (nnode) { - GtkWidget *label; - struct _EPopupItem *item = inode->item; - GtkMenuItem *menuitem; - - switch (item->type & E_POPUP_TYPE_MASK) { - case E_POPUP_ITEM: - if (item->image) { - GtkWidget *image; - - /* work-around e-icon-factory not doing GTK_STOCK stuff */ - if (strncmp((char *)item->image, "gtk-", 4) == 0) - image = gtk_image_new_from_stock((char *)item->image, GTK_ICON_SIZE_MENU); - else - image = e_icon_factory_get_image((char *)item->image, E_ICON_SIZE_MENU); - - gtk_widget_show(image); - menuitem = (GtkMenuItem *)gtk_image_menu_item_new(); - gtk_image_menu_item_set_image((GtkImageMenuItem *)menuitem, image); - } else { - menuitem = (GtkMenuItem *)gtk_menu_item_new(); - } - break; - case E_POPUP_TOGGLE: - menuitem = (GtkMenuItem *)gtk_check_menu_item_new(); - gtk_check_menu_item_set_active((GtkCheckMenuItem *)menuitem, item->type & E_POPUP_ACTIVE); - break; - case E_POPUP_RADIO: { - char *ppath = inode->parent?inode->parent->item->path:NULL; - - menuitem = (GtkMenuItem *)gtk_radio_menu_item_new(g_hash_table_lookup(group_hash, ppath)); - g_hash_table_insert(group_hash, ppath, gtk_radio_menu_item_get_group((GtkRadioMenuItem *)menuitem)); - gtk_check_menu_item_set_active((GtkCheckMenuItem *)menuitem, item->type & E_POPUP_ACTIVE); - break; } - case E_POPUP_IMAGE: - menuitem = (GtkMenuItem *)gtk_image_menu_item_new(); - gtk_image_menu_item_set_image((GtkImageMenuItem *)menuitem, item->image); - break; - case E_POPUP_SUBMENU: { - GtkMenu *submenu = ep_build_tree((struct _item_node *)inode->children.head, mask); - - menuitem = (GtkMenuItem *)gtk_menu_item_new(); - gtk_menu_item_set_submenu(menuitem, (GtkWidget *)submenu); - break; } - case E_POPUP_BAR: - menuitem = (GtkMenuItem *)gtk_separator_menu_item_new(); - break; - default: - continue; - } - - if (item->label) { - label = gtk_label_new_with_mnemonic(dgettext(inode->menu->domain, item->label)); - gtk_misc_set_alignment((GtkMisc *)label, 0.0, 0.5); - gtk_widget_show(label); - gtk_container_add((GtkContainer *)menuitem, label); - } - - if (item->activate) - g_signal_connect(menuitem, "activate", G_CALLBACK(ep_activate), inode); - - gtk_menu_shell_append((GtkMenuShell *)topmenu, (GtkWidget *)menuitem); - - if (item->enable & mask) - gtk_widget_set_sensitive((GtkWidget *)menuitem, FALSE); - - gtk_widget_show((GtkWidget *)menuitem); - - inode = nnode; - nnode = nnode->next; - } - - g_hash_table_destroy(group_hash); - - return topmenu; -} - -/** - * e_popup_create: - * @emp: An EPopup derived object. - * @target: popup target, if set, then factories will be invoked. - * This is then owned by the menu. - * @mask: If supplied, overrides the target specified mask or provides - * a mask if no target is supplied. Used to enable or show menu - * items. - * - * All of the menu items registered on @emp are sorted by path, and - * then converted into a menu heirarchy. - * - * - * Return value: A GtkMenu which can be popped up when ready. - **/ -GtkMenu * -e_popup_create_menu(EPopup *emp, EPopupTarget *target, guint32 mask) -{ - struct _EPopupPrivate *p = emp->priv; - struct _menu_node *mnode, *nnode; - GPtrArray *items = g_ptr_array_new(); - GSList *l; - GString *ppath = g_string_new(""); - GHashTable *tree_hash = g_hash_table_new(g_str_hash, g_str_equal); - EDList head = E_DLIST_INITIALISER(head); - int i; - - emp->target = target; - ep_add_static_items(emp); - - if (target && mask == 0) - mask = target->mask; - - /* Note: This code vastly simplifies memory management by - * keeping a linked list of all temporary tree nodes on the - * menu's tree until the epopup is destroyed */ - - /* FIXME: need to override old ones with new names */ - mnode = (struct _menu_node *)p->menus.head; - nnode = mnode->next; - while (nnode) { - for (l=mnode->menu; l; l = l->next) { - struct _item_node *inode; - struct _EPopupItem *item = l->data; - - /* we calculate bar/submenu visibility based on calculated set */ - if (item->visible) { - if ((item->type & E_POPUP_TYPE_MASK) != E_POPUP_BAR - && (item->type & E_POPUP_TYPE_MASK) != E_POPUP_SUBMENU - && item->visible & mask) { - d(printf("%s not visible\n", item->path)); - continue; - } - } - - inode = g_malloc0(sizeof(*inode)); - inode->item = l->data; - inode->menu = mnode; - e_dlist_init(&inode->children); - inode->link = mnode->items; - mnode->items = inode; - - g_ptr_array_add(items, inode); - } - mnode = nnode; - nnode = nnode->next; - } - - /* this makes building the tree in the right order easier */ - qsort(items->pdata, items->len, sizeof(items->pdata[0]), ep_cmp); - - /* create tree structure */ - for (i=0;i<items->len;i++) { - struct _item_node *inode = items->pdata[i], *pnode; - struct _EPopupItem *item = inode->item; - const char *tmp; - - g_string_truncate(ppath, 0); - tmp = strrchr(item->path, '/'); - if (tmp) { - g_string_append_len(ppath, item->path, tmp-item->path); - pnode = g_hash_table_lookup(tree_hash, ppath->str); - if (pnode == NULL) { - g_warning("No parent defined for node '%s'", item->path); - e_dlist_addtail(&head, (EDListNode *)inode); - } else { - e_dlist_addtail(&pnode->children, (EDListNode *)inode); - inode->parent = pnode; - } - } else { - e_dlist_addtail(&head, (EDListNode *)inode); - } - - if ((item->type & E_POPUP_TYPE_MASK) == E_POPUP_SUBMENU) - g_hash_table_insert(tree_hash, item->path, inode); - } - - g_string_free(ppath, TRUE); - g_ptr_array_free(items, TRUE); - g_hash_table_destroy(tree_hash); - - /* prune unnecessary items */ - ep_prune_tree(&head); - - /* & build it */ - return ep_build_tree((struct _item_node *)head.head, mask); -} - -static void -ep_popup_done(GtkWidget *w, EPopup *emp) -{ - gtk_widget_destroy(w); - if (emp->target) { - e_popup_target_free(emp, emp->target); - emp->target = NULL; - } - g_object_unref(emp); -} - -/** - * e_popup_create_menu_once: - * @emp: EPopup, once the menu is shown, this cannot be - * considered a valid pointer. - * @target: If set, the target of the selection. Static menu - * items will be added. The target will be freed once complete. - * @mask: Enable/disable and visibility mask. - * - * Like popup_create_menu, but automatically sets up the menu - * so that it is destroyed once a selection takes place, and - * the EPopup is unreffed. This is the normal entry point as it - * automates most memory management for popup menus. - * - * Return value: A menu, to popup. - **/ -GtkMenu * -e_popup_create_menu_once(EPopup *emp, EPopupTarget *target, guint32 mask) -{ - GtkMenu *menu; - - menu = e_popup_create_menu(emp, target, mask); - - g_signal_connect(menu, "selection_done", G_CALLBACK(ep_popup_done), emp); - - return menu; -} - -/* ********************************************************************** */ - -/** - * e_popup_class_add_factory: - * @klass: The EPopup derived class which you're interested in. - * @menuid: The identifier of the menu you're interested in, or NULL - * to be called for all menus on this class. - * @func: The factory called when the menu @menuid is being created. - * @data: User-data for the factory callback. - * - * This is a class-static method used to register factory callbacks - * against specific menu's. - * - * The factory method will be invoked before the menu is created. - * This way, the factory may add any additional menu items it wishes - * based on the context supplied in the @target. - * - * Return value: A handle to the factory which can be used to remove - * it later. - **/ -EPopupFactory * -e_popup_class_add_factory(EPopupClass *klass, const char *menuid, EPopupFactoryFunc func, void *data) -{ - struct _EPopupFactory *f = g_malloc0(sizeof(*f)); - - f->menuid = g_strdup(menuid); - f->factory = func; - f->factory_data = data; - e_dlist_addtail(&klass->factories, (EDListNode *)f); - - return f; -} - -/** - * e_popup_class_remove_factory: - * @klass: The EPopup derived class. - * @f: The factory handle returned by e_popup_class_add_factory(). - * - * Remove a popup menu factory. If it has not been added, or it has - * already been removed, then the result is undefined (i.e. it will - * crash). - * - * Generally factories are static for the life of the application, and - * so do not need to be removed. - **/ -void -e_popup_class_remove_factory(EPopupClass *klass, EPopupFactory *f) -{ - e_dlist_remove((EDListNode *)f); - g_free(f->menuid); - g_free(f); -} - -/** - * e_popup_target_new: - * @ep: An EPopup derived object. - * @type: type, defined by the implementing class. - * @size: The size of memory to allocate for the target. It must be - * equal or greater than the size of EPopupTarget. - * - * Allocate a new popup target suitable for this popup type. - **/ -void *e_popup_target_new(EPopup *ep, int type, size_t size) -{ - EPopupTarget *t; - - g_assert(size >= sizeof(EPopupTarget)); - - t = g_malloc0(size); - t->popup = ep; - g_object_ref(ep); - t->type = type; - - return t; -} - -/** - * e_popup_target_free: - * @ep: An EPopup derived object. - * @o: The target, previously allocated by e_popup_target_new(). - * - * Free the target against @ep. Note that targets are automatically - * freed if they are passed to the menu creation functions, so this is - * only required if you are using the target for other purposes. - **/ -void -e_popup_target_free(EPopup *ep, void *o) -{ - EPopupTarget *t = o; - - ((EPopupClass *)G_OBJECT_GET_CLASS(ep))->target_free(ep, t); -} - -/* ********************************************************************** */ - -/* Popup menu plugin handler */ - -/* -<e-plugin - class="org.gnome.mail.plugin.popup:1.0" - id="org.gnome.mail.plugin.popup.item:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelimap.so" - name="imap" - description="IMAP4 and IMAP4v1 mail store"> - <hook class="org.gnome.mail.popupMenu:1.0" - handler="HandlePopup"> - <menu id="any" target="select" factory="funcspec"?> - <item - type="item|toggle|radio|image|submenu|bar" - active - path="foo/bar" - label="label" - icon="foo" - visible="select_one" - activate="ep_view_emacs"/> * - </menu> - </extension> - -*/ - -static void *emph_parent_class; -#define emph ((EPopupHook *)eph) - -/* must have 1:1 correspondence with e-popup types in order */ -static const EPluginHookTargetKey emph_item_types[] = { - { "item", E_POPUP_ITEM }, - { "toggle", E_POPUP_TOGGLE }, - { "radio", E_POPUP_RADIO }, - { "image", E_POPUP_IMAGE }, - { "submenu", E_POPUP_SUBMENU }, - { "bar", E_POPUP_BAR }, - { 0 } -}; - -static void -emph_popup_activate(EPopup *ep, EPopupItem *item, void *data) -{ - EPopupHook *hook = data; - - e_plugin_invoke(hook->hook.plugin, (char *)item->user_data, ep->target); -} - -static void -emph_popup_factory(EPopup *emp, void *data) -{ - struct _EPopupHookMenu *menu = data; - - d(printf("popup factory called %s mask %08x\n", menu->id?menu->id:"all menus", emp->target->mask)); - - /* If we're disabled, then don't add the menu's. */ - if (emp->target->type != menu->target_type - || !menu->hook->hook.plugin->enabled) - return; - - if (menu->items) - e_popup_add_items(emp, menu->items, menu->hook->hook.plugin->domain, NULL, menu->hook); - - if (menu->factory) - e_plugin_invoke(menu->hook->hook.plugin, menu->factory, emp->target); -} - -static void -emph_free_item(struct _EPopupItem *item) -{ - g_free(item->path); - g_free(item->label); - g_free(item->image); - g_free(item->user_data); - g_free(item); -} - -static void -emph_free_menu(struct _EPopupHookMenu *menu) -{ - g_slist_foreach(menu->items, (GFunc)emph_free_item, NULL); - g_slist_free(menu->items); - - g_free(menu->factory); - g_free(menu->id); - g_free(menu); -} - -static struct _EPopupItem * -emph_construct_item(EPluginHook *eph, EPopupHookMenu *menu, xmlNodePtr root, EPopupHookTargetMap *map) -{ - struct _EPopupItem *item; - - d(printf(" loading menu item\n")); - item = g_malloc0(sizeof(*item)); - if ((item->type = e_plugin_hook_id(root, emph_item_types, "type")) == -1 - || item->type == E_POPUP_IMAGE) - goto error; - item->path = e_plugin_xml_prop(root, "path"); - item->label = e_plugin_xml_prop_domain(root, "label", eph->plugin->domain); - item->image = e_plugin_xml_prop(root, "icon"); - item->visible = e_plugin_hook_mask(root, map->mask_bits, "visible"); - item->enable = e_plugin_hook_mask(root, map->mask_bits, "enable"); - item->user_data = e_plugin_xml_prop(root, "activate"); - - item->activate = emph_popup_activate; - - if (item->user_data == NULL) - goto error; - - d(printf(" path=%s\n", item->path)); - d(printf(" label=%s\n", item->label)); - - return item; -error: - d(printf("error!\n")); - emph_free_item(item); - return NULL; -} - -static struct _EPopupHookMenu * -emph_construct_menu(EPluginHook *eph, xmlNodePtr root) -{ - struct _EPopupHookMenu *menu; - xmlNodePtr node; - EPopupHookTargetMap *map; - EPopupHookClass *klass = (EPopupHookClass *)G_OBJECT_GET_CLASS(eph); - char *tmp; - - d(printf(" loading menu\n")); - menu = g_malloc0(sizeof(*menu)); - menu->hook = (EPopupHook *)eph; - - tmp = xmlGetProp(root, "target"); - if (tmp == NULL) - goto error; - map = g_hash_table_lookup(klass->target_map, tmp); - xmlFree(tmp); - if (map == NULL) - goto error; - - menu->target_type = map->id; - menu->id = e_plugin_xml_prop(root, "id"); - if (menu->id == NULL) { - g_warning("Plugin '%s' missing 'id' field in popup for '%s'\n", eph->plugin->name, - ((EPluginHookClass *)G_OBJECT_GET_CLASS(eph))->id); - goto error; - } - - menu->factory = e_plugin_xml_prop(root, "factory"); - - node = root->children; - while (node) { - if (0 == strcmp(node->name, "item")) { - struct _EPopupItem *item; - - item = emph_construct_item(eph, menu, node, map); - if (item) - menu->items = g_slist_append(menu->items, item); - } - node = node->next; - } - - return menu; -error: - emph_free_menu(menu); - return NULL; -} - -static int -emph_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) -{ - xmlNodePtr node; - EPopupClass *klass; - - d(printf("loading popup hook\n")); - - if (((EPluginHookClass *)emph_parent_class)->construct(eph, ep, root) == -1) - return -1; - - klass = ((EPopupHookClass *)G_OBJECT_GET_CLASS(eph))->popup_class; - - node = root->children; - while (node) { - if (strcmp(node->name, "menu") == 0) { - struct _EPopupHookMenu *menu; - - menu = emph_construct_menu(eph, node); - if (menu) { - e_popup_class_add_factory(klass, menu->id, emph_popup_factory, menu); - emph->menus = g_slist_append(emph->menus, menu); - } - } - node = node->next; - } - - eph->plugin = ep; - - return 0; -} - -static void -emph_finalise(GObject *o) -{ - EPluginHook *eph = (EPluginHook *)o; - - g_slist_foreach(emph->menus, (GFunc)emph_free_menu, NULL); - g_slist_free(emph->menus); - - ((GObjectClass *)emph_parent_class)->finalize(o); -} - -static void -emph_class_init(EPluginHookClass *klass) -{ - ((GObjectClass *)klass)->finalize = emph_finalise; - klass->construct = emph_construct; - - /* this is actually an abstract implementation but list it anyway */ - klass->id = "org.gnome.evolution.popup:1.0"; - - d(printf("EPopupHook: init class %p '%s'\n", klass, g_type_name(((GObjectClass *)klass)->g_type_class.g_type))); - - ((EPopupHookClass *)klass)->target_map = g_hash_table_new(g_str_hash, g_str_equal); - ((EPopupHookClass *)klass)->popup_class = g_type_class_ref(e_popup_get_type()); -} - -/** - * e_popup_hook_get_type: - * - * Standard GObject function to get the object type. Used to subclass - * EPopupHook. - * - * Return value: The type of the popup hook class. - **/ -GType -e_popup_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EPopupHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL, - sizeof(EPopupHook), 0, (GInstanceInitFunc) NULL, - }; - - emph_parent_class = g_type_class_ref(e_plugin_hook_get_type()); - type = g_type_register_static(e_plugin_hook_get_type(), "EPopupHook", &info, 0); - } - - return type; -} - -/** - * e_popup_hook_class_add_target_map: - * @klass: The derived EPopupHook class. - * @map: A map used to describe a single EPopupTarget type for this - * class. - * - * Add a target map to a concrete derived class of EPopup. The target - * map enumerates a single target type and the enable mask bit names, - * so that the type can be loaded automatically by the EPopup class. - **/ -void e_popup_hook_class_add_target_map(EPopupHookClass *klass, const EPopupHookTargetMap *map) -{ - g_hash_table_insert(klass->target_map, (void *)map->type, (void *)map); -} diff --git a/e-util/e-popup.h b/e-util/e-popup.h deleted file mode 100644 index 9da06335f5..0000000000 --- a/e-util/e-popup.h +++ /dev/null @@ -1,304 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michel Zucchi <notzed@ximian.com> - * - * Copyright 2003 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __E_POPUP_H__ -#define __E_POPUP_H__ - -#include <glib-object.h> -#include "libedataserver/e-msgport.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* This is an abstract popup menu management/merging class. - - To implement your own popup menu system, just create your own - target types and implement the target free method. */ - -typedef struct _EPopup EPopup; -typedef struct _EPopupClass EPopupClass; - -typedef struct _EPopupItem EPopupItem; -typedef struct _EPopupFactory EPopupFactory; /* anonymous type */ -typedef struct _EPopupTarget EPopupTarget; - -typedef void (*EPopupActivateFunc)(EPopup *ep, EPopupItem *item, void *data); -typedef void (*EPopupFactoryFunc)(EPopup *emp, void *data); -typedef void (*EPopupItemsFunc)(EPopup *ep, GSList *items, void *data); - -/** - * enum _e_popup_t - Popup item type enumeration. - * @E_POPUP_ITEM: A simple menu item. - * @E_POPUP_TOGGLE: A toggle menu item. - * @E_POPUP_RADIO: A radio menu item. Note that the radio group is - * global for the entire (sub) menu. i.e. submenu's must be used to - * separate radio button menu items. - * @E_POPUP_IMAGE: A &GtkImage menu item. In this case the @image - * field of &struct _EPopupItem points to the &GtkImage directly. - * @E_POPUP_SUBMENU: A sub-menu header. It is up to the application - * to define the @path properly so that the submenu comes before the - * submenu items. - * @E_POPUP_BAR: A menu separator bar. - * @E_POPUP_TYPE_MASK: Mask used to separate item type from option bits. - * @E_POPUP_ACTIVE: An option bit to signify that the radio button or - * toggle button is active. - */ -enum _e_popup_t { - E_POPUP_ITEM = 0, - E_POPUP_TOGGLE, - E_POPUP_RADIO, - E_POPUP_IMAGE, - E_POPUP_SUBMENU, - E_POPUP_BAR, - E_POPUP_TYPE_MASK = 0xffff, - E_POPUP_ACTIVE = 0x10000, -}; - -/* FIXME: activate passes back no context data apart from that provided. - FIXME: It should pass the target at the least. The menu widget is - useless */ - -/** - * struct _EPopupItem - A popup menu item definition. - * @type: The type of the popup. See the &enum _epopup_t definition - * for possible values. - * @path: An absolute path, which when sorted using a simple ASCII - * sort, will put the menu item in the right place in the menu - * heirarchy. '/' is used to separate menus from submenu items. - * @label: The text of the menyu item. - * @activate: A function conforming to &EPopupActivateFunc which will - * be called when the menu item is activated. - * @user_data: Extra per-item user-data available to the - * application. This is not passed to the @data field of @activate. - * @image: For most types, the name of the icon in the icon theme to - * display next to the menu item, if required. For the %E_POPUP_IMAGE - * type, it is a pointer to the &GtkWidget instead. - * @visible: Visibility mask. Used together with the &EPopupTarget mask - * to determine if the item should be part of the menu or not. - * @enable: Sensitivity mask. Similar to the visibility mask, but - * currently unimplemented. - * @popup: Used by e-popup to reference the parent object from - * callbacks. - * - * The EPopupItem defines a single popup menu item, or submenu item, - * or menu separator based on the @type. Any number of these are - * merged at popup display type to form the popup menu. - * - * The application may extend this structure using simple C structure - * containers to add any additional fields it may require. - */ -struct _EPopupItem { - enum _e_popup_t type; - char *path; /* absolute path! must sort ascii-lexographically into the right spot */ - char *label; - EPopupActivateFunc activate; - void *user_data; /* user data, not passed directly to @activate */ - void *image; /* char* for item type, GtkWidget * for image type */ - guint32 visible; /* visibility mask */ - guint32 enable; /* sensitivity mask */ -}; - -/** - * struct EPopupTarget - A popup menu target definition. - * - * @popup: The parent popup object, used for virtual methods on the target. - * @widget: The parent widget, where available. In some cases the - * type of this object is part of the published api for the target. - * @type: The target type. This will be defined by the - * implementation. - * @mask: Target mask. This is used to sensitise and show items - * based on their definition in EPopupItem. - * - * An EPopupTarget defines the context for a specific popup menu - * instance. The root target object is abstract, and it is up to - * sub-classes of &EPopup to define the additional fields required to - * make it usable. - */ -struct _EPopupTarget { - struct _EPopup *popup; /* used for virtual methods */ - - struct _GtkWidget *widget; /* used if you need a parent toplevel, if available */ - guint32 type; /* targe type, for implementors */ - - guint32 mask; /* depends on type, visibility mask */ - - /* implementation fields follow */ -}; - -/** - * struct _EPopup - A Popup menu manager. - * - * @object: Superclass, GObject. - * @priv: Private data. - * @menuid: The id of this menu instance. - * @target: The current target during the display of the popup menu. - * - * The EPopup manager object. Each popup menu is built using this - * one-off object which is created each time the popup is invoked. - */ -struct _EPopup { - GObject object; - - struct _EPopupPrivate *priv; - - char *menuid; - - EPopupTarget *target; -}; - -/** - * struct _EPopupClass - - * - * @object_class: Superclass type. - * @factories: A list of factories for this particular class of popup - * menu. - * @target_free: Virtual method to free the popup target. The base - * class frees the allocation and unrefs the popup pointer - * structure. - * - * The EPopup class definition. This should be sub-classed for each - * component that wants to provide hookable popup menus. The - * sub-class only needs to know how to allocate and free the various target - * types it supports. - */ -struct _EPopupClass { - GObjectClass object_class; - - EDList factories; - - void (*target_free)(EPopup *ep, EPopupTarget *t); -}; - -GType e_popup_get_type(void); - -EPopup *e_popup_new(const char *menuid); - -/* Static class methods */ -EPopupFactory *e_popup_class_add_factory(EPopupClass *klass, const char *menuid, EPopupFactoryFunc func, void *data); -void e_popup_class_remove_factory(EPopupClass *klass, EPopupFactory *f); - -EPopup *e_popup_construct(EPopup *, const char *menuid); - -void e_popup_add_items(EPopup *, GSList *items, const char *domain, EPopupItemsFunc freefunc, void *data); - -void e_popup_add_static_items(EPopup *emp, EPopupTarget *target); -/* do not call e_popup_create_menu, it can leak structures if not used right */ -struct _GtkMenu *e_popup_create_menu(EPopup *, EPopupTarget *, guint32 mask); -struct _GtkMenu *e_popup_create_menu_once(EPopup *emp, EPopupTarget *, guint32 mask); - -void *e_popup_target_new(EPopup *, int type, size_t size); -void e_popup_target_free(EPopup *, void *); - -/* ********************************************************************** */ - -/* popup plugin target, they are closely integrated */ - -/* To implement a basic popup menu plugin, you just need to subclass - this and initialise the class target type tables */ - -#include "e-util/e-plugin.h" - -typedef struct _EPopupHookMenu EPopupHookMenu; -typedef struct _EPopupHook EPopupHook; -typedef struct _EPopupHookClass EPopupHookClass; - -typedef struct _EPluginHookTargetMap EPopupHookTargetMap; -typedef struct _EPluginHookTargetKey EPopupHookTargetMask; - -typedef void (*EPopupHookFunc)(struct _EPlugin *plugin, EPopupTarget *target); - -/** - * struct _EPopupHookMenu - - * - * @hook: Parent pointer. - * @id: The identifier of the menu to which these items belong. - * @target_type: The target number of the type of target these menu - * items expect. It will generally also be defined by the menu id. - * @items: A list of EPopupItems. - * @factory: If supplied, a function to call - * - * The structure used to keep track of all of the items that a plugin - * wishes to add to a given menu. This is used internally by a factory - * method set on EPlugin to add the right menu items to a given menu. - */ -struct _EPopupHookMenu { - struct _EPopupHook *hook; /* parent pointer */ - char *id; /* target menu id for these menu items */ - int target_type; /* target type of this menu */ - GSList *items; /* items to add to menu */ - char *factory; /* optional factory to call for adding menu items */ -}; - -/** - * struct _EPopupHook - A popup menu hook. - * - * @hook: Superclass. - * @menus: A list of EPopupHookMenus, for all menus registered on - * this hook type. - * - * The EPopupHook class loads and manages the meta-data required to - * map plugin definitions to physical menus. - */ -struct _EPopupHook { - EPluginHook hook; - - GSList *menus; -}; - -/** - * struct _EPopupHookClass - - * - * @hook_class: Superclass. - * @target_map: Table of EPluginHookTargetMaps which enumerate the - * target types and enable bits of the implementing class. - * @popup_class: The EPopupClass of the corresponding popup manager - * for the implementing class. - * - * The EPopupHookClass is a concrete class, however it is empty on its - * own. It needs to be sub-classed and initialised appropriately. - * - * The EPluginHookClass.id must be set to the name and version of the - * hook handler itself. The @target_map must be initialised with the - * data required to enumerate the target types and enable flags - * supported by the implementing class. - */ -struct _EPopupHookClass { - EPluginHookClass hook_class; - - /* EPopupHookTargetMap by .type */ - GHashTable *target_map; - /* the popup class these popups belong to */ - EPopupClass *popup_class; -}; - -GType e_popup_hook_get_type(void); - -/* for implementors */ -void e_popup_hook_class_add_target_map(EPopupHookClass *klass, const EPopupHookTargetMap *); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_POPUP_H__ */ diff --git a/e-util/e-print.c b/e-util/e-print.c deleted file mode 100644 index 63d7bf3e1e..0000000000 --- a/e-util/e-print.c +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-print.c - Uniform print setting/dialog routines for Evolution - * - * Copyright (C) 2005 Novell, Inc. - * - * Authors: JP Rosevear <jpr@novell.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <stdio.h> -#include <string.h> -#include <gconf/gconf-client.h> -#include "e-print.h" - -#define PRINT_CONFIG_KEY "/apps/evolution/shell/print_config" - -GnomePrintConfig * -e_print_load_config (void) -{ - GConfClient *gconf; - GnomePrintConfig *config; - char *str; - - gconf = gconf_client_get_default (); - str = gconf_client_get_string (gconf, PRINT_CONFIG_KEY, NULL); - g_object_unref (gconf); - - if (!str) - return gnome_print_config_default (); - - config = gnome_print_config_from_string (str, 0); - - /* Its unlikely people will want to preserve this too often */ - gnome_print_config_set_int (config, GNOME_PRINT_KEY_NUM_COPIES, 1); - gnome_print_config_set_boolean (config, GNOME_PRINT_KEY_COLLATE, FALSE); - - return config; -} - - -void -e_print_save_config (GnomePrintConfig *config) -{ - GConfClient *gconf; - char *str; - - str = gnome_print_config_to_string (config, 0); - - gconf = gconf_client_get_default (); - gconf_client_set_string (gconf, PRINT_CONFIG_KEY, str, NULL); - g_object_unref (gconf); -} - -static void -print_dialog_response(GtkWidget *widget, int resp, gpointer data) -{ - if (resp == GNOME_PRINT_DIALOG_RESPONSE_PRINT) - e_print_save_config (gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (widget))); -} - -GtkWidget * -e_print_get_dialog (const char *title, int flags) -{ - GnomePrintConfig *config; - GtkWidget *dialog; - - config = e_print_load_config (); - dialog = e_print_get_dialog_with_config (title, flags, config); - g_object_unref (config); - - return dialog; -} - -GtkWidget * -e_print_get_dialog_with_config (const char *title, int flags, GnomePrintConfig *config) -{ - GtkWidget *dialog; - - dialog = g_object_new (GNOME_TYPE_PRINT_DIALOG, "print_config", config, NULL); - gnome_print_dialog_construct (GNOME_PRINT_DIALOG (dialog), title, flags); - - g_signal_connect(dialog, "response", G_CALLBACK(print_dialog_response), NULL); - - return dialog; -} diff --git a/e-util/e-print.h b/e-util/e-print.h deleted file mode 100644 index 738da0f418..0000000000 --- a/e-util/e-print.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-print.c - Uniform print setting/dialog routines for Evolution - * - * Copyright (C) 2005 Novell, Inc. - * - * Authors: JP Rosevear <jpr@novell.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <gtk/gtk.h> -#include <libgnomeprint/gnome-print.h> -#include <libgnomeprintui/gnome-print-dialog.h> - -#ifndef __E_PRINT__ -#define __E_PRINT__ - -G_BEGIN_DECLS - -GnomePrintConfig *e_print_load_config (void); -void e_print_save_config (GnomePrintConfig *config); - -GtkWidget *e_print_get_dialog (const char *title, int flags); -GtkWidget *e_print_get_dialog_with_config (const char *title, int flags, GnomePrintConfig *config); - -G_END_DECLS - -#endif diff --git a/e-util/e-profile-event.c b/e-util/e-profile-event.c deleted file mode 100644 index 5b4495a31d..0000000000 --- a/e-util/e-profile-event.c +++ /dev/null @@ -1,198 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include "e-profile-event.h" -#include "libedataserver/e-msgport.h" - -static GObjectClass *eme_parent; -static EProfileEvent *e_profile_event; - -static void -eme_init(GObject *o) -{ - /*EProfileEvent *eme = (EProfileEvent *)o; */ -} - -static void -eme_finalise(GObject *o) -{ - ((GObjectClass *)eme_parent)->finalize(o); -} - -static void -eme_target_free(EEvent *ep, EEventTarget *t) -{ - switch (t->type) { - case E_PROFILE_EVENT_TARGET: { - EProfileEventTarget *s = (EProfileEventTarget *)t; - - g_free(s->id); - g_free(s->uid); - break; } - } - - ((EEventClass *)eme_parent)->target_free(ep, t); -} - -static void -eme_class_init(GObjectClass *klass) -{ - klass->finalize = eme_finalise; - ((EEventClass *)klass)->target_free = eme_target_free; -} - -GType -e_profile_event_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EProfileEventClass), - NULL, NULL, - (GClassInitFunc)eme_class_init, - NULL, NULL, - sizeof(EProfileEvent), 0, - (GInstanceInitFunc)eme_init - }; - eme_parent = g_type_class_ref(e_event_get_type()); - type = g_type_register_static(e_event_get_type(), "EProfileEvent", &info, 0); - } - - return type; -} - -/** - * e_profile_event_peek: - * @void: - * - * Get the singular instance of the profile event handler. - * - * Return value: - **/ -EProfileEvent *e_profile_event_peek(void) -{ - if (e_profile_event == NULL) { - e_profile_event = g_object_new(e_profile_event_get_type(), 0); - e_event_construct(&e_profile_event->popup, "org.gnome.evolution.profile.events"); - } - - return e_profile_event; -} - -EProfileEventTarget * -e_profile_event_target_new(EProfileEvent *eme, const char *id, const char *uid, guint32 flags) -{ - EProfileEventTarget *t = e_event_target_new(&eme->popup, E_PROFILE_EVENT_TARGET, sizeof(*t)); - - t->id = g_strdup(id); - t->uid = g_strdup(uid); - t->target.mask = ~flags; - gettimeofday(&t->tv, NULL); - - return t; -} - -#ifdef ENABLE_PROFILING -void -e_profile_event_emit(const char *id, const char *uid, guint32 flags) -{ - EProfileEvent *epe = e_profile_event_peek(); - EProfileEventTarget *t = e_profile_event_target_new(epe, id, uid, flags); - - e_event_emit((EEvent *)epe, "event", (EEventTarget *)t); -} -#else -#undef e_profile_event_emit -void e_profile_event_emit(const char *id, const char *uid, guint32 flags); - -void -e_profile_event_emit(const char *id, const char *uid, guint32 flags) -{ -} -#endif - -/* ********************************************************************** */ - -static void *emeh_parent_class; -#define emeh ((EProfileEventHook *)eph) - -static const EEventHookTargetMask emeh_profile_masks[] = { - { "start", E_PROFILE_EVENT_START }, - { "end", E_PROFILE_EVENT_END }, - { "cancel", E_PROFILE_EVENT_CANCEL }, - { 0 } -}; - -static const EEventHookTargetMap emeh_targets[] = { - { "event", E_PROFILE_EVENT_TARGET, emeh_profile_masks }, - { 0 } -}; - -static void -emeh_finalise(GObject *o) -{ - /*EPluginHook *eph = (EPluginHook *)o;*/ - - ((GObjectClass *)emeh_parent_class)->finalize(o); -} - -static void -emeh_class_init(EPluginHookClass *klass) -{ - int i; - - ((GObjectClass *)klass)->finalize = emeh_finalise; - ((EPluginHookClass *)klass)->id = "org.gnome.evolution.profile.events:1.0"; - - for (i=0;emeh_targets[i].type;i++) - e_event_hook_class_add_target_map((EEventHookClass *)klass, &emeh_targets[i]); - - ((EEventHookClass *)klass)->event = (EEvent *)e_profile_event_peek(); -} - -GType -e_profile_event_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EProfileEventHookClass), NULL, NULL, (GClassInitFunc) emeh_class_init, NULL, NULL, - sizeof(EProfileEventHook), 0, (GInstanceInitFunc) NULL, - }; - - emeh_parent_class = g_type_class_ref(e_event_hook_get_type()); - type = g_type_register_static(e_event_hook_get_type(), "EProfileEventHook", &info, 0); - } - - return type; -} diff --git a/e-util/e-profile-event.h b/e-util/e-profile-event.h deleted file mode 100644 index dd57d58a82..0000000000 --- a/e-util/e-profile-event.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michel Zucchi <notzed@ximian.com> - * - * Copyright 2003 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __E_PROFILE_EVENT_H__ -#define __E_PROFILE_EVENT_H__ - -#include <glib-object.h> -#include <sys/time.h> - -#include "e-util/e-event.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -struct _CamelFolder; -struct _CamelMimeMessage; - -typedef struct _EProfileEvent EProfileEvent; -typedef struct _EProfileEventClass EProfileEventClass; - -/* Current target description */ -enum _e_profile_event_target_t { - E_PROFILE_EVENT_TARGET, -}; - -/* Flags that qualify a target (UNIMPLEMENTED) */ -enum { - E_PROFILE_EVENT_START = 1<< 0, - E_PROFILE_EVENT_END = 1<< 1, - E_PROFILE_EVENT_CANCEL = 1<< 2, -}; - -typedef struct _EProfileEventTarget EProfileEventTarget; - -struct _EProfileEventTarget { - EEventTarget target; - - struct timeval tv; - char *id; /* id of event */ - char *uid; /* uid of event (folder/message, etc) */ -}; - -typedef struct _EEventItem EProfileEventItem; - -/* The object */ -struct _EProfileEvent { - EEvent popup; - - struct _EProfileEventPrivate *priv; -}; - -struct _EProfileEventClass { - EEventClass popup_class; -}; - -GType e_profile_event_get_type(void); - -EProfileEvent *e_profile_event_peek(void); - -EProfileEventTarget *e_profile_event_target_new(EProfileEvent *emp, const char *id, const char *uid, guint32 flags); - -/* we don't want ANY rubbish code lying around if we have profiling off */ -#ifdef ENABLE_PROFILING -void e_profile_event_emit(const char *id, const char *uid, guint32 flags); -#else -#define e_profile_event_emit(a, b, c) -#endif - -/* ********************************************************************** */ - -typedef struct _EProfileEventHook EProfileEventHook; -typedef struct _EProfileEventHookClass EProfileEventHookClass; - -struct _EProfileEventHook { - EEventHook hook; -}; - -struct _EProfileEventHookClass { - EEventHookClass hook_class; -}; - -GType e_profile_event_hook_get_type(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_PROFILE_EVENT_H__ */ diff --git a/e-util/e-request.c b/e-util/e-request.c deleted file mode 100644 index f105ce1bd3..0000000000 --- a/e-util/e-request.c +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-request.c - * - * Copyright (C) 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-request.h" - -#include <gtk/gtkbox.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtkentry.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkstock.h> - - -/** - * e_request_string: - * @parent: parent window, or %NULL - * @title: the dialog title (in the locale character set) - * @prompt: the prompt (in the locale character set) - * @default: default value (in UTF8) - * - * Request a string from the user. - * - * Return value: %NULL if the user cancelled the dialog, the inserted - * string (in UTF8) otherwise. The string must be freed by the caller. - **/ -char * -e_request_string (GtkWindow *parent, - const char *title, - const char *prompt, - const char *default_string) -{ - GtkWidget *prompt_label; - char *text; - GtkWidget *dialog; - GtkWidget *entry; - GtkWidget *vbox; - - g_return_val_if_fail (title != NULL, NULL); - g_return_val_if_fail (prompt != NULL, NULL); - - dialog = gtk_dialog_new_with_buttons (title, parent, - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - gtk_window_set_default_size (GTK_WINDOW (dialog), 275, -1); - gtk_container_set_border_width (GTK_CONTAINER (dialog), 6); - - vbox = GTK_DIALOG (dialog)->vbox; - - prompt_label = gtk_label_new (prompt); - gtk_box_pack_start (GTK_BOX (vbox), prompt_label, TRUE, TRUE, 6); - gtk_box_set_spacing (GTK_BOX (vbox), 6); - - entry = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (entry), default_string); - gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 3); - - atk_object_set_description (gtk_widget_get_accessible (entry), prompt); - - gtk_widget_grab_focus (entry); - - gtk_widget_show (prompt_label); - gtk_widget_show (entry); - gtk_widget_show (dialog); - - switch (gtk_dialog_run (GTK_DIALOG (dialog))) { - case GTK_RESPONSE_OK: - text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); - break; - default: - text = NULL; - break; - } - - gtk_widget_destroy (dialog); - - return text; -} diff --git a/e-util/e-request.h b/e-util/e-request.h deleted file mode 100644 index 7ebb70c43f..0000000000 --- a/e-util/e-request.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-request.c - * - * Copyright (C) 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef E_REQUEST_H -#define E_REQUEST_H - -#include <gtk/gtkwindow.h> - -char *e_request_string (GtkWindow *parent, - const char *title, - const char *prompt, - const char *default_string); - -#endif diff --git a/e-util/e-signature-list.c b/e-util/e-signature-list.c deleted file mode 100644 index e7812f0181..0000000000 --- a/e-util/e-signature-list.c +++ /dev/null @@ -1,471 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include "e-uid.h" - -#include "e-util-marshal.h" - -#include "e-signature-list.h" - -struct _ESignatureListPrivate { - GConfClient *gconf; - guint notify_id; - gboolean resave; -}; - -enum { - SIGNATURE_ADDED, - SIGNATURE_CHANGED, - SIGNATURE_REMOVED, - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL] = { 0 }; - -static void e_signature_list_class_init (ESignatureListClass *klass); -static void e_signature_list_init (ESignatureList *list, ESignatureListClass *klass); -static void e_signature_list_finalize (GObject *object); -static void e_signature_list_dispose (GObject *object); - - -static EListClass *parent_class = NULL; - - -GType -e_signature_list_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo type_info = { - sizeof (ESignatureListClass), - NULL, NULL, - (GClassInitFunc) e_signature_list_class_init, - NULL, NULL, - sizeof (ESignatureList), - 0, - (GInstanceInitFunc) e_signature_list_init, - }; - - type = g_type_register_static (E_TYPE_LIST, "ESignatureList", &type_info, 0); - } - - return type; -} - - -static void -e_signature_list_class_init (ESignatureListClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - - parent_class = g_type_class_ref (E_TYPE_LIST); - - /* virtual method override */ - object_class->dispose = e_signature_list_dispose; - object_class->finalize = e_signature_list_finalize; - - /* signals */ - signals[SIGNATURE_ADDED] = - g_signal_new ("signature-added", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESignatureListClass, signature_added), - NULL, NULL, - e_util_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_SIGNATURE); - signals[SIGNATURE_CHANGED] = - g_signal_new ("signature-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESignatureListClass, signature_changed), - NULL, NULL, - e_util_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_SIGNATURE); - signals[SIGNATURE_REMOVED] = - g_signal_new ("signature-removed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESignatureListClass, signature_removed), - NULL, NULL, - e_util_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_SIGNATURE); -} - -static void -e_signature_list_init (ESignatureList *list, ESignatureListClass *klass) -{ - list->priv = g_new0 (struct _ESignatureListPrivate, 1); -} - -static void -e_signature_list_dispose (GObject *object) -{ - ESignatureList *list = (ESignatureList *) object; - - if (list->priv->gconf) { - if (list->priv->notify_id != 0) - gconf_client_notify_remove (list->priv->gconf, list->priv->notify_id); - g_object_unref (list->priv->gconf); - list->priv->gconf = NULL; - } - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -e_signature_list_finalize (GObject *object) -{ - ESignatureList *list = (ESignatureList *) object; - - g_free (list->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static GSList * -add_autogen (ESignatureList *list, GSList *new_sigs) -{ - ESignature *autogen; - - autogen = e_signature_new (); - autogen->name = g_strdup ("Autogenerated"); - autogen->autogen = TRUE; - - e_list_append (E_LIST (list), autogen); - - return g_slist_prepend (new_sigs, autogen); -} - -static void -gconf_signatures_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) -{ - ESignatureList *signature_list = user_data; - GSList *list, *l, *n, *new_sigs = NULL; - gboolean have_autogen = FALSE; - gboolean resave = FALSE; - ESignature *signature; - EList *old_sigs; - EIterator *iter; - gboolean found; - char *uid; - - old_sigs = e_list_duplicate (E_LIST (signature_list)); - - list = gconf_client_get_list (client, "/apps/evolution/mail/signatures", GCONF_VALUE_STRING, NULL); - for (l = list; l; l = l->next) { - found = FALSE; - if ((uid = e_signature_uid_from_xml (l->data))) { - /* See if this is an existing signature */ - for (iter = e_list_get_iterator (old_sigs); e_iterator_is_valid (iter); e_iterator_next (iter)) { - signature = (ESignature *) e_iterator_get (iter); - if (!strcmp (signature->uid, uid)) { - /* The signature still exists, so remove - * it from "old_sigs" and update it. - */ - found = TRUE; - e_iterator_delete (iter); - if (e_signature_set_from_xml (signature, l->data)) - g_signal_emit (signature_list, signals[SIGNATURE_CHANGED], 0, signature); - - have_autogen |= signature->autogen; - - break; - } - } - - g_object_unref (iter); - } - - if (!found) { - /* Must be a new signature */ - signature = e_signature_new_from_xml (l->data); - have_autogen |= signature->autogen; - if (!signature->uid) { - signature->uid = e_uid_new (); - resave = TRUE; - } - - e_list_append (E_LIST (signature_list), signature); - new_sigs = g_slist_prepend (new_sigs, signature); - } - - g_free (uid); - } - - if (!have_autogen) { - new_sigs = add_autogen (signature_list, new_sigs); - have_autogen = TRUE; - resave = TRUE; - } - - if (new_sigs != NULL) { - /* Now emit signals for each added signature. */ - l = g_slist_reverse (new_sigs); - while (l != NULL) { - n = l->next; - signature = l->data; - g_signal_emit (signature_list, signals[SIGNATURE_ADDED], 0, signature); - g_object_unref (signature); - g_slist_free_1 (l); - l = n; - } - } - - /* Anything left in old_sigs must have been deleted */ - for (iter = e_list_get_iterator (old_sigs); e_iterator_is_valid (iter); e_iterator_next (iter)) { - signature = (ESignature *) e_iterator_get (iter); - e_list_remove (E_LIST (signature_list), signature); - g_signal_emit (signature_list, signals[SIGNATURE_REMOVED], 0, signature); - } - - g_object_unref (iter); - g_object_unref (old_sigs); - - signature_list->priv->resave = resave; -} - -static void * -copy_func (const void *data, void *closure) -{ - GObject *object = (GObject *)data; - - g_object_ref (object); - - return object; -} - -static void -free_func (void *data, void *closure) -{ - g_object_unref (data); -} - -/** - * e_signature_list_new: - * @gconf: a #GConfClient - * - * Reads the list of signaturess from @gconf and listens for changes. - * Will emit #signature_added, #signature_changed, and #signature_removed - * signals according to notifications from GConf. - * - * You can modify the list using e_list_append(), e_list_remove(), and - * e_iterator_delete(). After adding, removing, or changing accounts, - * you must call e_signature_list_save() to push the changes back to - * GConf. - * - * Return value: the list of signatures - **/ -ESignatureList * -e_signature_list_new (GConfClient *gconf) -{ - ESignatureList *signature_list; - - g_return_val_if_fail (GCONF_IS_CLIENT (gconf), NULL); - - signature_list = g_object_new (E_TYPE_SIGNATURE_LIST, NULL); - e_signature_list_construct (signature_list, gconf); - - return signature_list; -} - -void -e_signature_list_construct (ESignatureList *signature_list, GConfClient *gconf) -{ - g_return_if_fail (GCONF_IS_CLIENT (gconf)); - - e_list_construct (E_LIST (signature_list), copy_func, free_func, NULL); - signature_list->priv->gconf = gconf; - g_object_ref (gconf); - - gconf_client_add_dir (signature_list->priv->gconf, - "/apps/evolution/mail/signatures", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - - signature_list->priv->notify_id = - gconf_client_notify_add (signature_list->priv->gconf, - "/apps/evolution/mail/signatures", - gconf_signatures_changed, signature_list, - NULL, NULL); - - gconf_signatures_changed (signature_list->priv->gconf, - signature_list->priv->notify_id, - NULL, signature_list); - - if (signature_list->priv->resave) { - e_signature_list_save (signature_list); - signature_list->priv->resave = FALSE; - } -} - - -/** - * e_signature_list_save: - * @signature_list: an #ESignatureList - * - * Saves @signature_list to GConf. Signals will be emitted for changes. - **/ -void -e_signature_list_save (ESignatureList *signature_list) -{ - GSList *list = NULL; - ESignature *signature; - EIterator *iter; - char *xmlbuf; - - for (iter = e_list_get_iterator (E_LIST (signature_list)); - e_iterator_is_valid (iter); - e_iterator_next (iter)) { - signature = (ESignature *) e_iterator_get (iter); - - if ((xmlbuf = e_signature_to_xml (signature))) - list = g_slist_append (list, xmlbuf); - } - - g_object_unref (iter); - - gconf_client_set_list (signature_list->priv->gconf, - "/apps/evolution/mail/signatures", - GCONF_VALUE_STRING, list, NULL); - - while (list) { - g_free (list->data); - list = g_slist_remove (list, list->data); - } - - gconf_client_suggest_sync (signature_list->priv->gconf, NULL); -} - - -/** - * e_signature_list_add: - * @signatures: signature list - * @signature: signature to add - * - * Add an signature to the signature list. Will emit the signature-changed - * event. - **/ -void -e_signature_list_add (ESignatureList *signatures, ESignature *signature) -{ - e_list_append ((EList *) signatures, signature); - g_signal_emit (signatures, signals[SIGNATURE_ADDED], 0, signature); -} - - -/** - * e_signature_list_change: - * @signatures: signature list - * @signature: signature to change - * - * Signal that the details of an signature have changed. - **/ -void -e_signature_list_change (ESignatureList *signatures, ESignature *signature) -{ - /* maybe the signature should do this itself ... */ - g_signal_emit (signatures, signals[SIGNATURE_CHANGED], 0, signature); -} - - -/** - * e_signature_list_remove: - * @signatures: signature list - * @signature: signature - * - * Remove an signature from the signature list, and emit the - * signature-removed signal. If the signature was the default signature, - * then reset the default to the first signature. - **/ -void -e_signature_list_remove (ESignatureList *signatures, ESignature *signature) -{ - /* not sure if need to ref but no harm */ - g_object_ref (signature); - e_list_remove ((EList *) signatures, signature); - g_signal_emit (signatures, signals[SIGNATURE_REMOVED], 0, signature); - g_object_unref (signature); -} - - -/** - * e_signature_list_find: - * @signatures: signature list - * @type: Type of search. - * @key: Search key. - * - * Perform a search of the signature list on a single key. - * - * @type must be set from one of the following search types: - * E_SIGNATURE_FIND_NAME - Find a signature by signature name. - * E_SIGNATURE_FIND_UID - Find a signature based on UID - * - * Return value: The signature or NULL if it doesn't exist. - **/ -const ESignature * -e_signature_list_find (ESignatureList *signatures, e_signature_find_t type, const char *key) -{ - const ESignature *signature = NULL; - EIterator *it; - - /* this could use a callback for more flexibility ... - ... but this makes the common cases easier */ - - if (!key) - return NULL; - - for (it = e_list_get_iterator ((EList *) signatures); - e_iterator_is_valid (it); - e_iterator_next (it)) { - int found = 0; - - signature = (const ESignature *) e_iterator_get (it); - - switch (type) { - case E_SIGNATURE_FIND_NAME: - found = strcmp (signature->name, key) == 0; - break; - case E_SIGNATURE_FIND_UID: - found = strcmp (signature->uid, key) == 0; - break; - } - - if (found) - break; - - signature = NULL; - } - - g_object_unref (it); - - return signature; -} diff --git a/e-util/e-signature-list.h b/e-util/e-signature-list.h deleted file mode 100644 index cec82f9c6f..0000000000 --- a/e-util/e-signature-list.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef __E_SIGNATURE_LIST__ -#define __E_SIGNATURE_LIST__ - -#include <e-util/e-list.h> -#include <e-util/e-signature.h> - -#include <gconf/gconf-client.h> - -#define E_TYPE_SIGNATURE_LIST (e_signature_list_get_type ()) -#define E_SIGNATURE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIGNATURE_LIST, ESignatureList)) -#define E_SIGNATURE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIGNATURE_LIST, ESignatureListClass)) -#define E_IS_SIGNATURE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIGNATURE_LIST)) -#define E_IS_SIGNATURE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SIGNATURE_LIST)) - -typedef struct _ESignatureList ESignatureList; -typedef struct _ESignatureListClass ESignatureListClass; - -/* search options for the find command */ -typedef enum { - E_SIGNATURE_FIND_NAME, - E_SIGNATURE_FIND_UID, -} e_signature_find_t; - -struct _ESignatureList { - EList parent_object; - - struct _ESignatureListPrivate *priv; -}; - -struct _ESignatureListClass { - EListClass parent_class; - - /* signals */ - void (* signature_added) (ESignatureList *, ESignature *); - void (* signature_changed) (ESignatureList *, ESignature *); - void (* signature_removed) (ESignatureList *, ESignature *); -}; - - -GType e_signature_list_get_type (void); - -ESignatureList *e_signature_list_new (GConfClient *gconf); -void e_signature_list_construct (ESignatureList *signature_list, GConfClient *gconf); - -void e_signature_list_save (ESignatureList *signature_list); - -void e_signature_list_add (ESignatureList *signature_list, ESignature *signature); -void e_signature_list_change (ESignatureList *signature_list, ESignature *signature); -void e_signature_list_remove (ESignatureList *signature_list, ESignature *signature); - -const ESignature *e_signature_list_find (ESignatureList *signature_list, e_signature_find_t type, const char *key); - -#endif /* __E_SIGNATURE_LIST__ */ diff --git a/e-util/e-signature.c b/e-util/e-signature.c deleted file mode 100644 index c02857abb6..0000000000 --- a/e-util/e-signature.c +++ /dev/null @@ -1,366 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -#include <gconf/gconf-client.h> - -#include "e-uid.h" - -#include "e-signature.h" - - -static void e_signature_class_init (ESignatureClass *klass); -static void e_signature_init (ESignature *sig, ESignatureClass *klass); -static void e_signature_finalize (GObject *object); - - -static GObjectClass *parent_class = NULL; - - -GType -e_signature_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo type_info = { - sizeof (ESignatureClass), - NULL, NULL, - (GClassInitFunc) e_signature_class_init, - NULL, NULL, - sizeof (ESignature), - 0, - (GInstanceInitFunc) e_signature_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, "ESignature", &type_info, 0); - } - - return type; -} - -static void -e_signature_class_init (ESignatureClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - /* virtual method override */ - object_class->finalize = e_signature_finalize; -} - -static void -e_signature_init (ESignature *sig, ESignatureClass *klass) -{ - ; -} - -static void -e_signature_finalize (GObject *object) -{ - ESignature *sig = (ESignature *) object; - - g_free (sig->uid); - g_free (sig->name); - g_free (sig->filename); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - - -/** - * e_signature_new: - * - * Returns a new signature which can be filled in and - * added to an #ESignatureList. - **/ -ESignature * -e_signature_new (void) -{ - ESignature *signature; - - signature = g_object_new (E_TYPE_SIGNATURE, NULL); - signature->uid = e_uid_new (); - - return signature; -} - - -/** - * e_signature_new_from_xml: - * @xml: an XML signature description - * - * Return value: a new #ESignature based on the data in @xml, or %NULL - * if @xml could not be parsed as valid signature data. - **/ -ESignature * -e_signature_new_from_xml (const char *xml) -{ - ESignature *signature; - - signature = g_object_new (E_TYPE_SIGNATURE, NULL); - if (!e_signature_set_from_xml (signature, xml)) { - g_object_unref (signature); - return NULL; - } - - return signature; -} - - -static gboolean -xml_set_bool (xmlNodePtr node, const char *name, gboolean *val) -{ - gboolean bool; - char *buf; - - if ((buf = xmlGetProp (node, name))) { - bool = (!strcmp (buf, "true") || !strcmp (buf, "yes")); - xmlFree (buf); - - if (bool != *val) { - *val = bool; - return TRUE; - } - } - - return FALSE; -} - -static gboolean -xml_set_prop (xmlNodePtr node, const char *name, char **val) -{ - char *buf, *new_val; - - buf = xmlGetProp (node, name); - new_val = g_strdup (buf); - xmlFree (buf); - - /* We can use strcmp here whether the value is UTF8 or - * not, since we only care if the bytes changed. - */ - if (!*val || strcmp (*val, new_val)) { - g_free (*val); - *val = new_val; - return TRUE; - } else { - g_free (new_val); - return FALSE; - } -} - -static gboolean -xml_set_content (xmlNodePtr node, char **val) -{ - char *buf, *new_val; - - buf = xmlNodeGetContent (node); - new_val = g_strdup (buf); - xmlFree (buf); - - /* We can use strcmp here whether the value is UTF8 or - * not, since we only care if the bytes changed. - */ - if (!*val || strcmp (*val, new_val)) { - g_free (*val); - *val = new_val; - return TRUE; - } else { - g_free (new_val); - return FALSE; - } -} - - -/** - * e_signature_uid_from_xml: - * @xml: an XML signature description - * - * Return value: the permanent UID of the signature described by @xml - * (or %NULL if @xml could not be parsed or did not contain a uid). - * The caller must free this string. - **/ -char * -e_signature_uid_from_xml (const char *xml) -{ - xmlNodePtr node; - xmlDocPtr doc; - char *uid = NULL; - - if (!(doc = xmlParseDoc ((char *) xml))) - return NULL; - - node = doc->children; - if (strcmp (node->name, "signature") != 0) { - xmlFreeDoc (doc); - return NULL; - } - - xml_set_prop (node, "uid", &uid); - xmlFreeDoc (doc); - - return uid; -} - - -/** - * e_signature_set_from_xml: - * @signature: an #ESignature - * @xml: an XML signature description. - * - * Changes @signature to match @xml. - * - * Returns %TRUE if the signature was loaded or %FALSE otherwise. - **/ -gboolean -e_signature_set_from_xml (ESignature *signature, const char *xml) -{ - gboolean changed = FALSE; - xmlNodePtr node, cur; - xmlDocPtr doc; - gboolean bool; - char *buf; - - if (!(doc = xmlParseDoc ((char *) xml))) - return FALSE; - - node = doc->children; - if (strcmp (node->name, "signature") != 0) { - xmlFreeDoc (doc); - return FALSE; - } - - if (!signature->uid) - xml_set_prop (node, "uid", &signature->uid); - - changed |= xml_set_prop (node, "name", &signature->name); - changed |= xml_set_bool (node, "auto", &signature->autogen); - - if (signature->autogen) { - /* we're done */ - g_free (signature->filename); - signature->filename = NULL; - signature->script = FALSE; - signature->html = FALSE; - xmlFreeDoc (doc); - - return changed; - } - - buf = NULL; - xml_set_prop (node, "format", &buf); - if (buf && !strcmp (buf, "text/html")) - bool = TRUE; - else - bool = FALSE; - g_free (buf); - - if (signature->html != bool) { - signature->html = bool; - changed = TRUE; - } - - cur = node->children; - while (cur) { - if (!strcmp (cur->name, "filename")) { - changed |= xml_set_content (cur, &signature->filename); - changed |= xml_set_bool (cur, "script", &signature->script); - break; - } else if (!strcmp (cur->name, "script")) { - /* this is for handling 1.4 signature script definitions */ - changed |= xml_set_content (cur, &signature->filename); - if (!signature->script) { - signature->script = TRUE; - changed = TRUE; - } - break; - } - - cur = cur->next; - } - - xmlFreeDoc (doc); - - return changed; -} - - -/** - * e_signature_to_xml: - * @signature: an #ESignature - * - * Return value: an XML representation of @signature, which the caller - * must free. - **/ -char * -e_signature_to_xml (ESignature *signature) -{ - char *xmlbuf, *tmp; - xmlNodePtr root, node; - xmlDocPtr doc; - int n; - - doc = xmlNewDoc ("1.0"); - - root = xmlNewDocNode (doc, NULL, "signature", NULL); - xmlDocSetRootElement (doc, root); - - xmlSetProp (root, "name", signature->name); - xmlSetProp (root, "uid", signature->uid); - xmlSetProp (root, "auto", signature->autogen ? "true" : "false"); - - if (!signature->autogen) { - xmlSetProp (root, "format", signature->html ? "text/html" : "text/plain"); - - if (signature->filename) { - node = xmlNewTextChild (root, NULL, "filename", signature->filename); - if (signature->script) - xmlSetProp (node, "script", "true"); - } - } else { - /* this is to make Evolution-1.4 and older 1.5 versions happy */ - xmlSetProp (root, "format", "text/html"); - } - - xmlDocDumpMemory (doc, (xmlChar **) &xmlbuf, &n); - xmlFreeDoc (doc); - - /* remap to glib memory */ - tmp = g_malloc (n + 1); - memcpy (tmp, xmlbuf, n); - tmp[n] = '\0'; - xmlFree (xmlbuf); - - return tmp; -} - diff --git a/e-util/e-signature.h b/e-util/e-signature.h deleted file mode 100644 index b30b475c1a..0000000000 --- a/e-util/e-signature.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifndef __E_SIGNATURE_H__ -#define __E_SIGNATURE_H__ - -#include <glib-object.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_SIGNATURE (e_signature_get_type ()) -#define E_SIGNATURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIGNATURE, ESignature)) -#define E_SIGNATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIGNATURE, ESignatureClass)) -#define E_IS_SIGNATURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIGNATURE)) -#define E_IS_SIGNATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SIGNATURE)) - -typedef struct _ESignature ESignature; -typedef struct _ESignatureClass ESignatureClass; - -struct _ESignature { - GObject parent_object; - - gboolean autogen; - gboolean script; - gboolean html; - - char *filename; - char *name; - char *uid; -}; - -struct _ESignatureClass { - GObjectClass parent_class; - -}; - - -GType e_signature_get_type (void); - -ESignature *e_signature_new (void); -ESignature *e_signature_new_from_xml (const char *xml); - -char *e_signature_uid_from_xml (const char *xml); - -gboolean e_signature_set_from_xml (ESignature *sig, const char *xml); - -char *e_signature_to_xml (ESignature *sig); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_SIGNATURE_H__ */ diff --git a/e-util/e-system.error.xml b/e-util/e-system.error.xml deleted file mode 100644 index 7a2022af7f..0000000000 --- a/e-util/e-system.error.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0"?> -<error-list domain="system"> - - <error id="ask-save-file-exists-overwrite" type="error" default="GTK_RESPONSE_CANCEL"> - <_title>Overwrite file?</_title> - <_primary>File exists "{0}".</_primary> - <_secondary>Do you wish to overwrite it?</_secondary> - <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/> - <button _label="_Overwrite" response="GTK_RESPONSE_OK"/> - </error> - - <error id="no-save-file" type="error"> - <_primary>Cannot save file "{0}".</_primary> - <_secondary>Because "{1}".</_secondary> - </error> - - <error id="no-load-file" type="error"> - <_primary>Cannot open file "{0}".</_primary> - <_secondary>Because "{1}".</_secondary> - </error> - -</error-list> diff --git a/e-util/e-time-utils.c b/e-util/e-time-utils.c deleted file mode 100644 index 8f05427a81..0000000000 --- a/e-util/e-time-utils.c +++ /dev/null @@ -1,492 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Time utility functions - * - * Author: - * Damon Chaplin (damon@ximian.com) - * - * (C) 2001 Ximian, Inc. - */ - -#include <config.h> - -#ifdef __linux__ -/* We need this to get a prototype for strptime. */ -#define _GNU_SOURCE -#endif /* __linux__ */ - -#include <time.h> -#include <sys/time.h> -#include <gal/widgets/e-unicode.h> - -#ifdef __linux__ -#undef _GNU_SOURCE -#endif /* __linux__ */ - -#include <string.h> -#include <ctype.h> -#include <glib.h> -#include <libgnome/gnome-i18n.h> -#include <gal/util/e-util.h> -#include "e-time-utils.h" - - -/* Returns whether a string is NULL, empty, or full of whitespace */ -static gboolean -string_is_empty (const char *value) -{ - const char *p; - gboolean empty = TRUE; - - if (value) { - p = value; - while (*p) { - if (!isspace (*p)) { - empty = FALSE; - break; - } - p++; - } - } - return empty; -} - - -/* Takes a number of format strings for strptime() and attempts to parse a - * string with them. - */ -static ETimeParseStatus -parse_with_strptime (const char *value, struct tm *result, const char **formats, int n_formats) -{ - const char *parse_end = NULL, *pos; - gchar *locale_str; - gchar *format_str; - ETimeParseStatus parse_ret; - gboolean parsed = FALSE; - int i; - - if (string_is_empty (value)) { - memset (result, 0, sizeof (*result)); - result->tm_isdst = -1; - return E_TIME_PARSE_NONE; - } - - locale_str = e_utf8_to_locale_string (value); - - pos = (const char *) locale_str; - - /* Skip whitespace */ - while (isspace (*pos)) - pos++; - - /* Try each of the formats in turn */ - - for (i = 0; i < n_formats; i++) { - memset (result, 0, sizeof (*result)); - format_str = e_utf8_to_locale_string (formats[i]); - parse_end = strptime (pos, format_str, result); - g_free (format_str); - if (parse_end) { - parsed = TRUE; - break; - } - } - - result->tm_isdst = -1; - - parse_ret = E_TIME_PARSE_INVALID; - - /* If we parsed something, make sure we parsed the entire string. */ - if (parsed) { - /* Skip whitespace */ - while (isspace (*parse_end)) - parse_end++; - - if (*parse_end == '\0') - parse_ret = E_TIME_PARSE_OK; - } - - g_free (locale_str); - - return (parse_ret); - -} - - -/* Returns TRUE if the locale has 'am' and 'pm' strings defined, in which - case the user can choose between 12 and 24-hour time formats. */ -static gboolean -locale_supports_12_hour_format (void) -{ - struct tm tmp_tm = { 0 }; - char s[16]; - - e_utf8_strftime (s, sizeof (s), "%p", &tmp_tm); - return s[0] != '\0'; -} - - -/* - * Parses a string containing a date and a time. The date is expected to be - * in a format something like "Wed 3/13/00 14:20:00", though we use gettext - * to support the appropriate local formats and we try to accept slightly - * different formats, e.g. the weekday can be skipped and we can accept 12-hour - * formats with an am/pm string. - * - * Returns E_TIME_PARSE_OK if it could not be parsed, E_TIME_PARSE_NONE if it - * was empty, or E_TIME_PARSE_INVALID if it couldn't be parsed. - */ -ETimeParseStatus -e_time_parse_date_and_time (const char *value, - struct tm *result) -{ - struct tm *today_tm; - time_t t; - const char *format[16]; - int num_formats = 0; - gboolean use_12_hour_formats = locale_supports_12_hour_format (); - ETimeParseStatus status; - - if (string_is_empty (value)) { - memset (result, 0, sizeof (*result)); - result->tm_isdst = -1; - return E_TIME_PARSE_NONE; - } - - /* We'll parse the whole date and time in one go, otherwise we get - into i18n problems. We attempt to parse with several formats, - longest first. Note that we only use the '%p' specifier if the - locale actually has 'am' and 'pm' strings defined, otherwise we - will get incorrect results. Note also that we try to use exactly - the same strings as in e_time_format_date_and_time(), to try to - avoid i18n problems. We also use cut-down versions, so users don't - have to type in the weekday or the seconds, for example. - Note that all these formats include the full date, and the time - will be set to 00:00:00 before parsing, so we don't need to worry - about filling in any missing fields after parsing. */ - - /* - * Try the full times, with the weekday. Then try without seconds, - * and without minutes, and finally with no time at all. - */ - if (use_12_hour_formats) { - /* strptime format of a weekday, a date and a time, - in 12-hour format. */ - format[num_formats++] = _("%a %m/%d/%Y %I:%M:%S %p"); - } - - /* strptime format of a weekday, a date and a time, - in 24-hour format. */ - format[num_formats++] = _("%a %m/%d/%Y %H:%M:%S"); - - if (use_12_hour_formats) { - /* strptime format of a weekday, a date and a time, - in 12-hour format, without seconds. */ - format[num_formats++] = _("%a %m/%d/%Y %I:%M %p"); - } - - /* strptime format of a weekday, a date and a time, - in 24-hour format, without seconds. */ - format[num_formats++] = _("%a %m/%d/%Y %H:%M"); - - if (use_12_hour_formats) { - /* strptime format of a weekday, a date and a time, - in 12-hour format, without minutes or seconds. */ - format[num_formats++] = _("%a %m/%d/%Y %I %p"); - } - - /* strptime format of a weekday, a date and a time, - in 24-hour format, without minutes or seconds. */ - format[num_formats++] = _("%a %m/%d/%Y %H"); - - /* strptime format of a weekday and a date. */ - format[num_formats++] = _("%a %m/%d/%Y"); - - - /* - * Now try all the above formats again, but without the weekday. - */ - if (use_12_hour_formats) { - /* strptime format of a date and a time, in 12-hour format. */ - format[num_formats++] = _("%m/%d/%Y %I:%M:%S %p"); - } - - /* strptime format of a date and a time, in 24-hour format. */ - format[num_formats++] = _("%m/%d/%Y %H:%M:%S"); - - if (use_12_hour_formats) { - /* strptime format of a date and a time, in 12-hour format, - without seconds. */ - format[num_formats++] = _("%m/%d/%Y %I:%M %p"); - } - - /* strptime format of a date and a time, in 24-hour format, - without seconds. */ - format[num_formats++] = _("%m/%d/%Y %H:%M"); - - if (use_12_hour_formats) { - /* strptime format of a date and a time, in 12-hour format, - without minutes or seconds. */ - format[num_formats++] = _("%m/%d/%Y %I %p"); - } - - /* strptime format of a date and a time, in 24-hour format, - without minutes or seconds. */ - format[num_formats++] = _("%m/%d/%Y %H"); - - /* strptime format of a weekday and a date. */ - format[num_formats++] = _("%m/%d/%Y"); - - - status = parse_with_strptime (value, result, format, num_formats); - /* Note that we checked if it was empty already, so it is either OK - or INVALID here. */ - if (status == E_TIME_PARSE_OK) { - /* If a 2-digit year was used we use the current century. */ - if (result->tm_year < 0) { - t = time (NULL); - today_tm = localtime (&t); - - /* This should convert it into a value from 0 to 99. */ - result->tm_year += 1900; - - /* Now add on the century. */ - result->tm_year += today_tm->tm_year - - (today_tm->tm_year % 100); - } - } else { - /* Now we try to just parse a time, assuming the current day.*/ - status = e_time_parse_time (value, result); - if (status == E_TIME_PARSE_OK) { - /* We fill in the current day. */ - t = time (NULL); - today_tm = localtime (&t); - result->tm_mday = today_tm->tm_mday; - result->tm_mon = today_tm->tm_mon; - result->tm_year = today_tm->tm_year; - } - } - - return status; -} - -/** - * e_time_parse_date: - * @value: A date string. - * @result: Return value for the parsed date. - * - * Takes in a date string entered by the user and tries to convert it to - * a struct tm. - * - * Return value: Result code indicating whether the @value was an empty - * string, a valid date, or an invalid date. - **/ -ETimeParseStatus -e_time_parse_date (const char *value, struct tm *result) -{ - const char *format[2]; - struct tm *today_tm; - time_t t; - ETimeParseStatus status; - - g_return_val_if_fail (value != NULL, E_TIME_PARSE_INVALID); - g_return_val_if_fail (result != NULL, E_TIME_PARSE_INVALID); - - /* strptime format of a weekday and a date. */ - format[0] = _("%a %m/%d/%Y"); - - /* This is the preferred date format for the locale. */ - format[1] = _("%m/%d/%Y"); - - status = parse_with_strptime (value, result, format, sizeof (format) / sizeof (format[0])); - if (status == E_TIME_PARSE_OK) { - /* If a 2-digit year was used we use the current century. */ - if (result->tm_year < 0) { - t = time (NULL); - today_tm = localtime (&t); - - /* This should convert it into a value from 0 to 99. */ - result->tm_year += 1900; - - /* Now add on the century. */ - result->tm_year += today_tm->tm_year - - (today_tm->tm_year % 100); - } - } - - return status; -} - - -/* - * Parses a string containing a time. It is expected to be in a format - * something like "14:20:00", though we use gettext to support the appropriate - * local formats and we try to accept slightly different formats, e.g. we can - * accept 12-hour formats with an am/pm string. - * - * Returns E_TIME_PARSE_OK if it could not be parsed, E_TIME_PARSE_NONE if it - * was empty, or E_TIME_PARSE_INVALID if it couldn't be parsed. - */ -ETimeParseStatus -e_time_parse_time (const char *value, struct tm *result) -{ - const char *format[6]; - int num_formats = 0; - gboolean use_12_hour_formats = locale_supports_12_hour_format (); - - if (use_12_hour_formats) { - /* strptime format for a time of day, in 12-hour format. */ - format[num_formats++] = _("%I:%M:%S %p"); - } - - /* strptime format for a time of day, in 24-hour format. */ - format[num_formats++] = _("%H:%M:%S"); - - if (use_12_hour_formats) { - /* strptime format for time of day, without seconds, - in 12-hour format. */ - format[num_formats++] = _("%I:%M %p"); - } - - /* strptime format for time of day, without seconds 24-hour format. */ - format[num_formats++] = _("%H:%M"); - - if (use_12_hour_formats) { - /* strptime format for hour and AM/PM, 12-hour format. */ - format[num_formats++] = _("%I %p"); - } - - /* strptime format for hour, 24-hour format. */ - format[num_formats++] = "%H"; - - return parse_with_strptime (value, result, format, num_formats); -} - - -/* Creates a string representation of a time value and stores it in buffer. - buffer_size should be about 64 to be safe. If show_midnight is FALSE, and - the time is midnight, then we just show the date. If show_zero_seconds - is FALSE, then if the time has zero seconds only the hour and minute are - shown. */ -void -e_time_format_date_and_time (struct tm *date_tm, - gboolean use_24_hour_format, - gboolean show_midnight, - gboolean show_zero_seconds, - char *buffer, - int buffer_size) -{ - char *format; - - if (!show_midnight && date_tm->tm_hour == 0 - && date_tm->tm_min == 0 && date_tm->tm_sec == 0) { - /* strftime format of a weekday and a date. */ - format = _("%a %m/%d/%Y"); - } else if (use_24_hour_format) { - if (!show_zero_seconds && date_tm->tm_sec == 0) - /* strftime format of a weekday, a date and a - time, in 24-hour format, without seconds. */ - format = _("%a %m/%d/%Y %H:%M"); - else - /* strftime format of a weekday, a date and a - time, in 24-hour format. */ - format = _("%a %m/%d/%Y %H:%M:%S"); - } else { - if (!show_zero_seconds && date_tm->tm_sec == 0) - /* strftime format of a weekday, a date and a - time, in 12-hour format, without seconds. */ - format = _("%a %m/%d/%Y %I:%M %p"); - else - /* strftime format of a weekday, a date and a - time, in 12-hour format. */ - format = _("%a %m/%d/%Y %I:%M:%S %p"); - } - - /* strftime returns 0 if the string doesn't fit, and leaves the buffer - undefined, so we set it to the empty string in that case. */ - if (e_utf8_strftime (buffer, buffer_size, format, date_tm) == 0) - buffer[0] = '\0'; -} - - -/* Creates a string representation of a time value and stores it in buffer. - buffer_size should be about 64 to be safe. */ -void -e_time_format_time (struct tm *date_tm, - gboolean use_24_hour_format, - gboolean show_zero_seconds, - char *buffer, - int buffer_size) -{ - char *format; - - if (use_24_hour_format) { - if (!show_zero_seconds && date_tm->tm_sec == 0) - /* strftime format of a time in 24-hour format, - without seconds. */ - format = _("%H:%M"); - else - /* strftime format of a time in 24-hour format. */ - format = _("%H:%M:%S"); - } else { - if (!show_zero_seconds && date_tm->tm_sec == 0) - /* strftime format of a time in 12-hour format, - without seconds. */ - format = _("%I:%M %p"); - else - /* strftime format of a time in 12-hour format. */ - format = _("%I:%M:%S %p"); - } - - /* strftime returns 0 if the string doesn't fit, and leaves the buffer - undefined, so we set it to the empty string in that case. */ - if (e_utf8_strftime (buffer, buffer_size, format, date_tm) == 0) - buffer[0] = '\0'; -} - - -/* Like mktime(3), but assumes UTC instead of local timezone. */ -time_t -e_mktime_utc (struct tm *tm) -{ - time_t tt; - - tm->tm_isdst = -1; - tt = mktime (tm); - -#if defined (HAVE_TM_GMTOFF) - tt += tm->tm_gmtoff; -#elif defined (HAVE_TIMEZONE) - if (tm->tm_isdst > 0) { - #if defined (HAVE_ALTZONE) - tt -= altzone; - #else /* !defined (HAVE_ALTZONE) */ - tt -= (timezone - 3600); - #endif - } else - tt -= timezone; -#endif - - return tt; -} - -/* Like localtime_r(3), but also returns an offset in seconds after UTC. - (Calling gmtime with tt + offset would generate the same tm) */ -void -e_localtime_with_offset (time_t tt, struct tm *tm, int *offset) -{ - localtime_r (&tt, tm); - -#if defined (HAVE_TM_GMTOFF) - *offset = tm->tm_gmtoff; -#elif defined (HAVE_TIMEZONE) - if (tm->tm_isdst > 0) { - #if defined (HAVE_ALTZONE) - *offset = -altzone; - #else /* !defined (HAVE_ALTZONE) */ - *offset = -(timezone - 3600); - #endif - } else - *offset = -timezone; -#endif -} diff --git a/e-util/e-time-utils.h b/e-util/e-time-utils.h deleted file mode 100644 index 0b081dadd4..0000000000 --- a/e-util/e-time-utils.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Time utility functions - * - * Author: - * Damon Chaplin (damon@ximian.com) - * - * (C) 2001 Ximian, Inc. - */ - -#ifndef E_TIME_UTILS -#define E_TIME_UTILS - -#include <time.h> -#include <glib.h> - -typedef enum { - E_TIME_PARSE_OK, - E_TIME_PARSE_NONE, - E_TIME_PARSE_INVALID -} ETimeParseStatus; - -/* Tries to parse a string containing a date and time. */ -ETimeParseStatus e_time_parse_date_and_time (const char *value, - struct tm *result); - -/* Tries to parse a string containing a date. */ -ETimeParseStatus e_time_parse_date (const char *value, - struct tm *result); - -/* Tries to parse a string containing a time. */ -ETimeParseStatus e_time_parse_time (const char *value, - struct tm *result); - -/* Turns a struct tm into a string like "Wed 3/12/00 12:00:00 AM". */ -void e_time_format_date_and_time (struct tm *date_tm, - gboolean use_24_hour_format, - gboolean show_midnight, - gboolean show_zero_seconds, - char *buffer, - int buffer_size); - -/* Formats a time from a struct tm, e.g. "01:59 PM". */ -void e_time_format_time (struct tm *date_tm, - gboolean use_24_hour_format, - gboolean show_zero_seconds, - char *buffer, - int buffer_size); - - -/* Like mktime(3), but assumes UTC instead of local timezone. */ -time_t e_mktime_utc (struct tm *timeptr); - -/* Like localtime_r(3), but also returns an offset in minutes after UTC. - (Calling gmtime with tt + offset would generate the same tm) */ -void e_localtime_with_offset (time_t tt, struct tm *tm, int *offset); - -#endif /* E_TIME_UTILS */ diff --git a/e-util/e-uid.c b/e-util/e-uid.c deleted file mode 100644 index 90c036e0c1..0000000000 --- a/e-util/e-uid.c +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-uid.c - Unique ID generator. - * - * Copyright (C) 2002 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Dan Winship <danw@ximian.com> - */ - -#include "e-uid.h" - -#include <glib/gstrfuncs.h> - -#include <string.h> -#include <time.h> -#include <unistd.h> - - -/** - * e_uid_new: - * - * Generate a new unique string for use e.g. in account lists. - * - * Return value: the newly generated UID. The caller should free the string - * when it's done with it. - **/ -char * -e_uid_new (void) -{ - static char *hostname; - static int serial; - - if (!hostname) { - static char buffer [512]; - - if ((gethostname (buffer, sizeof (buffer) - 1) == 0) && - (buffer [0] != 0)) - hostname = buffer; - else - hostname = "localhost"; - } - - return g_strdup_printf ("%lu.%lu.%d@%s", - (unsigned long) time (NULL), - (unsigned long) getpid (), - serial++, - hostname); -} diff --git a/e-util/e-uid.h b/e-util/e-uid.h deleted file mode 100644 index 44ec8c0dd9..0000000000 --- a/e-util/e-uid.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-uid.h - Unique ID generator. - * - * Copyright (C) 2002 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 - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Dan Winship <danw@ximian.com> - */ - -#ifndef E_UID_H -#define E_UID_H - -char *e_uid_new (void); - -#endif /* E_UID_H */ diff --git a/e-util/e-util-marshal.list b/e-util/e-util-marshal.list deleted file mode 100644 index 463afd8129..0000000000 --- a/e-util/e-util-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -NONE:NONE -NONE:OBJECT diff --git a/e-util/eggtrayicon.c b/e-util/eggtrayicon.c deleted file mode 100644 index 6c309306e9..0000000000 --- a/e-util/eggtrayicon.c +++ /dev/null @@ -1,480 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* eggtrayicon.c - * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <string.h> -#include <libintl.h> - -#include "eggtrayicon.h" - -#include <gdk/gdkx.h> -#include <X11/Xatom.h> - -#ifndef EGG_COMPILATION -#ifndef _ -#define _(x) dgettext (GETTEXT_PACKAGE, x) -#define N_(x) x -#endif -#else -#define _(x) x -#define N_(x) x -#endif - -#define SYSTEM_TRAY_REQUEST_DOCK 0 -#define SYSTEM_TRAY_BEGIN_MESSAGE 1 -#define SYSTEM_TRAY_CANCEL_MESSAGE 2 - -#define SYSTEM_TRAY_ORIENTATION_HORZ 0 -#define SYSTEM_TRAY_ORIENTATION_VERT 1 - -enum { - PROP_0, - PROP_ORIENTATION -}; - -static GtkPlugClass *parent_class = NULL; - -static void egg_tray_icon_init (EggTrayIcon *icon); -static void egg_tray_icon_class_init (EggTrayIconClass *klass); - -static void egg_tray_icon_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void egg_tray_icon_realize (GtkWidget *widget); -static void egg_tray_icon_unrealize (GtkWidget *widget); - -static void egg_tray_icon_update_manager_window (EggTrayIcon *icon); - -GType -egg_tray_icon_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (EggTrayIconClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) egg_tray_icon_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EggTrayIcon), - 0, /* n_preallocs */ - (GInstanceInitFunc) egg_tray_icon_init - }; - - our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0); - } - - return our_type; -} - -static void -egg_tray_icon_init (EggTrayIcon *icon) -{ - icon->stamp = 1; - icon->orientation = GTK_ORIENTATION_HORIZONTAL; - - gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK); -} - -static void -egg_tray_icon_class_init (EggTrayIconClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *)klass; - GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->get_property = egg_tray_icon_get_property; - - widget_class->realize = egg_tray_icon_realize; - widget_class->unrealize = egg_tray_icon_unrealize; - - g_object_class_install_property (gobject_class, - PROP_ORIENTATION, - g_param_spec_enum ("orientation", - _("Orientation"), - _("The orientation of the tray."), - GTK_TYPE_ORIENTATION, - GTK_ORIENTATION_HORIZONTAL, - G_PARAM_READABLE)); -} - -static void -egg_tray_icon_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EggTrayIcon *icon = EGG_TRAY_ICON (object); - - switch (prop_id) - { - case PROP_ORIENTATION: - g_value_set_enum (value, icon->orientation); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -egg_tray_icon_get_orientation_property (EggTrayIcon *icon) -{ - Display *xdisplay; - Atom type; - int format; - union { - gulong *prop; - guchar *prop_ch; - } prop = { NULL }; - gulong nitems; - gulong bytes_after; - int error, result; - - g_assert (icon->manager_window != None); - - xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - - gdk_error_trap_push (); - type = None; - result = XGetWindowProperty (xdisplay, - icon->manager_window, - icon->orientation_atom, - 0, G_MAXLONG, FALSE, - XA_CARDINAL, - &type, &format, &nitems, - &bytes_after, &(prop.prop_ch)); - error = gdk_error_trap_pop (); - - if (error || result != Success) - return; - - if (type == XA_CARDINAL) - { - GtkOrientation orientation; - - orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ? - GTK_ORIENTATION_HORIZONTAL : - GTK_ORIENTATION_VERTICAL; - - if (icon->orientation != orientation) - { - icon->orientation = orientation; - - g_object_notify (G_OBJECT (icon), "orientation"); - } - } - - if (prop.prop) - XFree (prop.prop); -} - -static GdkFilterReturn -egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data) -{ - EggTrayIcon *icon = user_data; - XEvent *xev = (XEvent *)xevent; - - if (xev->xany.type == ClientMessage && - xev->xclient.message_type == icon->manager_atom && - xev->xclient.data.l[1] == icon->selection_atom) - { - egg_tray_icon_update_manager_window (icon); - } - else if (xev->xany.window == icon->manager_window) - { - if (xev->xany.type == PropertyNotify && - xev->xproperty.atom == icon->orientation_atom) - { - egg_tray_icon_get_orientation_property (icon); - } - if (xev->xany.type == DestroyNotify) - { - egg_tray_icon_update_manager_window (icon); - } - } - - return GDK_FILTER_CONTINUE; -} - -static void -egg_tray_icon_unrealize (GtkWidget *widget) -{ - EggTrayIcon *icon = EGG_TRAY_ICON (widget); - GdkWindow *root_window; - - if (icon->manager_window != None) - { - GdkWindow *gdkwin; - - gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget), - icon->manager_window); - - gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); - } - - root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); - - gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon); - - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); -} - -static void -egg_tray_icon_send_manager_message (EggTrayIcon *icon, - long message, - Window window, - long data1, - long data2, - long data3) -{ - XClientMessageEvent ev; - Display *display; - - ev.type = ClientMessage; - ev.window = window; - ev.message_type = icon->system_tray_opcode_atom; - ev.format = 32; - ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window); - ev.data.l[1] = message; - ev.data.l[2] = data1; - ev.data.l[3] = data2; - ev.data.l[4] = data3; - - display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - - gdk_error_trap_push (); - XSendEvent (display, - icon->manager_window, False, NoEventMask, (XEvent *)&ev); - XSync (display, False); - gdk_error_trap_pop (); -} - -static void -egg_tray_icon_send_dock_request (EggTrayIcon *icon) -{ - egg_tray_icon_send_manager_message (icon, - SYSTEM_TRAY_REQUEST_DOCK, - icon->manager_window, - gtk_plug_get_id (GTK_PLUG (icon)), - 0, 0); -} - -static void -egg_tray_icon_update_manager_window (EggTrayIcon *icon) -{ - Display *xdisplay; - - xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - - if (icon->manager_window != None) - { - GdkWindow *gdkwin; - - gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), - icon->manager_window); - - gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); - } - - XGrabServer (xdisplay); - - icon->manager_window = XGetSelectionOwner (xdisplay, - icon->selection_atom); - - if (icon->manager_window != None) - XSelectInput (xdisplay, - icon->manager_window, StructureNotifyMask|PropertyChangeMask); - - XUngrabServer (xdisplay); - XFlush (xdisplay); - - if (icon->manager_window != None) - { - GdkWindow *gdkwin; - - gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), - icon->manager_window); - - gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon); - - /* Send a request that we'd like to dock */ - egg_tray_icon_send_dock_request (icon); - - egg_tray_icon_get_orientation_property (icon); - } -} - -static void -egg_tray_icon_realize (GtkWidget *widget) -{ - EggTrayIcon *icon = EGG_TRAY_ICON (widget); - GdkScreen *screen; - GdkDisplay *display; - Display *xdisplay; - char buffer[256]; - GdkWindow *root_window; - - if (GTK_WIDGET_CLASS (parent_class)->realize) - GTK_WIDGET_CLASS (parent_class)->realize (widget); - - screen = gtk_widget_get_screen (widget); - display = gdk_screen_get_display (screen); - xdisplay = gdk_x11_display_get_xdisplay (display); - - /* Now see if there's a manager window around */ - g_snprintf (buffer, sizeof (buffer), - "_NET_SYSTEM_TRAY_S%d", - gdk_screen_get_number (screen)); - - icon->selection_atom = XInternAtom (xdisplay, buffer, False); - - icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False); - - icon->system_tray_opcode_atom = XInternAtom (xdisplay, - "_NET_SYSTEM_TRAY_OPCODE", - False); - - icon->orientation_atom = XInternAtom (xdisplay, - "_NET_SYSTEM_TRAY_ORIENTATION", - False); - - egg_tray_icon_update_manager_window (icon); - - root_window = gdk_screen_get_root_window (screen); - - /* Add a root window filter so that we get changes on MANAGER */ - gdk_window_add_filter (root_window, - egg_tray_icon_manager_filter, icon); -} - -EggTrayIcon * -egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name) -{ - GdkDisplay *display; - GdkScreen *screen; - - display = gdk_x11_lookup_xdisplay (DisplayOfScreen (xscreen)); - screen = gdk_display_get_screen (display, XScreenNumberOfScreen (xscreen)); - - return egg_tray_icon_new_for_screen (screen, name); -} - -EggTrayIcon * -egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name) -{ - g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); - - return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL); -} - -EggTrayIcon* -egg_tray_icon_new (const gchar *name) -{ - return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL); -} - -guint -egg_tray_icon_send_message (EggTrayIcon *icon, - gint timeout, - const gchar *message, - gint len) -{ - guint stamp; - - g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0); - g_return_val_if_fail (timeout >= 0, 0); - g_return_val_if_fail (message != NULL, 0); - - if (icon->manager_window == None) - return 0; - - if (len < 0) - len = strlen (message); - - stamp = icon->stamp++; - - /* Get ready to send the message */ - egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE, - (Window)gtk_plug_get_id (GTK_PLUG (icon)), - timeout, len, stamp); - - /* Now to send the actual message */ - gdk_error_trap_push (); - while (len > 0) - { - XClientMessageEvent ev; - Display *xdisplay; - - xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - - ev.type = ClientMessage; - ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon)); - ev.format = 8; - ev.message_type = XInternAtom (xdisplay, - "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); - if (len > 20) - { - memcpy (&ev.data, message, 20); - len -= 20; - message += 20; - } - else - { - memcpy (&ev.data, message, len); - len = 0; - } - - XSendEvent (xdisplay, - icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev); - XSync (xdisplay, False); - } - gdk_error_trap_pop (); - - return stamp; -} - -void -egg_tray_icon_cancel_message (EggTrayIcon *icon, - guint id) -{ - g_return_if_fail (EGG_IS_TRAY_ICON (icon)); - g_return_if_fail (id > 0); - - egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE, - (Window)gtk_plug_get_id (GTK_PLUG (icon)), - id, 0, 0); -} - -GtkOrientation -egg_tray_icon_get_orientation (EggTrayIcon *icon) -{ - g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL); - - return icon->orientation; -} diff --git a/e-util/eggtrayicon.h b/e-util/eggtrayicon.h deleted file mode 100644 index 007f4c18e9..0000000000 --- a/e-util/eggtrayicon.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* eggtrayicon.h - * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __EGG_TRAY_ICON_H__ -#define __EGG_TRAY_ICON_H__ - -#include <gtk/gtkplug.h> -#include <gdk/gdkx.h> - -G_BEGIN_DECLS - -#define EGG_TYPE_TRAY_ICON (egg_tray_icon_get_type ()) -#define EGG_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon)) -#define EGG_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) -#define EGG_IS_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TRAY_ICON)) -#define EGG_IS_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON)) -#define EGG_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) - -typedef struct _EggTrayIcon EggTrayIcon; -typedef struct _EggTrayIconClass EggTrayIconClass; - -struct _EggTrayIcon -{ - GtkPlug parent_instance; - - guint stamp; - - Atom selection_atom; - Atom manager_atom; - Atom system_tray_opcode_atom; - Atom orientation_atom; - Window manager_window; - - GtkOrientation orientation; -}; - -struct _EggTrayIconClass -{ - GtkPlugClass parent_class; -}; - -GType egg_tray_icon_get_type (void); - -EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen *screen, - const gchar *name); - -EggTrayIcon *egg_tray_icon_new (const gchar *name); - -guint egg_tray_icon_send_message (EggTrayIcon *icon, - gint timeout, - const char *message, - gint len); -void egg_tray_icon_cancel_message (EggTrayIcon *icon, - guint id); - -GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon); - -G_END_DECLS - -#endif /* __EGG_TRAY_ICON_H__ */ diff --git a/e-util/md5-utils.c b/e-util/md5-utils.c deleted file mode 100644 index e550968828..0000000000 --- a/e-util/md5-utils.c +++ /dev/null @@ -1,355 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to md5_init, call md5_update as - * needed on buffers full of bytes, and then call md5_Final, which - * will fill a supplied 16-byte array with the digest. - */ - -/* parts of this file are : - * Written March 1993 by Branko Lankester - * Modified June 1993 by Colin Plumb for altered md5.c. - * Modified October 1995 by Erik Troan for RPM - */ - - -#include <stdio.h> -#include <string.h> -#include "md5-utils.h" - - -static void md5_transform (guint32 buf[4], const guint32 in[16]); - -static gint _ie = 0x44332211; -static union _endian { gint i; gchar b[4]; } *_endian = (union _endian *)&_ie; -#define IS_BIG_ENDIAN() (_endian->b[0] == '\x44') -#define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11') - - -/* - * Note: this code is harmless on little-endian machines. - */ -static void -_byte_reverse (guchar *buf, guint32 longs) -{ - guint32 t; - do { - t = (guint32) ((guint32) buf[3] << 8 | buf[2]) << 16 | - ((guint32) buf[1] << 8 | buf[0]); - *(guint32 *) buf = t; - buf += 4; - } while (--longs); -} - -/** - * md5_init: Initialise an md5 context object - * @ctx: md5 context - * - * Initialise an md5 buffer. - * - **/ -void -md5_init (MD5Context *ctx) -{ - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bits[0] = 0; - ctx->bits[1] = 0; - - if (IS_BIG_ENDIAN()) - ctx->doByteReverse = 1; - else - ctx->doByteReverse = 0; -} - - - -/** - * md5_update: add a buffer to md5 hash computation - * @ctx: conetxt object used for md5 computaion - * @buf: buffer to add - * @len: buffer length - * - * Update context to reflect the concatenation of another buffer full - * of bytes. Use this to progressively construct an md5 hash. - **/ -void -md5_update (MD5Context *ctx, const guchar *buf, guint32 len) -{ - guint32 t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((guint32) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) { - guchar *p = (guchar *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memcpy (p, buf, len); - return; - } - memcpy (p, buf, t); - if (ctx->doByteReverse) - _byte_reverse (ctx->in, 16); - md5_transform (ctx->buf, (guint32 *) ctx->in); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memcpy (ctx->in, buf, 64); - if (ctx->doByteReverse) - _byte_reverse (ctx->in, 16); - md5_transform (ctx->buf, (guint32 *) ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memcpy (ctx->in, buf, len); -} - - - - - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -/** - * md5_final: copy the final md5 hash to a bufer - * @digest: 16 bytes buffer - * @ctx: context containing the calculated md5 - * - * copy the final md5 hash to a bufer - **/ -void -md5_final (MD5Context *ctx, guchar digest[16]) -{ - guint32 count; - guchar *p; - - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset (p, 0, count); - if (ctx->doByteReverse) - _byte_reverse (ctx->in, 16); - md5_transform (ctx->buf, (guint32 *) ctx->in); - - /* Now fill the next block with 56 bytes */ - memset (ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset (p, 0, count - 8); - } - if (ctx->doByteReverse) - _byte_reverse (ctx->in, 14); - - /* Append length in bits and transform */ - ((guint32 *) ctx->in)[14] = ctx->bits[0]; - ((guint32 *) ctx->in)[15] = ctx->bits[1]; - - md5_transform (ctx->buf, (guint32 *) ctx->in); - if (ctx->doByteReverse) - _byte_reverse ((guchar *) ctx->buf, 4); - memcpy (digest, ctx->buf, 16); -} - - - - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. md5_Update blocks - * the data and converts bytes into longwords for this routine. - */ -static void -md5_transform (guint32 buf[4], const guint32 in[16]) -{ - register guint32 a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP (F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP (F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP (F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP (F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP (F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP (F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP (F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP (F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP (F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP (F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP (F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP (F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP (F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP (F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP (F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP (F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP (F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP (F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP (F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP (F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP (F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP (F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP (F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP (F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP (F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP (F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP (F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP (F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP (F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP (F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP (F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP (F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP (F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP (F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP (F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP (F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP (F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP (F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP (F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP (F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP (F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP (F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP (F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP (F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP (F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP (F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP (F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP (F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP (F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP (F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP (F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP (F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP (F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP (F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP (F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP (F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP (F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP (F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP (F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP (F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP (F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP (F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP (F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP (F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - - - - -/** - * md5_get_digest: get the md5 hash of a buffer - * @buffer: byte buffer - * @buffer_size: buffer size (in bytes) - * @digest: 16 bytes buffer receiving the hash code. - * - * Get the md5 hash of a buffer. The result is put in - * the 16 bytes buffer @digest . - **/ -void -md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16]) -{ - MD5Context ctx; - - md5_init (&ctx); - md5_update (&ctx, buffer, buffer_size); - md5_final (&ctx, digest); - -} - - -/** - * md5_get_digest_from_file: get the md5 hash of a file - * @filename: file name - * @digest: 16 bytes buffer receiving the hash code. - * - * Get the md5 hash of a file. The result is put in - * the 16 bytes buffer @digest . - **/ -void -md5_get_digest_from_file (const gchar *filename, guchar digest[16]) -{ - MD5Context ctx; - guchar tmp_buf[1024]; - gint nb_bytes_read; - FILE *fp; - - md5_init (&ctx); - fp = fopen(filename, "r"); - if (!fp) { - return; - } - - while ((nb_bytes_read = fread (tmp_buf, sizeof (guchar), 1024, fp)) > 0) - md5_update (&ctx, tmp_buf, nb_bytes_read); - - if (ferror(fp)) { - fclose(fp); - return; - } - - - md5_final (&ctx, digest); -} diff --git a/e-util/md5-utils.h b/e-util/md5-utils.h deleted file mode 100644 index 607471a752..0000000000 --- a/e-util/md5-utils.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to rpmMD5Init, call rpmMD5Update as - * needed on buffers full of bytes, and then call rpmMD5Final, which - * will fill a supplied 16-byte array with the digest. - */ - -/* parts of this file are : - * Written March 1993 by Branko Lankester - * Modified June 1993 by Colin Plumb for altered md5.c. - * Modified October 1995 by Erik Troan for RPM - */ - - -#ifndef MD5_UTILS_H -#define MD5_UTILS_H - -#include <glib.h> - - -typedef struct _MD5Context { - guint32 buf[4]; - guint32 bits[2]; - guchar in[64]; - gint doByteReverse; -} MD5Context; - - -void md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16]); - -/* use this one when speed is needed */ -/* for use in provider code only */ -void md5_get_digest_from_file (const gchar *filename, guchar digest[16]); - -/* raw routines */ -void md5_init (MD5Context *ctx); -void md5_update (MD5Context *ctx, const guchar *buf, guint32 len); -void md5_final (MD5Context *ctx, guchar digest[16]); - - -#endif /* MD5_UTILS_H */ |