gtksourceview r2251 - in branches/gtksourcecompletion: . gtksourceview tests
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gtksourceview r2251 - in branches/gtksourcecompletion: . gtksourceview tests
- Date: Fri, 10 Apr 2009 21:10:12 +0000 (UTC)
Author: icq
Date: Fri Apr 10 21:10:12 2009
New Revision: 2251
URL: http://svn.gnome.org/viewvc/gtksourceview?rev=2251&view=rev
Log:
2009-04-10 Ignacio Casal Quinteiro <nacho resa gmail com>
* gtksourceview/gtksourcecompletion.c:
* gtksourceview/gtksourcecompletion.h:
* gtksourceview/gtksourcecompletiontrigger.c:
* gtksourceview/gtksourcecompletiontrigger.h:
* gtksourceview/gtksourcecompletiontriggerkey.c:
* tests/completion-simple.c:
Remove set_active func on completion.
Remove deactivate trigger func and added activate signal.
Modified:
branches/gtksourcecompletion/ChangeLog
branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c
branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.h
branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontrigger.c
branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontrigger.h
branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontriggerkey.c
branches/gtksourcecompletion/tests/completion-simple.c
Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c (original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.c Fri Apr 10 21:10:12 2009
@@ -64,14 +64,12 @@
PROP_0,
PROP_MANAGE_KEYS,
PROP_REMEMBER_INFO_VISIBILITY,
- PROP_SELECT_ON_SHOW,
- PROP_ACTIVE
+ PROP_SELECT_ON_SHOW
};
enum
{
TEXT_VIEW_KP,
- TEXT_VIEW_DESTROY,
TEXT_VIEW_FOCUS_OUT,
TEXT_VIEW_BUTTON_PRESS,
LAST_EXTERNAL_SIGNAL
@@ -123,8 +121,6 @@
GList *prov_trig;
GtkSourceCompletionTrigger *active_trigger;
- /*TRUE if the completion mechanism is active*/
- gboolean active;
gulong signals_ids[LAST_EXTERNAL_SIGNAL];
};
@@ -968,16 +964,43 @@
return ret;
}
+static gboolean
+view_focus_out_event_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ gpointer user_data)
+{
+ GtkSourceCompletion *self = GTK_SOURCE_COMPLETION (user_data);
+
+ if (GTK_WIDGET_VISIBLE (self)
+ && !GTK_WIDGET_HAS_FOCUS (self))
+ end_completion (self);
+
+ return FALSE;
+}
+
+static gboolean
+view_button_press_event_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ GtkSourceCompletion *self = GTK_SOURCE_COMPLETION (user_data);
+
+ if (GTK_WIDGET_VISIBLE (self))
+ end_completion (self);
+
+ return FALSE;
+}
+
static void
gtk_source_completion_finalize (GObject *object)
{
GtkSourceCompletion *self = GTK_SOURCE_COMPLETION (object);
- if (self->priv->active)
- gtk_source_completion_set_active (self, FALSE);
-
- g_list_foreach (self->priv->pages, (GFunc) free_page, NULL);
- g_list_free (self->priv->pages);
+ if (self->priv->pages != NULL)
+ {
+ g_list_foreach (self->priv->pages, (GFunc) free_page, NULL);
+ g_list_free (self->priv->pages);
+ }
if (self->priv->triggers != NULL)
{
@@ -993,6 +1016,11 @@
g_list_free (self->priv->prov_trig);
}
+ g_signal_handler_disconnect (self->priv->view,
+ self->priv->signals_ids[TEXT_VIEW_FOCUS_OUT]);
+ g_signal_handler_disconnect (self->priv->view,
+ self->priv->signals_ids[TEXT_VIEW_BUTTON_PRESS]);
+
G_OBJECT_CLASS (gtk_source_completion_parent_class)->finalize (object);
}
@@ -1139,9 +1167,6 @@
case PROP_SELECT_ON_SHOW:
g_value_set_boolean (value, self->priv->select_on_show);
break;
- case PROP_ACTIVE:
- g_value_set_boolean (value, self->priv->active);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1172,9 +1197,6 @@
case PROP_SELECT_ON_SHOW:
self->priv->select_on_show = g_value_get_boolean (value);
break;
- case PROP_ACTIVE:
- gtk_source_completion_set_active (self, g_value_get_boolean (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1240,18 +1262,7 @@
_("Completion mark as selected the first proposal on show"),
FALSE,
G_PARAM_READWRITE));
- /**
- * GtkSourceCompletion:active:
- *
- * %TRUE if the completion mechanism is active.
- */
- g_object_class_install_property (object_class,
- PROP_ACTIVE,
- g_param_spec_boolean ("active",
- _("Set or get if the completion mechanism is active"),
- _("Set or get if the completion mechanism is active"),
- FALSE,
- G_PARAM_READWRITE));
+
/**
* GtkSourceCompletion::proposal-selected:
* @completion: The #GtkSourceCompletion who emits the signal
@@ -1303,7 +1314,6 @@
self->priv = GTK_SOURCE_COMPLETION_GET_PRIVATE (self);
self->priv->destroy_has_run = FALSE;
self->priv->active_trigger = NULL;
- self->priv->active = FALSE;
self->priv->manage_keys = TRUE;
self->priv->remember_info_visibility = FALSE;
self->priv->info_visible = FALSE;
@@ -1444,39 +1454,97 @@
}
static void
-view_destroy_event_cb (GtkWidget *widget,
- gpointer user_data)
+trigger_activate_cb (GtkSourceCompletionTrigger *trigger,
+ GtkSourceCompletion *self)
{
- GtkSourceCompletion *self = GTK_SOURCE_COMPLETION (user_data);
-
- g_object_unref (self);
-}
+ GList *l;
+ GList *data_list;
+ GList *final_list = NULL;
+ GtkSourceCompletionProposal *last_proposal = NULL;
+ gint x, y;
-static gboolean
-view_focus_out_event_cb (GtkWidget *widget,
- GdkEventFocus *event,
- gpointer user_data)
-{
- GtkSourceCompletion *self = GTK_SOURCE_COMPLETION (user_data);
+ g_return_if_fail (GTK_IS_SOURCE_COMPLETION (self));
+ g_return_if_fail (GTK_IS_SOURCE_COMPLETION_TRIGGER (trigger));
+ /*
+ * If the completion is visble and there is a trigger active, you cannot
+ * raise a different trigger until the current trigger finish o_O
+ */
if (GTK_WIDGET_VISIBLE (self)
- && !GTK_WIDGET_HAS_FOCUS (self))
- end_completion (self);
+ && self->priv->active_trigger != trigger)
+ {
+ return;
+ }
- return FALSE;
-}
+ end_completion (self);
+ gtk_source_completion_clear (self);
+
+ for (l = self->priv->prov_trig; l != NULL; l = g_list_next (l))
+ {
+ PTPair *ptp = (PTPair *)l->data;
+
+ if (ptp->trigger == trigger)
+ {
+ data_list = gtk_source_completion_provider_get_proposals (ptp->provider,
+ trigger);
+ if (data_list != NULL)
+ {
+ final_list = g_list_concat (final_list,
+ data_list);
+ }
+ }
+ }
+
+ if (final_list == NULL)
+ {
+ if (GTK_WIDGET_VISIBLE (self))
+ end_completion (self);
+ return;
+ }
+
+ data_list = final_list;
+ /* Insert the data into the model */
+ do
+ {
+ GtkSourceCompletionPage *page;
+
+ last_proposal = GTK_SOURCE_COMPLETION_PROPOSAL (data_list->data);
+ page = get_page_by_name (self,
+ gtk_source_completion_proposal_get_page_name (last_proposal));
+
+ add_proposal (page,
+ last_proposal);
+ } while ((data_list = g_list_next (data_list)) != NULL);
+
+ g_list_free (final_list);
+
+ if (!GTK_WIDGET_HAS_FOCUS (self->priv->view))
+ return;
+
+ /*
+ *FIXME Do it supports only cursor position? We can
+ *add a new "position-type": cursor, center_screen,
+ *center_window, custom etc.
+ */
+ gtk_source_completion_utils_get_pos_at_cursor (GTK_WINDOW (self),
+ self->priv->view,
+ &x, &y, NULL);
-static gboolean
-view_button_press_event_cb (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- GtkSourceCompletion *self = GTK_SOURCE_COMPLETION (user_data);
+ gtk_window_move (GTK_WINDOW (self),
+ x, y);
- if (GTK_WIDGET_VISIBLE (self))
- end_completion (self);
+ /*
+ * We must call to gtk_widget_show and not to gsc_completion_show_or_update
+ * because if we don't call to gtk_widget_show, the show signal is not emitted
+ */
+ gtk_widget_show (GTK_WIDGET (self));
- return FALSE;
+ gtk_widget_grab_focus (GTK_WIDGET (self->priv->view));
+
+ self->priv->active_trigger = trigger;
+
+ if (self->priv->select_on_show)
+ select_first_proposal (self->priv->active_page);
}
/**
@@ -1492,6 +1560,20 @@
NULL));
self->priv->view = view;
+ self->priv->signals_ids[TEXT_VIEW_FOCUS_OUT] =
+ g_signal_connect (self->priv->view,
+ "focus-out-event",
+ G_CALLBACK (view_focus_out_event_cb),
+ self);
+
+ self->priv->signals_ids[TEXT_VIEW_BUTTON_PRESS] =
+ g_signal_connect (self->priv->view,
+ "button-press-event",
+ G_CALLBACK (view_button_press_event_cb),
+ self);
+
+ set_manage_keys (self);
+
return self;
}
@@ -1523,10 +1605,10 @@
trigger);
g_object_ref (trigger);
- if (self->priv->active)
- {
- gtk_source_completion_trigger_activate (trigger);
- }
+ g_signal_connect (trigger, "activate",
+ G_CALLBACK (trigger_activate_cb),
+ self);
+
return TRUE;
}
@@ -1603,11 +1685,6 @@
self->priv->triggers = g_list_remove (self->priv->triggers, trigger);
- if (self->priv->active)
- {
- gtk_source_completion_trigger_deactivate (trigger);
- }
-
for (l = self->priv->prov_trig; l != NULL; l = g_list_next (l))
{
PTPair *ptp = (PTPair *)l->data;
@@ -1620,7 +1697,10 @@
}
}
+ g_signal_handlers_disconnect_by_func (trigger, trigger_activate_cb,
+ self);
g_object_unref (trigger);
+
return TRUE;
}
@@ -1697,114 +1777,6 @@
}
/**
- * gtk_source_completion_trigger_event:
- * @self: the #GtkSourceCompletion
- * @trigger: The trigger who trigger the event
- *
- * Calling this function, the completion call to all providers to get data and, if
- * they return data, it shows the completion to the user.
- *
- * Returns: %TRUE if the event has been triggered, %FALSE if not
- *
- **/
-gboolean
-gtk_source_completion_trigger_event (GtkSourceCompletion *self,
- GtkSourceCompletionTrigger *trigger)
-{
- GList *l;
- GList *data_list;
- GList *final_list = NULL;
- GtkSourceCompletionProposal *last_proposal = NULL;
- gint x, y;
-
- g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION (self), FALSE);
- g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_TRIGGER (trigger), FALSE);
- g_return_val_if_fail (self->priv->active, FALSE);
-
- /*
- * If the completion is visble and there is a trigger active, you cannot
- * raise a different trigger until the current trigger finish o_O
- */
- if (GTK_WIDGET_VISIBLE (self)
- && self->priv->active_trigger != trigger)
- {
- return FALSE;
- }
-
- end_completion (self);
- gtk_source_completion_clear (self);
-
- for (l = self->priv->prov_trig; l != NULL; l = g_list_next (l))
- {
- PTPair *ptp = (PTPair *)l->data;
-
- if (ptp->trigger == trigger)
- {
- data_list = gtk_source_completion_provider_get_proposals (ptp->provider,
- trigger);
- if (data_list != NULL)
- {
- final_list = g_list_concat (final_list,
- data_list);
- }
- }
- }
-
- if (final_list == NULL)
- {
- if (GTK_WIDGET_VISIBLE (self))
- end_completion (self);
- return FALSE;
- }
-
- data_list = final_list;
- /* Insert the data into the model */
- do
- {
- GtkSourceCompletionPage *page;
-
- last_proposal = GTK_SOURCE_COMPLETION_PROPOSAL (data_list->data);
- page = get_page_by_name (self,
- gtk_source_completion_proposal_get_page_name (last_proposal));
-
- add_proposal (page,
- last_proposal);
- } while ((data_list = g_list_next (data_list)) != NULL);
-
- g_list_free (final_list);
-
- if (!GTK_WIDGET_HAS_FOCUS (self->priv->view))
- return FALSE;
-
- /*
- *FIXME Do it supports only cursor position? We can
- *add a new "position-type": cursor, center_screen,
- *center_window, custom etc.
- */
- gtk_source_completion_utils_get_pos_at_cursor (GTK_WINDOW (self),
- self->priv->view,
- &x, &y, NULL);
-
- gtk_window_move (GTK_WINDOW (self),
- x, y);
-
- /*
- * We must call to gtk_widget_show and not to gsc_completion_show_or_update
- * because if we don't call to gtk_widget_show, the show signal is not emitted
- */
- gtk_widget_show (GTK_WIDGET (self));
-
- gtk_widget_grab_focus (GTK_WIDGET (self->priv->view));
-
- self->priv->active_trigger = trigger;
-
- if (self->priv->select_on_show)
- select_first_proposal (self->priv->active_page);
-
- return TRUE;
-}
-
-/**
* gtk_source_completion_finish_completion:
* @self: The #GtkSourceCompletion
*
@@ -1868,90 +1840,6 @@
}
/**
- * gtk_source_completion_set_active:
- * @self: The #GtkSourceCompletion
- * @active: %TRUE if you want to activate the completion mechanism.
- *
- * This function activate/deactivate the completion mechanism. The completion
- * connects/disconnect all signals and activate/deactivate all registered triggers.
- */
-void
-gtk_source_completion_set_active (GtkSourceCompletion *self,
- gboolean active)
-{
- GList *l;
- GtkSourceCompletionTrigger *trigger;
- gint i;
-
- g_return_if_fail (GTK_IS_SOURCE_COMPLETION (self));
-
- if (active)
- {
- if (self->priv->active)
- return;
-
- self->priv->signals_ids[TEXT_VIEW_DESTROY] =
- g_signal_connect (self->priv->view,
- "destroy",
- G_CALLBACK (view_destroy_event_cb),
- self);
- self->priv->signals_ids[TEXT_VIEW_FOCUS_OUT] =
- g_signal_connect (self->priv->view,
- "focus-out-event",
- G_CALLBACK (view_focus_out_event_cb),
- self);
- self->priv->signals_ids[TEXT_VIEW_BUTTON_PRESS] =
- g_signal_connect (self->priv->view,
- "button-press-event",
- G_CALLBACK (view_button_press_event_cb),
- self);
-
- set_manage_keys (self);
-
- /* We activate the triggers */
- for (l = self->priv->triggers; l != NULL; l = g_list_next (l))
- {
- trigger = GTK_SOURCE_COMPLETION_TRIGGER (l->data);
-
- gtk_source_completion_trigger_activate (trigger);
- }
- }
- else
- {
- for (i = 0; i < LAST_EXTERNAL_SIGNAL; i++)
- {
- if (g_signal_handler_is_connected (self->priv->view,
- self->priv->signals_ids[i]))
- {
- g_signal_handler_disconnect (self->priv->view,
- self->priv->signals_ids[i]);
- }
- self->priv->signals_ids[i] = 0;
- }
-
- for (l = self->priv->triggers; l != NULL; l = g_list_next (l))
- {
- trigger = GTK_SOURCE_COMPLETION_TRIGGER (l->data);
-
- gtk_source_completion_trigger_deactivate (trigger);
- }
- }
- self->priv->active = active;
-}
-
-/**
- * gtk_source_completion_get_active:
- * @self: The #GtkSourceCompletion
- *
- * Returns: %TRUE if the completion mechanism is active, %FALSE if not.
- */
-gboolean
-gtk_source_completion_get_active (GtkSourceCompletion *self)
-{
- return self->priv->active;
-}
-
-/**
* gtk_source_completion_get_bottom_bar:
* @self: The #GtkSourceCompletion
*
Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.h
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.h (original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletion.h Fri Apr 10 21:10:12 2009
@@ -102,8 +102,8 @@
GtkSourceCompletionTrigger
*gtk_source_completion_get_active_trigger (GtkSourceCompletion *self);
-gboolean gtk_source_completion_trigger_event (GtkSourceCompletion *self,
- GtkSourceCompletionTrigger *trigger);
+/*gboolean gtk_source_completion_trigger_event (GtkSourceCompletion *self,
+ GtkSourceCompletionTrigger *trigger);*/
void gtk_source_completion_finish_completion (GtkSourceCompletion *self);
Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontrigger.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontrigger.c (original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontrigger.c Fri Apr 10 21:10:12 2009
@@ -31,6 +31,14 @@
#include <gtksourceview/gtksourcecompletiontrigger.h>
+enum
+{
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
/**
* gtk_source_completion_trigger_get_name:
* @self: The #GtkSourceCompletionTrigger
@@ -39,7 +47,7 @@
*
* Returns: The trigger's name
*/
-const gchar*
+const gchar *
gtk_source_completion_trigger_get_name (GtkSourceCompletionTrigger *self)
{
g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_TRIGGER (self), NULL);
@@ -54,47 +62,18 @@
}
/**
- * gtk_source_completion_trigger_activate:
- * @self: The #GtkSourceCompletionTrigger
- *
- * Activate the completion trigger.
+ * gtk_source_completion_trigger_event:
+ * @self: the #GtkSourceCompletionTrigger
*
- * Returns: %TRUE if the activation was OK, %FALSE if not.
- */
-gboolean
+ * Calling this function, the completion call to all providers to get data and, if
+ * they return data, it shows the completion to the user.
+ **/
+void
gtk_source_completion_trigger_activate (GtkSourceCompletionTrigger *self)
{
- g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_TRIGGER (self), FALSE);
- return GTK_SOURCE_COMPLETION_TRIGGER_GET_INTERFACE (self)->activate (self);
-}
-
-/* Default implementation */
-static gboolean
-gtk_source_completion_trigger_activate_default (GtkSourceCompletionTrigger *self)
-{
- g_return_val_if_reached (FALSE);
-}
-
-/**
- * gtk_source_completion_trigger_deactivate:
- * @self: The #GtkSourceCompletionTrigger
- *
- * Deactive the completion trigger
- *
- * Returns: TRUE if the deactivation was OK, FALSE if not.
- */
-gboolean
-gtk_source_completion_trigger_deactivate (GtkSourceCompletionTrigger* self)
-{
- g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_TRIGGER (self), FALSE);
- return GTK_SOURCE_COMPLETION_TRIGGER_GET_INTERFACE (self)->deactivate (self);
-}
-
-/* Default implementation */
-static gboolean
-gtk_source_completion_trigger_deactivate_default (GtkSourceCompletionTrigger *self)
-{
- g_return_val_if_reached (FALSE);
+ g_return_if_fail (GTK_IS_SOURCE_COMPLETION_TRIGGER (self));
+
+ g_signal_emit (self, signals[ACTIVATE], 0);
}
static void
@@ -103,10 +82,19 @@
static gboolean initialized = FALSE;
iface->get_name = gtk_source_completion_trigger_get_name_default;
- iface->activate = gtk_source_completion_trigger_activate_default;
- iface->deactivate = gtk_source_completion_trigger_deactivate_default;
- if (!initialized) {
+ if (!initialized)
+ {
+ signals[ACTIVATE] =
+ g_signal_new ("activate",
+ GTK_TYPE_SOURCE_COMPLETION_TRIGGER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkSourceCompletionTriggerIface, activate),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
initialized = TRUE;
}
}
Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontrigger.h
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontrigger.h (original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontrigger.h Fri Apr 10 21:10:12 2009
@@ -38,21 +38,22 @@
typedef struct _GtkSourceCompletionTrigger GtkSourceCompletionTrigger;
typedef struct _GtkSourceCompletionTriggerIface GtkSourceCompletionTriggerIface;
-struct _GtkSourceCompletionTriggerIface {
+struct _GtkSourceCompletionTriggerIface
+{
GTypeInterface parent;
- const gchar* (*get_name) (GtkSourceCompletionTrigger *self);
- gboolean (*activate) (GtkSourceCompletionTrigger* self);
- gboolean (*deactivate) (GtkSourceCompletionTrigger* self);
+ /* Signals */
+ void (*activate) (GtkSourceCompletionTrigger *self);
+
+ /* Virtual Table */
+ const gchar * (*get_name) (GtkSourceCompletionTrigger *self);
};
GType gtk_source_completion_trigger_get_type (void);
const gchar *gtk_source_completion_trigger_get_name (GtkSourceCompletionTrigger *self);
-gboolean gtk_source_completion_trigger_activate (GtkSourceCompletionTrigger *self);
-
-gboolean gtk_source_completion_trigger_deactivate (GtkSourceCompletionTrigger *self);
+void gtk_source_completion_trigger_activate (GtkSourceCompletionTrigger *self);
G_END_DECLS
Modified: branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontriggerkey.c
==============================================================================
--- branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontriggerkey.c (original)
+++ branches/gtksourcecompletion/gtksourceview/gtksourcecompletiontriggerkey.c Fri Apr 10 21:10:12 2009
@@ -66,21 +66,18 @@
static gboolean
view_key_press_event_cb (GtkWidget *view,
- GdkEventKey *event,
- gpointer user_data)
+ GdkEventKey *event,
+ GtkSourceCompletionTriggerKey *self)
{
- GtkSourceCompletionTriggerKey *self;
guint s;
guint key;
- self = GTK_SOURCE_COMPLETION_TRIGGER_KEY (user_data);
s = event->state & gtk_accelerator_get_default_mod_mask ();
key = gdk_keyval_to_lower (self->priv->key);
if (s == self->priv->mod && gdk_keyval_to_lower (event->keyval) == key)
{
- gtk_source_completion_trigger_event (self->priv->completion,
- GTK_SOURCE_COMPLETION_TRIGGER (self));
+ gtk_source_completion_trigger_activate (GTK_SOURCE_COMPLETION_TRIGGER (self));
return TRUE;
}
@@ -97,41 +94,6 @@
return self->priv->trigger_name;
}
-static gboolean
-gtk_source_completion_trigger_key_real_activate (GtkSourceCompletionTrigger* base)
-{
- GtkSourceCompletionTriggerKey *self;
- GtkTextView *view;
-
- self = GTK_SOURCE_COMPLETION_TRIGGER_KEY (base);
- view = gtk_source_completion_get_view (self->priv->completion);
- g_assert (GTK_IS_TEXT_VIEW (view));
-
- self->priv->signals[CKP_GTK_TEXT_VIEW_KP] =
- g_signal_connect_data (view,
- "key-press-event",
- G_CALLBACK (view_key_press_event_cb),
- self,
- NULL,
- 0);
- return TRUE;
-}
-
-static gboolean
-gtk_source_completion_trigger_key_real_deactivate (GtkSourceCompletionTrigger* base)
-{
- GtkSourceCompletionTriggerKey *self;
- GtkTextView *view;
-
- self = GTK_SOURCE_COMPLETION_TRIGGER_KEY (base);
- view = gtk_source_completion_get_view (self->priv->completion);
-
- g_signal_handler_disconnect (view,
- self->priv->signals[CKP_GTK_TEXT_VIEW_KP]);
-
- return FALSE;
-}
-
static void
gtk_source_completion_trigger_key_init (GtkSourceCompletionTriggerKey * self)
{
@@ -167,8 +129,6 @@
gtk_source_completion_trigger_key_iface_init (GtkSourceCompletionTriggerIface * iface)
{
iface->get_name = gtk_source_completion_trigger_key_real_get_name;
- iface->activate = gtk_source_completion_trigger_key_real_activate;
- iface->deactivate = gtk_source_completion_trigger_key_real_deactivate;
}
/**
@@ -191,6 +151,7 @@
const gchar *keys)
{
GtkSourceCompletionTriggerKey *self;
+ GtkTextView *view;
g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION (completion), NULL);
g_return_val_if_fail (trigger_name != NULL, NULL);
@@ -202,6 +163,14 @@
self->priv->trigger_name = g_strdup (trigger_name);
gtk_source_completion_trigger_key_set_keys (self, keys);
+ view = gtk_source_completion_get_view (self->priv->completion);
+ g_assert (GTK_IS_TEXT_VIEW (view));
+
+ g_signal_connect (view,
+ "key-press-event",
+ G_CALLBACK (view_key_press_event_cb),
+ self);
+
return self;
}
Modified: branches/gtksourcecompletion/tests/completion-simple.c
==============================================================================
--- branches/gtksourcecompletion/tests/completion-simple.c (original)
+++ branches/gtksourcecompletion/tests/completion-simple.c Fri Apr 10 21:10:12 2009
@@ -327,8 +327,6 @@
gtk_source_completion_register_provider (comp, GTK_SOURCE_COMPLETION_PROVIDER (prov_test),
GTK_SOURCE_COMPLETION_TRIGGER (ur_trigger));
-
- gtk_source_completion_set_active (comp, TRUE);
g_signal_connect (comp, "show", G_CALLBACK (show_completion_cb), NULL);
g_signal_connect (comp, "hide", G_CALLBACK (hide_completion_cb), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]