Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/libdocument
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2009-01-30 18:40:17 (GMT)
committer Christian Persch <chpe@src.gnome.org>2009-01-30 18:40:17 (GMT)
commit2d8aad40e1916911b773f1cfdd93c961feabf807 (patch)
treef87dabab6d4ba15446fd5cbe2625e0f18357cf3d /libdocument
parent1f9a1db557a629d68bba06d7b4b4379127c34f4d (diff)
A libdocument/ev-init.[ch]: Add single init/shutdown method. Bug #569117.
* evince-document.h: * libdocument/Makefile.am: A libdocument/ev-init.[ch]: Add single init/shutdown method. Bug #569117. * libdocument/ev-backends-manager.c: (_ev_backends_manager_init): * libdocument/ev-backends-manager.h: * libdocument/ev-debug.c: (_ev_debug_init), (_ev_debug_shutdown): * libdocument/ev-debug.h: * libdocument/ev-file-helpers.c: (_ev_file_helpers_init), (_ev_file_helpers_shutdown): * libdocument/ev-file-helpers.h: Make these init/shutdown methods private. * properties/ev-properties-main.c: (nautilus_module_initialize), (nautilus_module_shutdown): * shell/main.c: (main): * thumbnailer/evince-thumbnailer.c: (main): Use the new single init/shutdown method. svn path=/trunk/; revision=3391
Diffstat (limited to 'libdocument')
-rw-r--r--libdocument/Makefile.am2
-rw-r--r--libdocument/ev-backends-manager.c18
-rw-r--r--libdocument/ev-backends-manager.h4
-rw-r--r--libdocument/ev-debug.c4
-rw-r--r--libdocument/ev-debug.h4
-rw-r--r--libdocument/ev-file-helpers.c4
-rw-r--r--libdocument/ev-file-helpers.h4
-rw-r--r--libdocument/ev-init.c83
-rw-r--r--libdocument/ev-init.h39
9 files changed, 149 insertions, 13 deletions
diff --git a/libdocument/Makefile.am b/libdocument/Makefile.am
index 94b049f..6eab585 100644
--- a/libdocument/Makefile.am
+++ b/libdocument/Makefile.am
@@ -26,6 +26,7 @@ INST_H_FILES = \
ev-file-helpers.h \
ev-form-field.h \
ev-image.h \
+ ev-init.h \
ev-layer.h \
ev-link-action.h \
ev-link-dest.h \
@@ -48,6 +49,7 @@ libevdocument_la_SOURCES= \
ev-link-action.c \
ev-link-dest.c \
ev-image.c \
+ ev-init.c \
ev-document.c \
ev-document-factory.c \
ev-document-thumbnails.c \
diff --git a/libdocument/ev-backends-manager.c b/libdocument/ev-backends-manager.c
index 505d5c4..e92ecb5 100644
--- a/libdocument/ev-backends-manager.c
+++ b/libdocument/ev-backends-manager.c
@@ -146,17 +146,29 @@ ev_backends_manager_load (void)
return TRUE;
}
+/*
+ * _ev_backends_manager_init:
+ *
+ * Initializes the evince backends manager.
+ *
+ * Returns: %TRUE if there were any backends found; %FALSE otherwise
+ */
gboolean
-ev_backends_manager_init (void)
+_ev_backends_manager_init (void)
{
if (ev_backends_list)
- return FALSE;
+ return TRUE;
return ev_backends_manager_load ();
}
+/*
+ * _ev_backends_manager_shutdown:
+ *
+ * Shuts the evince backends manager down.
+ */
void
-ev_backends_manager_shutdown (void)
+_ev_backends_manager_shutdown (void)
{
g_list_foreach (ev_backends_list, (GFunc)ev_backend_info_free, NULL);
g_list_free (ev_backends_list);
diff --git a/libdocument/ev-backends-manager.h b/libdocument/ev-backends-manager.h
index 4fb1656..4bb54f2 100644
--- a/libdocument/ev-backends-manager.h
+++ b/libdocument/ev-backends-manager.h
@@ -35,8 +35,8 @@ typedef struct _EvTypeInfo {
const gchar **mime_types;
} EvTypeInfo;
-gboolean ev_backends_manager_init (void);
-void ev_backends_manager_shutdown (void);
+gboolean _ev_backends_manager_init (void);
+void _ev_backends_manager_shutdown (void);
EvDocument *ev_backends_manager_get_document (const gchar *mime_type);
const gchar *ev_backends_manager_get_document_module_name (EvDocument *document);
diff --git a/libdocument/ev-debug.c b/libdocument/ev-debug.c
index 48cbf5d..c6918e7 100644
--- a/libdocument/ev-debug.c
+++ b/libdocument/ev-debug.c
@@ -79,14 +79,14 @@ profile_init ()
}
void
-ev_debug_init ()
+_ev_debug_init ()
{
debug_init ();
profile_init ();
}
void
-ev_debug_shutdown ()
+_ev_debug_shutdown ()
{
if (timers) {
g_hash_table_destroy (timers);
diff --git a/libdocument/ev-debug.h b/libdocument/ev-debug.h
index 7acb41f..e97cdf4 100644
--- a/libdocument/ev-debug.h
+++ b/libdocument/ev-debug.h
@@ -87,8 +87,8 @@ typedef enum {
EV_PROFILE_JOBS = 1 << 0
} EvProfileSection;
-void ev_debug_init (void);
-void ev_debug_shutdown (void);
+void _ev_debug_init (void);
+void _ev_debug_shutdown (void);
void ev_debug_message (EvDebugSection section,
const gchar *file,
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index 9c65aa5..e48ce9d 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -75,12 +75,12 @@ ev_tmp_dir (void)
}
void
-ev_file_helpers_init (void)
+_ev_file_helpers_init (void)
{
}
void
-ev_file_helpers_shutdown (void)
+_ev_file_helpers_shutdown (void)
{
if (tmp_dir != NULL)
g_rmdir (tmp_dir);
diff --git a/libdocument/ev-file-helpers.h b/libdocument/ev-file-helpers.h
index 51d763d..adec69c 100644
--- a/libdocument/ev-file-helpers.h
+++ b/libdocument/ev-file-helpers.h
@@ -38,9 +38,9 @@ typedef enum {
const gchar *ev_tmp_dir (void);
-void ev_file_helpers_init (void);
+void _ev_file_helpers_init (void);
-void ev_file_helpers_shutdown (void);
+void _ev_file_helpers_shutdown (void);
gboolean ev_dir_ensure_exists (const gchar *dir,
int mode);
diff --git a/libdocument/ev-init.c b/libdocument/ev-init.c
new file mode 100644
index 0000000..34b323c
--- /dev/null
+++ b/libdocument/ev-init.c
@@ -0,0 +1,83 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright © 2009 Christian Persch
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince 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 Lesser
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 <glib.h>
+
+#include "ev-init.h"
+#include "ev-backends-manager.h"
+#include "ev-debug.h"
+#include "ev-file-helpers.h"
+
+static int ev_init_count;
+
+/**
+ * ev_init:
+ *
+ * Initializes the evince document library.
+ *
+ * You must call this before calling any other function in the evince
+ * document library.
+ *
+ * Returns: %TRUE if any backends were found; %FALSE otherwise
+ */
+gboolean
+ev_init (void)
+{
+ static gboolean have_backends;
+
+ if (ev_init_count++ > 0)
+ return have_backends;
+
+ _ev_debug_init ();
+ _ev_file_helpers_init ();
+ have_backends = _ev_backends_manager_init ();
+
+ return have_backends;
+}
+
+/**
+ * ev_shutdown:
+ *
+ * Shuts the evince document library down.
+ */
+void
+ev_shutdown (void)
+{
+ g_assert (_ev_is_initialized ());
+
+ if (--ev_init_count > 0)
+ return;
+
+ _ev_backends_manager_shutdown ();
+ _ev_file_helpers_shutdown ();
+ _ev_debug_shutdown ();
+}
+
+/*
+ * _ev_is_initialized:
+ *
+ * Returns: %TRUE if the evince document library has been initialized
+ */
+gboolean
+_ev_is_initialized (void)
+{
+ return ev_init_count > 0;
+}
diff --git a/libdocument/ev-init.h b/libdocument/ev-init.h
new file mode 100644
index 0000000..976429c
--- /dev/null
+++ b/libdocument/ev-init.h
@@ -0,0 +1,39 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright © 2009 Christian Persch
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince 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 Lesser
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ */
+
+#if !defined (__EV_EVINCE_DOCUMENT_H_INSIDE__) && !defined (EVINCE_COMPILATION)
+#error "Only <evince-document.h> can be included directly."
+#endif
+
+#ifndef EV_INIT_H
+#define EV_INIT_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gboolean ev_init (void);
+
+void ev_shutdown (void);
+
+gboolean _ev_is_initialized (void);
+
+G_END_DECLS
+
+#endif /* EV_INIT_H */