Commit a288047f authored by Milan Crha's avatar Milan Crha

I#140 - Single key accelerator triggered in search box ]I[

Related to #140
parent 8e68c3cb
......@@ -41,6 +41,10 @@
<title>Index</title>
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-3-32" role="3.32">
<title>Index of new symbols in 3.32</title>
<xi:include href="xml/api-index-3.32.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-3-24" role="3.24">
<title>Index of new symbols in 3.24</title>
<xi:include href="xml/api-index-3.24.xml"><xi:fallback /></xi:include>
......
......@@ -263,7 +263,8 @@ mail_shell_view_process_key_press_event (EMailShellView *mail_shell_view,
shell_view = E_SHELL_VIEW (mail_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
if ((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0)
if ((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0 ||
e_shell_window_get_need_input (shell_window, event))
return FALSE;
shell_content = e_shell_view_get_shell_content (shell_view);
......
......@@ -349,14 +349,8 @@ static gboolean
e_shell_window_key_press_event_cb (GtkWidget *widget,
GdkEventKey *event)
{
GtkWindow *window;
GtkWidget *focused;
g_return_val_if_fail (E_IS_SHELL_WINDOW (widget), FALSE);
window = GTK_WINDOW (widget);
focused = gtk_window_get_focus (window);
if ((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0 ||
event->keyval == GDK_KEY_Tab ||
event->keyval == GDK_KEY_Return ||
......@@ -366,10 +360,13 @@ e_shell_window_key_press_event_cb (GtkWidget *widget,
event->keyval == GDK_KEY_BackSpace)
return FALSE;
if (GTK_IS_ENTRY (focused) ||
GTK_IS_EDITABLE (focused) ||
(GTK_IS_TREE_VIEW (focused) && gtk_tree_view_get_search_column (GTK_TREE_VIEW (focused)) >= 0)) {
gtk_widget_event (focused, (GdkEvent *) event);
if (e_shell_window_get_need_input (E_SHELL_WINDOW (widget), event)) {
GtkWidget *focused;
focused = gtk_window_get_focus (GTK_WINDOW (widget));
if (focused)
gtk_widget_event (focused, (GdkEvent *) event);
return TRUE;
}
......
......@@ -2146,3 +2146,33 @@ e_shell_window_register_new_source_actions (EShellWindow *shell_window,
"backend-name", (gpointer) backend_name);
}
}
/**
* e_shell_window_get_need_input:
* @shell_window: an #EShellWindow
* @event: a #GdkEventKey
*
* Returns: Whether the key @event should be processed by currently
* focused widget in the @window, instead of being processed
* bu usual means including accelerators.
*
* Since: 3.32
**/
gboolean
e_shell_window_get_need_input (EShellWindow *shell_window,
GdkEventKey *event)
{
GtkWidget *focused;
g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if ((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0)
return FALSE;
focused = gtk_window_get_focus (GTK_WINDOW (shell_window));
return focused && (GTK_IS_ENTRY (focused) ||
GTK_IS_EDITABLE (focused) ||
(GTK_IS_TREE_VIEW (focused) && gtk_tree_view_get_search_column (GTK_TREE_VIEW (focused)) >= 0));
}
......@@ -155,6 +155,9 @@ void e_shell_window_connect_client (EShellWindow *shell_window,
gpointer user_data,
GDestroyNotify destroy_user_data);
gboolean e_shell_window_get_need_input (EShellWindow *shell_window,
GdkEventKey *event);
/* These should be called from the shell backend's window_created() handler. */
void e_shell_window_register_new_item_actions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment