[gtk/gbsneto/shortcuts-rebased: 81/112] window: Remove all old mnemonic handling API
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gbsneto/shortcuts-rebased: 81/112] window: Remove all old mnemonic handling API
- Date: Thu, 16 May 2019 00:13:09 +0000 (UTC)
commit 3839d41d44c183aff12452be1374a2f3e44443ab
Author: Benjamin Otte <otte redhat com>
Date: Thu Aug 16 07:49:50 2018 +0200
window: Remove all old mnemonic handling API
docs/reference/gtk/gtk4-sections.txt | 4 -
gtk/a11y/gtkmenuitemaccessible.c | 13 +-
gtk/gtkapplicationaccels.c | 2 +-
gtk/gtkwindow.c | 250 ++++-------------------------------
gtk/gtkwindow.h | 14 --
gtk/gtkwindowprivate.h | 1 -
6 files changed, 28 insertions(+), 256 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 15433d8614..15df476dce 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4662,8 +4662,6 @@ gtk_window_is_active
gtk_window_is_maximized
gtk_window_get_toplevels
gtk_window_list_toplevels
-gtk_window_add_mnemonic
-gtk_window_remove_mnemonic
gtk_window_get_focus
gtk_window_set_focus
gtk_window_get_default_widget
@@ -4686,7 +4684,6 @@ gtk_window_begin_resize_drag
gtk_window_begin_move_drag
gtk_window_set_decorated
gtk_window_set_deletable
-gtk_window_set_mnemonic_modifier
gtk_window_set_type_hint
gtk_window_set_accept_focus
gtk_window_set_focus_on_map
@@ -4697,7 +4694,6 @@ gtk_window_get_default_icon_name
gtk_window_get_default_size
gtk_window_get_destroy_with_parent
gtk_window_get_icon_name
-gtk_window_get_mnemonic_modifier
gtk_window_get_modal
gtk_window_get_size
gtk_window_get_title
diff --git a/gtk/a11y/gtkmenuitemaccessible.c b/gtk/a11y/gtkmenuitemaccessible.c
index 41cf7417b5..5fd95b4c32 100644
--- a/gtk/a11y/gtkmenuitemaccessible.c
+++ b/gtk/a11y/gtkmenuitemaccessible.c
@@ -520,7 +520,6 @@ gtk_menu_item_accessible_get_keybinding (AtkAction *action,
temp_item = item;
while (TRUE)
{
- GdkModifierType mnemonic_modifier = 0;
guint key_val;
gchar *key, *temp_keybinding;
@@ -532,23 +531,13 @@ gtk_menu_item_accessible_get_keybinding (AtkAction *action,
/* parent can be NULL when activating a window from the panel */
return NULL;
- if (GTK_IS_MENU_BAR (parent))
- {
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (parent);
- if (toplevel && GTK_IS_WINDOW (toplevel))
- mnemonic_modifier =
- gtk_window_get_mnemonic_modifier (GTK_WINDOW (toplevel));
- }
-
child = find_item_label (temp_item);
if (GTK_IS_LABEL (child))
{
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (child));
if (key_val != GDK_KEY_VoidSymbol)
{
- key = gtk_accelerator_name (key_val, mnemonic_modifier);
+ key = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
if (full_keybinding)
temp_keybinding = g_strconcat (key, ":", full_keybinding, NULL);
else
diff --git a/gtk/gtkapplicationaccels.c b/gtk/gtkapplicationaccels.c
index b4a14b9daa..43e35d79e4 100644
--- a/gtk/gtkapplicationaccels.c
+++ b/gtk/gtkapplicationaccels.c
@@ -347,7 +347,7 @@ gtk_application_accels_foreach_key (GtkApplicationAccels *accels,
{
AccelKey *accel_key = key;
- (* callback) (window, accel_key->key, accel_key->modifier, FALSE, user_data);
+ (* callback) (window, accel_key->key, accel_key->modifier, user_data);
}
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 03c866b6cc..c3ef5390fa 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -53,7 +53,6 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkmessagedialog.h"
-#include "gtkmnemonichash.h"
#include "gtkmenu.h"
#include "gtkmenubar.h"
#include "gtkmenushellprivate.h"
@@ -189,8 +188,6 @@ struct _GtkWindowPopover
typedef struct
{
- GtkMnemonicHash *mnemonic_hash;
-
GtkWidget *attach_widget;
GtkWidget *default_widget;
GtkWidget *initial_focus;
@@ -203,8 +200,6 @@ typedef struct
GQueue popovers;
- GdkModifierType mnemonic_modifier;
-
gchar *startup_id;
gchar *title;
@@ -1847,7 +1842,6 @@ gtk_window_init (GtkWindow *window)
priv->modal = FALSE;
priv->gravity = GDK_GRAVITY_NORTH_WEST;
priv->decorated = TRUE;
- priv->mnemonic_modifier = GDK_MOD1_MASK;
priv->display = gdk_display_get_default ();
priv->state = GDK_SURFACE_STATE_WITHDRAWN;
@@ -2741,130 +2735,6 @@ gtk_window_remove_accel_group (GtkWindow *window,
_gtk_window_notify_keys_changed (window);
}
-static GtkMnemonicHash *
-gtk_window_get_mnemonic_hash (GtkWindow *window,
- gboolean create)
-{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-
- if (!priv->mnemonic_hash && create)
- priv->mnemonic_hash = _gtk_mnemonic_hash_new ();
-
- return priv->mnemonic_hash;
-}
-
-/**
- * gtk_window_add_mnemonic:
- * @window: a #GtkWindow
- * @keyval: the mnemonic
- * @target: the widget that gets activated by the mnemonic
- *
- * Adds a mnemonic to this window.
- */
-void
-gtk_window_add_mnemonic (GtkWindow *window,
- guint keyval,
- GtkWidget *target)
-{
- g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail (GTK_IS_WIDGET (target));
-
- _gtk_mnemonic_hash_add (gtk_window_get_mnemonic_hash (window, TRUE),
- keyval, target);
- _gtk_window_notify_keys_changed (window);
-}
-
-/**
- * gtk_window_remove_mnemonic:
- * @window: a #GtkWindow
- * @keyval: the mnemonic
- * @target: the widget that gets activated by the mnemonic
- *
- * Removes a mnemonic from this window.
- */
-void
-gtk_window_remove_mnemonic (GtkWindow *window,
- guint keyval,
- GtkWidget *target)
-{
- g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail (GTK_IS_WIDGET (target));
-
- _gtk_mnemonic_hash_remove (gtk_window_get_mnemonic_hash (window, TRUE),
- keyval, target);
- _gtk_window_notify_keys_changed (window);
-}
-
-/*
- * gtk_window_mnemonic_activate:
- * @window: a #GtkWindow
- * @keyval: the mnemonic
- * @modifier: the modifiers
- *
- * Activates the targets associated with the mnemonic.
- *
- * Returns: %TRUE if the activation is done.
- */
-static gboolean
-gtk_window_mnemonic_activate (GtkWindow *window,
- guint keyval,
- GdkModifierType modifier)
-{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-
- g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
-
- if (priv->mnemonic_modifier == (modifier & gtk_accelerator_get_default_mod_mask ()))
- {
- GtkMnemonicHash *mnemonic_hash = gtk_window_get_mnemonic_hash (window, FALSE);
- if (mnemonic_hash)
- return _gtk_mnemonic_hash_activate (mnemonic_hash, keyval);
- }
-
- return FALSE;
-}
-
-/**
- * gtk_window_set_mnemonic_modifier:
- * @window: a #GtkWindow
- * @modifier: the modifier mask used to activate
- * mnemonics on this window.
- *
- * Sets the mnemonic modifier for this window.
- **/
-void
-gtk_window_set_mnemonic_modifier (GtkWindow *window,
- GdkModifierType modifier)
-{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-
- g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail ((modifier & ~GDK_MODIFIER_MASK) == 0);
-
- priv->mnemonic_modifier = modifier;
- _gtk_window_notify_keys_changed (window);
-}
-
-/**
- * gtk_window_get_mnemonic_modifier:
- * @window: a #GtkWindow
- *
- * Returns the mnemonic modifier for this window. See
- * gtk_window_set_mnemonic_modifier().
- *
- * Returns: the modifier mask used to activate
- * mnemonics on this window.
- **/
-GdkModifierType
-gtk_window_get_mnemonic_modifier (GtkWindow *window)
-{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-
- g_return_val_if_fail (GTK_IS_WINDOW (window), 0);
-
- return priv->mnemonic_modifier;
-}
-
/**
* gtk_window_set_position:
* @window: a #GtkWindow.
@@ -4777,15 +4647,10 @@ gtk_window_finalize (GObject *object)
{
GtkWindow *window = GTK_WINDOW (object);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GtkMnemonicHash *mnemonic_hash;
g_free (priv->title);
gtk_window_release_application (window);
- mnemonic_hash = gtk_window_get_mnemonic_hash (window, FALSE);
- if (mnemonic_hash)
- _gtk_mnemonic_hash_free (mnemonic_hash);
-
if (priv->geometry_info)
{
g_free (priv->geometry_info);
@@ -6147,8 +6012,6 @@ _gtk_window_query_nonaccels (GtkWindow *window,
guint accel_key,
GdkModifierType accel_mods)
{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
-
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
/* movement keys are considered locked accels */
@@ -6165,14 +6028,6 @@ _gtk_window_query_nonaccels (GtkWindow *window,
return TRUE;
}
- /* mnemonics are considered locked accels */
- if (accel_mods == priv->mnemonic_modifier)
- {
- GtkMnemonicHash *mnemonic_hash = gtk_window_get_mnemonic_hash (window, FALSE);
- if (mnemonic_hash && _gtk_mnemonic_hash_lookup (mnemonic_hash, accel_key))
- return TRUE;
- }
-
return FALSE;
}
@@ -6217,13 +6072,9 @@ gtk_window_real_activate_focus (GtkWindow *window)
static gboolean
gtk_window_has_mnemonic_modifier_pressed (GtkWindow *window)
{
- GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GList *seats, *s;
gboolean retval = FALSE;
- if (!priv->mnemonic_modifier)
- return FALSE;
-
seats = gdk_display_list_seats (gtk_widget_get_display (GTK_WIDGET (window)));
for (s = seats; s; s = s->next)
@@ -6233,7 +6084,7 @@ gtk_window_has_mnemonic_modifier_pressed (GtkWindow *window)
gdk_device_get_state (dev, _gtk_widget_get_surface (GTK_WIDGET (window)),
NULL, &mask);
- if (priv->mnemonic_modifier == (mask & gtk_accelerator_get_default_mod_mask ()))
+ if ((mask & gtk_accelerator_get_default_mod_mask ()) == GDK_MOD1_MASK)
{
retval = TRUE;
break;
@@ -8625,21 +8476,6 @@ gtk_window_activate_menubar (GtkWidget *widget,
return TRUE;
}
-static void
-gtk_window_mnemonic_hash_foreach (guint keyval,
- GSList *targets,
- gpointer data)
-{
- struct {
- GtkWindow *window;
- GtkWindowKeysForeachFunc func;
- gpointer func_data;
- } *info = data;
- GtkWindowPrivate *priv = gtk_window_get_instance_private (info->window);
-
- (*info->func) (info->window, keyval, priv->mnemonic_modifier, TRUE, info->func_data);
-}
-
static void
_gtk_window_keys_foreach (GtkWindow *window,
GtkWindowKeysForeachFunc func,
@@ -8647,22 +8483,6 @@ _gtk_window_keys_foreach (GtkWindow *window,
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GSList *groups;
- GtkMnemonicHash *mnemonic_hash;
-
- struct {
- GtkWindow *window;
- GtkWindowKeysForeachFunc func;
- gpointer func_data;
- } info;
-
- info.window = window;
- info.func = func;
- info.func_data = func_data;
-
- mnemonic_hash = gtk_window_get_mnemonic_hash (window, FALSE);
- if (mnemonic_hash)
- _gtk_mnemonic_hash_foreach (mnemonic_hash,
- gtk_window_mnemonic_hash_foreach, &info);
groups = gtk_accel_groups_from_object (G_OBJECT (window));
while (groups)
@@ -8675,7 +8495,7 @@ _gtk_window_keys_foreach (GtkWindow *window,
GtkAccelKey *key = &group->priv->priv_accels[i].key;
if (key->accel_key)
- (*func) (window, key->accel_key, key->accel_mods, FALSE, func_data);
+ (*func) (window, key->accel_key, key->accel_mods, func_data);
}
groups = groups->next;
@@ -8703,7 +8523,6 @@ struct _GtkWindowKeyEntry
{
guint keyval;
guint modifiers;
- guint is_mnemonic : 1;
};
static void
@@ -8716,7 +8535,6 @@ static void
add_to_key_hash (GtkWindow *window,
guint keyval,
GdkModifierType modifiers,
- gboolean is_mnemonic,
gpointer data)
{
GtkKeyHash *key_hash = data;
@@ -8725,7 +8543,6 @@ add_to_key_hash (GtkWindow *window,
entry->keyval = keyval;
entry->modifiers = modifiers;
- entry->is_mnemonic = is_mnemonic;
/* GtkAccelGroup stores lowercased accelerators. To deal
* with this, if <Shift> was specified, uppercase.
@@ -8811,18 +8628,11 @@ gtk_window_activate_key (GtkWindow *window,
for (tmp_list = entries; tmp_list; tmp_list = tmp_list->next)
{
GtkWindowKeyEntry *entry = tmp_list->data;
- if (entry->is_mnemonic)
+ if (enable_accels && !found_entry)
{
found_entry = entry;
break;
}
- else
- {
- if (enable_accels && !found_entry)
- {
- found_entry = entry;
- }
- }
}
g_slist_free (entries);
@@ -8830,39 +8640,31 @@ gtk_window_activate_key (GtkWindow *window,
if (found_entry)
{
- if (found_entry->is_mnemonic)
- {
- return gtk_window_mnemonic_activate (window, found_entry->keyval,
- found_entry->modifiers);
- }
- else
+ if (enable_accels)
{
- if (enable_accels)
+ if (gtk_accel_groups_activate (G_OBJECT (window), found_entry->keyval, found_entry->modifiers))
+ return TRUE;
+
+ if (priv->application)
{
- if (gtk_accel_groups_activate (G_OBJECT (window), found_entry->keyval, found_entry->modifiers))
- return TRUE;
-
- if (priv->application)
- {
- GtkWidget *focused_widget;
- GtkActionMuxer *muxer;
- GtkApplicationAccels *app_accels;
-
- focused_widget = gtk_window_get_focus (window);
-
- if (focused_widget)
- muxer = _gtk_widget_get_action_muxer (focused_widget, FALSE);
- else
- muxer = _gtk_widget_get_action_muxer (GTK_WIDGET (window), FALSE);
-
- if (muxer == NULL)
- return FALSE;
-
- app_accels = gtk_application_get_application_accels (priv->application);
- return gtk_application_accels_activate (app_accels,
- G_ACTION_GROUP (muxer),
- found_entry->keyval, found_entry->modifiers);
- }
+ GtkWidget *focused_widget;
+ GtkActionMuxer *muxer;
+ GtkApplicationAccels *app_accels;
+
+ focused_widget = gtk_window_get_focus (window);
+
+ if (focused_widget)
+ muxer = _gtk_widget_get_action_muxer (focused_widget, FALSE);
+ else
+ muxer = _gtk_widget_get_action_muxer (GTK_WIDGET (window), FALSE);
+
+ if (muxer == NULL)
+ return FALSE;
+
+ app_accels = gtk_application_get_application_accels (priv->application);
+ return gtk_application_accels_activate (app_accels,
+ G_ACTION_GROUP (muxer),
+ found_entry->keyval, found_entry->modifiers);
}
}
}
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 5befe158ca..d58682f4e3 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -265,20 +265,6 @@ GDK_AVAILABLE_IN_ALL
void gtk_window_set_has_user_ref_count (GtkWindow *window,
gboolean setting);
-GDK_AVAILABLE_IN_ALL
-void gtk_window_add_mnemonic (GtkWindow *window,
- guint keyval,
- GtkWidget *target);
-GDK_AVAILABLE_IN_ALL
-void gtk_window_remove_mnemonic (GtkWindow *window,
- guint keyval,
- GtkWidget *target);
-GDK_AVAILABLE_IN_ALL
-void gtk_window_set_mnemonic_modifier (GtkWindow *window,
- GdkModifierType modifier);
-GDK_AVAILABLE_IN_ALL
-GdkModifierType gtk_window_get_mnemonic_modifier (GtkWindow *window);
-
GDK_AVAILABLE_IN_ALL
void gtk_window_present (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h
index 0e6b2a0415..4b7f04bee0 100644
--- a/gtk/gtkwindowprivate.h
+++ b/gtk/gtkwindowprivate.h
@@ -56,7 +56,6 @@ void gtk_window_check_resize (GtkWindow *self);
typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
guint keyval,
GdkModifierType modifiers,
- gboolean is_mnemonic,
gpointer data);
gboolean gtk_window_emit_close_request (GtkWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]