summaryrefslogtreecommitdiff
path: root/src/terminal-screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/terminal-screen.c')
-rw-r--r--src/terminal-screen.c105
1 files changed, 101 insertions, 4 deletions
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index b3318bc..d110386 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -119,7 +119,11 @@ static gboolean terminal_screen_popup_menu (GtkWidget *widget);
static gboolean terminal_screen_button_press (GtkWidget *widget,
GdkEventButton *event);
static void terminal_screen_launch_child_on_idle (TerminalScreen *screen);
-static void terminal_screen_child_exited (VteTerminal *terminal);
+#if VTE_CHECK_VERSION (0, 38, 0)
+static void terminal_screen_child_exited (VteTerminal *terminal, int status);
+#else
+static void terminal_screen_child_exited (VteTerminal *terminal);
+#endif
static void terminal_screen_window_title_changed (VteTerminal *vte_terminal,
TerminalScreen *screen);
@@ -134,8 +138,12 @@ static void terminal_screen_cook_title (TerminalScreen *screen);
static void terminal_screen_cook_icon_title (TerminalScreen *screen);
static char* terminal_screen_check_match (TerminalScreen *screen,
+#if VTE_CHECK_VERSION (0, 38, 0)
+ GdkEvent *event,
+#else
int column,
int row,
+#endif
int *flavor);
static guint signals[LAST_SIGNAL] = { 0 };
@@ -284,6 +292,7 @@ terminal_screen_get_window (TerminalScreen *screen)
return TERMINAL_WINDOW (toplevel);
}
+#if !VTE_CHECK_VERSION (0, 38, 0)
static gboolean
window_uses_argb_visual (TerminalScreen *screen)
{
@@ -295,21 +304,26 @@ window_uses_argb_visual (TerminalScreen *screen)
return terminal_window_uses_argb_visual (window);
}
+#endif
static void
terminal_screen_realize (GtkWidget *widget)
{
+#if !VTE_CHECK_VERSION (0, 38, 0)
TerminalScreen *screen = TERMINAL_SCREEN (widget);
TerminalScreenPrivate *priv = screen->priv;
TerminalBackgroundType bg_type;
+#endif
GTK_WIDGET_CLASS (terminal_screen_parent_class)->realize (widget);
+#if !VTE_CHECK_VERSION (0, 38, 0)
/* FIXME: Don't enable this if we have a compmgr. */
bg_type = terminal_profile_get_property_enum (priv->profile, TERMINAL_PROFILE_BACKGROUND_TYPE);
vte_terminal_set_background_transparent (VTE_TERMINAL (screen),
bg_type == TERMINAL_BACKGROUND_TRANSPARENT &&
!window_uses_argb_visual (screen));
+#endif
}
static void
@@ -917,7 +931,9 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
GObject *object = G_OBJECT (screen);
VteTerminal *vte_terminal = VTE_TERMINAL (screen);
const char *prop_name;
+#if !VTE_CHECK_VERSION (0, 38, 0)
TerminalBackgroundType bg_type;
+#endif
TerminalWindow *window;
if (pspec)
@@ -961,6 +977,10 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
prop_name == I_(TERMINAL_PROFILE_USE_THEME_COLORS) ||
prop_name == I_(TERMINAL_PROFILE_FOREGROUND_COLOR) ||
prop_name == I_(TERMINAL_PROFILE_BACKGROUND_COLOR) ||
+#if VTE_CHECK_VERSION (0, 38, 0)
+ prop_name == I_(TERMINAL_PROFILE_BACKGROUND_TYPE) ||
+ prop_name == I_(TERMINAL_PROFILE_BACKGROUND_DARKNESS) ||
+#endif
prop_name == I_(TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG) ||
prop_name == I_(TERMINAL_PROFILE_BOLD_COLOR) ||
prop_name == I_(TERMINAL_PROFILE_PALETTE))
@@ -970,8 +990,15 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
vte_terminal_set_audible_bell (vte_terminal, !terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_SILENT_BELL));
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_WORD_CHARS))
+#if VTE_CHECK_VERSION (0, 40, 0)
+ vte_terminal_set_word_char_exceptions (vte_terminal,
+ terminal_profile_get_property_string (profile, TERMINAL_PROFILE_WORD_CHARS));
+#elif !VTE_CHECK_VERSION (0, 38, 0)
vte_terminal_set_word_chars (vte_terminal,
terminal_profile_get_property_string (profile, TERMINAL_PROFILE_WORD_CHARS));
+#else
+ {}
+#endif
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE))
vte_terminal_set_scroll_on_keystroke (vte_terminal,
terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE));
@@ -1013,6 +1040,9 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
}
#endif /* ENABLE_SKEY */
+/* Background image support was removed in vte 0.38.
+ * Transparency for 0.38+ is handled above next to TERMINAL_PROFILE_BACKGROUND_COLOR. */
+#if !VTE_CHECK_VERSION (0, 38, 0)
if (!prop_name ||
prop_name == I_(TERMINAL_PROFILE_BACKGROUND_TYPE) ||
prop_name == I_(TERMINAL_PROFILE_BACKGROUND_IMAGE) ||
@@ -1053,6 +1083,7 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
bg_type == TERMINAL_BACKGROUND_TRANSPARENT &&
!window_uses_argb_visual (screen));
}
+#endif
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_BACKSPACE_BINDING))
vte_terminal_set_backspace_binding (vte_terminal,
@@ -1077,6 +1108,23 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
g_object_thaw_notify (object);
}
+/* TODO: Once Gtk2 support is dropped, mate-terminal should be converted to use GdkRGBA everywhere instead of GdkColor. */
+#if VTE_CHECK_VERSION (0, 38, 0)
+static GdkRGBA *
+gdk_color_to_rgba (const GdkColor *color,
+ double alpha,
+ GdkRGBA *rgba)
+{
+ if (color == NULL)
+ return NULL;
+ rgba->red = color->red / 65535.0;
+ rgba->green = color->green / 65535.0;
+ rgba->blue = color->blue / 65535.0;
+ rgba->alpha = alpha;
+ return rgba;
+}
+#endif
+
static void
update_color_scheme (TerminalScreen *screen)
{
@@ -1112,11 +1160,33 @@ update_color_scheme (TerminalScreen *screen)
n_colors = G_N_ELEMENTS (colors);
terminal_profile_get_palette (priv->profile, colors, &n_colors);
+#if VTE_CHECK_VERSION (0, 38, 0)
+ {
+ GdkRGBA colors_rgba[TERMINAL_PALETTE_SIZE];
+ GdkRGBA fg_rgba, bg_rgba, bold_rgba;
+ double alpha = 1.0;
+ int i;
+
+ for (i = 0; i < n_colors; i++)
+ gdk_color_to_rgba (&colors[i], 1.0, &colors_rgba[i]);
+
+ if (terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_BACKGROUND_TYPE) == TERMINAL_BACKGROUND_TRANSPARENT)
+ alpha = terminal_profile_get_property_double (profile, TERMINAL_PROFILE_BACKGROUND_DARKNESS);
+ vte_terminal_set_colors (VTE_TERMINAL (screen),
+ gdk_color_to_rgba (&fg, 1.0, &fg_rgba),
+ gdk_color_to_rgba (&bg, alpha, &bg_rgba),
+ colors_rgba, n_colors);
+ if (bold_color)
+ vte_terminal_set_color_bold (VTE_TERMINAL (screen),
+ gdk_color_to_rgba (bold_color, 1.0, &bold_rgba));
+ }
+#else
vte_terminal_set_colors (VTE_TERMINAL (screen), &fg, &bg,
colors, n_colors);
if (bold_color)
vte_terminal_set_color_bold (VTE_TERMINAL (screen), bold_color);
vte_terminal_set_background_tint_color (VTE_TERMINAL (screen), &bg);
+#endif
}
void
@@ -1502,7 +1572,12 @@ terminal_screen_launch_child_cb (TerminalScreen *screen)
pty_flags |= VTE_PTY_NO_UTMP | VTE_PTY_NO_WTMP;
if (!get_child_command (screen, shell, &spawn_flags, &argv, &err) ||
- !vte_terminal_fork_command_full (terminal,
+#if VTE_CHECK_VERSION (0, 38, 0)
+ !vte_terminal_spawn_sync (
+#else
+ !vte_terminal_fork_command_full (
+#endif
+ terminal,
pty_flags,
working_dir,
argv,
@@ -1510,6 +1585,9 @@ terminal_screen_launch_child_cb (TerminalScreen *screen)
spawn_flags,
NULL, NULL,
&pid,
+#if VTE_CHECK_VERSION (0, 38, 0)
+ NULL,
+#endif
&err))
{
GtkWidget *info_bar;
@@ -1620,14 +1698,19 @@ terminal_screen_button_press (GtkWidget *widget,
TerminalScreen *screen = TERMINAL_SCREEN (widget);
gboolean (* button_press_event) (GtkWidget*, GdkEventButton*) =
GTK_WIDGET_CLASS (terminal_screen_parent_class)->button_press_event;
- int char_width, char_height, row, col;
char *matched_string;
int matched_flavor = 0;
guint state;
+#if !VTE_CHECK_VERSION (0, 38, 0)
+ int char_width, char_height, row, col;
GtkBorder *inner_border = NULL;
+#endif
state = event->state & gtk_accelerator_get_default_mod_mask ();
+#if VTE_CHECK_VERSION (0, 38, 0)
+ matched_string = terminal_screen_check_match (screen, event, &matched_flavor);
+#else
terminal_screen_get_cell_size (screen, &char_width, &char_height);
gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
@@ -1635,8 +1718,8 @@ terminal_screen_button_press (GtkWidget *widget,
col = (event->y - (inner_border ? inner_border->top : 0)) / char_height;
gtk_border_free (inner_border);
- /* FIXMEchpe: add vte API to do this check by widget coords instead of grid coords */
matched_string = terminal_screen_check_match (screen, row, col, &matched_flavor);
+#endif
if (matched_string != NULL &&
(event->button == 1 || event->button == 2) &&
@@ -1872,7 +1955,11 @@ terminal_screen_icon_title_changed (VteTerminal *vte_terminal,
}
static void
+#if VTE_CHECK_VERSION (0, 38, 0)
+terminal_screen_child_exited (VteTerminal *terminal, int status)
+#else
terminal_screen_child_exited (VteTerminal *terminal)
+#endif
{
TerminalScreen *screen = TERMINAL_SCREEN (terminal);
TerminalScreenPrivate *priv = screen->priv;
@@ -1900,9 +1987,11 @@ terminal_screen_child_exited (VteTerminal *terminal)
case TERMINAL_EXIT_HOLD:
{
GtkWidget *info_bar;
+#if !VTE_CHECK_VERSION (0, 38, 0)
int status;
status = vte_terminal_get_child_exit_status (terminal);
+#endif
info_bar = terminal_info_bar_new (GTK_MESSAGE_INFO,
_("_Relaunch"), RESPONSE_RELAUNCH,
@@ -2269,8 +2358,12 @@ terminal_screen_skey_match_remove (TerminalScreen *screen)
static char*
terminal_screen_check_match (TerminalScreen *screen,
+#if VTE_CHECK_VERSION (0, 38, 0)
+ GdkEvent *event,
+#else
int column,
int row,
+#endif
int *flavor)
{
TerminalScreenPrivate *priv = screen->priv;
@@ -2278,7 +2371,11 @@ terminal_screen_check_match (TerminalScreen *screen,
int tag;
char *match;
+#if VTE_CHECK_VERSION (0, 38, 0)
+ match = vte_terminal_match_check_event (VTE_TERMINAL (screen), event, &tag);
+#else
match = vte_terminal_match_check (VTE_TERMINAL (screen), column, row, &tag);
+#endif
for (tags = priv->match_tags; tags != NULL; tags = tags->next)
{
TagData *tag_data = (TagData*) tags->data;