port to vte 0.38.0

VTE is not making any attempt to maintain API stability. The following
changes to the API impacted Termite, despite it avoiding deprecated
functions:

* vte_pty_set_term removed (hopefully without an impact...)
* vte_terminal_get_child_exit_status replaced with new signal parameter
* beep signal -> bell signal
* vte_char_attributes -> VteCharAttributes
* sync suffix added to I/O functions along with some parameter changes
* rgba suffix removed from all color functions
* inner-border attribute replaced with GtkStyleContext padding
* vte_terminal_set_font_from_string removed, use Pango directly
* vte_terminal_is_word_char removed - is_word_char copied to Termite
* vte_terminal_set_word_chars removed - feature dropped
* vte_terminal_set_visible_bell removed - feature dropped

Support for text selection is still not supported upstream. The required
API is tiny and does not expose internal details. Despite the lack of a
compelling reason to leave it out like a backwards compatibility risk,
the patch has been left to rot on the bug tracker.

The vte_terminal_get_user_shell_with_fallback API was also removed,
although it was an internal API and Termite was only using it for
convenience. The functionality has been moved inside Termite.

Closes #187
This commit is contained in:
Daniel Micay 2014-09-21 17:14:29 -04:00
parent fb09063431
commit 7f03ded730
5 changed files with 158 additions and 145 deletions

View File

@ -1,7 +1,7 @@
VERSION = $(shell git describe --tags)
PREFIX = /usr/local
GTK = gtk+-3.0
VTE = vte-2.90
VTE = vte-2.91
TERMINFO = ${PREFIX}/share/terminfo
CXXFLAGS := -std=c++11 -O3 \

View File

@ -12,7 +12,7 @@ process.
DEPENDENCIES
============
A vte version >= ``0.34``. A `patch
A vte version >= ``0.38.0``. A `patch
<https://github.com/thestinger/termite/blob/master/expose_select_text.patch>`_
is required to expose the functions needed for keyboard selection.

6
config
View File

@ -3,7 +3,6 @@ resize_grip = false
scroll_on_output = false
scroll_on_keystroke = true
audible_bell = false
visible_bell = false
mouse_autohide = false
allow_bold = true
dynamic_title = true
@ -24,10 +23,6 @@ cursor_shape = block
# $BROWSER is used by default
#browser = firefox
# word characters used for word selection
# (default if unset: all graphic non-punctuation/space characters)
#word_chars = -A-Za-z0-9,./?%&#:_=+@~
# set size hints for the window
#size_hints = false
@ -37,7 +32,6 @@ cursor_shape = block
[colors]
foreground = #dcdccc
foreground_bold = #ffffff
#foreground_dim = #888888
background = #3f3f3f
#cursor = #dcdccc

View File

