diff options
author | Don Scorgie <dscorgie@src.gnome.org> | 2006-06-11 18:38:27 +0000 |
---|---|---|
committer | Don Scorgie <dscorgie@src.gnome.org> | 2006-06-11 18:38:27 +0000 |
commit | cbb7f3723a7b05e63e58f3a845114a770fcf53f9 (patch) | |
tree | 92e9f32a9fe2e82ae5b6360ce5f2681e39395185 | |
parent | aea5295d653f9ea5574da5f7feffb42d51edaa2c (diff) | |
download | yelp-cbb7f3723a7b05e63e58f3a845114a770fcf53f9.tar.gz |
Move from bonobo activation to dbus activation Add {-p,--private-session}
* src/yelp-main.c:
* src/yelp-infos.xml:
* src/yelp-base.h:
* src/yelp-base.c:
* src/Makefile.am:
* Makefile.am:
* configure.in:
Move from bonobo activation to dbus activation
Add {-p,--private-session} flag to stop from activating
If dbus isn't running, fallback to private session
Bug #337540
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | configure.in | 6 | ||||
-rw-r--r-- | src/Makefile.am | 40 | ||||
-rw-r--r-- | src/yelp-base.c | 178 | ||||
-rw-r--r-- | src/yelp-base.h | 19 | ||||
-rw-r--r-- | src/yelp-infos.xml | 15 | ||||
-rw-r--r-- | src/yelp-main.c | 291 |
8 files changed, 295 insertions, 267 deletions
@@ -1,5 +1,17 @@ 2006-06-11 Don Scorgie <dscorgie@cvs.gnome.org> + * src/yelp-main.c: + * src/yelp-infos.xml: + * src/yelp-base.h: + * src/yelp-base.c: + * src/Makefile.am: + * Makefile.am: + * configure.in: + Move from bonobo activation to dbus activation + Add {-p,--private-session} flag to stop from activating + If dbus isn't running, fallback to private session + Bug #337540 + * data/toc.xml.in: Change 'Multimedia' category to 'Sound & Vision' for consistancy (bug #332182) diff --git a/Makefile.am b/Makefile.am index 36374bad..9d410cfc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,6 @@ EXTRA_DIST = \ intltool-extract.in \ intltool-merge.in \ intltool-update.in \ - idl/GNOME_Yelp.idl \ important_docs.xml \ $(desktop_in_files) diff --git a/configure.in b/configure.in index b31bed7b..9d04068b 100644 --- a/configure.in +++ b/configure.in @@ -23,7 +23,6 @@ AM_PROG_CC_STDC AC_ISC_POSIX AC_HEADER_STDC AM_PROG_LIBTOOL -AM_PATH_ORBIT2 AM_PATH_GLIB_2_0 GNOME_DEBUG_CHECK @@ -72,7 +71,6 @@ PKG_CHECK_MODULES(YELP, libgnomeprintui-2.2 gnome-vfs-2.0 >= 1.1 gtk+-2.0 >= 2.5.3 - libbonobo-2.0 >= 1.108.0 libglade-2.0 >= 2.0.0 libgnome-2.0 >= 2.0.2 libgnomeui-2.0 >= 1.103.0 @@ -80,16 +78,14 @@ PKG_CHECK_MODULES(YELP, libxslt >= 1.1.4 libexslt >= 0.8.1 libstartup-notification-1.0 >= 0.8 + dbus-glib-1 ]) AC_SUBST([YELP_CFLAGS]) AC_SUBST([YELP_LIBS]) YELP_MODULES="gnome-vfs-2.0 libgnomeui-2.0 libbonobo-2.0" -idl_dirs="`$PKG_CONFIG --variable=idldir gnome-vfs-2.0 libgnomeui-2.0 libbonobo-2.0 bonobo-activation-2.0`" AC_PATH_PROGS(SED, gsed sed) -YELP_IDL_INCLUDES="`echo ${idl_dirs} | ${SED} -e 's/^/ /' -e 's/ *$//' -e 's/ */ -I /g' -e 's/^ *//'`" -AC_SUBST(YELP_IDL_INCLUDES) XSLT_PATH="`$PKG_CONFIG --variable=xsltdir gnome-doc-utils`" DB_TITLE="$XSLT_PATH""/docbook/common/db-title.xsl" diff --git a/src/Makefile.am b/src/Makefile.am index 7a3c7be4..eea724d3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,8 +1,5 @@ bin_PROGRAMS = yelp -nodist_yelp_SOURCES = \ - $(gnome_yelp_idl_sources) - yelp_SOURCES = \ Yelper.cpp Yelper.h \ yelp-base.c yelp-base.h \ @@ -166,16 +163,22 @@ test_uri_LDADD = $(YELP_LIBS) test_uri_LDFLAGS = $(AM_LDFLAGS) -serverdir = $(libdir)/bonobo/servers -server_in_files = GNOME_Yelp.server.in -server_DATA = $(server_in_files:.server.in=.server) - @INTLTOOL_SERVER_RULE@ -BUILT_SOURCES = yelp-marshal.h yelp-marshal.c $(gnome_yelp_idl_sources) +BUILT_SOURCES = yelp-marshal.h yelp-marshal.c server-bindings.h \ + client-bindings.h + +noinst_HEADERS = $(BUILT_SOURCES) + +server-bindings.h: yelp-infos.xml + dbus-binding-tool --prefix=server_object --mode=glib-server $< > $@ + +client-bindings.h: yelp-infos.xml + dbus-binding-tool --prefix=server_object --mode=glib-client $< > $@ yelp-marshal.h: stamp-yelp-marshal.h @true + stamp-yelp-marshal.h: yelp-marshal.list @GLIB_GENMARSHAL@ --prefix=yelp_marshal $(srcdir)/yelp-marshal.list --header > xgen-ymh \ && (cmp -s xgen-ymh yelp-marshal.h || cp xgen-ymh yelp-marshal.h) \ @@ -189,26 +192,11 @@ yelp-marshal.c: yelp-marshal.list yelp-marshal-main.c: yelp-marshal.c -gnome_yelp_idl_sources = \ - GNOME_Yelp-stubs.c \ - GNOME_Yelp-skels.c \ - GNOME_Yelp-common.c \ - GNOME_Yelp.h - -$(gnome_yelp_idl_sources): $(top_srcdir)/idl/GNOME_Yelp.idl $(ORBIT_IDL) - $(ORBIT_IDL) $(YELP_IDL_INCLUDES) -I$(top_srcdir) $< - -CLEANFILES = \ - $(gnome_yelp_idl_sources) \ - gnome_yelp_idl_stamp \ - GNOME_Yelp.server \ - xgen-ymh xgen-ymc +CLEANFILES = xgen-ymh xgen-ymc -MAINTAINERCLEANFILES = stamp-yelp-marshal.h $(BUILT_SOURCES) +MAINTAINERCLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = \ - yelp-marshal.list \ - $(server_in_files) +EXTRA_DIST = yelp-marshal.list install-exec-local: rm -f $(DESTDIR)$(bindir)/gnome-help && \ diff --git a/src/yelp-base.c b/src/yelp-base.c index 5922cf84..6761e969 100644 --- a/src/yelp-base.c +++ b/src/yelp-base.c @@ -22,7 +22,7 @@ #include <config.h> -#include <bonobo/bonobo-main.h> +#include <dbus/dbus-glib-bindings.h> #include <libgnomevfs/gnome-vfs.h> #include <gdk/gdkx.h> #define SN_API_NOT_YET_FROZEN @@ -36,6 +36,7 @@ #include "yelp-toc-pager.h" #include "yelp-base.h" #include "yelp-bookmarks.h" +#include "server-bindings.h" gboolean main_running; @@ -43,6 +44,7 @@ gboolean main_running; struct _YelpBasePriv { GNode *toc_tree; + gboolean private_session; GList *index; GSList *windows; @@ -50,6 +52,7 @@ struct _YelpBasePriv { static void yelp_base_init (YelpBase *base); static void yelp_base_class_init (YelpBaseClass *klass); +static void yelp_base_register_dbus (YelpBase *base); static void yelp_base_new_window_cb (YelpWindow *window, const gchar *uri, YelpBase *base); @@ -57,52 +60,33 @@ static void yelp_base_window_finalized_cb (YelpBase *base, YelpWindow *window); -#define PARENT_TYPE BONOBO_OBJECT_TYPE -static BonoboObjectClass *parent_class; +#define PARENT_TYPE G_TYPE_OBJECT +static GObjectClass *parent_class; -static void -impl_Yelp_newWindow (PortableServer_Servant servant, - const CORBA_char *url, - const CORBA_char *time, - CORBA_Environment *ev) +GType +yelp_base_get_type (void) { - YelpBase *yelp_base; - - yelp_base = YELP_BASE (bonobo_object (servant)); - yelp_base_new_window (yelp_base, url, time); -} - -static GNOME_Yelp_WindowList * -impl_Yelp_getWindows (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - YelpBase *base; - YelpBasePriv *priv; - GNOME_Yelp_WindowList *list; - gint len, i; - GSList *node; - YelpDocInfo *doc_info; - gchar *uri; - - base = YELP_BASE (bonobo_object (servant)); - priv = base->priv; - - len = g_slist_length (priv->windows); - - list = GNOME_Yelp_WindowList__alloc (); - list->_buffer = CORBA_sequence_CORBA_string_allocbuf (len); - list->_length = len; - list->_maximum = len; - CORBA_sequence_set_release (list, CORBA_TRUE); - - for (node = priv->windows, i = 0; node; node = node->next, i++) { - doc_info = yelp_window_get_doc_info (YELP_WINDOW (node->data)); - uri = yelp_doc_info_get_uri (doc_info, NULL, YELP_URI_TYPE_ANY); - list->_buffer[i] = CORBA_string_dup (uri); - g_free (uri); - } - - return list; + static GType base_type = 0; + + if (!base_type) { + static const GTypeInfo base_info = { + sizeof (YelpBaseClass), + NULL, + NULL, + (GClassInitFunc) yelp_base_class_init, + NULL, + NULL, + sizeof (YelpBase), + 0, + (GInstanceInitFunc) yelp_base_init, + }; + + base_type = g_type_register_static (G_TYPE_OBJECT, + "YelpBase", + &base_info, 0); + } + + return base_type; } static void @@ -111,7 +95,6 @@ yelp_base_init (YelpBase *base) YelpBasePriv *priv; base->priv = priv = YELP_BASE_GET_PRIVATE (base); - priv->toc_tree = g_node_new (NULL); priv->index = NULL; priv->windows = NULL; @@ -123,20 +106,62 @@ yelp_base_init (YelpBase *base) static void yelp_base_class_init (YelpBaseClass *klass) { - POA_GNOME_Yelp__epv *epv = &klass->epv; - parent_class = gtk_type_class (PARENT_TYPE); - epv->newWindow = impl_Yelp_newWindow; - epv->getWindows = impl_Yelp_getWindows; - main_running = TRUE; g_type_class_add_private (klass, sizeof (YelpBasePriv)); } +gboolean +server_new_window (YelpBase *base, gchar *url, gchar *timestamp, + GError **error) +{ + GtkWidget *new_window; + + new_window = yelp_base_new_window (base, url, timestamp); + gtk_widget_show (new_window); + return TRUE; +} + +gboolean +server_get_url_list (YelpBase *server, gchar **urls, GError **error) +{ + gint len, i; + GSList *node; + YelpDocInfo *doc_info; + gchar *uri; + YelpBasePriv *priv; + + priv = server->priv; + + len = g_slist_length (priv->windows); + + node = priv->windows; + + doc_info = yelp_window_get_doc_info (YELP_WINDOW (node->data)); + uri = yelp_doc_info_get_uri (doc_info, NULL, + YELP_URI_TYPE_ANY); + *urls = g_strdup (uri); + g_free (uri); + node = node->next; + + for (i = 0; node; node = node->next, i++) { + gchar *list; + doc_info = yelp_window_get_doc_info (YELP_WINDOW (node->data)); + uri = yelp_doc_info_get_uri (doc_info, NULL, + YELP_URI_TYPE_ANY); + list = g_strconcat (*urls, ";", uri, NULL); + g_free (*urls); + *urls = g_strdup (list); + g_free (list); + g_free (uri); + } + return TRUE; +} + static void -yelp_base_new_window_cb (YelpWindow *window, const gchar *uri, +yelp_base_new_window_cb (YelpWindow *window, const gchar *uri, YelpBase *base) { GtkWidget *new_window; @@ -162,17 +187,19 @@ yelp_base_window_finalized_cb (YelpBase *base, YelpWindow *window) if (g_slist_length (priv->windows) == 0) { main_running = FALSE; - bonobo_main_quit (); + gtk_main_quit (); } } YelpBase * -yelp_base_new (void) +yelp_base_new (gboolean priv) { YelpBase *base; base = g_object_new (YELP_TYPE_BASE, NULL); - + if (!priv) + yelp_base_register_dbus (base); + base->priv->private_session = priv; yelp_toc_pager_init (); return base; @@ -258,4 +285,43 @@ yelp_base_new_window (YelpBase *base, const gchar *uri, const gchar *startup_id) return window; } -BONOBO_TYPE_FUNC_FULL (YelpBase, GNOME_Yelp, PARENT_TYPE, yelp_base) +static void +yelp_base_register_dbus (YelpBase *base) +{ + GError *error = NULL; + DBusGProxy *driver_proxy; + YelpBaseClass *klass = YELP_BASE_GET_CLASS (base); + guint request_ret; + YelpBasePriv *priv; + + priv = base->priv; + + klass->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (klass->connection == NULL) { + g_warning("Unable to connect to dbus: %s", error->message); + g_error_free (error); + return; + } + + dbus_g_object_type_install_info (YELP_TYPE_BASE, + &dbus_glib_server_object_object_info); + + dbus_g_connection_register_g_object (klass->connection, + "/org/gnome/YelpService", + G_OBJECT (base)); + + driver_proxy = dbus_g_proxy_new_for_name (klass->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + if(!org_freedesktop_DBus_request_name (driver_proxy, + "org.gnome.YelpService", + 0, &request_ret, + &error)) { + g_warning("Unable to register service: %s", error->message); + g_error_free (error); + } + g_object_unref (driver_proxy); + +} diff --git a/src/yelp-base.h b/src/yelp-base.h index 091b88a3..e5ac0e7c 100644 --- a/src/yelp-base.h +++ b/src/yelp-base.h @@ -23,8 +23,8 @@ #ifndef __YELP_BASE_H__ #define __YELP_BASE_H__ -#include <bonobo/bonobo-object.h> -#include "GNOME_Yelp.h" +#include <dbus/dbus-glib.h> + typedef struct _YelpBase YelpBase; typedef struct _YelpBaseClass YelpBaseClass; @@ -39,22 +39,29 @@ typedef struct _YelpBasePriv YelpBasePriv; struct _YelpBase { - BonoboObject parent; + GObject parent; YelpBasePriv *priv; }; struct _YelpBaseClass { - BonoboObjectClass parent_class; + GObjectClass parent_class; - POA_GNOME_Yelp__epv epv; + DBusGConnection *connection; }; GType yelp_base_get_type (void); -YelpBase * yelp_base_new (void); +YelpBase * yelp_base_new (gboolean priv); GtkWidget * yelp_base_new_window (YelpBase *base, const gchar *uri, const gchar *timestamp); +gboolean server_new_window (YelpBase *server, + gchar *url, + gchar *timestamp, + GError **error); +gboolean server_get_url_list (YelpBase *server, + gchar **urls, + GError **error); #endif /* __YELP_BASE_H__ */ diff --git a/src/yelp-infos.xml b/src/yelp-infos.xml new file mode 100644 index 00000000..18462b61 --- /dev/null +++ b/src/yelp-infos.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<node name="/org/gnome/YelpService"> + <interface name="org.gnome.YelpService"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="server"/> + <method name="new_window"> + <arg type="s" name="url" direction="in" /> + <arg type="s" name="timestamp" direction="in" /> + </method> + <method name="get_url_list"> + <arg type="s" name="urls" direction="out" /> + </method> + <!-- Add more methods/signals if you want --> + </interface> +</node> diff --git a/src/yelp-main.c b/src/yelp-main.c index 522cca90..c9ae09dc 100644 --- a/src/yelp-main.c +++ b/src/yelp-main.c @@ -28,28 +28,26 @@ #include <gtk/gtkmain.h> #include <gtk/gtkwidget.h> #include <gdk/gdkx.h> -#include <bonobo/bonobo-context.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-main.h> #include <libgnome/gnome-program.h> #include <libgnomeui/gnome-ui-init.h> #include <libgnomevfs/gnome-vfs.h> #include <libgnomeui/gnome-client.h> +#include <dbus/dbus-glib-bindings.h> #include <string.h> #include <stdlib.h> -#include "GNOME_Yelp.h" +#include "client-bindings.h" #include "yelp-window.h" #include "yelp-base.h" #include "yelp-html.h" -#define YELP_FACTORY_OAFIID "OAFIID:GNOME_Yelp_Factory" - static gchar *cache_dir; static gchar *open_urls; static gchar *startup_id; static gchar **files; +static gboolean private = FALSE; + +static DBusGConnection *connection; /*structure defining command line option.*/ enum { @@ -57,14 +55,10 @@ enum { OPTION_CACHE_DIR }; -static BonoboObject * main_base_factory (BonoboGenericFactory *factory, - const gchar *iid, - gpointer closure); -static CORBA_Object main_activate_base (void); -static void main_open_new_window (CORBA_Object yelp_base, - const gchar *url); -static void main_start (gchar *url); -static gboolean main_idle_start (gchar *url); +static void main_start (const gchar *url); +static DBusGProxy * main_dbus_get_proxy (void); +static gboolean main_is_running (void); +static gboolean main_slave_start (gchar *url); static int main_save_session (GnomeClient *client, gint phase, GnomeRestartStyle rstyle, @@ -90,6 +84,14 @@ static const GOptionEntry options[] = { NULL, NULL, }, { + "private-session", + 'p', + 0, G_OPTION_ARG_NONE, + &private, + N_("Use a private session"), + NULL, + }, + { "with-cache-dir", '\0', 0, @@ -104,102 +106,36 @@ static const GOptionEntry options[] = { { NULL} }; -static BonoboObject * -main_base_factory (BonoboGenericFactory *factory, - const gchar *iid, - gpointer closure) +static void +main_start (const gchar *url) { - static YelpBase *yelp_base = NULL; + YelpBase *base; + GError *error = NULL; - if (!yelp_base) { - yelp_base = yelp_base_new (); - } else { - bonobo_object_ref (BONOBO_OBJECT (yelp_base)); - } - - return BONOBO_OBJECT (yelp_base); -} - -static CORBA_Object -main_activate_base (void) -{ - CORBA_Environment ev; - CORBA_Object yelp_base; + base = yelp_base_new (private); + server_new_window (base, (gchar *) url, startup_id, &error); - CORBA_exception_init (&ev); + gtk_main (); - yelp_base = bonobo_activation_activate_from_id ("OAFIID:GNOME_Yelp", - 0, NULL, &ev); - - if (BONOBO_EX (&ev) || yelp_base == CORBA_OBJECT_NIL) { - g_error (_("Could not activate Yelp: '%s'"), - bonobo_exception_get_text (&ev)); - } - - CORBA_exception_free (&ev); - - return yelp_base; + return; } -static void -main_open_new_window (CORBA_Object yelp_base, const gchar *url) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - GNOME_Yelp_newWindow (yelp_base, url, startup_id, &ev); - - if (BONOBO_EX (&ev)) { - g_error (_("Could not open new window.")); - } - - g_free (startup_id); - CORBA_exception_free (&ev); -} -static void -main_start (gchar *url) -{ - CORBA_Object yelp_base; - gchar *new_url; - - new_url = gnome_vfs_make_uri_from_input_with_dirs (url, - GNOME_VFS_MAKE_URI_DIR_CURRENT); - - yelp_base = main_activate_base (); - - if (!yelp_base) { - g_error ("Couldn't activate YelpBase"); - } - - main_open_new_window (yelp_base, new_url); - gdk_notify_startup_complete (); - - bonobo_object_release_unref (yelp_base, NULL); - - if (url) { - g_free (url); - } -} - static gboolean -main_idle_start (gchar *url) +main_slave_start (gchar *url) { - CORBA_Object yelp_base; - - yelp_base = main_activate_base (); + DBusGProxy *proxy = NULL; + GError *error = NULL; - if (!yelp_base) { - g_error ("Couldn't activate YelpBase"); - } + proxy = main_dbus_get_proxy (); - main_open_new_window (yelp_base, url); + if (!proxy) + g_error ("Cannot connect to dbus\n"); + + if (!org_gnome_YelpService_new_window (proxy, url, startup_id, + &error)) + g_error ("%s\n", error->message); - if (url) { - g_free (url); - } - return FALSE; } @@ -213,32 +149,32 @@ main_save_session (GnomeClient *client, gint fast, gpointer cdata) { - - GNOME_Yelp_WindowList *list; - CORBA_Environment ev; - CORBA_Object yelp_base; gchar **argv; + gchar *open_windows = NULL; gint i=1; gint arg_len = 1; gboolean store_open_urls = FALSE; + DBusGProxy *proxy = NULL; + GError *error = NULL; - CORBA_exception_init (&ev); - - yelp_base = main_activate_base (); + proxy = main_dbus_get_proxy (); + if (!proxy) + g_error ("Unable to connect to bus again\n"); - list = GNOME_Yelp_getWindows (yelp_base, &ev); - bonobo_object_release_unref (yelp_base, NULL); + if (!org_gnome_YelpService_get_url_list (proxy, &open_windows, + &error)) + g_error ("Cannot recieve window list - %s\n", error->message); - if (cache_dir) { + if (open_windows != NULL) { + store_open_urls = TRUE; arg_len++; } - if (list->_length > 0) { - store_open_urls = TRUE; + if (cache_dir) { arg_len++; } - + argv = g_malloc0 (sizeof (gchar *) * arg_len); /* Program name */ @@ -250,21 +186,8 @@ main_save_session (GnomeClient *client, } if (store_open_urls) { - gchar *urls; - - /* Get the URI of each window */ - urls = g_strdup_printf ("--open-urls=\"%s", list->_buffer[0]); - - for (i=1; i < list->_length; i++) { - gchar *tmp; - - tmp = g_strconcat (urls, ";", list->_buffer[i], NULL); - g_free (urls); - urls = tmp; - } - - argv[arg_len - 1] = g_strconcat (urls, "\"", NULL); - g_free (urls); + argv[arg_len - 1] = g_strdup_printf ("--open-urls=\"%s\"", + open_windows); } gnome_client_set_clone_command (client, arg_len, argv); @@ -272,8 +195,7 @@ main_save_session (GnomeClient *client, for (i = 0; i < arg_len; ++i) { g_free (argv[i]); - } - + } g_free (argv); return TRUE; @@ -283,35 +205,38 @@ static void main_client_die (GnomeClient *client, gpointer cdata) { - bonobo_main_quit (); + gtk_main_quit (); } static gboolean main_restore_session (void) { - CORBA_Object yelp_base; + YelpBase *yelp_base; - yelp_base = main_activate_base (); + yelp_base = yelp_base_new (private); if (!yelp_base) { g_error ("Couldn't activate YelpBase"); } - + g_print ("restoring session\n"); if (open_urls) { gchar **urls = g_strsplit_set (open_urls, ";\"", -1); gchar *url; gint i = 0; - + GError *error = NULL; + while ((url = urls[i]) != NULL) { if (*url != '\0') - main_open_new_window (yelp_base, url); + server_new_window (yelp_base, url, + startup_id, &error); ++i; } g_strfreev (urls); } - + gtk_main (); return FALSE; + } /* Copied from libnautilus/nautilus-program-choosing.c; Needed in case @@ -365,11 +290,49 @@ slowly_and_stupidly_obtain_timestamp (Display *xdisplay) return event.xproperty.time; } +DBusGProxy * +main_dbus_get_proxy (void) +{ + if (!connection) + return NULL; + + return dbus_g_proxy_new_for_name (connection, + "org.gnome.YelpService", + "/org/gnome/YelpService", + "org.gnome.YelpService"); +} + +gboolean +main_is_running (void) +{ + DBusGProxy *proxy = NULL; + gboolean instance = TRUE; + GError * error = NULL; + + if (!connection) + return TRUE; + + proxy = dbus_g_proxy_new_for_name (connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + if (!dbus_g_proxy_call (proxy, "NameHasOwner", &error, + G_TYPE_STRING, "org.gnome.YelpService", + G_TYPE_INVALID, + G_TYPE_BOOLEAN, &instance, + G_TYPE_INVALID)) { + g_error ("Cannot connect to DBus - %s\n", error->message); + exit (2); + } + return instance; +} + + int main (int argc, char **argv) { GnomeProgram *program; - CORBA_Object factory; gchar *url = NULL; GnomeClient *client; gboolean session_started = FALSE; @@ -407,17 +370,18 @@ main (int argc, char **argv) g_set_application_name (_("Help")); gtk_window_set_default_icon_name ("gnome-help"); - /* Need to set this to the canonical DISPLAY value, since - that's where we're registering per-display components */ - bonobo_activation_set_activation_env_value - ("DISPLAY", - gdk_display_get_name (gdk_display_get_default ()) ); - gnome_vfs_init (); + if (!private) { + connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL); + if (!connection) { + g_warning ("Cannot find dbus bus\n"); + private = TRUE; + } + } + if (!yelp_html_initialize ()) { - g_print ("Could not initialize gecko!"); - exit (2); + g_error ("Could not initialize gecko!"); } if (files != NULL && files[0] != NULL) { @@ -431,50 +395,31 @@ main (int argc, char **argv) g_signal_connect (client, "die", G_CALLBACK (main_client_die), NULL); - factory = bonobo_activation_activate_from_id (YELP_FACTORY_OAFIID, - Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, - NULL, NULL); - /* Check for previous session to restore. */ if (gnome_client_get_flags (client) & GNOME_CLIENT_RESTORED) { session_started = TRUE; } - if (!factory) { /* Not started, start now */ - BonoboGenericFactory *factory; - char *registration_id; + if (private || !main_is_running ()) { const gchar *env; /* workaround for bug #329461 */ env = g_getenv ("MOZ_ENABLE_PANGO"); - + if (env == NULL || *env == '\0' || g_str_equal(env, "0")) - { - g_setenv ("MOZ_DISABLE_PANGO", "1", TRUE); - } - - registration_id = bonobo_activation_make_registration_id ( - YELP_FACTORY_OAFIID, - gdk_display_get_name (gdk_display_get_default ())); - factory = bonobo_generic_factory_new (registration_id, - main_base_factory, - NULL); - g_free (registration_id); - - bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory)); - - /* If started by session, restore from last session */ + { + g_setenv ("MOZ_DISABLE_PANGO", "1", TRUE); + } + if (session_started) { - g_idle_add ((GSourceFunc) main_restore_session, NULL); + main_restore_session (); } else { - g_idle_add ((GSourceFunc) main_idle_start, url); + main_start (url); } - - bonobo_main (); } else { - main_start (url); + main_slave_start (url); } yelp_html_shutdown (); |