Make the settings daemon a singleton BonoboObject so capplets can detect

2002-03-10  Seth Nickell  <snickell@stanford.edu>

        Make the settings daemon a singleton BonoboObject so capplets
	can detect whether its running and activate it if its not.

	* Makefile.am:
	* factory.c: (main):
	* gnome-settings-daemon.c: (awake_impl), (finalize),
	(gnome_settings_daemon_class_init), (gnome_settings_daemon_init),
	(gnome_settings_daemon_new):
	* gnome-settings-daemon.h:

	Convert the settings-daemon into a BonoboObject and add code to
	register it with bonobo-activation. Still has a main loop that can
	be run normally to launch the settings daemon.
This commit is contained in:
Seth Nickell 2002-03-11 01:44:03 +00:00 committed by Seth Nickell
parent fb94a4c2de
commit 3831d63e77
5 changed files with 192 additions and 21 deletions

View file

@ -1,3 +1,19 @@
2002-03-10 Seth Nickell <snickell@stanford.edu>
Make the settings daemon a singleton BonoboObject so capplets
can detect whether its running and activate it if its not.
* Makefile.am:
* factory.c: (main):
* gnome-settings-daemon.c: (awake_impl), (finalize),
(gnome_settings_daemon_class_init), (gnome_settings_daemon_init),
(gnome_settings_daemon_new):
* gnome-settings-daemon.h:
Convert the settings-daemon into a BonoboObject and add code to
register it with bonobo-activation. Still has a main loop that can
be run normally to launch the settings daemon.
2002-03-06 Miles Lane <miles@megapathdsl.net> 2002-03-06 Miles Lane <miles@megapathdsl.net>
* gnome-settings-daemon.c -- Correct the gnome_program_init() * gnome-settings-daemon.c -- Correct the gnome_program_init()

View file

