Commit 7bb5595b authored by Nick Schermer's avatar Nick Schermer

* xfce4-settings-helper/main.c, configure.ac.in: Properly quit

	  the main loop when a signal is received.

(Old svn revision: 27341)
parent 76e81e80
2008-07-18 Nick Schermer <nick@xfce.org>
* xfce4-settings-helper/main.c, configure.ac.in: Properly quit
the main loop when a signal is received.
2008-07-18 Nick Schermer <nick@xfce.org>
* dialogs/mouse-settings/main.c: Allow editing the display name
......
......@@ -10,12 +10,6 @@ Keyboard settings
again) (Jannis)
Accessibility Settings
------------------------------------------------------------------------
* Also show the values of the sliders and add tooltips.
Mouse Settings (Nick)
------------------------------------------------------------------------
......@@ -25,8 +19,8 @@ Mouse Settings (Nick)
Settings Helper
------------------------------------------------------------------------
* Add signal watch to xfce4-setting-helper to quit the main loop when
receiving a sigterm. (Nick)
* Check for an already running instance. This is quite easy with
a pid file, but I'm not sure that's a good solution...
Display Settings (Nick)
......
......@@ -60,7 +60,7 @@ AC_PROG_LIBTOOL()
dnl **********************************
dnl *** Check for standard headers ***
dnl **********************************
AC_CHECK_HEADERS([errno.h memory.h math.h stdlib.h string.h unistd.h])
AC_CHECK_HEADERS([errno.h memory.h math.h stdlib.h string.h unistd.h signal.h])
dnl ******************************
dnl *** Check for i18n support ***
......
......@@ -29,6 +29,12 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <glib.h>
#include <gtk/gtk.h>
......@@ -43,8 +49,8 @@
static gboolean opt_version = FALSE;
static gboolean opt_debug = FALSE;
static gboolean opt_version = FALSE;
static gboolean opt_debug = FALSE;
static GOptionEntry option_entries[] =
{
{ "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, N_("Version information"), NULL },
......@@ -54,15 +60,26 @@ static GOptionEntry option_entries[] =
static void
signal_handler (gint signum)
{
/* quit the main loop */
gtk_main_quit ();
}
gint
main (gint argc, gchar **argv)
{
GError *error = NULL;
GObject *pointer_helper;
GObject *keyboards_helper;
GObject *accessibility_helper;
GObject *shortcuts_helper;
pid_t pid;
GError *error = NULL;
GObject *pointer_helper;
GObject *keyboards_helper;
GObject *accessibility_helper;
GObject *shortcuts_helper;
pid_t pid;
guint i;
const gint signums[] = { SIGHUP, SIGINT, SIGQUIT, SIGTERM };
/* setup translation domain */
xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
......@@ -104,6 +121,16 @@ main (gint argc, gchar **argv)
return EXIT_SUCCESS;
}
/* initialize xfconf */
if (!xfconf_init (&error))
{
/* print error and exit */
g_error ("Failed to connect to xfconf daemon: %s.", error->message);
g_error_free (error);
return EXIT_FAILURE;
}
/* daemonize the process when not running in debug mode */
if (!opt_debug)
{
......@@ -113,7 +140,7 @@ main (gint argc, gchar **argv)
if (G_UNLIKELY (pid == -1))
{
/* show message and continue in normal mode */
g_warning ("Failed to fork the process, starting in non-daemon mode");
g_warning ("Failed to fork the process: %s. Continuing in non-daemon mode.", g_strerror (errno));
}
else if (pid > 0)
{
......@@ -122,22 +149,16 @@ main (gint argc, gchar **argv)
}
}
/* initialize xfconf */
if (!xfconf_init (&error))
{
/* print error and exit */
g_error ("Failed to connect to xfconf daemon: %s.", error->message);
g_error_free (error);
return EXIT_FAILURE;
}
/* create the sub daemons */
pointer_helper = g_object_new (XFCE_TYPE_POINTERS_HELPER, NULL);
keyboards_helper = g_object_new (XFCE_TYPE_KEYBOARDS_HELPER, NULL);
accessibility_helper = g_object_new (XFCE_TYPE_ACCESSIBILITY_HELPER, NULL);
shortcuts_helper = g_object_new (XFCE_TYPE_KEYBOARD_SHORTCUTS_HELPER, NULL);
/* setup signal handlers to properly quit the main loop */
for (i = 0; i < G_N_ELEMENTS (signums); i++)
signal (signums[i], signal_handler);
/* enter the main loop */
gtk_main();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment