From 18bdfb6b6c4c69c79b7948c1ef70246737fa4e2e Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 8 Jan 2019 07:57:25 +0000 Subject: [PATCH] add option 'enable keyboard shortcuts' --- src/prefs_common.c | 4 +++- src/prefs_common.h | 3 ++- src/prefs_other.c | 40 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/prefs_common.c b/src/prefs_common.c index 5ce34dde4..bc8cc2313 100644 --- a/src/prefs_common.c +++ b/src/prefs_common.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team + * Copyright (C) 1999-2019 Hiroyuki Yamamoto and the Claws Mail team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1017,6 +1017,8 @@ static PrefParam param[] = { {"gtk_can_change_accels", "FALSE", &prefs_common.gtk_can_change_accels, P_BOOL, NULL, NULL, NULL}, + {"gtk_enable_accels", "TRUE", &prefs_common.gtk_enable_accels, P_BOOL, + NULL, NULL, NULL}, {"color_new", "#0000b3", &prefs_common.color[COL_NEW], P_COLOR, NULL, NULL, NULL}, diff --git a/src/prefs_common.h b/src/prefs_common.h index 05a7896c5..d4f746a72 100644 --- a/src/prefs_common.h +++ b/src/prefs_common.h @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team + * Copyright (C) 1999-2019 Hiroyuki Yamamoto and the Claws Mail team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -458,6 +458,7 @@ struct _PrefsCommon gint io_timeout_secs; gboolean gtk_can_change_accels; + gboolean gtk_enable_accels; /* Memory cache*/ gint cache_max_mem_usage; diff --git a/src/prefs_other.c b/src/prefs_other.c index 9bd90e24b..ead5f9c35 100644 --- a/src/prefs_other.c +++ b/src/prefs_other.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 2005-2015 Colin Leroy and The Claws Mail Team + * Copyright (C) 2005-2019 Colin Leroy and The Claws Mail Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,7 @@ typedef struct _OtherPage GtkWidget *checkbtn_askonclean; GtkWidget *checkbtn_warnqueued; GtkWidget *spinbtn_iotimeout; + GtkWidget *checkbtn_gtk_enable_accels; GtkWidget *checkbtn_gtk_can_change_accels; GtkWidget *checkbtn_askonfilter; GtkWidget *checkbtn_use_shred; @@ -454,6 +455,7 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window, GtkWidget *frame_keys; GtkWidget *vbox_keys; + GtkWidget *checkbtn_gtk_enable_accels; GtkWidget *checkbtn_gtk_can_change_accels; GtkWidget *button_keybind; @@ -511,6 +513,9 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window, vbox_keys = gtkut_get_options_frame(vbox1, &frame_keys, _("Keyboard shortcuts")); + PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_enable_accels, + _("Enable keyboard shortcuts")); + PACK_CHECK_BUTTON(vbox_keys, checkbtn_gtk_can_change_accels, _("Enable customisable keyboard shortcuts")); @@ -629,6 +634,8 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window, g_signal_connect (G_OBJECT (button_change_passphrase), "clicked", G_CALLBACK (prefs_change_master_passphrase), NULL); #endif + SET_TOGGLE_SENSITIVITY(checkbtn_gtk_enable_accels, checkbtn_gtk_can_change_accels); + SET_TOGGLE_SENSITIVITY(checkbtn_gtk_enable_accels, button_keybind); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_addaddrbyclick), prefs_common.add_address_by_click); @@ -640,6 +647,8 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window, prefs_common.ask_on_clean); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued), prefs_common.warn_queued_on_exit); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_enable_accels), + prefs_common.gtk_enable_accels); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_can_change_accels), prefs_common.gtk_can_change_accels); @@ -669,6 +678,7 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window, prefs_other->checkbtn_warnqueued = checkbtn_warnqueued; prefs_other->spinbtn_iotimeout = spinbtn_iotimeout; prefs_other->checkbtn_transhdr = checkbtn_transhdr; + prefs_other->checkbtn_gtk_enable_accels = checkbtn_gtk_enable_accels; prefs_other->checkbtn_gtk_can_change_accels = checkbtn_gtk_can_change_accels; prefs_other->checkbtn_askonfilter = checkbtn_askonfilter; prefs_other->checkbtn_use_shred = checkbtn_use_shred; @@ -684,6 +694,7 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window, static void prefs_other_save(PrefsPage *_page) { OtherPage *page = (OtherPage *) _page; + gboolean gtk_enable_accels; gboolean gtk_can_change_accels; prefs_common.add_address_by_click = gtk_toggle_button_get_active( @@ -763,7 +774,26 @@ static void prefs_other_save(PrefsPage *_page) "gtk-can-change-accels", (glong)prefs_common.gtk_can_change_accels, "XProperty"); + } + gtk_enable_accels = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(page->checkbtn_gtk_enable_accels)); + if (prefs_common.gtk_enable_accels != gtk_enable_accels) { + prefs_common.gtk_enable_accels = gtk_enable_accels; + + gtk_settings_set_long_property(gtk_settings_get_default(), + "gtk-enable-accels", + (glong)prefs_common.gtk_enable_accels, + "XProperty"); + + gtk_settings_set_long_property(gtk_settings_get_default(), + "gtk-enable-mnemonics", + (glong)prefs_common.gtk_enable_accels, + "XProperty"); + } + + if (prefs_common.gtk_enable_accels != gtk_enable_accels || + prefs_common.gtk_can_change_accels != gtk_can_change_accels) { /* gtk_can_change_accels value changed : we have (only if changed) * to apply the gtk property to all widgets : */ gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE); @@ -798,6 +828,14 @@ void prefs_other_init(void) "gtk-can-change-accels", (glong)prefs_common.gtk_can_change_accels, "XProperty"); + gtk_settings_set_long_property(gtk_settings_get_default(), + "gtk-enable-accels", + (glong)prefs_common.gtk_enable_accels, + "XProperty"); + gtk_settings_set_long_property(gtk_settings_get_default(), + "gtk-enable-mnemonics", + (glong)prefs_common.gtk_enable_accels, + "XProperty"); } void prefs_other_done(void) -- 2.11.4.GIT