[dia] introduce filter_import_get_by_name()



commit 8adf2075dbbf2be615d6398cea2edfcb66ab93d6
Author: Hans Breuer <hans breuer org>
Date:   Wed Oct 3 21:39:29 2012 +0200

    introduce filter_import_get_by_name()
    
    rename filter_get_by_name() to filter_export_get_by_name()

 app/app_procs.c |    8 ++++----
 lib/filter.c    |   22 ++++++++++++++++++++--
 lib/filter.h    |    6 ++++--
 lib/libdia.def  |    7 ++++---
 4 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/app/app_procs.c b/app/app_procs.c
index 71fd097..7fb5d97 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -370,7 +370,7 @@ do_convert(const char *infname,
    * are quite some filter selecting their output format by it. --hb
    */
   if (size) {
-    if (ef == filter_get_by_name ("png-libart")) /* the warning we get is appropriate, don't cast */
+    if (ef == filter_export_get_by_name ("png-libart")) /* the warning we get is appropriate, don't cast */
       ef->export_func(diagdata, ctx, outfname, infname, size);
     else {
       g_warning ("--size parameter unsupported for %s filter", 
@@ -547,11 +547,11 @@ handle_initial_diagram(const char *in_file_name,
 
     /* to make the --size hack even uglier but work again for the only filter supporting it */
     if (   size && strcmp(export_file_format, "png") == 0)
-      ef = filter_get_by_name ("png-libart");
+      ef = filter_export_get_by_name ("png-libart");
     if (!ef)
       ef = filter_guess_export_filter(export_file_name);
     if (ef == NULL) {
-      ef = filter_get_by_name(export_file_format);
+      ef = filter_export_get_by_name(export_file_format);
       if (ef == NULL) {
 	g_critical(_("Can't find output format/filter %s\n"), export_file_format);
 	return FALSE;
@@ -568,7 +568,7 @@ handle_initial_diagram(const char *in_file_name,
 
     /* if this looks like an ugly hack to you, agreed ;)  */
     if (size && strstr(out_file_name, ".png"))
-      ef = filter_get_by_name ("png-libart");
+      ef = filter_export_get_by_name ("png-libart");
     
     made_conversions |= do_convert(in_file_name, out_file_name, ef,
 				   size, show_layers);
diff --git a/lib/filter.c b/lib/filter.c
index 7f986a1..63c84e2 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -138,7 +138,7 @@ filter_guess_export_filter(const gchar *filename)
   /* maybe ther is no need to guess? */
   unique_name = _favored_hash ? g_hash_table_lookup(_favored_hash, ext) : NULL;
   if (unique_name) {
-    DiaExportFilter *ef = filter_get_by_name(unique_name);
+    DiaExportFilter *ef = filter_export_get_by_name(unique_name);
     if (ef)
       return ef;
   }
@@ -164,7 +164,7 @@ filter_guess_export_filter(const gchar *filename)
 /** Get an export filter by unique name.
  */
 DiaExportFilter *
-filter_get_by_name(const gchar *name) 
+filter_export_get_by_name(const gchar *name) 
 {
   GList *tmp;
   DiaExportFilter *filter = NULL;
@@ -181,6 +181,24 @@ filter_get_by_name(const gchar *name)
   }
   return filter;
 }
+DiaImportFilter *
+filter_import_get_by_name(const gchar *name) 
+{
+  GList *tmp;
+  DiaImportFilter *filter = NULL;
+
+  for (tmp = import_filters; tmp != NULL; tmp = tmp->next) {
+    DiaImportFilter *af = tmp->data;
+    if (af->unique_name != NULL) {
+      if (!g_ascii_strcasecmp(af->unique_name, name)) {
+	if (filter) 
+	  g_warning(_("Multiple import filters with unique name %s"), name);
+	filter = af;
+      }
+    }
+  }
+  return filter;
+}
 
 static gint
 import_filter_compare(gconstpointer a, gconstpointer b)
diff --git a/lib/filter.h b/lib/filter.h
index 9e30e9e..6c24411 100644
--- a/lib/filter.h
+++ b/lib/filter.h
@@ -104,8 +104,8 @@ gchar *filter_get_export_filter_label(DiaExportFilter *efilter);
 
 /* guess the filter for a given filename. */
 DiaExportFilter *filter_guess_export_filter(const gchar *filename);
-/* Get the filter for the unique filename. */
-DiaExportFilter *filter_get_by_name(const gchar *name);
+/* Get the filter for the unique filter name. */
+DiaExportFilter *filter_export_get_by_name(const gchar *name);
 /* Get the list of unique names for the given extension */
 GList *filter_get_unique_export_names(const char *extension);
 /* Set the favorit 'guess' */
@@ -116,6 +116,8 @@ void filter_unregister_import(DiaImportFilter *ifilter);
 GList *filter_get_import_filters(void);
 gchar *filter_get_import_filter_label(DiaImportFilter *ifilter);
 DiaImportFilter *filter_guess_import_filter(const gchar *filename);
+/* Get the filter for the unique filter name. */
+DiaImportFilter *filter_import_get_by_name(const gchar *name);
 
 void filter_register_callback(DiaCallbackFilter *cbfilter);
 /* returns all registered callbacks */
diff --git a/lib/libdia.def b/lib/libdia.def
index e325382..808dcd8 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -41,11 +41,11 @@ EXPORTS
  bezier_render_stroke
  bezier_render_fill
  beziercommon_set_points
+ beziercommon_closest_segment
 
  bezierconn_add_segment
  bezierconn_closest_handle
  bezierconn_closest_major_handle
- bezierconn_closest_segment
  bezierconn_copy
  bezierconn_destroy
  bezierconn_distance_from
@@ -62,7 +62,6 @@ EXPORTS
  beziershape_add_segment
  beziershape_closest_handle
  beziershape_closest_major_handle
- beziershape_closest_segment
  beziershape_copy
  beziershape_destroy
  beziershape_distance_from
@@ -424,7 +423,7 @@ EXPORTS
  ellipse_bbox
  element_change_new
 
- filter_get_by_name
+ filter_export_get_by_name
  filter_get_callbacks
  filter_get_export_filter_label
  filter_get_export_filters
@@ -434,6 +433,7 @@ EXPORTS
  filter_get_import_filters
  filter_guess_export_filter
  filter_guess_import_filter
+ filter_import_get_by_name
  filter_register_callback
  filter_register_export
  filter_register_import
@@ -680,6 +680,7 @@ EXPORTS
  prop_list_from_descs
  prop_list_from_single
 
+ point_in_rectangle
  rectangle_add_point
  rectangle_bbox
  rectangle_in_rectangle



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