Created
August 3, 2022 22:41
-
-
Save adsr/fc801153bd25af024fc8ab876e24f1f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e3e2c987154055fceea4d459c34699a44d36cada Mon Sep 17 00:00:00 2001 | |
From: Adam Saponara <as@php.net> | |
Date: Wed, 3 Aug 2022 18:27:14 -0400 | |
Subject: [PATCH] Add sixel support | |
--- | |
terminal/terminal-preferences-dialog.c | 15 +++++++++++++++ | |
terminal/terminal-preferences.c | 11 +++++++++++ | |
terminal/terminal-screen.c | 16 +++++++++++++++- | |
3 files changed, 41 insertions(+), 1 deletion(-) | |
diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c | |
index 0687d9c1..f40b2bc8 100644 | |
--- a/terminal/terminal-preferences-dialog.c | |
+++ b/terminal/terminal-preferences-dialog.c | |
@@ -1161,6 +1161,21 @@ terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog) | |
gtk_grid_attach (GTK_GRID (grid), button, 0, row, 6, 1); | |
gtk_widget_show (button); | |
+#if VTE_CHECK_VERSION(0, 69, 90) | |
+ if (vte_get_feature_flags () & VTE_FEATURE_FLAG_SIXEL) | |
+ { | |
+ /* next row */ | |
+ row++; | |
+ | |
+ button = gtk_check_button_new_with_mnemonic (_("_Enable sixel graphics")); | |
+ g_object_bind_property (G_OBJECT (dialog->preferences), "enable-sixel", | |
+ G_OBJECT (button), "active", | |
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); | |
+ gtk_widget_set_tooltip_text (button, _("Enable sixel graphics")); | |
+ gtk_grid_attach (GTK_GRID (grid), button, 0, row, 6, 1); | |
+ gtk_widget_show (button); | |
+ } | |
+#endif | |
/* section: Custom colors */ | |
terminal_preferences_dialog_new_section (&frame, &vbox, &grid, &label, &row, "Custom Colors"); | |
diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c | |
index 86778bce..bbe3a79e 100644 | |
--- a/terminal/terminal-preferences.c | |
+++ b/terminal/terminal-preferences.c | |
@@ -133,6 +133,7 @@ enum | |
PROP_TEXT_BLINK_MODE, | |
PROP_CELL_WIDTH_SCALE, | |
PROP_CELL_HEIGHT_SCALE, | |
+ PROP_ENABLE_SIXEL, | |
N_PROPERTIES, | |
}; | |
@@ -1231,6 +1232,16 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass) | |
1.0, 2.0, 1.0, | |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
+ /** | |
+ * TerminalPreferences:enable-sixel: | |
+ **/ | |
+ preferences_props[PROP_ENABLE_SIXEL] = | |
+ g_param_spec_boolean ("enable-sixel", | |
+ NULL, | |
+ "EnableSixel", | |
+ TRUE, | |
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | |
+ | |
/* install all properties */ | |
g_object_class_install_properties (gobject_class, N_PROPERTIES, preferences_props); | |
} | |
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c | |
index 6a0ff803..56a1e9f7 100644 | |
--- a/terminal/terminal-screen.c | |
+++ b/terminal/terminal-screen.c | |
@@ -182,7 +182,7 @@ static GtkWidget* terminal_screen_unsafe_paste_dialog_new (TerminalScreen | |
static void terminal_screen_paste_unsafe_text (TerminalScreen *screen, | |
const gchar *text, | |
GdkAtom original_clipboard); | |
- | |
+static void terminal_screen_update_sixel (TerminalScreen *screen); | |
struct _TerminalScreenClass | |
@@ -396,6 +396,7 @@ terminal_screen_init (TerminalScreen *screen) | |
terminal_screen_update_word_chars (screen); | |
terminal_screen_update_background (screen); | |
terminal_screen_update_colors (screen); | |
+ terminal_screen_update_sixel (screen); | |
/* last, connect contents-changed to avoid a race with updates above */ | |
g_signal_connect_swapped (G_OBJECT (screen->terminal), "contents-changed", | |
@@ -685,6 +686,8 @@ terminal_screen_preferences_changed (TerminalPreferences *preferences, | |
terminal_screen_update_word_chars (screen); | |
else if (strcmp ("misc-tab-position", name) == 0) | |
terminal_screen_update_label_orientation (screen); | |
+ else if (strcmp ("enable-sixel", name) == 0) | |
+ terminal_screen_update_sixel (screen); | |
} | |
@@ -3121,3 +3124,14 @@ terminal_screen_widget_append_accels (TerminalScreen *screen, | |
if (G_LIKELY (G_IS_OBJECT (screen->terminal))) | |
g_object_set (G_OBJECT (screen->terminal), "accel-group", accel_group, NULL); | |
} | |
+ | |
+void terminal_screen_update_sixel (TerminalScreen *screen) | |
+{ | |
+#if VTE_CHECK_VERSION (0, 69, 90) | |
+ gboolean enable_sixel; | |
+ g_object_get (G_OBJECT (screen->preferences), | |
+ "enable-sixel", &enable_sixel, | |
+ NULL); | |
+ vte_terminal_set_enable_sixel (VTE_TERMINAL (screen->terminal), enable_sixel); | |
+#endif | |
+} | |
-- | |
2.36.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment