Skip to content

Commit

Permalink
Use of GtkTextView instead of GtkSourceView
Browse files Browse the repository at this point in the history
We have not a real dependency on GtkSourceView, we will use
GtkTextView instead.
  • Loading branch information
chuchiperriman committed Sep 11, 2009
1 parent 7f43414 commit 48eb979
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 101 deletions.
32 changes: 0 additions & 32 deletions gtksourcecompletion/gsc-completion-priv.h

This file was deleted.

35 changes: 16 additions & 19 deletions gtksourcecompletion/gsc-completion.c
Expand Up @@ -36,7 +36,6 @@
#include "gsc-model.h"
#include "gsc-context.h"
#include <string.h>
#include <gtksourceview/gtksourceview.h>
#include <stdarg.h>

#define WINDOW_WIDTH 350
Expand Down Expand Up @@ -97,7 +96,7 @@ struct _GscCompletionPrivate
gboolean select_on_show;

/* Completion management */
GtkSourceView *view;
GtkTextView *view;

GList *providers;
GHashTable *capability_map;
Expand Down Expand Up @@ -126,8 +125,6 @@ G_DEFINE_TYPE(GscCompletion, gsc_completion, G_TYPE_OBJECT);
* call twice to gsc_proposal_new, the second time it returns
* the previous created GscCompletion, not creates a new one
*
* FIXME We will remove this functions when we will integrate
* Gsc in GtkSourceView
*/

static GHashTable *gsccompletion_map = NULL;
Expand Down Expand Up @@ -298,7 +295,7 @@ activate_current_proposal (GscCompletion *completion)
if (!activated)
{
text = gsc_proposal_get_text (proposal);
gsc_utils_replace_current_word (GTK_SOURCE_BUFFER (buffer),
gsc_utils_replace_current_word (buffer,
text ? text : NULL,
-1);
}
Expand Down Expand Up @@ -1007,7 +1004,7 @@ gsc_completion_user_request (GscCompletion *completion)
}

