Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--evince-document.h1
-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
-rw-r--r--properties/ev-properties-main.c5
-rw-r--r--shell/main.c14
-rw-r--r--thumbnailer/evince-thumbnailer.c13
14 files changed, 186 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index b779804..d9f6925 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2009-01-30 Christian Persch <chpe@gnome.org>
+
+ * 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.
+
2009-01-29 Christian Persch <chpe@gnome.org>
* shell/main.c: (option_version_cb): Add --version which was lost in
diff --git a/evince-document.h b/evince-document.h
index 0f1c13f..b35525f 100644
--- a/evince-document.h
+++ b/evince-document.h
@@ -42,6 +42,7 @@
#include <libdocument/ev-file-helpers.h>
#include <libdocument/ev-form-field.h>
#include <libdocument/ev-image.h>
+#include <libdocument/ev-init.h>
#include <libdocument/ev-layer.h>
#include <libdocument/ev-link-action.h>
#include <libdocument/ev-link-dest.h>
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 */
diff --git a/properties/ev-properties-main.c b/properties/ev-properties-main.c
index a3c045b..27b80c3 100644
--- a/properties/ev-properties-main.c
+++ b/properties/ev-properties-main.c
@@ -137,13 +137,13 @@ nautilus_module_initialize (GTypeModule *module)
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- ev_backends_manager_init ();
+ ev_init ();
}
void
nautilus_module_shutdown (void)
{
- ev_backends_manager_shutdown ();
+ ev_shutdown ();
}
void
@@ -156,4 +156,3 @@ nautilus_module_list_types (const GType **types,
*types = type_list;
*num_types = G_N_ELEMENTS (type_list);
}
-
diff --git a/shell/main.c b/shell/main.c
index c10ac85..5348469 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -33,6 +33,7 @@
#include "ev-application.h"
#include "ev-backends-manager.h"
#include "ev-debug.h"
+#include "ev-init.h"
#include "ev-file-helpers.h"
#include "ev-stock-icons.h"
#include "eggsmclient.h"
@@ -369,10 +370,9 @@ main (int argc, char *argv[])
}
#endif /* ENABLE_DBUS */
- ev_debug_init ();
- ev_backends_manager_init ();
-
- ev_file_helpers_init ();
+ if (!ev_init ())
+ return 1;
+
ev_stock_icons_init ();
egg_set_desktop_file (GNOMEDATADIR "/applications/evince.desktop");
@@ -383,11 +383,7 @@ main (int argc, char *argv[])
gtk_main ();
- ev_file_helpers_shutdown ();
-
- ev_backends_manager_shutdown ();
-
- ev_debug_shutdown ();
+ ev_shutdown ();
return 0;
}
diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c
index ec72f16..217210b 100644
--- a/thumbnailer/evince-thumbnailer.c
+++ b/thumbnailer/evince-thumbnailer.c
@@ -163,7 +163,8 @@ main (int argc, char *argv[])
if (!g_thread_supported ())
g_thread_init (NULL);
- ev_backends_manager_init ();
+ if (!ev_init ())
+ return -1;
file = g_file_new_for_commandline_arg (input);
uri = g_file_get_uri (file);
@@ -173,13 +174,13 @@ main (int argc, char *argv[])
g_free (uri);
if (!document) {
- ev_backends_manager_shutdown ();
+ ev_shutdown ();
return -2;
}
if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
g_object_unref (document);
- ev_backends_manager_shutdown ();
+ ev_shutdown ();
return -2;
}
@@ -198,19 +199,19 @@ main (int argc, char *argv[])
gtk_main ();
g_object_unref (document);
- ev_backends_manager_shutdown ();
+ ev_shutdown ();
return data.success ? 0 : -2;
}
if (!evince_thumbnail_pngenc_get (document, output, size)) {
g_object_unref (document);
- ev_backends_manager_shutdown ();
+ ev_shutdown ();
return -2;
}
g_object_unref (document);
- ev_backends_manager_shutdown ();
+ ev_shutdown ();
return 0;
}