[glom] examples: Add a static image item to the Project Manager example.



commit 0a9fccb4d16bd0f0032c4a6ae92c46c4f6200b54
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Nov 11 18:41:01 2012 +0100

    examples: Add a static image item to the Project Manager example.
    
            * examples/example_project_manager.glom: This is just so we
    use this layout item somewhere, so we can test it.
            * glom/glom_document.dtd: Mention the layout_item_image tag.
    * configure.ac:
    * Makefile_tests.am:
    * tests/test_document_load_image.cc: Add a new test for this
    feature, using GdkPixbufLoader to check that we can interpret
    the data as an image.

 ChangeLog                             |   13 +++
 Makefile_tests.am                     |    6 ++
 configure.ac                          |    2 +
 examples/example_project_manager.glom |   10 +--
 glom/glom_document.dtd                |   14 +++-
 glom/libglom/document/document.cc     |   16 +++-
 tests/test_document_load_image.cc     |  131 +++++++++++++++++++++++++++++++++
 7 files changed, 176 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5e22f57..1fb6481 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-11-11  Murray Cumming  <murrayc murrayc com>
+
+        examples: Add a static image item to the Project Manager example.
+
+        * examples/example_project_manager.glom: This is just so we 
+	use this layout item somewhere, so we can test it.
+        * glom/glom_document.dtd: Mention the layout_item_image tag.
+	* configure.ac:
+	* Makefile_tests.am:
+	* tests/test_document_load_image.cc: Add a new test for this
+	feature, using GdkPixbufLoader to check that we can interpret
+	the data as an image.
+
 2012-11-10  Murray Cumming  <murrayc murrayc com>
 
         Resave all the examples in the latest file format.
diff --git a/Makefile_tests.am b/Makefile_tests.am
index 67420ea..5736911 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -22,6 +22,7 @@ check_PROGRAMS =						\
 	tests/test_document_load			\
 	tests/test_document_load_and_change		\
 	tests/test_document_load_and_save		\
+	tests/test_document_load_image			\
 	tests/test_document_load_translations		\
 	tests/test_document_change			\
 	tests/test_document_autosave			\
@@ -56,6 +57,7 @@ check_PROGRAMS =						\
 TESTS =	tests/test_document_load	\
 	tests/test_document_load_and_change	\
 	tests/test_document_load_and_save_all.sh \
+	tests/test_document_load_image \
 	tests/test_document_load_translations	\
 	tests/test_document_change	\
 	tests/test_document_autosave	\
@@ -132,6 +134,10 @@ tests_test_document_load_and_save_SOURCES = tests/test_document_load_and_save.cc
 tests_test_document_load_and_save_LDADD = $(tests_ldadd)
 tests_test_document_load_and_save_CPPFLAGS = $(tests_cppflags)
 
+tests_test_document_load_image_SOURCES = tests/test_document_load_image.cc
+tests_test_document_load_image_LDADD = $(tests_ldadd) $(GDKMM_LIBS)
+tests_test_document_load_image_CPPFLAGS = $(tests_cppflags) $(GDKMM_CFLAGS)
+
 tests_test_document_load_translations_SOURCES = tests/test_document_load_translations.cc
 tests_test_document_load_translations_LDADD = $(tests_ldadd)
 tests_test_document_load_translations_CPPFLAGS = $(tests_cppflags)
diff --git a/configure.ac b/configure.ac
index e1a6120..e33776a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -175,6 +175,8 @@ MM_PKG_CONFIG_SUBST([ISO_CODES_PREFIX], [--variable=prefix iso-codes])
 AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX], ["$ISO_CODES_PREFIX"],
                    [Define to the installation prefix of the iso-codes module.])
 
+# This is used in one test:
+PKG_CHECK_MODULES([GDKMM], [gdkmm-3.0 >= 3.4.0])
 
 # Allow use of mm-common macros for the warnings option and for installing developer documentation.
 MM_PREREQ([0.9.5])
