Activate line on button release
This commit is contained in:
parent
db4a98aacf
commit
8c2e7e8fd0
@ -46,7 +46,7 @@ static void moo_pane_view_finalize (GObject *object);
|
|||||||
// GParamSpec *pspec);
|
// GParamSpec *pspec);
|
||||||
|
|
||||||
static void moo_pane_view_realize (GtkWidget *widget);
|
static void moo_pane_view_realize (GtkWidget *widget);
|
||||||
static gboolean moo_pane_view_button_press (GtkWidget *widget,
|
static gboolean moo_pane_view_button_release (GtkWidget *widget,
|
||||||
GdkEventButton *event);
|
GdkEventButton *event);
|
||||||
|
|
||||||
static void moo_pane_view_move_cursor (GtkTextView *text_view,
|
static void moo_pane_view_move_cursor (GtkTextView *text_view,
|
||||||
@ -54,7 +54,7 @@ static void moo_pane_view_move_cursor (GtkTextView *text_view,
|
|||||||
gint count,
|
gint count,
|
||||||
gboolean extend_selection);
|
gboolean extend_selection);
|
||||||
|
|
||||||
static gboolean activate (MooPaneView *view,
|
static void activate (MooPaneView *view,
|
||||||
int line);
|
int line);
|
||||||
static void activate_current_line (MooPaneView *view);
|
static void activate_current_line (MooPaneView *view);
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ static void moo_pane_view_class_init (MooPaneViewClass *klass)
|
|||||||
gobject_class->finalize = moo_pane_view_finalize;
|
gobject_class->finalize = moo_pane_view_finalize;
|
||||||
|
|
||||||
widget_class->realize = moo_pane_view_realize;
|
widget_class->realize = moo_pane_view_realize;
|
||||||
widget_class->button_press_event = moo_pane_view_button_press;
|
widget_class->button_release_event = moo_pane_view_button_release;
|
||||||
|
|
||||||
textview_class->move_cursor = moo_pane_view_move_cursor;
|
textview_class->move_cursor = moo_pane_view_move_cursor;
|
||||||
|
|
||||||
@ -102,9 +102,9 @@ static void moo_pane_view_class_init (MooPaneViewClass *klass)
|
|||||||
G_OBJECT_CLASS_TYPE (klass),
|
G_OBJECT_CLASS_TYPE (klass),
|
||||||
G_SIGNAL_RUN_LAST,
|
G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET (MooPaneViewClass, activate),
|
G_STRUCT_OFFSET (MooPaneViewClass, activate),
|
||||||
g_signal_accumulator_true_handled, NULL,
|
NULL, NULL,
|
||||||
_moo_marshal_BOOL__POINTER_INT,
|
_moo_marshal_VOID__POINTER_INT,
|
||||||
G_TYPE_BOOLEAN, 2,
|
G_TYPE_NONE, 2,
|
||||||
G_TYPE_POINTER, G_TYPE_INT);
|
G_TYPE_POINTER, G_TYPE_INT);
|
||||||
|
|
||||||
signals[ACTIVATE_CURRENT_LINE] =
|
signals[ACTIVATE_CURRENT_LINE] =
|
||||||
@ -223,14 +223,13 @@ get_hash_table (MooPaneView *view)
|
|||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
moo_pane_view_button_press (GtkWidget *widget,
|
moo_pane_view_button_release (GtkWidget *widget,
|
||||||
GdkEventButton *event)
|
GdkEventButton *event)
|
||||||
{
|
{
|
||||||
GtkTextView *textview = GTK_TEXT_VIEW (widget);
|
GtkTextView *textview = GTK_TEXT_VIEW (widget);
|
||||||
MooPaneView *view = MOO_PANE_VIEW (widget);
|
MooPaneView *view = MOO_PANE_VIEW (widget);
|
||||||
int buffer_x, buffer_y;
|
int buffer_x, buffer_y;
|
||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
gboolean handled = FALSE;
|
|
||||||
|
|
||||||
if (gtk_text_view_get_window_type (textview, event->window) == GTK_TEXT_WINDOW_TEXT)
|
if (gtk_text_view_get_window_type (textview, event->window) == GTK_TEXT_WINDOW_TEXT)
|
||||||
{
|
{
|
||||||
@ -240,30 +239,20 @@ moo_pane_view_button_press (GtkWidget *widget,
|
|||||||
&buffer_x, &buffer_y);
|
&buffer_x, &buffer_y);
|
||||||
/* XXX */
|
/* XXX */
|
||||||
gtk_text_view_get_line_at_y (textview, &iter, buffer_y, NULL);
|
gtk_text_view_get_line_at_y (textview, &iter, buffer_y, NULL);
|
||||||
|
activate (view, gtk_text_iter_get_line (&iter));
|
||||||
handled = activate (view, gtk_text_iter_get_line (&iter));
|
|
||||||
|
|
||||||
if (handled)
|
|
||||||
gtk_text_buffer_place_cursor (get_buffer (view), &iter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handled)
|
return GTK_WIDGET_CLASS(moo_pane_view_parent_class)->button_release_event (widget, event);
|
||||||
return GTK_WIDGET_CLASS(moo_pane_view_parent_class)->button_press_event (widget, event);
|
|
||||||
else
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
activate (MooPaneView *view,
|
activate (MooPaneView *view,
|
||||||
int line)
|
int line)
|
||||||
{
|
{
|
||||||
gboolean handled = FALSE;
|
g_signal_emit (view, signals[ACTIVATE], 0,
|
||||||
gpointer data = moo_pane_view_get_line_data (view, line);
|
moo_pane_view_get_line_data (view, line),
|
||||||
|
line);
|
||||||
g_signal_emit (view, signals[ACTIVATE], 0, data, line, &handled);
|
|
||||||
|
|
||||||
return handled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -378,10 +367,6 @@ moo_pane_view_move_cursor (GtkTextView *text_view,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean activate (MooPaneView *view,
|
|
||||||
int line);
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
moo_pane_view_realize (GtkWidget *widget)
|
moo_pane_view_realize (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ struct _MooPaneViewClass
|
|||||||
{
|
{
|
||||||
MooTextViewClass parent_class;
|
MooTextViewClass parent_class;
|
||||||
|
|
||||||
gboolean (*activate) (MooPaneView *view,
|
void (*activate) (MooPaneView *view,
|
||||||
gpointer line_data,
|
gpointer line_data,
|
||||||
int line);
|
int line);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user