flowbox: Add a private api to disable move-cursor
Without this, it seems impossible to make cross-section keynav in the Emoji chooser work. I've tried, but got lost between the focus, grab_focus, move_cursor and keynav-failed vfuncs and signals, and their competing implementations GtkFlowBox and GtkEmojiChooser.
This commit is contained in:
@@ -766,6 +766,8 @@ stop_search (GtkEntry *entry,
|
||||
gtk_popover_popdown (GTK_POPOVER (data));
|
||||
}
|
||||
|
||||
extern void gtk_flow_box_disable_move_cursor (GtkFlowBox *box);
|
||||
|
||||
static void
|
||||
setup_section (GtkEmojiChooser *chooser,
|
||||
EmojiSection *section,
|
||||
@@ -781,6 +783,7 @@ setup_section (GtkEmojiChooser *chooser,
|
||||
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window));
|
||||
|
||||
gtk_container_set_focus_vadjustment (GTK_CONTAINER (section->box), adj);
|
||||
gtk_flow_box_disable_move_cursor (GTK_FLOW_BOX (section->box));
|
||||
gtk_flow_box_set_filter_func (GTK_FLOW_BOX (section->box), filter_func, section, NULL);
|
||||
g_signal_connect_swapped (section->button, "clicked", G_CALLBACK (scroll_to_section), section);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "gtkflowbox.h"
|
||||
#include "gtkflowboxprivate.h"
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkcontainerprivate.h"
|
||||
@@ -640,6 +641,8 @@ struct _GtkFlowBoxPrivate {
|
||||
GtkFlowBoxCreateWidgetFunc create_widget_func;
|
||||
gpointer create_widget_func_data;
|
||||
GDestroyNotify create_widget_func_data_destroy;
|
||||
|
||||
gboolean disable_move_cursor;
|
||||
};
|
||||
|
||||
#define BOX_PRIV(box) ((GtkFlowBoxPrivate*)gtk_flow_box_get_instance_private ((GtkFlowBox*)(box)))
|
||||
@@ -3005,6 +3008,14 @@ gtk_flow_box_toggle_cursor_child (GtkFlowBox *box)
|
||||
gtk_flow_box_select_and_activate (box, priv->cursor_child);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_flow_box_disable_move_cursor (GtkFlowBox *box)
|
||||
{
|
||||
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
|
||||
|
||||
priv->disable_move_cursor = TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_flow_box_move_cursor (GtkFlowBox *box,
|
||||
GtkMovementStep step,
|
||||
@@ -3023,6 +3034,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
|
||||
GtkAdjustment *adjustment;
|
||||
gboolean vertical;
|
||||
|
||||
if (priv->disable_move_cursor)
|
||||
return FALSE;
|
||||
|
||||
vertical = priv->orientation == GTK_ORIENTATION_VERTICAL;
|
||||
|
||||
if (vertical)
|
||||
|
||||
26
gtk/gtkflowboxprivate.h
Normal file
26
gtk/gtkflowboxprivate.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 2020 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_FLOW_BOX_PRIVATE_H__
|
||||
#define __GTK_FLOW_BOX_PRIVATE_H__
|
||||
|
||||
#include "gtkflowbox.h"
|
||||
|
||||
void gtk_flow_box_disable_move_cursor (GtkFlowBox *box);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user