summaryrefslogtreecommitdiff
path: root/gconf
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2009-01-27 15:40:43 +0000
committerTor Lillqvist <tml@src.gnome.org>2009-01-27 15:40:43 +0000
commit47626b285b41911ff11464dda5beb1137c637fda (patch)
treefafe7a7af412eba905994d98d5d6436a53751684 /gconf
parentf034d1b5ef0cc0f4124f57f67e54e0aef612eeaa (diff)
downloadgconf-47626b285b41911ff11464dda5beb1137c637fda.tar.gz
Use the -mwindows flag when linking on Windows, so that we build a "GUI"
2009-01-27 Tor Lillqvist <tml@novell.com> * gconf/Makefile.am (gconfd_2_LDFLAGS): Use the -mwindows flag when linking on Windows, so that we build a "GUI" executable. * gconf/gconfd.c (main): On Windows, with GCONF_DEBUG_OUTPUT set, make sure stdout and stderr go somewhere. Use the parent's console window if possible, otherwise open an own console window. If we had to open an own console window, give the user a chance to read the output when exiting. Same idea that has been successfully used in GIMP for a while. svn path=/trunk/; revision=2746
Diffstat (limited to 'gconf')
-rw-r--r--gconf/Makefile.am4
-rw-r--r--gconf/gconfd.c59
2 files changed, 63 insertions, 0 deletions
diff --git a/gconf/Makefile.am b/gconf/Makefile.am
index 13fb5a7b..2bcc8e87 100644
--- a/gconf/Makefile.am
+++ b/gconf/Makefile.am
@@ -74,6 +74,10 @@ gconfd_2_SOURCES = \
gconfd.h \
gconfd.c
+if OS_WIN32
+gconfd_2_LDFLAGS = -mwindows
+endif
+
gconfd_2_LDADD = $(EFENCE) $(INTLLIBS) $(DEPENDENT_LIBS) libgconf-$(MAJOR_VERSION).la
gconftool_2_SOURCES = \
diff --git a/gconf/gconfd.c b/gconf/gconfd.c
index 2f3a9d10..2e7183b8 100644
--- a/gconf/gconfd.c
+++ b/gconf/gconfd.c
@@ -57,6 +57,13 @@
#include <dbus/dbus-glib-lowlevel.h>
+#ifdef G_OS_WIN32
+#include <io.h>
+#include <conio.h>
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+#endif
+
/* This makes hash table safer when debugging */
#ifndef GCONF_ENABLE_DEBUG
#define safe_g_hash_table_insert g_hash_table_insert
@@ -712,6 +719,19 @@ get_on_system_bus (void)
}
#endif /* ENABLE_DEFAULTS_SERVICE */
+#ifdef G_OS_WIN32
+
+static void
+wait_console_window (void)
+{
+ SetConsoleTitle ("GConf daemon exiting. Type any character to close this window.");
+ printf ("\n"
+ "(GConf daemon exiting. Type any character to close this window)\n");
+ _getch ();
+}
+
+#endif
+
int
main(int argc, char** argv)
{
@@ -762,6 +782,45 @@ main(int argc, char** argv)
else
{
gconf_log_debug_messages = TRUE;
+#ifdef G_OS_WIN32
+ if (fileno (stdout) != -1 &&
+ _get_osfhandle (fileno (stdout)) != -1)
+ {
+ /* stdout is fine, presumably redirected to a file or pipe */
+ }
+ else
+ {
+ int allocated_new_console = FALSE;
+
+ typedef BOOL (* WINAPI AttachConsole_t) (DWORD);
+
+ AttachConsole_t p_AttachConsole =
+ (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole");
+
+ if (p_AttachConsole != NULL)
+ {
+ if (!AttachConsole (ATTACH_PARENT_PROCESS))
+ {
+ if (AllocConsole ())
+ allocated_new_console = TRUE;
+ }
+
+ freopen ("CONOUT$", "w", stdout);
+ dup2 (fileno (stdout), 1);
+ freopen ("CONOUT$", "w", stderr);
+ dup2 (fileno (stderr), 2);
+
+ if (allocated_new_console)
+ {
+ SetConsoleTitle ("GConf daemon debugging output. You can minimize this window, but don't close it.");
+ printf ("You asked for debugging output by setting the GCONF_DEBUG_OUTPUT\n"
+ "environment variable, so here it is.\n"
+ "\n");
+ atexit (wait_console_window);
+ }
+ }
+ }
+#endif
}
umask (022);