changeset 130:54014258099a

Added most of the missing code for the MLE's for GTK 2.0.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 20 Oct 2002 13:07:08 +0000
parents e47c52b37cdd
children 594307469c79
files gtk/dw.c
diffstat 1 files changed, 68 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Sun Oct 20 06:36:18 2002 +0000
+++ b/gtk/dw.c	Sun Oct 20 13:07:08 2002 +0000
@@ -2427,6 +2427,7 @@
 			gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint);
 			gtk_text_buffer_place_cursor(tbuffer, &iter);
 			gtk_text_buffer_insert_at_cursor(tbuffer, impbuf, -1);
+			tmppoint = startpoint + strlen(impbuf);      
 			free(impbuf);
 		}
 #else
@@ -2461,16 +2462,32 @@
  */
 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
 {
-#if GTK_MAJOR_VERSION > 1
-#else
 	int _locked_by_me = FALSE;
 	gchar *text;
 
 	DW_MUTEX_LOCK;
+#if GTK_MAJOR_VERSION > 1
+	if(GTK_IS_SCROLLED_WINDOW(handle))
+#else
 	if(GTK_IS_BOX(handle))
+#endif
 	{
 		GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
 
+#if GTK_MAJOR_VERSION > 1
+		if(tmp && GTK_IS_TEXT_VIEW(tmp))
+		{
+			GtkTextBuffer *tbuffer;
+			GtkTextIter start, end;
+
+			tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
+			gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
+			gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
+			text = gtk_text_iter_get_text(&start, &end);
+			if(text) /* Should this get freed? */
+				strcpy(buffer, text);
+		}
+#else
 		if(tmp && GTK_IS_TEXT(tmp))
 		{
 			text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length);
@@ -2480,9 +2497,9 @@
 				g_free(text);
 			}
 		}
+#endif
 	}
 	DW_MUTEX_UNLOCK;
-#endif
 }
 
 /*
@@ -2564,18 +2581,32 @@
 
 	DW_MUTEX_LOCK;
 #if GTK_MAJOR_VERSION > 1
+	if(GTK_IS_SCROLLED_WINDOW(handle))
 #else
 	if(GTK_IS_BOX(handle))
+#endif
 	{
 		GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
 
+#if GTK_MAJOR_VERSION > 1
+		if(tmp && GTK_IS_TEXT_VIEW(tmp))
+		{
+			GtkTextBuffer *tbuffer;
+			GtkTextIter start, end;
+
+			tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
+			gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
+			gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
+			gtk_text_buffer_delete(tbuffer, &start, &end);
+		}
+#else
 		if(tmp && GTK_IS_TEXT(tmp))
 		{
 			gtk_text_set_point(GTK_TEXT(tmp), startpoint);
 			gtk_text_forward_delete(GTK_TEXT(tmp), length);
 		}
-	}
 #endif
+	}
 	DW_MUTEX_UNLOCK;
 }
 
@@ -2733,11 +2764,24 @@
 
 	DW_MUTEX_LOCK;
 #if GTK_MAJOR_VERSION > 1
+	if(GTK_IS_SCROLLED_WINDOW(handle))
 #else
 	if(GTK_IS_BOX(handle))
+#endif
 	{
 		GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
 
+#if GTK_MAJOR_VERSION > 1
+		if(tmp && GTK_IS_TEXT_VIEW(tmp))
+		{
+			GtkTextBuffer *tbuffer;
+			GtkTextIter iter;
+
+			tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
+			gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
+			gtk_text_buffer_place_cursor(tbuffer, &iter);
+		}
+#else
 		if(tmp && GTK_IS_TEXT(tmp))
 		{
 			unsigned long chars;
@@ -2755,8 +2799,8 @@
 			}
 			gtk_text_set_point(GTK_TEXT(tmp), point);
 		}
-	}
 #endif
+	}
 	DW_MUTEX_UNLOCK;
 }
 
@@ -2774,11 +2818,25 @@
 
 	DW_MUTEX_LOCK;
 #if GTK_MAJOR_VERSION > 1
+	if(GTK_IS_SCROLLED_WINDOW(handle))
 #else
 	if(GTK_IS_BOX(handle))
+#endif
 	{
 		GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
 
+#if GTK_MAJOR_VERSION > 1
+		if(tmp && GTK_IS_TEXT_VIEW(tmp))
+		{
+			GtkTextBuffer *tbuffer;
+			GtkTextIter iter, found;
+
+			tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
+			gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
+			gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL);
+			retval = gtk_text_iter_get_offset(&found);  
+		}
+#else
 		if(tmp && GTK_IS_TEXT(tmp))
 		{
 			int len = gtk_text_get_length(GTK_TEXT(tmp));
@@ -2817,8 +2875,8 @@
 				g_free(tmpbuf);
 			}
 		}
-	}
 #endif
+	}
 	DW_MUTEX_UNLOCK;
 	return retval;
 }
@@ -2830,11 +2888,10 @@
  */
 void dw_mle_freeze(HWND handle)
 {
+#if GTK_MAJOR_VERSION < 2
 	int _locked_by_me = FALSE;
 
 	DW_MUTEX_LOCK;
-#if GTK_MAJOR_VERSION > 1
-#else
 	if(GTK_IS_BOX(handle))
 	{
 		GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
@@ -2844,8 +2901,8 @@
 			gtk_text_freeze(GTK_TEXT(tmp));
 		}
 	}
+	DW_MUTEX_UNLOCK;
 #endif
-	DW_MUTEX_UNLOCK;
 }
 
 /*
@@ -2855,11 +2912,10 @@
  */
 void dw_mle_thaw(HWND handle)
 {
+#if GTK_MAJOR_VERSION < 2
 	int _locked_by_me = FALSE;
 
 	DW_MUTEX_LOCK;
-#if GTK_MAJOR_VERSION > 1
-#else
 	if(GTK_IS_BOX(handle))
 	{
 		GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
@@ -2869,8 +2925,8 @@
 			gtk_text_thaw(GTK_TEXT(tmp));
 		}
 	}
+	DW_MUTEX_UNLOCK;
 #endif
-	DW_MUTEX_UNLOCK;
 }
 
 /*