Commit 52b3ee97 authored by Murray Cumming's avatar Murray Cumming Committed by Murray Cumming
Browse files

Remove the gtkmm dependency from libglom.

2009-03-30  Murray Cumming  <murrayc@murrayc.com>

* configure.ac: Remove the gtkmm dependency from libglom.

* glom/libglom/Makefile.am:
* glom/bakery/Makefile.am:
* glom/libglom/busy_cursor.[h|cc]: Moved this to glom/bakery/.

* glom/libglom/data_structure/glomconversions.[h|cc]:
Moved get_pixbuf_for_gda_value() to glom/utils_ui.[h|cc].

* glom/libglom/*.[h|cc]: Adapted, and removed any gtkmm or gdkmm headers.

svn path=/trunk/; revision=2035
parent 66d86ee5
2009-03-30 Murray Cumming <murrayc@murrayc.com>
* configure.ac: Remove the gtkmm dependency from libglom.
* glom/libglom/Makefile.am:
* glom/bakery/Makefile.am:
* glom/libglom/busy_cursor.[h|cc]: Moved this to glom/bakery/.
* glom/libglom/data_structure/glomconversions.[h|cc]:
Moved get_pixbuf_for_gda_value() to glom/utils_ui.[h|cc].
* glom/libglom/*.[h|cc]: Adapted, and removed any gtkmm or gdkmm headers.
2009-03-30 Murray Cumming <murrayc@murrayc.com>
 
* glom/glade_utils.cc: Added missing file to fix the build.
......
......@@ -105,7 +105,7 @@ if test "$enable_postgresql" = "yes"; then
fi
# Libraries used by libglom:
REQUIRED_LIBGLOM_LIBS="gtkmm-2.4 >= 2.14 gthread-2.0 libxml++-2.6 pygda-4.0 >= 2.25.3 pygtk-2.0 >= 2.6.0 libgdamm-4.0 >= 3.99.14 libgda-4.0 >= 4.0.0 libgda-postgres-4.0"
REQUIRED_LIBGLOM_LIBS="giomm-2.4 gthread-2.0 libxml++-2.6 pygda-4.0 >= 2.25.3 pygtk-2.0 >= 2.6.0 libgdamm-4.0 >= 3.99.14 libgda-4.0 >= 4.0.0 libgda-postgres-4.0"
if test "$enable_maemo" = "yes"; then
REQUIRED_LIBGLOM_LIBS="$REQUIRED_LIBGLOM_LIBS ibepc-1.0 >= 0.3.1 avahi-ui";
......
......@@ -889,7 +889,7 @@ void App_Glom::init_create_document()
{
Document_Glom* document_glom = new Document_Glom();
m_pDocument = document_glom;
document_glom->set_parent_window(this); //So that it can show a BusyCursor when loading and saving.
//document_glom->set_parent_window(this); //So that it can show a BusyCursor when loading and saving.
//Tell document about view:
m_pDocument->set_view(m_pFrame);
......
AM_CPPFLAGS = -I@top_srcdir@/ -I@top_srcdir@/glom $(GLOM_CFLAGS) $(GLOM_WARNING_FLAGS)
h_sources = app_withdoc.h app.h app_withdoc_gtk.h dialog_offersave.h
cc_sources = app_withdoc.cc app.cc app_withdoc_gtk.cc dialog_offersave.cc
h_sources = app_withdoc.h app.h app_withdoc_gtk.h dialog_offersave.h busy_cursor.h
cc_sources = app_withdoc.cc app.cc app_withdoc_gtk.cc dialog_offersave.cc busy_cursor.cc
noinst_LIBRARIES = libbakery_app.a
libbakery_app_a_SOURCES = $(h_sources) $(cc_sources)
......
#include <libglom/busy_cursor.h>
#include <glom/bakery/busy_cursor.h>
#include <gtkmm/main.h>
#include <gtk/gtk.h>
......
......@@ -34,7 +34,7 @@
#include <libglom/utils.h>
#include <libglom/calcinprogress.h>
#include <libglom/document/bakery/view/view.h>
#include <libglom/busy_cursor.h>
#include <glom/bakery/busy_cursor.h>
namespace Glom
{
......
......@@ -27,8 +27,7 @@
#include <libglom/document/document_glom.h>
#include <libglom/connectionpool.h>
#include <libglom/appstate.h>
#include "base_db.h"
#include <libglom/busy_cursor.h>
#include <glom/base_db.h>
#include <gtkmm/builder.h>
namespace Glom
......
......@@ -22,7 +22,7 @@
#include "box_withbuttons.h" //For Box_WithButtons::connect_to_server().
#include <libglom/standard_table_prefs_fields.h>
#include <libglom/data_structure/glomconversions.h>
#include <libglom/busy_cursor.h>
#include <glom/bakery/busy_cursor.h>
#include <glibmm/i18n.h>
namespace Glom
......
......@@ -26,7 +26,6 @@ h_sources_public = libglom_config.h \
appstate.h
h_sources = $(h_sources_public) \
busy_cursor.h \
calcinprogress.h \
connectionpool.h \
spawn_with_feedback.h \
......@@ -34,7 +33,6 @@ h_sources = $(h_sources_public) \
gst-package.h
cc_sources = appstate.cc \
busy_cursor.cc \
calcinprogress.cc \
connectionpool.cc \
spawn_with_feedback.cc \
......
......@@ -21,13 +21,10 @@
#include <libglom/libglom_config.h> // For HAVE_STRPTIME
#include <libgda/gda-blob-op.h> // For gda_blob_op_read_all()
#include "glomconversions.h"
#include <libglom/connectionpool.h>
#include <libglom/utils.h>
#include <gdkmm/pixbufloader.h>
#include <libglom/data_structure/layout/layoutitem_image.h> // For GLOM_IMAGE_FORMAT
#include <glibmm/i18n.h>
#include <sstream> //For stringstream
......@@ -978,102 +975,5 @@ Gnome::Gda::Value Conversions::convert_value(const Gnome::Gda::Value& value, Fie
return value;
}
Glib::RefPtr<Gdk::Pixbuf> Conversions::get_pixbuf_for_gda_value(const Gnome::Gda::Value& value)
{
Glib::RefPtr<Gdk::Pixbuf> result;
if(value.get_value_type() == GDA_TYPE_BINARY || value.get_value_type() == GDA_TYPE_BLOB)
{
glong buffer_binary_length;
gconstpointer buffer_binary;
if(value.get_value_type() == GDA_TYPE_BLOB)
{
const GdaBlob* blob = value.get_blob();
if(gda_blob_op_read_all(blob->op, const_cast<GdaBlob*>(blob)))
{
buffer_binary_length = blob->data.binary_length;
buffer_binary = blob->data.data;
}
else
{
buffer_binary_length = 0;
buffer_binary = NULL;
g_warning("Conversions::get_pixbuf_for_gda_value(): Failed to read BLOB data");
}
}
else
{
buffer_binary = value.get_binary(buffer_binary_length);
}
/* Note that this is regular binary data, not escaped text representing the binary data: */
if(buffer_binary && buffer_binary_length)
{
//typedef std::list<Gdk::PixbufFormat> type_list_formats;
//const type_list_formats formats = Gdk::Pixbuf::get_formats();
//std::cout << "Debug: Supported pixbuf formats:" << std::endl;
//for(type_list_formats::const_iterator iter = formats.begin(); iter != formats.end(); ++iter)
//{
// std::cout << " name=" << iter->get_name() << ", writable=" << iter->is_writable() << std::endl;
//}
Glib::RefPtr<Gdk::PixbufLoader> refPixbufLoader;
try
{
refPixbufLoader = Gdk::PixbufLoader::create(GLOM_IMAGE_FORMAT);
}
catch(const Gdk::PixbufError& ex)
{
refPixbufLoader.reset();
std::cerr << "PixbufLoader::create failed: " << ex.what() << std::endl;
}
if(refPixbufLoader)
{
guint8* puiData = (guint8*)buffer_binary;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
//g_warning("ImageGlom::set_value(): debug: from db: ");
//for(int i = 0; i < 10; ++i)
// g_warning("%02X (%c), ", (guint8)puiData[i], (char)puiData[i]);
refPixbufLoader->write(puiData, (glong)buffer_binary_length);
result = refPixbufLoader->get_pixbuf();
refPixbufLoader->close(); //This throws if write() threw, so it must be inside the try block.
}
#else
std::auto_ptr<Glib::Error> error;
refPixbufLoader->write(puiData, (glong)buffer_binary_length, error);
if(error.get() == NULL)
{
result = refPixbufLoader->get_pixbuf();
refPixbufLoader->close(error);
}
#endif
#ifdef GLIBMM_EXCEPTIONS_ENABLED
catch(const Glib::Exception& ex)
{
#else
if(error.get() != NULL)
{
const Glib::Exception& ex = *error.get();
#endif
g_warning("Conversions::get_pixbuf_for_gda_value(): PixbufLoader::write() failed: %s", ex.what().c_str());
}
}
//TODO: load the image, using the mime type stored elsewhere.
//pixbuf = Gdk::Pixbuf::create_from_data(
}
}
return result;
}
} //namespace Glom
......@@ -26,7 +26,6 @@
#include <libglom/data_structure/layout/layoutitem_field.h>
#include <libxml++/libxml++.h>
#include <gdkmm/pixbuf.h>
namespace Glom
{
......@@ -81,10 +80,8 @@ namespace Conversions
Gnome::Gda::Value get_example_value(Field::glom_field_type field_type);
Gnome::Gda::Value convert_value(const Gnome::Gda::Value& value, Field::glom_field_type target_glom_type);
Glib::RefPtr<Gdk::Pixbuf> get_pixbuf_for_gda_value(const Gnome::Gda::Value& value);
}
} //namespace Conversions
} //namespace Glom
......
......@@ -23,7 +23,6 @@
#include "layoutitem.h"
#include <libgdamm/value.h>
#include <gdkmm/pixbuf.h>
namespace Glom
{
......
......@@ -33,8 +33,7 @@
#include <libglom/data_structure/layout/layoutitem_line.h>
#include <libglom/standard_table_prefs_fields.h>
#include <giomm.h>
#include <libglom/busy_cursor.h>
#include <gtkmm/pagesetup.h>
//#include <libglom/busy_cursor.h>
#include <libglom/connectionpool.h>
......@@ -243,8 +242,7 @@ Document_Glom::Document_Glom()
m_allow_auto_save(true), //Save all changes immediately, by default.
#endif // !GLOM_ENABLE_CLIENT_ONLY
m_is_example(false),
m_opened_from_browse(false),
m_parent_window(0)
m_opened_from_browse(false)
{
m_document_format_version = get_latest_known_document_format_version(); //Default to this for new documents.
......@@ -2296,12 +2294,15 @@ void Document_Glom::load_after_print_layout_position(const xmlpp::Element* nodeI
bool Document_Glom::load_after()
{
//TODO: Use some callback UI to show a busy cursor?
/*
//Use a std::auto_ptr<> to avoid even unncessarily instantiating a BusyCursor,
//which would require GTK+ to be initialized:
std::auto_ptr<BusyCursor> auto_cursor;
if(m_parent_window)
auto_cursor = std::auto_ptr<BusyCursor>( new BusyCursor(m_parent_window) );
*/
m_block_modified_set = true; //Prevent the set_ functions from trigerring a save.
bool result = GlomBakery::Document_XML::load_after();
......@@ -3181,12 +3182,15 @@ void Document_Glom::save_before_print_layout_position(xmlpp::Element* nodeItem,
bool Document_Glom::save_before()
{
//TODO: Use some callback UI to show a busy cursor?
/*
//Use a std::auto_ptr<> to avoid even unncessarily instantiating a BusyCursor,
//which would require GTK+ to be initialized:
std::auto_ptr<BusyCursor> auto_cursor;
if(m_parent_window)
auto_cursor = std::auto_ptr<BusyCursor>( new BusyCursor(m_parent_window) );
*/
xmlpp::Element* nodeRoot = get_node_document();
if(nodeRoot)
......@@ -3945,11 +3949,6 @@ void Document_Glom::fill_translatable_layout_items(const sharedptr<LayoutGroup>&
}
}
void Document_Glom::set_parent_window(Gtk::Window* window)
{
m_parent_window = window;
}
void Document_Glom::set_file_uri(const Glib::ustring& file_uri, bool bEnforceFileExtension /* = false */)
{
//We override this because set_modified() triggers a save (to the old filename) in this derived class.
......
......@@ -417,8 +417,6 @@ public:
#ifndef SWIG //Hide this API from swig.
void set_parent_window(Gtk::Window* window);
Glib::ustring build_and_get_contents() const;
protected:
......@@ -613,8 +611,6 @@ private:
bool m_opened_from_browse;
Glib::ustring m_active_layout_platform; //empty (means normal), or "maemo".
Gtk::Window* m_parent_window; //Needed by BusyCursor.
};
} //namespace Glom
......
......@@ -33,6 +33,7 @@
#include <libglom/data_structure/layout/layoutitem_portal.h>
#include <libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h>
#include <libglom/data_structure/glomconversions.h>
#include <glom/utils_ui.h>
#include <glibmm/i18n.h>
#include <math.h>
#include <algorithm> //For std::max().
......@@ -193,7 +194,7 @@ Glib::RefPtr<CanvasItemMovable> CanvasLayoutItem::create_canvas_item_for_layout_
if(image)
{
Glib::RefPtr<CanvasImageMovable> canvas_item = CanvasImageMovable::create();
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(image->m_image);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Utils::get_pixbuf_for_gda_value(image->m_image);
if(pixbuf)
canvas_item->set_image(pixbuf);
else
......@@ -403,7 +404,7 @@ void CanvasLayoutItem::set_db_data(const Gnome::Gda::Value& value)
double height = 0;
canvas_item->get_width_height(width, height);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(value);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Utils::get_pixbuf_for_gda_value(value);
if(pixbuf) //TODO: Remove this if() check when goocanvas has my patch to avoid crashes when this is NULL.
canvas_item->set_image(pixbuf);
......
......@@ -756,7 +756,7 @@ void Canvas_PrintLayout::set_canvas_item_field_value(const Glib::RefPtr<Goocanva
if(!canvas_image)
return;
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(value);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Utils::get_pixbuf_for_gda_value(value);
canvas_image->property_pixbuf() = pixbuf;
}
else //text, numbers, date, time, boolean:
......
......@@ -648,7 +648,7 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const shar
{
Gtk::CellRendererPixbuf* pixbuf_renderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(item_image->m_image);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Utils::get_pixbuf_for_gda_value(item_image->m_image);
if(pixbuf)
pixbuf_renderer->set_property("pixbuf", pixbuf);
else
......@@ -2002,7 +2002,7 @@ void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gt
Gtk::CellRendererPixbuf* pDerived = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);
if(pDerived)
{
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(value);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Utils::get_pixbuf_for_gda_value(value);
//Scale it down to a sensible size.
if(pixbuf)
......
......@@ -21,6 +21,7 @@
#include "imageglom.h"
#include <glibmm/i18n.h>
#include <glom/application.h>
#include <glom/utils_ui.h>
#include <libglom/data_structure/glomconversions.h>
//#include <sstream> //For stringstream
......@@ -156,7 +157,7 @@ void ImageGlom::set_pixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
void ImageGlom::set_value(const Gnome::Gda::Value& value)
{
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(value);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Utils::get_pixbuf_for_gda_value(value);
if(pixbuf)
{
set_pixbuf(pixbuf);
......
......@@ -25,7 +25,10 @@
#include <libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h>
#include <libglom/data_structure/glomconversions.h>
#include <glibmm/i18n.h>
#include <libglom/data_structure/layout/layoutitem_image.h> // For GLOM_IMAGE_FORMAT
#include <gdkmm/pixbufloader.h>
#include <libgda/gda-blob-op.h> // For gda_blob_op_read_all()
#include <gtkmm/messagedialog.h>
#include <giomm.h>
......@@ -34,6 +37,8 @@
#include <hildonmm/note.h>
#endif
#include <glibmm/i18n.h>
#include <string.h> // for strchr
#include <sstream> //For stringstream
......@@ -212,4 +217,101 @@ Glib::ustring Utils::bold_message(const Glib::ustring& message)
}
Glib::RefPtr<Gdk::Pixbuf> Utils::get_pixbuf_for_gda_value(const Gnome::Gda::Value& value)
{
Glib::RefPtr<Gdk::Pixbuf> result;
if(value.get_value_type() == GDA_TYPE_BINARY || value.get_value_type() == GDA_TYPE_BLOB)
{
glong buffer_binary_length;
gconstpointer buffer_binary;
if(value.get_value_type() == GDA_TYPE_BLOB)
{
const GdaBlob* blob = value.get_blob();
if(gda_blob_op_read_all(blob->op, const_cast<GdaBlob*>(blob)))
{
buffer_binary_length = blob->data.binary_length;
buffer_binary = blob->data.data;
}
else
{
buffer_binary_length = 0;
buffer_binary = NULL;
g_warning("Conversions::get_pixbuf_for_gda_value(): Failed to read BLOB data");
}
}
else
{
buffer_binary = value.get_binary(buffer_binary_length);
}
/* Note that this is regular binary data, not escaped text representing the binary data: */
if(buffer_binary && buffer_binary_length)
{
//typedef std::list<Gdk::PixbufFormat> type_list_formats;
//const type_list_formats formats = Gdk::Pixbuf::get_formats();
//std::cout << "Debug: Supported pixbuf formats:" << std::endl;
//for(type_list_formats::const_iterator iter = formats.begin(); iter != formats.end(); ++iter)
//{
// std::cout << " name=" << iter->get_name() << ", writable=" << iter->is_writable() << std::endl;
//}
Glib::RefPtr<Gdk::PixbufLoader> refPixbufLoader;
try
{
refPixbufLoader = Gdk::PixbufLoader::create(GLOM_IMAGE_FORMAT);
}
catch(const Gdk::PixbufError& ex)
{
refPixbufLoader.reset();
std::cerr << "PixbufLoader::create failed: " << ex.what() << std::endl;
}
if(refPixbufLoader)
{
guint8* puiData = (guint8*)buffer_binary;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
//g_warning("ImageGlom::set_value(): debug: from db: ");
//for(int i = 0; i < 10; ++i)
// g_warning("%02X (%c), ", (guint8)puiData[i], (char)puiData[i]);
refPixbufLoader->write(puiData, (glong)buffer_binary_length);
result = refPixbufLoader->get_pixbuf();
refPixbufLoader->close(); //This throws if write() threw, so it must be inside the try block.
}
#else
std::auto_ptr<Glib::Error> error;
refPixbufLoader->write(puiData, (glong)buffer_binary_length, error);
if(error.get() == NULL)
{
result = refPixbufLoader->get_pixbuf();
refPixbufLoader->close(error);
}
#endif
#ifdef GLIBMM_EXCEPTIONS_ENABLED
catch(const Glib::Exception& ex)
{
#else
if(error.get() != NULL)
{
const Glib::Exception& ex = *error.get();
#endif
g_warning("Conversions::get_pixbuf_for_gda_value(): PixbufLoader::write() failed: %s", ex.what().c_str());
}
}
//TODO: load the image, using the mime type stored elsewhere.
//pixbuf = Gdk::Pixbuf::create_from_data(
}
}
return result;
}
} //namespace Glom
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