Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ctrl+X and Ctrl+C in non-Latin keyboard layouts #1386

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions data/geany.glade
Original file line number Diff line number Diff line change
Expand Up @@ -6321,6 +6321,7 @@
<object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="deactivate" handler="on_menubar1_deactivate" after="yes" swapped="no"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sad we can't really connect something on the menu item next to the "activate" signal. We could use "deselect", but I'm not sure is really correct.

Copy link
Contributor Author

@Forkest Forkest Feb 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about "deselect" too. Probably yes, but it feels not safe to rely on "activate"-"deselect". If we change "activate" to "select", then it'll be OK, IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've experimented a bit, but can't find the difference between activate and select. GTK docs aren't clear about this too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://developer.gnome.org/gtk3/stable/GtkMenuShell.html#id-1.3.20.5.10.4 suggests using select/deselect is just fine. And in practice it does seem to work great.
But agreed the docs are not very clear.

<child>
<object class="GtkMenuItem" id="file1">
<property name="visible">True</property>
Expand Down
6 changes: 6 additions & 0 deletions src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ static void on_edit1_activate(GtkMenuItem *menuitem, gpointer user_data)
}


static void on_menubar1_deactivate(GtkMenuShell *menushell, gpointer user_data)
{
ui_restore_menu_copy_items();
}


void on_undo1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
GeanyDocument *doc = document_get_current();
Expand Down
20 changes: 16 additions & 4 deletions src/ui_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,18 @@ void ui_update_popup_goto_items(gboolean enable)
}


static void set_menu_copy_items_sensitive(gboolean enable)
{
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], enable);
}


void ui_update_menu_copy_items(GeanyDocument *doc)
{
gboolean enable = FALSE;
guint i, len;
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));

g_return_if_fail(doc == NULL || doc->is_valid);
Expand All @@ -533,9 +541,13 @@ void ui_update_menu_copy_items(GeanyDocument *doc)
enable = gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL);
}

len = G_N_ELEMENTS(widgets.menu_copy_items);
for (i = 0; i < len; i++)
ui_widget_set_sensitive(widgets.menu_copy_items[i], enable);
set_menu_copy_items_sensitive(enable);
}


void ui_restore_menu_copy_items()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function indirection doesn't add clarity to me, so I'd rather expose the set_sensitive() part directly.

{
set_menu_copy_items_sensitive(TRUE);
}


Expand Down
2 changes: 2 additions & 0 deletions src/ui_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ void ui_update_popup_goto_items(gboolean enable);

void ui_update_menu_copy_items(GeanyDocument *doc);

void ui_restore_menu_copy_items();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argument list should be (void) for a proper prototype


void ui_update_insert_include_item(GeanyDocument *doc, gint item);

void ui_update_fold_items(void);
Expand Down