mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-14 20:51:07 +00:00
shortcutcontroller: Add private API for running class shortcuts
We don't want regular users to be able to run class shortcuts in their controllers, so we have to special case that.
This commit is contained in:
parent
dfd81f9c64
commit
376dc4d169
@ -29,7 +29,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtkshortcutcontrollerprivate.h"
|
||||
|
||||
#include "gtkeventcontrollerprivate.h"
|
||||
#include "gtkbindings.h"
|
||||
@ -41,6 +41,8 @@
|
||||
struct _GtkShortcutController
|
||||
{
|
||||
GtkEventController parent_instance;
|
||||
|
||||
guint run_class : 1;
|
||||
};
|
||||
|
||||
struct _GtkShortcutControllerClass
|
||||
@ -82,6 +84,9 @@ gtk_shortcut_controller_handle_event (GtkEventController *controller,
|
||||
const GSList *l;
|
||||
|
||||
widget = gtk_event_controller_get_widget (controller);
|
||||
|
||||
if (self->run_class)
|
||||
{
|
||||
if (event_type == GDK_KEY_PRESS ||
|
||||
event_type == GDK_KEY_RELEASE)
|
||||
{
|
||||
@ -94,6 +99,7 @@ gtk_shortcut_controller_handle_event (GtkEventController *controller,
|
||||
if (gtk_shortcut_controller_trigger_shortcut (self, l->data, event))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -119,3 +125,10 @@ gtk_shortcut_controller_new (void)
|
||||
return g_object_new (GTK_TYPE_SHORTCUT_CONTROLLER,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_shortcut_controller_set_run_class (GtkShortcutController *controller,
|
||||
gboolean run_class)
|
||||
{
|
||||
controller->run_class = run_class;
|
||||
}
|
||||
|
28
gtk/gtkshortcutcontrollerprivate.h
Normal file
28
gtk/gtkshortcutcontrollerprivate.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* 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.1 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/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SHORTCUT_CONTROLLER_PRIVATE_H__
|
||||
#define __GTK_SHORTCUT_CONTROLLER_PRIVATE_H__
|
||||
|
||||
#include "gtkshortcutcontroller.h"
|
||||
|
||||
void gtk_shortcut_controller_set_run_class (GtkShortcutController *controller,
|
||||
gboolean run_class);
|
||||
|
||||
#endif /* __GTK_SHORTCUT_CONTROLLER_H__ */
|
@ -59,7 +59,7 @@
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtkshortcutcontrollerprivate.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtksizegroup-private.h"
|
||||
#include "gtksnapshotprivate.h"
|
||||
@ -2412,6 +2412,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
|
||||
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
gtk_event_controller_set_name (controller, "gtk-widget-class-shortcuts");
|
||||
gtk_shortcut_controller_set_run_class (GTK_SHORTCUT_CONTROLLER (controller), TRUE);
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user