mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 07:04:29 +00:00
fontchooser: Add global keynav
Starting to type should focus the search entry and start a search.
This commit is contained in:
parent
3f012f6d01
commit
e90787d975
@ -26,6 +26,7 @@
|
|||||||
#include "gtkfontchooserdialog.h"
|
#include "gtkfontchooserdialog.h"
|
||||||
#include "gtkfontchooser.h"
|
#include "gtkfontchooser.h"
|
||||||
#include "gtkfontchooserwidget.h"
|
#include "gtkfontchooserwidget.h"
|
||||||
|
#include "gtkfontchooserwidgetprivate.h"
|
||||||
#include "gtkfontchooserutils.h"
|
#include "gtkfontchooserutils.h"
|
||||||
#include "gtkbox.h"
|
#include "gtkbox.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
@ -120,6 +121,21 @@ font_activated_cb (GtkFontChooser *fontchooser,
|
|||||||
gtk_dialog_response (dialog, GTK_RESPONSE_OK);
|
gtk_dialog_response (dialog, GTK_RESPONSE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gtk_font_chooser_dialog_key_press_event (GtkWidget *dialog,
|
||||||
|
GdkEventKey *event)
|
||||||
|
{
|
||||||
|
GtkFontChooserDialog *fdialog = GTK_FONT_CHOOSER_DIALOG (dialog);
|
||||||
|
gboolean handled = FALSE;
|
||||||
|
|
||||||
|
handled = GTK_WIDGET_CLASS (gtk_font_chooser_dialog_parent_class)->key_press_event (dialog, event);
|
||||||
|
|
||||||
|
if (!handled)
|
||||||
|
handled = gtk_font_chooser_widget_handle_event (fdialog->priv->fontchooser, event);
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
|
gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
|
||||||
{
|
{
|
||||||
@ -129,6 +145,8 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
|
|||||||
gobject_class->get_property = gtk_font_chooser_dialog_get_property;
|
gobject_class->get_property = gtk_font_chooser_dialog_get_property;
|
||||||
gobject_class->set_property = gtk_font_chooser_dialog_set_property;
|
gobject_class->set_property = gtk_font_chooser_dialog_set_property;
|
||||||
|
|
||||||
|
widget_class->key_press_event = gtk_font_chooser_dialog_key_press_event;
|
||||||
|
|
||||||
_gtk_font_chooser_install_properties (gobject_class);
|
_gtk_font_chooser_install_properties (gobject_class);
|
||||||
|
|
||||||
/* Bind class to template
|
/* Bind class to template
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <atk/atk.h>
|
#include <atk/atk.h>
|
||||||
|
|
||||||
#include "gtkfontchooserwidget.h"
|
#include "gtkfontchooserwidget.h"
|
||||||
|
#include "gtkfontchooserwidgetprivate.h"
|
||||||
|
|
||||||
#include "gtkadjustment.h"
|
#include "gtkadjustment.h"
|
||||||
#include "gtkbuildable.h"
|
#include "gtkbuildable.h"
|
||||||
@ -1401,3 +1402,14 @@ gtk_font_chooser_widget_iface_init (GtkFontChooserIface *iface)
|
|||||||
iface->set_font_map = gtk_font_chooser_widget_set_font_map;
|
iface->set_font_map = gtk_font_chooser_widget_set_font_map;
|
||||||
iface->get_font_map = gtk_font_chooser_widget_get_font_map;
|
iface->get_font_map = gtk_font_chooser_widget_get_font_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gtk_font_chooser_widget_handle_event (GtkWidget *widget,
|
||||||
|
GdkEventKey *key_event)
|
||||||
|
{
|
||||||
|
GtkFontChooserWidget *fontchooser = GTK_FONT_CHOOSER_WIDGET (widget);
|
||||||
|
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
|
||||||
|
GdkEvent *event = (GdkEvent *)key_event;
|
||||||
|
|
||||||
|
return gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search_entry), event);
|
||||||
|
}
|
||||||
|
30
gtk/gtkfontchooserwidgetprivate.h
Normal file
30
gtk/gtkfontchooserwidgetprivate.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* GTK - The GIMP Toolkit
|
||||||
|
* Copyright (C) 2017 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_FONT_CHOOSER_WIDGET_PRIVATE_H__
|
||||||
|
#define __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__
|
||||||
|
|
||||||
|
#include "gtkfontchooserwidget.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
gboolean gtk_font_chooser_widget_handle_event (GtkWidget *widget,
|
||||||
|
GdkEventKey *event);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GTK_FONT_CHOOSER_WIDGET_PRIVATE_H__ */
|
Loading…
Reference in New Issue
Block a user