diff --git a/examples/example_project_manager.glom b/examples/example_project_manager.glom
index 12d1b92..4758a08 100644
--- a/examples/example_project_manager.glom
+++ b/examples/example_project_manager.glom
@@ -1013,6 +1013,7 @@
             <data_layout_item name="name" editable="true" use_default_formatting="true">
               <formatting/>
             </data_layout_item>
+            <data_layout_image text="iVBORw0KGgoAAAANSUhEUgAAAMYAAAAXCAYAAABQ+TDXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAEOwAABDsBSyyCPQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9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Ae8ilSj+iALRimlgMZlwH3KUq3H3MBnN6SfKoWZSGPczkjx40JgRcZ9pZgDjEDChasy6JciK+Ygnj3VqvI50rxZoHfGOyYg4VZnpC8qhTVIPtiHqMpUAdORcKsLwv81NK+KVxved7Az6u3Si9WIWxyExK+5YUqMmcB1zqhHonM53uJFZ9RhoadlCNL/FON94HVgHFIiXA2grT8BsQpNLUR9AcxDJmixzUAW25YWRNr6uD1hBRIC1iHWqkjGxzujJkZ0Q5GqRdwZsAQpBU9B+rWej6pr1yO9R/uzXgkXApOAt5EWhhdL+L9DWz8WuBxJ3EsXOeuRlfx5SMj0WnjOtPDOVqxPRmsQBSi6aDsiVrsK6XZeFugujeiLrtvWiLUvZBHnWQDXIyv/cWFhfhjXRKSdo2GyaeuvAu6jcWhdj5RmJyFJ74Oh1Iq2flMkMikqj7VIyXwqIutxoWoX41pt/SjE+51F0+0gK8P7XkYaDuc1QQNEbedhtbVjEEjRqr1FYKrc9nHUjlA8p2sYcKrC0c8Z1VC7DyuW3ZHYdVLcMt0UQql1R6TXZREwN/rYFREW6VY
 CK0rLpCG0aAfUxcoUrrVBrGVbYHrRdp14VyckBp7mjPokh79wXzXiIXdDJuwHwPzS0mQTvG8DLC0MSRPX2wOrnFGrwjfvBCwpQ18d6FeUXg/l+r2RcGayM2pRxpiKfrU1wBRnVFnvGJR8F2TBbk6lcTdxbxUyl3ohBm85kkfMiJPzSij7e4wvC239rWzYelGK2UCP0knZghZ8U/CV/vorsegXY2SLUrTgm4yv+p8hnI7EsPNZ/0ur1UhsW/xKDzZsLWlBC75R+B+JXytNe7HN7AAAAABJRU5ErkJggg=="/>
           </data_layout_group>
           <data_layout_group name="details" columns_count="2" title="Details">
             <trans_set>
@@ -1811,14 +1812,7 @@
       <table_privs table_name="team_members" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
       <table_privs table_name="teams" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
     </group>
-    <group name="glom_developer">
-      <table_privs table_name="contacts" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
-      <table_privs table_name="glom_system_preferences" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
-      <table_privs table_name="projects" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
-      <table_privs table_name="project_teams" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
-      <table_privs table_name="team_members" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
-      <table_privs table_name="teams" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
-    </group>
+    <group name="glom_developer" developer="true"/>
     <group name="personnel_department">
       <table_privs table_name="contacts" priv_view="true" priv_edit="true" priv_create="true" priv_delete="true"/>
       <table_privs table_name="glom_system_preferences" priv_view="true" priv_edit="true"/>
diff --git a/glom/glom_document.dtd b/glom/glom_document.dtd
index e884016..9c6ae7e 100644
--- a/glom/glom_document.dtd
+++ b/glom/glom_document.dtd
@@ -222,7 +222,7 @@ TODO: Should we specify the presence of child text nodes in the ELEMENT somehow?
 <!-- A data_layout_group is is a list of layout items. It can contain sub-groups. -->
 
     <!-- TODO: The comma separator specifies a fixed child node sequence, but we don't want to enforce that. -->
