Verified Commit aa9d87bc authored by Zander's avatar Zander 💥

Bundle UML alias icons in gresource

parent 19b9657b
......@@ -268,7 +268,11 @@ fill_sheet_wbox(Sheet *sheet)
ToolButtonData *data;
if (sheet_obj->pixmap != NULL) {
pixbuf = gdk_pixbuf_new_from_xpm_data (sheet_obj->pixmap);
if (g_str_has_prefix ((const char *) sheet_obj->pixmap, "res:")) {
pixbuf = pixbuf_from_resource ((const char *) sheet_obj->pixmap + 4);
} else {
pixbuf = gdk_pixbuf_new_from_xpm_data (sheet_obj->pixmap);
}
} else if (sheet_obj->pixmap_file != NULL) {
GError* gerror = NULL;
......
......@@ -402,6 +402,8 @@ load_register_sheet (const gchar *dirname,
xmlChar *ot_name = NULL;
gchar *sheetdir = dia_get_data_directory ("sheets");
if (xmlIsBlankNode (node)) {
continue;
}
......@@ -474,18 +476,20 @@ load_register_sheet (const gchar *dirname,
objdesc = xmlNodeGetContent (subnode);
}
} 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);
tmp = xmlNodeGetContent (subnode);
if (g_str_has_prefix ((char *) tmp, "res:")) {
iconname = g_strdup ((char *) tmp);
} else {
iconname = g_build_filename (dirname, (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);
iconname = g_build_filename (sheetdir, (char *) tmp, NULL);
}
}
has_icon_on_sheet = TRUE;
if (tmp) {
xmlFree (tmp);
}
} else if (subnode->ns == ns && !xmlStrcmp (subnode->name, (const xmlChar *) "alias")) {
if (ot_name) {
object_register_alias_type (object_get_type ((char *) ot_name), subnode);
......@@ -493,17 +497,25 @@ load_register_sheet (const gchar *dirname,
}
}
g_free (sheetdir);
sheet_obj = g_new (SheetObject, 1);
sheet_obj->object_type = g_strdup ((char *) ot_name);
sheet_obj->description = g_strdup ((gchar *)objdesc);
sheet_obj->description = g_strdup ((char *) objdesc);
xmlFree (objdesc);
objdesc = NULL;
sheet_obj->pixmap = NULL;
sheet_obj->user_data = GINT_TO_POINTER (intdata); /* XXX modify user_data type ? */
sheet_obj->user_data_type = has_intdata ? USER_DATA_IS_INTDATA /* sure, */
: USER_DATA_IS_OTHER; /* why not */
sheet_obj->pixmap_file = iconname;
if (iconname && g_str_has_prefix (iconname, "res:")) {
// Apparently we hate the world
sheet_obj->pixmap = (const char **) iconname;
sheet_obj->pixmap_file = NULL;
} else {
sheet_obj->pixmap = NULL;
sheet_obj->pixmap_file = iconname;
}
sheet_obj->has_icon_on_sheet = has_icon_on_sheet;
sheet_obj->line_break = set_line_break;
set_line_break = FALSE;
......@@ -524,7 +536,8 @@ load_register_sheet (const gchar *dirname,
}
/* set defaults */
if (sheet_obj->pixmap_file == NULL) {
if (sheet_obj->pixmap_file == NULL &&
sheet_obj->pixmap == NULL) {
g_assert (otype->pixmap || otype->pixmap_file);
sheet_obj->pixmap = otype->pixmap;
sheet_obj->pixmap_file = otype->pixmap_file;
......
......@@ -783,8 +783,10 @@ pixbuf_from_resource (const gchar *path)
bytes = g_resources_lookup_data (path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
if (!bytes)
if (!bytes) {
g_critical ("Missing resource %s", path);
goto out;
}
loader = gdk_pixbuf_loader_new ();
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/Dia/UML">
<file>umlclass_template.png</file>
<file>aggregation.png</file>
<file>receptacle.png</file>
<file>eventsource.png</file>
<file>eventsink.png</file>
</gresource>
</gresources>
......@@ -36,6 +36,10 @@ sources = files(
'umlformalparameter.c'
)
sources += gnome.compile_resources('dia-uml-resources', 'dia-uml.gresource.xml',
source_dir : '.',
c_name : 'dia_uml')
dia_object_desc += {
'name': 'uml_objects',
'sources': sources,
......
......@@ -8,7 +8,7 @@
</object>
<object name="UML - Class" intdata="1">
<_description>Template class</_description>
<icon>UML/umlclass_template.png</icon>
<icon>res:/org/gnome/Dia/UML/umlclass_template.png</icon>
</object>
<object name="UML - Note">
<_description>Note</_description>
......@@ -27,7 +27,7 @@
</object>
<object name="UML - Association" intdata="1">
<_description>Aggregation, one class is part of another</_description>
<icon>UML/aggregation.png</icon>
<icon>res:/org/gnome/Dia/UML/aggregation.png</icon>
</object>
<object name="UML - Implements">
<_description>Implements, class implements a specific interface</_description>
......@@ -64,15 +64,15 @@
</object>
<object name="UML - Component Feature" intdata="1">
<_description>Receptacle</_description>
<icon>UML/receptacle.png</icon>
<icon>res:/org/gnome/Dia/UML/receptacle.png</icon>
</object>
<object name="UML - Component Feature" intdata="2">
<_description>Event Source</_description>
<icon>UML/eventsource.png</icon>
<icon>res:/org/gnome/Dia/UML/eventsource.png</icon>
</object>
<object name="UML - Component Feature" intdata="3">
<_description>Event Sink</_description>
<icon>UML/eventsink.png</icon>
<icon>res:/org/gnome/Dia/UML/eventsink.png</icon>
</object>
<object name="UML - Node">
<_description>Node</_description>
......
sheetsdir = join_paths(pkgdatadir, 'sheets')
sheet_icons_sources = [
'UML/umlclass_template.png',
'UML/aggregation.png',
'UML/receptacle.png',
'UML/eventsource.png',
'UML/eventsink.png',
'ER/weakentity.png',
'GRAFCET/etapei.png',
'GRAFCET/etapems.png',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment