예제 #1
0
파일: property.c 프로젝트: blueyed/LilyTerm
gboolean set_background_saturation(GtkRange *range, GtkScrollType scroll, gdouble value, GtkWidget *vte)
{
#ifdef DETAIL
	g_debug("! Launch set_background_saturation() with value = %f, vte = %p", value, vte);
#endif
#ifdef SAFEMODE
	if (vte==NULL) return FALSE;
#endif
	struct Page *page_data = (struct Page *)g_object_get_data(G_OBJECT(vte), "Page_Data");
#ifdef SAFEMODE
	if (page_data==NULL || (page_data->window==NULL)) return FALSE;
#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 FALSE;
#endif
	// g_debug("Get win_data = %d when set background saturation!", win_data);

	value = CLAMP(value, 0, 1);

#ifdef ENABLE_RGBA
	if (win_data->use_rgba == -1)
	{
		if (win_data->transparent_background)
			vte_terminal_set_opacity(VTE_TERMINAL(vte), (1-value) * 65535);
		else
			vte_terminal_set_opacity(VTE_TERMINAL(vte), 65535);
	}
	else
#endif
		vte_terminal_set_background_transparent(VTE_TERMINAL(vte), win_data->transparent_background);

	// g_debug("set_background_saturation(): win_data->transparent_background = %d, value = %1.3f",
	//	win_data->transparent_background, value);
	// g_debug("set_background_saturation(): win_data->background_image = %s", win_data->background_image);
	if (win_data->transparent_background)
	{
		vte_terminal_set_background_image_file (VTE_TERMINAL(vte), NULL_DEVICE);
		vte_terminal_set_background_saturation( VTE_TERMINAL(vte), value);
	}
	else
	{
		if (compare_strings(win_data->background_image, NULL_DEVICE, TRUE))
		{
			vte_terminal_set_background_saturation( VTE_TERMINAL(vte), value);
			vte_terminal_set_background_image_file (VTE_TERMINAL(vte), win_data->background_image);
			vte_terminal_set_scroll_background(VTE_TERMINAL(vte), win_data->scroll_background);
		}
		else
			vte_terminal_set_background_saturation( VTE_TERMINAL(vte), 0);
	}

	dirty_vte_terminal_set_background_tint_color(VTE_TERMINAL(page_data->vte), win_data->color[0]);
	return FALSE;
}
예제 #2
0
void termit_tab_set_transparency(struct TermitTab* pTab, gdouble transparency)
{
    pTab->style.transparency = transparency;
    if (transparency) {
        if (pTab->style.image_file == NULL) {
            vte_terminal_set_background_transparent(VTE_TERMINAL(pTab->vte), TRUE);
        } else {
            vte_terminal_set_background_transparent(VTE_TERMINAL(pTab->vte), FALSE);
        }
        vte_terminal_set_background_saturation(VTE_TERMINAL(pTab->vte), pTab->style.transparency);
    } else {
        vte_terminal_set_background_saturation(VTE_TERMINAL(pTab->vte), pTab->style.transparency);
        vte_terminal_set_background_transparent(VTE_TERMINAL(pTab->vte), FALSE);
    }
}
예제 #3
0
static VALUE
rg_set_background_saturation(VALUE self, VALUE saturation)
{
    vte_terminal_set_background_saturation(_SELF(self),
                                           NUM2DBL(saturation));
    return self;
}
예제 #4
0
static VALUE
term_set_background_saturation(VALUE self, VALUE saturation)
{
    vte_terminal_set_background_saturation(RVAL2TERM(self),
                                           NUM2DBL(saturation));
    return Qnil;
}
예제 #5
0
void mainwindow_create_tab(void) {
    GtkWidget* tmp_term = build_term();
    GtkVScrollbar *sbar= NULL;
    GtkHBox *tmp_box = GTK_HBOX(gtk_hbox_new(FALSE, 0));

    if (conf_get_scrollbar() == -1)
        gtk_box_pack_start(GTK_BOX(tmp_box), tmp_term, TRUE, TRUE, 0);
    else if (conf_get_scrollbar() == POS_LEFT) {
        sbar = GTK_VSCROLLBAR(gtk_vscrollbar_new(vte_terminal_get_adjustment(
        VTE_TERMINAL(tmp_term))));
        gtk_box_pack_start(GTK_BOX(tmp_box), GTK_WIDGET(sbar), FALSE, FALSE, 0);
        gtk_box_pack_end(GTK_BOX(tmp_box), GTK_WIDGET(tmp_term), TRUE, TRUE, 0);
    } else // (conf_get_scrollbar() == POS_RIGHT)
    {
        sbar = GTK_VSCROLLBAR(gtk_vscrollbar_new(vte_terminal_get_adjustment(
        VTE_TERMINAL(tmp_term))));
        gtk_box_pack_start(GTK_BOX(tmp_box), GTK_WIDGET(tmp_term), TRUE, TRUE, 0);
        gtk_box_pack_end(GTK_BOX(tmp_box), GTK_WIDGET(sbar), FALSE, FALSE, 0);
    }

    char buffer [100];
    sprintf(buffer, "%s %d", conf_get_term_name(), activetab + 1);
    GtkLabel* tmp_label = GTK_LABEL(gtk_label_new(buffer));

    if (conf_get_opacity() < 100) {
        if (screen_is_composited) {
            vte_terminal_set_background_transparent(VTE_TERMINAL(tmp_term), FALSE);
            vte_terminal_set_opacity(VTE_TERMINAL(tmp_term),
            conf_get_opacity()/100 * 0xffff);
        } else {
            vte_terminal_set_background_saturation(VTE_TERMINAL(tmp_term),
                1.0 - conf_get_opacity()/100);
            if (conf_get_bg_image() == NULL)
                vte_terminal_set_background_transparent(VTE_TERMINAL(tmp_term), TRUE);
        }
    }

    if (conf_get_opacity() < 100 && screen_is_composited) {
        vte_terminal_set_background_transparent(VTE_TERMINAL(tmp_term), FALSE);
        vte_terminal_set_opacity(VTE_TERMINAL(tmp_term),
        conf_get_opacity()/100 * 0xffff);
    }
    g_signal_connect(G_OBJECT(tmp_term), "window-title-changed",
            G_CALLBACK(mainwindow_window_title_changed), tmp_label);

    g_array_append_val(tabs, tmp_term);
    tabcount++;

    gtk_widget_show_all(GTK_WIDGET(tmp_box));
    gtk_notebook_append_page(tabbar, GTK_WIDGET(tmp_box), GTK_WIDGET(tmp_label));

    if (conf_get_tab_fill())
        gtk_container_child_set(GTK_CONTAINER(tabbar), GTK_WIDGET(tmp_box),
                "tab-expand", TRUE, "tab-fill", TRUE, NULL);

    if (conf_get_show_tab() == TABS_ONE&& tabcount > 1)
        gtk_notebook_set_show_tabs(tabbar, TRUE);

    activetab = tabcount - 1;
    gtk_notebook_set_current_page(tabbar, activetab);
}
예제 #6
0
/**
 * tilda_term_config_defaults ()
 *
 * Read and set all of the defaults for this terminal from the current configuration.
 *
 * Success: return 0
 * Failure: return non-zero
 */
