eventcontrollerkey: Add getters for the properties
...and use them.
This commit is contained in:
@@ -6729,6 +6729,8 @@ gtk_event_controller_key_forward
|
||||
gtk_event_controller_key_get_group
|
||||
gtk_event_controller_key_get_focus_origin
|
||||
gtk_event_controller_key_get_focus_target
|
||||
gtk_event_controller_key_contains_focus
|
||||
gtk_event_controller_key_is_focus
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_EVENT_CONTROLLER_KEY
|
||||
|
||||
@@ -596,3 +596,35 @@ gtk_event_controller_key_get_focus_target (GtkEventControllerKey *controller)
|
||||
else
|
||||
return (GtkWidget *)gdk_event_get_related_target (controller->current_event);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_key_contains_focus:
|
||||
* @self: a #GtkEventControllerKey
|
||||
*
|
||||
* Returns the value of the GtkEventControllerKey:contains-focus property.
|
||||
*
|
||||
* Returns: %TRUE if focus is within @self or one of its children
|
||||
*/
|
||||
gboolean
|
||||
gtk_event_controller_key_contains_focus (GtkEventControllerKey *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (self), FALSE);
|
||||
|
||||
return self->contains_focus;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_event_controller_key_is_focus:
|
||||
* @self: a #GtkEventControllerKey
|
||||
*
|
||||
* Returns the value of the GtkEventControllerKey:is-focus property.
|
||||
*
|
||||
* Returns: %TRUE if focus is within @self but not one of its children
|
||||
*/
|
||||
gboolean
|
||||
gtk_event_controller_key_is_focus (GtkEventControllerKey *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (self), FALSE);
|
||||
|
||||
return self->is_focus;
|
||||
}
|
||||
|
||||
@@ -59,9 +59,15 @@ GDK_AVAILABLE_IN_ALL
|
||||
guint gtk_event_controller_key_get_group (GtkEventControllerKey *controller);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_event_controller_key_get_focus_origin (GtkEventControllerKey *controller);
|
||||
GtkWidget * gtk_event_controller_key_get_focus_origin (GtkEventControllerKey *controller);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_event_controller_key_get_focus_target (GtkEventControllerKey *controller);
|
||||
GtkWidget * gtk_event_controller_key_get_focus_target (GtkEventControllerKey *controller);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_event_controller_key_contains_focus (GtkEventControllerKey *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_event_controller_key_is_focus (GtkEventControllerKey *self);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -210,19 +210,15 @@ visible_submenu_changed (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
focus_out (GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
GtkPopoverMenu *menu)
|
||||
focus_out (GtkEventControllerKey *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
GtkPopoverMenu *menu)
|
||||
{
|
||||
gboolean contains_focus;
|
||||
|
||||
g_object_get (controller, "contains-focus", &contains_focus, NULL);
|
||||
|
||||
if (!contains_focus)
|
||||
if (!gtk_event_controller_key_contains_focus (controller))
|
||||
{
|
||||
if (menu->parent_menu &&
|
||||
GTK_POPOVER_MENU (menu->parent_menu)->open_submenu == (GtkWidget*)menu)
|
||||
GTK_POPOVER_MENU (menu->parent_menu)->open_submenu == (GtkWidget*) menu)
|
||||
GTK_POPOVER_MENU (menu->parent_menu)->open_submenu = NULL;
|
||||
gtk_popover_popdown (GTK_POPOVER (menu));
|
||||
}
|
||||
|
||||
@@ -5619,7 +5619,8 @@ gtk_tree_view_key_controller_focus_out (GtkEventControllerKey *key,
|
||||
|
||||
/* destroy interactive search dialog */
|
||||
if (tree_view->priv->search_window &&
|
||||
!is_focus && !contains_focus)
|
||||
!gtk_event_controller_key_is_focus (key) &&
|
||||
!gtk_event_controller_key_contains_focus (key))
|
||||
gtk_tree_view_search_window_hide (tree_view->priv->search_window, tree_view,
|
||||
gtk_get_current_event_device ());
|
||||
}
|
||||
|
||||
@@ -26,47 +26,35 @@ detail_to_string (GdkNotifyType detail)
|
||||
}
|
||||
|
||||
static void
|
||||
focus_in (GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
GString *s)
|
||||
focus_in (GtkEventControllerKey *key,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
GString *s)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
gboolean is_focus;
|
||||
gboolean contains_focus;
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (key));
|
||||
|
||||
g_object_get (controller,
|
||||
"is-focus", &is_focus,
|
||||
"contains-focus", &contains_focus,
|
||||
NULL);
|
||||
g_string_append_printf (s, "%s: focus-in %s %s is-focus: %d contains-focus: %d\n",
|
||||
widget_name (widget),
|
||||
mode_to_string (mode),
|
||||
detail_to_string (detail),
|
||||
is_focus,
|
||||
contains_focus);
|
||||
gtk_event_controller_key_is_focus (key),
|
||||
gtk_event_controller_key_contains_focus (key));
|
||||
}
|
||||
|
||||
static void
|
||||
focus_out (GtkEventController *controller,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
GString *s)
|
||||
focus_out (GtkEventControllerKey *key,
|
||||
GdkCrossingMode mode,
|
||||
GdkNotifyType detail,
|
||||
GString *s)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
gboolean is_focus;
|
||||
gboolean contains_focus;
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (key));
|
||||
|
||||
g_object_get (controller,
|
||||
"is-focus", &is_focus,
|
||||
"contains-focus", &contains_focus,
|
||||
NULL);
|
||||
g_string_append_printf (s, "%s: focus-out %s %s is-focus: %d contains-focus: %d\n",
|
||||
widget_name (widget),
|
||||
mode_to_string (mode),
|
||||
detail_to_string (detail),
|
||||
is_focus,
|
||||
contains_focus);
|
||||
gtk_event_controller_key_is_focus (key),
|
||||
gtk_event_controller_key_contains_focus (key));
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user