menushell: Remove old mnemonic handling
It's not used anymore. This was also the last user of GtkMnemonicHash, so delete that one, too.
This commit is contained in:
committed by
Matthias Clasen
parent
ba70b22ab1
commit
97cdd92233
@@ -66,7 +66,6 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkmenubarprivate.h"
|
||||
#include "gtkmenuitemprivate.h"
|
||||
#include "gtkmnemonichash.h"
|
||||
#include "gtkmodelmenuitemprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkseparatormenuitem.h"
|
||||
@@ -110,14 +109,12 @@ static void gtk_menu_shell_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_menu_shell_finalize (GObject *object);
|
||||
static void gtk_menu_shell_dispose (GObject *object);
|
||||
static gboolean gtk_menu_shell_key_press (GtkEventControllerKey *key,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType modifiers,
|
||||
GtkWidget *widget);
|
||||
static void gtk_menu_shell_root (GtkWidget *widget);
|
||||
static void click_pressed (GtkGestureClick *gesture,
|
||||
gint n_press,
|
||||
gdouble x,
|
||||
@@ -150,11 +147,6 @@ static void gtk_real_menu_shell_cancel (GtkMenuShell *menu_shell)
|
||||
static void gtk_real_menu_shell_cycle_focus (GtkMenuShell *menu_shell,
|
||||
GtkDirectionType dir);
|
||||
|
||||
static void gtk_menu_shell_reset_key_hash (GtkMenuShell *menu_shell);
|
||||
static gboolean gtk_menu_shell_activate_mnemonic (GtkMenuShell *menu_shell,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
guint group);
|
||||
static gboolean gtk_menu_shell_real_move_selected (GtkMenuShell *menu_shell,
|
||||
gint distance);
|
||||
|
||||
@@ -171,11 +163,8 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
|
||||
|
||||
object_class->set_property = gtk_menu_shell_set_property;
|
||||
object_class->get_property = gtk_menu_shell_get_property;
|
||||
object_class->finalize = gtk_menu_shell_finalize;
|
||||
object_class->dispose = gtk_menu_shell_dispose;
|
||||
|
||||
widget_class->root = gtk_menu_shell_root;
|
||||
|
||||
container_class->add = gtk_menu_shell_add;
|
||||
container_class->remove = gtk_menu_shell_remove;
|
||||
container_class->child_type = gtk_menu_shell_child_type;
|
||||
@@ -458,21 +447,6 @@ gtk_menu_shell_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_shell_finalize (GObject *object)
|
||||
{
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
|
||||
GtkMenuShellPrivate *priv = menu_shell->priv;
|
||||
|
||||
if (priv->mnemonic_hash)
|
||||
_gtk_mnemonic_hash_free (priv->mnemonic_hash);
|
||||
if (priv->key_hash)
|
||||
_gtk_key_hash_free (priv->key_hash);
|
||||
|
||||
G_OBJECT_CLASS (gtk_menu_shell_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_menu_shell_dispose (GObject *object)
|
||||
{
|
||||
@@ -909,16 +883,7 @@ gtk_menu_shell_key_press (GtkEventControllerKey *key,
|
||||
priv->parent_menu_shell)
|
||||
return gtk_event_controller_key_forward (key, priv->parent_menu_shell);
|
||||
|
||||
return gtk_menu_shell_activate_mnemonic (menu_shell, keycode, modifiers,
|
||||
gtk_event_controller_key_get_group (key));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_shell_root (GtkWidget *widget)
|
||||
{
|
||||
GTK_WIDGET_CLASS (gtk_menu_shell_parent_class)->root (widget);
|
||||
|
||||
gtk_menu_shell_reset_key_hash (GTK_MENU_SHELL (widget));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1466,126 +1431,6 @@ gtk_menu_shell_cancel (GtkMenuShell *menu_shell)
|
||||
g_signal_emit (menu_shell, menu_shell_signals[CANCEL], 0);
|
||||
}
|
||||
|
||||
static GtkMnemonicHash *
|
||||
gtk_menu_shell_get_mnemonic_hash (GtkMenuShell *menu_shell,
|
||||
gboolean create)
|
||||
{
|
||||
GtkMenuShellPrivate *priv = menu_shell->priv;
|
||||
|
||||
if (!priv->mnemonic_hash && create)
|
||||
priv->mnemonic_hash = _gtk_mnemonic_hash_new ();
|
||||
|
||||
return priv->mnemonic_hash;
|
||||
}
|
||||
|
||||
static void
|
||||
menu_shell_add_mnemonic_foreach (guint keyval,
|
||||
GSList *targets,
|
||||
gpointer data)
|
||||
{
|
||||
GtkKeyHash *key_hash = data;
|
||||
|
||||
_gtk_key_hash_add_entry (key_hash, keyval, 0, GUINT_TO_POINTER (keyval));
|
||||
}
|
||||
|
||||
static GtkKeyHash *
|
||||
gtk_menu_shell_get_key_hash (GtkMenuShell *menu_shell,
|
||||
gboolean create)
|
||||
{
|
||||
GtkMenuShellPrivate *priv = menu_shell->priv;
|
||||
GtkWidget *widget = GTK_WIDGET (menu_shell);
|
||||
|
||||
if (!priv->key_hash && create)
|
||||
{
|
||||
GtkMnemonicHash *mnemonic_hash = gtk_menu_shell_get_mnemonic_hash (menu_shell, FALSE);
|
||||
GdkKeymap *keymap = gdk_display_get_keymap (gtk_widget_get_display (widget));
|
||||
|
||||
if (!mnemonic_hash)
|
||||
return NULL;
|
||||
|
||||
priv->key_hash = _gtk_key_hash_new (keymap, NULL);
|
||||
|
||||
_gtk_mnemonic_hash_foreach (mnemonic_hash,
|
||||
menu_shell_add_mnemonic_foreach,
|
||||
priv->key_hash);
|
||||
}
|
||||
|
||||
return priv->key_hash;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_menu_shell_reset_key_hash (GtkMenuShell *menu_shell)
|
||||
{
|
||||
GtkMenuShellPrivate *priv = menu_shell->priv;
|
||||
|
||||
if (priv->key_hash)
|
||||
{
|
||||
_gtk_key_hash_free (priv->key_hash);
|
||||
priv->key_hash = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_menu_shell_activate_mnemonic (GtkMenuShell *menu_shell,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
guint group)
|
||||
{
|
||||
GtkMnemonicHash *mnemonic_hash;
|
||||
GtkKeyHash *key_hash;
|
||||
GSList *entries;
|
||||
gboolean result = FALSE;
|
||||
|
||||
mnemonic_hash = gtk_menu_shell_get_mnemonic_hash (menu_shell, FALSE);
|
||||
if (!mnemonic_hash)
|
||||
return FALSE;
|
||||
|
||||
key_hash = gtk_menu_shell_get_key_hash (menu_shell, TRUE);
|
||||
if (!key_hash)
|
||||
return FALSE;
|
||||
|
||||
entries = _gtk_key_hash_lookup (key_hash,
|
||||
keycode,
|
||||
state,
|
||||
gtk_accelerator_get_default_mod_mask (),
|
||||
group);
|
||||
|
||||
if (entries)
|
||||
{
|
||||
result = _gtk_mnemonic_hash_activate (mnemonic_hash,
|
||||
GPOINTER_TO_UINT (entries->data));
|
||||
g_slist_free (entries);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_menu_shell_add_mnemonic (GtkMenuShell *menu_shell,
|
||||
guint keyval,
|
||||
GtkWidget *target)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
|
||||
g_return_if_fail (GTK_IS_WIDGET (target));
|
||||
|
||||
_gtk_mnemonic_hash_add (gtk_menu_shell_get_mnemonic_hash (menu_shell, TRUE),
|
||||
keyval, target);
|
||||
gtk_menu_shell_reset_key_hash (menu_shell);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_menu_shell_remove_mnemonic (GtkMenuShell *menu_shell,
|
||||
guint keyval,
|
||||
GtkWidget *target)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
|
||||
g_return_if_fail (GTK_IS_WIDGET (target));
|
||||
|
||||
_gtk_mnemonic_hash_remove (gtk_menu_shell_get_mnemonic_hash (menu_shell, TRUE),
|
||||
keyval, target);
|
||||
gtk_menu_shell_reset_key_hash (menu_shell);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_menu_shell_set_grab_device (GtkMenuShell *menu_shell,
|
||||
GdkDevice *device)
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
|
||||
#include <gtk/gtkmenushell.h>
|
||||
#include <gtk/gtkmnemonichash.h>
|
||||
#include <gtk/gtkkeyhash.h>
|
||||
#include <gtk/gtkmenutrackerprivate.h>
|
||||
#include <gtk/gtkeventcontroller.h>
|
||||
@@ -65,9 +64,6 @@ struct _GtkMenuShellPrivate
|
||||
* signal is coming soon (when checked
|
||||
* from inside of a "hide" handler).
|
||||
*/
|
||||
GtkMnemonicHash *mnemonic_hash;
|
||||
GtkKeyHash *key_hash;
|
||||
|
||||
GdkDevice *grab_pointer;
|
||||
GtkEventController *key_controller;
|
||||
};
|
||||
@@ -79,13 +75,6 @@ void _gtk_menu_shell_set_grab_device (GtkMenuShell *menu_shell,
|
||||
GdkDevice *device);
|
||||
GdkDevice *_gtk_menu_shell_get_grab_device (GtkMenuShell *menu_shell);
|
||||
|
||||
void _gtk_menu_shell_add_mnemonic (GtkMenuShell *menu_shell,
|
||||
guint keyval,
|
||||
GtkWidget *target);
|
||||
void _gtk_menu_shell_remove_mnemonic (GtkMenuShell *menu_shell,
|
||||
guint keyval,
|
||||
GtkWidget *target);
|
||||
|
||||
void _gtk_menu_shell_update_mnemonics (GtkMenuShell *menu_shell);
|
||||
void _gtk_menu_shell_set_keyboard_mode (GtkMenuShell *menu_shell,
|
||||
gboolean keyboard_mode);
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
/* gtkmnemonichash.c: Sets of mnemonics with cycling
|
||||
*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2002, Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkmnemonichash.h"
|
||||
#include "gtknative.h"
|
||||
|
||||
struct _GtkMnemnonicHash
|
||||
{
|
||||
GHashTable *hash;
|
||||
};
|
||||
|
||||
|
||||
GtkMnemonicHash *
|
||||
_gtk_mnemonic_hash_new (void)
|
||||
{
|
||||
GtkMnemonicHash *mnemonic_hash = g_new (GtkMnemonicHash, 1);
|
||||
|
||||
mnemonic_hash->hash = g_hash_table_new (g_direct_hash, NULL);
|
||||
|
||||
return mnemonic_hash;
|
||||
}
|
||||
|
||||
static void
|
||||
mnemonic_hash_free_foreach (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user)
|
||||
{
|
||||
guint keyval = GPOINTER_TO_UINT (key);
|
||||
GSList *targets = value;
|
||||
|
||||
gchar *name = gtk_accelerator_name (keyval, 0);
|
||||
|
||||
g_warning ("mnemonic \"%s\" wasn't removed for widget (%p)",
|
||||
name, targets->data);
|
||||
g_free (name);
|
||||
|
||||
g_slist_free (targets);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_mnemonic_hash_free (GtkMnemonicHash *mnemonic_hash)
|
||||
{
|
||||
g_hash_table_foreach (mnemonic_hash->hash,
|
||||
mnemonic_hash_free_foreach,
|
||||
NULL);
|
||||
|
||||
g_hash_table_destroy (mnemonic_hash->hash);
|
||||
g_free (mnemonic_hash);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_mnemonic_hash_add (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval,
|
||||
GtkWidget *target)
|
||||
{
|
||||
gpointer key = GUINT_TO_POINTER (keyval);
|
||||
GSList *targets, *new_targets;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (target));
|
||||
|
||||
targets = g_hash_table_lookup (mnemonic_hash->hash, key);
|
||||
g_return_if_fail (g_slist_find (targets, target) == NULL);
|
||||
|
||||
new_targets = g_slist_append (targets, target);
|
||||
if (new_targets != targets)
|
||||
g_hash_table_insert (mnemonic_hash->hash, key, new_targets);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_mnemonic_hash_remove (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval,
|
||||
GtkWidget *target)
|
||||
{
|
||||
gpointer key = GUINT_TO_POINTER (keyval);
|
||||
GSList *targets, *new_targets;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (target));
|
||||
|
||||
targets = g_hash_table_lookup (mnemonic_hash->hash, key);
|
||||
|
||||
g_return_if_fail (targets && g_slist_find (targets, target) != NULL);
|
||||
|
||||
new_targets = g_slist_remove (targets, target);
|
||||
if (new_targets != targets)
|
||||
{
|
||||
if (new_targets == NULL)
|
||||
g_hash_table_remove (mnemonic_hash->hash, key);
|
||||
else
|
||||
g_hash_table_insert (mnemonic_hash->hash, key, new_targets);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval)
|
||||
{
|
||||
GSList *list, *targets;
|
||||
GtkWidget *widget, *chosen_widget;
|
||||
GdkSurface *surface;
|
||||
gboolean overloaded;
|
||||
|
||||
targets = g_hash_table_lookup (mnemonic_hash->hash,
|
||||
GUINT_TO_POINTER (keyval));
|
||||
if (!targets)
|
||||
return FALSE;
|
||||
|
||||
overloaded = FALSE;
|
||||
chosen_widget = NULL;
|
||||
for (list = targets; list; list = list->next)
|
||||
{
|
||||
widget = GTK_WIDGET (list->data);
|
||||
surface = gtk_native_get_surface (gtk_widget_get_native (widget));
|
||||
|
||||
if (gtk_widget_is_sensitive (widget) &&
|
||||
gtk_widget_get_mapped (widget) &&
|
||||
surface && gdk_surface_is_viewable (surface))
|
||||
{
|
||||
if (chosen_widget)
|
||||
{
|
||||
overloaded = TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
chosen_widget = widget;
|
||||
}
|
||||
}
|
||||
|
||||
if (chosen_widget)
|
||||
{
|
||||
/* For round robin we put the activated entry on
|
||||
* the end of the list after activation
|
||||
*/
|
||||
targets = g_slist_remove (targets, chosen_widget);
|
||||
targets = g_slist_append (targets, chosen_widget);
|
||||
g_hash_table_insert (mnemonic_hash->hash,
|
||||
GUINT_TO_POINTER (keyval),
|
||||
targets);
|
||||
|
||||
return gtk_widget_mnemonic_activate (chosen_widget, overloaded);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GSList *
|
||||
_gtk_mnemonic_hash_lookup (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval)
|
||||
{
|
||||
return g_hash_table_lookup (mnemonic_hash->hash, GUINT_TO_POINTER (keyval));
|
||||
}
|
||||
|
||||
static void
|
||||
mnemonic_hash_foreach_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer data)
|
||||
{
|
||||
struct {
|
||||
GtkMnemonicHashForeach func;
|
||||
gpointer func_data;
|
||||
} *info = data;
|
||||
|
||||
guint keyval = GPOINTER_TO_UINT (key);
|
||||
GSList *targets = value;
|
||||
|
||||
(*info->func) (keyval, targets, info->func_data);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_mnemonic_hash_foreach (GtkMnemonicHash *mnemonic_hash,
|
||||
GtkMnemonicHashForeach func,
|
||||
gpointer func_data)
|
||||
{
|
||||
struct {
|
||||
GtkMnemonicHashForeach func;
|
||||
gpointer func_data;
|
||||
} info;
|
||||
|
||||
info.func = func;
|
||||
info.func_data = func_data;
|
||||
|
||||
g_hash_table_foreach (mnemonic_hash->hash,
|
||||
mnemonic_hash_foreach_func,
|
||||
&info);
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/* gtkmnemonichash.h: Sets of mnemonics with cycling
|
||||
*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2002, Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_MNEMONIC_HASH_H__
|
||||
#define __GTK_MNEMONIC_HASH_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkMnemnonicHash GtkMnemonicHash;
|
||||
|
||||
typedef void (*GtkMnemonicHashForeach) (guint keyval,
|
||||
GSList *targets,
|
||||
gpointer data);
|
||||
|
||||
GtkMnemonicHash *_gtk_mnemonic_hash_new (void);
|
||||
void _gtk_mnemonic_hash_free (GtkMnemonicHash *mnemonic_hash);
|
||||
void _gtk_mnemonic_hash_add (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval,
|
||||
GtkWidget *target);
|
||||
void _gtk_mnemonic_hash_remove (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval,
|
||||
GtkWidget *target);
|
||||
gboolean _gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval);
|
||||
GSList * _gtk_mnemonic_hash_lookup (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval);
|
||||
void _gtk_mnemonic_hash_foreach (GtkMnemonicHash *mnemonic_hash,
|
||||
GtkMnemonicHashForeach func,
|
||||
gpointer func_data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_MNEMONIC_HASH_H__ */
|
||||
@@ -120,7 +120,6 @@ gtk_private_sources = files([
|
||||
'gtkmenusectionbox.c',
|
||||
'gtkmenutracker.c',
|
||||
'gtkmenutrackeritem.c',
|
||||
'gtkmnemonichash.c',
|
||||
'gtkpango.c',
|
||||
'gskpango.c',
|
||||
'gtkpathbar.c',
|
||||
|
||||
Reference in New Issue
Block a user