Kaydet (Commit) e3d3765a authored tarafından Nick Treleaven's avatar Nick Treleaven

Add fixed shortcuts for VTE copy (Ctrl-Shift-C) and paste

(Ctrl-Shift-V).



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5623 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 15937490
......@@ -2,6 +2,9 @@
* plugins/filebrowser.c:
Add history to filter entry.
* src/keybindings.c, src/vte.c:
Add fixed shortcuts for VTE copy (Ctrl-Shift-C) and paste
(Ctrl-Shift-V).
2011-03-24 Colomban Wendling <colomban(at)geany(dot)org>
......
......@@ -1083,6 +1083,9 @@ static gboolean check_vte(GdkModifierType state, guint keyval)
return FALSE;
if (state == 0 && (keyval < GDK_F1 || keyval > GDK_F35)) /* e.g. backspace */
return FALSE;
/* let VTE copy/paste override any user keybinding */
if (state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) && (keyval == GDK_c || keyval == GDK_v))
return TRUE;
/* make focus commands override any bash commands */
group = g_ptr_array_index(keybinding_groups, GEANY_KEY_GROUP_FOCUS);
......
......@@ -60,7 +60,6 @@ static pid_t pid = 0;
static gboolean clean = TRUE;
static GModule *module = NULL;
static struct VteFunctions *vf;
static gboolean popup_menu_created = FALSE;
static gchar *gtk_menu_key_accel = NULL;
static gint vte_prefs_tab_num = -1;
......@@ -232,6 +231,15 @@ void vte_init(void)
}
static void on_vte_realize(void)
{
/* the vte widget has to be realised before color changes take effect */
vte_apply_user_settings();
vf->vte_terminal_im_append_menuitems(VTE_TERMINAL(vc->vte), GTK_MENU_SHELL(vc->im_submenu));
}
static void create_vte(void)
{
GtkWidget *vte, *scrollbar, *hbox, *frame;
......@@ -240,6 +248,9 @@ static void create_vte(void)
scrollbar = gtk_vscrollbar_new(GTK_ADJUSTMENT(VTE_TERMINAL(vte)->adjustment));
GTK_WIDGET_UNSET_FLAGS(scrollbar, GTK_CAN_FOCUS);
/* create menu now so copy/paste shortcuts work */
vc->menu = vte_create_popup_menu();
frame = gtk_frame_new(NULL);
hbox = gtk_hbox_new(FALSE, 0);
......@@ -271,8 +282,7 @@ static void create_vte(void)
gtk_widget_show_all(frame);
gtk_notebook_insert_page(GTK_NOTEBOOK(msgwindow.notebook), frame, gtk_label_new(_("Terminal")), MSG_VTE);
/* the vte widget has to be realised before color changes take effect */
g_signal_connect_after(vte, "realize", G_CALLBACK(vte_apply_user_settings), NULL);
g_signal_connect_after(vte, "realize", G_CALLBACK(on_vte_realize), NULL);
}
......@@ -282,7 +292,6 @@ void vte_close(void)
/* free the vte widget before unloading vte module
* this prevents a segfault on X close window if the message window is hidden */
gtk_widget_destroy(vc->vte);
if (popup_menu_created)
gtk_widget_destroy(vc->menu);
g_free(vc->emulation);
g_free(vc->shell);
......@@ -378,17 +387,9 @@ static gboolean vte_button_pressed(GtkWidget *widget, GdkEventButton *event, gpo
{
if (event->button == 3)
{
if (G_UNLIKELY(! popup_menu_created))
{
vc->menu = vte_create_popup_menu();
vf->vte_terminal_im_append_menuitems(VTE_TERMINAL(vc->vte), GTK_MENU_SHELL(vc->im_submenu));
popup_menu_created = TRUE;
}
gtk_widget_grab_focus(vc->vte);
gtk_menu_popup(GTK_MENU(vc->menu), NULL, NULL, NULL, NULL, event->button, event->time);
}
return FALSE;
}
......@@ -507,15 +508,23 @@ static void vte_popup_menu_clicked(GtkMenuItem *menuitem, gpointer user_data)
static GtkWidget *vte_create_popup_menu(void)
{
GtkWidget *menu, *item;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(main_widgets.window), accel_group);
item = gtk_image_menu_item_new_from_stock("gtk-copy", NULL);
gtk_widget_add_accelerator(item, "activate", accel_group,
GDK_c, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(menu), item);
g_signal_connect(item, "activate", G_CALLBACK(vte_popup_menu_clicked), GINT_TO_POINTER(POPUP_COPY));
item = gtk_image_menu_item_new_from_stock("gtk-paste", NULL);
gtk_widget_add_accelerator(item, "activate", accel_group,
GDK_v, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
gtk_widget_show(item);
gtk_container_add(GTK_CONTAINER(menu), item);
g_signal_connect(item, "activate", G_CALLBACK(vte_popup_menu_clicked), GINT_TO_POINTER(POPUP_PASTE));
......@@ -566,7 +575,7 @@ static GtkWidget *vte_create_popup_menu(void)
gtk_container_add(GTK_CONTAINER(menu), item);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), vc->im_submenu);
/* submenu populated after vte realized */
return menu;
}
......
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