gtksourceview r2243 - in branches/gtksourcecompletion: . gtksourceview



Author: icq
Date: Tue Apr  7 17:57:58 2009
New Revision: 2243
URL: http://svn.gnome.org/viewvc/gtksourceview?rev=2243&view=rev

Log:

2009-04-07  Ignacio Casal Quinteiro  <nacho resa gmail com>

        * gtksourceview/gtksourcecompletion.c:
        * gtksourceview/gtksourceview.c:
        * gtksourceview/gtksourcecompletion.h:
        * gtksourceview/gtksourceview.h:
        Integrate GtkSourceCompletion into GtkSourceView.



Modified:
   branches/gtksourcecompletion/ChangeLog
   branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c
   branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.h
   branches/gtksourcecompletion/gtksourceview/gtksourceview.c
   branches/gtksourcecompletion/gtksourceview/gtksourceview.h

Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c	(original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c	Tue Apr  7 17:57:58 2009
@@ -132,49 +132,6 @@
 
 G_DEFINE_TYPE(GtkSourceCompletion, gtk_source_completion, GTK_TYPE_WINDOW);
 
-/* **************** GtkTextView-GtkSourceCompletion Control *********** */
-
-/*
- * We save a map with a GtkTextView and his GtkSourceCompletion. If you 
- * call twice to gtk_source_completion_proposal_new, the second time it returns
- * the previous created GtkSourceCompletion, not creates a new one
- *
- * FIXME We will remove this functions when we will integrate 
- * Gsc in GtkSourceView
- */
-
-static GHashTable *gsccompletion_map = NULL;
-
-static GtkSourceCompletion* 
-completion_control_get_completion (GtkTextView *view)
-{
-	if (gsccompletion_map == NULL)
-		gsccompletion_map = g_hash_table_new (g_direct_hash,
-						      g_direct_equal);
-
-	return g_hash_table_lookup (gsccompletion_map, view);
-}
-
-static void 
-completion_control_add_completion (GtkTextView *view,
-				   GtkSourceCompletion *comp)
-{
-	if (gsccompletion_map == NULL)
-		gsccompletion_map = g_hash_table_new (g_direct_hash,
-						      g_direct_equal);
-	g_hash_table_insert (gsccompletion_map, view, comp);
-}
-
-static void 
-completion_control_remove_completion (GtkTextView *view)
-{
-	if (gsccompletion_map == NULL)
-		gsccompletion_map = g_hash_table_new (g_direct_hash,
-						      g_direct_equal);
-	g_hash_table_remove (gsccompletion_map, view);
-}
-/* ********************************************************************* */
-
 static gboolean
 get_selected_proposal (GtkSourceCompletionPage *page,
 		       GtkSourceCompletionProposal **proposal)
@@ -1036,8 +993,6 @@
 		g_list_free (self->priv->prov_trig);
 	}
 	
-	completion_control_remove_completion(self->priv->view);
-	
 	G_OBJECT_CLASS (gtk_source_completion_parent_class)->finalize (object);
 }
 
@@ -1525,21 +1480,19 @@
 }
 
 /**
- * gtk_source_completion_new:
+ * _gtk_source_completion_new:
  *
  * Returns The new #GtkSourceCompletion
  */
-GtkWidget*
-gtk_source_completion_new (GtkTextView *view)
+GtkSourceCompletion *
+_gtk_source_completion_new (GtkTextView *view)
 {
 	GtkSourceCompletion *self = GTK_SOURCE_COMPLETION (g_object_new (GTK_TYPE_SOURCE_COMPLETION,
 									 "type", GTK_WINDOW_POPUP,
 									 NULL));
 	self->priv->view = view;
 	
-	completion_control_add_completion (view, self);
-	
-	return GTK_WIDGET (self);
+	return self;
 }
 
 /**
@@ -2086,18 +2039,6 @@
 }
 
 /**
- * gtk_source_completion_get_from_view:
- * @view: The #GtkTextView associated with a #GtkSourceCompletion
- *
- * Returns: The #GtkSourceCompletion associated with a @view or %NULL.
- */
-GtkSourceCompletion*
-gtk_source_completion_get_from_view (GtkTextView *view)
-{
-	return completion_control_get_completion (view);
-}
-
-/**
  * gtk_source_completion_get_page_pos:
  * @self: The #GtkSourceCompletion
  * @page_name: The page name to search

Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.h
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.h	(original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.h	Tue Apr  7 17:57:58 2009
@@ -83,7 +83,8 @@
 
 GType		 gtk_source_completion_get_type			(void) G_GNUC_CONST;
 
-GtkWidget	*gtk_source_completion_new			(GtkTextView *view);
+GtkSourceCompletion
+		*_gtk_source_completion_new			(GtkTextView *view);
 
 GtkTextView	*gtk_source_completion_get_view			(GtkSourceCompletion *self);
 

Modified: branches/gtksourcecompletion/gtksourceview/gtksourceview.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourceview.c	(original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourceview.c	Tue Apr  7 17:57:58 2009
@@ -39,6 +39,7 @@
 #include "gtksourceview-typebuiltins.h"
 #include "gtksourcemark.h"
 #include "gtksourceview.h"
+#include "gtksourcecompletion.h"
 
 /*
 #define ENABLE_DEBUG
@@ -131,6 +132,8 @@
 
 	GdkColor         current_line_color;
 	guint            current_line_color_set : 1;
+	
+	GtkSourceCompletion	*completion;
 };
 
 
@@ -711,6 +714,7 @@
 	view->priv->smart_home_end = GTK_SOURCE_SMART_HOME_END_DISABLED;
 	view->priv->right_margin_pos = DEFAULT_RIGHT_MARGIN_POSITION;
 	view->priv->cached_right_margin_pos = -1;
+	view->priv->completion = _gtk_source_completion_new (GTK_TEXT_VIEW (view));
 
 	gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 2);
 	gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 2);
@@ -781,6 +785,9 @@
 
 	if (view->priv->mark_categories)
 		g_hash_table_destroy (view->priv->mark_categories);
+	
+	if (view->priv->completion != NULL)
+		g_object_unref (view->priv->completion);
 
 	set_source_buffer (view, NULL);
 
@@ -3982,3 +3989,19 @@
 			view->priv->style_scheme_applied = FALSE;
 	}
 }
+
+/**
+ * gtk_source_view_get_completion:
+ * @view: a #GtkSourceView
+ *
+ * Gets the #GtkSourceCompletion associated with @view.
+ *
+ * Returns: the #GtkSourceCompletion associated with @view.
+ */
+GtkSourceCompletion *
+gtk_source_view_get_completion (GtkSourceView *view)
+{
+	g_return_val_if_fail (GTK_IS_SOURCE_VIEW (view), NULL);
+	
+	return view->priv->completion;
+}

Modified: branches/gtksourcecompletion/gtksourceview/gtksourceview.h
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourceview.h	(original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourceview.h	Tue Apr  7 17:57:58 2009
@@ -28,6 +28,7 @@
 #include <gtk/gtktextview.h>
 
 #include <gtksourceview/gtksourcebuffer.h>
+#include <gtksourceview/gtksourcecompletion.h>
 
 G_BEGIN_DECLS
 
@@ -198,5 +199,8 @@
 GtkSourceDrawSpacesFlags
 		gtk_source_view_get_draw_spaces		(GtkSourceView   *view);
 
+GtkSourceCompletion *
+		gtk_source_view_get_completion		(GtkSourceView   *view);
+
 G_END_DECLS
 #endif				/* end of SOURCE_VIEW_H__ */



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