mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
gtktexttag: Remove GtkTextTag::event and gtk_text_tag_event()
GtkSourceView is not using it, so it's unneeded. And it's certainly diving deep into event internals of GtkTextView which hinders a proper gesturization.
This commit is contained in:
parent
52424d8640
commit
d65d5d0a84
@ -3044,7 +3044,6 @@ GtkTextTag
|
|||||||
gtk_text_tag_new
|
gtk_text_tag_new
|
||||||
gtk_text_tag_get_priority
|
gtk_text_tag_get_priority
|
||||||
gtk_text_tag_set_priority
|
gtk_text_tag_set_priority
|
||||||
gtk_text_tag_event
|
|
||||||
gtk_text_tag_changed
|
gtk_text_tag_changed
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GTK_TEXT_TAG
|
GTK_TEXT_TAG
|
||||||
|
@ -82,11 +82,6 @@
|
|||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
#include "gtktypebuiltins.h"
|
#include "gtktypebuiltins.h"
|
||||||
|
|
||||||
enum {
|
|
||||||
EVENT,
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
/* Construct args */
|
/* Construct args */
|
||||||
@ -180,8 +175,6 @@ static void gtk_text_tag_get_property (GObject *object,
|
|||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkTextTag, gtk_text_tag, G_TYPE_OBJECT)
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkTextTag, gtk_text_tag, G_TYPE_OBJECT)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -803,35 +796,6 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
|
|||||||
ADD_SET_PROP ("font-features-set", PROP_FONT_FEATURES_SET,
|
ADD_SET_PROP ("font-features-set", PROP_FONT_FEATURES_SET,
|
||||||
P_("Font features set"),
|
P_("Font features set"),
|
||||||
P_("Whether this tag affects font features"));
|
P_("Whether this tag affects font features"));
|
||||||
|
|
||||||
/**
|
|
||||||
* GtkTextTag::event:
|
|
||||||
* @tag: the #GtkTextTag on which the signal is emitted
|
|
||||||
* @object: the object the event was fired from (typically a #GtkTextView)
|
|
||||||
* @event: the event which triggered the signal
|
|
||||||
* @iter: a #GtkTextIter pointing at the location the event occurred
|
|
||||||
*
|
|
||||||
* The ::event signal is emitted when an event occurs on a region of the
|
|
||||||
* buffer marked with this tag.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE to stop other handlers from being invoked for the
|
|
||||||
* event. %FALSE to propagate the event further.
|
|
||||||
*/
|
|
||||||
signals[EVENT] =
|
|
||||||
g_signal_new (I_("event"),
|
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET (GtkTextTagClass, event),
|
|
||||||
_gtk_boolean_handled_accumulator, NULL,
|
|
||||||
_gtk_marshal_BOOLEAN__OBJECT_BOXED_BOXED,
|
|
||||||
G_TYPE_BOOLEAN,
|
|
||||||
3,
|
|
||||||
G_TYPE_OBJECT,
|
|
||||||
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
|
|
||||||
GTK_TYPE_TEXT_ITER);
|
|
||||||
g_signal_set_va_marshaller (signals[EVENT],
|
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
|
||||||
_gtk_marshal_BOOLEAN__OBJECT_BOXED_BOXEDv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2065,40 +2029,6 @@ gtk_text_tag_set_priority (GtkTextTag *tag,
|
|||||||
priv->priority = priority;
|
priv->priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_text_tag_event:
|
|
||||||
* @tag: a #GtkTextTag
|
|
||||||
* @event_object: object that received the event, such as a widget
|
|
||||||
* @event: the event
|
|
||||||
* @iter: location where the event was received
|
|
||||||
*
|
|
||||||
* Emits the “event” signal on the #GtkTextTag.
|
|
||||||
*
|
|
||||||
* Returns: result of signal emission (whether the event was handled)
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gtk_text_tag_event (GtkTextTag *tag,
|
|
||||||
GObject *event_object,
|
|
||||||
GdkEvent *event,
|
|
||||||
const GtkTextIter *iter)
|
|
||||||
{
|
|
||||||
gboolean retval = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
|
|
||||||
g_return_val_if_fail (G_IS_OBJECT (event_object), FALSE);
|
|
||||||
g_return_val_if_fail (event != NULL, FALSE);
|
|
||||||
|
|
||||||
g_signal_emit (tag,
|
|
||||||
signals[EVENT],
|
|
||||||
0,
|
|
||||||
event_object,
|
|
||||||
event,
|
|
||||||
iter,
|
|
||||||
&retval);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_text_tag_changed:
|
* gtk_text_tag_changed:
|
||||||
* @tag: a #GtkTextTag.
|
* @tag: a #GtkTextTag.
|
||||||
|
@ -86,11 +86,6 @@ struct _GtkTextTagClass
|
|||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
gboolean (* event) (GtkTextTag *tag,
|
|
||||||
GObject *event_object, /* widget, canvas item, whatever */
|
|
||||||
GdkEvent *event, /* the event itself */
|
|
||||||
const GtkTextIter *iter); /* location of event in buffer */
|
|
||||||
|
|
||||||
/* Padding for future expansion */
|
/* Padding for future expansion */
|
||||||
void (*_gtk_reserved1) (void);
|
void (*_gtk_reserved1) (void);
|
||||||
void (*_gtk_reserved2) (void);
|
void (*_gtk_reserved2) (void);
|
||||||
@ -107,11 +102,6 @@ gint gtk_text_tag_get_priority (GtkTextTag *tag);
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_text_tag_set_priority (GtkTextTag *tag,
|
void gtk_text_tag_set_priority (GtkTextTag *tag,
|
||||||
gint priority);
|
gint priority);
|
||||||
GDK_AVAILABLE_IN_ALL
|
|
||||||
gboolean gtk_text_tag_event (GtkTextTag *tag,
|
|
||||||
GObject *event_object,
|
|
||||||
GdkEvent *event,
|
|
||||||
const GtkTextIter *iter);
|
|
||||||
GDK_AVAILABLE_IN_3_20
|
GDK_AVAILABLE_IN_3_20
|
||||||
void gtk_text_tag_changed (GtkTextTag *tag,
|
void gtk_text_tag_changed (GtkTextTag *tag,
|
||||||
gboolean size_changed);
|
gboolean size_changed);
|
||||||
|
@ -409,8 +409,6 @@ static void gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture,
|
|||||||
gdouble offset_y,
|
gdouble offset_y,
|
||||||
GtkTextView *text_view);
|
GtkTextView *text_view);
|
||||||
|
|
||||||
static gint gtk_text_view_event (GtkWidget *widget,
|
|
||||||
GdkEvent *event);
|
|
||||||
static gint gtk_text_view_key_press_event (GtkWidget *widget,
|
static gint gtk_text_view_key_press_event (GtkWidget *widget,
|
||||||
GdkEventKey *event);
|
GdkEventKey *event);
|
||||||
static gint gtk_text_view_key_release_event (GtkWidget *widget,
|
static gint gtk_text_view_key_release_event (GtkWidget *widget,
|
||||||
@ -741,7 +739,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
|
|||||||
widget_class->state_flags_changed = gtk_text_view_state_flags_changed;
|
widget_class->state_flags_changed = gtk_text_view_state_flags_changed;
|
||||||
widget_class->measure = gtk_text_view_measure;
|
widget_class->measure = gtk_text_view_measure;
|
||||||
widget_class->size_allocate = gtk_text_view_size_allocate;
|
widget_class->size_allocate = gtk_text_view_size_allocate;
|
||||||
widget_class->event = gtk_text_view_event;
|
|
||||||
widget_class->key_press_event = gtk_text_view_key_press_event;
|
widget_class->key_press_event = gtk_text_view_key_press_event;
|
||||||
widget_class->key_release_event = gtk_text_view_key_release_event;
|
widget_class->key_release_event = gtk_text_view_key_release_event;
|
||||||
widget_class->focus_in_event = gtk_text_view_focus_in_event;
|
widget_class->focus_in_event = gtk_text_view_focus_in_event;
|
||||||
@ -4886,77 +4883,6 @@ gtk_text_view_unobscure_mouse_cursor (GtkTextView *text_view)
|
|||||||
* Events
|
* Events
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static gboolean
|
|
||||||
get_event_coordinates (GdkEvent *event, gint *x, gint *y)
|
|
||||||
{
|
|
||||||
gdouble event_x, event_y;
|
|
||||||
|
|
||||||
if (event)
|
|
||||||
switch ((guint) gdk_event_get_event_type (event))
|
|
||||||
{
|
|
||||||
case GDK_MOTION_NOTIFY:
|
|
||||||
case GDK_BUTTON_PRESS:
|
|
||||||
case GDK_BUTTON_RELEASE:
|
|
||||||
gdk_event_get_coords (event, &event_x, &event_y);
|
|
||||||
*x = event_x;
|
|
||||||
*y = event_y;
|
|
||||||
return TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_KEY_PRESS:
|
|
||||||
case GDK_KEY_RELEASE:
|
|
||||||
case GDK_ENTER_NOTIFY:
|
|
||||||
case GDK_LEAVE_NOTIFY:
|
|
||||||
case GDK_PROPERTY_NOTIFY:
|
|
||||||
case GDK_SELECTION_CLEAR:
|
|
||||||
case GDK_SELECTION_REQUEST:
|
|
||||||
case GDK_SELECTION_NOTIFY:
|
|
||||||
case GDK_PROXIMITY_IN:
|
|
||||||
case GDK_PROXIMITY_OUT:
|
|
||||||
case GDK_DRAG_ENTER:
|
|
||||||
case GDK_DRAG_LEAVE:
|
|
||||||
case GDK_DRAG_MOTION:
|
|
||||||
case GDK_DRAG_STATUS:
|
|
||||||
case GDK_DROP_START:
|
|
||||||
case GDK_DROP_FINISHED:
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
emit_event_on_tags (GtkWidget *widget,
|
|
||||||
GdkEvent *event,
|
|
||||||
GtkTextIter *iter)
|
|
||||||
{
|
|
||||||
GSList *tags;
|
|
||||||
GSList *tmp;
|
|
||||||
gboolean retval = FALSE;
|
|
||||||
|
|
||||||
tags = gtk_text_iter_get_tags (iter);
|
|
||||||
|
|
||||||
tmp = tags;
|
|
||||||
while (tmp != NULL)
|
|
||||||
{
|
|
||||||
GtkTextTag *tag = tmp->data;
|
|
||||||
|
|
||||||
if (gtk_text_tag_event (tag, G_OBJECT (widget), event, iter))
|
|
||||||
{
|
|
||||||
retval = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = tmp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_free (tags);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_text_window_to_widget_coords (GtkTextView *text_view,
|
_text_window_to_widget_coords (GtkTextView *text_view,
|
||||||
gint *x,
|
gint *x,
|
||||||
@ -5264,54 +5190,6 @@ gtk_text_view_update_handles (GtkTextView *text_view,
|
|||||||
GTK_TEXT_HANDLE_POSITION_SELECTION_START);
|
GTK_TEXT_HANDLE_POSITION_SELECTION_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
|
||||||
gtk_text_view_event (GtkWidget *widget, GdkEvent *event)
|
|
||||||
{
|
|
||||||
GtkTextView *text_view;
|
|
||||||
GtkTextViewPrivate *priv;
|
|
||||||
gint x = 0, y = 0;
|
|
||||||
GdkEventType event_type;
|
|
||||||
|
|
||||||
text_view = GTK_TEXT_VIEW (widget);
|
|
||||||
priv = text_view->priv;
|
|
||||||
|
|
||||||
if (priv->layout == NULL ||
|
|
||||||
get_buffer (text_view) == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
event_type = gdk_event_get_event_type (event);
|
|
||||||
|
|
||||||
if (get_event_coordinates (event, &x, &y))
|
|
||||||
{
|
|
||||||
GtkTextIter iter;
|
|
||||||
|
|
||||||
x += priv->xoffset;
|
|
||||||
y += priv->yoffset;
|
|
||||||
|
|
||||||
/* FIXME this is slow and we do it twice per event.
|
|
||||||
* My favorite solution is to have GtkTextLayout cache
|
|
||||||
* the last couple lookups.
|
|
||||||
*/
|
|
||||||
gtk_text_layout_get_iter_at_pixel (priv->layout,
|
|
||||||
&iter,
|
|
||||||
x, y);
|
|
||||||
|
|
||||||
return emit_event_on_tags (widget, event, &iter);
|
|
||||||
}
|
|
||||||
else if (event_type == GDK_KEY_PRESS ||
|
|
||||||
event_type == GDK_KEY_RELEASE)
|
|
||||||
{
|
|
||||||
GtkTextIter iter;
|
|
||||||
|
|
||||||
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter,
|
|
||||||
gtk_text_buffer_get_insert (get_buffer (text_view)));
|
|
||||||
|
|
||||||
return emit_event_on_tags (widget, event, &iter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user