+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
#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>
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 \
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 \
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);
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);
}
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);
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,
}
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);
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);
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* 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 */
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
*types = type_list;
*num_types = G_N_ELEMENTS (type_list);
}
-
#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"
}
#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");
gtk_main ();
- ev_file_helpers_shutdown ();
-
- ev_backends_manager_shutdown ();
-
- ev_debug_shutdown ();
+ ev_shutdown ();
return 0;
}
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);
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;
}
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;
}