[monkey-bubble: 677/753] Add gconf error stuff as a module, no api added. The only two gnome-gconf



commit d27a561acbf62e89e26d09a701aab62a5017b3bd
Author: George Lebl <jirka 5z com>
Date:   Mon Aug 27 07:44:44 2001 +0000

    Add gconf error stuff as a module, no api added. The only two gnome-gconf
    
    Mon Aug 27 00:44:15 2001  George Lebl <jirka 5z com>
    
    	* Makefile.am, gnome-gconf-ui.[ch], gnome-ui-init.c, libgnomeui.h:
    	  Add gconf error stuff as a module, no api added.  The only two
    	  gnome-gconf API entry points are in libgnome itself.  Also
    	  a bit of cleanup in the init code, and handle fork() < 0 case
    	  on segfault.
    
    	* gnome-app-helper.c, gnome-messagebox.c: fix includes and use the
    	  gconf stuff

 libgnomeui/ChangeLog          |   11 +++
 libgnomeui/Makefile.am        |    2 +
 libgnomeui/gnome-app-helper.c |    6 +-
 libgnomeui/gnome-gconf-ui.c   |  174 +++++++++++++++++++++++++++++++++++++++++
 libgnomeui/gnome-gconf-ui.h   |   41 ++++++++++
 libgnomeui/gnome-messagebox.c |    1 -
 libgnomeui/gnome-ui-init.c    |   40 ++++++----
 libgnomeui/libgnomeui.h       |    1 +
 8 files changed, 257 insertions(+), 19 deletions(-)
---
diff --git a/libgnomeui/ChangeLog b/libgnomeui/ChangeLog
index 5fa46d6..b53268f 100644
--- a/libgnomeui/ChangeLog
+++ b/libgnomeui/ChangeLog
@@ -1,3 +1,14 @@
+Mon Aug 27 00:44:15 2001  George Lebl <jirka 5z com>
+
+	* Makefile.am, gnome-gconf-ui.[ch], gnome-ui-init.c, libgnomeui.h: 
+	  Add gconf error stuff as a module, no api added.  The only two
+	  gnome-gconf API entry points are in libgnome itself.  Also
+	  a bit of cleanup in the init code, and handle fork() < 0 case
+	  on segfault.
+
+	* gnome-app-helper.c, gnome-messagebox.c: fix includes and use the
+	  gconf stuff
+
 Sun Aug 26 19:35:04 2001  George Lebl <jirka 5z com>
 
 	* Makefile.am, gnome-app-helper.[ch], gnome-app-util.[ch],
diff --git a/libgnomeui/Makefile.am b/libgnomeui/Makefile.am
index bbdf71d..7c5f23f 100644
--- a/libgnomeui/Makefile.am
+++ b/libgnomeui/Makefile.am
@@ -62,6 +62,7 @@ libgnomeui_2_la_SOURCES = \
 	gnome-component-widget.c	\
 	gnome-entry.c			\
 	gnome-file-entry.c		\
+	gnome-gconf-ui.c		\
 	gnome-image-entry.c		\
 	gnome-image-selector.c		\
 	gnome-href.c			\
@@ -95,6 +96,7 @@ gnome_headers = \
 	gnome-component-widget.h	\
 	gnome-entry.h			\
 	gnome-file-entry.h		\
+	gnome-gconf-ui.h		\
 	gnome-image-entry.h		\
 	gnome-image-selector.h		\
 	gnome-href.h			\
diff --git a/libgnomeui/gnome-app-helper.c b/libgnomeui/gnome-app-helper.c
index db6ef23..7b65296 100644
--- a/libgnomeui/gnome-app-helper.c
+++ b/libgnomeui/gnome-app-helper.c
@@ -43,7 +43,6 @@
 #include <gconf/gconf-client.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
-#include <libgnome/libgnome.h>
 
 #include <libgnome/gnome-util.h>
 #include <libgnome/gnome-config.h>
