Skip to content

Commit 43119c2

Browse files
committed
GridDay: GTK4 prep
1 parent bbac9af commit 43119c2

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/Widgets/calendar/GridDay.vala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
3636
private Gtk.Label label;
3737
private bool valid_grab = false;
3838

39+
private Gtk.GestureMultiPress click_gesture;
40+
private Gtk.EventControllerKey key_controller;
41+
3942
public GridDay (GLib.DateTime date) {
4043
Object (date: date);
4144
}
@@ -76,8 +79,12 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
7679
show_all ();
7780

7881
// Signals and handlers
79-
button_press_event.connect (on_button_press);
80-
key_press_event.connect (on_key_press);
82+
click_gesture = new Gtk.GestureMultiPress (this);
83+
click_gesture.pressed.connect (on_button_press);
84+
85+
key_controller = new Gtk.EventControllerKey (this);
86+
key_controller.key_pressed.connect (on_key_press);
87+
8188
bind_property ("date", label, "label", GLib.BindingFlags.SYNC_CREATE, (binding, from_value, ref to_value) => {
8289
unowned var new_date = (GLib.DateTime) from_value.get_boxed ();
8390
to_value.take_string (new_date.get_day_of_month ().to_string ());
@@ -150,17 +157,16 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
150157
event_box.sensitive = sens;
151158
}
152159

153-
private bool on_button_press (Gdk.EventButton event) {
154-
if (event.type == Gdk.EventType.2BUTTON_PRESS && event.button == Gdk.BUTTON_PRIMARY) {
160+
private void on_button_press (int n_press) {
161+
if (n_press == 2) {
155162
on_event_add (date);
156163
}
157164
valid_grab = true;
158165
grab_focus ();
159-
return false;
160166
}
161167

162-
private bool on_key_press (Gdk.EventKey event) {
163-
if (event.keyval == Gdk.keyval_from_name ("Return") ) {
168+
private bool on_key_press (uint keyval) {
169+
if (keyval == Gdk.keyval_from_name ("Return") ) {
164170
on_event_add (date);
165171
return true;
166172
}

0 commit comments

Comments
 (0)