diff options
author | Robey Pointer <robey@src.gnome.org> | 2000-12-19 00:14:29 +0000 |
---|---|---|
committer | Robey Pointer <robey@src.gnome.org> | 2000-12-19 00:14:29 +0000 |
commit | 7b17c8c881234c34fbc5d0dcb596c0573cdcf85c (patch) | |
tree | 5226f04a5bad2d8bfeddbb3adab06cec5f0f4f25 /components/services/trilobite | |
parent | 108a853366329d814594f97085b4446fef62b1d3 (diff) | |
download | nautilus-7b17c8c881234c34fbc5d0dcb596c0573cdcf85c.tar.gz |
Clean up trilobite_init to not use or require X anymore (yay!). Add a
* components/services/trilobite/libtrilobite/trilobite-core-utils.c
: (trilobite_get_popt_context), (trilobite_init), (trilobite_main),
(trilobite_main_quit):
* components/services/trilobite/libtrilobite/trilobite-core-utils.h
:
Clean up trilobite_init to not use or require X anymore (yay!).
Add a trilobite_main and trilobite_main_quit to mirror the GTK
versions (but without polling for X events). Add a way for
services to retreive their popt context for command-line argument
processing.
* components/services/install/command-line/eazel-alt-install-corba.
c: (done), (main):
* components/services/install/server/main.c:
(trilobite_service_factory_destroy), (main):
* components/services/time/service/main.c:
(trilobite_service_factory_destroy), (main):
* components/services/trilobite/sample/service/main.c:
(trilobite_service_factory_destroy), (main):
Make the command-line utilities use trilobite_main() and
trilobite_main_quit() instead of the GTK variants.
* components/services/install/lib/eazel-install-xml-package-list.c:
(generate_xml_package_list), (osd_parse_dependency):
Stop filling in the soft_depends field from XML. (The old code
that uses soft_depends doesn't expect it to be filled in and will
get confused, and this field is going away shortly anyway.)
* components/services/install/nautilus-view/main.c: (main):
* components/services/time/nautilus-view/main.c: (main):
Don't make the nautilus-views use trilobite_* functions (that
would be bad), but clean them up to look similar to each other so
it's easy to see how to copy them and make new trilobites.
Diffstat (limited to 'components/services/trilobite')
3 files changed, 61 insertions, 11 deletions
diff --git a/components/services/trilobite/libtrilobite/trilobite-core-utils.c b/components/services/trilobite/libtrilobite/trilobite-core-utils.c index ee0d15c50..74fb6822a 100644 --- a/components/services/trilobite/libtrilobite/trilobite-core-utils.c +++ b/components/services/trilobite/libtrilobite/trilobite-core-utils.c @@ -146,16 +146,27 @@ close_and_give_up: #ifndef TRILOBITE_SLIM -/* trilobite_init -- does all the init stuff - * FIXME bugzilla.eazel.com 1656: - * for now, this requires init_gnome, and thus a running X server. - * initializes OAF and bonobo, too. +#undef TRILOBITE_USE_X +static poptContext trilobite_popt; + +poptContext +trilobite_get_popt_context (void) +{ + return trilobite_popt; +} + +/* trilobite_init * - * service_name should be your G_LOG_DOMAIN, if you set one, because of the way logging works - * - * options is a way to add extra parameters in the future (can be NULL for now). + * This does all of the initialization needed for command-line utilities or + * background CORBA services: The GTK type & signal system is initialized, + * along with OAF and bonobo and all their friends. If you specify a logfile, + * logging begins (service_name should be your G_LOG_DOMAIN). * - * returns FALSE if init fails. + * This initialization does not start any X services! It's meant to be used + * by processes that won't talk to an X server -- use normal GNOME init + * functions if you will be using X or doing any GUI stuff. + * + * Returns FALSE if init fails, TRUE on success. */ gboolean trilobite_init (const char *service_name, const char *version_name, const char *log_filename, @@ -167,12 +178,13 @@ trilobite_init (const char *service_name, const char *version_name, const char * #ifdef TRILOBITE_USE_X gnome_init_with_popt_table (service_name, version_name, argc, argv, oaf_popt_options, 0, NULL); + trilobite_popt = NULL; #else gtk_type_init (); gtk_signal_init (); gnomelib_init (service_name, version_name); gnomelib_register_popt_table (oaf_popt_options, service_name); - gnomelib_parse_args (argc, argv, 0); + trilobite_popt = gnomelib_parse_args (argc, argv, 0); #endif orb = oaf_init (argc, argv); @@ -202,6 +214,40 @@ trilobite_init (const char *service_name, const char *version_name, const char * fail: return FALSE; } + +static GList *loop_list = NULL; + +/* if you want to be able to run without X, you should use trilobite_main and + * trilobite_main_quit instead of the gtk_* varieties. + * + * if you use bonobo_main, you can substitute the sequence of calls + * { bonobo_activate; trilobite_main; } + * and get the same effect. this is an attempt to remove the X requirements + * from trilobite services and command-line utilities. + */ +void +trilobite_main (void) +{ + GMainLoop *loop; + + loop = g_main_new (TRUE); + loop_list = g_list_prepend (loop_list, loop); + if (g_main_is_running (loop)) { + g_main_run (loop); + } + loop_list = g_list_remove (loop_list, loop); + + g_main_destroy (loop); +} + +void +trilobite_main_quit (void) +{ + if (loop_list != NULL) { + g_main_quit ((GMainLoop *)(loop_list->data)); + loop_list = g_list_remove (loop_list, loop_list->data); + } +} #endif /* TRILOBITE_SLIM */ const char * diff --git a/components/services/trilobite/libtrilobite/trilobite-core-utils.h b/components/services/trilobite/libtrilobite/trilobite-core-utils.h index 4ec76b883..75fe276e1 100644 --- a/components/services/trilobite/libtrilobite/trilobite-core-utils.h +++ b/components/services/trilobite/libtrilobite/trilobite-core-utils.h @@ -34,6 +34,7 @@ #include <stdio.h> #include <glib.h> #ifndef TRILOBITE_SLIM +#include <popt.h> #include <bonobo.h> #endif @@ -54,6 +55,9 @@ gboolean trilobite_init (const char *service_name, const char *log_filename, int argc, char **argv); +poptContext trilobite_get_popt_context (void); +void trilobite_main (void); +void trilobite_main_quit (void); #endif /* TRILOBITE_SLIM */ const char *trilobite_get_useragent_string (gboolean version, diff --git a/components/services/trilobite/sample/service/main.c b/components/services/trilobite/sample/service/main.c index 8e67b4f74..aea54d425 100644 --- a/components/services/trilobite/sample/service/main.c +++ b/components/services/trilobite/sample/service/main.c @@ -59,7 +59,7 @@ trilobite_service_factory_destroy (GtkObject *object) bonobo_object_unref (BONOBO_OBJECT (factory)); trilobite_passwordquery_destroy (GTK_OBJECT (trilobite_password)); - gtk_main_quit (); + trilobite_main_quit (); g_message ("out factory_destroy"); } @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) { g_message ("%s ready", argv[0]); do { - bonobo_main (); + trilobite_main (); } while (trilobites_active > 0); g_message ("%s quitting", argv[0]); |