static void menu_paste_cb (GtkWidget *widget, gpointer data) { DEBUG_FUNCTION ("menu_paste_cb"); DEBUG_ASSERT (widget != NULL); DEBUG_ASSERT (data != NULL); tilda_term *tt = TILDA_TERM(data); vte_terminal_paste_clipboard (VTE_TERMINAL (tt->vte_term)); }
static void menu_paste_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data) { DEBUG_FUNCTION ("menu_paste_cb"); DEBUG_ASSERT (user_data != NULL); tilda_term *tt = TILDA_TERM(user_data); vte_terminal_paste_clipboard (VTE_TERMINAL (tt->vte_term)); }
static void window_title_changed_cb (GtkWidget *widget, gpointer data) { DEBUG_FUNCTION ("window_title_changed_cb"); DEBUG_ASSERT (widget != NULL); DEBUG_ASSERT (data != NULL); tilda_term *tt = TILDA_TERM(data); gchar *title = get_window_title (widget); GtkWidget *label; label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (tt->tw->notebook), tt->hbox); gtk_label_set_text (GTK_LABEL(label), title); g_free (title); }
static void child_exited_cb (GtkWidget *widget, gpointer data) { DEBUG_FUNCTION ("child_exited_cb"); DEBUG_ASSERT (widget != NULL); DEBUG_ASSERT (data != NULL); tilda_term *tt = TILDA_TERM(data); gint index = gtk_notebook_page_num (GTK_NOTEBOOK(tt->tw->notebook), tt->hbox); /* Make sure we got a valid index */ if (index == -1) { DEBUG_ERROR ("Bad notebook tab\n"); return; } /* These can stay here. They don't need to go into a header because * they are only used at this point in the code. */ enum command_exit { DROP_TO_DEFAULT_SHELL, RESTART_COMMAND, EXIT_TERMINAL }; /* Check the user's preference for what to do when the child terminal * is closed. Take the appropriate action */ switch (config_getint ("command_exit")) { case EXIT_TERMINAL: tilda_window_close_tab (tt->tw, index, FALSE); break; case RESTART_COMMAND: vte_terminal_feed (VTE_TERMINAL(tt->vte_term), "\r\n\r\n", 4); start_shell (tt, FALSE, NULL); break; case DROP_TO_DEFAULT_SHELL: start_shell (tt, TRUE, NULL); default: break; } }
static void window_title_changed_cb (GtkWidget *widget, gpointer data) { DEBUG_FUNCTION ("window_title_changed_cb"); DEBUG_ASSERT (widget != NULL); DEBUG_ASSERT (data != NULL); tilda_term *tt = TILDA_TERM(data); gchar *title = get_window_title (widget); GtkWidget *label; label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (tt->tw->notebook), tt->hbox); /* We need to check if the widget that received the title change is the currently * active tab. If not we should not update the window title. */ gint page = gtk_notebook_get_current_page (GTK_NOTEBOOK (tt->tw->notebook)); GtkWidget *active_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (tt->tw->notebook), page); gboolean active = widget == active_page; guint length = (guint) config_getint ("title_max_length"); if(config_getbool("title_max_length_flag") && strlen(title) > length) { gchar *titleOffset = title + strlen(title) - length; gchar *shortTitle = g_strdup_printf ("...%s", titleOffset); gtk_label_set_text (GTK_LABEL(label), shortTitle); if (active) { gtk_window_set_title (GTK_WINDOW (tt->tw->window), shortTitle); } g_free(shortTitle); } else { gtk_label_set_text (GTK_LABEL(label), title); if (active) { gtk_window_set_title (GTK_WINDOW (tt->tw->window), title); } } g_free (title); }
static int button_press_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { DEBUG_FUNCTION ("button_press_cb"); DEBUG_ASSERT (data != NULL); VteTerminal *terminal; tilda_term *tt; gchar *match; gint tag; gint xpad, ypad; gchar *cmd; gchar *web_browser_cmd; gboolean ret = FALSE; tt = TILDA_TERM(data); switch (event->button) { case 3: /* Right Click */ popup_menu (tt->tw, tt); break; case 2: /* Middle Click */ break; case 1: /* Left Click */ terminal = VTE_TERMINAL(tt->vte_term); GtkBorder border; gtk_widget_style_get (GTK_WIDGET (terminal), "inner-border", &border, NULL); xpad = border.left; ypad = border.bottom; match = vte_terminal_match_check (terminal, (event->x - ypad) / vte_terminal_get_char_width (terminal), (event->y - ypad) / vte_terminal_get_char_height (terminal), &tag); /* Check if we can launch a web browser, and do so if possible */ if ((event->state & GDK_CONTROL_MASK) && match != NULL) { #if DEBUG g_print ("Got a Ctrl+Left Click -- Matched: `%s' (%d)\n", match, tag); #endif web_browser_cmd = g_strescape (config_getstr ("web_browser"), NULL); cmd = g_strdup_printf ("%s %s", web_browser_cmd, match); #if DEBUG g_print ("Launching command: `%s'\n", cmd); #endif ret = g_spawn_command_line_async(cmd, NULL); /* Check that the command launched */ if (!ret) { g_printerr (_("Failed to launch the web browser. The command was `%s'\n"), cmd); TILDA_PERROR (); } g_free (cmd); } /* Always free match if it is non NULL */ if (match) g_free (match); break; default: break; } return FALSE; }