summaryrefslogtreecommitdiff
path: root/src/math-window.c
diff options
context:
space:
mode:
authormbkma <[email protected]>2020-05-31 01:04:31 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2020-07-13 22:25:30 +0200
commitf649f841b919cf2fa5c40f7d8b1bf1dd61300a81 (patch)
tree81457fb376b8be5baf30448eb919d968fe5a5b40 /src/math-window.c
parente6206b2c8a4123be75b1f4a7b811d91136e667e5 (diff)
downloadmate-calc-f649f841b919cf2fa5c40f7d8b1bf1dd61300a81.tar.bz2
mate-calc-f649f841b919cf2fa5c40f7d8b1bf1dd61300a81.tar.xz
Implement navigation through history stack equations using keyboard
Diffstat (limited to 'src/math-window.c')
-rw-r--r--src/math-window.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/math-window.c b/src/math-window.c
index 08ac3e3..e872f4f 100644
--- a/src/math-window.c
+++ b/src/math-window.c
@@ -202,7 +202,29 @@ key_press_cb(MathWindow *window, GdkEventKey *event)
gboolean result;
g_signal_emit_by_name(window->priv->display, "key-press-event", event, &result);
- if (math_buttons_get_mode (window->priv->buttons) == PROGRAMMING && (event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) {
+ /* Keyboard navigation for history */
+ if ((event->state & GDK_MOD1_MASK) == GDK_MOD1_MASK && (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_Down))
+ {
+ switch (event->keyval)
+ {
+ case GDK_KEY_Up:
+ math_history_set_current(window->priv->history, -1);
+ break;
+ case GDK_KEY_Down:
+ math_history_set_current(window->priv->history, 1);
+ break;
+ }
+
+ MathHistoryEntry *entry = math_history_get_entry_at(window->priv->history, math_history_get_current(window->priv->history));
+ if (entry)
+ {
+ gchar *equation_string = math_history_entry_get_equation(entry);
+ math_equation_set(window->priv->equation, equation_string);
+ g_free(equation_string);
+ }
+ return TRUE;
+ }
+ else if (math_buttons_get_mode (window->priv->buttons) == PROGRAMMING && (event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) {
switch(event->keyval)
{
/* Binary */
@@ -540,7 +562,7 @@ static void create_menu(MathWindow* window)
menu = add_menu(window->priv->menu_bar, VIEW_MENU_LABEL);
window->priv->view_history_menu_item = add_menu_item(menu, gtk_check_menu_item_new_with_mnemonic(VIEW_HISTORY_LABEL), G_CALLBACK(history_check_toggled_cb), window);
- gtk_widget_add_accelerator(window->priv->view_history_menu_item, "activate", accel_group, GDK_KEY_H, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator(window->priv->view_history_menu_item, "activate", accel_group, GDK_KEY_H, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
menu = add_menu(window->priv->menu_bar, HELP_MENU_LABEL);
menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_icon("help-browser", HELP_CONTENTS_LABEL, accel_group), G_CALLBACK(help_cb), window);