@@ -54,6 +53,8 @@
  */
 
 #include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-gconf.h>
+#include <libgnome/gnome-program.h>
 #include "gnome-app.h"
 #include "gnome-app-helper.h"
 #include "gnome-uidefs.h"
@@ -2481,9 +2482,6 @@ per_app_toolbar_style_changed_notify(GConfClient            *client,
         gtk_toolbar_set_style(toolbar, style);
 }
 
-/* FIXME FIXME FIXME */
-#define gnome_gconf_get_gnome_libs_settings_relative(p) NULL
-
 static void
 toolbar_style_changed_notify(GConfClient            *client,
                              guint                   cnxn_id,
diff --git a/libgnomeui/gnome-gconf-ui.c b/libgnomeui/gnome-gconf-ui.c
new file mode 100644
index 0000000..974d1e7
--- /dev/null
+++ b/libgnomeui/gnome-gconf-ui.c
@@ -0,0 +1,174 @@
+/*  -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* GNOME GUI Library - gnome-gconf-ui.c
+ * Copyright (C) 2000  Red Hat Inc.,
+ * All rights reserved.
+ *
+ * Author: Jonathan Blandford  <jrb redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
+ */
+/*
+  @NOTATION@
+*/
+
+
+#include <config.h>
+#include <stdlib.h>
+
+#include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
+
+#include "gnome-i18nP.h"
+
+#include <libgnome.h>
+#include <gtk/gtk.h>
+
+#include "gnome-gconf-ui.h"
+
+/*
+ * Our global GConfClient, and module stuff
+ */
+static void gnome_default_gconf_client_error_handler (GConfClient                  *client,
+                                                      GError                       *error);
+
+
+static void
+gnome_gconf_ui_pre_args_parse (GnomeProgram *app, GnomeModuleInfo *mod_info)
+{
+        gconf_client_set_global_default_error_handler
+		(gnome_default_gconf_client_error_handler);
+}
+
+static void
+gnome_gconf_ui_post_args_parse (GnomeProgram *app, GnomeModuleInfo *mod_info)
+{
+	/* Nothing for now */
+}
+
+static GnomeModuleRequirement gnome_gconf_ui_requirements[] = {
+	{ VERSION, &gnome_gconf_module_info },
+        { NULL, NULL }
+};
+
+GnomeModuleInfo gnome_gconf_ui_module_info = {
+        "gnome-gconf-ui", VERSION, N_("GNOME GConf UI Support"),
+        gnome_gconf_ui_requirements,
+	NULL /* instance init */,
+        gnome_gconf_ui_pre_args_parse,
+	gnome_gconf_ui_post_args_parse,
+        NULL /* options */,
+	NULL /* init_pass */,
+	NULL /* class_init */,
+	NULL, NULL /* expansions */
+};
+
+
+typedef struct {
+        GConfClient *client;
+} ErrorIdleData;
+
+static guint error_handler_idle = 0;
+static GSList *pending_errors = NULL;
+static ErrorIdleData eid = { NULL };
+
+static gboolean
+error_idle_func (gpointer data)
+{
+        GtkWidget *dialog;
+        GSList *iter;
+        gboolean have_overridden = FALSE;
+        const gchar* fmt = NULL;
+        
+        error_handler_idle = 0;
+
+        g_return_val_if_fail(eid.client != NULL, FALSE);
+        g_return_val_if_fail(pending_errors != NULL, FALSE);
+        
+        iter = pending_errors;
+        while (iter != NULL) {
+                GError *error = iter->data;
+
+                if (g_error_matches (error, GCONF_ERROR, GCONF_ERROR_OVERRIDDEN))
+                        have_overridden = TRUE;
+                
+                iter = g_slist_next(iter);
+        }
+        
+        if (have_overridden) {
+                fmt = _("You attempted to change an aspect of your "
+			"configuration that your system administrator "
+			"or operating system vendor does not allow you to "
+			"change. Some of the settings you have selected may "
+			"not take effect, or may not be restored next time "
+			"you use this application (%s).");
+                
+        } else {
+                fmt = _("An error occurred while loading or saving "
+			"configuration information for %s. Some of your "
+			"configuration settings may not work properly.");
+        }
+
+        dialog = gtk_message_dialog_new (NULL /* parent */,
+					 0 /* flags */,
+					 GTK_MESSAGE_ERROR,
+					 GTK_BUTTONS_OK,
+					 fmt,
+					 gnome_program_get_human_readable_name(gnome_program_get()));
+        gtk_widget_show_all(dialog);
+
+
+        /* FIXME put this in a "Technical Details" optional part of the dialog
+           that can be opened up if users are interested */
+        iter = pending_errors;
+        while (iter != NULL) {
+                GError *error = iter->data;
+                iter->data = NULL;
+
+                fprintf(stderr, _("GConf error details: %s\n"), error->message);
+
+                g_error_free(error);
+                
+                iter = g_slist_next(iter);
+        }
+
+        g_slist_free(pending_errors);
+
+        pending_errors = NULL;
+        
+        g_object_unref(G_OBJECT(eid.client));
+        eid.client = NULL;
+
+        return FALSE;
+}
+
+static void
+gnome_default_gconf_client_error_handler (GConfClient                  *client,
+                                          GError                       *error)
+{
+        g_object_ref(G_OBJECT(client));
+        
+        if (eid.client) {
+                g_object_unref(G_OBJECT(eid.client));
+        }
+        
+        eid.client = client;
+        
+        pending_errors = g_slist_append(pending_errors, g_error_copy(error));
+
+        if (error_handler_idle == 0) {
+                error_handler_idle = gtk_idle_add (error_idle_func, NULL);
+        }
+}
+
diff --git a/libgnomeui/gnome-gconf-ui.h b/libgnomeui/gnome-gconf-ui.h
new file mode 100644
index 0000000..3a9ea6d
--- /dev/null
+++ b/libgnomeui/gnome-gconf-ui.h
@@ -0,0 +1,41 @@
+/*  -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* GNOME GUI Library - gnome-gconf.h
+ * Copyright (C) 2000  Red Hat Inc.,
+ * All rights reserved.
+ *
+ * Author: Jonathan Blandford  <jrb redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
+ */
+/*
+  @NOTATION@
+*/
+
+#ifndef GNOME_GCONF_UI_H
+#define GNOME_GCONF_UI_H
+
+#include <libgnome/gnome-program.h>
+
+/* GNOME GConf UI module; basically what this builds on
+   the GConf module from libgnome, adding a GUI error box,
+   etc..
+*/
+
+extern GnomeModuleInfo gnome_gconf_ui_module_info;
+
+#endif
+
+
+
diff --git a/libgnomeui/gnome-messagebox.c b/libgnomeui/gnome-messagebox.c
index 1e00225..95e52fb 100644
--- a/libgnomeui/gnome-messagebox.c
+++ b/libgnomeui/gnome-messagebox.c
@@ -36,7 +36,6 @@
 #include <string.h> /* for strcmp */
 #include <gtk/gtk.h>
 #include <libgnomeui/gnome-uidefs.h>
-#include <libgnome/libgnome.h>
 
 #define GNOME_MESSAGE_BOX_WIDTH  425
 #define GNOME_MESSAGE_BOX_HEIGHT 125
diff --git a/libgnomeui/gnome-ui-init.c b/libgnomeui/gnome-ui-init.c
index ce90e88..f1eab4e 100644
--- a/libgnomeui/gnome-ui-init.c
+++ b/libgnomeui/gnome-ui-init.c
@@ -49,6 +49,7 @@
 #include <libgnomeui/gnome-canvas-init.h>
 
 #include "gnome-client.h"
+#include "gnome-gconf-ui.h"
 #include "gnome-ui-init.h"
 #include "gnome-winhints.h"
 #include "gnome-stock-icons.h"
@@ -113,6 +114,7 @@ static void libgnomeui_rc_parse (gchar *command);
 static void libgnomeui_segv_setup(gboolean post_arg_parse);
 
 static GnomeModuleRequirement libgnomeui_requirements[] = {
+        {VERSION, &gnome_gconf_ui_module_info},
         {VERSION, &libgnome_module_info},
         {VERSION, &libgnomecanvas_module_info},
         {VERSION, &libbonoboui_module_info},
@@ -283,25 +285,23 @@ libgnomeui_pre_args_parse(GnomeProgram *app, GnomeModuleInfo *mod_info)
            characters will display for as many people as possible. Related to bug #1979 */
         ctype = setlocale (LC_CTYPE, NULL);
 
-        if (!strcmp(ctype, "C")) {
+        if (strcmp (ctype, "C") == 0) {
                 old_ctype = g_strdup (g_getenv ("LC_CTYPE"));
-                putenv ("LC_CTYPE=en_US");
+                gnome_setenv ("LC_CTYPE", "en_US", TRUE);
                 ctype_set = TRUE;
-        } else
+        } else {
                 ctype_set = FALSE;
+	}
 
         gtk_set_locale ();
 
         if (ctype_set) {
-                char *setme;
-
                 if (old_ctype) {
-                        setme = g_strconcat ("LC_CTYPE=", old_ctype, NULL);
-                        g_free(old_ctype);
-                } else
-                        setme = "LC_CTYPE";
-
-                putenv (setme);
+			gnome_setenv ("LC_CTYPE", old_ctype, TRUE);
+                        g_free (old_ctype);
+                } else {
+			gnome_unsetenv ("LC_CTYPE");
+		}
         }
         /* End hack */
 }
