[libgda] Added wrap mode to the "text" plugin



commit c30cc25820c8d03b45551b16a1bd5196b682763a
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed Jul 21 17:18:18 2010 +0200

    Added wrap mode to the "text" plugin

 .../plugins/gdaui-entry-text-spec.xml.in           |   24 ++++++++++++++++++++
 libgda-ui/data-entries/plugins/gdaui-entry-text.c  |   24 +++++++++++++++++--
 2 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/libgda-ui/data-entries/plugins/gdaui-entry-text-spec.xml.in b/libgda-ui/data-entries/plugins/gdaui-entry-text-spec.xml.in
index 69b87a3..1c9f296 100644
--- a/libgda-ui/data-entries/plugins/gdaui-entry-text-spec.xml.in
+++ b/libgda-ui/data-entries/plugins/gdaui-entry-text-spec.xml.in
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
 <data-set-spec>
   <parameters>
+    <parameter id="WRAP_MODE" _name="Lines wrapping" _descr="Defines how long lines are wrapped" gdatype="string" source="wrappermodes:0"/>
     <parameter id="PROG_LANG" _name="Programming language" _descr="Define to enable syntactical colourisation" gdatype="string" source="langs:0"/>
   </parameters>
   <sources>
@@ -9,5 +10,28 @@
       <gda_array_field name="name" gdatype="gchararray"/>
       <gda_array_data/>
     </gda_array>
+
+    <gda_array name="wrappermodes">
+      <gda_array_field name="id" gdatype="gchararray"/>
+      <gda_array_field name="name" gdatype="gchararray"/>
+      <gda_array_data>
+	<gda_array_row>
+          <gda_value>NONE</gda_value>
+          <_gda_value>Do not wrap lines</_gda_value>
+	</gda_array_row>
+	<gda_array_row>
+          <gda_value>CHAR</gda_value>
+          <_gda_value>break lines anywhere the cursor can appear</_gda_value>
+	</gda_array_row>
+	<gda_array_row>
+          <gda_value>WORD</gda_value>
+          <_gda_value>Break lines in between words</_gda_value>
+	</gda_array_row>
+	<gda_array_row>
+          <gda_value>D_CHAR</gda_value>
+          <_gda_value>Break lines in between words or graphemes</_gda_value>
+        </gda_array_row>
+      </gda_array_data>
+    </gda_array>
   </sources>
 </data-set-spec>
diff --git a/libgda-ui/data-entries/plugins/gdaui-entry-text.c b/libgda-ui/data-entries/plugins/gdaui-entry-text.c
index fb93dc0..7904a07 100644
--- a/libgda-ui/data-entries/plugins/gdaui-entry-text.c
+++ b/libgda-ui/data-entries/plugins/gdaui-entry-text.c
@@ -62,6 +62,7 @@ struct _GdauiEntryTextPrivate
 	GtkTextBuffer *buffer;
 	GtkWidget     *view;
 	gchar         *lang; /* for code colourisation */
+	GtkWrapMode    wrapmode;
 };
 
 
@@ -112,6 +113,7 @@ gdaui_entry_text_init (GdauiEntryText * gdaui_entry_text)
 	gdaui_entry_text->priv = g_new0 (GdauiEntryTextPrivate, 1);
 	gdaui_entry_text->priv->buffer = NULL;
 	gdaui_entry_text->priv->view = NULL;
+	gdaui_entry_text->priv->wrapmode = GTK_WRAP_NONE;
 }
 
 /**
@@ -136,18 +138,30 @@ gdaui_entry_text_new (GdaDataHandler *dh, GType type, const gchar *options)
 
 	obj = g_object_new (GDAUI_TYPE_ENTRY_TEXT, "handler", dh, NULL);
 	mgtxt = GDAUI_ENTRY_TEXT (obj);
-#ifdef HAVE_GTKSOURCEVIEW
 	if (options && *options) {
+
                 GdaQuarkList *params;
                 const gchar *str;
 
                 params = gda_quark_list_new_from_string (options);
+#ifdef HAVE_GTKSOURCEVIEW
                 str = gda_quark_list_find (params, "PROG_LANG");
                 if (str)
 			mgtxt->priv->lang = g_strdup (str);
+#endif
+		str = gda_quark_list_find (params, "WRAP_MODE");
+                if (str) {
+			if (*str == 'N')
+				mgtxt->priv->wrapmode = GTK_WRAP_NONE;
+			else if (*str == 'C')
+				mgtxt->priv->wrapmode = GTK_WRAP_CHAR;
+			else if (*str == 'W')
+				mgtxt->priv->wrapmode = GTK_WRAP_WORD;
+			else
+				mgtxt->priv->wrapmode = GTK_WRAP_WORD_CHAR;
+		}
                 gda_quark_list_free (params);
         }
-#endif
 
 	gdaui_data_entry_set_value_type (GDAUI_DATA_ENTRY (mgtxt), type);
 
@@ -274,6 +288,7 @@ create_entry (GdauiEntryWrapper *mgwrap)
 	mgtxt->priv->view = gtk_text_view_new ();
 #endif
 	mgtxt->priv->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (mgtxt->priv->view));
+	gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (mgtxt->priv->view), mgtxt->priv->wrapmode);
 	sw = gtk_scrolled_window_new (NULL, NULL);
 	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
@@ -398,7 +413,10 @@ connect_signals(GdauiEntryWrapper *mgwrap, GCallback modify_cb, GCallback activa
 static gboolean
 can_expand (GdauiEntryWrapper *mgwrap, gboolean horiz)
 {
-	return TRUE;
+	if (horiz)
+		return FALSE;
+	else
+		return TRUE;
 }
 
 static void



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