[devhelp/application-menu] libdevhelp: provide a dh_init() to initialize common configuration



commit a108ad2f01d004c0185ee44d08ed864a3d9276bf
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Tue Jun 26 17:29:03 2012 +0200

    libdevhelp: provide a dh_init() to initialize common configuration

 src/Makefile.am |    6 ++++--
 src/devhelp.h   |   45 +++++++++++++++++++++++++++++++++++++++++++++
 src/dh-app.c    |   20 +-------------------
 src/dh-common.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 src/dh-main.c   |    6 ++++--
 5 files changed, 97 insertions(+), 23 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 11eceb3..e6b1716 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,9 +50,10 @@ devhelp_LDADD = 					\
 lib_LTLIBRARIES = libdevhelp-3.la
 
 INST_H_FILES = 						\
+	devhelp.h					\
+	dh-app.h					\
 	dh-assistant.h					\
 	dh-assistant-view.h				\
-	dh-app.h					\
 	dh-book-manager.h				\
 	dh-language.h					\
 	dh-book.h					\
@@ -67,13 +68,14 @@ devhelpincludedir = $(includedir)/devhelp-3.0/devhelp
 devhelpinclude_HEADERS = $(INST_H_FILES)
 
 libdevhelp_3_la_SOURCES =				\
+	dh-common.c					\
 	dh-marshal.c					\
 	dh-marshal.h					\
 	dh-enum-types.c					\
 	dh-enum-types.h					\
+	dh-app.c					\
 	dh-assistant.c					\
 	dh-assistant-view.c				\
-	dh-app.c					\
 	dh-book-manager.c				\
 	dh-language.c					\
 	dh-book.c					\
diff --git a/src/devhelp.h b/src/devhelp.h
new file mode 100644
index 0000000..4072d8f
--- /dev/null
+++ b/src/devhelp.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2012 Aleksander Morgado <aleksander gnu org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __DEVHELP_H__
+#define __DEVHELP_H__
+
+#include <glib.h>
+
+/* Explicitly include all the exported headers */
+#include "dh-assistant.h"
+#include "dh-assistant-view.h"
+#include "dh-book-manager.h"
+#include "dh-language.h"
+#include "dh-book.h"
+#include "dh-book-tree.h"
+#include "dh-error.h"
+#include "dh-keyword-model.h"
+#include "dh-link.h"
+#include "dh-search.h"
+#include "dh-window.h"
+
+G_BEGIN_DECLS
+
+void dh_init (void);
+
+G_END_DECLS
+
+#endif /* __DEVHELP_H__ */
diff --git a/src/dh-app.c b/src/dh-app.c
index 13db0a0..d9d63e2 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -25,12 +25,9 @@
 
 #include <glib/gi18n.h>
 
-#include "ige-conf.h"
-#include "dh-util.h"
+#include "devhelp.h"
 #include "dh-app.h"
 #include "dh-preferences.h"
-#include "dh-window.h"
-#include "dh-assistant.h"
 
 struct _DhAppPrivate {
         DhBookManager *book_manager;
@@ -295,18 +292,6 @@ setup_actions (DhApp *self)
 /******************************************************************************/
 
 static void
-load_config_defaults (void)
-{
-        IgeConf    *conf;
-        gchar      *path;
-
-        conf = ige_conf_get ();
-        path = dh_util_build_data_filename ("devhelp", "devhelp.defaults", NULL);
-        ige_conf_add_defaults (conf, path);
-        g_free (path);
-}
-
-static void
 create_application_menu (DhApp *self)
 {
         GMenu *menu, *section;
@@ -344,9 +329,6 @@ startup (GApplication *application)
         /* Create application menu */
         create_application_menu (self);
 
-        /* Setup default configuration */
-        load_config_defaults ();
-
         /* Load the book manager */
         g_assert (self->priv->book_manager == NULL);
         self->priv->book_manager = dh_book_manager_new ();
diff --git a/src/dh-common.c b/src/dh-common.c
new file mode 100644
index 0000000..f5fe74d
--- /dev/null
+++ b/src/dh-common.c
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2012 Aleksander Morgado <aleksander gnu org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "devhelp.h"
+
+#include "ige-conf.h"
+#include "dh-util.h"
+
+static void
+load_config_defaults (void)
+{
+        IgeConf    *conf;
+        gchar      *path;
+
+        conf = ige_conf_get ();
+        path = dh_util_build_data_filename ("devhelp", "devhelp.defaults", NULL);
+        ige_conf_add_defaults (conf, path);
+        g_free (path);
+}
+
+void
+dh_init (void)
+{
+        load_config_defaults ();
+}
diff --git a/src/dh-main.c b/src/dh-main.c
index c4c2bc8..0d771a0 100644
--- a/src/dh-main.c
+++ b/src/dh-main.c
@@ -32,9 +32,8 @@
 #include <gdk/gdkx.h>
 #endif
 
+#include "devhelp.h"
 #include "dh-app.h"
-#include "dh-window.h"
-#include "dh-assistant.h"
 
 static gboolean  option_new_window;
 static gchar    *option_search;
@@ -146,6 +145,9 @@ main (int argc, char **argv)
                 return EXIT_SUCCESS;
         }
 
+        /* Initialize Devhelp support */
+        dh_init ();
+
         /* Create new DhApp */
         application = dh_app_new ();
         g_signal_connect (application, "activate", G_CALLBACK (activate_cb), NULL);



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