From 6ee6a56490821f09bffbe17f3dde19da3a119dd8 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 3 Mar 2008 15:01:19 +0000 Subject: [PATCH] Allow making backend modules resident. This is needed only for some 2008-03-03 Carlos Garcia Campos * backend/pdf/pdfdocument.evince-backend.in: * libdocument/ev-backends-manager.c: (ev_backends_manager_load_backend), (ev_backends_manager_get_document): * libdocument/ev-module.[ch]: (ev_module_load), (ev_module_new): Allow making backend modules resident. This is needed only for some backends like pdf to avoid registering glib types more than once. svn path=/trunk/; revision=2943 --- ChangeLog | 12 ++++++++++++ backend/pdf/pdfdocument.evince-backend.in | 1 + libdocument/ev-backends-manager.c | 6 +++++- libdocument/ev-module.c | 8 +++++++- libdocument/ev-module.h | 3 ++- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecd577e7..84395173 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-03-03 Carlos Garcia Campos + + * backend/pdf/pdfdocument.evince-backend.in: + * libdocument/ev-backends-manager.c: + (ev_backends_manager_load_backend), + (ev_backends_manager_get_document): + * libdocument/ev-module.[ch]: (ev_module_load), (ev_module_new): + + Allow making backend modules resident. This is needed only for + some backends like pdf to avoid registering glib types more than + once. + 2008-03-03 Carlos Garcia Campos * backend/comics/comics-document.c: diff --git a/backend/pdf/pdfdocument.evince-backend.in b/backend/pdf/pdfdocument.evince-backend.in index 476afe33..04573343 100644 --- a/backend/pdf/pdfdocument.evince-backend.in +++ b/backend/pdf/pdfdocument.evince-backend.in @@ -1,5 +1,6 @@ [Evince Backend] Module=pdfdocument +Resident=true _TypeDescription=PDF Documents MimeType=application/pdf;application/x-bzpdf;application/x-gzpdf diff --git a/libdocument/ev-backends-manager.c b/libdocument/ev-backends-manager.c index 87f7fea4..28672dfc 100644 --- a/libdocument/ev-backends-manager.c +++ b/libdocument/ev-backends-manager.c @@ -30,6 +30,7 @@ typedef struct _EvBackendInfo EvBackendInfo; struct _EvBackendInfo { gchar *module_name; GTypeModule *module; + gboolean resident; GType type_id; @@ -78,6 +79,9 @@ ev_backends_manager_load_backend (const gchar *file) return NULL; } + info->resident = g_key_file_get_boolean (backend_file, EV_BACKENDS_GROUP, + "Resident", NULL); + info->type_desc = g_key_file_get_locale_string (backend_file, EV_BACKENDS_GROUP, "TypeDescription", NULL, NULL); if (!info->type_desc) { @@ -194,7 +198,7 @@ ev_backends_manager_get_document (const gchar *mime_type) gchar *path; path = g_module_build_path (EV_BACKENDSDIR, info->module_name); - info->module = G_TYPE_MODULE (ev_module_new (path)); + info->module = G_TYPE_MODULE (ev_module_new (path, info->resident)); g_free (path); } diff --git a/libdocument/ev-module.c b/libdocument/ev-module.c index f2aebe70..f9860a2f 100644 --- a/libdocument/ev-module.c +++ b/libdocument/ev-module.c @@ -54,6 +54,7 @@ struct _EvModule { GTypeModule parent_instance; GModule *library; + gboolean resident; gchar *path; GType type; @@ -106,6 +107,9 @@ ev_module_load (GTypeModule *gmodule) return FALSE; } + if (module->resident) + g_module_make_resident (module->library); + return TRUE; } @@ -175,7 +179,8 @@ ev_module_class_init (EvModuleClass *class) } EvModule * -ev_module_new (const gchar *path) +ev_module_new (const gchar *path, + gboolean resident) { EvModule *result; @@ -185,6 +190,7 @@ ev_module_new (const gchar *path) g_type_module_set_name (G_TYPE_MODULE (result), path); result->path = g_strdup (path); + result->resident = resident; return result; } diff --git a/libdocument/ev-module.h b/libdocument/ev-module.h index 4239cb11..09d46fa2 100644 --- a/libdocument/ev-module.h +++ b/libdocument/ev-module.h @@ -56,7 +56,8 @@ typedef struct _EvModule EvModule; GType ev_module_get_type (void) G_GNUC_CONST; -EvModule *ev_module_new (const gchar *path); +EvModule *ev_module_new (const gchar *path, + gboolean resident); const gchar *ev_module_get_path (EvModule *module); -- 2.43.5