dia r4297 - in trunk: . app lib



Author: sdteffen
Date: Wed Feb 25 22:38:31 2009
New Revision: 4297
URL: http://svn.gnome.org/viewvc/dia?rev=4297&view=rev

Log:
        * app/sheets_dialog_callbacks.c:
        * lib/libdia.def:
        * lib/sheet.c:
        * lib/dia_dirs.[ch]: Save relative path for icons in user
        * created
        sheets; allow icon loader to fall back to system directoy if
icon
        is not found in config directory; fixes bug #573027


Modified:
   trunk/ChangeLog
   trunk/app/sheets_dialog_callbacks.c
   trunk/lib/dia_dirs.c
   trunk/lib/dia_dirs.h
   trunk/lib/libdia.def
   trunk/lib/sheet.c

Modified: trunk/app/sheets_dialog_callbacks.c
==============================================================================
--- trunk/app/sheets_dialog_callbacks.c	(original)
+++ trunk/app/sheets_dialog_callbacks.c	Wed Feb 25 22:38:31 2009
@@ -1780,10 +1780,26 @@
 
     if (sheetobject->has_icon_on_sheet == TRUE)
     {
+      gchar *canonical_icon;
+      gchar *canonical_user_sheets;
+      gchar *canonical_sheets;
+      gchar *icon;
+
       xmlAddChild(object_node, xmlNewText((const xmlChar *)"\n"));
       icon_node = xmlNewChild(object_node, NULL, (const xmlChar *)"icon", NULL);
-      xmlAddChild(icon_node, xmlNewText((xmlChar *) sheetobject->pixmap_file));
+      canonical_icon = dia_get_canonical_path(sheetobject->pixmap_file);
+      icon = canonical_icon;
+      canonical_user_sheets = dia_get_canonical_path(dir_user_sheets);
+      canonical_sheets = dia_get_canonical_path(dia_get_data_directory("sheets"));
+      if(g_str_has_prefix(icon, canonical_user_sheets))
+        icon += strlen(canonical_user_sheets) + 1;
+      if(g_str_has_prefix(icon, canonical_sheets))
+        icon += strlen(canonical_sheets) + 1; 
+      xmlAddChild(icon_node, xmlNewText((xmlChar *) icon));
       xmlAddChild(object_node, xmlNewText((const xmlChar *)"\n"));
+      g_free(canonical_icon);
+      g_free(canonical_user_sheets);
+      g_free(canonical_sheets);
     }
   }
   xmlSetDocCompressMode(doc, 0);

Modified: trunk/lib/dia_dirs.c
==============================================================================
--- trunk/lib/dia_dirs.c	(original)
+++ trunk/lib/dia_dirs.c	Wed Feb 25 22:38:31 2009
@@ -152,7 +152,7 @@
  * @param path String to canonicalize.
  * @returns A newly allocated string, or NULL if too many ..'s were found
  */
-static gchar *
+gchar *
 dia_get_canonical_path(const gchar *path)
 {
   gchar  *ret = NULL;

Modified: trunk/lib/dia_dirs.h
==============================================================================
--- trunk/lib/dia_dirs.h	(original)
+++ trunk/lib/dia_dirs.h	Wed Feb 25 22:38:31 2009
@@ -32,6 +32,7 @@
 gchar *dia_config_filename    (const gchar* file);
 gboolean dia_config_ensure_dir  (const gchar* filename);
 gchar *dia_get_absolute_filename (const gchar *filename);
+gchar *dia_get_canonical_path (const gchar *path);
 const gchar *dia_message_filename (const gchar *filename);
 
 #endif /* DIA_DIRS_H */

Modified: trunk/lib/libdia.def
==============================================================================
--- trunk/lib/libdia.def	(original)
+++ trunk/lib/libdia.def	Wed Feb 25 22:38:31 2009
@@ -245,6 +245,7 @@
  dia_get_data_directory
  dia_get_lib_directory
  dia_get_absolute_filename
+ dia_get_canonical_path
 
  dia_image_add_ref
  dia_image_draw

Modified: trunk/lib/sheet.c
==============================================================================
--- trunk/lib/sheet.c	(original)
+++ trunk/lib/sheet.c	Wed Feb 25 22:38:31 2009
@@ -415,6 +415,13 @@
       } else if (subnode->ns == ns && !xmlStrcmp(subnode->name, (const xmlChar *)"icon")) {
           tmp = xmlNodeGetContent(subnode);
           iconname = g_strconcat(dirname,G_DIR_SEPARATOR_S, (char *) tmp,NULL);
+	  if(!shadowing_sheet && !g_file_test (iconname, G_FILE_TEST_EXISTS))
+          {
+	   /* Fall back to system directory if there is no user icon */
+            gchar *sheetdir = dia_get_data_directory("sheets");
+            iconname = g_strconcat(sheetdir,G_DIR_SEPARATOR_S, (char *) tmp,NULL);
+	    g_free(sheetdir);
+          }
           has_icon_on_sheet = TRUE;
           if (tmp) xmlFree(tmp);
       }



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