[libgda] Better support for blobs which are text in text UI plugin
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgda] Better support for blobs which are text in text UI plugin
- Date: Fri, 29 Jan 2010 20:03:16 +0000 (UTC)
commit cb3e66f151d94277b72e0e03b9b5de31a8720fce
Author: Vivien Malerba <malerba gnome-db org>
Date: Fri Jan 29 20:57:21 2010 +0100
Better support for blobs which are text in text UI plugin
this is necessary since for example the TEXT type in
MySQL is reported as a BLOB even though it's only text
libgda-ui/data-entries/plugins/gdaui-entry-text.c | 37 ++++++++++++++++++---
1 files changed, 32 insertions(+), 5 deletions(-)
---
diff --git a/libgda-ui/data-entries/plugins/gdaui-entry-text.c b/libgda-ui/data-entries/plugins/gdaui-entry-text.c
index 5be6306..7fdb678 100644
--- a/libgda-ui/data-entries/plugins/gdaui-entry-text.c
+++ b/libgda-ui/data-entries/plugins/gdaui-entry-text.c
@@ -197,12 +197,39 @@ real_set_value (GdauiEntryWrapper *mgwrap, const GValue *value)
if (! gda_value_is_null ((GValue *) value)) {
GdaDataHandler *dh;
gchar *str;
+ gboolean done = FALSE;
+
+ if (G_VALUE_TYPE (value) == GDA_TYPE_BLOB) {
+ const GdaBlob *blob;
+ GdaBinary *bin;
+ blob = gda_value_get_blob (value);
+ bin = (GdaBinary *) blob;
+ if (blob->op &&
+ (bin->binary_length != gda_blob_op_get_length (blob->op)))
+ gda_blob_op_read_all (blob->op, blob);
+ if (g_utf8_validate (bin->data, bin->binary_length, NULL)) {
+ gtk_text_buffer_set_text (mgtxt->priv->buffer, (gchar*) bin->data,
+ bin->binary_length);
+ done = TRUE;
+ }
+ }
+ else if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
+ const GdaBinary *bin;
+ bin = gda_value_get_binary (value);
+ if (g_utf8_validate (bin->data, bin->binary_length, NULL)) {
+ gtk_text_buffer_set_text (mgtxt->priv->buffer, (gchar*) bin->data,
+ bin->binary_length);
+ done = TRUE;
+ }
+ }
- dh = gdaui_data_entry_get_handler (GDAUI_DATA_ENTRY (mgwrap));
- str = gda_data_handler_get_str_from_value (dh, value);
- if (str) {
- gtk_text_buffer_set_text (mgtxt->priv->buffer, str, -1);
- g_free (str);
+ if (!done) {
+ dh = gdaui_data_entry_get_handler (GDAUI_DATA_ENTRY (mgwrap));
+ str = gda_data_handler_get_str_from_value (dh, value);
+ if (str) {
+ gtk_text_buffer_set_text (mgtxt->priv->buffer, str, -1);
+ g_free (str);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]