gtk2/gtk/gtkshortcuttrigger.h
Emmanuele Bassi 457b6657bb Turn GtkShortcutTrigger into an object
The lightweight inheritance mechanism used for GtkShortcutTrigger is not
going to be usable by bindings, because boxed types cannot have derived
types.

We could use GTypeInstance and derive everything from that, like
GParamSpec, but in the end shortcuts are not really a performance
critical paths, unlike CSS values or render nodes.
2020-03-25 23:14:45 -04:00

164 lines
6.0 KiB
C

/*
* 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_TRIGGER_H__
#define __GTK_SHORTCUT_TRIGGER_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtktypes.h>
G_BEGIN_DECLS
#define GTK_TYPE_SHORTCUT_TRIGGER (gtk_shortcut_trigger_get_type ())
/**
* GtkShortcutTrigger:
*
* A trigger for a key shortcut.
*/
/**
* GtkShortcutTriggerMatch:
* @GTK_SHORTCUT_TRIGGER_MATCH_NONE: The key event does not
* match the trigger
* @GTK_SHORTCUT_TRIGGER_MATCH_PARTIAL: The key event matches
* the trigger if keyboard state (specifically, the currently
* active group) is ignored
* @GTK_SHORTCUT_TRIGGER_MATCH_EXACT: The key event matches
* the trigger
*
* The possible return values from gtk_shortcut_trigger_trigger()
* describe if a key event triggers a shortcut.
*/
typedef enum {
GTK_SHORTCUT_TRIGGER_MATCH_NONE,
GTK_SHORTCUT_TRIGGER_MATCH_PARTIAL,
GTK_SHORTCUT_TRIGGER_MATCH_EXACT,
} GtkShortcutTriggerMatch;
GDK_AVAILABLE_IN_ALL
GDK_DECLARE_INTERNAL_TYPE (GtkShortcutTrigger, gtk_shortcut_trigger, GTK, SHORTCUT_TRIGGER, GObject)
GDK_AVAILABLE_IN_ALL
GtkShortcutTrigger * gtk_shortcut_trigger_parse_string (const char *string);
GDK_AVAILABLE_IN_ALL
char * gtk_shortcut_trigger_to_string (GtkShortcutTrigger *self);
GDK_AVAILABLE_IN_ALL
void gtk_shortcut_trigger_print (GtkShortcutTrigger *self,
GString *string);
GDK_AVAILABLE_IN_ALL
char * gtk_shortcut_trigger_to_label (GtkShortcutTrigger *self,
GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
gboolean gtk_shortcut_trigger_print_label (GtkShortcutTrigger *self,
GdkDisplay *display,
GString *string);
GDK_AVAILABLE_IN_ALL
guint gtk_shortcut_trigger_hash (gconstpointer trigger);
GDK_AVAILABLE_IN_ALL
gboolean gtk_shortcut_trigger_equal (gconstpointer trigger1,
gconstpointer trigger2);
GDK_AVAILABLE_IN_ALL
gint gtk_shortcut_trigger_compare (gconstpointer trigger1,
gconstpointer trigger2);
GDK_AVAILABLE_IN_ALL
GtkShortcutTriggerMatch gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self,
GdkEvent *event,
gboolean enable_mnemonics);
#define GTK_TYPE_NEVER_TRIGGER (gtk_never_trigger_get_type())
/**
* GtkNeverTrigger:
*
* A #GtkShortcutTrigger that never triggers.
*/
GDK_AVAILABLE_IN_ALL
GDK_DECLARE_INTERNAL_TYPE (GtkNeverTrigger, gtk_never_trigger, GTK, NEVER_TRIGGER, GtkShortcutTrigger)
GDK_AVAILABLE_IN_ALL
GtkShortcutTrigger * gtk_never_trigger_get (void);
#define GTK_TYPE_KEYVAL_TRIGGER (gtk_keyval_trigger_get_type())
/**
* GtkKeyvalTrigger:
*
* A #GtkShortcutTrigger that triggers when a specific keyval
* and (optionally) modifiers are pressed.
*/
GDK_AVAILABLE_IN_ALL
GDK_DECLARE_INTERNAL_TYPE (GtkKeyvalTrigger, gtk_keyval_trigger, GTK, KEYVAL_TRIGGER, GtkShortcutTrigger)
GDK_AVAILABLE_IN_ALL
GtkShortcutTrigger * gtk_keyval_trigger_new (guint keyval,
GdkModifierType modifiers);
GDK_AVAILABLE_IN_ALL
GdkModifierType gtk_keyval_trigger_get_modifiers (GtkKeyvalTrigger *self);
GDK_AVAILABLE_IN_ALL
guint gtk_keyval_trigger_get_keyval (GtkKeyvalTrigger *self);
#define GTK_TYPE_MNEMONIC_TRIGGER (gtk_mnemonic_trigger_get_type())
/**
* GtkMnemonicTrigger:
*
* A #GtkShortcutTrigger that triggers when a specific mnemonic
* is pressed.
*/
GDK_AVAILABLE_IN_ALL
GDK_DECLARE_INTERNAL_TYPE (GtkMnemonicTrigger, gtk_mnemonic_trigger, GTK, MNEMONIC_TRIGGER, GtkShortcutTrigger)
GDK_AVAILABLE_IN_ALL
GtkShortcutTrigger * gtk_mnemonic_trigger_new (guint keyval);
GDK_AVAILABLE_IN_ALL
guint gtk_mnemonic_trigger_get_keyval (GtkMnemonicTrigger *self);
#define GTK_TYPE_ALTERNATIVE_TRIGGER (gtk_alternative_trigger_get_type())
/**
* GtkAlternativeTrigger:
*
* A #GtkShortcutTrigger that triggers when either of two
* #GtkShortcutTriggers trigger.
*/
GDK_AVAILABLE_IN_ALL
GDK_DECLARE_INTERNAL_TYPE (GtkAlternativeTrigger, gtk_alternative_trigger, GTK, ALTERNATIVE_TRIGGER, GtkShortcutTrigger)
GDK_AVAILABLE_IN_ALL
GtkShortcutTrigger * gtk_alternative_trigger_new (GtkShortcutTrigger *first,
GtkShortcutTrigger *second);
GDK_AVAILABLE_IN_ALL
GtkShortcutTrigger * gtk_alternative_trigger_get_first (GtkAlternativeTrigger *self);
GDK_AVAILABLE_IN_ALL
GtkShortcutTrigger * gtk_alternative_trigger_get_second (GtkAlternativeTrigger *self);
G_END_DECLS
#endif /* __GTK_SHORTCUT_TRIGGER_H__ */