[gnome-calculator/wip-gtk4-port] More preparations for Gtk4 with compatible calls
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/wip-gtk4-port] More preparations for Gtk4 with compatible calls
- Date: Fri, 1 Oct 2021 16:59:45 +0000 (UTC)
commit de43979e3e1668ac191018509015a0cb47a7706c
Author: Robert Roth <robert roth off gmail com>
Date: Fri Oct 1 19:58:06 2021 +0300
More preparations for Gtk4 with compatible calls
src/gnome-calculator.vala | 2 +-
src/math-window.vala | 25 ++++++++++++++-----------
2 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala
index 49b0b92b..befe3b73 100644
--- a/src/gnome-calculator.vala
+++ b/src/gnome-calculator.vala
@@ -306,7 +306,7 @@ public class Calculator : Gtk.Application
{
try
{
- Gtk.show_uri_on_window (get_active_window (), "help:gnome-calculator",
Gtk.get_current_event_time ());
+ Gtk.show_uri (get_active_window ().get_screen (), "help:gnome-calculator", Gdk.CURRENT_TIME);
}
catch (Error e)
{
diff --git a/src/math-window.vala b/src/math-window.vala
index e0f7c444..28c8198c 100644
--- a/src/math-window.vala
+++ b/src/math-window.vala
@@ -16,7 +16,7 @@ public class MathWindow : Hdy.ApplicationWindow
public MathEquation equation { get { return _equation; } }
private MathDisplay _display;
- public MathDisplay display { get { return _display; } }
+ public MathDisplay math_display { get { return _display; } }
private MathButtons _buttons;
public MathButtons buttons { get { return _buttons; } }
private bool right_aligned;
@@ -31,6 +31,8 @@ public class MathWindow : Hdy.ApplicationWindow
[GtkChild]
private unowned MathConverter converter;
+ private Gtk.EventControllerKey event_controller;
+
private const ActionEntry[] window_entries =
{
{ "copy", copy_cb, null, null, null },
@@ -56,13 +58,17 @@ public class MathWindow : Hdy.ApplicationWindow
converter.set_category (null);
converter.set_conversion (equation.source_units, equation.target_units);
+ event_controller = new Gtk.EventControllerKey (this as Gtk.Widget);
+ // (this as Gtk.Widget).add_controller (event_controller);
+ event_controller.key_pressed.connect (key_press_cb);
+
_display = new MathDisplay (equation);
grid.attach (_display, 0, 1, 1, 1);
_display.show ();
_display.grabfocus ();
_buttons = new MathButtons (equation);
- grid.add(_buttons);
+ grid.attach_next_to(_buttons, _display, Gtk.PositionType.BOTTOM);
remove_buttons = (_buttons.mode != ButtonMode.KEYBOARD) ? true : false;
@@ -125,7 +131,7 @@ public class MathWindow : Hdy.ApplicationWindow
converter.show ();
}
- display.set_enable_osk (remove_buttons);
+ _display.set_enable_osk (remove_buttons);
}
public void critical_error (string title, string contents)
@@ -142,13 +148,11 @@ public class MathWindow : Hdy.ApplicationWindow
destroy ();
}
- protected override bool key_press_event (Gdk.EventKey event)
+ protected bool key_press_cb (Gtk.EventControllerKey controller, uint keyval, uint keycode,
Gdk.ModifierType state)
{
- var result = base.key_press_event (event);
-
- if (buttons.mode == ButtonMode.PROGRAMMING && (event.state & Gdk.ModifierType.CONTROL_MASK) ==
Gdk.ModifierType.CONTROL_MASK)
+ if (buttons.mode == ButtonMode.PROGRAMMING && (state & Gdk.ModifierType.CONTROL_MASK) ==
Gdk.ModifierType.CONTROL_MASK)
{
- switch (event.keyval)
+ switch (keyval)
{
/* Binary */
case Gdk.Key.b:
@@ -168,8 +172,7 @@ public class MathWindow : Hdy.ApplicationWindow
return true;
}
}
-
- return result;
+ return false;
}
[GtkCallback]
@@ -216,7 +219,7 @@ public class MathWindow : Hdy.ApplicationWindow
popover.hide ();
menu_button.set_active (false);
- display.grab_focus ();
+ _display.grab_focus ();
var mode = ButtonMode.BASIC;
var mode_str = parameter.get_string (null);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]