static gboolean
view_key_press_event_cb (GtkSourceView *view,
view_key_press_event_cb (GtkTextView *view,
GdkEventKey *event,
GscCompletion *completion)
{
Expand Down Expand Up @@ -1117,7 +1114,7 @@ update_typing_offsets (GscCompletion *completion)
gchar *word;

buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (completion->priv->view));
word = gsc_utils_get_word_iter (GTK_SOURCE_BUFFER (buffer),
word = gsc_utils_get_word_iter (buffer,
NULL,
&start,
&end);
Expand Down Expand Up @@ -1157,7 +1154,7 @@ show_auto_completion (GscCompletion *completion)
return FALSE;
}

word = gsc_utils_get_word_iter (GTK_SOURCE_BUFFER (buffer),
word = gsc_utils_get_word_iter (buffer,
&iter,
&start,
&end);
Expand Down Expand Up @@ -1461,15 +1458,15 @@ gsc_completion_class_init (GscCompletionClass *klass)
/**
* Gsc:view:
*
* The #GtkSourceView bound to the completion object.
* The #GtkTextView bound to the completion object.
*
*/
g_object_class_install_property (object_class,
PROP_VIEW,
g_param_spec_object ("view",
_("View"),
_("The GtkSourceView bound to the completion"),
GTK_TYPE_SOURCE_VIEW,
_("The GtkTextView bound to the completion"),
GTK_TYPE_TEXT_VIEW,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));

/**
Expand Down Expand Up @@ -2079,12 +2076,12 @@ gsc_completion_show (GscCompletion *completion,
if (place == NULL)
{
gsc_utils_move_to_cursor (GTK_WINDOW (completion->priv->window),
GTK_SOURCE_VIEW (completion->priv->view));
completion->priv->view);
}
else
{
gsc_utils_move_to_iter (GTK_WINDOW (completion->priv->window),
GTK_SOURCE_VIEW (completion->priv->view),
completion->priv->view,
place);
}

Expand Down Expand Up @@ -2155,16 +2152,16 @@ gsc_completion_error_quark (void)

/**
* gsc_completion_new:
* @view: A #GtkSourceView
* @view: A #GtkTextView
*
* Create a new #GscCompletion associated with @view.
*
* Returns: The new #Gsc.
*/
GscCompletion *
gsc_completion_new (GtkSourceView *view)
gsc_completion_new (GtkTextView *view)
{
g_return_val_if_fail (GTK_IS_SOURCE_VIEW (view), NULL);
g_return_val_if_fail (GTK_IS_TEXT_VIEW (view), NULL);

GscCompletion *self = g_object_new (GSC_TYPE_COMPLETION,
"view", view,
Expand Down Expand Up @@ -2310,11 +2307,11 @@ gsc_completion_get_info_window (GscCompletion *completion)
* gsc_completion_get_view:
* @completion: A #Gsc
*
* The #GtkSourceView associated with @completion.
* The #GtkTextView associated with @completion.
*
* Returns: The #GtkSourceView associated with @completion.
* Returns: The #GtkTextView associated with @completion.
*/
GtkSourceView *
GtkTextView *
gsc_completion_get_view (GscCompletion *completion)
{
g_return_val_if_fail (GSC_IS_COMPLETION (completion), NULL);
Expand Down
8 changes: 2 additions & 6 deletions gtksourcecompletion/gsc-completion.h
Expand Up @@ -24,7 +24,6 @@
#define GSC_COMPLETION_H

#include <gtk/gtk.h>
#include <gtksourceview/gtksourceview.h>
#include "gsc-info.h"
#include "gsc-provider.h"

Expand Down Expand Up @@ -52,9 +51,6 @@ typedef enum
GSC_COMPLETION_ERROR_NOT_BOUND,
} GscCompletionError;

/* Forward declaration of GtkSourceView */
struct _GtkSourceView;

struct _GscCompletion
{
GObject parent;
Expand All @@ -79,7 +75,7 @@ GType gsc_completion_get_type (void) G_GNUC_CONST;

GQuark gsc_completion_error_quark (void);

GscCompletion *gsc_completion_new (GtkSourceView *source_view);
GscCompletion *gsc_completion_new (GtkTextView *source_view);

gboolean gsc_completion_add_provider (GscCompletion *completion,
GscProvider *provider,
Expand All @@ -100,7 +96,7 @@ void gsc_completion_hide (GscCompletion *completion);
GscInfo *
gsc_completion_get_info_window (GscCompletion *completion);

GtkSourceView *gsc_completion_get_view (GscCompletion *completion);
GtkTextView *gsc_completion_get_view (GscCompletion *completion);

G_END_DECLS

Expand Down
2 changes: 1 addition & 1 deletion gtksourcecompletion/gsc-context.c
Expand Up @@ -151,7 +151,7 @@ update_criteria (GscContext *context)

g_free (context->priv->criteria);
context->priv->criteria =
gsc_utils_get_word (GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (context->priv->view)));
gsc_utils_get_word (gtk_text_view_get_buffer (context->priv->view));
}

GscContext*
Expand Down
4 changes: 2 additions & 2 deletions gtksourcecompletion/gsc-info.c
Expand Up @@ -411,7 +411,7 @@ gsc_completion_info_move_to_iter (GscInfo *info,
GtkTextIter start;

g_return_if_fail (GSC_IS_INFO (info));
g_return_if_fail (GTK_IS_SOURCE_VIEW (view));
g_return_if_fail (GTK_IS_TEXT_VIEW (view));

if (iter == NULL)
{
Expand All @@ -425,7 +425,7 @@ gsc_completion_info_move_to_iter (GscInfo *info,
}

gsc_utils_move_to_iter (GTK_WINDOW (info),
GTK_SOURCE_VIEW (view),
view,
&start);
}

Expand Down
6 changes: 0 additions & 6 deletions gtksourcecompletion/gsc-model.c
Expand Up @@ -303,7 +303,6 @@ tree_model_iter_n_children (GtkTreeModel *tree_model,

if (iter == NULL)
{
g_debug ("n children num: %i", GSC_MODEL (tree_model)->priv->num);
return GSC_MODEL (tree_model)->priv->num;
}
else
Expand Down Expand Up @@ -796,8 +795,6 @@ gsc_model_set_proposals (GscModel *model,
g_hash_table_destroy (rinfo.proposals);
}

g_debug ("%s> %i",gsc_provider_get_name (info->provider), info->num);

if (info->num == 0)
{
remove_node (model, info->header_node,
Expand Down Expand Up @@ -890,7 +887,6 @@ gsc_model_is_empty (GscModel *model,
gboolean invisible)
{
g_return_val_if_fail (GSC_IS_MODEL (model), FALSE);
g_debug ("is empty num: %i", model->priv->num);
if (invisible)
{
return model->priv->num == 0;
Expand All @@ -911,8 +907,6 @@ gsc_model_n_proposals (GscModel *model,
g_return_val_if_fail (GSC_IS_MODEL (model), 0);
g_return_val_if_fail (GSC_IS_PROVIDER (provider), 0);

g_debug ("n proposals num: %i", model->priv->num);

info = g_hash_table_lookup (model->priv->providers_info, provider);

if (info == NULL)
Expand Down

0 comments on commit 48eb979

Please sign in to comment.