static gint tilda_term_config_defaults (tilda_term *tt)
{
    DEBUG_FUNCTION ("tilda_term_config_defaults");
    DEBUG_ASSERT (tt != NULL);

    gdouble transparency_level = 0.0;
    GdkRGBA fg, bg, cc;
    gchar* word_chars;
    gint i;
    gint cursor_shape;

    /** Colors & Palette **/
    bg.red   =    GUINT16_TO_FLOAT(config_getint ("back_red"));
    bg.green =    GUINT16_TO_FLOAT(config_getint ("back_green"));
    bg.blue  =    GUINT16_TO_FLOAT(config_getint ("back_blue"));
    bg.alpha =    1.0;

    fg.red   =    GUINT16_TO_FLOAT(config_getint ("text_red"));
    fg.green =    GUINT16_TO_FLOAT(config_getint ("text_green"));
    fg.blue  =    GUINT16_TO_FLOAT(config_getint ("text_blue"));
    fg.alpha =    1.0;

    cc.red   =    GUINT16_TO_FLOAT(config_getint ("cursor_red"));
    cc.green =    GUINT16_TO_FLOAT(config_getint ("cursor_green"));
    cc.blue  =    GUINT16_TO_FLOAT(config_getint ("cursor_blue"));
    cc.alpha = 1.0;

    for(i = 0;i < TERMINAL_PALETTE_SIZE; i++) {
        current_palette[i].red   = GUINT16_TO_FLOAT(config_getnint ("palette", i*3));
        current_palette[i].green = GUINT16_TO_FLOAT(config_getnint ("palette", i*3+1));
        current_palette[i].blue  = GUINT16_TO_FLOAT(config_getnint ("palette", i*3+2));
        current_palette[i].alpha = 1.0;
    }

    vte_terminal_set_colors_rgba (VTE_TERMINAL(tt->vte_term), &fg, &bg, current_palette, TERMINAL_PALETTE_SIZE);

    /** Bells **/
    vte_terminal_set_audible_bell (VTE_TERMINAL(tt->vte_term), config_getbool ("bell"));
    vte_terminal_set_visible_bell (VTE_TERMINAL(tt->vte_term), config_getbool ("bell"));

    /** Cursor **/
    vte_terminal_set_cursor_blink_mode (VTE_TERMINAL(tt->vte_term),
            (config_getbool ("blinks"))?VTE_CURSOR_BLINK_ON:VTE_CURSOR_BLINK_OFF);
    vte_terminal_set_color_cursor_rgba (VTE_TERMINAL(tt->vte_term), &cc);

    cursor_shape = config_getint("cursor_shape");
    if (cursor_shape < 0 || cursor_shape > 2) {
        config_setint("cursor_shape", 0);
        cursor_shape = 0;
    }
    vte_terminal_set_cursor_shape(VTE_TERMINAL(tt->vte_term), (VteTerminalCursorShape)cursor_shape);

    /** Scrolling **/
    vte_terminal_set_scroll_background (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_background"));
    vte_terminal_set_scroll_on_output (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_on_output"));
    vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_on_key"));

    /** Mouse **/
    vte_terminal_set_mouse_autohide (VTE_TERMINAL(tt->vte_term), FALSE); /* TODO: make this configurable */

    /** Text Properties **/
    vte_terminal_set_allow_bold (VTE_TERMINAL(tt->vte_term), config_getbool ("bold"));
    gtk_widget_set_double_buffered (tt->vte_term, config_getbool("double_buffer"));
    PangoFontDescription *description =
        pango_font_description_from_string (config_getstr ("font"));
    vte_terminal_set_font (VTE_TERMINAL (tt->vte_term), description);

    /** Scrollback **/
    vte_terminal_set_scrollback_lines (VTE_TERMINAL(tt->vte_term), config_getbool("scroll_history_infinite") ? -1 : config_getint ("lines"));

    /** Keys **/
    switch (config_getint ("backspace_key"))
    {
        case ASCII_DELETE:
            vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_DELETE);
            break;
        case DELETE_SEQUENCE:
            vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_DELETE_SEQUENCE);
            break;
        case ASCII_BACKSPACE:
            vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_BACKSPACE);
            break;
        case AUTO:
        default:
            vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_AUTO);
            break;
    }

    switch (config_getint ("delete_key"))
    {
        case ASCII_DELETE:
            vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_DELETE);
            break;
        case DELETE_SEQUENCE:
            vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_DELETE_SEQUENCE);
            break;
        case ASCII_BACKSPACE:
            vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_BACKSPACE);
            break;
        case AUTO:
        default:
            vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_AUTO);
            break;
    }

    /** Word chars **/
    word_chars =  config_getstr ("word_chars");
    if (NULL == word_chars || '\0' == *word_chars) {
        word_chars = DEFAULT_WORD_CHARS;
    }
    vte_terminal_set_word_chars (VTE_TERMINAL(tt->vte_term), word_chars);

    /** Background **/
    if (config_getbool ("use_image"))
        vte_terminal_set_background_image_file (VTE_TERMINAL(tt->vte_term), config_getstr ("image"));
    else
        vte_terminal_set_background_image_file (VTE_TERMINAL(tt->vte_term), NULL);

    transparency_level = ((gdouble) config_getint ("transparency"))/100;

    if (config_getbool ("enable_transparency") && transparency_level > 0)
    {
        vte_terminal_set_background_saturation (VTE_TERMINAL (tt->vte_term), transparency_level);
        vte_terminal_set_opacity (VTE_TERMINAL (tt->vte_term), (1.0 - transparency_level) * 0xffff);
        vte_terminal_set_background_transparent (VTE_TERMINAL(tt->vte_term), !tt->tw->have_argb_visual);
    }

    return 0;
}
예제 #7
0
파일: svte.c 프로젝트: skawouter/svte-tmp
/* create a new tab */
static void tab_new(struct window *w) {
  term *t;
  int tmp;


  char **args = 0;
  const gchar *shell = g_getenv("SHELL");
  if (!shell) {
    shell = "sh";
  }
  g_shell_parse_argv(shell, 0, &args, 0);

  t = g_new0(term, 1);
  t->label = gtk_label_new("");
  t->w = w;
  t->vte = vte_terminal_new();
  int index = gtk_notebook_append_page(GTK_NOTEBOOK(w->notebook), t->vte,
      t->label);
  gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(w->notebook), t->vte, TRUE);

  if (index == 0) {
    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(w->notebook), FALSE);
    vte_terminal_fork_command_full(VTE_TERMINAL(t->vte), 
        VTE_PTY_DEFAULT, NULL, 
        args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, t->pid, NULL);
    tab_geometry_hints(t);
  } else {
    struct term *previous = get_nth_term(w, gtk_notebook_get_current_page(GTK_NOTEBOOK(w->notebook)));

    vte_terminal_fork_command_full(VTE_TERMINAL(t->vte), 
        VTE_PTY_DEFAULT, tab_get_cwd(previous), 
        args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, t->pid, NULL);
    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(w->notebook), TRUE);
  }

  g_object_set_qdata_full(G_OBJECT(gtk_notebook_get_nth_page(
          (GtkNotebook*)w->notebook, index)), term_data_id, t, NULL);

  g_signal_connect(G_OBJECT(t->vte), "child-exited", G_CALLBACK(tab_close), w);
  g_signal_connect(G_OBJECT(t->vte), "window-title-changed", G_CALLBACK(tab_title), t);
  g_signal_connect(G_OBJECT(t->vte), "button-press-event", G_CALLBACK(event_button), NULL);

  vte_terminal_set_allow_bold(VTE_TERMINAL(t->vte), config->allow_bold);
  vte_terminal_set_audible_bell(VTE_TERMINAL(t->vte), config->audible_bell);
  vte_terminal_set_background_transparent(VTE_TERMINAL(t->vte),
      config->bg_transparent);
  vte_terminal_set_background_saturation(VTE_TERMINAL(t->vte), config->bg_saturation);
  vte_terminal_set_background_image_file(VTE_TERMINAL(t->vte), config->bg_image);
  vte_terminal_set_font_from_string(VTE_TERMINAL(t->vte), config->font);
  vte_terminal_set_mouse_autohide(VTE_TERMINAL(t->vte),
      config->autohide_mouse);
  vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(t->vte),
      config->scroll_on_keystroke);
  vte_terminal_set_scroll_on_output(VTE_TERMINAL(t->vte),
      config->scroll_on_output);
  vte_terminal_set_scrollback_lines(VTE_TERMINAL(t->vte),
      config->num_scrollback_lines);
  vte_terminal_set_visible_bell(VTE_TERMINAL(t->vte), config->visible_bell);
  vte_terminal_set_word_chars(VTE_TERMINAL(t->vte), config->word_chars);
  vte_terminal_set_colors(VTE_TERMINAL(t->vte), &config->foreground,
      &config->background, config->colour_palette, DEFAULT_PALETTE_SIZE);

  tmp = vte_terminal_match_add_gregex(
      VTE_TERMINAL(t->vte),
      g_regex_new(config->url_regex, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY,
        NULL), 
      0);

  vte_terminal_match_set_cursor_type(VTE_TERMINAL(t->vte), tmp,
      GDK_HAND2);
  gtk_widget_show_all(w->notebook);
  gtk_notebook_set_current_page(GTK_NOTEBOOK(w->notebook), index);
  gtk_widget_grab_focus(t->vte);
}