]> www.fi.muni.cz Git - evince.git/blob - libdocument/ev-init.c
A libdocument/ev-init.[ch]: Add single init/shutdown method. Bug #569117.
[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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include <config.h>
21
22 #include <glib.h>
23
24 #include "ev-init.h"
25 #include "ev-backends-manager.h"
26 #include "ev-debug.h"
27 #include "ev-file-helpers.h"
28
29 static int ev_init_count;
30
31 /**
32  * ev_init:
33  *
34  * Initializes the evince document library.
35  *
36  * You must call this before calling any other function in the evince
37  * document library.
38  *
39  * Returns: %TRUE if any backends were found; %FALSE otherwise
40  */
41 gboolean
42 ev_init (void)
43 {
44         static gboolean have_backends;
45
46         if (ev_init_count++ > 0)
47                 return have_backends;
48
49         _ev_debug_init ();
50         _ev_file_helpers_init ();
51         have_backends = _ev_backends_manager_init ();
52
53         return have_backends;
54 }
55
56 /**
57  * ev_shutdown:
58  *
59  * Shuts the evince document library down.
60  */
61 void
62 ev_shutdown (void)
63 {
64         g_assert (_ev_is_initialized ());
65
66         if (--ev_init_count > 0)
67                 return;
68
69         _ev_backends_manager_shutdown ();
70         _ev_file_helpers_shutdown ();
71         _ev_debug_shutdown ();
72 }
73
74 /*
75  * _ev_is_initialized:
76  *
77  * Returns: %TRUE if the evince document library has been initialized
78  */
79 gboolean
80 _ev_is_initialized (void)
81 {
82         return ev_init_count > 0;
83 }