Beispiel #1
0
console_t *uimon_window_open(void)
{
    GtkWidget *scrollbar, *horizontal_container;

    if (fixed.window == NULL) {
        fixed.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(fixed.window), "VICE monitor");
        gtk_window_set_position(GTK_WINDOW(fixed.window), GTK_WIN_POS_CENTER);
        gtk_widget_set_app_paintable(fixed.window, TRUE);
        gtk_window_set_deletable(GTK_WINDOW(fixed.window), TRUE);
        fixed.term = vte_terminal_new();
        vte_terminal_set_scrollback_lines (VTE_TERMINAL(fixed.term), 1000);
        vte_terminal_set_scroll_on_output (VTE_TERMINAL(fixed.term), TRUE);
        scrollbar = gtk_vscrollbar_new(vte_terminal_get_adjustment (VTE_TERMINAL(fixed.term)));
        horizontal_container = gtk_hbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(fixed.window), horizontal_container);
        gtk_container_add(GTK_CONTAINER(horizontal_container), fixed.term);
        gtk_container_add(GTK_CONTAINER(horizontal_container), scrollbar);

        g_signal_connect(G_OBJECT(fixed.window), "delete-event",
            G_CALLBACK(close_window), &fixed.input_buffer);

        g_signal_connect(G_OBJECT(fixed.term), "key-press-event", 
            G_CALLBACK(key_press_event), &fixed.input_buffer);

        g_signal_connect(G_OBJECT(fixed.term), "button-press-event", 
            G_CALLBACK(button_press_event), &fixed.input_buffer);

        vte_console.console_xres = vte_terminal_get_column_count(VTE_TERMINAL(fixed.term));
        vte_console.console_yres = vte_terminal_get_row_count(VTE_TERMINAL(fixed.term));
        vte_console.console_can_stay_open = 1;
    }
    return uimon_window_resume();
}
Beispiel #2
0
int getColumns(struct console_private_s *t)
{
    if(t->term) {
        return vte_terminal_get_column_count(VTE_TERMINAL(t->term));
    }
    return 80;
}
Beispiel #3
0
static void
resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
{
	VteTerminal *terminal;

	if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) {
                gint owidth, oheight, char_width, char_height, column_count, row_count;
                GtkBorder *inner_border;

		terminal = VTE_TERMINAL(widget);

		gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);

		/* Take into account border overhead. */
                char_width = vte_terminal_get_char_width (terminal);
                char_height = vte_terminal_get_char_height (terminal);
                column_count = vte_terminal_get_column_count (terminal);
                row_count = vte_terminal_get_row_count (terminal);
                gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);

                owidth -= char_width * column_count;
                oheight -= char_height * row_count;
                if (inner_border != NULL) {
                        owidth -= inner_border->left + inner_border->right;
                        oheight -= inner_border->top + inner_border->bottom;
                }
		gtk_window_resize(GTK_WINDOW(data),
				  width + owidth, height + oheight);
                gtk_border_free (inner_border);
	}
}
Beispiel #4
0
static void get_terminal_size_in_chars(VteTerminal *terminal,
                           glong *width,
                           glong *height)
{
    *width = vte_terminal_get_column_count(terminal);
    *height = vte_terminal_get_row_count(terminal);
}
Beispiel #5
0
void
term_set_font(GtkWidget *win, VteTerminal *term, size_t index)
{
    PangoFontDescription *font_desc = NULL;
    glong width, height;

    if (index >= sizeof fonts / sizeof fonts[0])
    {
        fprintf(stderr, __NAME__": Warning: Invalid font index\n");
        return;
    }

    width = vte_terminal_get_column_count(term);
    height = vte_terminal_get_row_count(term);

    font_desc = pango_font_description_from_string(fonts[index]);
    vte_terminal_set_font(term, font_desc);
    pango_font_description_free(font_desc);
    vte_terminal_set_font_scale(term, 1);

    term_set_size(win, term, width, height);

    if (win != NULL)
        vte_terminal_set_geometry_hints_for_window(VTE_TERMINAL(term),
                                                   GTK_WINDOW(win));
}
Beispiel #6
0
static void
adjust_font_size(GtkWidget *widget, gpointer data, gdouble factor)
{
	VteTerminal *terminal;
        gdouble scale;
        glong char_width, char_height;
	gint columns, rows, owidth, oheight;

	/* Read the screen dimensions in cells. */
	terminal = VTE_TERMINAL(widget);
	columns = vte_terminal_get_column_count(terminal);
	rows = vte_terminal_get_row_count(terminal);

	/* Take into account padding and border overhead. */
	gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);
        char_width = vte_terminal_get_char_width (terminal);
        char_height = vte_terminal_get_char_height (terminal);
	owidth -= char_width * columns;
	oheight -= char_height * rows;

	scale = vte_terminal_get_font_scale(terminal);
        vte_terminal_set_font_scale(terminal, scale * factor);

        /* This above call will have changed the char size! */
        char_width = vte_terminal_get_char_width (terminal);
        char_height = vte_terminal_get_char_height (terminal);

	gtk_window_resize(GTK_WINDOW(data),
			  columns * char_width + owidth,
			  rows * char_height + oheight);
}
Beispiel #7
0
static void
resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
{
	VteTerminal *terminal;

	if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) {
		gint owidth, oheight, char_width, char_height, column_count, row_count;
		GtkBorder padding;

		terminal = VTE_TERMINAL(widget);

		gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);

		/* Take into account border overhead. */
		char_width = vte_terminal_get_char_width (terminal);
		char_height = vte_terminal_get_char_height (terminal);
		column_count = vte_terminal_get_column_count (terminal);
		row_count = vte_terminal_get_row_count (terminal);
                gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
                                              gtk_widget_get_state_flags(widget),
                                              &padding);

                owidth -= char_width * column_count + padding.left + padding.right;
                oheight -= char_height * row_count + padding.top + padding.bottom;
		gtk_window_resize(GTK_WINDOW(data),
				  width + owidth, height + oheight);
	}
}
Beispiel #8
0
static void
mud_subwindow_set_size_force_grid (MudSubwindow *window,
                                   VteTerminal *screen,
                                   gboolean        even_if_mapped,
                                   int             force_grid_width,
                                   int             force_grid_height)
{
    /* TODO: Missing get_padding in new VTE; maybe we can just use vte_terminal_set_size? */
#if 0
#warning Reimplement mud_subwindow size forcing
    /* Owen's hack from gnome-terminal */
    GtkWidget *widget;
    GtkWidget *app;
    GtkRequisition toplevel_request;
    GtkRequisition widget_request;
    int w, h;
    int char_width;
    int char_height;
    int grid_width;
    int grid_height;
    int xpad;
    int ypad;

    g_return_if_fail(MUD_IS_SUBWINDOW(window));

    /* be sure our geometry is up-to-date */
    mud_subwindow_update_geometry (window);
    widget = GTK_WIDGET (screen);

    app = window->priv->window;

    gtk_widget_size_request (app, &toplevel_request);
    gtk_widget_size_request (widget, &widget_request);

    w = toplevel_request.width - widget_request.width;
    h = toplevel_request.height - widget_request.height;

    char_width = vte_terminal_get_char_width (screen);
    char_height = vte_terminal_get_char_height (screen);

    grid_width = vte_terminal_get_column_count (screen);
    grid_height = vte_terminal_get_row_count (screen);

    if (force_grid_width >= 0)
        grid_width = force_grid_width;
    if (force_grid_height >= 0)
        grid_height = force_grid_height;

    vte_terminal_get_padding (VTE_TERMINAL (screen), &xpad, &ypad);

    w += xpad * 2 + char_width * grid_width;
    h += ypad * 2 + char_height * grid_height;

    if (even_if_mapped && gtk_widget_get_mapped (app)) {
        gtk_window_resize (GTK_WINDOW (app), w, h);
    }
}
Beispiel #9
0
PUSS_EXPORT void* puss_plugin_create(Puss* app) {
	PussVConsole* self;
	GtkWindow* window;
	GModule* module;

	bindtextdomain(TEXT_DOMAIN, app->get_locale_path());
	bind_textdomain_codeset(TEXT_DOMAIN, "UTF-8");

	window = puss_get_main_window(app);
	module = (GModule*)g_object_get_data(G_OBJECT(window), LIBVTE_KEEP_KEY);
	if( !module ) {
		module = g_module_open("libvte", G_MODULE_BIND_LAZY);
		if( !module ) {
			g_printerr("warning(puss_vconsole) : keep libvte failed! reload plugin will cause error!\n");
		} else {
			g_object_set_data_full(G_OBJECT(window), LIBVTE_KEEP_KEY, module, (GDestroyNotify)g_module_close);
		}
	}

	self = g_new0(PussVConsole, 1);
	self->app = app;
	self->vte = vte_terminal_new();

	{
		GtkWidget* hbox = gtk_hbox_new(FALSE, 4);
		GtkWidget* sbar = gtk_vscrollbar_new( vte_terminal_get_adjustment(VTE_TERMINAL(self->vte)) );

		gtk_box_pack_start(GTK_BOX(hbox), self->vte, TRUE, TRUE, 0);
		gtk_box_pack_start(GTK_BOX(hbox), sbar, FALSE, FALSE, 0);

		g_signal_connect(self->vte, "child-exited", G_CALLBACK(on_quit), self);

		vte_terminal_fork_command( VTE_TERMINAL(self->vte)
				, 0, 0
				, 0, 0
				, FALSE
				, FALSE
				, FALSE );

		vte_terminal_set_size(VTE_TERMINAL(self->vte), vte_terminal_get_column_count(VTE_TERMINAL(self->vte)), 5);
		vte_terminal_set_audible_bell(VTE_TERMINAL(self->vte), FALSE);
		gtk_widget_set_size_request(self->vte, 200, 50);
        gtk_widget_show_all(hbox);

		self->panel = hbox;
		app->panel_append(self->panel, gtk_label_new(_("Terminal")), "puss_vconsole_plugin_panel", PUSS_PANEL_POS_BOTTOM);
	}

	return self;
}
Beispiel #10
0
void
term_set_font_scale(GtkWidget *win, VteTerminal *term, gdouble mult)
{
    gdouble s;
    glong width, height;

    width = vte_terminal_get_column_count(term);
    height = vte_terminal_get_row_count(term);

    s = vte_terminal_get_font_scale(term);
    s *= mult;
    vte_terminal_set_font_scale(term, s);
    term_set_size(win, term, width, height);
    vte_terminal_set_geometry_hints_for_window(VTE_TERMINAL(term),
                                               GTK_WINDOW(win));
}
Beispiel #11
0
static void
mud_subwindow_size_allocate_cb(GtkWidget *widget,
                               GtkAllocation *allocation,
                               MudSubwindow *self)
{
    if(gtk_widget_get_mapped(self->priv->window))
    {
        if(self->priv->width != allocation->width ||
                self->priv->height != allocation->height)
        {
            self->priv->width = vte_terminal_get_column_count (VTE_TERMINAL (self->priv->terminal));
            self->priv->height = vte_terminal_get_row_count (VTE_TERMINAL(self->priv->terminal));

            g_signal_emit(self,
                    mud_subwindow_signal[RESIZED],
                    0,
                    self->priv->width,
                    self->priv->height);
        }
    }
}
Beispiel #12
0
static gboolean
idle_send_pty_size_request (gpointer user_data)
{
  HotSshTab *self = user_data;
  HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self);
  guint width = vte_terminal_get_column_count ((VteTerminal*)priv->terminal);
  guint height = vte_terminal_get_row_count ((VteTerminal*)priv->terminal);

  priv->queued_pty_size_id = 0;

  g_assert (priv->connection);

  if (gssh_connection_get_state (priv->connection) == GSSH_CONNECTION_STATE_CONNECTED)
    {
      priv->need_pty_size_request = FALSE;
      priv->sent_pty_size_request = TRUE;
      gssh_channel_request_pty_size_async (priv->channel, width, height,
                                           priv->cancellable, on_pty_size_complete, self);
    }

  return FALSE;
}
Beispiel #13
0
static void adjust_font_size (GtkWidget *widget, gpointer data, gint howmuch)
{
    DEBUG_FUNCTION ("adjust_font_size");
    DEBUG_ASSERT (widget != NULL);
    DEBUG_ASSERT (data != NULL);

    VteTerminal *terminal;
    PangoFontDescription *desired;
    gint newsize;
    gint columns, rows, owidth, oheight;

    /* Read the screen dimensions in cells. */
    terminal = VTE_TERMINAL(widget);
    columns = vte_terminal_get_column_count (terminal);
    rows = vte_terminal_get_row_count (terminal);

    /* Take into account padding and border overhead. */
    gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);
    owidth -= vte_terminal_get_char_width (terminal) * columns;
    oheight -= vte_terminal_get_char_height (terminal) * rows;

    /* Calculate the new font size. */
    desired = pango_font_description_copy (vte_terminal_get_font(terminal));
    newsize = pango_font_description_get_size (desired) / PANGO_SCALE;
    newsize += howmuch;
    pango_font_description_set_size (desired, CLAMP(newsize, 4, 144) * PANGO_SCALE);

    /* Change the font, then resize the window so that we have the same
     * number of rows and columns. */
    vte_terminal_set_font (terminal, desired);
    /*gtk_window_resize (GTK_WINDOW(data),
              columns * terminal->char_width + owidth,
              rows * terminal->char_height + oheight);*/

    pango_font_description_free (desired);
}
Beispiel #14
0
void reset_vte_size(GtkWidget *vte, gchar *new_font_name, Font_Reset_Type type)
{
#ifdef DETAIL
	g_debug("! Launch reset_vte_size() with vte = %p, new_font_name = %s, type = %d",
		vte, new_font_name, type);
#endif
#ifdef SAFEMODE
	if ((vte==NULL) || (new_font_name==NULL)) return;
#endif

	// type 0, RESET_CURRENT_TAB_FONT: change current page's font
	// type 1, RESET_ALL_TO_CURRENT_TAB: apply current column & row to every vte
	// type 2, RESET_ALL_TO_DEFAULT: apply default column & row to every vte
	// type 3, RESET_ALL_TO_SYSTEM: apply system column & row to every vte

	struct Page *page_data = (struct Page *)g_object_get_data(G_OBJECT(vte), "Page_Data");
#ifdef SAFEMODE
	if (page_data==NULL) return;
#endif
	struct Window *win_data = (struct Window *)g_object_get_data(G_OBJECT(page_data->window), "Win_Data");
#ifdef SAFEMODE
	if (win_data==NULL) return;
#endif
	// g_debug("Get win_data = %d when reset vte size!", win_data);

	switch (type)
	{
		case RESET_CURRENT_TAB_FONT:
			// We need to apply a new font to a single vte.
			// so that we should insure that this won't change the size of window.
			// g_debug("Trying to apply font %s to vte", current_font_name);
			vte_terminal_set_font_from_string_full( VTE_TERMINAL(vte),
								new_font_name,
								win_data->font_anti_alias);
			// g_debug("reset_vte_size(): call window_resizable() with run_once = %d", win_data->update_hints);
			// g_debug("reset_vte_size(): launch update_window_hint()!");
			update_window_hint(win_data, page_data);
			break;
		case RESET_ALL_TO_CURRENT_TAB:
			// increase/decrease window size & font size for every vte
			// g_debug("Trying to apply font %s to every vte", current_font_name);
			// struct Page *page_data = (struct Page *)g_object_get_data(G_OBJECT(current_vte), "Page_Data");
			apply_font_to_every_vte( page_data->window, new_font_name,
						 vte_terminal_get_column_count(VTE_TERMINAL(win_data->current_vte)),
						 vte_terminal_get_row_count(VTE_TERMINAL(win_data->current_vte)));
			break;
		case RESET_ALL_TO_DEFAULT:
			// reset window size & font size for every vte
			// g_debug("Trying to apply font %s to every vte", current_font_name);
			apply_font_to_every_vte(page_data->window, new_font_name,
						win_data->default_column, win_data->default_row);
			break;
		case RESET_ALL_TO_SYSTEM:
			// reset window size & font size for every vte
			// g_debug("Trying to apply font %s to every vte", current_font_name);
			apply_font_to_every_vte(page_data->window, new_font_name,
						SYSTEM_COLUMN, SYSTEM_ROW);
			break;
		default:
#ifdef FATAL
			print_switch_out_of_range_error_dialog("reset_vte_size", "type", type);
#endif
			break;
	}
}
Beispiel #15
0
static VALUE
rg_column_count(VALUE self)
{
    return LONG2NUM(vte_terminal_get_column_count(_SELF(self)));
}
Beispiel #16
0
static VALUE
term_get_column_count(VALUE self)
{
    return LONG2NUM(vte_terminal_get_column_count(RVAL2TERM(self)));
}