@ -1,7 +1,20 @@
diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
--- vte-0.32.2-old/src/vte.c 2012-07-13 21:09:04.003969877 -0400
+++ vte-0.32.2/src/vte.c 2012-08-30 04:30:04.285924831 -0400
@@ -129,7 +129,6 @@
Only in vte-0.38.0.new: expose_select_text.patch
diff -aur vte-0.38.0/src/vteaccess.c vte-0.38.0.new/src/vteaccess.c
--- vte-0.38.0/src/vteaccess.c 2014-08-13 08:00:38.000000000 -0400
+++ vte-0.38.0.new/src/vteaccess.c 2014-09-21 17:05:23.934641193 -0400
@@ -1427,7 +1427,7 @@
*start_offset = offset_from_xy (priv, start_x, start_y);
_vte_terminal_get_end_selection (terminal, &end_x, &end_y);
*end_offset = offset_from_xy (priv, end_x, end_y);
- return _vte_terminal_get_selection (terminal);
+ return vte_terminal_get_selection (terminal);
}
static gboolean
diff -aur vte-0.38.0/src/vte.c vte-0.38.0.new/src/vte.c
--- vte-0.38.0/src/vte.c 2014-09-13 03:23:47.000000000 -0400
+++ vte-0.38.0.new/src/vte.c 2014-09-21 17:03:04.671656749 -0400
@@ -122,7 +122,6 @@
gpointer data,
GArray *attributes,
gboolean include_trailing_spaces);
@ -9,7 +22,7 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
static void _vte_terminal_disconnect_pty_write(VteTerminal *terminal);
static void vte_terminal_stop_processing (VteTerminal *terminal);
@@ -3508,8 +3507,8 @@
@@ -3267,9 +3266,10 @@
_vte_debug_print (VTE_DEBUG_IO, "removed poll of vte_terminal_io_read\n");
terminal->pvt->pty_input_source = 0;
}
@ -18,9 +31,11 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
+void
+vte_terminal_connect_pty_read(VteTerminal *terminal)
{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (terminal->pvt->pty_channel == NULL) {
return;
@@ -3560,8 +3559,8 @@
}
@@ -3321,9 +3321,10 @@
}
}
@ -29,29 +44,11 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
+void
+vte_terminal_disconnect_pty_read(VteTerminal *terminal)
{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (terminal->pvt->pty_input_source != 0) {
_vte_debug_print (VTE_DEBUG_IO, "disconnecting poll of vte_terminal_io_read\n");
@@ -3708,8 +3707,8 @@
return NULL;
}
-static char *
-_vte_terminal_get_user_shell_with_fallback (void)
+char *
+vte_terminal_get_user_shell_with_fallback (void)
{
char *command;
const gchar *env;
@@ -3744,7 +3743,7 @@
char **argv2;
char *shell = NULL;
- argv2 = __vte_pty_get_argv(command ? command : (shell = _vte_terminal_get_user_shell_with_fallback ()),
+ argv2 = __vte_pty_get_argv(command ? command : (shell = vte_terminal_get_user_shell_with_fallback ()),
argv,
flags);
g_free(shell);
@@ -6545,6 +6544,28 @@
g_source_remove(terminal->pvt->pty_input_source);
@@ -6154,6 +6155,28 @@
}
}
@ -80,8 +77,8 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
static GtkClipboard *
vte_terminal_clipboard_get(VteTerminal *terminal, GdkAtom board)
{
@@ -6676,7 +6697,7 @@
terminal->pvt->selection_start.row);
@@ -6319,7 +6342,7 @@
vte_terminal_extend_selection(terminal, x, y, FALSE, TRUE);
/* Temporarily stop caring about input from the child. */
- _vte_terminal_disconnect_pty_read(terminal);
@ -89,7 +86,7 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
}
static gboolean
@@ -6693,7 +6714,7 @@
@@ -6336,7 +6359,7 @@
terminal->pvt->selecting = FALSE;
/* Reconnect to input from the child if we paused it. */
@ -98,35 +95,8 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
return TRUE;
}
@@ -8994,7 +9015,7 @@
#endif
kill(terminal->pvt->pty_pid, SIGHUP);
}
- _vte_terminal_disconnect_pty_read(terminal);
+ vte_terminal_disconnect_pty_read(terminal);
_vte_terminal_disconnect_pty_write(terminal);
if (terminal->pvt->pty_channel != NULL) {
g_io_channel_unref (terminal->pvt->pty_channel);
@@ -14384,7 +14405,7 @@
g_object_freeze_notify(object);
if (pvt->pty != NULL) {
- _vte_terminal_disconnect_pty_read(terminal);
+ vte_terminal_disconnect_pty_read(terminal);
_vte_terminal_disconnect_pty_write(terminal);
if (terminal->pvt->pty_channel != NULL) {
@@ -14440,7 +14461,7 @@
_vte_terminal_setup_utf8 (terminal);
/* Open channels to listen for input on. */
- _vte_terminal_connect_pty_read (terminal);
+ vte_terminal_connect_pty_read (terminal);
g_object_notify(object, "pty");
g_object_notify(object, "pty-object");
@@ -14567,6 +14588,50 @@
}
@@ -6834,6 +6857,50 @@
vte_terminal_deselect_all (terminal);
}
+/**
@ -173,21 +143,72 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
+ _vte_terminal_select_text(terminal, start_col, start_row, end_col, end_row, 0, 0);
+}
+
void
_vte_terminal_select_text(VteTerminal *terminal,
long start_col, long start_row,
diff -aur vte-0.32.2-old/src/vte.h vte-0.32.2/src/vte.h
--- vte-0.32.2-old/src/vte.h 2012-07-13 21:09:04.003969877 -0400
+++ vte-0.32.2/src/vte.h 2012-08-30 04:30:09.695999432 -0400
@@ -296,6 +296,15 @@
/* simple manipulation of selection */
void vte_terminal_select_all(VteTerminal *terminal);
void vte_terminal_select_none(VteTerminal *terminal);
+gboolean vte_terminal_get_selection_block_mode(VteTerminal *terminal);
+void vte_terminal_set_selection_block_mode(VteTerminal *terminal, gboolean block_mode);
/* Autoscroll a bit. */
static gboolean
vte_terminal_autoscroll(VteTerminal *terminal)
@@ -8476,7 +8543,7 @@
#endif
kill(terminal->pvt->pty_pid, SIGHUP);
}
- _vte_terminal_disconnect_pty_read(terminal);
+ vte_terminal_disconnect_pty_read(terminal);
_vte_terminal_disconnect_pty_write(terminal);
if (terminal->pvt->pty_channel != NULL) {
g_io_channel_unref (terminal->pvt->pty_channel);
@@ -12533,7 +12600,7 @@
g_object_freeze_notify(object);
if (pvt->pty != NULL) {
- _vte_terminal_disconnect_pty_read(terminal);
+ vte_terminal_disconnect_pty_read(terminal);
_vte_terminal_disconnect_pty_write(terminal);
if (terminal->pvt->pty_channel != NULL) {
@@ -12588,7 +12655,7 @@
_vte_terminal_setup_utf8 (terminal);
/* Open channels to listen for input on. */
- _vte_terminal_connect_pty_read (terminal);
+ vte_terminal_connect_pty_read (terminal);
g_object_notify(object, "pty");
@@ -12623,7 +12690,7 @@
}
char *
-_vte_terminal_get_selection(VteTerminal *terminal)
+vte_terminal_get_selection(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
Only in vte-0.38.0.new/src: .vte.c.swp
diff -aur vte-0.38.0/src/vteint.h vte-0.38.0.new/src/vteint.h
--- vte-0.38.0/src/vteint.h 2014-05-16 13:51:26.000000000 -0400
+++ vte-0.38.0.new/src/vteint.h 2014-09-21 17:05:44.934589281 -0400
@@ -25,7 +25,6 @@
G_BEGIN_DECLS
void _vte_terminal_accessible_ref(VteTerminal *terminal);
-char* _vte_terminal_get_selection(VteTerminal *terminal);
void _vte_terminal_get_start_selection(VteTerminal *terminal, long *x, long *y);
void _vte_terminal_get_end_selection(VteTerminal *terminal, long *x, long *y);
void _vte_terminal_select_text(VteTerminal *terminal, long start_x, long start_y, long end_x, long end_y, int start_offset, int end_offset);
diff -aur vte-0.38.0/src/vteterminal.h vte-0.38.0.new/src/vteterminal.h
--- vte-0.38.0/src/vteterminal.h 2014-09-13 03:23:47.000000000 -0400
+++ vte-0.38.0.new/src/vteterminal.h 2014-09-21 17:03:39.094903032 -0400
@@ -170,6 +170,18 @@
void vte_terminal_select_all(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
void vte_terminal_unselect_all(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+gboolean vte_terminal_get_selection_block_mode(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+void vte_terminal_set_selection_block_mode(VteTerminal *terminal,
+ gboolean block_mode) _VTE_GNUC_NONNULL(1);
+void vte_terminal_select_text(VteTerminal *terminal,
+ long start_col, long start_row,
+ long end_col, long end_row);
+ long end_col, long end_row) _VTE_GNUC_NONNULL(1);
+char *
+vte_terminal_get_selection(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+
+/* pause and unpause output */
+void vte_terminal_disconnect_pty_read(VteTerminal *vte);
@ -195,20 +216,13 @@ diff -aur vte-0.32.2-old/src/vte.h vte-0.32.2/src/vte.h
/* Set the terminal's size. */
void vte_terminal_set_size(VteTerminal *terminal,
@@ -435,6 +444,8 @@
GArray *attributes);
@@ -276,6 +288,8 @@
void vte_terminal_get_cursor_position(VteTerminal *terminal,
glong *column, glong *row);
glong *column,
glong *row) _VTE_GNUC_NONNULL(1);
+void vte_terminal_set_cursor_position(VteTerminal *terminal,
+ long column, long row);
/* Display string matching: clear all matching expressions. */
void vte_terminal_match_clear_all(VteTerminal *terminal);
+ long column, long row) _VTE_GNUC_NONNULL(1);
@@ -484,6 +495,7 @@
VtePty *vte_terminal_get_pty_object(VteTerminal *terminal);
char *vte_get_user_shell (void);
+char *vte_terminal_get_user_shell_with_fallback(void);
/* Accessors for bindings. */
#if !GTK_CHECK_VERSION (2, 91, 2)
/* Add a matching expression, returning the tag the widget assigns to that
* expression. */
Only in vte-0.38.0.new/src: .vteterminal.h.swp

View File

@ -31,7 +31,6 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <vte/vte.h>
#include <vte/vteaccess.h>
#include "url_regex.hh"
#include "util/clamp.hh"
@ -116,7 +115,7 @@ static gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info
static gboolean entry_key_press_cb(GtkEntry *entry, GdkEventKey *event, keybind_info *info);
static gboolean position_overlay_cb(GtkBin *overlay, GtkWidget *widget, GdkRectangle *alloc);
static gboolean button_press_cb(VteTerminal *vte, GdkEventButton *event, const config_info *info);
static void beep_cb(GtkWidget *vte, gboolean *urgent_on_bell);
static void bell_cb(GtkWidget *vte, gboolean *urgent_on_bell);
static gboolean focus_cb(GtkWindow *window);
static GtkTreeModel *create_completion_model(VteTerminal *vte);
@ -218,7 +217,7 @@ static void launch_in_directory(VteTerminal *vte) {
static void find_urls(VteTerminal *vte, search_panel_info *panel_info) {
GRegex *regex = g_regex_new(url_regex, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, nullptr);
GArray *attributes = g_array_new(FALSE, FALSE, sizeof (vte_char_attributes));
GArray *attributes = g_array_new(FALSE, FALSE, sizeof (VteCharAttributes));
auto content = make_unique(vte_terminal_get_text(vte, nullptr, nullptr, attributes), g_free);
for (char *s_ptr = content.get(), *saveptr; ; s_ptr = nullptr) {
@ -235,8 +234,8 @@ static void find_urls(VteTerminal *vte, search_panel_info *panel_info) {
int pos;
g_match_info_fetch_pos(info, 0, &pos, nullptr);
const long first_row = g_array_index(attributes, vte_char_attributes, 0).row;
const auto attr = g_array_index(attributes, vte_char_attributes, token + pos - content.get());
const long first_row = g_array_index(attributes, VteCharAttributes, 0).row;
const auto attr = g_array_index(attributes, VteCharAttributes, token + pos - content.get());
panel_info->url_list.emplace_back(g_match_info_fetch(info, 0),
attr.column,
@ -346,7 +345,7 @@ static gboolean draw_cb(const draw_cb_info *info, cairo_t *cr) {
}
static void update_selection(VteTerminal *vte, const select_info *select) {
vte_terminal_select_none(vte);
vte_terminal_unselect_all(vte);
if (select->mode == vi_mode::command) {
return;
@ -394,7 +393,7 @@ static void enter_command_mode(VteTerminal *vte, select_info *select) {
static void exit_command_mode(VteTerminal *vte, select_info *select) {
vte_terminal_set_cursor_position(vte, select->origin_col, select->origin_row);
vte_terminal_connect_pty_read(vte);
vte_terminal_select_none(vte);
vte_terminal_unselect_all(vte);
select->mode = vi_mode::insert;
}
@ -456,10 +455,10 @@ static void move_to_row_start(VteTerminal *vte, select_info *select, long row) {
static void open_selection(char *browser, VteTerminal *vte) {
if (browser) {
AtkText *text = ATK_TEXT(vte_terminal_accessible_new(vte));
auto selection = make_unique(atk_text_get_selection(text, 0, nullptr, nullptr), g_free);
if (selection && *selection)
auto selection = make_unique(vte_terminal_get_selection(vte), g_free);
if (selection && *selection) {
launch_browser(browser, selection.get());
}
} else {
g_printerr("no browser to open url\n");
}
@ -471,6 +470,13 @@ get_text_range(VteTerminal *vte, long start_row, long start_col, long end_row, l
nullptr, nullptr, nullptr), g_free};
}
static bool is_word_char(gunichar c) {
static const char *word_char_ascii_punct = "-,.;/?%&#:_=+@~";
return g_unichar_isgraph(c) &&
(g_unichar_isalnum(c) || (g_unichar_ispunct(c) &&
(c >= 0x80 || strchr(word_char_ascii_punct, (int)c) != NULL)));
}
template<typename F>
static void move_backward(VteTerminal *vte, select_info *select, F is_word) {
long cursor_col, cursor_row;
@ -508,7 +514,7 @@ static void move_backward(VteTerminal *vte, select_info *select, F is_word) {
}
static void move_backward_word(VteTerminal *vte, select_info *select) {
move_backward(vte, select, std::bind(vte_terminal_is_word_char, vte, _1));
move_backward(vte, select, is_word_char);
}
static void move_backward_blank_word(VteTerminal *vte, select_info *select) {
@ -620,7 +626,7 @@ static void move_forward(VteTerminal *vte, select_info *select, F is_word) {
}
static void move_forward_word(VteTerminal *vte, select_info *select) {
move_forward(vte, select, std::bind(vte_terminal_is_word_char, vte, _1));
move_forward(vte, select, is_word_char);
}
static void move_forward_blank_word(VteTerminal *vte, select_info *select) {
@ -998,7 +1004,7 @@ gboolean button_press_cb(VteTerminal *vte, GdkEventButton *event, const config_i
return FALSE;
}
void beep_cb(GtkWidget *vte, gboolean *urgent_on_bell) {
static void bell_cb(GtkWidget *vte, gboolean *urgent_on_bell) {
if (*urgent_on_bell) {
gtk_window_set_urgency_hint(GTK_WINDOW(gtk_widget_get_toplevel(vte)), TRUE);
}
@ -1048,10 +1054,10 @@ void search(VteTerminal *vte, const char *pattern, bool reverse) {
GRegex *regex = vte_terminal_search_get_gregex(vte);
if (regex) g_regex_unref(regex);
regex = g_regex_new(pattern, (GRegexCompileFlags)0, (GRegexMatchFlags)0, nullptr);
vte_terminal_search_set_gregex(vte, regex);
vte_terminal_search_set_gregex(vte, regex, (GRegexMatchFlags)0);
if (!terminal_search(vte)) {
vte_terminal_select_none(vte);
vte_terminal_unselect_all(vte);
terminal_search(vte);
}
@ -1080,18 +1086,14 @@ void overlay_show(search_panel_info *info, overlay_mode mode, VteTerminal *vte)
}
void get_vte_padding(VteTerminal *vte, int *left, int *top, int *right, int *bottom) {
GtkBorder *border = nullptr;
gtk_widget_style_get(GTK_WIDGET(vte), "inner-border", &border, nullptr);
if (!border) {
g_warning("VTE's inner-border property unavailable");
*left = *top = *right = *bottom = 0;
} else {
*left = border->left;
*right = border->right;
*top = border->top;
*bottom = border->bottom;
gtk_border_free(border);
}
GtkBorder border;
gtk_style_context_get_padding(gtk_widget_get_style_context(GTK_WIDGET(vte)),
gtk_widget_get_state_flags(GTK_WIDGET(vte)),
&border);
*left = border.left;
*right = border.right;
*top = border.top;
*bottom = border.bottom;
}
char *check_match(VteTerminal *vte, int event_x, int event_y) {
@ -1177,26 +1179,23 @@ static void load_theme(GtkWindow *window, VteTerminal *vte, GKeyFile *config, hi
}
}
vte_terminal_set_colors_rgba(vte, nullptr, nullptr, palette.data(), palette.size());
vte_terminal_set_colors(vte, nullptr, nullptr, palette.data(), palette.size());
if (auto color = get_config_color(config, "colors", "foreground")) {
vte_terminal_set_color_foreground_rgba(vte, &*color);
vte_terminal_set_color_bold_rgba(vte, &*color);
vte_terminal_set_color_foreground(vte, &*color);
vte_terminal_set_color_bold(vte, &*color);
}
if (auto color = get_config_color(config, "colors", "foreground_bold")) {
vte_terminal_set_color_bold_rgba(vte, &*color);
}
if (auto color = get_config_color(config, "colors", "foreground_dim")) {
vte_terminal_set_color_dim_rgba(vte, &*color);
vte_terminal_set_color_bold(vte, &*color);
}
if (auto color = get_config_color(config, "colors", "background")) {
vte_terminal_set_color_background_rgba(vte, &*color);
vte_terminal_set_color_background(vte, &*color);
gtk_widget_override_background_color(GTK_WIDGET(window), GTK_STATE_FLAG_NORMAL, &*color);
}
if (auto color = get_config_color(config, "colors", "cursor")) {
vte_terminal_set_color_cursor_rgba(vte, &*color);
vte_terminal_set_color_cursor(vte, &*color);
}
if (auto color = get_config_color(config, "colors", "highlight")) {
vte_terminal_set_color_highlight_rgba(vte, &*color);
vte_terminal_set_color_highlight(vte, &*color);
}
if (auto s = get_config_string(config, "hints", "font")) {
@ -1262,7 +1261,7 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
vte_terminal_set_scroll_on_output(vte, cfg_bool("scroll_on_output", FALSE));
vte_terminal_set_scroll_on_keystroke(vte, cfg_bool("scroll_on_keystroke", TRUE));
vte_terminal_set_audible_bell(vte, cfg_bool("audible_bell", FALSE));
vte_terminal_set_visible_bell(vte, cfg_bool("visual_bell", FALSE));
//vte_terminal_set_visible_bell(vte, cfg_bool("visual_bell", FALSE));
vte_terminal_set_mouse_autohide(vte, cfg_bool("mouse_autohide", FALSE));
vte_terminal_set_allow_bold(vte, cfg_bool("allow_bold", TRUE));
vte_terminal_search_set_wrap_around(vte, cfg_bool("search_wrap", TRUE));
@ -1302,12 +1301,9 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
}
if (auto s = get_config_string(config, "options", "font")) {
vte_terminal_set_font_from_string(vte, *s);
g_free(*s);
}
if (auto s = get_config_string(config, "options", "word_chars")) {
vte_terminal_set_word_chars(vte, *s);
PangoFontDescription *font = pango_font_description_from_string(*s);
vte_terminal_set_font(vte, font);
pango_font_description_free(font);
g_free(*s);
}
@ -1350,8 +1346,7 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
load_theme(window, vte, config, info->hints);
}/*}}}*/
static void exit_with_status(VteTerminal *vte) {
int status = vte_terminal_get_child_exit_status(vte);
static void exit_with_status(VteTerminal *, int status) {
gtk_main_quit();
exit(WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);
}
@ -1361,6 +1356,17 @@ static void exit_with_success(VteTerminal *) {
exit(EXIT_SUCCESS);
}
static char *get_user_shell_with_fallback() {
if (char *command = vte_get_user_shell())
return command;
if (const char *env = g_getenv("SHELL"))
return g_strdup(env);
return g_strdup("/bin/sh");
}
int main(int argc, char **argv) {
GError *error = nullptr;
const char *const term = "xterm-termite";
@ -1428,11 +1434,11 @@ int main(int argc, char **argv) {
}
command_argv = argvp;
} else {
default_argv[0] = vte_terminal_get_user_shell_with_fallback();
default_argv[0] = get_user_shell_with_fallback();
command_argv = default_argv;
}
VtePty *pty = vte_terminal_pty_new(vte, VTE_PTY_DEFAULT, &error);
VtePty *pty = vte_terminal_pty_new_sync(vte, VTE_PTY_DEFAULT, NULL, &error);
if (!pty) {
g_printerr("failed to create pty: %s\n", error->message);
@ -1460,8 +1466,7 @@ int main(int argc, char **argv) {
};
signal(SIGUSR1, [](int){ reload_config(); });
vte_terminal_set_pty_object(vte, pty);
vte_pty_set_term(pty, term);
vte_terminal_set_pty(vte, pty);
GdkRGBA transparent {0, 0, 0, 0};
@ -1491,7 +1496,7 @@ int main(int argc, char **argv) {
g_signal_connect(info.panel.entry, "key-press-event", G_CALLBACK(entry_key_press_cb), &info);
g_signal_connect(panel_overlay, "get-child-position", G_CALLBACK(position_overlay_cb), nullptr);
g_signal_connect(vte, "button-press-event", G_CALLBACK(button_press_cb), &info.config);
g_signal_connect(vte, "beep", G_CALLBACK(beep_cb), &info.config.urgent_on_bell);
g_signal_connect(vte, "bell", G_CALLBACK(bell_cb), &info.config.urgent_on_bell);
draw_cb_info draw_cb_info{vte, &info.panel, &info.config.hints};
g_signal_connect_swapped(info.panel.da, "draw", G_CALLBACK(draw_cb), &draw_cb_info);