static void char_size_realized(GtkWidget *widget, gpointer data) { VteTerminal *terminal; GtkWindow *window; GdkGeometry geometry; guint width, height; GtkBorder *inner_border; g_assert(GTK_IS_WINDOW(data)); g_assert(VTE_IS_TERMINAL(widget)); terminal = VTE_TERMINAL(widget); window = GTK_WINDOW(data); if (!GTK_WIDGET_REALIZED (window)) return; gtk_widget_style_get (widget, "inner-border", &inner_border, NULL); width = vte_terminal_get_char_width (terminal); height = vte_terminal_get_char_height (terminal); geometry.width_inc = width; geometry.height_inc = height; geometry.base_width = inner_border ? (inner_border->left + inner_border->right) : 0; geometry.base_height = inner_border ? (inner_border->top + inner_border->bottom) : 0; geometry.min_width = geometry.base_width + width * 2; geometry.min_height = geometry.base_height + height * 2; gtk_border_free (inner_border); gtk_window_set_geometry_hints(window, widget, &geometry, GDK_HINT_RESIZE_INC | GDK_HINT_BASE_SIZE | GDK_HINT_MIN_SIZE); }
static void size_allocate_cb (VteTerminal *terminal, GtkAllocation *alloc, GbTerminalView *self) { glong width; glong height; glong columns; glong rows; g_assert (VTE_IS_TERMINAL (terminal)); g_assert (alloc != NULL); g_assert (GB_IS_TERMINAL_VIEW (self)); if ((alloc->width == 0) || (alloc->height == 0)) return; width = vte_terminal_get_char_width (terminal); height = vte_terminal_get_char_height (terminal); if ((width == 0) || (height == 0)) return; columns = alloc->width / width; rows = alloc->height / height; if ((columns < 2) || (rows < 2)) return; vte_terminal_set_size (terminal, columns, rows); }
static gboolean focus_in_event_cb (VteTerminal *terminal, GdkEvent *event, GbTerminalView *self) { const gchar *title; g_assert (VTE_IS_TERMINAL (terminal)); g_assert (GB_IS_TERMINAL_VIEW (self)); self->bottom_has_focus = (terminal != self->terminal_top); title = gb_terminal_get_title (GB_VIEW (self)); if (self->document) gb_terminal_document_set_title (self->document, title); if (terminal == self->terminal_top) { self->top_has_needs_attention = FALSE; gb_terminal_set_needs_attention (self, FALSE, GTK_POS_TOP); } else if (terminal == self->terminal_bottom) { self->bottom_has_needs_attention = FALSE; gb_terminal_set_needs_attention (self, FALSE, GTK_POS_BOTTOM); } g_object_notify (G_OBJECT (self), "title"); return GDK_EVENT_PROPAGATE; }
static void window_title_changed_cb (VteTerminal *terminal, GbTerminalView *self) { g_assert (VTE_IS_TERMINAL (terminal)); g_assert (GB_IS_TERMINAL_VIEW (self)); g_object_notify (G_OBJECT (self), "title"); }
static void notification_received_cb (VteTerminal *terminal, const gchar *summary, const gchar *body, IdeTerminalPage *self) { g_assert (VTE_IS_TERMINAL (terminal)); g_assert (IDE_IS_TERMINAL_PAGE (self)); if (!gtk_widget_has_focus (GTK_WIDGET (terminal))) gbp_terminal_page_set_needs_attention (self, TRUE); }
static void child_exited_cb (VteTerminal *terminal, gint exit_status, GbTerminalView *self) { g_assert (VTE_IS_TERMINAL (terminal)); g_assert (GB_IS_TERMINAL_VIEW (self)); if (!ide_widget_action (GTK_WIDGET (self), "view-stack", "close", NULL)) { if (!gtk_widget_in_destruction (GTK_WIDGET (terminal))) gb_terminal_respawn (self, terminal); } }
static gboolean focus_in_event_cb (VteTerminal *terminal, GdkEvent *event, IdeTerminalPage *self) { g_assert (VTE_IS_TERMINAL (terminal)); g_assert (IDE_IS_TERMINAL_PAGE (self)); self->needs_attention = FALSE; gbp_terminal_page_set_needs_attention (self, FALSE); gtk_revealer_set_reveal_child (self->search_revealer_top, FALSE); return GDK_EVENT_PROPAGATE; }
static gboolean read_and_feed(GIOChannel *source, GIOCondition condition, gpointer data) { char buf[2048]; gsize size; GIOStatus status; g_assert(VTE_IS_TERMINAL(data)); status = g_io_channel_read_chars(source, buf, sizeof(buf), &size, NULL); if ((status == G_IO_STATUS_NORMAL) && (size > 0)) { vte_terminal_feed(VTE_TERMINAL(data), buf, size); return TRUE; } return FALSE; }
static void window_title_changed_cb (VteTerminal *terminal, IdeTerminalPage *self) { const gchar *title; g_assert (VTE_IS_TERMINAL (terminal)); g_assert (IDE_IS_TERMINAL_PAGE (self)); title = vte_terminal_get_window_title (VTE_TERMINAL (self->terminal_top)); if (title == NULL || title[0] == '\0') title = _("Untitled terminal"); ide_page_set_title (IDE_PAGE (self), title); }
static void notification_received_cb (VteTerminal *terminal, const gchar *summary, const gchar *body, GbTerminalView *self) { g_assert (VTE_IS_TERMINAL (terminal)); g_assert (GB_IS_TERMINAL_VIEW (self)); if (!gtk_widget_has_focus (GTK_WIDGET (terminal))) { if (terminal == self->terminal_top) gb_terminal_set_needs_attention (self, TRUE, GTK_POS_TOP); else if (terminal == self->terminal_bottom) gb_terminal_set_needs_attention (self, TRUE, GTK_POS_BOTTOM); } }
static void set_vte(GtkWidget *widget) { if (VTE_IS_TERMINAL(widget)) { have_vte = TRUE; vte = VTE_TERMINAL(widget); } else if (GTK_IS_CONTAINER(widget)) { GList *children, *iter; children = gtk_container_get_children(GTK_CONTAINER(widget)); for (iter=children; !have_vte && iter; iter=g_list_next(iter)) set_vte(iter->data); g_list_free(children); } }
/* locate vte anywhere at or below widget */ static gboolean holds_vte(GtkWidget *widget) { gboolean found = FALSE; if (VTE_IS_TERMINAL(widget)) found = TRUE; else if (GTK_IS_CONTAINER(widget)) { GList *children, *iter; children = gtk_container_get_children(GTK_CONTAINER(widget)); for (iter=children; !found && iter; iter=g_list_next(iter)) found = holds_vte(iter->data); g_list_free(children); } return found; }
static gboolean focus_in_event_cb (VteTerminal *terminal, GdkEvent *event, GbTerminalView *self) { g_assert (VTE_IS_TERMINAL (terminal)); g_assert (GB_IS_TERMINAL_VIEW (self)); self->bottom_has_focus = (terminal != self->terminal_top); if (terminal == self->terminal_top) { self->top_has_needs_attention = FALSE; gb_terminal_set_needs_attention (self, FALSE, GTK_POS_TOP); } else if (terminal == self->terminal_bottom) { self->bottom_has_needs_attention = FALSE; gb_terminal_set_needs_attention (self, FALSE, GTK_POS_BOTTOM); } return GDK_EVENT_PROPAGATE; }
static void gb_terminal_view_wait_cb (GObject *object, GAsyncResult *result, gpointer user_data) { IdeSubprocess *subprocess = (IdeSubprocess *)object; VteTerminal *terminal = user_data; GbTerminalView *self; g_autoptr(GError) error = NULL; IDE_ENTRY; g_assert (IDE_IS_SUBPROCESS (subprocess)); g_assert (G_IS_ASYNC_RESULT (result)); g_assert (VTE_IS_TERMINAL (terminal)); if (!ide_subprocess_wait_finish (subprocess, result, &error)) { g_warning ("%s", error->message); IDE_GOTO (failure); } self = (GbTerminalView *)gtk_widget_get_ancestor (GTK_WIDGET (terminal), GB_TYPE_TERMINAL_VIEW); if (self == NULL) IDE_GOTO (failure); if (!ide_widget_action (GTK_WIDGET (self), "view-stack", "close", NULL)) { if (!gtk_widget_in_destruction (GTK_WIDGET (terminal))) gb_terminal_respawn (self, terminal); } failure: g_clear_object (&terminal); IDE_EXIT; }