]> www.fi.muni.cz Git - evince.git/blob - libdocument/ev-init.c
2b247ebe2e02fd8460b85fa2ec3e0c47919bd881
[evince.git] / libdocument / ev-init.c
1 /* this file is part of evince, a gnome document viewer
2  *
3  * Copyright © 2009 Christian Persch
4  *
5  * Evince is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation; either version 2.1 of the License, or
8  * (at your option) any later version.
9  *
10  * Evince is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #include <config.h>
21
22 #include <glib.h>
23 #include <glib/gi18n-lib.h>
24
25 #include "ev-init.h"
26 #include "ev-backends-manager.h"
27 #include "ev-debug.h"
28 #include "ev-file-helpers.h"
29
30 static int ev_init_count;
31
32 /**
33  * ev_init:
34  *
35  * Initializes the evince document library, and binds the evince
36  * gettext domain.
37  *
38  * You must call this before calling any other function in the evince
39  * document library.
40  *
41  * Returns: %TRUE if any backends were found; %FALSE otherwise
42  */
43 gboolean
44 ev_init (void)
45 {
46         static gboolean have_backends;
47
48         if (ev_init_count++ > 0)
49                 return have_backends;
50
51         /* set up translation catalog */
52         bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
53         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
54
55         _ev_debug_init ();
56         _ev_file_helpers_init ();
57         have_backends = _ev_backends_manager_init ();
58
59         return have_backends;
60 }
61
62 /**
63  * ev_shutdown:
64  *
65  * Shuts the evince document library down.
66  */
67 void
68 ev_shutdown (void)
69 {
70         g_assert (_ev_is_initialized ());
71
72         if (--ev_init_count > 0)
73                 return;
74
75         _ev_backends_manager_shutdown ();
76         _ev_file_helpers_shutdown ();
77         _ev_debug_shutdown ();
78 }
79
80 /*
81  * _ev_is_initialized:
82  *
83  * Returns: %TRUE if the evince document library has been initialized
84  */
85 gboolean
86 _ev_is_initialized (void)
87 {
88         return ev_init_count > 0;
89 }