Fri, 19 Oct 2018 17:22:33 -0500
pidgin: Drop keyboard shortcut preferences
This patch drops the keyboard shortcut preferences, which only had
the option to close a conversation window with the Escape key instead
of the standard Ctrl+W. Since Gtk 3.10 and forward ignore the
gtk-can-change-accels setting, disallowing users from changing
accelerators in the interface, this was the last configuration which
required manually wrangling accel groups.
Future patches are intended to drop the manual GtkAccelGroup wrangling
in preparation for porting things to GtkBuilder. I haven't managed
to get such wrangling working with it. Since there's such little
benefit attempting to support this feature, it's been decided to
keep things simple and drop it.
If the accelerators are needed to be changed by an end user, there
is the possibility of overriding the GResource .ui files, without
recompiling, once the interfaces have been ported to GtkBuilder.
--- a/pidgin/gtkconv.c Fri Oct 12 01:42:09 2018 +0000 +++ b/pidgin/gtkconv.c Fri Oct 19 17:22:33 2018 -0500 @@ -3196,7 +3196,7 @@ { "Remove", GTK_STOCK_REMOVE, N_("_Remove..."), NULL, NULL, G_CALLBACK(menu_add_remove_cb) }, { "InsertLink", PIDGIN_STOCK_TOOLBAR_INSERT_LINK, N_("Insert Lin_k..."), NULL, NULL, G_CALLBACK(menu_insert_link_cb) }, { "InsertImage", PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, N_("Insert Imag_e..."), NULL, NULL, G_CALLBACK(menu_insert_image_cb) }, - { "Close", GTK_STOCK_CLOSE, N_("_Close"), NULL, NULL, G_CALLBACK(menu_close_conv_cb) }, + { "Close", GTK_STOCK_CLOSE, N_("_Close"), "<control>W", NULL, G_CALLBACK(menu_close_conv_cb) }, /* Options */ { "OptionsMenu", NULL, N_("_Options"), NULL, NULL, NULL },
--- a/pidgin/gtkprefs.c Fri Oct 12 01:42:09 2018 +0000 +++ b/pidgin/gtkprefs.c Fri Oct 19 17:22:33 2018 -0500 @@ -122,9 +122,6 @@ PidginPrefCombo tab_side; PidginPrefCombo placement; } conversations; - struct { - GtkWidget *escape; - } keys; } iface; /* Browser page */ @@ -1947,97 +1944,6 @@ purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", ""); } - -#define CONVERSATION_CLOSE_ACCEL_PATH "<Actions>/ConversationActions/Close" - -/* Filled in in keyboard_shortcuts(). */ -static GtkAccelKey ctrl_w = { 0, 0, 0 }; -static GtkAccelKey escape = { 0, 0, 0 }; - -static guint escape_closes_conversation_cb_id = 0; - -static gboolean -accel_is_escape(GtkAccelKey *k) -{ - return (k->accel_key == escape.accel_key - && k->accel_mods == escape.accel_mods); -} - -/* Update the tickybox in Preferences when the keybinding for Conversation -> - * Close is changed via Gtk. - */ -static void -conversation_close_accel_changed_cb (GtkAccelMap *object, - gchar *accel_path, - guint accel_key, - GdkModifierType accel_mods, - gpointer checkbox_) -{ - GtkToggleButton *checkbox = GTK_TOGGLE_BUTTON(checkbox_); - GtkAccelKey new = { accel_key, accel_mods, 0 }; - - g_signal_handler_block(checkbox, escape_closes_conversation_cb_id); - gtk_toggle_button_set_active(checkbox, accel_is_escape(&new)); - g_signal_handler_unblock(checkbox, escape_closes_conversation_cb_id); -} - - -static void -escape_closes_conversation_cb(GtkWidget *w, - gpointer unused) -{ - gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); - gboolean changed; - GtkAccelKey *new_key = active ? &escape : &ctrl_w; - - changed = gtk_accel_map_change_entry(CONVERSATION_CLOSE_ACCEL_PATH, - new_key->accel_key, new_key->accel_mods, TRUE); - - /* If another path is already bound to the new accelerator, - * _change_entry tries to delete that binding (because it was passed - * replace=TRUE). If that other path is locked, then _change_entry - * will fail. We don't ever lock any accelerator paths, so this case - * should never arise. - */ - if(!changed) - purple_debug_warning("gtkprefs", "Escape accel failed to change\n"); -} - - -/* Creates preferences for keyboard shortcuts that it's hard to change with the - * standard Gtk accelerator-changing mechanism. - */ -static void -keyboard_shortcuts(GtkWidget *checkbox) -{ - GtkAccelKey current = { 0, 0, 0 }; - GtkAccelMap *map = gtk_accel_map_get(); - - /* Maybe it would be better just to hardcode the values? - * -- resiak, 2007-04-30 - */ - if (ctrl_w.accel_key == 0) - { - gtk_accelerator_parse ("<Control>w", &(ctrl_w.accel_key), - &(ctrl_w.accel_mods)); - g_assert(ctrl_w.accel_key != 0); - - gtk_accelerator_parse ("Escape", &(escape.accel_key), - &(escape.accel_mods)); - g_assert(escape.accel_key != 0); - } - - gtk_accel_map_lookup_entry(CONVERSATION_CLOSE_ACCEL_PATH, ¤t); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), - accel_is_escape(¤t)); - - escape_closes_conversation_cb_id = g_signal_connect(checkbox, - "clicked", G_CALLBACK(escape_closes_conversation_cb), NULL); - - g_signal_connect_object(map, "changed::" CONVERSATION_CLOSE_ACCEL_PATH, - G_CALLBACK(conversation_close_accel_changed_cb), checkbox, (GConnectFlags)0); -} - static void bind_interface_page(PidginPrefsWindow *win) { @@ -2086,8 +1992,6 @@ &win->iface.conversations.placement, names); g_list_free(names); - - keyboard_shortcuts(win->iface.keys.escape); } /* This is also Win32-specific, but must be visible for Glade binding. */ @@ -4034,9 +3938,6 @@ gtk_widget_class_bind_template_child( widget_class, PidginPrefsWindow, iface.conversations.placement.combo); - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, - iface.keys.escape); /* Browser page */ gtk_widget_class_bind_template_child(
--- a/pidgin/resources/Prefs/prefs.ui Fri Oct 12 01:42:09 2018 +0000 +++ b/pidgin/resources/Prefs/prefs.ui Fri Oct 19 17:22:33 2018 -0500 @@ -667,47 +667,6 @@ <property name="position">2</property> </packing> </child> - <child> - <object class="GtkFrame"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkAlignment"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="bottom_padding">12</property> - <property name="left_padding">12</property> - <child> - <object class="GtkCheckButton" id="iface.keys.escape"> - <property name="label" translatable="yes">Cl_ose conversations with the Escape key</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Keyboard Shortcuts</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> </object> </child> <child type="tab">