-    <!ELEMENT data_layout_group (trans_set?, (data_layout_group | data_layout_item | data_layout_portal | data_layout_calendar_portal | data_layout_item_groupby | data_layout_button | data_layout_notebook | data_layout_item_header | data_layout_text)*)>
+    <!ELEMENT data_layout_group (trans_set?, (data_layout_group | data_layout_item | data_layout_portal | data_layout_calendar_portal | data_layout_item_groupby | data_layout_button | data_layout_notebook | data_layout_item_header | data_layout_text | data_layout_image)*)>
     <!ATTLIST data_layout_group
         name CDATA #IMPLIED
         title CDATA #IMPLIED
@@ -248,12 +248,20 @@ TODO: Should we specify the presence of child text nodes in the ELEMENT somehow?
         columns_count CDATA #IMPLIED
         border_width CDATA #IMPLIED>
 
-<!-- data_layout_text and text are for displaying text. -->
-
+<!-- data_layout_text displays static text (text that is not from the database). -->
     <!ELEMENT data_layout_text (text?, formatting?, position?)>
     <!ATTLIST data_layout_text
         sequence CDATA #IMPLIED>
 
+<!-- data_layout_image displays a static image (an image that is not from the database).
+     The text attribute is the base64-encoded image data (if format="base64". Otherwise it is the deprecated GDA image text format.) -->
+    <!ELEMENT data_layout_image (formatting?, position?)>
+    <!ATTLIST data_layout_image
+        text CDATA #IMPLIED
+        title CDATA #IMPLIED
+        sequence CDATA #IMPLIED>
+
+<!-- The text tag contains the text of a data_layout_text, and its translations. TODO: Add the translations. -->
     <!ELEMENT text EMPTY>
     <!ATTLIST text
         title CDATA #REQUIRED>
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index edaa3a1..122633f 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -101,7 +101,7 @@ static const char GLOM_NODE_DATA_LAYOUT_BUTTON[] = "data_layout_button";
 static const char GLOM_NODE_DATA_LAYOUT_TEXTOBJECT[] = "data_layout_text";
 static const char GLOM_NODE_DATA_LAYOUT_TEXTOBJECT_TEXT[] = "text";
 static const char GLOM_NODE_DATA_LAYOUT_IMAGEOBJECT[] = "data_layout_image";
-static const char GLOM_ATTRIBUTE_DATA_LAYOUT_IMAGEOBJECT_IMAGE[] = "text";
+static const char GLOM_ATTRIBUTE_DATA_LAYOUT_IMAGEOBJECT_IMAGE[] = "text"; //TODO: Deprecate this and replace it with "image"
 static const char GLOM_NODE_DATA_LAYOUT_LINE[] = "data_layout_line";
 static const char GLOM_ATTRIBUTE_DATA_LAYOUT_LINE_START_X[] = "start_x";
 static const char GLOM_ATTRIBUTE_DATA_LAYOUT_LINE_START_Y[] = "start_y";
@@ -4432,13 +4432,19 @@ void Document::fill_translatable_layout_items(const sharedptr<LayoutGroup>& grou
       //Buttons too:
       sharedptr<LayoutItem_Button> button = sharedptr<LayoutItem_Button>::cast_dynamic(item);
       if(button)
-        the_list.push_back( pair_translatable_item_and_hint(button, this_hint) ); 
+        the_list.push_back( pair_translatable_item_and_hint(button, this_hint) );
       else
       {
-        sharedptr<LayoutItem_Field> layout_field = sharedptr<LayoutItem_Field>::cast_dynamic(item);
-        if(layout_field)
+        sharedptr<LayoutItem_Text> text = sharedptr<LayoutItem_Text>::cast_dynamic(item);
+        if(text)
+          the_list.push_back( pair_translatable_item_and_hint(text, this_hint) );
+        else
         {
-          fill_translatable_layout_items(layout_field, the_list, hint);
+          sharedptr<LayoutItem_Field> layout_field = sharedptr<LayoutItem_Field>::cast_dynamic(item);
+          if(layout_field)
+          {
+            fill_translatable_layout_items(layout_field, the_list, hint);
+          }
         }
       }
     }
