diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2018-03-23 16:09:37 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-04-05 19:26:55 +0200 |
commit | 73fe140b10d9d639cb0beb68278092e61fdca4d8 (patch) | |
tree | e3edc973e5be799aec56af294d093b3c40b2d80f /gtk/gtkcalendar.c | |
parent | b0cd5cd7c8dc63ae2179083b4b6e9bf9ce519cb2 (diff) | |
download | gtk+-73fe140b10d9d639cb0beb68278092e61fdca4d8.tar.gz |
gtkcalendar: Use key controller to track focus changes
Diffstat (limited to 'gtk/gtkcalendar.c')
-rw-r--r-- | gtk/gtkcalendar.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index e52b5e7911..643bbf9ddb 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -301,8 +301,8 @@ static gboolean gtk_calendar_key_controller_key_pressed (GtkEventControllerKey * guint keycode, GdkModifierType state, GtkWidget *widget); -static gboolean gtk_calendar_event (GtkWidget *widget, - GdkEvent *event); +static void gtk_calendar_key_controller_focus (GtkEventControllerKey *controller, + GtkWidget *widget); static void gtk_calendar_grab_notify (GtkWidget *widget, gboolean was_grabbed); static void gtk_calendar_state_flags_changed (GtkWidget *widget, @@ -380,7 +380,6 @@ gtk_calendar_class_init (GtkCalendarClass *class) widget_class->size_allocate = gtk_calendar_size_allocate; widget_class->state_flags_changed = gtk_calendar_state_flags_changed; widget_class->grab_notify = gtk_calendar_grab_notify; - widget_class->event = gtk_calendar_event; widget_class->query_tooltip = gtk_calendar_query_tooltip; widget_class->drag_data_get = gtk_calendar_drag_data_get; @@ -694,6 +693,12 @@ gtk_calendar_init (GtkCalendar *calendar) g_signal_connect (priv->key_controller, "key-pressed", G_CALLBACK (gtk_calendar_key_controller_key_pressed), calendar); + g_signal_connect (priv->key_controller, "focus-in", + G_CALLBACK (gtk_calendar_key_controller_focus), + calendar); + g_signal_connect (priv->key_controller, "focus-out", + G_CALLBACK (gtk_calendar_key_controller_focus), + calendar); if (!default_abbreviated_dayname[0]) for (i=0; i<7; i++) @@ -2870,6 +2875,17 @@ gtk_calendar_key_controller_key_pressed (GtkEventControllerKey *controller, return return_val; } +static void +gtk_calendar_key_controller_focus (GtkEventControllerKey *key, + GtkWidget *widget) +{ + GtkCalendar *calendar = GTK_CALENDAR (widget); + + calendar_queue_refresh (calendar); + calendar_stop_spinning (calendar); + calendar->priv->in_drag = 0; +} + /**************************************** * Misc widget methods * @@ -2897,23 +2913,6 @@ gtk_calendar_grab_notify (GtkWidget *widget, calendar_stop_spinning (GTK_CALENDAR (widget)); } -static gboolean -gtk_calendar_event (GtkWidget *widget, - GdkEvent *event) -{ - GtkCalendar *calendar = GTK_CALENDAR (widget); - - if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE) - { - calendar_queue_refresh (calendar); - calendar_stop_spinning (calendar); - - calendar->priv->in_drag = 0; - } - - return GDK_EVENT_PROPAGATE; -} - /**************************************** * Drag and Drop * |