Merge branch 'Forkest/copy-items-nonlatin'

Work around incorrect keybinding handling with multiple layouts so
cut/copy/delete keybindings work via menuitem activation if we failed
to trigger the action ourselves.

Closes #1386.
This commit is contained in:
Colomban Wendling 2017-02-05 17:32:54 +01:00
commit b0f71a1666
4 changed files with 26 additions and 6 deletions

View File

@ -6562,7 +6562,8 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">_Edit</property> <property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="activate" handler="on_edit1_activate" swapped="no"/> <signal name="select" handler="on_edit1_select" swapped="no"/>
<signal name="deselect" handler="on_edit1_deselect" swapped="no"/>
<child type="submenu"> <child type="submenu">
<object class="GtkMenu" id="edit1_menu"> <object class="GtkMenu" id="edit1_menu">
<property name="can_focus">False</property> <property name="can_focus">False</property>

View File

@ -183,7 +183,7 @@ static void on_file1_activate(GtkMenuItem *menuitem, gpointer user_data)
/* edit actions, c&p & co, from menu bar and from popup menu */ /* edit actions, c&p & co, from menu bar and from popup menu */
static void on_edit1_activate(GtkMenuItem *menuitem, gpointer user_data) static void on_edit1_select(GtkMenuItem *menuitem, gpointer user_data)
{ {
GtkWidget *item; GtkWidget *item;
GeanyDocument *doc = document_get_current(); GeanyDocument *doc = document_get_current();
@ -200,6 +200,16 @@ static void on_edit1_activate(GtkMenuItem *menuitem, gpointer user_data)
} }
static void on_edit1_deselect(GtkMenuShell *menushell, gpointer user_data)
{
/* we re-enable items that were disabled in on_edit1_select() on menu popdown to
* workaround mutli-layout keyboard issues in our keybinding handling code, so that
* GTK's accelerator handling can catch them.
* See https://github.com/geany/geany/issues/1368#issuecomment-273678207 */
ui_menu_copy_items_set_sensitive(TRUE);
}
void on_undo1_activate(GtkMenuItem *menuitem, gpointer user_data) void on_undo1_activate(GtkMenuItem *menuitem, gpointer user_data)
{ {
GeanyDocument *doc = document_get_current(); GeanyDocument *doc = document_get_current();

View File

@ -512,10 +512,19 @@ void ui_update_popup_goto_items(gboolean enable)
} }
void ui_menu_copy_items_set_sensitive(gboolean sensitive)
{
guint i, len;
len = G_N_ELEMENTS(widgets.menu_copy_items);
for (i = 0; i < len; i++)
ui_widget_set_sensitive(widgets.menu_copy_items[i], sensitive);
}
void ui_update_menu_copy_items(GeanyDocument *doc) void ui_update_menu_copy_items(GeanyDocument *doc)
{ {
gboolean enable = FALSE; gboolean enable = FALSE;
guint i, len;
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window)); GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
g_return_if_fail(doc == NULL || doc->is_valid); g_return_if_fail(doc == NULL || doc->is_valid);
@ -533,9 +542,7 @@ void ui_update_menu_copy_items(GeanyDocument *doc)
enable = gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL); enable = gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL);
} }
len = G_N_ELEMENTS(widgets.menu_copy_items); ui_menu_copy_items_set_sensitive(enable);
for (i = 0; i < len; i++)
ui_widget_set_sensitive(widgets.menu_copy_items[i], enable);
} }

View File

@ -297,6 +297,8 @@ void ui_update_popup_copy_items(GeanyDocument *doc);
void ui_update_popup_goto_items(gboolean enable); void ui_update_popup_goto_items(gboolean enable);
void ui_menu_copy_items_set_sensitive(gboolean sensitive);
void ui_update_menu_copy_items(GeanyDocument *doc); void ui_update_menu_copy_items(GeanyDocument *doc);
void ui_update_insert_include_item(GeanyDocument *doc, gint item); void ui_update_insert_include_item(GeanyDocument *doc, gint item);