[evince/wip/bug654832: 11/18] [libdocument] Rename some internal functions



commit 161df3606060ac5e5f177f15e1eea7455161bd0e
Author: Christian Persch <chpe gnome org>
Date:   Sun Feb 14 15:06:22 2010 +0100

    [libdocument] Rename some internal functions

 libdocument/ev-document-factory.c |   82 +++++++++++++++++-------------------
 1 files changed, 39 insertions(+), 43 deletions(-)
---
diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c
index e8bac31..800efbd 100644
--- a/libdocument/ev-document-factory.c
+++ b/libdocument/ev-document-factory.c
@@ -41,19 +41,17 @@ static GList *ev_backends_list = NULL;
 static gchar *ev_backends_dir = NULL;
 
 static EvBackendInfo *
-ev_document_factory_get_backend_info_for_mime_type (const gchar *mime_type)
+get_backend_info_for_mime_type (const gchar *mime_type)
 {
         GList *l;
 
         for (l = ev_backends_list; l; l = l->next) {
-                EvBackendInfo *info;
-                gint           i = 0;
-                const char    *mime;
+                EvBackendInfo *info = (EvBackendInfo *) l->data;
+                char **mime_types = info->mime_types;
+                guint i;
 
-                info = (EvBackendInfo *)l->data;
-
-                while ((mime = info->mime_types[i++])) {
-                        if (g_ascii_strcasecmp (mime, mime_type) == 0)
+                for (i = 0; mime_types[i] != NULL; ++i) {
+                        if (g_ascii_strcasecmp (mime_type, mime_types[i]) == 0)
                                 return info;
                 }
         }
@@ -61,13 +59,34 @@ ev_document_factory_get_backend_info_for_mime_type (const gchar *mime_type)
         return NULL;
 }
 
+static EvBackendInfo *
+get_backend_info_for_document (EvDocument *document)
+{
+        GList *l;
+
+        for (l = ev_backends_list; l; l = l->next) {
+                EvBackendInfo *info = (EvBackendInfo *) l->data;
+                GType type;
+
+                if (!info->module)
+                        continue;
+
+                type = _ev_module_get_object_type (EV_MODULE (info->module));
+
+                if (G_TYPE_CHECK_INSTANCE_TYPE (document, type))
+                        return info;
+        }
+
+        return NULL;
+}
+
 EvDocument *
 ev_document_factory_new_document_for_mime_type (const gchar *mime_type)
 {
         EvDocument    *document;
         EvBackendInfo *info;
 
-        info = ev_document_factory_get_backend_info_for_mime_type (mime_type);
+        info = get_backend_info_for_mime_type (mime_type);
         if (!info)
                 return NULL;
 
@@ -97,30 +116,6 @@ ev_document_factory_new_document_for_mime_type (const gchar *mime_type)
         return document;
 }
 
-static EvBackendInfo *
-ev_document_factory_get_backend_for_document (EvDocument *document)
-{
-        GList *l;
-
-        for (l = ev_backends_list; l; l = l->next) {
-                EvBackendInfo *info;
-                GType          type_id;
-
-                info = (EvBackendInfo *)l->data;
-
-                if (!info->module)
-                        continue;
-
-                type_id = _ev_module_get_object_type (EV_MODULE (info->module));
-
-                if (G_TYPE_CHECK_INSTANCE_TYPE (document, type_id)) {
-                        return info;
-                }
-        }
-
-        return NULL;
-}
-
 static EvCompressionType
 get_compression_from_mime_type (const gchar *mime_type)
 {
@@ -144,7 +139,7 @@ get_compression_from_mime_type (const gchar *mime_type)
 
 
 /*
- * get_document_from_uri:
+ * new_document_for_uri:
  * @uri: the document URI
  * @fast: whether to use fast MIME type detection
  * @compression: a location to store the document's compression type
@@ -158,10 +153,10 @@ get_compression_from_mime_type (const gchar *mime_type)
  * Returns: a new #EvDocument instance, or %NULL on error with @error filled in
  */
 static EvDocument *
-get_document_from_uri (const char        *uri,
-		       gboolean           fast,
-		       EvCompressionType *compression,
-		       GError           **error)
+new_document_for_uri (const char        *uri,
+                      gboolean           fast,
+                      EvCompressionType *compression,
+                      GError           **error)
 {
 	EvDocument *document = NULL;
 	gchar      *mime_type = NULL;
@@ -296,7 +291,7 @@ ev_document_factory_get_document (const char *uri, GError **error)
 
 	g_return_val_if_fail (uri != NULL, NULL);
 
-	document = get_document_from_uri (uri, TRUE, &compression, &err);
+	document = new_document_for_uri (uri, TRUE, &compression, &err);
 	g_assert (document != NULL || err != NULL);
 
 	if (document != NULL) {
@@ -334,7 +329,7 @@ ev_document_factory_get_document (const char *uri, GError **error)
 	g_clear_error (&err);
 	uri_unc = NULL;
 
-	document = get_document_from_uri (uri, FALSE, &compression, &err);
+	document = new_document_for_uri (uri, FALSE, &compression, &err);
 	if (document == NULL) {
 		g_assert (err != NULL);
 		g_propagate_error (error, err);
@@ -425,7 +420,8 @@ ev_document_factory_add_filters (GtkWidget *chooser, EvDocument *document)
 	if (document) {
 		EvBackendInfo *info;
 
-		info = ev_document_factory_get_backend_for_document (document);
+		info = get_backend_info_for_document (document);
+                g_assert (info != NULL);
 		default_filter = filter = gtk_file_filter_new ();
 		gtk_file_filter_set_name (filter, info->type_desc);
 		file_filter_add_mime_types (info, filter);
@@ -463,7 +459,7 @@ EvDocument  *ev_backends_manager_get_document (const gchar *mime_type)
 const gchar *
 ev_backends_manager_get_document_module_name (EvDocument  *document)
 {
-        EvBackendInfo *info = ev_document_factory_get_backend_for_document (document);
+        EvBackendInfo *info = get_backend_info_for_document (document);
         if (info == NULL)
                 return NULL;
 
@@ -472,7 +468,7 @@ ev_backends_manager_get_document_module_name (EvDocument  *document)
 
 EvTypeInfo *ev_backends_manager_get_document_type_info (EvDocument  *document)
 {
-        return (EvTypeInfo *) ev_document_factory_get_backend_for_document (document);
+        return (EvTypeInfo *) get_backend_info_for_document (document);
 }
 
 GList *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]