@@ -312,7 +312,7 @@ libgnomeui_post_args_parse(GnomeProgram *program, GnomeModuleInfo *mod_info)
         GnomeProgramPrivate_libgnomeui *priv = g_new0(GnomeProgramPrivate_libgnomeui, 1);
 
         gnome_type_init();
-        // #warning FIXME: here... gtk_rc ...
+        /* #warning FIXME: here... gtk_rc ... */
         libgnomeui_rc_parse(program_invocation_name);
 
         libgnomeui_segv_setup(TRUE);
@@ -475,7 +475,19 @@ static void libgnomeui_segv_handle(int signum)
 
         gdk_flush();
         
-	if ((pid = fork())) {
+	pid = fork();
+
+	if (pid < 0) {
+		/* Eeeek! Can't show dialog */
+                fprintf (stderr, _("Segmentation fault!\n"
+				   "Cannot display crash dialog\n"));
+
+                /* Don't use app attributes here - a lot of things are probably hosed */
+		if (g_getenv ("GNOME_DUMP_CORE"))
+	                abort ();
+
+		_exit(1);
+	} else if (pid > 0) {
                 /* Wait for user to see the dialog, then exit. */
                 /* Why wait at all? Because we want to allow people to attach to the
 		   process */
@@ -489,7 +501,7 @@ static void libgnomeui_segv_handle(int signum)
 	                abort ();
 
 		_exit(1);
-	} else {
+	} else /* pid == 0 */ {
                 GnomeProgram *program;
 		char buf[32];
 
diff --git a/libgnomeui/libgnomeui.h b/libgnomeui/libgnomeui.h
index 0e3bc26..107ccf8 100644
--- a/libgnomeui/libgnomeui.h
+++ b/libgnomeui/libgnomeui.h
@@ -45,6 +45,7 @@
 #include <libgnomeui/gnome-color-picker.h>
 #include <libgnomeui/gnome-entry.h>
 #include <libgnomeui/gnome-file-entry.h>
+#include <libgnomeui/gnome-gconf-ui.h>
 #include <libgnomeui/gnome-image-entry.h>
 #include <libgnomeui/gnome-image-selector.h>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]