From 2e5b2bbb530b642dda56b332cfd93810ac415098 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 1 Apr 2003 17:15:53 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'EVOLUTION_1_2_4'. svn path=/tags/EVOLUTION_1_2_4/; revision=20614 --- e-util/ChangeLog | 480 +----------- e-util/Makefile.am | 56 +- e-util/e-bit-array.c | 429 ----------- e-util/e-bit-array.h | 104 --- e-util/e-categories-config.c | 43 +- e-util/e-component-listener.c | 83 +- e-util/e-config-listener.c | 408 +++++----- e-util/e-config-listener.h | 33 +- e-util/e-dialog-utils.c | 337 ++++---- e-util/e-html-utils.c | 5 + e-util/e-i18n.h | 75 -- e-util/e-iconv.c | 610 --------------- e-util/e-iconv.h | 49 -- e-util/e-lang-utils.c | 1 + e-util/e-msgport.c | 21 - e-util/e-msgport.h | 2 - e-util/e-pilot-settings.h | 16 +- e-util/e-proxy.c | 61 +- e-util/e-sorter-array.c | 259 ------- e-util/e-sorter-array.h | 77 -- e-util/e-sorter.c | 153 ---- e-util/e-sorter.h | 82 -- e-util/e-text-event-processor-emacs-like.c | 489 ------------ e-util/e-text-event-processor-emacs-like.h | 70 -- e-util/e-text-event-processor-types.h | 132 ---- e-util/e-text-event-processor.c | 148 ---- e-util/e-text-event-processor.h | 77 -- e-util/e-util.c | 1150 ---------------------------- e-util/e-util.h | 221 ------ e-util/e-xml-hash-utils.c | 2 +- e-util/e-xml-utils.c | 502 ------------ e-util/e-xml-utils.h | 101 --- 32 files changed, 540 insertions(+), 5736 deletions(-) delete mode 100644 e-util/e-bit-array.c delete mode 100644 e-util/e-bit-array.h delete mode 100644 e-util/e-i18n.h delete mode 100644 e-util/e-iconv.c delete mode 100644 e-util/e-iconv.h delete mode 100644 e-util/e-sorter-array.c delete mode 100644 e-util/e-sorter-array.h delete mode 100644 e-util/e-sorter.c delete mode 100644 e-util/e-sorter.h delete mode 100644 e-util/e-text-event-processor-emacs-like.c delete mode 100644 e-util/e-text-event-processor-emacs-like.h delete mode 100644 e-util/e-text-event-processor-types.h delete mode 100644 e-util/e-text-event-processor.c delete mode 100644 e-util/e-text-event-processor.h delete mode 100644 e-util/e-util.c delete mode 100644 e-util/e-util.h delete mode 100644 e-util/e-xml-utils.c delete mode 100644 e-util/e-xml-utils.h (limited to 'e-util') diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 4b024cedec..30eff14bf4 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,335 +1,55 @@ -2003-03-31 Chris Toshok +2003-03-05 Rodney Dawes - * 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 - - * e-account-list.c (e_account_list_find): guard against NULL keys - -2003-03-25 Dan Winship - - * 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 - - * e-meta.c (meta_filename): fix a typo & some missing headers. - -2003-03-24 Dan Winship - - * 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 - - * 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 - - * 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 - - * 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 - - * e-trie.c (trie_utf8_getc): Don't use __inline__ as it is not - always defined. - -2003-03-13 Dan Winship - - * 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 - - * 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 - - * e-request.c (e_request_string): Make the entry activate the - default response in the dialog. - -2003-03-03 Rodney Dawes - - * e-proxy.c: Use gnome2 proxy settings + * e-proxy.c: Don't append trailing slash to paths for dir_exists calls -2003-03-02 Rodney Dawes +2003-02-14 Rodney Dawes - * e-pilot-util.c: s/gnome-xml/libxml/ + * e-proxy.c: Fixed a typo dir_exits should be dir_exists -2003-02-27 JP Rosevear - - * Makefile.am: include gnome-pilot cflags - -2003-02-23 Jeffrey Stedfast - - * e-account-list.c (gconf_accounts_changed): 'uid' should not be - const. - -2003-02-20 Not Zed - - * 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 - - * 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 - - * e-account-list.c (gconf_accounts_changed): fix memleak - free - uid. - -2003-02-11 Not Zed - - * 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 - - * 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 - - * 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 - - * 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 - - * e-pilot-settings.c (e_pilot_settings_new): ref/sink the pilot - settings to clear up that gtk warning. - -2003-01-25 Chris Toshok - - * 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 - - * e-pilot-settings.[ch]: GObjectify this. - -2003-01-24 Hans Petter Jansson - - * 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 - - * 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 - - * 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 - - * e-xml-hash-utils.c: New, sort of from evolution-recurid-branch. - -2003-01-16 Dan Winship - - * 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 - - * e-dialog-utils.c: Do not #include . - (e_set_dialog_parent): Remove the BonoboWidget handling stuff (it - doesn't really work anyways). - -2003-01-14 Ettore Perazzoli +2003-02-11 Rodney Dawes - * Makefile.am (eutilinclude_HEADERS): Add e-dialog-utils.h. - -2003-01-09 Chris Toshok - - * e-gui-utils.c (e_create_image_widget): change this to use - GtkImage instead of GnomeCanvas. - -2003-01-08 Ettore Perazzoli - - * Makefile.am: Images are now in $(datadir)/evolution/images - instead of $(datadir)/images/evolution. - -2003-01-07 Dan Winship - - * e-config-listener.c (e_config_listener_remove_value): New. + * e-proxy.c (set_proxy): Priority use of gnome2 proxy settings if + they are set, as we are most likely running under gnome2. + +2003-02-05 JP Rosevear - * e-passwords.c (e_passwords_get_password): Don't look at the - passwords hash until calling e_passwords_init(). + * e-xml-hash-utils.[hc]: back port from main line -2003-01-06 Dan Winship + * Makefile.am: build back ported files - * 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. +2003-02-04 Ettore Perazzoli - * Makefile.am (libeutil_la_SOURCES): re-add e-html-utils + * Makefile.am: Build e-pilot-settings into libeconduit if ! + ENABLE_PILOT_CONDUITS, so we avoid doing a non-portable "ar cru" + without any object files [fails on OS X, reported by Max Horn + ]. -2003-01-02 Jeffrey Stedfast +2003-01-24 Kjartan Maraas - A bunch of fixes to make e-util build with -DG_DISABLE_DEPRECATED - and -DGTK_DISABLE_DEPRECATED. + * e-categories-config.c: Fix #include + * e-component-listener.c: Same + * e-config-listener.c: Here too. + * e-dialog-utils.c: And here. + * e-html-utils.c: And here. + * e-pilot-settings.h: And remove it here. -2003-01-02 Ettore Perazzoli +2003-01-10 JP Rosevear - * e-gtk-utils.c (e_signal_connect_full_while_alive): Get to - compile. - (e_signal_connect_while_alive): Like. + * e-xml-utils.[hc]: various xml utility routines -2002-12-19 Ettore Perazzoli + * e-xmlhash.[hc]: new files to manage an xml hash on disk - * 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(). + * Makefile.am: Build new files -2002-12-16 Jeffrey Stedfast +2002-12-10 JP Rosevear - * e-html-utils.[c,h]: Removed. Back to the fiery depths of hell - from whence ye came! + * e-config-listener.c (e_config_listener_remove_dir): Fix warning 2002-12-10 Rodrigo Moya - * e-config-listener.[ch] (e_config_listener_remove_dir): new - function. - -2002-12-09 Jeffrey Stedfast - - * e-trie.c: New implementation of an Aho-Corasick trie. - -2002-12-09 Chris Toshok - - * 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 - - * e-msgport.c (e_mutex_cond_wait): Allow an e-mutex to be used - with standard condition variables. - -2002-12-06 Chris Toshok - - * 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 + * e-config-listener.[ch] (e_config_listener_remove_dir): new function. + +2002-11-25 Dan Winship * 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. @@ -347,142 +67,6 @@ (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 - - * 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 - - * 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 - - * e-config-listener.c (add_key): g_strdup() the value in the case - of a string value. - -2002-11-11 Jeffrey Stedfast - - * Makefile.am: Re-add e-proxy.c to the build. - -2002-11-08 Chris Toshok - - * 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 - - * 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 - - * 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 - - * e-component-listener.[ch]: ported to GObject. - - * Makefile.am: re-enabled e-component-listener.[ch] - -2002-11-03 Rodrigo Moya - - * 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 - - * 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 - - * 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 - - * ename/Makefile.am (INCLUDES): Removed -I$(includedir). - - * ename/test-ename-western-gtk.c: #include - instead of . - (create_window): Added GTK_SIGNAL_FUNC() cast. - (main): Use gnome_program_init(). - - * e-db3-utils.c: Do not #include . - - * e-request.c: Do not #include . - - * 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 . - - * e-gui-utils.c: Don't #include . - (e_create_image_widget): Pass NULL to gdk_pixbuf_new_from_file() - for the error arg. - - * e-corba-utils.h: #include instead of - . - - * 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 - - * e-config-listener.[ch]: ported to GConf and GObject. - -2002-11-01 Rodrigo Moya - - * e-config-listener.[ch]: - * e-component-listener.[ch]: compilation fixes for GNOME 2 porting. - 2002-10-24 Rodrigo Moya Fixes #32764 diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 74bf6978d7..ed912cab03 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -1,28 +1,27 @@ SUBDIRS = . ename -eutilincludedir = $(privincludedir)/e-util -econdincludedir = $(privincludedir)/e-conduit -edb3includedir = $(privincludedir)/e-db3util +imagesdir = $(datadir)/images/evolution + +eutilincludedir = $(includedir)/evolution/e-util +econdincludedir = $(includedir)/evolution/e-conduit +edb3includedir = $(includedir)/evolution/e-db3util INCLUDES = \ -I$(top_srcdir) \ -DEVOLUTION_IMAGES=\""$(imagesdir)"\" \ -DEVOLUTION_CATEGORY_ICONS=\""$(imagesdir)/categories"\" \ -DG_LOG_DOMAIN=\"e-utils\" \ - -DG_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ $(DB3_CFLAGS) \ - $(GNOME_PILOT_CFLAGS) \ + $(PISOCK_CFLAGS) \ $(E_UTIL_CFLAGS) privlib_LTLIBRARIES = libeutil.la libedb3util.la libeconduit.la noinst_LTLIBRARIES = libeutil-static.la libeconduit-static.la eutilinclude_HEADERS = \ - e-account-list.h \ - e-account.h \ - e-categories-config.h \ + e-bonobo-factory-util.h \ e-categories-master-list-wombat.h \ + e-categories-config.h \ e-component-listener.h \ e-config-listener.h \ e-corba-utils.h \ @@ -37,7 +36,6 @@ eutilinclude_HEADERS = \ e-list-iterator.h \ e-list.h \ e-memory.h \ - e-meta.h \ e-mktemp.h \ e-msgport.h \ e-passwords.h \ @@ -46,17 +44,15 @@ eutilinclude_HEADERS = \ e-request.h \ e-sexp.h \ e-time-utils.h \ - e-trie.h \ e-url.h \ e-xml-hash-utils.h \ md5-utils.h libeutil_la_SOURCES = \ $(eutilinclude_HEADERS) \ - e-account-list.c \ - e-account.c \ - e-categories-config.c \ + e-bonobo-factory-util.c \ e-categories-master-list-wombat.c \ + e-categories-config.c \ e-component-listener.c \ e-config-listener.c \ e-corba-utils.c \ @@ -71,7 +67,6 @@ libeutil_la_SOURCES = \ e-list-iterator.c \ e-list.c \ e-memory.c \ - e-meta.c \ e-mktemp.c \ e-msgport.c \ e-passwords.c \ @@ -80,39 +75,15 @@ libeutil_la_SOURCES = \ e-request.c \ e-sexp.c \ e-time-utils.c \ - e-trie.c \ e-url.c \ - e-util-marshal.c \ e-xml-hash-utils.c \ md5-utils.c -# GLib marshalling cruft - -e-util-marshal.h: e-util-marshal.list - ( @GLIB_GENMARSHAL@ --prefix=e_util_marshal e-util-marshal.list --header > e-util-marshal.h.tmp \ - && mv e-util-marshal.h.tmp e-util-marshal.h ) \ - || ( rm -f e-util-marshal.h.tmp && exit 1 ) - -e-util-marshal.c: e-util-marshal.h - ( @GLIB_GENMARSHAL@ --prefix=e_util_marshal e-util-marshal.list --body > e-util-marshal.c.tmp \ - && mv e-util-marshal.c.tmp e-util-marshal.c ) \ - || ( rm -f e-util-marshal.c.tmp && exit 1 ) - -MARSHAL_GENERATED = e-util-marshal.c e-util-marshal.h - - -# FIXME TODO -# e-passwords.c -# bonobo-factory-util.[ch] - libeutil_la_LIBADD = $(E_UTIL_LIBS) libeutil_static_la_SOURCES = $(libeutil_la_SOURCES) libeutil_static_la_LIBADD = $(libeutil_la_LIBADD) libeutil_static_la_LDFLAGS = -all-static -# Make sure libeutil.la and libeutil-static.la are not built in -# parallel when using a parallel make; libtool can't handle that. -libeutil_static_la_DEPENDENCIES = libeutil.la econdinclude_HEADERS = \ e-pilot-map.h \ @@ -128,7 +99,7 @@ pilot_sources = \ if ENABLE_PILOT_CONDUITS pilot_compile = $(pilot_sources) else -pilot_compile = +pilot_compile = e-pilot-settings.c e-pilot-settings.h endif libeconduit_la_SOURCES = $(pilot_compile) @@ -136,7 +107,7 @@ libeconduit_la_SOURCES = $(pilot_compile) libeconduit_static_la_SOURCES = $(libeconduit_la_SOURCES) libeconduit_static_la_LDFLAGS = -all-static -EXTRA_DIST = $(pilot_sources) e-util-marshal.list +EXTRA_DIST = $(pilot_sources) edb3include_HEADERS = \ e-db3-utils.h \ @@ -146,6 +117,3 @@ libedb3util_la_SOURCES = \ $(edb3include_HEADERS) \ e-db3-utils.c \ e-dbhash.c - -BUILT_SOURCES = $(MARSHAL_GENERATED) -CLEANFILES = $(BUILT_SOURCES) diff --git a/e-util/e-bit-array.c b/e-util/e-bit-array.c deleted file mode 100644 index 2a79e1bab2..0000000000 --- a/e-util/e-bit-array.c +++ /dev/null @@ -1,429 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-bit-array.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 -#include -#include "e-bit-array.h" -#include "gal/util/e-util.h" - -#define PARENT_TYPE G_TYPE_OBJECT - -#define ONES ((guint32) 0xffffffff) - -#define BOX(n) ((n) / 32) -#define OFFSET(n) (31 - ((n) % 32)) -#define BITMASK(n) ((guint32)(((guint32) 0x1) << OFFSET((n)))) -#define BITMASK_LEFT(n) ((((n) % 32) == 0) ? 0 : (ONES << (32 - ((n) % 32)))) -#define BITMASK_RIGHT(n) ((guint32)(((guint32) ONES) >> ((n) % 32))) - -static GObjectClass *parent_class; - -static void -e_bit_array_insert_real(EBitArray *eba, int row) -{ - int box; - int i; - if(eba->bit_count >= 0) { - /* Add another word if needed. */ - if ((eba->bit_count & 0x1f) == 0) { - eba->data = g_renew(guint32, eba->data, (eba->bit_count >> 5) + 1); - eba->data[eba->bit_count >> 5] = 0; - } - - /* The box is the word that our row is in. */ - box = BOX(row); - /* Shift all words to the right of our box right one bit. */ - for (i = eba->bit_count >> 5; i > box; i--) { - eba->data[i] = (eba->data[i] >> 1) | (eba->data[i - 1] << 31); - } - - /* Shift right half of box one bit to the right. */ - eba->data[box] = (eba->data[box] & BITMASK_LEFT(row)) | ((eba->data[box] & BITMASK_RIGHT(row)) >> 1); - eba->bit_count ++; - } -} - -static void -e_bit_array_delete_real(EBitArray *eba, int row, gboolean move_selection_mode) -{ - int box; - int i; - int last; - int selected = FALSE; - if(eba->bit_count >= 0) { - guint32 bitmask; - box = row >> 5; - last = eba->bit_count >> 5; - - /* Build bitmasks for the left and right half of the box */ - bitmask = BITMASK_RIGHT(row) >> 1; - if (move_selection_mode) - selected = e_bit_array_value_at(eba, row); - /* Shift right half of box one bit to the left. */ - eba->data[box] = (eba->data[box] & BITMASK_LEFT(row))| ((eba->data[box] & bitmask) << 1); - - /* Shift all words to the right of our box left one bit. */ - if (box < last) { - eba->data[box] &= eba->data[box + 1] >> 31; - - for (i = box + 1; i < last; i++) { - eba->data[i] = (eba->data[i] << 1) | (eba->data[i + 1] >> 31); - } - /* this over-runs our memory! */ - /*eba->data[i] = eba->data[i] << 1; */ - } - eba->bit_count --; - /* Remove the last word if not needed. */ - if ((eba->bit_count & 0x1f) == 0) { - eba->data = g_renew(guint32, eba->data, eba->bit_count >> 5); - } - if (move_selection_mode && selected) { - e_bit_array_select_single_row (eba, row > 0 ? row - 1 : 0); - } - } -} - -/* FIXME : Improve efficiency here. */ -void -e_bit_array_delete(EBitArray *eba, int row, int count) -{ - int i; - for (i = 0; i < count; i++) - e_bit_array_delete_real(eba, row, FALSE); -} - -/* FIXME : Improve efficiency here. */ -void -e_bit_array_delete_single_mode(EBitArray *eba, int row, int count) -{ - int i; - for (i = 0; i < count; i++) - e_bit_array_delete_real(eba, row, TRUE); -} - -/* FIXME : Improve efficiency here. */ -void -e_bit_array_insert(EBitArray *eba, int row, int count) -{ - int i; - for (i = 0; i < count; i++) - e_bit_array_insert_real(eba, row); -} - -/* FIXME: Implement this more efficiently. */ -void -e_bit_array_move_row(EBitArray *eba, int old_row, int new_row) -{ - e_bit_array_delete_real(eba, old_row, FALSE); - e_bit_array_insert_real(eba, new_row); -} - -static void -eba_dispose (GObject *object) -{ - EBitArray *eba; - - eba = E_BIT_ARRAY (object); - - if (eba->data) - g_free(eba->data); - eba->data = NULL; - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/** - * e_selection_model_is_row_selected - * @selection: #EBitArray to check - * @n: The row to check - * - * This routine calculates whether the given row is selected. - * - * Returns: %TRUE if the given row is selected - */ -gboolean -e_bit_array_value_at (EBitArray *eba, - gint n) -{ - if (eba->bit_count < n || eba->bit_count == 0) - return 0; - else - return (eba->data[BOX(n)] >> OFFSET(n)) & 0x1; -} - -/** - * e_selection_model_foreach - * @selection: #EBitArray to traverse - * @callback: The callback function to call back. - * @closure: The closure - * - * This routine calls the given callback function once for each - * selected row, passing closure as the closure. - */ -void -e_bit_array_foreach (EBitArray *eba, - EForeachFunc callback, - gpointer closure) -{ - int i; - int last = (eba->bit_count + 31) / 32; - for (i = 0; i < last; i++) { - if (eba->data[i]) { - int j; - guint32 value = eba->data[i]; - for (j = 0; j < 32; j++) { - if (value & 0x80000000) { - callback(i * 32 + j, closure); - } - value <<= 1; - } - } - } -} - -/** - * e_selection_model_clear - * @selection: #EBitArray to clear - * - * This routine clears the selection to no rows selected. - */ -void -e_bit_array_clear(EBitArray *eba) -{ - g_free(eba->data); - eba->data = NULL; - eba->bit_count = 0; -} - -#define PART(x,n) (((x) & (0x01010101 << n)) >> n) -#define SECTION(x, n) (((x) >> (n * 8)) & 0xff) - -/** - * e_selection_model_selected_count - * @selection: #EBitArray to count - * - * This routine calculates the number of rows selected. - * - * Returns: The number of rows selected in the given model. - */ -gint -e_bit_array_selected_count (EBitArray *eba) -{ - gint count; - int i; - int last; - - if (!eba->data) - return 0; - - count = 0; - - last = BOX(eba->bit_count - 1); - - for (i = 0; i <= last; i++) { - int j; - guint32 thiscount = 0; - for (j = 0; j < 8; j++) - thiscount += PART(eba->data[i], j); - for (j = 0; j < 4; j++) - count += SECTION(thiscount, j); - } - - return count; -} - -/** - * e_selection_model_select_all - * @selection: #EBitArray to select all - * - * This routine selects all the rows in the given - * #EBitArray. - */ -void -e_bit_array_select_all (EBitArray *eba) -{ - int i; - - if (!eba->data) - eba->data = g_new0 (guint32, (eba->bit_count + 31) / 32); - - for (i = 0; i < (eba->bit_count + 31) / 32; i ++) { - eba->data[i] = ONES; - } - - /* need to zero out the bits corresponding to the rows not - selected in the last full 32 bit mask */ - if (eba->bit_count % 32) { - int unselected_mask = 0; - int num_unselected_in_last_byte = 32 - eba->bit_count % 32; - - for (i = 0; i < num_unselected_in_last_byte; i ++) - unselected_mask |= 1 << i; - - eba->data[(eba->bit_count + 31) / 32 - 1] &= ~unselected_mask; - } -} - -/** - * e_selection_model_invert_selection - * @selection: #EBitArray to invert - * - * This routine inverts all the rows in the given - * #EBitArray. - */ -void -e_bit_array_invert_selection (EBitArray *eba) -{ - int i; - - if (!eba->data) - eba->data = g_new0 (guint32, (eba->bit_count + 31) / 32); - - for (i = 0; i < (eba->bit_count + 31) / 32; i ++) { - eba->data[i] = ~eba->data[i]; - } -} - -int -e_bit_array_bit_count (EBitArray *eba) -{ - return eba->bit_count; -} - -gboolean -e_bit_array_cross_and (EBitArray *eba) -{ - int i; - for (i = 0; i < eba->bit_count / 32; i++) { - if (eba->data[i] != ONES) - return FALSE; - } - if ((eba->bit_count % 32) && ((eba->data[i] & BITMASK_LEFT(eba->bit_count)) != BITMASK_LEFT(eba->bit_count))) - return FALSE; - return TRUE; -} - -gboolean -e_bit_array_cross_or (EBitArray *eba) -{ - int i; - for (i = 0; i < eba->bit_count / 32; i++) { - if (eba->data[i] != 0) - return TRUE; - } - if ((eba->bit_count % 32) && ((eba->data[i] & BITMASK_LEFT(eba->bit_count)) != 0)) - return TRUE; - return FALSE; -} - -#define OPERATE(object, i,mask,grow) ((grow) ? (((object)->data[(i)]) |= ((guint32) ~(mask))) : (((object)->data[(i)]) &= (mask))) - -void -e_bit_array_change_one_row(EBitArray *eba, int row, gboolean grow) -{ - int i; - i = BOX(row); - - OPERATE(eba, i, ~BITMASK(row), grow); -} - -void -e_bit_array_change_range(EBitArray *eba, int start, int end, gboolean grow) -{ - int i, last; - if (start != end) { - i = BOX(start); - last = BOX(end); - - if (i == last) { - OPERATE(eba, i, BITMASK_LEFT(start) | BITMASK_RIGHT(end), grow); - } else { - OPERATE(eba, i, BITMASK_LEFT(start), grow); - if (grow) - for (i ++; i < last; i++) - eba->data[i] = ONES; - else - for (i ++; i < last; i++) - eba->data[i] = 0; - OPERATE(eba, i, BITMASK_RIGHT(end), grow); - } - } -} - -void -e_bit_array_select_single_row (EBitArray *eba, int row) -{ - int i; - for (i = 0; i < ((eba->bit_count + 31) / 32); i++) { - if (!((i == BOX(row) && eba->data[i] == BITMASK(row)) || - (i != BOX(row) && eba->data[i] == 0))) { - g_free(eba->data); - eba->data = g_new0(guint32, (eba->bit_count + 31) / 32); - eba->data[BOX(row)] = BITMASK(row); - - break; - } - } -} - -void -e_bit_array_toggle_single_row (EBitArray *eba, int row) -{ - if (eba->data[BOX(row)] & BITMASK(row)) - eba->data[BOX(row)] &= ~BITMASK(row); - else - eba->data[BOX(row)] |= BITMASK(row); -} - - -static void -e_bit_array_init (EBitArray *eba) -{ - eba->data = NULL; - eba->bit_count = 0; -} - -static void -e_bit_array_class_init (EBitArrayClass *klass) -{ - GObjectClass *object_class; - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class = G_OBJECT_CLASS(klass); - - object_class->dispose = eba_dispose; -} - -E_MAKE_TYPE(e_bit_array, "EBitArray", EBitArray, - e_bit_array_class_init, e_bit_array_init, PARENT_TYPE) - -EBitArray * -e_bit_array_new (int count) -{ - EBitArray *eba = g_object_new (E_BIT_ARRAY_TYPE, NULL); - eba->bit_count = count; - eba->data = g_new0(guint32, (eba->bit_count + 31) / 32); - return eba; -} diff --git a/e-util/e-bit-array.h b/e-util/e-bit-array.h deleted file mode 100644 index ebfe644da6..0000000000 --- a/e-util/e-bit-array.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-bit-array.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_BIT_ARRAY_H_ -#define _E_BIT_ARRAY_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define E_BIT_ARRAY_TYPE (e_bit_array_get_type ()) -#define E_BIT_ARRAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_BIT_ARRAY_TYPE, EBitArray)) -#define E_BIT_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_BIT_ARRAY_TYPE, EBitArrayClass)) -#define E_IS_BIT_ARRAY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_BIT_ARRAY_TYPE)) -#define E_IS_BIT_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_BIT_ARRAY_TYPE)) - -#ifndef _E_FOREACH_FUNC_H_ -#define _E_FOREACH_FUNC_H_ -typedef void (*EForeachFunc) (int model_row, - gpointer closure); -#endif - -typedef struct { - GObject base; - - gint bit_count; - guint32 *data; -} EBitArray; - -typedef struct { - GObjectClass parent_class; -} EBitArrayClass; - - -GType e_bit_array_get_type (void); -EBitArray *e_bit_array_new (int count); - -gboolean e_bit_array_value_at (EBitArray *selection, - gint n); -void e_bit_array_foreach (EBitArray *selection, - EForeachFunc callback, - gpointer closure); -void e_bit_array_clear (EBitArray *selection); -gint e_bit_array_selected_count (EBitArray *selection); -void e_bit_array_select_all (EBitArray *selection); -void e_bit_array_invert_selection (EBitArray *selection); -int e_bit_array_bit_count (EBitArray *selection); -void e_bit_array_change_one_row (EBitArray *selection, - int row, - gboolean grow); -void e_bit_array_change_range (EBitArray *selection, - int start, - int end, - gboolean grow); -void e_bit_array_select_single_row (EBitArray *eba, - int row); -void e_bit_array_toggle_single_row (EBitArray *eba, - int row); - -void e_bit_array_insert (EBitArray *esm, - int row, - int count); -void e_bit_array_delete (EBitArray *esm, - int row, - int count); -void e_bit_array_delete_single_mode (EBitArray *esm, - int row, - int count); -void e_bit_array_move_row (EBitArray *esm, - int old_row, - int new_row); -gint e_bit_array_bit_count (EBitArray *esm); - -gboolean e_bit_array_cross_and (EBitArray *esm); -gboolean e_bit_array_cross_or (EBitArray *esm); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* _E_BIT_ARRAY_H_ */ diff --git a/e-util/e-categories-config.c b/e-util/e-categories-config.c index e5e4c0592e..0317103d72 100644 --- a/e-util/e-categories-config.c +++ b/e-util/e-categories-config.c @@ -8,10 +8,15 @@ * Copyright 2001, Ximian, Inc. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include #include +#include #include #include "e-categories-config.h" #include "e-categories-master-list-wombat.h" @@ -102,7 +107,7 @@ e_categories_config_get_icon_for (const char *category, GdkPixmap **pixmap, GdkB /* load the icon in our list */ pixbuf = g_hash_table_lookup (icons_table, icon_file); if (!pixbuf) { - pixbuf = gdk_pixbuf_new_from_file (icon_file, NULL); + pixbuf = gdk_pixbuf_new_from_file (icon_file); if (!pixbuf) { *pixmap = NULL; if (mask != NULL) @@ -173,30 +178,34 @@ e_categories_config_set_icon_for (const char *category, const char *icon_file) void e_categories_config_open_dialog_for_entry (GtkEntry *entry) { - GtkDialog *dialog; - const char *text; char *categories; + GnomeDialog *dialog; int result; - + g_return_if_fail (entry != NULL); g_return_if_fail (GTK_IS_ENTRY (entry)); - + if (!initialized) initialize_categories_config (); - - text = gtk_entry_get_text (GTK_ENTRY (entry)); - dialog = GTK_DIALOG (e_categories_new (text)); - - g_object_set (dialog, "ecml", ecmlw, NULL); - + + categories = e_utf8_gtk_entry_get_text (GTK_ENTRY (entry)); + dialog = GNOME_DIALOG (e_categories_new (categories)); + + gtk_object_set (GTK_OBJECT (dialog), + "ecml", ecmlw, + NULL); + /* run the dialog */ - result = gtk_dialog_run (dialog); - - if (result == GTK_RESPONSE_OK) { - g_object_get (dialog, "categories", &categories, NULL); - gtk_entry_set_text (GTK_ENTRY (entry), categories); + result = gnome_dialog_run (dialog); + g_free (categories); + + if (result == 0) { + gtk_object_get (GTK_OBJECT (dialog), + "categories", &categories, + NULL); + e_utf8_gtk_entry_set_text (GTK_ENTRY (entry), categories); g_free (categories); } - + gtk_object_destroy (GTK_OBJECT (dialog)); } diff --git a/e-util/e-component-listener.c b/e-util/e-component-listener.c index e3cb3c6e1f..6db67dc270 100644 --- a/e-util/e-component-listener.c +++ b/e-util/e-component-listener.c @@ -8,8 +8,14 @@ * Copyright 2002, Ximian, Inc. */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include #include #include +#include #include "e-component-listener.h" #include @@ -23,10 +29,10 @@ struct _EComponentListenerPrivate { }; 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 void e_component_listener_init (EComponentListener *cl); +static void e_component_listener_destroy (GtkObject *object); -static GObjectClass *parent_class = NULL; +static GtkObjectClass *parent_class = NULL; enum { COMPONENT_DIED, @@ -38,25 +44,25 @@ static guint comp_listener_signals[LAST_SIGNAL]; static void e_component_listener_class_init (EComponentListenerClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); + parent_class = gtk_type_class (PARENT_TYPE); - object_class->finalize = e_component_listener_finalize; + object_class->destroy = e_component_listener_destroy; 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); + gtk_signal_new ("component_died", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EComponentListenerClass, component_died), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, comp_listener_signals, LAST_SIGNAL); } static void -e_component_listener_init (EComponentListener *cl, EComponentListenerClass *klass) +e_component_listener_init (EComponentListener *cl) { /* allocate internal structure */ cl->priv = g_new (EComponentListenerPrivate, 1); @@ -66,7 +72,7 @@ e_component_listener_init (EComponentListener *cl, EComponentListenerClass *klas } static void -e_component_listener_finalize (GObject *object) +e_component_listener_destroy (GtkObject *object) { EComponentListener *cl = (EComponentListener *) object; @@ -83,27 +89,28 @@ e_component_listener_finalize (GObject *object) g_free (cl->priv); cl->priv = NULL; - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } -GType +GtkType e_component_listener_get_type (void) { - static GType type = 0; + static GtkType 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); + static const GtkTypeInfo info = { + "EComponentListener", + sizeof (EComponentListener), + sizeof (EComponentListenerClass), + (GtkClassInitFunc) e_component_listener_class_init, + (GtkObjectInitFunc) e_component_listener_init, + NULL, /* reserved_1 */ + NULL, /* reserved_2 */ + (GtkClassInitFunc) NULL + }; + + type = gtk_type_unique (PARENT_TYPE, &info); } return type; @@ -129,28 +136,26 @@ ping_component_callback (gpointer user_data) "CORBA object is nil or not")); goto out; } + CORBA_exception_free (&ev); if (is_nil) goto out; - alive = bonobo_unknown_ping (cl->priv->component, &ev); - if (alive) { - CORBA_exception_free (&ev); + alive = bonobo_unknown_ping (cl->priv->component); + if (alive) return TRUE; - } out: /* the component has died, so we notify and close the timeout */ - CORBA_exception_free (&ev); /* we ref the object just in case it gets destroyed in the callbacks */ - g_object_ref (G_OBJECT (cl)); - g_signal_emit (G_OBJECT (cl), comp_listener_signals[COMPONENT_DIED], 0); + gtk_object_ref (GTK_OBJECT (cl)); + gtk_signal_emit (GTK_OBJECT (cl), comp_listener_signals[COMPONENT_DIED]); cl->priv->component = CORBA_OBJECT_NIL; cl->priv->ping_timeout_id = -1; - g_object_unref (G_OBJECT (cl)); + gtk_object_unref (GTK_OBJECT (cl)); return FALSE; } @@ -181,7 +186,7 @@ e_component_listener_new (Bonobo_Unknown comp, int ping_delay) { EComponentListener *cl; - cl = g_object_new (E_COMPONENT_LISTENER_TYPE, NULL); + cl = gtk_type_new (E_COMPONENT_LISTENER_TYPE); cl->priv->component = comp; /* set up the timeout function */ diff --git a/e-util/e-config-listener.c b/e-util/e-config-listener.c index 19c40b1dba..cfd2b52eba 100644 --- a/e-util/e-config-listener.c +++ b/e-util/e-config-listener.c @@ -8,17 +8,25 @@ * Copyright 2002, Ximian, Inc. */ -#include -#include +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include #include "e-config-listener.h" -#define PARENT_TYPE G_TYPE_OBJECT +#define PARENT_TYPE GTK_TYPE_OBJECT typedef struct { EConfigListener *cl; - guint lid; + Bonobo_EventSource_ListenerId lid; char *key; - GConfValueType type; + GtkFundamentalType type; union { gboolean v_bool; float v_float; @@ -29,15 +37,15 @@ typedef struct { } KeyData; struct _EConfigListenerPrivate { - GConfClient *db; + Bonobo_ConfigDatabase 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 void e_config_listener_init (EConfigListener *cl); +static void e_config_listener_destroy (GtkObject *object); -static GObjectClass *parent_class = NULL; +static GtkObjectClass *parent_class = NULL; enum { KEY_CHANGED, @@ -49,35 +57,41 @@ static guint config_listener_signals[LAST_SIGNAL]; static void e_config_listener_class_init (EConfigListenerClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); + parent_class = gtk_type_class (PARENT_TYPE); - object_class->finalize = e_config_listener_finalize; + object_class->destroy = e_config_listener_destroy; 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); + gtk_signal_new ("key_changed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EConfigListenerClass, key_changed), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + gtk_object_class_add_signals (object_class, config_listener_signals, LAST_SIGNAL); } static void -e_config_listener_init (EConfigListener *cl, EConfigListenerClass *klass) +e_config_listener_init (EConfigListener *cl) { + CORBA_Environment ev; + /* 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 (); + + /* activate the configuration database */ + CORBA_exception_init (&ev); + cl->priv->db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev); + + if (BONOBO_EX (&ev) || cl->priv->db == CORBA_OBJECT_NIL) { + CORBA_exception_free (&ev); + cl->priv->db = CORBA_OBJECT_NIL; + } } static void @@ -87,11 +101,11 @@ free_key_hash (gpointer key, gpointer value, gpointer user_data) g_return_if_fail (kd != NULL); - gconf_client_notify_remove (kd->cl->priv->db, kd->lid); + bonobo_event_source_client_remove_listener (kd->cl->priv->db, kd->lid, NULL); g_free (kd->key); switch (kd->type) { - case GCONF_VALUE_STRING : + case GTK_TYPE_STRING : g_free (kd->value.v_str); break; default : @@ -102,7 +116,7 @@ free_key_hash (gpointer key, gpointer value, gpointer user_data) } static void -e_config_listener_finalize (GObject *object) +e_config_listener_destroy (GtkObject *object) { EConfigListener *cl = (EConfigListener *) object; @@ -112,36 +126,36 @@ e_config_listener_finalize (GObject *object) 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; + if (cl->priv->db != CORBA_OBJECT_NIL) { + bonobo_object_release_unref (cl->priv->db, NULL); + cl->priv->db = CORBA_OBJECT_NIL; } g_free (cl->priv); cl->priv = NULL; - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } -GType +GtkType e_config_listener_get_type (void) { - static GType type = 0; + static GtkType 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); + static const GtkTypeInfo info = { + "EConfigListener", + sizeof (EConfigListener), + sizeof (EConfigListenerClass), + (GtkClassInitFunc) e_config_listener_class_init, + (GtkObjectInitFunc) e_config_listener_init, + NULL, /* reserved_1 */ + NULL, /* reserved_2 */ + (GtkClassInitFunc) NULL + }; + + type = gtk_type_unique (PARENT_TYPE, &info); } return type; @@ -162,49 +176,53 @@ e_config_listener_new (void) { EConfigListener *cl; - cl = g_object_new (E_CONFIG_LISTENER_TYPE, NULL); + cl = gtk_type_new (E_CONFIG_LISTENER_TYPE); return cl; } static void -property_change_cb (GConfEngine *engine, - guint cnxn_id, - GConfEntry *entry, +property_change_cb (BonoboListener *listener, + char *event_name, + CORBA_any *any, + CORBA_Environment *ev, gpointer user_data) { KeyData *kd = (KeyData *) user_data; - g_return_if_fail (entry != NULL); + g_return_if_fail (any != NULL); g_return_if_fail (kd != NULL); /* free previous value */ - if (kd->type == GCONF_VALUE_STRING) + if (kd->type == GTK_TYPE_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)); + if (bonobo_arg_type_is_equal (any->_type, BONOBO_ARG_BOOLEAN, NULL)) { + kd->type = GTK_TYPE_BOOL; + kd->value.v_bool = BONOBO_ARG_GET_BOOLEAN (any); + } else if (bonobo_arg_type_is_equal (any->_type, BONOBO_ARG_FLOAT, NULL)) { + kd->type = GTK_TYPE_FLOAT; + kd->value.v_float = BONOBO_ARG_GET_FLOAT (any); + } else if (bonobo_arg_type_is_equal (any->_type, BONOBO_ARG_LONG, NULL)) { + kd->type = GTK_TYPE_LONG; + kd->value.v_long = BONOBO_ARG_GET_LONG (any); + } else if (bonobo_arg_type_is_equal (any->_type, BONOBO_ARG_STRING, NULL)) { + kd->type = GTK_TYPE_STRING; + kd->value.v_str = g_strdup (BONOBO_ARG_GET_STRING (any)); } else return; - g_signal_emit (G_OBJECT (kd->cl), config_listener_signals[KEY_CHANGED], 0, kd->key); + gtk_signal_emit (GTK_OBJECT (kd->cl), config_listener_signals[KEY_CHANGED], kd->key); } static KeyData * -add_key (EConfigListener *cl, const char *key, GConfValueType type, +add_key (EConfigListener *cl, const char *key, GtkFundamentalType type, gpointer value, gboolean used_default) { KeyData *kd; + char *event_name; + char *ch; + CORBA_Environment ev; /* add the key to our hash table */ kd = g_new0 (KeyData, 1); @@ -212,17 +230,17 @@ add_key (EConfigListener *cl, const char *key, GConfValueType type, kd->key = g_strdup (key); kd->type = type; switch (type) { - case GCONF_VALUE_BOOL : + case GTK_TYPE_BOOL : memcpy (&kd->value.v_bool, value, sizeof (gboolean)); break; - case GCONF_VALUE_FLOAT : + case GTK_TYPE_FLOAT : memcpy (&kd->value.v_float, value, sizeof (float)); break; - case GCONF_VALUE_INT : + case GTK_TYPE_LONG : memcpy (&kd->value.v_long, value, sizeof (long)); break; - case GCONF_VALUE_STRING : - kd->value.v_str = g_strdup ((const char *) value); + case GTK_TYPE_STRING : + kd->value.v_str = (char *) value; break; default : break; @@ -231,20 +249,31 @@ add_key (EConfigListener *cl, const char *key, GConfValueType type, kd->used_default = used_default; /* add the listener for changes */ - gconf_client_add_dir (cl->priv->db, key, GCONF_CLIENT_PRELOAD_NONE, NULL); - kd->lid = gconf_client_notify_add (cl->priv->db, key, - (GConfClientNotifyFunc) property_change_cb, - kd, NULL, NULL); + event_name = g_strdup_printf ("=Bonobo/ConfigDatabase:change%s", + kd->key); + ch = strrchr (event_name, '/'); + if (ch) + *ch = ':'; + + CORBA_exception_init (&ev); + kd->lid = bonobo_event_source_client_add_listener ( + cl->priv->db, + property_change_cb, + event_name, + &ev, kd); + if (BONOBO_EX (&ev)) { + CORBA_exception_free (&ev); + g_free (event_name); + free_key_hash (kd->key, kd, NULL); + return NULL; + } g_hash_table_insert (cl->priv->keys, kd->key, kd); - return kd; -} + CORBA_exception_free (&ev); + g_free (event_name); -gboolean -e_config_listener_get_boolean (EConfigListener *cl, const char *key) -{ - return e_config_listener_get_boolean_with_default (cl, key, FALSE, NULL); + return kd; } gboolean @@ -253,9 +282,9 @@ e_config_listener_get_boolean_with_default (EConfigListener *cl, gboolean def, gboolean *used_default) { - GConfValue *conf_value; gboolean value; KeyData *kd; + gboolean d; gpointer orig_key, orig_value; g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), FALSE); @@ -264,26 +293,16 @@ e_config_listener_get_boolean_with_default (EConfigListener *cl, /* 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); + value = bonobo_config_get_boolean_with_default (cl->priv->db, key, def, &d); + kd = add_key (cl, key, GTK_TYPE_BOOL, &value, d); - if (used_default != NULL) - *used_default = TRUE; - } + if (used_default != NULL) + *used_default = d; } else { kd = (KeyData *) orig_value; g_assert (kd != NULL); - if (kd->type == GCONF_VALUE_BOOL) { + if (kd->type == GTK_TYPE_BOOL) { value = kd->value.v_bool; if (used_default != NULL) *used_default = kd->used_default; @@ -294,21 +313,15 @@ e_config_listener_get_boolean_with_default (EConfigListener *cl, 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; + gboolean d; gpointer orig_key, orig_value; g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), -1); @@ -317,26 +330,16 @@ e_config_listener_get_float_with_default (EConfigListener *cl, /* 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); + value = bonobo_config_get_float_with_default (cl->priv->db, key, def, &d); + kd = add_key (cl, key, GTK_TYPE_FLOAT, &value, d); - if (used_default != NULL) - *used_default = TRUE; - } + if (used_default != NULL) + *used_default = d; } else { kd = (KeyData *) orig_value; g_assert (kd != NULL); - if (kd->type == GCONF_VALUE_FLOAT) { + if (kd->type == GTK_TYPE_FLOAT) { value = kd->value.v_float; if (used_default != NULL) *used_default = kd->used_default; @@ -347,21 +350,15 @@ e_config_listener_get_float_with_default (EConfigListener *cl, 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; + gboolean d; gpointer orig_key, orig_value; g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), -1); @@ -370,26 +367,16 @@ e_config_listener_get_long_with_default (EConfigListener *cl, /* 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); + value = bonobo_config_get_long_with_default (cl->priv->db, key, def, &d); + kd = add_key (cl, key, GTK_TYPE_LONG, &value, d); - if (used_default != NULL) - *used_default = TRUE; - } + if (used_default != NULL) + *used_default = d; } else { kd = (KeyData *) orig_value; g_assert (kd != NULL); - if (kd->type == GCONF_VALUE_INT) { + if (kd->type == GTK_TYPE_LONG) { value = kd->value.v_long; if (used_default != NULL) *used_default = kd->used_default; @@ -400,21 +387,15 @@ e_config_listener_get_long_with_default (EConfigListener *cl, 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; + gboolean d; gpointer orig_key, orig_value; g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), NULL); @@ -423,41 +404,34 @@ e_config_listener_get_string_with_default (EConfigListener *cl, /* 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); + str = bonobo_config_get_string_with_default (cl->priv->db, key, (char *) def, &d); + if (str) { + kd = add_key (cl, key, GTK_TYPE_STRING, (gpointer) str, d); if (used_default != NULL) - *used_default = TRUE; - } + *used_default = d; + } else + return NULL; } else { kd = (KeyData *) orig_value; g_assert (kd != NULL); - if (kd->type == GCONF_VALUE_STRING) { - str = g_strdup (kd->value.v_str); + if (kd->type == GTK_TYPE_STRING) { + str = kd->value.v_str; if (used_default != NULL) *used_default = kd->used_default; } else return NULL; } - return str; + return g_strdup (str); } void e_config_listener_set_boolean (EConfigListener *cl, const char *key, gboolean value) { + CORBA_Environment ev; KeyData *kd; - GError *err = NULL; g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); g_return_if_fail (key != NULL); @@ -466,23 +440,26 @@ e_config_listener_set_boolean (EConfigListener *cl, const char *key, gboolean va 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 { + CORBA_exception_init (&ev); + + bonobo_config_set_boolean (cl->priv->db, key, value, &ev); + if (BONOBO_EX (&ev)) + g_warning ("Cannot save config key %s -- %s", key, BONOBO_EX_ID (&ev)); + else { /* update the internal copy */ kd = g_hash_table_lookup (cl->priv->keys, key); if (kd) kd->value.v_bool = value; } + + CORBA_exception_free (&ev); } void e_config_listener_set_float (EConfigListener *cl, const char *key, float value) { + CORBA_Environment ev; KeyData *kd; - GError *err = NULL; g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); g_return_if_fail (key != NULL); @@ -491,23 +468,26 @@ e_config_listener_set_float (EConfigListener *cl, const char *key, float value) 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 { + CORBA_exception_init (&ev); + + bonobo_config_set_float (cl->priv->db, key, value, &ev); + if (BONOBO_EX (&ev)) + g_warning ("Cannot save config key %s -- %s", key, BONOBO_EX_ID (&ev)); + else { /* update the internal copy */ kd = g_hash_table_lookup (cl->priv->keys, key); if (kd) kd->value.v_float = value; } + + CORBA_exception_free (&ev); } void e_config_listener_set_long (EConfigListener *cl, const char *key, long value) { + CORBA_Environment ev; KeyData *kd; - GError *err = NULL; g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); g_return_if_fail (key != NULL); @@ -516,24 +496,27 @@ e_config_listener_set_long (EConfigListener *cl, const char *key, long value) 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 { + CORBA_exception_init (&ev); + + bonobo_config_set_long (cl->priv->db, key, value, &ev); + if (BONOBO_EX (&ev)) + g_warning ("Cannot save config key %s -- %s", key, BONOBO_EX_ID (&ev)); + else { /* update the internal copy */ kd = g_hash_table_lookup (cl->priv->keys, key); if (kd) kd->value.v_long = value; } + + CORBA_exception_free (&ev); } void e_config_listener_set_string (EConfigListener *cl, const char *key, const char *value) { + CORBA_Environment ev; char *s1, *s2; KeyData *kd; - GError *err = NULL; g_return_if_fail (E_IS_CONFIG_LISTENER (cl)); g_return_if_fail (key != NULL); @@ -548,11 +531,12 @@ e_config_listener_set_string (EConfigListener *cl, const char *key, const char * 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 { + CORBA_exception_init (&ev); + + bonobo_config_set_string (cl->priv->db, key, value, &ev); + if (BONOBO_EX (&ev)) + g_warning ("Cannot save config key %s -- %s", key, BONOBO_EX_ID (&ev)); + else { /* update the internal copy */ kd = g_hash_table_lookup (cl->priv->keys, key); if (kd) { @@ -560,48 +544,30 @@ e_config_listener_set_string (EConfigListener *cl, const char *key, const char * kd->value.v_str = g_strdup (value); } } + + CORBA_exception_free (&ev); } void -e_config_listener_remove_value (EConfigListener *cl, const char *key) +e_config_listener_remove_dir (EConfigListener *cl, const char *dir) { - gpointer orig_key, orig_value; + CORBA_Environment ev; 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_return_if_fail (dir != NULL); - g_free (kd); + CORBA_exception_init (&ev); + Bonobo_ConfigDatabase_removeDir (cl->priv->db, dir, &ev); + if (BONOBO_EX (&ev)) { + g_warning ("Cannot remove config dir %s -- %s", dir, BONOBO_EX_ID (&ev)); } - gconf_client_unset (cl->priv->db, key, NULL); + CORBA_exception_free (&ev); } -void -e_config_listener_remove_dir (EConfigListener *cl, const char *dir) +Bonobo_ConfigDatabase +e_config_listener_get_db (EConfigListener *cl) { - 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); + g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), CORBA_OBJECT_NIL); + return cl->priv->db; } diff --git a/e-util/e-config-listener.h b/e-util/e-config-listener.h index 9b331a7c8a..a393350ce4 100644 --- a/e-util/e-config-listener.h +++ b/e-util/e-config-listener.h @@ -11,48 +11,46 @@ #ifndef __E_CONFIG_LISTENER_H__ #define __E_CONFIG_LISTENER_H__ -#include +#include +#include +#include -G_BEGIN_DECLS +BEGIN_GNOME_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)) +#define E_CONFIG_LISTENER(o) (GTK_CHECK_CAST ((o), E_CONFIG_LISTENER_TYPE, EConfigListener)) +#define E_CONFIG_LISTENER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CONFIG_LISTENER_TYPE, EConfigListenerClass)) +#define E_IS_CONFIG_LISTENER(o) (GTK_CHECK_TYPE ((o), E_CONFIG_LISTENER_TYPE)) +#define E_IS_CONFIG_LISTENER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CONFIG_LISTENER_TYPE)) typedef struct _EConfigListenerPrivate EConfigListenerPrivate; typedef struct { - GObject object; + GtkObject object; EConfigListenerPrivate *priv; } EConfigListener; typedef struct { - GObjectClass parent_class; + GtkObjectClass parent_class; void (* key_changed) (EConfigListener *cl, const char *key); } EConfigListenerClass; -GType e_config_listener_get_type (void); +GtkType 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, @@ -70,11 +68,10 @@ 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); +void e_config_listener_remove_dir (EConfigListener *cl, const char *dir); -G_END_DECLS +Bonobo_ConfigDatabase e_config_listener_get_db (EConfigListener *cl); + +END_GNOME_DECLS #endif diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c index a37519297e..bf51a63914 100644 --- a/e-util/e-dialog-utils.c +++ b/e-util/e-dialog-utils.c @@ -22,239 +22,230 @@ * Ettore Perazzoli */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include "e-dialog-utils.h" +#include "widgets/misc/e-bonobo-widget.h" + #include +#include +#include -#include #include -#include +#include +#include +#include #include #include +#include +#include + +#include +#include -/** - * 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, ...) +#define TRANSIENT_DATA_ID "e-dialog:transient" + + +static void +transient_realize_callback (GtkWidget *widget) { - 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); - 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); + GdkWindow *window; + + window = gtk_object_get_data (GTK_OBJECT (widget), TRANSIENT_DATA_ID); + g_assert (window != NULL); + + gdk_window_set_transient_for (GTK_WIDGET (widget)->window, window); } -/** - * 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, ...) +static void +transient_unrealize_callback (GtkWidget *widget) { - 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); - va_end (args); - g_free (str); + GdkWindow *window; + + window = gtk_object_get_data (GTK_OBJECT (widget), TRANSIENT_DATA_ID); + g_assert (window != NULL); + + gdk_property_delete (window, gdk_atom_intern ("WM_TRANSIENT_FOR", FALSE)); +} + +static void +transient_destroy_callback (GtkWidget *widget) +{ + GdkWindow *window; - if (parent) - e_dialog_set_transient_for_xid (GTK_WINDOW (dialog), parent); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + window = gtk_object_get_data (GTK_OBJECT (widget), "transient"); + if (window != NULL) + gdk_window_unref (window); } - -/* 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 void +set_transient_for_gdk (GtkWindow *window, + GdkWindow *parent) { - 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; + g_return_if_fail (window != NULL); + g_return_if_fail (gtk_object_get_data (GTK_OBJECT (window), TRANSIENT_DATA_ID) == NULL); + + /* if the parent window doesn't exist anymore, + * something is probably about to go very wrong, + * but at least let's not segfault here. */ + + if (parent == NULL) { + g_warning ("set_transient_for_gdk: uhoh, parent of window %p is NULL", window); + return; } - return FALSE; + + gdk_window_ref (parent); /* FIXME? */ + + gtk_object_set_data (GTK_OBJECT (window), TRANSIENT_DATA_ID, parent); + + if (GTK_WIDGET_REALIZED (window)) + gdk_window_set_transient_for (GTK_WIDGET (window)->window, parent); + + gtk_signal_connect (GTK_OBJECT (window), "realize", + GTK_SIGNAL_FUNC (transient_realize_callback), NULL); + + gtk_signal_connect (GTK_OBJECT (window), "unrealize", + GTK_SIGNAL_FUNC (transient_unrealize_callback), NULL); + + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (transient_destroy_callback), NULL); } + /** - * e_dialog_set_transient_for: - * @dialog: a dialog window - * @parent_widget: the parent for @dialog + * e_set_dialog_parent: + * @dialog: + * @parent_widget: * - * 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. + * This sets the parent for @dialog to be @parent_widget. Unlike + * gtk_window_set_parent(), this doesn't need @parent_widget to be the actual + * toplevel, and also works if @parent_widget is been embedded as a Bonobo + * control by an out-of-process container. **/ void -e_dialog_set_transient_for (GtkWindow *dialog, - GtkWidget *parent_widget) +e_set_dialog_parent (GtkWindow *dialog, + GtkWidget *parent_widget) { + Bonobo_PropertyBag property_bag; GtkWidget *toplevel; - Window parent, root_ret, *children; - unsigned int numchildren; - Display *display; - Status status; + GdkWindow *gdk_window; + CORBA_char *id; + guint32 xid; + g_return_if_fail (dialog != NULL); g_return_if_fail (GTK_IS_WINDOW (dialog)); + g_return_if_fail (parent_widget != NULL); 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)); + if (! BONOBO_IS_CONTROL (toplevel)) { + if (GTK_IS_WINDOW (toplevel)) + gtk_window_set_transient_for (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); + property_bag = bonobo_control_get_ambient_properties (BONOBO_CONTROL (toplevel), NULL); + if (property_bag == CORBA_OBJECT_NIL) + return; - while (parent && !window_is_wm_toplevel (display, parent)) { - status = XQueryTree (display, parent, &root_ret, - &parent, &children, &numchildren); - if (status != 0) - XFree (children); - } + id = bonobo_property_bag_client_get_value_string (property_bag, E_BONOBO_WIDGET_TOPLEVEL_PROPERTY_ID, NULL); + if (id == NULL) + return; - e_dialog_set_transient_for_xid (dialog, parent); -} + xid = strtol (id, NULL, 10); -static void -dialog_realized (GtkWindow *dialog, gpointer xid) -{ - e_dialog_set_transient_for_xid (dialog, (GdkNativeWindow)xid); + gdk_window = gdk_window_foreign_new (xid); + set_transient_for_gdk (dialog, gdk_window); } /** - * e_dialog_set_transient_for_xid: - * @dialog: a dialog window - * @xid: the X Window parent + * e_set_dialog_parent_from_xid: + * @dialog: + * @xid: * - * Like e_dialog_set_transient_for(), but use an XID to specify the - * parent window. + * Like %e_set_dialog_parent_from_xid, but use an XID to specify the parent + * window. **/ void -e_dialog_set_transient_for_xid (GtkWindow *dialog, - GdkNativeWindow xid) +e_set_dialog_parent_from_xid (GtkWindow *dialog, + Window xid) { -#ifdef GDK_MULTIHEAD_SAFE - GdkDisplay *display; -#endif - GdkWindow *parent; - + g_return_if_fail (dialog != NULL); 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; - } + set_transient_for_gdk (dialog, gdk_window_foreign_new (xid)); +} -#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); +static void +e_gnome_dialog_parent_destroyed (GtkWidget *parent, GtkWidget *dialog) +{ + gnome_dialog_close (GNOME_DIALOG (dialog)); +} - gdk_window_set_transient_for (GTK_WIDGET (dialog)->window, parent); +void +e_gnome_dialog_set_parent (GnomeDialog *dialog, GtkWindow *parent) +{ + gnome_dialog_set_parent (dialog, parent); + gtk_signal_connect_while_alive (GTK_OBJECT (parent), "destroy", + e_gnome_dialog_parent_destroyed, + dialog, GTK_OBJECT (dialog)); } +GtkWidget * +e_gnome_warning_dialog_parented (const char *warning, GtkWindow *parent) +{ + GtkWidget *dialog; + + dialog = gnome_warning_dialog_parented (warning, parent); + gtk_signal_connect_while_alive (GTK_OBJECT (parent), "destroy", + e_gnome_dialog_parent_destroyed, dialog, GTK_OBJECT(dialog)); + + return dialog; +} + +GtkWidget * +e_gnome_ok_cancel_dialog_parented (const char *message, GnomeReplyCallback callback, + gpointer data, GtkWindow *parent) +{ + GtkWidget *dialog; + + dialog = gnome_ok_cancel_dialog_parented (message, callback, data, parent); + gtk_signal_connect_while_alive (GTK_OBJECT (parent), "destroy", + e_gnome_dialog_parent_destroyed, dialog, GTK_OBJECT(dialog)); + + return dialog; +} - static void save_ok (GtkWidget *widget, gpointer data) { GtkWidget *fs; char **filename = data; - const char *path; - int btn = GTK_RESPONSE_YES; - + char *path; + int btn = GNOME_YES; + fs = gtk_widget_get_toplevel (widget); path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); - - if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) { + + if (g_file_test (path, G_FILE_TEST_ISFILE)) { 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?")); - - btn = gtk_dialog_run (GTK_DIALOG (dlg)); - gtk_widget_destroy (dlg); + + dlg = gnome_question_dialog_modal (_("A file by that name already exists.\n" + "Overwrite it?"), NULL, NULL); + btn = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); } - - if (btn == GTK_RESPONSE_YES) + + if (btn == GNOME_YES) *filename = g_strdup (path); - + gtk_main_quit (); } @@ -263,21 +254,23 @@ e_file_dialog_save (const char *title) { GtkFileSelection *fs; char *path, *filename = NULL; - + fs = GTK_FILE_SELECTION (gtk_file_selection_new (title)); path = g_strdup_printf ("%s/", g_get_home_dir ()); gtk_file_selection_set_filename (fs, path); g_free (path); - g_signal_connect (fs->ok_button, "clicked", G_CALLBACK (save_ok), &filename); - g_signal_connect (fs->cancel_button, "clicked", G_CALLBACK (gtk_main_quit), NULL); + gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", + GTK_SIGNAL_FUNC (save_ok), &filename); + gtk_signal_connect (GTK_OBJECT (fs->cancel_button), "clicked", + GTK_SIGNAL_FUNC (gtk_main_quit), NULL); gtk_widget_show (GTK_WIDGET (fs)); gtk_grab_add (GTK_WIDGET (fs)); gtk_main (); gtk_widget_destroy (GTK_WIDGET (fs)); - + return filename; } diff --git a/e-util/e-html-utils.c b/e-util/e-html-utils.c index 12aee18d2b..ef3a7ca2bf 100644 --- a/e-util/e-html-utils.c +++ b/e-util/e-html-utils.c @@ -18,10 +18,15 @@ * Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include #include +#include #include "e-html-utils.h" diff --git a/e-util/e-i18n.h b/e-util/e-i18n.h deleted file mode 100644 index 2bc8b93a04..0000000000 --- a/e-util/e-i18n.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-i18n.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * Copied from gnome-i18nP.h, because this header is typically not installed - * - * This file has to be included before any file from the GNOME libraries - * to have this override the definitions that are pulled from the gnome-i18n.h - * - * the difference is that gnome-i18n.h is used for applications, and this is - * used by libraries (because libraries have to use dcgettext instead of - * gettext and they need to provide the translation domain, unlike apps). - * - * So you can just put this after you include config.h - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_I18N_H__ -#define __E_I18N_H__ - -#include - -G_BEGIN_DECLS - -#ifdef ENABLE_NLS - /* this function is defined in e-util.c */ - extern char *e_gettext (const char *msgid); -# undef _ -# ifdef GNOME_EXPLICIT_TRANSLATION_DOMAIN -# define _(String) dgettext (GNOME_EXPLICIT_TRANSLATION_DOMAIN, String) -/* No parentheses allowed here since that breaks string concatenation. */ -# define E_I18N_DOMAIN GNOME_EXPLICIT_TRANSLATION_DOMAIN -# else -# define _(String) dgettext (PACKAGE, String) -/* No parentheses allowed here since that breaks string concatenation. */ -# define E_I18N_DOMAIN PACKAGE -# endif -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -/* Stubs that do something close enough. */ -# define textdomain(String) (String) -# define gettext(String) (String) -# define dgettext(Domain,Message) (Message) -# define dcgettext(Domain,Message,Type) (Message) -# define bindtextdomain(Domain,Directory) (Domain) -# define _(String) (String) -# define N_(String) (String) -/* No parentheses allowed here since that breaks string concatenation. */ -# define E_I18N_DOMAIN "" -#endif - -G_END_DECLS - -#endif /* __E_I18N_H__ */ diff --git a/e-util/e-iconv.c b/e-util/e-iconv.c deleted file mode 100644 index 9c33209012..0000000000 --- a/e-util/e-iconv.c +++ /dev/null @@ -1,610 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-iconv.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Michael Zucchi - * Jeffery Stedfast - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 -#endif - -#include -#include -#include -#include - -#include -#include "e-iconv.h" - -#include - -#ifdef HAVE_CODESET -#include -#endif - -#include "iconv-detect.h" - -#define cd(x) - -#ifdef G_THREADS_ENABLED -static GStaticMutex lock = G_STATIC_MUTEX_INIT; -#define LOCK() g_static_mutex_lock(&lock) -#define UNLOCK() g_static_mutex_unlock(&lock) -#else -#define LOCK() -#define UNLOCK() -#endif - -typedef struct _EDListNode { - struct _EDListNode *next; - struct _EDListNode *prev; -} EDListNode; - -typedef struct _EDList { - struct _EDListNode *head; - struct _EDListNode *tail; - struct _EDListNode *tailpred; -} EDList; - -#define E_DLIST_INITIALISER(l) { (EDListNode *)&l.tail, 0, (EDListNode *)&l.head } - -struct _iconv_cache_node { - struct _iconv_cache_node *next; - struct _iconv_cache_node *prev; - - struct _iconv_cache *parent; - - int busy; - iconv_t ip; -}; - -struct _iconv_cache { - struct _iconv_cache *next; - struct _iconv_cache *prev; - - char *conv; - - EDList open; /* stores iconv_cache_nodes, busy ones up front */ -}; - -#define E_ICONV_CACHE_SIZE (16) - -static EDList iconv_cache_list; -static GHashTable *iconv_cache; -static GHashTable *iconv_cache_open; -static unsigned int iconv_cache_size = 0; - -static GHashTable *iconv_charsets = NULL; -static char *locale_charset = NULL; -static char *locale_lang = NULL; - -struct { - char *charset; - char *iconv_name; -} known_iconv_charsets[] = { -#if 0 - /* charset name, iconv-friendly charset name */ - { "iso-8859-1", "iso-8859-1" }, - { "iso8859-1", "iso-8859-1" }, - /* the above mostly serves as an example for iso-style charsets, - but we have code that will populate the iso-*'s if/when they - show up in e_iconv_charset_name() so I'm - not going to bother putting them all in here... */ - { "windows-cp1251", "cp1251" }, - { "windows-1251", "cp1251" }, - { "cp1251", "cp1251" }, - /* the above mostly serves as an example for windows-style - charsets, but we have code that will parse and convert them - to their cp#### equivalents if/when they show up in - e_iconv_charset_name() so I'm not going to bother - putting them all in here either... */ -#endif - /* charset name (lowercase!), iconv-friendly name (sometimes case sensitive) */ - { "utf-8", "UTF-8" }, - - /* 10646 is a special case, its usually UCS-2 big endian */ - /* This might need some checking but should be ok for solaris/linux */ - { "iso-10646-1", "UCS-2BE" }, - { "iso_10646-1", "UCS-2BE" }, - { "iso10646-1", "UCS-2BE" }, - { "iso-10646", "UCS-2BE" }, - { "iso_10646", "UCS-2BE" }, - { "iso10646", "UCS-2BE" }, - - { "ks_c_5601-1987", "EUC-KR" }, - - /* FIXME: Japanese/Korean/Chinese stuff needs checking */ - { "euckr-0", "EUC-KR" }, - { "5601", "EUC-KR" }, - { "big5-0", "BIG5" }, - { "big5.eten-0", "BIG5" }, - { "big5hkscs-0", "BIG5HKCS" }, - { "gb2312-0", "gb2312" }, - { "gb2312.1980-0", "gb2312" }, - { "gb-2312", "gb2312" }, - { "gb18030-0", "gb18030" }, - { "gbk-0", "GBK" }, - - { "eucjp-0", "eucJP" }, - { "ujis-0", "ujis" }, - { "jisx0208.1983-0","SJIS" }, - { "jisx0212.1990-0","SJIS" }, - { "pck", "SJIS" }, - { NULL, NULL } -}; - - - -/* Another copy of this trivial list implementation - Why? This stuff gets called a lot (potentially), should run fast, - and g_list's are f@@#$ed up to make this a hassle */ -static void e_dlist_init(EDList *v) -{ - v->head = (EDListNode *)&v->tail; - v->tail = 0; - v->tailpred = (EDListNode *)&v->head; -} - -static EDListNode *e_dlist_addhead(EDList *l, EDListNode *n) -{ - n->next = l->head; - n->prev = (EDListNode *)&l->head; - l->head->prev = n; - l->head = n; - return n; -} - -static EDListNode *e_dlist_addtail(EDList *l, EDListNode *n) -{ - n->next = (EDListNode *)&l->tail; - n->prev = l->tailpred; - l->tailpred->next = n; - l->tailpred = n; - return n; -} - -static EDListNode *e_dlist_remove(EDListNode *n) -{ - n->next->prev = n->prev; - n->prev->next = n->next; - return n; -} - - -/* fucking glib... */ -static const char * -e_strdown (char *str) -{ - register char *s = str; - - while (*s) { - if (*s >= 'A' && *s <= 'Z') - *s += 0x20; - s++; - } - - return str; -} - -static const char * -e_strup (char *str) -{ - register char *s = str; - - while (*s) { - if (*s >= 'a' && *s <= 'z') - *s -= 0x20; - s++; - } - - return str; -} - - -static void -locale_parse_lang (const char *locale) -{ - char *codeset, *lang; - - if ((codeset = strchr (locale, '.'))) - lang = g_strndup (locale, codeset - locale); - else - lang = g_strdup (locale); - - /* validate the language */ - if (strlen (lang) >= 2) { - if (lang[2] == '-' || lang[2] == '_') { - /* canonicalise the lang */ - e_strdown (lang); - - /* validate the country code */ - if (strlen (lang + 3) > 2) { - /* invalid country code */ - lang[2] = '\0'; - } else { - lang[2] = '-'; - e_strup (lang + 3); - } - } else if (lang[2] != '\0') { - /* invalid language */ - g_free (lang); - lang = NULL; - } - - locale_lang = lang; - } else { - /* invalid language */ - locale_lang = NULL; - g_free (lang); - } -} - -/* NOTE: Owns the lock on return if keep is TRUE ! */ -static void -e_iconv_init(int keep) -{ - char *from, *to, *locale; - int i; - - LOCK(); - - if (iconv_charsets != NULL) { - if (!keep) - UNLOCK(); - return; - } - - iconv_charsets = g_hash_table_new(g_str_hash, g_str_equal); - - for (i = 0; known_iconv_charsets[i].charset != NULL; i++) { - from = g_strdup(known_iconv_charsets[i].charset); - to = g_strdup(known_iconv_charsets[i].iconv_name); - e_strdown (from); - g_hash_table_insert(iconv_charsets, from, to); - } - - e_dlist_init(&iconv_cache_list); - iconv_cache = g_hash_table_new(g_str_hash, g_str_equal); - iconv_cache_open = g_hash_table_new(NULL, NULL); - - locale = setlocale (LC_ALL, NULL); - - if (!locale || !strcmp (locale, "C") || !strcmp (locale, "POSIX")) { - /* The locale "C" or "POSIX" is a portable locale; its - * LC_CTYPE part corresponds to the 7-bit ASCII character - * set. - */ - - locale_charset = NULL; - locale_lang = NULL; - } else { -#ifdef HAVE_CODESET - locale_charset = g_strdup (nl_langinfo (CODESET)); - e_strdown (locale_charset); -#else - /* A locale name is typically of the form language[_terri- - * tory][.codeset][@modifier], where language is an ISO 639 - * language code, territory is an ISO 3166 country code, and - * codeset is a character set or encoding identifier like - * ISO-8859-1 or UTF-8. - */ - char *codeset, *p; - - codeset = strchr (locale, '.'); - if (codeset) { - codeset++; - - /* ; is a hack for debian systems and / is a hack for Solaris systems */ - for (p = codeset; *p && !strchr ("@;/", *p); p++); - locale_charset = g_strndup (codeset, p - codeset); - e_strdown (locale_charset); - } else { - /* charset unknown */ - locale_charset = NULL; - } -#endif - - /* parse the locale lang */ - locale_parse_lang (locale); - - } - - if (!keep) - UNLOCK(); -} - -const char *e_iconv_charset_name(const char *charset) -{ - char *name, *ret, *tmp; - - if (charset == NULL) - return NULL; - - name = g_alloca (strlen (charset) + 1); - strcpy (name, charset); - e_strdown (name); - - e_iconv_init(TRUE); - ret = g_hash_table_lookup(iconv_charsets, name); - if (ret != NULL) { - UNLOCK(); - return ret; - } - - /* Unknown, try canonicalise some basic charset types to something that should work */ - if (strncmp(name, "iso", 3) == 0) { - /* Convert iso-nnnn-n or isonnnn-n or iso_nnnn-n to iso-nnnn-n or isonnnn-n */ - int iso, codepage; - char *p; - - tmp = name + 3; - if (*tmp == '-' || *tmp == '_') - tmp++; - - iso = strtoul (tmp, &p, 10); - - if (iso == 10646) { - /* they all become ICONV_10646 */ - ret = g_strdup (ICONV_10646); - } else { - tmp = p; - if (*tmp == '-' || *tmp == '_') - tmp++; - - codepage = strtoul (tmp, &p, 10); - - if (p > tmp) { - /* codepage is numeric */ -#ifdef __aix__ - if (codepage == 13) - ret = g_strdup ("IBM-921"); - else -#endif /* __aix__ */ - ret = g_strdup_printf (ICONV_ISO_D_FORMAT, iso, codepage); - } else { - /* codepage is a string - probably iso-2022-jp or something */ - ret = g_strdup_printf (ICONV_ISO_S_FORMAT, iso, p); - } - } - } else if (strncmp(name, "windows-", 8) == 0) { - /* Convert windows-nnnnn or windows-cpnnnnn to cpnnnn */ - tmp = name+8; - if (!strncmp(tmp, "cp", 2)) - tmp+=2; - ret = g_strdup_printf("CP%s", tmp); - } else if (strncmp(name, "microsoft-", 10) == 0) { - /* Convert microsoft-nnnnn or microsoft-cpnnnnn to cpnnnn */ - tmp = name+10; - if (!strncmp(tmp, "cp", 2)) - tmp+=2; - ret = g_strdup_printf("CP%s", tmp); - } else { - /* Just assume its ok enough as is, case and all */ - ret = g_strdup(charset); - } - - g_hash_table_insert(iconv_charsets, g_strdup(name), ret); - UNLOCK(); - - return ret; -} - -static void -flush_entry(struct _iconv_cache *ic) -{ - struct _iconv_cache_node *in, *nn; - - in = (struct _iconv_cache_node *)ic->open.head; - nn = in->next; - while (nn) { - if (in->ip != (iconv_t)-1) { - g_hash_table_remove(iconv_cache_open, in->ip); - iconv_close(in->ip); - } - g_free(in); - in = nn; - nn = in->next; - } - g_free(ic->conv); - g_free(ic); -} - -/* This should run pretty quick, its called a lot */ -iconv_t e_iconv_open(const char *oto, const char *ofrom) -{ - const char *to, *from; - char *tofrom; - struct _iconv_cache *ic; - struct _iconv_cache_node *in; - int errnosav; - iconv_t ip; - - if (oto == NULL || ofrom == NULL) { - errno = EINVAL; - return (iconv_t) -1; - } - - to = e_iconv_charset_name (oto); - from = e_iconv_charset_name (ofrom); - tofrom = g_alloca (strlen (to) + strlen (from) + 2); - sprintf(tofrom, "%s%%%s", to, from); - - LOCK(); - - ic = g_hash_table_lookup(iconv_cache, tofrom); - if (ic) { - e_dlist_remove((EDListNode *)ic); - } else { - struct _iconv_cache *last = (struct _iconv_cache *)iconv_cache_list.tailpred; - struct _iconv_cache *prev; - - prev = last->prev; - while (prev && iconv_cache_size > E_ICONV_CACHE_SIZE) { - in = (struct _iconv_cache_node *)last->open.head; - if (in->next && !in->busy) { - cd(printf("Flushing iconv converter '%s'\n", last->conv)); - e_dlist_remove((EDListNode *)last); - g_hash_table_remove(iconv_cache, last->conv); - flush_entry(last); - iconv_cache_size--; - } - last = prev; - prev = last->prev; - } - - iconv_cache_size++; - - ic = g_malloc(sizeof(*ic)); - e_dlist_init(&ic->open); - ic->conv = g_strdup(tofrom); - g_hash_table_insert(iconv_cache, ic->conv, ic); - - cd(printf("Creating iconv converter '%s'\n", ic->conv)); - } - e_dlist_addhead(&iconv_cache_list, (EDListNode *)ic); - - /* If we have a free iconv, use it */ - in = (struct _iconv_cache_node *)ic->open.tailpred; - if (in->prev && !in->busy) { - cd(printf("using existing iconv converter '%s'\n", ic->conv)); - ip = in->ip; - if (ip != (iconv_t)-1) { - /* work around some broken iconv implementations - * that die if the length arguments are NULL - */ - size_t buggy_iconv_len = 0; - char *buggy_iconv_buf = NULL; - - /* resets the converter */ - iconv(ip, &buggy_iconv_buf, &buggy_iconv_len, &buggy_iconv_buf, &buggy_iconv_len); - in->busy = TRUE; - e_dlist_remove((EDListNode *)in); - e_dlist_addhead(&ic->open, (EDListNode *)in); - } - } else { - cd(printf("creating new iconv converter '%s'\n", ic->conv)); - ip = iconv_open(to, from); - in = g_malloc(sizeof(*in)); - in->ip = ip; - in->parent = ic; - e_dlist_addhead(&ic->open, (EDListNode *)in); - if (ip != (iconv_t)-1) { - g_hash_table_insert(iconv_cache_open, ip, in); - in->busy = TRUE; - } else { - errnosav = errno; - g_warning("Could not open converter for '%s' to '%s' charset", from, to); - in->busy = FALSE; - errno = errnosav; - } - } - - UNLOCK(); - - return ip; -} - -size_t e_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char ** outbuf, size_t *outbytesleft) -{ - return iconv(cd, (char **) inbuf, inbytesleft, outbuf, outbytesleft); -} - -void -e_iconv_close(iconv_t ip) -{ - struct _iconv_cache_node *in; - - if (ip == (iconv_t)-1) - return; - - LOCK(); - in = g_hash_table_lookup(iconv_cache_open, ip); - if (in) { - cd(printf("closing iconv converter '%s'\n", in->parent->conv)); - e_dlist_remove((EDListNode *)in); - in->busy = FALSE; - e_dlist_addtail(&in->parent->open, (EDListNode *)in); - } else { - g_warning("trying to close iconv i dont know about: %p", ip); - iconv_close(ip); - } - UNLOCK(); - -} - -const char *e_iconv_locale_charset(void) -{ - e_iconv_init(FALSE); - - return locale_charset; -} - - -const char * -e_iconv_locale_language (void) -{ - e_iconv_init (FALSE); - - return locale_lang; -} - -/* map CJKR charsets to their language code */ -/* NOTE: only support charset names that will be returned by - * e_iconv_charset_name() so that we don't have to keep track of all - * the aliases too. */ -static struct { - char *charset; - char *lang; -} cjkr_lang_map[] = { - { "Big5", "zh" }, - { "BIG5HKCS", "zh" }, - { "gb2312", "zh" }, - { "gb18030", "zh" }, - { "gbk", "zh" }, - { "euc-tw", "zh" }, - { "iso-2022-jp", "ja" }, - { "sjis", "ja" }, - { "ujis", "ja" }, - { "eucJP", "ja" }, - { "euc-jp", "ja" }, - { "euc-kr", "ko" }, - { "koi8-r", "ru" }, - { "koi8-u", "uk" } -}; - -#define NUM_CJKR_LANGS (sizeof (cjkr_lang_map) / sizeof (cjkr_lang_map[0])) - -const char * -e_iconv_charset_language (const char *charset) -{ - int i; - - if (!charset) - return NULL; - - charset = e_iconv_charset_name (charset); - for (i = 0; i < NUM_CJKR_LANGS; i++) { - if (!strcasecmp (cjkr_lang_map[i].charset, charset)) - return cjkr_lang_map[i].lang; - } - - return NULL; -} diff --git a/e-util/e-iconv.h b/e-util/e-iconv.h deleted file mode 100644 index 14b93853d5..0000000000 --- a/e-util/e-iconv.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-iconv.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Michael Zucchi - * Jeffrey Stedfast - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_ICONV_H_ -#define _E_ICONV_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -const char *e_iconv_charset_name(const char *charset); -iconv_t e_iconv_open(const char *oto, const char *ofrom); -size_t e_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char ** outbuf, size_t *outbytesleft); -void e_iconv_close(iconv_t ip); -const char *e_iconv_locale_charset(void); - -/* languages */ -const char *e_iconv_locale_language (void); -const char *e_iconv_charset_language (const char *charset); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* !_E_ICONV_H_ */ diff --git a/e-util/e-lang-utils.c b/e-util/e-lang-utils.c index 564b4a353d..649a8cc887 100644 --- a/e-util/e-lang-utils.c +++ b/e-util/e-lang-utils.c @@ -35,6 +35,7 @@ e_get_language_list (void) GSList *list = NULL; const char *env; const char *p; + char *lang; env = g_getenv ("LANGUAGE"); if (env == NULL) { diff --git a/e-util/e-msgport.c b/e-util/e-msgport.c index 03c12c8847..34a6391ad7 100644 --- a/e-util/e-msgport.c +++ b/e-util/e-msgport.c @@ -906,27 +906,6 @@ void e_mutex_assert_locked(EMutex *m) pthread_mutex_unlock(&m->mutex); } -int e_mutex_cond_wait(void *vcond, EMutex *m) -{ - int ret; - pthread_cond_t *cond = vcond; - - switch(m->type) { - case E_MUTEX_SIMPLE: - return pthread_cond_wait(cond, &m->mutex); - case E_MUTEX_REC: - if (pthread_mutex_lock(&m->mutex) == -1) - return -1; - g_assert(m->owner == pthread_self()); - ret = pthread_cond_wait(cond, &m->mutex); - g_assert(m->owner == pthread_self()); - pthread_mutex_unlock(&m->mutex); - return ret; - default: - g_return_val_if_reached(-1); - } -} - #ifdef STANDALONE EMsgPort *server_port; diff --git a/e-util/e-msgport.h b/e-util/e-msgport.h index 8d4e0c20f7..6fc01efb14 100644 --- a/e-util/e-msgport.h +++ b/e-util/e-msgport.h @@ -82,7 +82,5 @@ int e_mutex_destroy(EMutex *m); int e_mutex_lock(EMutex *m); int e_mutex_unlock(EMutex *m); void e_mutex_assert_locked(EMutex *m); -/* this uses pthread cond's */ -int e_mutex_cond_wait(void *cond, EMutex *m); #endif diff --git a/e-util/e-pilot-settings.h b/e-util/e-pilot-settings.h index 908f9e1836..6fe5eedc52 100644 --- a/e-util/e-pilot-settings.h +++ b/e-util/e-pilot-settings.h @@ -24,11 +24,7 @@ #ifndef _E_PILOT_SETTINGS_H_ #define _E_PILOT_SETTINGS_H_ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include +#include #ifdef __cplusplus extern "C" { @@ -36,10 +32,10 @@ extern "C" { #endif /* __cplusplus */ #define E_TYPE_PILOT_SETTINGS (e_pilot_settings_get_type ()) -#define E_PILOT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_PILOT_SETTINGS, EPilotSettings)) -#define E_PILOT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_PILOT_SETTINGS, EPilotSettingsClass)) -#define E_IS_PILOT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_PILOT_SETTINGS)) -#define E_IS_PILOT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_PILOT_SETTINGS)) +#define E_PILOT_SETTINGS(obj) (GTK_CHECK_CAST ((obj), E_TYPE_PILOT_SETTINGS, EPilotSettings)) +#define E_PILOT_SETTINGS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_PILOT_SETTINGS, EPilotSettingsClass)) +#define E_IS_PILOT_SETTINGS(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_PILOT_SETTINGS)) +#define E_IS_PILOT_SETTINGS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_PILOT_SETTINGS)) typedef struct _EPilotSettings EPilotSettings; @@ -60,7 +56,7 @@ struct _EPilotSettingsClass { }; -GType e_pilot_settings_get_type (void); +GtkType e_pilot_settings_get_type (void); GtkWidget *e_pilot_settings_new (void); gboolean e_pilot_settings_get_secret (EPilotSettings *ps); diff --git a/e-util/e-proxy.c b/e-util/e-proxy.c index f47231c84c..8fbabd28e3 100644 --- a/e-util/e-proxy.c +++ b/e-util/e-proxy.c @@ -41,20 +41,40 @@ set_proxy (GConfClient *client) char *proxy_server, *proxy_user, *proxy_pw, *uri; gboolean use_auth, use_proxy; int proxy_port; - - use_proxy = gconf_client_get_bool (client, "/system/http_proxy/use_http_proxy", NULL); + gboolean new_proxy_exists; + + new_proxy_exists = gconf_client_dir_exists (client, "/system/http_proxy", NULL); + + if (new_proxy_exists) { + use_proxy = gconf_client_get_bool (client, "/system/http_proxy/use_http_proxy", NULL); + } else { + use_proxy = gconf_client_get_bool (client, "/system/gnome-vfs/use-http-proxy", NULL); + } + if (use_proxy == FALSE) { return; } + + if (new_proxy_exists) { + proxy_server = gconf_client_get_string (client, "/system/http_proxy/host", NULL); + proxy_port = gconf_client_get_int (client, "/system/http_proxy/port", NULL); + + use_auth = gconf_client_get_bool (client, "/system/http_proxy/use_authentication", NULL); + } else { + proxy_server = gconf_client_get_string (client, "/system/gnome-vfs/http-proxy-host", NULL); + proxy_port = gconf_client_get_int (client, "/system/gnome-vfs/http-proxy-port", NULL); - proxy_server = gconf_client_get_string (client, "/system/http_proxy/host", NULL); - proxy_port = gconf_client_get_int (client, "/system/http_proxy/port", NULL); - - use_auth = gconf_client_get_bool (client, "/system/http_proxy/use_authentication", NULL); + use_auth = gconf_client_get_bool (client, "/system/gnome-vfs/use-http-proxy-authorization", NULL); + } + if (use_auth == TRUE) { - proxy_user = gconf_client_get_string (client, "/system/http_proxy/authentication_user", NULL); - proxy_pw = gconf_client_get_string (client, "/system/http_proxy/authentication_password", NULL); - + if (new_proxy_exists) { + proxy_user = gconf_client_get_string (client, "/system/http_proxy/authentication_user", NULL); + proxy_pw = gconf_client_get_string (client, "/system/http_proxy/authentication_password", NULL); + } else { + proxy_user = gconf_client_get_string (client, "/system/gnome-vfs/http-proxy-authorization-user", NULL); + proxy_pw = gconf_client_get_string (client, "/system/gnome-vfs/http-proxy-authorization-password", NULL); + } uri = g_strdup_printf ("http://%s:%s@%s:%d", proxy_user, proxy_pw, proxy_server, proxy_port); } else { uri = g_strdup_printf ("http://%s:%d", proxy_server, proxy_port); @@ -77,7 +97,8 @@ void e_proxy_init () { GConfClient *client; - + gboolean new_proxy_exists; + /* We get the gnome-vfs proxy keys here set soup up to use the proxy, and listen to any changes */ @@ -85,12 +106,22 @@ e_proxy_init () if (!(client = gconf_client_get_default ())) return; + new_proxy_exists = gconf_client_dir_exists (client, "/system/http_proxy", NULL); + /* Listen to the changes in the gnome-vfs path */ - gconf_client_add_dir (client, "/system/http_proxy", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - - gconf_client_notify_add (client, "/system/http_proxy/", - proxy_setting_changed, NULL, NULL, NULL); + if (new_proxy_exists) { + gconf_client_add_dir (client, "/system/http_proxy", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add (client, "/system/http_proxy/", + proxy_setting_changed, NULL, + NULL, NULL); + } else { + gconf_client_add_dir (client, "/system/gnome-vfs", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add (client, "/system/gnome-vfs/", + proxy_setting_changed, NULL, + NULL, NULL); + } set_proxy (client); } diff --git a/e-util/e-sorter-array.c b/e-util/e-sorter-array.c deleted file mode 100644 index ab1e748d9a..0000000000 --- a/e-util/e-sorter-array.c +++ /dev/null @@ -1,259 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-sorter-array.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 -#include -#include -#include "gal/util/e-util.h" -#include "e-sorter-array.h" - -#define d(x) - -#define PARENT_TYPE E_SORTER_TYPE - -#define INCREMENT_AMOUNT 100 - -static ESorterClass *parent_class; - -static void esa_sort (ESorterArray *esa); -static void esa_backsort (ESorterArray *esa); - -static gint esa_model_to_sorted (ESorter *sorter, int row); -static gint esa_sorted_to_model (ESorter *sorter, int row); -static void esa_get_model_to_sorted_array (ESorter *sorter, int **array, int *count); -static void esa_get_sorted_to_model_array (ESorter *sorter, int **array, int *count); -static gboolean esa_needs_sorting (ESorter *esa); - -#define ESA_NEEDS_SORTING(esa) (((ESorterArray *) (esa))->compare != NULL) - -static int -esort_callback(const void *data1, const void *data2, gpointer user_data) -{ - ESorterArray *esa = user_data; - int ret_val; - int int1, int2; - - int1 = *(int *)data1; - int2 = *(int *)data2; - - ret_val = esa->compare (int1, int2, esa->closure); - if (ret_val != 0) - return ret_val; - - if (int1 < int2) - return -1; - if (int1 > int2) - return 1; - return 0; -} - -static void -esa_sort(ESorterArray *esa) -{ - int rows; - int i; - - if (esa->sorted) - return; - - rows = esa->rows; - - esa->sorted = g_new(int, rows); - for (i = 0; i < rows; i++) - esa->sorted[i] = i; - - if (esa->compare) - e_sort (esa->sorted, rows, sizeof(int), esort_callback, esa); -} - -static void -esa_backsort(ESorterArray *esa) -{ - int i, rows; - - if (esa->backsorted) - return; - - esa_sort(esa); - - rows = esa->rows; - - esa->backsorted = g_new0(int, rows); - - for (i = 0; i < rows; i++) { - esa->backsorted[esa->sorted[i]] = i; - } -} - - -static gint -esa_model_to_sorted (ESorter *es, int row) -{ - ESorterArray *esa = E_SORTER_ARRAY(es); - - g_return_val_if_fail(row >= 0, -1); - g_return_val_if_fail(row < esa->rows, -1); - - if (ESA_NEEDS_SORTING(es)) - esa_backsort(esa); - - if (esa->backsorted) - return esa->backsorted[row]; - else - return row; -} - -static gint -esa_sorted_to_model (ESorter *es, int row) -{ - ESorterArray *esa = (ESorterArray *) es; - - g_return_val_if_fail(row >= 0, -1); - g_return_val_if_fail(row < esa->rows, -1); - - if (ESA_NEEDS_SORTING(es)) - esa_sort(esa); - - if (esa->sorted) - return esa->sorted[row]; - else - return row; -} - -static void -esa_get_model_to_sorted_array (ESorter *es, int **array, int *count) -{ - ESorterArray *esa = E_SORTER_ARRAY(es); - if (array || count) { - esa_backsort(esa); - - if (array) - *array = esa->backsorted; - if (count) - *count = esa->rows; - } -} - -static void -esa_get_sorted_to_model_array (ESorter *es, int **array, int *count) -{ - ESorterArray *esa = E_SORTER_ARRAY(es); - if (array || count) { - esa_sort(esa); - - if (array) - *array = esa->sorted; - if (count) - *count = esa->rows; - } -} - -static gboolean -esa_needs_sorting(ESorter *es) -{ - ESorterArray *esa = E_SORTER_ARRAY(es); - return esa->compare != NULL; -} - -void -e_sorter_array_clean(ESorterArray *esa) -{ - g_free(esa->sorted); - esa->sorted = NULL; - - g_free(esa->backsorted); - esa->backsorted = NULL; -} - -void -e_sorter_array_set_count (ESorterArray *esa, int count) -{ - e_sorter_array_clean (esa); - esa->rows = count; -} - -void -e_sorter_array_append (ESorterArray *esa, int count) -{ - int i; - g_free(esa->backsorted); - esa->backsorted = NULL; - - if (esa->sorted) { - esa->sorted = g_renew(int, esa->sorted, esa->rows + count); - for (i = 0; i < count; i++) { - int value = esa->rows; - size_t pos; - e_bsearch (&value, esa->sorted, esa->rows, sizeof (int), esort_callback, esa, &pos, NULL); - memmove (esa->sorted + pos + 1, esa->sorted + pos, sizeof (int) * (esa->rows - pos)); - esa->sorted[pos] = value; - esa->rows ++; - } - } else { - esa->rows += count; - } -} - -ESorterArray * -e_sorter_array_construct (ESorterArray *esa, - ECompareRowsFunc compare, - gpointer closure) -{ - esa->compare = compare; - esa->closure = closure; - return esa; -} - -ESorterArray * -e_sorter_array_new (ECompareRowsFunc compare, gpointer closure) -{ - ESorterArray *esa = g_object_new (E_SORTER_ARRAY_TYPE, NULL); - - return e_sorter_array_construct (esa, compare, closure); -} - -static void -esa_class_init (ESorterArrayClass *klass) -{ - ESorterClass *sorter_class = E_SORTER_CLASS(klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - sorter_class->model_to_sorted = esa_model_to_sorted ; - sorter_class->sorted_to_model = esa_sorted_to_model ; - sorter_class->get_model_to_sorted_array = esa_get_model_to_sorted_array ; - sorter_class->get_sorted_to_model_array = esa_get_sorted_to_model_array ; - sorter_class->needs_sorting = esa_needs_sorting ; -} - -static void -esa_init (ESorterArray *esa) -{ - esa->rows = 0; - esa->compare = NULL; - esa->closure = NULL; - esa->sorted = NULL; - esa->backsorted = NULL; -} - -E_MAKE_TYPE(e_sorter_array, "ESorterArray", ESorterArray, esa_class_init, esa_init, PARENT_TYPE) diff --git a/e-util/e-sorter-array.h b/e-util/e-sorter-array.h deleted file mode 100644 index 227e437443..0000000000 --- a/e-util/e-sorter-array.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-sorter-array.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_SORTER_ARRAY_H_ -#define _E_SORTER_ARRAY_H_ - -#include -#include -#include - -G_BEGIN_DECLS - -#define E_SORTER_ARRAY_TYPE (e_sorter_array_get_type ()) -#define E_SORTER_ARRAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_SORTER_ARRAY_TYPE, ESorterArray)) -#define E_SORTER_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_SORTER_ARRAY_TYPE, ESorterArrayClass)) -#define E_IS_SORTER_ARRAY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_SORTER_ARRAY_TYPE)) -#define E_IS_SORTER_ARRAY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_SORTER_ARRAY_TYPE)) - -#ifndef _E_COMPARE_ROWS_FUNC_H_ -#define _E_COMPARE_ROWS_FUNC_H_ -typedef int (*ECompareRowsFunc) (int row1, - int row2, - gpointer closure); -#endif - -typedef struct { - ESorter base; - - ECompareRowsFunc compare; - gpointer closure; - - /* If needs_sorting is 0, then model_to_sorted and sorted_to_model are no-ops. */ - int *sorted; - int *backsorted; - - int rows; -} ESorterArray; - -typedef struct { - ESorterClass parent_class; -} ESorterArrayClass; - -GType e_sorter_array_get_type (void); -ESorterArray *e_sorter_array_construct (ESorterArray *sorter, - ECompareRowsFunc compare, - gpointer closure); -ESorterArray *e_sorter_array_new (ECompareRowsFunc compare, - gpointer closure); -void e_sorter_array_clean (ESorterArray *esa); -void e_sorter_array_set_count (ESorterArray *esa, - int count); -void e_sorter_array_append (ESorterArray *esa, - int count); - -G_END_DECLS - -#endif /* _E_SORTER_ARRAY_H_ */ diff --git a/e-util/e-sorter.c b/e-util/e-sorter.c deleted file mode 100644 index adee6d0d98..0000000000 --- a/e-util/e-sorter.c +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-sorter.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 -#include -#include -#include "gal/util/e-util.h" -#include "e-sorter.h" - -#define d(x) - -#define PARENT_TYPE G_TYPE_OBJECT - -static GObjectClass *parent_class; - -static gint es_model_to_sorted (ESorter *es, int row); -static gint es_sorted_to_model (ESorter *es, int row); -static void es_get_model_to_sorted_array (ESorter *es, int **array, int *count); -static void es_get_sorted_to_model_array (ESorter *es, int **array, int *count); -static gboolean es_needs_sorting(ESorter *es); - -static void -es_class_init (ESorterClass *klass) -{ - parent_class = g_type_class_ref (PARENT_TYPE); - - klass->model_to_sorted = es_model_to_sorted; - klass->sorted_to_model = es_sorted_to_model; - klass->get_model_to_sorted_array = es_get_model_to_sorted_array; - klass->get_sorted_to_model_array = es_get_sorted_to_model_array; - klass->needs_sorting = es_needs_sorting; -} - -static void -es_init (ESorter *es) -{ -} - -E_MAKE_TYPE(e_sorter, "ESorter", ESorter, es_class_init, es_init, PARENT_TYPE) - -ESorter * -e_sorter_new (void) -{ - ESorter *es = g_object_new (E_SORTER_TYPE, NULL); - - return es; -} - - -static gint -es_model_to_sorted (ESorter *es, int row) -{ - return row; -} - -static gint -es_sorted_to_model (ESorter *es, int row) -{ - return row; -} - - -static void -es_get_model_to_sorted_array (ESorter *es, int **array, int *count) -{ -} - -static void -es_get_sorted_to_model_array (ESorter *es, int **array, int *count) -{ -} - - -static gboolean -es_needs_sorting(ESorter *es) -{ - return FALSE; -} - -gint -e_sorter_model_to_sorted (ESorter *es, int row) -{ - g_return_val_if_fail(es != NULL, -1); - g_return_val_if_fail(row >= 0, -1); - - if (E_SORTER_GET_CLASS(es)->model_to_sorted) - return E_SORTER_GET_CLASS(es)->model_to_sorted (es, row); - else - return -1; -} - -gint -e_sorter_sorted_to_model (ESorter *es, int row) -{ - g_return_val_if_fail(es != NULL, -1); - g_return_val_if_fail(row >= 0, -1); - - if (E_SORTER_GET_CLASS(es)->sorted_to_model) - return E_SORTER_GET_CLASS(es)->sorted_to_model (es, row); - else - return -1; -} - - -void -e_sorter_get_model_to_sorted_array (ESorter *es, int **array, int *count) -{ - g_return_if_fail(es != NULL); - - if (E_SORTER_GET_CLASS(es)->get_model_to_sorted_array) - E_SORTER_GET_CLASS(es)->get_model_to_sorted_array (es, array, count); -} - -void -e_sorter_get_sorted_to_model_array (ESorter *es, int **array, int *count) -{ - g_return_if_fail(es != NULL); - - if (E_SORTER_GET_CLASS(es)->get_sorted_to_model_array) - E_SORTER_GET_CLASS(es)->get_sorted_to_model_array (es, array, count); -} - - -gboolean -e_sorter_needs_sorting(ESorter *es) -{ - g_return_val_if_fail (es != NULL, FALSE); - - if (E_SORTER_GET_CLASS(es)->needs_sorting) - return E_SORTER_GET_CLASS(es)->needs_sorting (es); - else - return FALSE; -} diff --git a/e-util/e-sorter.h b/e-util/e-sorter.h deleted file mode 100644 index a70c2bd2d7..0000000000 --- a/e-util/e-sorter.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-sorter.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_SORTER_H_ -#define _E_SORTER_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define E_SORTER_TYPE (e_sorter_get_type ()) -#define E_SORTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_SORTER_TYPE, ESorter)) -#define E_SORTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_SORTER_TYPE, ESorterClass)) -#define E_IS_SORTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_SORTER_TYPE)) -#define E_IS_SORTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_SORTER_TYPE)) -#define E_SORTER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_SORTER_TYPE, ESorterClass)) - -typedef struct { - GObject base; -} ESorter; - -typedef struct { - GObjectClass parent_class; - gint (*model_to_sorted) (ESorter *sorter, - int row); - gint (*sorted_to_model) (ESorter *sorter, - int row); - - void (*get_model_to_sorted_array) (ESorter *sorter, - int **array, - int *count); - void (*get_sorted_to_model_array) (ESorter *sorter, - int **array, - int *count); - - gboolean (*needs_sorting) (ESorter *sorter); -} ESorterClass; - -GType e_sorter_get_type (void); -ESorter *e_sorter_new (void); - -gint e_sorter_model_to_sorted (ESorter *sorter, - int row); -gint e_sorter_sorted_to_model (ESorter *sorter, - int row); - -void e_sorter_get_model_to_sorted_array (ESorter *sorter, - int **array, - int *count); -void e_sorter_get_sorted_to_model_array (ESorter *sorter, - int **array, - int *count); - -gboolean e_sorter_needs_sorting (ESorter *sorter); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_SORTER_H_ */ diff --git a/e-util/e-text-event-processor-emacs-like.c b/e-util/e-text-event-processor-emacs-like.c deleted file mode 100644 index 9cda8f1677..0000000000 --- a/e-util/e-text-event-processor-emacs-like.c +++ /dev/null @@ -1,489 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-text-event-processor-emacs-like.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 -#include -#include -#include "e-text-event-processor-emacs-like.h" - -static void e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *card); -static void e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass); -static gint e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event); - -#define PARENT_TYPE E_TEXT_EVENT_PROCESSOR_TYPE -static ETextEventProcessorClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0 -}; - -static const ETextEventProcessorCommand control_keys[26] = -{ - { E_TEP_START_OF_LINE, E_TEP_MOVE, 0, "" }, /* a */ - { E_TEP_BACKWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* b */ - { E_TEP_SELECTION, E_TEP_COPY, 0, "" }, /* c */ - { E_TEP_FORWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* d */ - { E_TEP_END_OF_LINE, E_TEP_MOVE, 0, "" }, /* e */ - { E_TEP_FORWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* f */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */ - { E_TEP_BACKWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* h */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */ - { E_TEP_END_OF_LINE, E_TEP_DELETE, 0, "" }, /* k */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */ - { E_TEP_FORWARD_LINE, E_TEP_MOVE, 0, "" }, /* n */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */ - { E_TEP_BACKWARD_LINE, E_TEP_MOVE, 0, "" }, /* p */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */ - { E_TEP_START_OF_LINE, E_TEP_DELETE, 0, "" }, /* u */ - { E_TEP_SELECTION, E_TEP_PASTE, 0, "" }, /* v */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* w */ - { E_TEP_SELECTION, E_TEP_DELETE, 0, "" }, /* x */ - { E_TEP_SELECTION, E_TEP_PASTE, 0, "" }, /* y */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */ -}; - -static const ETextEventProcessorCommand alt_keys[26] = -{ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* a */ - { E_TEP_BACKWARD_WORD, E_TEP_MOVE, 0, "" }, /* b */ - { E_TEP_SELECTION, E_TEP_CAPS, E_TEP_CAPS_TITLE, "" },/* c */ - { E_TEP_FORWARD_WORD, E_TEP_DELETE, 0, "" }, /* d */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* e */ - { E_TEP_FORWARD_WORD, E_TEP_MOVE, 0, "" }, /* f */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* h */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* k */ - { E_TEP_SELECTION, E_TEP_CAPS, E_TEP_CAPS_LOWER, "" }, /* l */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* n */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* p */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */ - { E_TEP_SELECTION, E_TEP_CAPS, E_TEP_CAPS_UPPER, "" }, /* u */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* v */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* w */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* x */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* y */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */ - -}; - -E_MAKE_TYPE (e_text_event_processor_emacs_like, - "ETextEventProcessorEmacsLike", - ETextEventProcessorEmacsLike, - e_text_event_processor_emacs_like_class_init, - e_text_event_processor_emacs_like_init, - PARENT_TYPE) - -static void -e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass) -{ - ETextEventProcessorClass *processor_class; - - processor_class = (ETextEventProcessorClass*) klass; - - parent_class = g_type_class_ref (PARENT_TYPE); - - processor_class->event = e_text_event_processor_emacs_like_event; -} - -static void -e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *tep) -{ -} - -static gint -e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event) -{ - ETextEventProcessorCommand command; - ETextEventProcessorEmacsLike *tep_el = E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(tep); - command.action = E_TEP_NOP; - switch (event->type) { - case GDK_BUTTON_PRESS: - if (event->button.button == 1) { - command.action = E_TEP_GRAB; - command.time = event->button.time; - g_signal_emit_by_name (tep, "command", &command); - if (event->button.state & GDK_SHIFT_MASK) - command.action = E_TEP_SELECT; - else - command.action = E_TEP_MOVE; - command.position = E_TEP_VALUE; - command.value = event->button.position; - command.time = event->button.time; - tep_el->mouse_down = TRUE; - } - break; - case GDK_2BUTTON_PRESS: - if (event->button.button == 1) { - command.action = E_TEP_SELECT; - command.position = E_TEP_SELECT_WORD; - command.time = event->button.time; - } - break; - case GDK_3BUTTON_PRESS: - if (event->button.button == 1) { - command.action = E_TEP_SELECT; - command.position = E_TEP_SELECT_ALL; - command.time = event->button.time; - } - break; - case GDK_BUTTON_RELEASE: - if (event->button.button == 1) { - command.action = E_TEP_UNGRAB; - command.time = event->button.time; - tep_el->mouse_down = FALSE; - } else if (event->button.button == 2) { - command.action = E_TEP_MOVE; - command.position = E_TEP_VALUE; - command.value = event->button.position; - command.time = event->button.time; - g_signal_emit_by_name (tep, "command", &command); - - command.action = E_TEP_GET_SELECTION; - command.position = E_TEP_SELECTION; - command.value = 0; - command.time = event->button.time; - } - break; - case GDK_MOTION_NOTIFY: - if (tep_el->mouse_down) { - command.action = E_TEP_SELECT; - command.position = E_TEP_VALUE; - command.time = event->motion.time; - command.value = event->motion.position; - } - break; - case GDK_KEY_PRESS: - { - ETextEventProcessorEventKey key = event->key; - command.time = event->key.time; - if (key.state & GDK_SHIFT_MASK) - command.action = E_TEP_SELECT; - else - command.action = E_TEP_MOVE; - switch(key.keyval) { - case GDK_Home: - case GDK_KP_Home: - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_START_OF_BUFFER; - else - command.position = E_TEP_START_OF_LINE; - break; - case GDK_End: - case GDK_KP_End: - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_END_OF_BUFFER; - else - command.position = E_TEP_END_OF_LINE; - break; - case GDK_Page_Up: - case GDK_KP_Page_Up: command.position = E_TEP_BACKWARD_PAGE; break; - - case GDK_Page_Down: - case GDK_KP_Page_Down: command.position = E_TEP_FORWARD_PAGE; break; - /* CUA has Ctrl-Up/Ctrl-Down as paragraph up down */ - case GDK_Up: - case GDK_KP_Up: command.position = E_TEP_BACKWARD_LINE; break; - - case GDK_Down: - case GDK_KP_Down: command.position = E_TEP_FORWARD_LINE; break; - - case GDK_Left: - case GDK_KP_Left: - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_BACKWARD_WORD; - else - command.position = E_TEP_BACKWARD_CHARACTER; - break; - case GDK_Right: - case GDK_KP_Right: - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_FORWARD_WORD; - else - command.position = E_TEP_FORWARD_CHARACTER; - break; - - case GDK_BackSpace: - command.action = E_TEP_DELETE; - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_BACKWARD_WORD; - else - command.position = E_TEP_BACKWARD_CHARACTER; - break; - case GDK_Clear: - command.action = E_TEP_DELETE; - command.position = E_TEP_END_OF_LINE; - break; - case GDK_Insert: - case GDK_KP_Insert: - if (key.state & GDK_SHIFT_MASK) { - command.action = E_TEP_PASTE; - command.position = E_TEP_SELECTION; - } else if (key.state & GDK_CONTROL_MASK) { - command.action = E_TEP_COPY; - command.position = E_TEP_SELECTION; - } else { - /* gtk_toggle_insert(text) -- IMPLEMENT -- FIXME */ - } - break; - case GDK_Delete: - case GDK_KP_Delete: - if (key.state & GDK_CONTROL_MASK){ - command.action = E_TEP_DELETE; - command.position = E_TEP_FORWARD_WORD; - } else if (key.state & GDK_SHIFT_MASK) { - command.action = E_TEP_COPY; - command.position = E_TEP_SELECTION; - g_signal_emit_by_name (tep, "command", &command); - - command.action = E_TEP_DELETE; - command.position = E_TEP_SELECTION; - } else { - command.action = E_TEP_DELETE; - command.position = E_TEP_FORWARD_CHARACTER; - } - break; - case GDK_Tab: - case GDK_KP_Tab: - case GDK_ISO_Left_Tab: - case GDK_3270_BackTab: - /* Don't insert literally */ - command.action = E_TEP_NOP; - command.position = E_TEP_SELECTION; - break; - case GDK_Return: - case GDK_KP_Enter: - if (tep->allow_newlines) { - if (key.state & GDK_CONTROL_MASK) { - command.action = E_TEP_ACTIVATE; - command.position = E_TEP_SELECTION; - } else { - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "\n"; - } - } else { - if (key.state & GDK_CONTROL_MASK) { - command.action = E_TEP_NOP; - command.position = E_TEP_SELECTION; - } else { - command.action = E_TEP_ACTIVATE; - command.position = E_TEP_SELECTION; - } - } - break; - case GDK_Escape: - /* Don't insert literally */ - command.action = E_TEP_NOP; - command.position = E_TEP_SELECTION; - break; - - case GDK_KP_Space: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = " "; - break; - case GDK_KP_Equal: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "="; - break; - case GDK_KP_Multiply: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "*"; - break; - case GDK_KP_Add: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "+"; - break; - case GDK_KP_Subtract: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "-"; - break; - case GDK_KP_Decimal: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "."; - break; - case GDK_KP_Divide: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "/"; - break; - case GDK_KP_0: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "0"; - break; - case GDK_KP_1: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "1"; - break; - case GDK_KP_2: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "2"; - break; - case GDK_KP_3: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "3"; - break; - case GDK_KP_4: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "4"; - break; - case GDK_KP_5: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "5"; - break; - case GDK_KP_6: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "6"; - break; - case GDK_KP_7: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "7"; - break; - case GDK_KP_8: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "8"; - break; - case GDK_KP_9: - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "9"; - break; - - default: - if ((key.state & GDK_CONTROL_MASK) && !(key.state & GDK_MOD1_MASK)) { - if ((key.keyval >= 'A') && (key.keyval <= 'Z')) - key.keyval -= 'A' - 'a'; - - if ((key.keyval >= 'a') && (key.keyval <= 'z')) { - command.position = control_keys[(int) (key.keyval - 'a')].position; - if (control_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE) - command.action = control_keys[(int) (key.keyval - 'a')].action; - command.value = control_keys[(int) (key.keyval - 'a')].value; - command.string = control_keys[(int) (key.keyval - 'a')].string; - } - - if (key.keyval == 'x') { - command.action = E_TEP_COPY; - command.position = E_TEP_SELECTION; - g_signal_emit_by_name (tep, "command", &command); - - command.action = E_TEP_DELETE; - command.position = E_TEP_SELECTION; - } - - break; - } else if ((key.state & GDK_MOD1_MASK) && !(key.state & GDK_CONTROL_MASK)) { - if ((key.keyval >= 'A') && (key.keyval <= 'Z')) - key.keyval -= 'A' - 'a'; - - if ((key.keyval >= 'a') && (key.keyval <= 'z')) { - command.position = alt_keys[(int) (key.keyval - 'a')].position; - if (alt_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE) - command.action = alt_keys[(int) (key.keyval - 'a')].action; - command.value = alt_keys[(int) (key.keyval - 'a')].value; - command.string = alt_keys[(int) (key.keyval - 'a')].string; - } - } else if (!(key.state & GDK_MOD1_MASK) && !(key.state & GDK_CONTROL_MASK) && key.length > 0) { - if (key.keyval >= GDK_KP_0 && key.keyval <= GDK_KP_9) { - key.keyval = '0'; - key.string = "0"; - } - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = strlen(key.string); - command.string = key.string; - - } else { - command.action = E_TEP_NOP; - } - } - break; - case GDK_KEY_RELEASE: - command.time = event->key.time; - command.action = E_TEP_NOP; - break; - default: - command.action = E_TEP_NOP; - break; - } - } - if (command.action != E_TEP_NOP) { - g_signal_emit_by_name (tep, "command", &command); - return 1; - } - else - return 0; -} - -ETextEventProcessor * -e_text_event_processor_emacs_like_new (void) -{ - ETextEventProcessorEmacsLike *retval = g_object_new (E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, NULL); - return E_TEXT_EVENT_PROCESSOR (retval); -} - diff --git a/e-util/e-text-event-processor-emacs-like.h b/e-util/e-text-event-processor-emacs-like.h deleted file mode 100644 index 1fd74dacfe..0000000000 --- a/e-util/e-text-event-processor-emacs-like.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-text-event-processor-emacs-like.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ -#define __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* ETextEventProcessorEmacsLike - Turns events on a text widget into commands. Uses an emacs-ish interface. - * - */ - -#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE (e_text_event_processor_emacs_like_get_type ()) -#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLike)) -#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLikeClass)) -#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE)) -#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE)) - - -typedef struct _ETextEventProcessorEmacsLike ETextEventProcessorEmacsLike; -typedef struct _ETextEventProcessorEmacsLikeClass ETextEventProcessorEmacsLikeClass; - -struct _ETextEventProcessorEmacsLike -{ - ETextEventProcessor parent; - - /* object specific fields */ - guint mouse_down : 1; -}; - -struct _ETextEventProcessorEmacsLikeClass -{ - ETextEventProcessorClass parent_class; -}; - - -GType e_text_event_processor_emacs_like_get_type (void); -ETextEventProcessor *e_text_event_processor_emacs_like_new (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ */ diff --git a/e-util/e-text-event-processor-types.h b/e-util/e-text-event-processor-types.h deleted file mode 100644 index 5cb3f198d7..0000000000 --- a/e-util/e-text-event-processor-types.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-text-event-processor-types.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_TEXT_EVENT_PROCESSOR_TYPES_H__ -#define __E_TEXT_EVENT_PROCESSOR_TYPES_H__ - -#include - -G_BEGIN_DECLS - -#include - -typedef union _ETextEventProcessorEvent ETextEventProcessorEvent; - -typedef enum { - E_TEP_VALUE, - E_TEP_SELECTION, - - E_TEP_START_OF_BUFFER, - E_TEP_END_OF_BUFFER, - - E_TEP_START_OF_LINE, - E_TEP_END_OF_LINE, - - E_TEP_FORWARD_CHARACTER, - E_TEP_BACKWARD_CHARACTER, - - E_TEP_FORWARD_WORD, - E_TEP_BACKWARD_WORD, - - E_TEP_FORWARD_LINE, - E_TEP_BACKWARD_LINE, - - E_TEP_FORWARD_PARAGRAPH, - E_TEP_BACKWARD_PARAGRAPH, - - E_TEP_FORWARD_PAGE, - E_TEP_BACKWARD_PAGE, - - E_TEP_SELECT_WORD, - E_TEP_SELECT_ALL - -} ETextEventProcessorCommandPosition; - -typedef enum { - E_TEP_MOVE, - E_TEP_SELECT, - E_TEP_DELETE, - E_TEP_INSERT, - - E_TEP_CAPS, - - E_TEP_COPY, - E_TEP_PASTE, - E_TEP_GET_SELECTION, - E_TEP_SET_SELECT_BY_WORD, - E_TEP_ACTIVATE, - - E_TEP_GRAB, - E_TEP_UNGRAB, - - E_TEP_NOP -} ETextEventProcessorCommandAction; - -typedef struct { - ETextEventProcessorCommandPosition position; - ETextEventProcessorCommandAction action; - int value; - char *string; - guint32 time; -} ETextEventProcessorCommand; - -typedef struct { - GdkEventType type; - guint32 time; - guint state; - guint button; - gint position; -} ETextEventProcessorEventButton; - -typedef struct { - GdkEventType type; - guint32 time; - guint state; - guint keyval; - gint length; - gchar *string; -} ETextEventProcessorEventKey; - -typedef struct { - GdkEventType type; - guint32 time; - guint state; - gint position; -} ETextEventProcessorEventMotion; - -union _ETextEventProcessorEvent { - GdkEventType type; - ETextEventProcessorEventButton button; - ETextEventProcessorEventKey key; - ETextEventProcessorEventMotion motion; -}; - -typedef enum _ETextEventProcessorCaps { - E_TEP_CAPS_UPPER, - E_TEP_CAPS_LOWER, - E_TEP_CAPS_TITLE -} ETextEventProcessorCaps; - -G_END_DECLS - -#endif /* __E_TEXT_EVENT_PROCESSOR_TYPES_H__ */ diff --git a/e-util/e-text-event-processor.c b/e-util/e-text-event-processor.c deleted file mode 100644 index 6b974d894e..0000000000 --- a/e-util/e-text-event-processor.c +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-text-event-processor.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 "e-text-event-processor.h" -#include -#include -#include "gal/util/e-marshal.h" - -static void e_text_event_processor_init (ETextEventProcessor *card); -static void e_text_event_processor_class_init (ETextEventProcessorClass *klass); - -static void e_text_event_processor_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void e_text_event_processor_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_ALLOW_NEWLINES -}; - -enum { - E_TEP_EVENT, - E_TEP_LAST_SIGNAL -}; - -static guint e_tep_signals[E_TEP_LAST_SIGNAL] = { 0 }; - -E_MAKE_TYPE (e_text_event_processor, - "ETextEventProcessor", - ETextEventProcessor, - e_text_event_processor_class_init, - e_text_event_processor_init, - PARENT_TYPE) - -static void -e_text_event_processor_class_init (ETextEventProcessorClass *klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass*) klass; - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->set_property = e_text_event_processor_set_property; - object_class->get_property = e_text_event_processor_get_property; - - e_tep_signals[E_TEP_EVENT] = - g_signal_new ("command", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ETextEventProcessorClass, command), - NULL, NULL, - e_marshal_NONE__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - - g_object_class_install_property (object_class, PROP_ALLOW_NEWLINES, - g_param_spec_boolean ("allow_newlines", - _( "Allow newlines" ), - _( "Allow newlines" ), - FALSE, - G_PARAM_READWRITE)); - - klass->event = NULL; - klass->command = NULL; - -} - -static void -e_text_event_processor_init (ETextEventProcessor *tep) -{ - tep->allow_newlines = TRUE; -} - -gint -e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event) -{ - if (E_TEXT_EVENT_PROCESSOR_GET_CLASS(tep)->event) - return E_TEXT_EVENT_PROCESSOR_GET_CLASS(tep)->event(tep, event); - else - return 0; -} - -/* Set_arg handler for the text item */ -static void -e_text_event_processor_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ETextEventProcessor *tep = E_TEXT_EVENT_PROCESSOR (object); - - switch (prop_id) { - case PROP_ALLOW_NEWLINES: - tep->allow_newlines = g_value_get_boolean (value); - break; - default: - return; - } -} - -/* Get_arg handler for the text item */ -static void -e_text_event_processor_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ETextEventProcessor *tep = E_TEXT_EVENT_PROCESSOR (object); - - switch (prop_id) { - case PROP_ALLOW_NEWLINES: - g_value_set_boolean (value, tep->allow_newlines); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} diff --git a/e-util/e-text-event-processor.h b/e-util/e-text-event-processor.h deleted file mode 100644 index 21f2550fde..0000000000 --- a/e-util/e-text-event-processor.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-text-event-processor.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_TEXT_EVENT_PROCESSOR_H__ -#define __E_TEXT_EVENT_PROCESSOR_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* ETextEventProcessor - Turns events on a text widget into commands. - * - */ - -#define E_TEXT_EVENT_PROCESSOR_TYPE (e_text_event_processor_get_type ()) -#define E_TEXT_EVENT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessor)) -#define E_TEXT_EVENT_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessorClass)) -#define E_IS_TEXT_EVENT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE)) -#define E_IS_TEXT_EVENT_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE)) -#define E_TEXT_EVENT_PROCESSOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessorClass)) -typedef struct _ETextEventProcessor ETextEventProcessor; -typedef struct _ETextEventProcessorClass ETextEventProcessorClass; - -struct _ETextEventProcessor -{ - GObject parent; - - /* object specific fields */ - guint allow_newlines : 1; -}; - -struct _ETextEventProcessorClass -{ - GtkObjectClass parent_class; - - /* signals */ - void (* command) (ETextEventProcessor *tep, ETextEventProcessorCommand *command); - - /* virtual functions */ - gint (* event) (ETextEventProcessor *tep, ETextEventProcessorEvent *event); -}; - - -GType e_text_event_processor_get_type (void); -gint e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_TEXT_EVENT_PROCESSOR_H__ */ diff --git a/e-util/e-util.c b/e-util/e-util.c deleted file mode 100644 index 4e3584a059..0000000000 --- a/e-util/e-util.c +++ /dev/null @@ -1,1150 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-util.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 -#include "e-util.h" -#include "e-i18n.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if 0 -#include -#endif - -int -g_str_compare (const void *x, const void *y) -{ - if (x == NULL || y == NULL) { - if (x == y) - return 0; - else - return x ? -1 : 1; - } - - return strcmp (x, y); -} - -int -g_collate_compare (const void *x, const void *y) -{ - if (x == NULL || y == NULL) { - if (x == y) - return 0; - else - return x ? -1 : 1; - } - - return g_utf8_collate (x, y); -} - -int -g_int_compare (const void *x, const void *y) -{ - if (GPOINTER_TO_INT (x) < GPOINTER_TO_INT (y)) - return -1; - else if (GPOINTER_TO_INT (x) == GPOINTER_TO_INT (y)) - return 0; - else - return 1; -} - -char * -e_strdup_strip(const char *string) -{ - int i; - int length = 0; - int initial = 0; - for ( i = 0; string[i]; i++ ) { - if (initial == i && isspace((unsigned char) string[i])) { - initial ++; - } - if (!isspace((unsigned char) string[i])) { - length = i - initial + 1; - } - } - return g_strndup(string + initial, length); -} - -void -e_free_object_list (GList *list) -{ - GList *p; - - for (p = list; p != NULL; p = p->next) - g_object_unref (p->data); - - g_list_free (list); -} - -void -e_free_object_slist (GSList *list) -{ - GSList *p; - - for (p = list; p != NULL; p = p->next) - g_object_unref (p->data); - - g_slist_free (list); -} - -void -e_free_string_list (GList *list) -{ - GList *p; - - for (p = list; p != NULL; p = p->next) - g_free (p->data); - - g_list_free (list); -} - -void -e_free_string_slist (GSList *list) -{ - GSList *p; - - for (p = list; p != NULL; p = p->next) - g_free (p->data); - g_slist_free (list); -} - -#define BUFF_SIZE 1024 - -char * -e_read_file(const char *filename) -{ - int fd; - char buffer[BUFF_SIZE]; - GList *list = NULL, *list_iterator; - GList *lengths = NULL, *lengths_iterator; - int length = 0; - int bytes; - char *ret_val; - - fd = open(filename, O_RDONLY); - if (fd == -1) - return NULL; - bytes = read(fd, buffer, BUFF_SIZE); - while (bytes) { - if (bytes > 0) { - char *temp = g_malloc(bytes); - memcpy (temp, buffer, bytes); - list = g_list_prepend(list, temp); - lengths = g_list_prepend(lengths, GINT_TO_POINTER(bytes)); - length += bytes; - } else { - if (errno != EINTR) { - close(fd); - g_list_foreach(list, (GFunc) g_free, NULL); - g_list_free(list); - g_list_free(lengths); - return NULL; - } - } - bytes = read(fd, buffer, BUFF_SIZE); - } - ret_val = g_new(char, length + 1); - ret_val[length] = 0; - lengths_iterator = lengths; - list_iterator = list; - for ( ; list_iterator; list_iterator = list_iterator->next, lengths_iterator = lengths_iterator->next) { - int this_length = GPOINTER_TO_INT(lengths_iterator->data); - length -= this_length; - memcpy(ret_val + length, list_iterator->data, this_length); - } - close(fd); - g_list_foreach(list, (GFunc) g_free, NULL); - g_list_free(list); - g_list_free(lengths); - return ret_val; -} - -gint -e_write_file(const char *filename, const char *data, int flags) -{ - int fd; - int length = strlen(data); - int bytes; - fd = open(filename, flags | O_WRONLY, 0666); - if (fd == -1) - return errno; - while (length > 0) { - bytes = write(fd, data, length); - if (bytes > 0) { - length -= bytes; - data += bytes; - } else { - if (errno != EINTR && errno != EAGAIN) { - int save_errno = errno; - close(fd); - return save_errno; - } - } - } - if (close(fd) != 0) { - return errno; - } - return 0; -} - -gint -e_write_file_mkstemp(char *filename, const char *data) -{ - int fd; - int length = strlen(data); - int bytes; - fd = mkstemp (filename); - if (fd == -1) - return errno; - while (length > 0) { - bytes = write(fd, data, length); - if (bytes > 0) { - length -= bytes; - data += bytes; - } else { - if (errno != EINTR && errno != EAGAIN) { - int save_errno = errno; - close(fd); - return save_errno; - } - } - } - if (close(fd) != 0) { - return errno; - } - return 0; -} - -/** - * e_mkdir_hier: - * @path: a directory path - * @mode: a mode, as for mkdir(2) - * - * This creates the named directory with the given @mode, creating - * any necessary intermediate directories (with the same @mode). - * - * Return value: 0 on success, -1 on error, in which case errno will - * be set as for mkdir(2). - **/ -int -e_mkdir_hier(const char *path, mode_t mode) -{ - char *copy, *p; - - if (path[0] == '/') { - p = copy = g_strdup (path); - } else { - gchar *current_dir = g_get_current_dir(); - p = copy = g_concat_dir_and_file (current_dir, path); - } - - do { - p = strchr (p + 1, '/'); - if (p) - *p = '\0'; - if (access (copy, F_OK) == -1) { - if (mkdir (copy, mode) == -1) { - g_free (copy); - return -1; - } - } - if (p) - *p = '/'; - } while (p); - - g_free (copy); - return 0; -} - -#if 0 -char * -e_read_uri(const char *uri) -{ - GnomeVFSHandle *handle; - GList *list = NULL, *list_iterator; - GList *lengths = NULL, *lengths_iterator; - gchar buffer[1025]; - gchar *ret_val; - int length = 0; - GnomeVFSFileSize bytes; - - gnome_vfs_open(&handle, uri, GNOME_VFS_OPEN_READ); - - gnome_vfs_read(handle, buffer, 1024, &bytes); - while (bytes) { - if (bytes) { - char *temp = g_malloc(bytes); - memcpy (temp, buffer, bytes); - list = g_list_prepend(list, temp); - lengths = g_list_prepend(lengths, GINT_TO_POINTER((gint) bytes)); - length += bytes; - } - gnome_vfs_read(handle, buffer, 1024, &bytes); - } - - ret_val = g_new(char, length + 1); - ret_val[length] = 0; - lengths_iterator = lengths; - list_iterator = list; - for ( ; list_iterator; list_iterator = list_iterator->next, lengths_iterator = lengths_iterator->next) { - int this_length = GPOINTER_TO_INT(lengths_iterator->data); - length -= this_length; - memcpy(ret_val + length, list_iterator->data, this_length); - } - gnome_vfs_close(handle); - g_list_foreach(list, (GFunc) g_free, NULL); - g_list_free(list); - g_list_free(lengths); - return ret_val; -} -#endif - -/* Include build marshalers */ - -#include "e-marshal.h" -#include "e-marshal.c" - -gchar** -e_strsplit (const gchar *string, - const gchar *delimiter, - gint max_tokens) -{ - GSList *string_list = NULL, *slist; - gchar **str_array, *s; - guint i, n = 1; - - g_return_val_if_fail (string != NULL, NULL); - g_return_val_if_fail (delimiter != NULL, NULL); - - if (max_tokens < 1) - max_tokens = G_MAXINT; - - s = strstr (string, delimiter); - if (s) - { - guint delimiter_len = strlen (delimiter); - - do - { - guint len; - gchar *new_string; - - len = s - string; - new_string = g_new (gchar, len + 1); - strncpy (new_string, string, len); - new_string[len] = 0; - string_list = g_slist_prepend (string_list, new_string); - n++; - string = s + delimiter_len; - s = strstr (string, delimiter); - } - while (--max_tokens && s); - } - - n++; - string_list = g_slist_prepend (string_list, g_strdup (string)); - - str_array = g_new (gchar*, n); - - i = n - 1; - - str_array[i--] = NULL; - for (slist = string_list; slist; slist = slist->next) - str_array[i--] = slist->data; - - g_slist_free (string_list); - - return str_array; -} - -gchar * -e_strstrcase (const gchar *haystack, const gchar *needle) -{ - /* find the needle in the haystack neglecting case */ - const gchar *ptr; - guint len; - - g_return_val_if_fail (haystack != NULL, NULL); - g_return_val_if_fail (needle != NULL, NULL); - - len = strlen(needle); - if (len > strlen(haystack)) - return NULL; - - if (len == 0) - return (gchar *) haystack; - - for (ptr = haystack; *(ptr + len - 1) != '\0'; ptr++) - if (!g_strncasecmp (ptr, needle, len)) - return (gchar *) ptr; - - return NULL; -} - -/* This only makes a filename safe for usage as a filename. It still may have shell meta-characters in it. */ -void -e_filename_make_safe (gchar *string) -{ - gchar *p; - - g_return_if_fail (string != NULL); - - for (p = string; *p; p++) { - if (!isprint ((unsigned char)*p) || strchr (" /'\"`&();|<>${}!", *p)) - *p = '_'; - } -} - -static gint -epow10 (gint number) { - gint value; - - for (value = 1; number > 0; number --) { - value *= 10; - } - return value; -} - -gchar * -e_format_number (gint number) -{ - GList *iterator, *list = NULL; - struct lconv *locality; - gint char_length = 0; - gint group_count = 0; - guchar *grouping; - int last_count = 3; - int divider; - char *value; - char *value_iterator; - - locality = localeconv(); - grouping = locality->grouping; - while (number) { - char *group; - switch (*grouping) { - default: - last_count = *grouping; - grouping++; - case 0: - divider = epow10(last_count); - if (number >= divider) { - group = g_strdup_printf("%0*d", last_count, number % divider); - } else { - group = g_strdup_printf("%d", number % divider); - } - number /= divider; - break; - case CHAR_MAX: - group = g_strdup_printf("%d", number); - number = 0; - break; - } - char_length += strlen(group); - list = g_list_prepend(list, group); - group_count ++; - } - - if (list) { - value = g_new(char, 1 + char_length + (group_count - 1) * strlen(locality->thousands_sep)); - - iterator = list; - value_iterator = value; - - strcpy(value_iterator, iterator->data); - value_iterator += strlen(iterator->data); - for (iterator = iterator->next; iterator; iterator = iterator->next) { - strcpy(value_iterator, locality->thousands_sep); - value_iterator += strlen(locality->thousands_sep); - - strcpy(value_iterator, iterator->data); - value_iterator += strlen(iterator->data); - } - e_free_string_list (list); - return value; - } else { - return g_strdup("0"); - } -} - -static gchar * -do_format_number_as_float (double number) -{ - GList *iterator, *list = NULL; - struct lconv *locality; - gint char_length = 0; - gint group_count = 0; - guchar *grouping; - int last_count = 3; - int divider; - char *value; - char *value_iterator; - double fractional; - - locality = localeconv(); - grouping = locality->grouping; - while (number >= 1.0) { - char *group; - switch (*grouping) { - default: - last_count = *grouping; - grouping++; - /* Fall through */ - case 0: - divider = epow10(last_count); - number /= divider; - fractional = modf (number, &number); - fractional *= divider; - fractional = floor (fractional); - - if (number >= 1.0) { - group = g_strdup_printf("%0*d", last_count, (int) fractional); - } else { - group = g_strdup_printf("%d", (int) fractional); - } - break; - case CHAR_MAX: - divider = epow10(last_count); - number /= divider; - fractional = modf (number, &number); - fractional *= divider; - fractional = floor (fractional); - - while (number >= 1.0) { - group = g_strdup_printf("%0*d", last_count, (int) fractional); - - char_length += strlen(group); - list = g_list_prepend(list, group); - group_count ++; - - divider = epow10(last_count); - number /= divider; - fractional = modf (number, &number); - fractional *= divider; - fractional = floor (fractional); - } - - group = g_strdup_printf("%d", (int) fractional); - break; - } - char_length += strlen(group); - list = g_list_prepend(list, group); - group_count ++; - } - - if (list) { - value = g_new(char, 1 + char_length + (group_count - 1) * strlen(locality->thousands_sep)); - - iterator = list; - value_iterator = value; - - strcpy(value_iterator, iterator->data); - value_iterator += strlen(iterator->data); - for (iterator = iterator->next; iterator; iterator = iterator->next) { - strcpy(value_iterator, locality->thousands_sep); - value_iterator += strlen(locality->thousands_sep); - - strcpy(value_iterator, iterator->data); - value_iterator += strlen(iterator->data); - } - e_free_string_list (list); - return value; - } else { - return g_strdup("0"); - } -} - -gchar * -e_format_number_float (gfloat number) -{ - gfloat int_part; - gint fraction; - struct lconv *locality; - gchar *str_intpart; - gchar *decimal_point; - gchar *str_fraction; - gchar *value; - - locality = localeconv(); - - int_part = floor (number); - str_intpart = do_format_number_as_float ((double) int_part); - - if (!strcmp(locality->mon_decimal_point, "")) { - decimal_point = "."; - } - else { - decimal_point = locality->mon_decimal_point; - } - - fraction = (int) ((number - int_part) * 100); - - if (fraction == 0) { - str_fraction = g_strdup ("00"); - } else { - str_fraction = g_strdup_printf ("%02d", fraction); - } - - value = g_strconcat (str_intpart, decimal_point, str_fraction, NULL); - - g_free (str_intpart); - g_free (str_fraction); - - return value; -} - -gboolean -e_create_directory (gchar *directory) -{ - gint ret_val = e_mkdir_hier (directory, 0777); - if (ret_val == -1) - return FALSE; - else - return TRUE; -} - - -/* Perform a binary search for key in base which has nmemb elements - of size bytes each. The comparisons are done by (*compare)(). */ -void e_bsearch (const void *key, - const void *base, - size_t nmemb, - size_t size, - ESortCompareFunc compare, - gpointer closure, - size_t *start, - size_t *end) -{ - size_t l, u, idx; - const void *p; - int comparison; - if (!(start || end)) - return; - - l = 0; - u = nmemb; - while (l < u) { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compare) (key, p, closure); - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else { - size_t lsave, usave; - lsave = l; - usave = u; - if (start) { - while (l < u) { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compare) (key, p, closure); - if (comparison <= 0) - u = idx; - else - l = idx + 1; - } - *start = l; - - l = lsave; - u = usave; - } - if (end) { - while (l < u) { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compare) (key, p, closure); - if (comparison < 0) - u = idx; - else - l = idx + 1; - } - *end = l; - } - return; - } - } - - if (start) - *start = l; - if (end) - *end = l; -} - -static gpointer closure_closure; -static ESortCompareFunc compare_closure; - -static int -qsort_callback(const void *data1, const void *data2) -{ - return (*compare_closure) (data1, data2, closure_closure); -} - -/* Forget it. We're just going to use qsort. I lost the need for a stable sort. */ -void -e_sort (void *base, - size_t nmemb, - size_t size, - ESortCompareFunc compare, - gpointer closure) -{ - closure_closure = closure; - compare_closure = compare; - qsort(base, nmemb, size, qsort_callback); -#if 0 - void *base_copy; - int i; - base_copy = g_malloc(nmemb * size); - - for (i = 0; i < nmemb; i++) { - int position; - e_bsearch(base + (i * size), base_copy, i, size, compare, closure, NULL, &position); - memmove(base_copy + (position + 1) * size, base_copy + position * size, (i - position) * size); - memcpy(base_copy + position * size, base + i * size, size); - } - memcpy(base, base_copy, nmemb * size); - g_free(base_copy); -#endif -} - -size_t e_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) -{ -#ifdef HAVE_LKSTRFTIME - return strftime(s, max, fmt, tm); -#else - char *c, *ffmt, *ff; - size_t ret; - - ffmt = g_strdup(fmt); - ff = ffmt; - while ((c = strstr(ff, "%l")) != NULL) { - c[1] = 'I'; - ff = c; - } - - ff = fmt; - while ((c = strstr(ff, "%k")) != NULL) { - c[1] = 'H'; - ff = c; - } - - ret = strftime(s, max, ffmt, tm); - g_free(ffmt); - return ret; -#endif -} - - -/** - * Function to do a last minute fixup of the AM/PM stuff if the locale - * and gettext haven't done it right. Most English speaking countries - * except the USA use the 24 hour clock (UK, Australia etc). However - * since they are English nobody bothers to write a language - * translation (gettext) file. So the locale turns off the AM/PM, but - * gettext does not turn on the 24 hour clock. Leaving a mess. - * - * This routine checks if AM/PM are defined in the locale, if not it - * forces the use of the 24 hour clock. - * - * The function itself is a front end on strftime and takes exactly - * the same arguments. - * - * TODO: Actually remove the '%p' from the fixed up string so that - * there isn't a stray space. - **/ - -size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct tm *tm) -{ - char buf[10]; - char *sp; - char *ffmt; - size_t ret; - - if (strstr(fmt, "%p")==NULL && strstr(fmt, "%P")==NULL) { - /* No AM/PM involved - can use the fmt string directly */ - ret=e_strftime(s, max, fmt, tm); - } else { - /* Get the AM/PM symbol from the locale */ - e_strftime (buf, 10, "%p", tm); - - if (buf[0]) { - /** - * AM/PM have been defined in the locale - * so we can use the fmt string directly - **/ - ret=e_strftime(s, max, fmt, tm); - } else { - /** - * No AM/PM defined by locale - * must change to 24 hour clock - **/ - ffmt=g_strdup(fmt); - for (sp=ffmt; (sp=strstr(sp, "%l")); sp++) { - /** - * Maybe this should be 'k', but I have never - * seen a 24 clock actually use that format - **/ - sp[1]='H'; - } - for (sp=ffmt; (sp=strstr(sp, "%I")); sp++) { - sp[1]='H'; - } - ret=e_strftime(s, max, ffmt, tm); - g_free(ffmt); - } - } - return(ret); -} - -/** - * e_flexible_strtod: - * @nptr: the string to convert to a numeric value. - * @endptr: if non-NULL, it returns the character after - * the last character used in the conversion. - * - * Converts a string to a gdouble value. This function detects - * strings either in the standard C locale or in the current locale. - * - * This function is typically used when reading configuration files or - * other non-user input that should not be locale dependent, but may - * have been in the past. To handle input from the user you should - * normally use the locale-sensitive system strtod function. - * - * To convert from a double to a string in a locale-insensitive way, use - * @g_ascii_dtostr. - * - * Return value: the gdouble value. - **/ -gdouble -e_flexible_strtod (const gchar *nptr, - gchar **endptr) -{ - gchar *fail_pos; - gdouble val; - struct lconv *locale_data; - const char *decimal_point; - int decimal_point_len; - const char *p, *decimal_point_pos; - const char *end = NULL; /* Silence gcc */ - char *copy, *c; - - g_return_val_if_fail (nptr != NULL, 0); - - fail_pos = NULL; - - locale_data = localeconv (); - decimal_point = locale_data->decimal_point; - decimal_point_len = strlen (decimal_point); - - g_assert (decimal_point_len != 0); - - decimal_point_pos = NULL; - if (!strcmp (decimal_point, ".")) - return strtod (nptr, endptr); - - p = nptr; - - /* Skip leading space */ - while (isspace ((guchar)*p)) - p++; - - /* Skip leading optional sign */ - if (*p == '+' || *p == '-') - p++; - - if (p[0] == '0' && - (p[1] == 'x' || p[1] == 'X')) { - p += 2; - /* HEX - find the (optional) decimal point */ - - while (isxdigit ((guchar)*p)) - p++; - - if (*p == '.') { - decimal_point_pos = p++; - - while (isxdigit ((guchar)*p)) - p++; - - if (*p == 'p' || *p == 'P') - p++; - if (*p == '+' || *p == '-') - p++; - while (isdigit ((guchar)*p)) - p++; - end = p; - } else if (strncmp (p, decimal_point, decimal_point_len) == 0) { - return strtod (nptr, endptr); - } - } else { - while (isdigit ((guchar)*p)) - p++; - - if (*p == '.') { - decimal_point_pos = p++; - - while (isdigit ((guchar)*p)) - p++; - - if (*p == 'e' || *p == 'E') - p++; - if (*p == '+' || *p == '-') - p++; - while (isdigit ((guchar)*p)) - p++; - end = p; - } else if (strncmp (p, decimal_point, decimal_point_len) == 0) { - return strtod (nptr, endptr); - } - } - /* For the other cases, we need not convert the decimal point */ - - if (!decimal_point_pos) - return strtod (nptr, endptr); - - /* We need to convert the '.' to the locale specific decimal point */ - copy = g_malloc (end - nptr + 1 + decimal_point_len); - - c = copy; - memcpy (c, nptr, decimal_point_pos - nptr); - c += decimal_point_pos - nptr; - memcpy (c, decimal_point, decimal_point_len); - c += decimal_point_len; - memcpy (c, decimal_point_pos + 1, end - (decimal_point_pos + 1)); - c += end - (decimal_point_pos + 1); - *c = 0; - - val = strtod (copy, &fail_pos); - - if (fail_pos) { - if (fail_pos > decimal_point_pos) - fail_pos = (char *)nptr + (fail_pos - copy) - (decimal_point_len - 1); - else - fail_pos = (char *)nptr + (fail_pos - copy); - } - - g_free (copy); - - if (endptr) - *endptr = fail_pos; - - return val; -} - -/** - * e_ascii_dtostr: - * @buffer: A buffer to place the resulting string in - * @buf_len: The length of the buffer. - * @format: The printf-style format to use for the - * code to use for converting. - * @d: The double to convert - * - * Converts a double to a string, using the '.' as - * decimal_point. To format the number you pass in - * a printf-style formating string. Allowed conversion - * specifiers are eEfFgG. - * - * If you want to generates enough precision that converting - * the string back using @g_strtod gives the same machine-number - * (on machines with IEEE compatible 64bit doubles) use the format - * string "%.17g". If you do this it is guaranteed that the size - * of the resulting string will never be larger than - * @G_ASCII_DTOSTR_BUF_SIZE bytes. - * - * Return value: The pointer to the buffer with the converted string. - **/ -gchar * -e_ascii_dtostr (gchar *buffer, - gint buf_len, - const gchar *format, - gdouble d) -{ - struct lconv *locale_data; - const char *decimal_point; - int decimal_point_len; - gchar *p; - int rest_len; - gchar format_char; - - g_return_val_if_fail (buffer != NULL, NULL); - g_return_val_if_fail (format[0] == '%', NULL); - g_return_val_if_fail (strpbrk (format + 1, "'l%") == NULL, NULL); - - format_char = format[strlen (format) - 1]; - - g_return_val_if_fail (format_char == 'e' || format_char == 'E' || - format_char == 'f' || format_char == 'F' || - format_char == 'g' || format_char == 'G', - NULL); - - if (format[0] != '%') - return NULL; - - if (strpbrk (format + 1, "'l%")) - return NULL; - - if (!(format_char == 'e' || format_char == 'E' || - format_char == 'f' || format_char == 'F' || - format_char == 'g' || format_char == 'G')) - return NULL; - - - g_snprintf (buffer, buf_len, format, d); - - locale_data = localeconv (); - decimal_point = locale_data->decimal_point; - decimal_point_len = strlen (decimal_point); - - g_assert (decimal_point_len != 0); - - if (strcmp (decimal_point, ".")) { - p = buffer; - - if (*p == '+' || *p == '-') - p++; - - while (isdigit ((guchar)*p)) - p++; - - if (strncmp (p, decimal_point, decimal_point_len) == 0) { - *p = '.'; - p++; - if (decimal_point_len > 1) { - rest_len = strlen (p + (decimal_point_len-1)); - memmove (p, p + (decimal_point_len-1), - rest_len); - p[rest_len] = 0; - } - } - } - - return buffer; -} - -gchar * -e_strdup_append_strings (gchar *first_string, ...) -{ - gchar *buffer; - gchar *current; - gint length; - va_list args1; - va_list args2; - char *v_string; - int v_int; - - va_start (args1, first_string); - G_VA_COPY (args2, args1); - - length = 0; - - v_string = first_string; - while (v_string) { - v_int = va_arg (args1, int); - if (v_int >= 0) - length += v_int; - else - length += strlen (v_string); - v_string = va_arg (args1, char *); - } - - buffer = g_new (char, length + 1); - current = buffer; - - v_string = first_string; - while (v_string) { - v_int = va_arg (args2, int); - if (v_int < 0) { - int i; - for (i = 0; v_string[i]; i++) { - *(current++) = v_string[i]; - } - } else { - int i; - for (i = 0; v_string[i] && i < v_int; i++) { - *(current++) = v_string[i]; - } - } - v_string = va_arg (args2, char *); - } - *(current++) = 0; - - va_end (args1); - va_end (args2); - - return buffer; -} - -gchar ** -e_strdupv (const gchar **str_array) -{ - if (str_array) { - gint i; - gchar **retval; - - i = 0; - while (str_array[i]) - i++; - - retval = g_new (gchar*, i + 1); - - i = 0; - while (str_array[i]) { - retval[i] = g_strdup (str_array[i]); - i++; - } - retval[i] = NULL; - - return retval; - } else { - return NULL; - } -} - -char * -e_gettext (const char *msgid) -{ - static gboolean initialized = FALSE; - - if (!initialized) { - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - initialized = TRUE; - } - - return dgettext (GETTEXT_PACKAGE, msgid); -} - diff --git a/e-util/e-util.h b/e-util/e-util.h deleted file mode 100644 index 2937265f6b..0000000000 --- a/e-util/e-util.h +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-util.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_UTIL_H_ -#define _E_UTIL_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#include - -#define E_MAKE_TYPE(l,str,t,ci,i,parent) \ -GType l##_get_type(void)\ -{\ - static GType type = 0; \ - if (!type){ \ - static GTypeInfo const object_info = { \ - sizeof (t##Class), \ - \ - (GBaseInitFunc) NULL, \ - (GBaseFinalizeFunc) NULL, \ - \ - (GClassInitFunc) ci, \ - (GClassFinalizeFunc) NULL, \ - NULL, /* class_data */ \ - \ - sizeof (t), \ - 0, /* n_preallocs */ \ - (GInstanceInitFunc) i, \ - }; \ - type = g_type_register_static (parent, str, &object_info, 0); \ - } \ - return type; \ -} - - -#define E_MAKE_X_TYPE(l,str,t,ci,i,parent,poa_init,offset) \ -GtkType l##_get_type(void) \ -{ \ - static GtkType type = 0; \ - if (!type){ \ - GTypeInfo info = { \ - sizeof (t##Class), \ - \ - (GBaseInitFunc) NULL, \ - (GBaseFinalizeFunc) NULL, \ - \ - (GClassInitFunc) ci, \ - (GClassFinalizeFunc) NULL, \ - \ - NULL, /* class_data */ \ - \ - sizeof (t), \ - 0, /* n_preallocs */ \ - (GInstanceInitFunc) i, \ - }; \ - type = bonobo_x_type_unique ( \ - parent, poa_init, NULL, \ - offset, &info, str); \ - } \ - return type; \ -} - -#define GET_STRING_ARRAY_FROM_ELLIPSIS(labels, first_string) \ - { \ - va_list args; \ - int i; \ - char *s; \ - \ - va_start (args, (first_string)); \ - \ - i = 0; \ - for (s = (first_string); s; s = va_arg (args, char *)) \ - i++; \ - va_end (args); \ - \ - (labels) = g_new (char *, i + 1); \ - \ - va_start (args, (first_string)); \ - i = 0; \ - for (s = (first_string); s; s = va_arg (args, char *)) \ - (labels)[i++] = s; \ - \ - va_end (args); \ - (labels)[i] = NULL; \ - } - - -#define GET_DUPLICATED_STRING_ARRAY_FROM_ELLIPSIS(labels, first_string) \ - { \ - int i; \ - GET_STRING_ARRAY_FROM_ELLIPSIS ((labels), (first_string)); \ - for (i = 0; labels[i]; i++) \ - labels[i] = g_strdup (labels[i]); \ - } - - -#if 0 -# define E_OBJECT_CLASS_ADD_SIGNALS(oc,sigs,last) \ - gtk_object_class_add_signals (oc, sigs, last) -# define E_OBJECT_CLASS_TYPE(oc) (oc)->type -#else -# define E_OBJECT_CLASS_ADD_SIGNALS(oc,sigs,last) -# define E_OBJECT_CLASS_TYPE(oc) G_TYPE_FROM_CLASS (oc) -#endif - - -typedef enum { - E_FOCUS_NONE, - E_FOCUS_CURRENT, - E_FOCUS_START, - E_FOCUS_END -} EFocus; -int g_str_compare (const void *x, - const void *y); -int g_collate_compare (const void *x, - const void *y); -int g_int_compare (const void *x, - const void *y); -char *e_strdup_strip (const char *string); -void e_free_object_list (GList *list); -void e_free_object_slist (GSList *list); -void e_free_string_list (GList *list); -void e_free_string_slist (GSList *list); -char *e_read_file (const char *filename); -int e_write_file (const char *filename, - const char *data, - int flags); -int e_write_file_mkstemp (char *filename, - const char *data); -int e_mkdir_hier (const char *path, - mode_t mode); - -gchar **e_strsplit (const gchar *string, - const gchar *delimiter, - gint max_tokens); -gchar *e_strstrcase (const gchar *haystack, - const gchar *needle); -/* This only makes a filename safe for usage as a filename. It still may have shell meta-characters in it. */ -void e_filename_make_safe (gchar *string); -gchar *e_format_number (gint number); -gchar *e_format_number_float (gfloat number); -gboolean e_create_directory (gchar *directory); -gchar **e_strdupv (const gchar **str_array); - - -typedef int (*ESortCompareFunc) (const void *first, - const void *second, - gpointer closure); -void e_sort (void *base, - size_t nmemb, - size_t size, - ESortCompareFunc compare, - gpointer closure); -void e_bsearch (const void *key, - const void *base, - size_t nmemb, - size_t size, - ESortCompareFunc compare, - gpointer closure, - size_t *start, - size_t *end); -size_t e_strftime_fix_am_pm (char *s, - size_t max, - const char *fmt, - const struct tm *tm); - -size_t e_strftime (char *s, - size_t max, - const char *fmt, - const struct tm *tm); - -/* String to/from double conversion functions */ -gdouble e_flexible_strtod (const gchar *nptr, - gchar **endptr); - -/* 29 bytes should enough for all possible values that - * g_ascii_dtostr can produce with the %.17g format. - * Then add 10 for good measure */ -#define E_ASCII_DTOSTR_BUF_SIZE (DBL_DIG + 12 + 10) -gchar *e_ascii_dtostr (gchar *buffer, - gint buf_len, - const gchar *format, - gdouble d); - -/* Alternating char * and int arguments with a NULL char * to end. - Less than 0 for the int means copy the whole string. */ -gchar *e_strdup_append_strings (gchar *first_string, - ...); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_UTIL_H_ */ diff --git a/e-util/e-xml-hash-utils.c b/e-util/e-xml-hash-utils.c index e82d5ab237..efb29f5fb6 100644 --- a/e-util/e-xml-hash-utils.c +++ b/e-util/e-xml-hash-utils.c @@ -38,7 +38,7 @@ e_xml_to_hash (xmlDoc *doc, EXmlHashType type) root = xmlDocGetRootElement (doc); for (node = root->xmlChildrenNode; node; node = node->next) { - if (node->name == NULL || node->type != XML_ELEMENT_NODE) + if (node->name == NULL) continue; if (type == E_XML_HASH_TYPE_OBJECT_UID && diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c deleted file mode 100644 index 437934be65..0000000000 --- a/e-util/e-xml-utils.c +++ /dev/null @@ -1,502 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-xml-utils.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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 -#endif - -#include "e-xml-utils.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gal/util/e-i18n.h" -#include "gal/util/e-util.h" - -xmlNode * -e_xml_get_child_by_name (const xmlNode *parent, const xmlChar *child_name) -{ - xmlNode *child; - - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (child_name != NULL, NULL); - - for (child = parent->xmlChildrenNode; child != NULL; child = child->next) { - if (xmlStrcmp (child->name, child_name) == 0) { - return child; - } - } - return NULL; -} - -/* Returns the first child with the name child_name and the "lang" - * attribute that matches the current LC_MESSAGES, or else, the first - * child with the name child_name and no "lang" attribute. - */ -xmlNode * -e_xml_get_child_by_name_by_lang (const xmlNode *parent, - const xmlChar *child_name, - const gchar *lang) -{ - xmlNode *child; - /* This is the default version of the string. */ - xmlNode *C = NULL; - - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (child_name != NULL, NULL); - - if (lang == NULL) { -#ifdef HAVE_LC_MESSAGES - lang = setlocale (LC_MESSAGES, NULL); -#else - lang = setlocale (LC_CTYPE, NULL); -#endif - } - for (child = parent->xmlChildrenNode; child != NULL; child = child->next) { - if (xmlStrcmp (child->name, child_name) == 0) { - xmlChar *this_lang = xmlGetProp (child, "lang"); - if (this_lang == NULL) { - C = child; - } else if (xmlStrcmp(this_lang, "lang") == 0) { - return child; - } - } - } - return C; -} - -static xmlNode * -e_xml_get_child_by_name_by_lang_list_with_score (const xmlNode *parent, - const gchar *name, - const GList *lang_list, - gint *best_lang_score) -{ - xmlNodePtr best_node = NULL, node; - - for (node = parent->xmlChildrenNode; node != NULL; node = node->next) { - xmlChar *lang; - - if (node->name == NULL || strcmp (node->name, name) != 0) { - continue; - } - lang = xmlGetProp (node, "xml:lang"); - if (lang != NULL) { - const GList *l; - gint i; - - for (l = lang_list, i = 0; - l != NULL && i < *best_lang_score; - l = l->next, i++) { - if (strcmp ((gchar *) l->data, lang) == 0) { - best_node = node; - *best_lang_score = i; - } - } - } else { - if (best_node == NULL) { - best_node = node; - } - } - xmlFree (lang); - if (*best_lang_score == 0) { - return best_node; - } - } - - return best_node; -} - -/* - * e_xml_get_child_by_name_by_lang_list: - * - */ -xmlNode * -e_xml_get_child_by_name_by_lang_list (const xmlNode *parent, - const gchar *name, - const GList *lang_list) -{ - gint best_lang_score = INT_MAX; - - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (name != NULL, NULL); - - if (lang_list == NULL) { - lang_list = gnome_i18n_get_language_list ("LC_MESSAGES"); - } - return e_xml_get_child_by_name_by_lang_list_with_score - (parent,name, - lang_list, - &best_lang_score); -} - -/* - * e_xml_get_child_by_name_no_lang - * - */ -xmlNode * -e_xml_get_child_by_name_no_lang (const xmlNode *parent, const gchar *name) -{ - xmlNodePtr node; - - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (name != NULL, NULL); - - for (node = parent->xmlChildrenNode; node != NULL; node = node->next) { - xmlChar *lang; - - if (node->name == NULL || strcmp (node->name, name) != 0) { - continue; - } - lang = xmlGetProp (node, "xml:lang"); - if (lang == NULL) { - return node; - } - xmlFree (lang); - } - - return NULL; -} - -gint -e_xml_get_integer_prop_by_name (const xmlNode *parent, const xmlChar *prop_name) -{ - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - return e_xml_get_integer_prop_by_name_with_default (parent, prop_name, 0); -} - -gint -e_xml_get_integer_prop_by_name_with_default (const xmlNode *parent, - const xmlChar *prop_name, - gint def) -{ - xmlChar *prop; - gint ret_val = def; - - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - prop = xmlGetProp ((xmlNode *) parent, prop_name); - if (prop != NULL) { - (void) sscanf (prop, "%d", &ret_val); - xmlFree (prop); - } - return ret_val; -} - -void -e_xml_set_integer_prop_by_name (xmlNode *parent, - const xmlChar *prop_name, - gint value) -{ - gchar *valuestr; - - g_return_if_fail (parent != NULL); - g_return_if_fail (prop_name != NULL); - - valuestr = g_strdup_printf ("%d", value); - xmlSetProp (parent, prop_name, valuestr); - g_free (valuestr); -} - -guint -e_xml_get_uint_prop_by_name (const xmlNode *parent, const xmlChar *prop_name) -{ - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - return e_xml_get_uint_prop_by_name_with_default (parent, prop_name, 0); -} - -guint -e_xml_get_uint_prop_by_name_with_default (const xmlNode *parent, - const xmlChar *prop_name, - guint def) -{ - xmlChar *prop; - guint ret_val = def; - - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - prop = xmlGetProp ((xmlNode *) parent, prop_name); - if (prop != NULL) { - (void) sscanf (prop, "%u", &ret_val); - xmlFree (prop); - } - return ret_val; -} - -void -e_xml_set_uint_prop_by_name (xmlNode *parent, - const xmlChar *prop_name, - guint value) -{ - gchar *valuestr; - - g_return_if_fail (parent != NULL); - g_return_if_fail (prop_name != NULL); - - valuestr = g_strdup_printf ("%u", value); - xmlSetProp (parent, prop_name, valuestr); - g_free (valuestr); -} - -gboolean -e_xml_get_bool_prop_by_name (const xmlNode *parent, - const xmlChar *prop_name) -{ - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - return e_xml_get_bool_prop_by_name_with_default (parent, - prop_name, - FALSE); -} - -gboolean -e_xml_get_bool_prop_by_name_with_default(const xmlNode *parent, - const xmlChar *prop_name, - gboolean def) -{ - xmlChar *prop; - gboolean ret_val = def; - - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - prop = xmlGetProp ((xmlNode *) parent, prop_name); - if (prop != NULL) { - if (g_strcasecmp (prop, "true") == 0) { - ret_val = TRUE; - } else if (g_strcasecmp (prop, "false") == 0) { - ret_val = FALSE; - } - xmlFree(prop); - } - return ret_val; -} - -void -e_xml_set_bool_prop_by_name (xmlNode *parent, const xmlChar *prop_name, gboolean value) -{ - g_return_if_fail (parent != NULL); - g_return_if_fail (prop_name != NULL); - - if (value) { - xmlSetProp (parent, prop_name, "true"); - } else { - xmlSetProp (parent, prop_name, "false"); - } -} - -gdouble -e_xml_get_double_prop_by_name (const xmlNode *parent, const xmlChar *prop_name) -{ - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - return e_xml_get_double_prop_by_name_with_default (parent, prop_name, 0.0); -} - -gdouble -e_xml_get_double_prop_by_name_with_default (const xmlNode *parent, const xmlChar *prop_name, gdouble def) -{ - xmlChar *prop; - gdouble ret_val = def; - - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - prop = xmlGetProp ((xmlNode *) parent, prop_name); - if (prop != NULL) { - ret_val = e_flexible_strtod (prop, NULL); - xmlFree (prop); - } - return ret_val; -} - -void -e_xml_set_double_prop_by_name(xmlNode *parent, const xmlChar *prop_name, gdouble value) -{ - char buffer[E_ASCII_DTOSTR_BUF_SIZE]; - char *format; - - g_return_if_fail (parent != NULL); - g_return_if_fail (prop_name != NULL); - - if (fabs (value) < 1e9 && fabs (value) > 1e-5) { - format = g_strdup_printf ("%%.%df", DBL_DIG); - } else { - format = g_strdup_printf ("%%.%dg", DBL_DIG); - } - e_ascii_dtostr (buffer, sizeof (buffer), format, value); - g_free (format); - - xmlSetProp (parent, prop_name, buffer); -} - -gchar * -e_xml_get_string_prop_by_name (const xmlNode *parent, const xmlChar *prop_name) -{ - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - return e_xml_get_string_prop_by_name_with_default (parent, prop_name, NULL); -} - -gchar * -e_xml_get_string_prop_by_name_with_default (const xmlNode *parent, const xmlChar *prop_name, const gchar *def) -{ - xmlChar *prop; - gchar *ret_val; - - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - prop = xmlGetProp ((xmlNode *) parent, prop_name); - if (prop != NULL) { - ret_val = g_strdup (prop); - xmlFree (prop); - } else { - ret_val = g_strdup (def); - } - return ret_val; -} - -void -e_xml_set_string_prop_by_name (xmlNode *parent, const xmlChar *prop_name, const gchar *value) -{ - g_return_if_fail (parent != NULL); - g_return_if_fail (prop_name != NULL); - - if (value != NULL) { - xmlSetProp (parent, prop_name, value); - } -} - -gchar * -e_xml_get_translated_string_prop_by_name (const xmlNode *parent, const xmlChar *prop_name) -{ - xmlChar *prop; - gchar *ret_val = NULL; - gchar *combined_name; - - g_return_val_if_fail (parent != NULL, 0); - g_return_val_if_fail (prop_name != NULL, 0); - - prop = xmlGetProp ((xmlNode *) parent, prop_name); - if (prop != NULL) { - ret_val = g_strdup (prop); - xmlFree (prop); - return ret_val; - } - - combined_name = g_strdup_printf("_%s", prop_name); - prop = xmlGetProp ((xmlNode *) parent, combined_name); - if (prop != NULL) { - ret_val = g_strdup (gettext(prop)); - xmlFree (prop); - } - g_free(combined_name); - - return ret_val; -} - - -int -e_xml_save_file (const char *filename, xmlDocPtr doc) -{ - char *filesave, *slash, *xmlbuf; - size_t n, written = 0; - int ret, fd, size; - int errnosave; - ssize_t w; - - filesave = alloca (strlen (filename) + 5); - slash = strrchr (filename, '/'); - if (slash) - sprintf (filesave, "%.*s.#%s", slash - filename + 1, filename, slash + 1); - else - sprintf (filesave, ".#%s", filename); - - fd = open (filesave, O_WRONLY | O_CREAT | O_TRUNC, 0600); - if (fd == -1) - return -1; - - xmlDocDumpFormatMemory (doc, (xmlChar **) &xmlbuf, &size, TRUE); - if (size <= 0) { - close (fd); - unlink (filesave); - errno = ENOMEM; - return -1; - } - - n = (size_t) size; - do { - do { - w = write (fd, xmlbuf + written, n - written); - } while (w == -1 && errno == EINTR); - - if (w > 0) - written += w; - } while (w != -1 && written < n); - - xmlFree (xmlbuf); - - if (written < n || fsync (fd) == -1) { - errnosave = errno; - close (fd); - unlink (filesave); - errno = errnosave; - return -1; - } - - while ((ret = close (fd)) == -1 && errno == EINTR) - ; - - if (ret == -1) - return -1; - - if (rename (filesave, filename) == -1) { - errnosave = errno; - unlink (filesave); - errno = errnosave; - return -1; - } - - return 0; -} diff --git a/e-util/e-xml-utils.h b/e-util/e-xml-utils.h deleted file mode 100644 index 6c39ee6f79..0000000000 --- a/e-util/e-xml-utils.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-xml-utils.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library 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_XML_UTILS__ -#define __E_XML_UTILS__ - -#include -#include - -G_BEGIN_DECLS - -xmlNode *e_xml_get_child_by_name (const xmlNode *parent, - const xmlChar *child_name); -/* lang set to NULL means use the current locale. */ -xmlNode *e_xml_get_child_by_name_by_lang (const xmlNode *parent, - const xmlChar *child_name, - const gchar *lang); -/* lang_list set to NULL means use the current locale. */ -xmlNode *e_xml_get_child_by_name_by_lang_list (const xmlNode *parent, - const gchar *name, - const GList *lang_list); -xmlNode *e_xml_get_child_by_name_no_lang (const xmlNode *parent, - const gchar *name); - - -gint e_xml_get_integer_prop_by_name (const xmlNode *parent, - const xmlChar *prop_name); -gint e_xml_get_integer_prop_by_name_with_default (const xmlNode *parent, - const xmlChar *prop_name, - gint def); -void e_xml_set_integer_prop_by_name (xmlNode *parent, - const xmlChar *prop_name, - gint value); - - -guint e_xml_get_uint_prop_by_name (const xmlNode *parent, - const xmlChar *prop_name); -guint e_xml_get_uint_prop_by_name_with_default (const xmlNode *parent, - const xmlChar *prop_name, - guint def); -void e_xml_set_uint_prop_by_name (xmlNode *parent, - const xmlChar *prop_name, - guint value); - - -gboolean e_xml_get_bool_prop_by_name (const xmlNode *parent, - const xmlChar *prop_name); -gboolean e_xml_get_bool_prop_by_name_with_default (const xmlNode *parent, - const xmlChar *prop_name, - gboolean def); -void e_xml_set_bool_prop_by_name (xmlNode *parent, - const xmlChar *prop_name, - gboolean value); - -gdouble e_xml_get_double_prop_by_name (const xmlNode *parent, - const xmlChar *prop_name); -gdouble e_xml_get_double_prop_by_name_with_default (const xmlNode *parent, - const xmlChar *prop_name, - gdouble def); -void e_xml_set_double_prop_by_name ( xmlNode *parent, - const xmlChar *prop_name, - gdouble value); - - -gchar *e_xml_get_string_prop_by_name (const xmlNode *parent, - const xmlChar *prop_name); -gchar *e_xml_get_string_prop_by_name_with_default (const xmlNode *parent, - const xmlChar *prop_name, - const gchar *def); -void e_xml_set_string_prop_by_name (xmlNode *parent, - const xmlChar *prop_name, - const gchar *value); - -gchar *e_xml_get_translated_string_prop_by_name (const xmlNode *parent, - const xmlChar *prop_name); - -int e_xml_save_file (const char *filename, xmlDocPtr doc); - -G_END_DECLS - -#endif /* __E_XML_UTILS__ */ -- cgit v1.2.3