@ -3,6 +3,7 @@ INCLUDES=$(GNOME_SETTINGS_DAEMON_CFLAGS) -I$(top_srcdir)/libbackground -I$(top_s
bin_PROGRAMS=gnome2-settings-daemon bin_PROGRAMS=gnome2-settings-daemon
gnome2_settings_daemon_SOURCES = \ gnome2_settings_daemon_SOURCES = \
factory.c \
gnome-settings-daemon.h \ gnome-settings-daemon.h \
gnome-settings-daemon.c \ gnome-settings-daemon.c \
gnome-settings-mouse.h \ gnome-settings-mouse.h \
@ -22,7 +23,8 @@ gnome2_settings_daemon_SOURCES = \
xsettings-common.c \ xsettings-common.c \
xsettings-manager.c \ xsettings-manager.c \
xsettings-common.h \ xsettings-common.h \
xsettings-manager.h xsettings-manager.h \
$(CORBA_GENERATED)
gnome2_settings_daemon_LDADD = \ gnome2_settings_daemon_LDADD = \
$(GNOME_SETTINGS_DAEMON_LIBS) \ $(GNOME_SETTINGS_DAEMON_LIBS) \
@ -30,6 +32,34 @@ gnome2_settings_daemon_LDADD = \
$(top_builddir)/libsounds/libsounds.a \ $(top_builddir)/libsounds/libsounds.a \
$(XF86MISC_LIBS) $(XF86MISC_LIBS)
CORBA_GENERATED_HEADER_FILES = GNOME_SettingsDaemon.h
CORBA_GENERATED = \
$(CORBA_GENERATED_HEADER_FILES) \
GNOME_SettingsDaemon-common.c \
GNOME_SettingsDaemon-stubs.c \
GNOME_SettingsDaemon-skels.c
BUILT_SOURCES=$(CORBA_GENERATED)
idl_dir = $(top_srcdir)/idl
IDL_FLAGS = -D__GNOME_SettingsDaemon_COMPILATION -I $(idl_dir) -I $(datadir)/idl \
-I $(LIBBONOBO_IDL_DIR) \
-I $(BONOBO_ACTIVATION_IDL_DIR)
$(CORBA_GENERATED): $(idl_dir)/GNOME_SettingsDaemon.idl
$(ORBIT_IDL) $(IDL_FLAGS) $(idl_dir)/GNOME_SettingsDaemon.idl
serverdir = $(libdir)/bonobo/servers
server_in_files = GNOME_SettingsDaemon.server.in
server_DATA = $(server_in_files:.server.in=.server)
@INTLTOOL_SERVER_RULE@
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
$(BUILT_SOURCES) \
$(server_DATA) \
$(server_in_files) \

View file

@ -0,0 +1,48 @@
#include "gnome-settings-daemon.h"
#include <bonobo.h>
#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-generic-factory.h>
#include <libgnome/gnome-init.h>
#include <libgnomeui/gnome-ui-init.h>
#include <libgnomeui/gnome-client.h>
#include <config.h>
static BonoboObject *services_server = NULL;
int main (int argc, char *argv [])
{
GnomeClient *session;
Bonobo_RegistrationResult ret;
gchar *restart_argv[] = { "gnome2-settings-daemon", *argv, 0 };
gnome_program_init ("gnome2-settings-daemon", VERSION, LIBGNOMEUI_MODULE,
argc, argv, NULL);
session = gnome_master_client ();
gnome_client_set_restart_command (session, 2, restart_argv);
gnome_client_set_restart_style (session, GNOME_RESTART_IMMEDIATELY);
gnome_client_set_priority (session, 5);
if (!bonobo_init (&argc, argv)) {
g_error (_("Could not initialize Bonobo"));
}
gconf_init (argc, argv, NULL); /* exits w/ message on failure */
/* start the settings daemon */
services_server = BONOBO_OBJECT (gnome_settings_daemon_new ());
ret = bonobo_activation_active_server_register ("OAFIID:GNOME_SettingsDaemon",
BONOBO_OBJREF (services_server));
if (ret != Bonobo_ACTIVATION_REG_SUCCESS) {
g_warning ("Encountered problems registering the settings daemon with bonobo-activation. "
"Clients may not detect that the settings daemon is already running.");
}
gtk_main();
return -1;
}

View file

@ -30,7 +30,6 @@
#include <gconf/gconf.h> #include <gconf/gconf.h>
#include <libgnome/gnome-init.h> #include <libgnome/gnome-init.h>
#include <libgnomeui/gnome-ui-init.h> #include <libgnomeui/gnome-ui-init.h>
#include <libgnomeui/gnome-client.h>
#include <config.h> #include <config.h>
#include "xsettings-manager.h" #include "xsettings-manager.h"
#include "gnome-settings-daemon.h" #include "gnome-settings-daemon.h"
@ -42,6 +41,13 @@
#include "gnome-settings-sound.h" #include "gnome-settings-sound.h"
#include "gnome-settings-wm.h" #include "gnome-settings-wm.h"
#include "GNOME_SettingsDaemon.h"
static GObjectClass *parent_class = NULL;
struct _GnomeSettingsDaemonPrivate {
};
static GSList *directories = NULL; static GSList *directories = NULL;
XSettingsManager *manager; XSettingsManager *manager;
@ -131,17 +137,66 @@ manager_event_filter (GdkXEvent *xevent,
return GDK_FILTER_CONTINUE; return GDK_FILTER_CONTINUE;
} }
int CORBA_boolean
main (int argc, char **argv) awake_impl (PortableServer_Servant servant,
const CORBA_char *service,
CORBA_Environment *ev)
{
printf ("I received an activate request for %s\n", service);
return TRUE;
}
static void
finalize (GObject *object)
{
GnomeSettingsDaemon *daemon;
daemon = GNOME_SETTINGS_DAEMON (object);
if (daemon->private == NULL) {
return;
}
xsettings_manager_destroy (manager);
g_free (daemon->private);
daemon->private = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gnome_settings_daemon_class_init (GnomeSettingsDaemonClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = finalize;
klass->epv.awake = awake_impl;
parent_class = g_type_class_peek_parent (klass);
}
static void
gnome_settings_daemon_init (GnomeSettingsDaemon *settings)
{
settings->private = g_new (GnomeSettingsDaemonPrivate, 1);
}
BONOBO_TYPE_FUNC_FULL(GnomeSettingsDaemon, GNOME_SettingsDaemon,
BONOBO_TYPE_OBJECT, gnome_settings_daemon)
GObject *
gnome_settings_daemon_new (void)
{ {
gboolean terminated = FALSE; gboolean terminated = FALSE;
GConfClient *client; GConfClient *client;
GnomeClient *session;
GSList *list; GSList *list;
gchar *restart_argv[] = { "gnome2-settings-daemon", *argv, 0 }; GnomeSettingsDaemon *daemon;
gnome_program_init ("gnome2-settings-daemon", VERSION, LIBGNOMEUI_MODULE, daemon = g_object_new (gnome_settings_daemon_get_type (), NULL);
argc, argv, NULL);
if (xsettings_manager_check_running (gdk_display, DefaultScreen (gdk_display))) if (xsettings_manager_check_running (gdk_display, DefaultScreen (gdk_display)))
{ {
@ -159,13 +214,6 @@ main (int argc, char **argv)
exit (1); exit (1);
} }
} }
session = gnome_master_client ();
gnome_client_set_restart_command (session, 2, restart_argv);
gnome_client_set_restart_style (session, GNOME_RESTART_IMMEDIATELY);
gnome_client_set_priority (session, 5);
gconf_init (argc, argv, NULL); /* exits w/ message on failure */
/* We use GConfClient not GConfClient because a cache isn't useful /* We use GConfClient not GConfClient because a cache isn't useful
* for us * for us
@ -210,10 +258,5 @@ main (int argc, char **argv)
gnome_settings_background_load (client); gnome_settings_background_load (client);
gnome_settings_wm_load (client); gnome_settings_wm_load (client);
if (!terminated) return G_OBJECT (daemon);
gtk_main ();
xsettings_manager_destroy (manager);
return 0;
} }

View file

@ -28,6 +28,9 @@
#include <gconf/gconf-client.h> #include <gconf/gconf-client.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <bonobo/bonobo-object.h>
#include "GNOME_SettingsDaemon.h"
typedef void (* KeyCallbackFunc) (GConfEntry *entry); typedef void (* KeyCallbackFunc) (GConfEntry *entry);
@ -35,4 +38,35 @@ void gnome_settings_daemon_register_callback (const char *dir,
KeyCallbackFunc func); KeyCallbackFunc func);
GtkWidget *gnome_settings_daemon_get_invisible (void); GtkWidget *gnome_settings_daemon_get_invisible (void);
G_BEGIN_DECLS
#define GNOME_SETTINGS_DAEMON_TYPE (gnome_settings_daemon_get_type ())
#define GNOME_SETTINGS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_SETTINGS_DAEMON_TYPE, GnomeSettingsDaemon))
#define GNOME_SETTINGS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_SETTINGS_DAEMON_TYPE, GnomeSettingsDaemonClass))
#define IS_GNOME_SETTINGS_DAEMON(obj) (GTK_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_SETTINGS_DAEMON_TYPE))
#define IS_GNOME_SETTINGS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_SETTINGS_DAEMON_TYPE))
#define GNOME_SETTINGS_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_SETTINGS_DAEMON_TYPE, GnomeSettingsDaemonClass))
typedef struct _GnomeSettingsDaemon GnomeSettingsDaemon;
typedef struct _GnomeSettingsDaemonClass GnomeSettingsDaemonClass;
typedef struct _GnomeSettingsDaemonPrivate GnomeSettingsDaemonPrivate;
struct _GnomeSettingsDaemon
{
BonoboObject parent_instance;
GnomeSettingsDaemonPrivate *private;
};
struct _GnomeSettingsDaemonClass
{
BonoboObjectClass parent_class;
POA_GNOME_SettingsDaemon__epv epv;
};
GType gnome_settings_daemon_get_type (void);
GObject *gnome_settings_daemon_new (void);
G_END_DECLS
#endif /* __GNOME_SETTINGS_DAEMON_H */ #endif /* __GNOME_SETTINGS_DAEMON_H */