forked from AuroraMiddleware/gtk
gtkcalendar: Stop using ::key-press-event
Use GtkEventControllerKey for the task
This commit is contained in:
parent
b033e30318
commit
5081472d97
@ -86,6 +86,7 @@
|
|||||||
#include "gtkgesturemultipress.h"
|
#include "gtkgesturemultipress.h"
|
||||||
#include "gtkgesturedrag.h"
|
#include "gtkgesturedrag.h"
|
||||||
#include "gtkeventcontrollerscroll.h"
|
#include "gtkeventcontrollerscroll.h"
|
||||||
|
#include "gtkeventcontrollerkey.h"
|
||||||
|
|
||||||
#define TIMEOUT_INITIAL 500
|
#define TIMEOUT_INITIAL 500
|
||||||
#define TIMEOUT_REPEAT 50
|
#define TIMEOUT_REPEAT 50
|
||||||
@ -251,6 +252,7 @@ struct _GtkCalendarPrivate
|
|||||||
GtkGesture *press_gesture;
|
GtkGesture *press_gesture;
|
||||||
GtkGesture *drag_gesture;
|
GtkGesture *drag_gesture;
|
||||||
GtkEventController *scroll_controller;
|
GtkEventController *scroll_controller;
|
||||||
|
GtkEventController *key_controller;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gtk_calendar_finalize (GObject *calendar);
|
static void gtk_calendar_finalize (GObject *calendar);
|
||||||
@ -294,8 +296,11 @@ static void gtk_calendar_drag_update (GtkGestureDrag *gesture,
|
|||||||
double x,
|
double x,
|
||||||
double y,
|
double y,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
static gboolean gtk_calendar_key_press (GtkWidget *widget,
|
static gboolean gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller,
|
||||||
GdkEventKey *event);
|
guint keyval,
|
||||||
|
guint keycode,
|
||||||
|
GdkModifierType state,
|
||||||
|
GtkWidget *widget);
|
||||||
static gboolean gtk_calendar_event (GtkWidget *widget,
|
static gboolean gtk_calendar_event (GtkWidget *widget,
|
||||||
GdkEvent *event);
|
GdkEvent *event);
|
||||||
static void gtk_calendar_grab_notify (GtkWidget *widget,
|
static void gtk_calendar_grab_notify (GtkWidget *widget,
|
||||||
@ -373,7 +378,6 @@ gtk_calendar_class_init (GtkCalendarClass *class)
|
|||||||
widget_class->snapshot = gtk_calendar_snapshot;
|
widget_class->snapshot = gtk_calendar_snapshot;
|
||||||
widget_class->measure = gtk_calendar_measure;
|
widget_class->measure = gtk_calendar_measure;
|
||||||
widget_class->size_allocate = gtk_calendar_size_allocate;
|
widget_class->size_allocate = gtk_calendar_size_allocate;
|
||||||
widget_class->key_press_event = gtk_calendar_key_press;
|
|
||||||
widget_class->state_flags_changed = gtk_calendar_state_flags_changed;
|
widget_class->state_flags_changed = gtk_calendar_state_flags_changed;
|
||||||
widget_class->grab_notify = gtk_calendar_grab_notify;
|
widget_class->grab_notify = gtk_calendar_grab_notify;
|
||||||
widget_class->event = gtk_calendar_event;
|
widget_class->event = gtk_calendar_event;
|
||||||
@ -685,6 +689,12 @@ gtk_calendar_init (GtkCalendar *calendar)
|
|||||||
G_CALLBACK (gtk_calendar_scroll_controller_scroll),
|
G_CALLBACK (gtk_calendar_scroll_controller_scroll),
|
||||||
calendar);
|
calendar);
|
||||||
|
|
||||||
|
priv->key_controller =
|
||||||
|
gtk_event_controller_key_new (GTK_WIDGET (calendar));
|
||||||
|
g_signal_connect (priv->key_controller, "key-pressed",
|
||||||
|
G_CALLBACK (gtk_calendar_key_controller_key_pressed),
|
||||||
|
calendar);
|
||||||
|
|
||||||
if (!default_abbreviated_dayname[0])
|
if (!default_abbreviated_dayname[0])
|
||||||
for (i=0; i<7; i++)
|
for (i=0; i<7; i++)
|
||||||
{
|
{
|
||||||
@ -1320,6 +1330,7 @@ gtk_calendar_finalize (GObject *object)
|
|||||||
g_object_unref (priv->press_gesture);
|
g_object_unref (priv->press_gesture);
|
||||||
g_object_unref (priv->drag_gesture);
|
g_object_unref (priv->drag_gesture);
|
||||||
g_object_unref (priv->scroll_controller);
|
g_object_unref (priv->scroll_controller);
|
||||||
|
g_object_unref (priv->key_controller);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_calendar_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gtk_calendar_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -2755,8 +2766,11 @@ move_focus (GtkCalendar *calendar,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_calendar_key_press (GtkWidget *widget,
|
gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller,
|
||||||
GdkEventKey *event)
|
guint keyval,
|
||||||
|
guint keycode,
|
||||||
|
GdkModifierType state,
|
||||||
|
GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GtkCalendar *calendar = GTK_CALENDAR (widget);
|
GtkCalendar *calendar = GTK_CALENDAR (widget);
|
||||||
GtkCalendarPrivate *priv = calendar->priv;
|
GtkCalendarPrivate *priv = calendar->priv;
|
||||||
@ -2764,14 +2778,9 @@ gtk_calendar_key_press (GtkWidget *widget,
|
|||||||
gint old_focus_row;
|
gint old_focus_row;
|
||||||
gint old_focus_col;
|
gint old_focus_col;
|
||||||
gint row, col, day;
|
gint row, col, day;
|
||||||
guint keyval, state;
|
|
||||||
|
|
||||||
return_val = FALSE;
|
return_val = FALSE;
|
||||||
|
|
||||||
if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval) ||
|
|
||||||
!gdk_event_get_state ((GdkEvent *) event, &state))
|
|
||||||
return return_val;
|
|
||||||
|
|
||||||
old_focus_row = priv->focus_row;
|
old_focus_row = priv->focus_row;
|
||||||
old_focus_col = priv->focus_col;
|
old_focus_col = priv->focus_col;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user