evince r3391 - in trunk: . libdocument properties shell thumbnailer
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: evince r3391 - in trunk: . libdocument properties shell thumbnailer
- Date: Fri, 30 Jan 2009 18:40:18 +0000 (UTC)
Author: chpe
Date: Fri Jan 30 18:40:17 2009
New Revision: 3391
URL: http://svn.gnome.org/viewvc/evince?rev=3391&view=rev
Log:
* 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.
Added:
trunk/libdocument/ev-init.c
trunk/libdocument/ev-init.h
Modified:
trunk/ChangeLog
trunk/evince-document.h
trunk/libdocument/Makefile.am
trunk/libdocument/ev-backends-manager.c
trunk/libdocument/ev-backends-manager.h
trunk/libdocument/ev-debug.c
trunk/libdocument/ev-debug.h
trunk/libdocument/ev-file-helpers.c
trunk/libdocument/ev-file-helpers.h
trunk/properties/ev-properties-main.c
trunk/shell/main.c
trunk/thumbnailer/evince-thumbnailer.c
Modified: trunk/evince-document.h
==============================================================================
--- trunk/evince-document.h (original)
+++ trunk/evince-document.h Fri Jan 30 18:40:17 2009
@@ -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>
Modified: trunk/libdocument/Makefile.am
==============================================================================
--- trunk/libdocument/Makefile.am (original)
+++ trunk/libdocument/Makefile.am Fri Jan 30 18:40:17 2009
@@ -26,6 +26,7 @@
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 @@
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 \
Modified: trunk/libdocument/ev-backends-manager.c
==============================================================================
--- trunk/libdocument/ev-backends-manager.c (original)
+++ trunk/libdocument/ev-backends-manager.c Fri Jan 30 18:40:17 2009
@@ -146,17 +146,29 @@
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);
Modified: trunk/libdocument/ev-backends-manager.h
==============================================================================
--- trunk/libdocument/ev-backends-manager.h (original)
+++ trunk/libdocument/ev-backends-manager.h Fri Jan 30 18:40:17 2009
@@ -35,8 +35,8 @@
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);
Modified: trunk/libdocument/ev-debug.c
==============================================================================
--- trunk/libdocument/ev-debug.c (original)
+++ trunk/libdocument/ev-debug.c Fri Jan 30 18:40:17 2009
@@ -79,14 +79,14 @@
}
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);
Modified: trunk/libdocument/ev-debug.h
==============================================================================
--- trunk/libdocument/ev-debug.h (original)
+++ trunk/libdocument/ev-debug.h Fri Jan 30 18:40:17 2009
@@ -87,8 +87,8 @@
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,
Modified: trunk/libdocument/ev-file-helpers.c
==============================================================================
--- trunk/libdocument/ev-file-helpers.c (original)
+++ trunk/libdocument/ev-file-helpers.c Fri Jan 30 18:40:17 2009
@@ -75,12 +75,12 @@
}
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);
Modified: trunk/libdocument/ev-file-helpers.h
==============================================================================
--- trunk/libdocument/ev-file-helpers.h (original)
+++ trunk/libdocument/ev-file-helpers.h Fri Jan 30 18:40:17 2009
@@ -38,9 +38,9 @@
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);
Added: trunk/libdocument/ev-init.c
==============================================================================
--- (empty file)
+++ trunk/libdocument/ev-init.c Fri Jan 30 18:40:17 2009
@@ -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;
+}
Added: trunk/libdocument/ev-init.h
==============================================================================
--- (empty file)
+++ trunk/libdocument/ev-init.h Fri Jan 30 18:40:17 2009
@@ -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 */
Modified: trunk/properties/ev-properties-main.c
==============================================================================
--- trunk/properties/ev-properties-main.c (original)
+++ trunk/properties/ev-properties-main.c Fri Jan 30 18:40:17 2009
@@ -137,13 +137,13 @@
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 @@
*types = type_list;
*num_types = G_N_ELEMENTS (type_list);
}
-
Modified: trunk/shell/main.c
==============================================================================
--- trunk/shell/main.c (original)
+++ trunk/shell/main.c Fri Jan 30 18:40:17 2009
@@ -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 @@
}
#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 @@
gtk_main ();
- ev_file_helpers_shutdown ();
-
- ev_backends_manager_shutdown ();
-
- ev_debug_shutdown ();
+ ev_shutdown ();
return 0;
}
Modified: trunk/thumbnailer/evince-thumbnailer.c
==============================================================================
--- trunk/thumbnailer/evince-thumbnailer.c (original)
+++ trunk/thumbnailer/evince-thumbnailer.c Fri Jan 30 18:40:17 2009
@@ -163,7 +163,8 @@
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 @@
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 @@
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]