mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 13:11:13 +00:00
gdk: Remove gdk_event_get_string()
You want to use an IM module to get strings out of keypresses, not some crude hack that only works on X11 and Wayland anyway.
This commit is contained in:
parent
36ed4c2a29
commit
813957a92f
@ -655,7 +655,6 @@ gdk_event_get_key_is_modifier
|
||||
gdk_event_get_pad_axis_value
|
||||
gdk_event_get_pad_button
|
||||
gdk_event_get_pad_group_mode
|
||||
gdk_event_get_string
|
||||
gdk_event_get_touch_emulating_pointer
|
||||
gdk_event_get_touchpad_angle_delta
|
||||
gdk_event_get_touchpad_deltas
|
||||
|
@ -1293,37 +1293,6 @@ gdk_event_get_key_group (const GdkEvent *event,
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_string:
|
||||
* @event: a #GdkEvent
|
||||
* @string: (out) (transfer none): return location for the string
|
||||
*
|
||||
* Extracts a string from an event. The string is an
|
||||
* approximation of the keyval in a key event.
|
||||
*
|
||||
* Returns: %TRUE on success, otherwise %FALSE
|
||||
**/
|
||||
gboolean
|
||||
gdk_event_get_string (const GdkEvent *event,
|
||||
const char **string)
|
||||
{
|
||||
gboolean fetched = TRUE;
|
||||
|
||||
switch ((guint) event->any.type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
*string = event->key.string;
|
||||
break;
|
||||
default:
|
||||
*string = NULL;
|
||||
fetched = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_key_is_modifier:
|
||||
* @event: a #GdkEvent
|
||||
|
@ -403,9 +403,6 @@ gboolean gdk_event_get_key_is_modifier (const GdkEvent *event,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_key_group (const GdkEvent *event,
|
||||
guint *group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_string (const GdkEvent *event,
|
||||
const char **string);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
|
||||
|
@ -116,13 +116,11 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key,
|
||||
GdkModifierType state;
|
||||
guint keyval;
|
||||
guint16 keycode;
|
||||
const char *string;
|
||||
|
||||
type = gdk_event_get_event_type ((GdkEvent *)key);
|
||||
gdk_event_get_state ((GdkEvent *)key, &state);
|
||||
gdk_event_get_keyval ((GdkEvent *)key, &keyval);
|
||||
gdk_event_get_keycode ((GdkEvent *)key, &keycode);
|
||||
gdk_event_get_string ((GdkEvent *)key, &string);
|
||||
|
||||
if (type == GDK_KEY_PRESS)
|
||||
event->type = ATK_KEY_EVENT_PRESS;
|
||||
@ -133,14 +131,8 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key,
|
||||
|
||||
event->state = state;
|
||||
event->keyval = keyval;
|
||||
if (string && string[0] &&
|
||||
(state & GDK_CONTROL_MASK ||
|
||||
g_unichar_isgraph (g_utf8_get_char (string))))
|
||||
event->string = (char *) string;
|
||||
else
|
||||
event->string = gdk_keyval_name (keyval);
|
||||
|
||||
event->length = strlen (string);
|
||||
event->string = gdk_keyval_name (keyval);
|
||||
event->length = strlen (event->string);
|
||||
event->keycode = keycode;
|
||||
event->timestamp = gdk_event_get_time ((GdkEvent *)key);
|
||||
}
|
||||
|
@ -1281,7 +1281,8 @@ key_is_left_or_right (const GdkEvent *event)
|
||||
static gboolean
|
||||
should_trigger_location_entry (GtkFileChooserWidget *impl,
|
||||
guint keyval,
|
||||
GdkModifierType state)
|
||||
GdkModifierType state,
|
||||
const char **string)
|
||||
{
|
||||
GdkModifierType no_text_input_mask;
|
||||
|
||||
@ -1291,16 +1292,27 @@ should_trigger_location_entry (GtkFileChooserWidget *impl,
|
||||
no_text_input_mask =
|
||||
gtk_widget_get_modifier_mask (GTK_WIDGET (impl), GDK_MODIFIER_INTENT_NO_TEXT_INPUT);
|
||||
|
||||
if ((keyval == GDK_KEY_slash
|
||||
|| keyval == GDK_KEY_KP_Divide
|
||||
|| keyval == GDK_KEY_period
|
||||
#ifdef G_OS_UNIX
|
||||
|| keyval == GDK_KEY_asciitilde
|
||||
#endif
|
||||
) && !(state & no_text_input_mask))
|
||||
return TRUE;
|
||||
if (state & no_text_input_mask)
|
||||
return FALSE;
|
||||
|
||||
return FALSE;
|
||||
switch (keyval)
|
||||
{
|
||||
case GDK_KEY_slash:
|
||||
case GDK_KEY_KP_Divide:
|
||||
*string = "/";
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_period:
|
||||
*string = ".";
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_asciitilde:
|
||||
*string = "~";
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Handles key press events on the file list, so that we can trap Enter to
|
||||
@ -1317,16 +1329,14 @@ key_press_cb (GtkEventController *controller,
|
||||
GtkFileChooserWidget *impl = (GtkFileChooserWidget *) data;
|
||||
GtkFileChooserWidgetPrivate *priv = impl->priv;
|
||||
const GdkEvent *event;
|
||||
const char *string;
|
||||
|
||||
event = gtk_get_current_event ();
|
||||
|
||||
if (should_trigger_location_entry (impl, keyval, state) &&
|
||||
if (should_trigger_location_entry (impl, keyval, state, &string) &&
|
||||
(priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER))
|
||||
{
|
||||
const char *string;
|
||||
|
||||
gdk_event_get_string ((GdkEvent *)event, &string);
|
||||
location_popup_handler (impl, string);
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
@ -1388,17 +1398,15 @@ widget_key_press_cb (GtkEventController *controller,
|
||||
GtkFileChooserWidgetPrivate *priv = impl->priv;
|
||||
gboolean handled = FALSE;
|
||||
GdkEvent *event;
|
||||
const char *string;
|
||||
|
||||
event = gtk_get_current_event ();
|
||||
|
||||
if (should_trigger_location_entry (impl, keyval, state))
|
||||
if (should_trigger_location_entry (impl, keyval, state, &string))
|
||||
{
|
||||
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
{
|
||||
const char *string;
|
||||
|
||||
gdk_event_get_string (event, &string);
|
||||
location_popup_handler (impl, string);
|
||||
handled = TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user