Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-backend-info.c File Reference
#include <config.h>
#include "ev-backend-info.h"
+ Include dependency graph for ev-backend-info.c:

Go to the source code of this file.

Macros

#define EV_BACKENDS_GROUP   "Evince Backend"
 
#define EV_BACKENDS_EXTENSION   ".evince-backend"
 

Functions

EvBackendInfo_ev_backend_info_ref (EvBackendInfo *info)
 
void _ev_backend_info_unref (EvBackendInfo *info)
 
EvBackendInfo_ev_backend_info_new_from_file (const char *file, GError **error)
 
GList * _ev_backend_info_load_from_dir (const char *path)
 

Macro Definition Documentation

#define EV_BACKENDS_EXTENSION   ".evince-backend"

Definition at line 25 of file ev-backend-info.c.

#define EV_BACKENDS_GROUP   "Evince Backend"

Definition at line 24 of file ev-backend-info.c.

Function Documentation

GList* _ev_backend_info_load_from_dir ( const char *  path)

Definition at line 127 of file ev-backend-info.c.

128 {
129  GList *list = NULL;
130  GDir *dir;
131  const gchar *dirent;
132  GError *error = NULL;
133 
134  dir = g_dir_open (path, 0, &error);
135  if (!dir) {
136  g_warning ("%s", error->message);
137  g_error_free (error);
138 
139  return FALSE;
140  }
141 
142  while ((dirent = g_dir_read_name (dir))) {
143  EvBackendInfo *info;
144  gchar *file;
145 
146  if (!g_str_has_suffix (dirent, EV_BACKENDS_EXTENSION))
147  continue;
148 
149  file = g_build_filename (path, dirent, NULL);
150  info = _ev_backend_info_new_from_file (file, &error);
151  if (error != NULL) {
152  g_warning ("Failed to load backend info from '%s': %s\n",
153  file, error->message);
154  g_clear_error (&error);
155  }
156  g_free (file);
157 
158  if (info == NULL)
159  continue;
160 
161  list = g_list_prepend (list, info);
162  }
163 
164  g_dir_close (dir);
165 
166  return list;
167 }

+ Here is the caller graph for this function:

EvBackendInfo* _ev_backend_info_new_from_file ( const char *  file,
GError **  error 
)

_ev_backend_info_new_from_file: : path to the backends file : a location to store a #GError, or NULL

Loads backend information from .

Returns: a new EvBackendInfo, or NULL on error with filled in

Definition at line 76 of file ev-backend-info.c.

78 {
79  EvBackendInfo *info = NULL;
80  GKeyFile *backend_file = NULL;
81 
82  backend_file = g_key_file_new ();
83  if (!g_key_file_load_from_file (backend_file, file, G_KEY_FILE_NONE, error))
84  goto err;
85 
86  info = g_slice_new0 (EvBackendInfo);
87  info->ref_count = 1;
88 
89  info->module_name = g_key_file_get_string (backend_file, EV_BACKENDS_GROUP,
90  "Module", error);
91  if (!info->module_name)
92  goto err;
93 
94  info->resident = g_key_file_get_boolean (backend_file, EV_BACKENDS_GROUP,
95  "Resident", NULL);
96 
97  info->type_desc = g_key_file_get_locale_string (backend_file, EV_BACKENDS_GROUP,
98  "TypeDescription", NULL, error);
99  if (!info->type_desc)
100  goto err;
101 
102  info->mime_types = g_key_file_get_string_list (backend_file, EV_BACKENDS_GROUP,
103  "MimeType", NULL, error);
104  if (!info->mime_types)
105  goto err;
106 
107  g_key_file_free (backend_file);
108 
109  return info;
110 
111  err:
112  g_key_file_free (backend_file);
113  _ev_backend_info_unref (info);
114  return NULL;
115 }

+ Here is the caller graph for this function:

EvBackendInfo* _ev_backend_info_ref ( EvBackendInfo info)

Definition at line 34 of file ev-backend-info.c.

35 {
36  g_return_val_if_fail (info != NULL, NULL);
37  g_return_val_if_fail (info->ref_count >= 1, NULL);
38 
39  g_atomic_int_inc (&info->ref_count);
40  return info;
41 }

+ Here is the caller graph for this function:

void _ev_backend_info_unref ( EvBackendInfo info)

Definition at line 50 of file ev-backend-info.c.

51 {
52  if (info == NULL)
53  return;
54 
55  g_return_if_fail (info->ref_count >= 1);
56 
57  if (!g_atomic_int_dec_and_test (&info->ref_count))
58  return;
59 
60  g_free (info->module_name);
61  g_free (info->type_desc);
62  g_strfreev (info->mime_types);
63  g_slice_free (EvBackendInfo, info);
64 }

+ Here is the caller graph for this function: