gboolean lcrt_terminal_has_selection(struct lcrt_window *lwindow) { if (lwindow == NULL || lwindow->w_notebook == NULL || lwindow->w_notebook->current_terminal == NULL) return FALSE; return vte_terminal_get_has_selection(lwindow->w_notebook->current_terminal->terminal); }
static guint console_menu_extra_state(void) { #ifdef G_OS_UNIX if (debug_console) return vte_terminal_get_has_selection(debug_console) << DS_INDEX_1; #endif return gtk_text_buffer_get_has_selection(context) << DS_INDEX_1; }
void lcrt_terminal_on_selection_changed(VteTerminal *vteterminal, gpointer user_data) { struct lcrt_terminal *lterminal = (struct lcrt_terminal *)user_data; struct lcrt_toolbar *ltoolbar = lterminal->parent->parent->w_toolbar; gboolean selected = vte_terminal_get_has_selection(lterminal->terminal); gtk_widget_set_sensitive(ltoolbar->toolitem[LCRT_B_COPY], selected); gtk_widget_set_sensitive(ltoolbar->toolitem[LCRT_B_PASTE], lterminal->connected == LCRT_TERMINAL_CONNECTED); }
static void on_terminal_copy_cb (GtkAction * action, TerminalPlugin *term_plugin) { VteTerminal *term; if (term_plugin->child_pid) term = VTE_TERMINAL (term_plugin->term); else term = VTE_TERMINAL (term_plugin->shell); if (vte_terminal_get_has_selection(term)) vte_terminal_copy_clipboard(term); }
static void popup_targets_received (GtkClipboard *clipboard, GtkSelectionData *data, gpointer user_data) { PopupInfo *popup_info = user_data; g_autoptr(IdeTerminal) self = NULL; g_autoptr(GdkEvent) event = NULL; IdeTerminalPrivate *priv; g_assert (popup_info != NULL); g_assert (IDE_IS_TERMINAL (popup_info->terminal)); self = g_steal_pointer (&popup_info->terminal); priv = ide_terminal_get_instance_private (self); event = g_steal_pointer (&popup_info->event); if (gtk_widget_get_realized (GTK_WIDGET (self))) { DzlWidgetActionGroup *group; GMenu *menu; gboolean clipboard_contains_text; gboolean have_selection; clipboard_contains_text = gtk_selection_data_targets_include_text (data); have_selection = vte_terminal_get_has_selection (VTE_TERMINAL (self)); g_clear_pointer (&priv->popup_menu, gtk_widget_destroy); priv->url = vte_terminal_match_check_event (VTE_TERMINAL (self), event, NULL); menu = dzl_application_get_menu_by_id (DZL_APPLICATION_DEFAULT, "ide-terminal-view-popup-menu"); priv->popup_menu = gtk_menu_new_from_model (G_MENU_MODEL (menu)); group = DZL_WIDGET_ACTION_GROUP (gtk_widget_get_action_group (GTK_WIDGET (self), "terminal")); dzl_widget_action_group_set_action_enabled (group, "copy-link-address", priv->url != NULL); dzl_widget_action_group_set_action_enabled (group, "open-link", priv->url != NULL); dzl_widget_action_group_set_action_enabled (group, "copy-clipboard", have_selection); dzl_widget_action_group_set_action_enabled (group, "paste-clipboard", clipboard_contains_text); dzl_gtk_widget_add_style_class (priv->popup_menu, GTK_STYLE_CLASS_CONTEXT_MENU); gtk_menu_attach_to_widget (GTK_MENU (priv->popup_menu), GTK_WIDGET (self), popup_menu_detach); g_signal_emit (self, signals[POPULATE_POPUP], 0, priv->popup_menu); gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), event); } g_slice_free (PopupInfo, popup_info); }
gchar* termit_get_selection() { gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); TERMIT_GET_TAB_BY_INDEX2(pTab, page, NULL); if (vte_terminal_get_has_selection(VTE_TERMINAL(pTab->vte)) == FALSE) { return NULL; } GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_PRIMARY); gchar* text = NULL; gtk_clipboard_request_text(clip, clipboard_received_text, &text); if (!text) return NULL; return text; }
static gboolean terminal_click_cb (GtkWidget *widget, GdkEventButton *event, TerminalPlugin *term) { if (event->button == 3) { AnjutaUI *ui; GtkMenu *popup; GtkAction *action; ui = anjuta_shell_get_ui (ANJUTA_PLUGIN(term)->shell, NULL); popup = GTK_MENU (gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui), "/PopupTerminal")); action = gtk_action_group_get_action (term->action_group, "ActionCopyFromTerminal"); gtk_action_set_sensitive (action,vte_terminal_get_has_selection(VTE_TERMINAL(widget))); gtk_menu_popup (popup, NULL, NULL, NULL, NULL, event->button, event->time); } return FALSE; }
static gboolean term_mouse_button_released (VteTerminal *vtterm, GdkEventButton *event, gpointer userdata) { g_free (last_match_text); last_match_text = NULL; glong row = (glong) (event->y) / vte_terminal_get_char_height (vtterm); glong col = (glong) (event->x) / vte_terminal_get_char_width (vtterm); gint match_tag; dg_lmem gchar* match = vte_terminal_match_check (vtterm, col, row, &match_tag); if (match && event->button == 1) { if (CHECK_FLAGS (event->state, GDK_CONTROL_MASK)) { dg_lerr GError *gerror = NULL; if (!gtk_show_uri (NULL, match, event->time, &gerror)) g_printerr ("Could not open URL: %s\n", gerror->message); return FALSE; } else if (g_regex_match (image_regex, match, 0, NULL)) { /* Show picture in a popover */ GdkRectangle rect; rect.height = vte_terminal_get_char_height (vtterm); rect.width = vte_terminal_get_char_width (vtterm); rect.y = rect.height * row; rect.x = rect.width * col; GtkWidget* popover = make_popover_for_image_url (vtterm, match); gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect); return FALSE; } } if (event->button == 3 && userdata != NULL) { GdkRectangle rect; rect.height = vte_terminal_get_char_height (vtterm); rect.width = vte_terminal_get_char_width (vtterm); rect.y = rect.height * row; rect.x = rect.width * col; gtk_popover_set_pointing_to (GTK_POPOVER (userdata), &rect); GActionMap *actions = G_ACTION_MAP (gtk_widget_get_ancestor (GTK_WIDGET (vtterm), GTK_TYPE_WINDOW)); g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (actions, "copy")), vte_terminal_get_has_selection (vtterm)); g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (actions, "open-url")), match != NULL); g_simple_action_set_enabled (G_SIMPLE_ACTION (g_action_map_lookup_action (actions, "copy-url")), match != NULL); if (match) { last_match_text = match; match = NULL; } gtk_widget_show_all (GTK_WIDGET (userdata)); return TRUE; } return FALSE; }
void Terminal::vte_selection_changed(VteTerminal *vte, gpointer user_data) { if (vte_terminal_get_has_selection(vte)) { vte_terminal_copy_clipboard(vte); } }
static guint terminal_menu_extra_state(void) { return vte_terminal_get_has_selection(program_terminal) << DS_INDEX_1; }
static VALUE rg_has_selection_p(VALUE self) { return CBOOL2RVAL(vte_terminal_get_has_selection(_SELF(self))); }
static VALUE term_get_has_selection(VALUE self) { return CBOOL2RVAL(vte_terminal_get_has_selection(RVAL2TERM(self))); }