diff --git a/tests/test_document_load_image.cc b/tests/test_document_load_image.cc
new file mode 100644
index 0000000..d27b16f
--- /dev/null
+++ b/tests/test_document_load_image.cc
@@ -0,0 +1,131 @@
+/* Glom
+ *
+ * Copyright (C) 2010 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+71 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
+#include "tests/test_utils.h"
+#include <libglom/document/document.h>
+#include <libglom/init.h>
+#include <libglom/db_utils.h>
+#include <giomm/file.h>
+#include <glibmm/convert.h>
+#include <glibmm/miscutils.h>
+#include <gdkmm/wrap_init.h> //TODO: Add a Gdk::init() to gtkmm.
+#include <gdkmm/pixbufloader.h>
+
+#include <iostream>
+ 
+int main()
+{
+  Glom::libglom_init();
+
+  // Get a URI for a test file:
+  Glib::ustring uri;
+
+  try
+  {
+    const std::string path =
+       Glib::build_filename(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED,
+   "example_project_manager.glom");
+    uri = Glib::filename_to_uri(path);
+  }
+  catch(const Glib::ConvertError& ex)
+  {
+    std::cerr << G_STRFUNC << ": " << ex.what();
+    return EXIT_FAILURE;
+  }
+
+  //std::cout << "URI=" << uri << std::endl;
+
+
+  // Load the document:
+  Glom::Document document;
+  document.set_file_uri(uri);
+  int failure_code = 0;
+  const bool test = document.load(failure_code);
+  //std::cout << "Document load result=" << test << std::endl;
+
+  if(!test)
+  {
+    std::cerr << "Document::load() failed with failure_code=" << failure_code << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  //Test some known details:
+  g_assert(document.get_is_example_file());
+  g_assert(document.get_database_title_original() == "Project Manager Example");
+
+  //Check a layout:
+  const Glom::Document::type_list_layout_groups groups = 
+    document.get_data_layout_groups("details", "projects");
+  g_assert(groups.size() == 3);
+  const Glom::sharedptr<const Glom::LayoutGroup> group =
+    groups[0];
+  g_assert(group);
+  g_assert(group->get_name() == "overview");
+
+  const Glom::LayoutGroup::type_list_const_items items = 
+    group->get_items();
+  //std::cout << "size: " << items.size() << std::endl;
+  g_assert(items.size() == 3);
+  Glom::sharedptr<const Glom::LayoutItem> item = items[2];
+  g_assert(item);
+  Glom::sharedptr<const Glom::LayoutItem_Image> image_item =
+    Glom::sharedptr<const Glom::LayoutItem_Image>::cast_dynamic(item);
+  g_assert(image_item);
+
+  const Gnome::Gda::Value value = image_item->get_image();
+  g_assert(!value.is_null());
+  g_assert(value.get_value_type() == GDA_TYPE_BINARY);
+  long data_length = 0;
+  const guchar* data = value.get_binary(data_length);
+  g_assert(data);
+  g_assert(data_length);
+
+  //Check that it can be interpreted as an image:
+  //Luckily, the use of GdkPixbufLoader here does not seem to require an X display.
+  Gdk::wrap_init();
+  Glib::RefPtr<Gdk::PixbufLoader> refPixbufLoader;      
+  try
+  {
+    refPixbufLoader = Gdk::PixbufLoader::create();
+  }
+  catch(const Gdk::PixbufError& ex)
+  {
+    std::cerr << "PixbufLoader::create failed: " << ex.what() << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+  guint8* puiData = (guint8*)data;
+  try
+  {
+    refPixbufLoader->write(puiData, static_cast<gsize>(data_length));
+    pixbuf = refPixbufLoader->get_pixbuf();
+    refPixbufLoader->close(); //This throws if write() threw, so it must be inside the try block.
+  }
+  catch(const Glib::Exception& ex)
+  {
+    std::cerr << "PixbufLoader::write() failed: " << ex.what() << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  Glom::libglom_deinit();
+
+  return EXIT_SUCCESS;
+}



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