From 8a01e1caf42417b263ae796613066f0becea8d1c Mon Sep 17 00:00:00 2001 From: Dave Sp Date: Thu, 9 Aug 2018 16:46:13 -0500 Subject: [PATCH 1/4] Allow tab width to be set via "Edit -> Preferences -> Advanced". --- data/lxterminal-preferences.glade | 39 +++++++++++++++++++++++++++++++ src/lxterminal.c | 4 +++- src/preferences.c | 5 ++++ src/setting.c | 9 ++++++- src/setting.h | 2 ++ 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/data/lxterminal-preferences.glade b/data/lxterminal-preferences.glade index 03d55964..66daefb4 100644 --- a/data/lxterminal-preferences.glade +++ b/data/lxterminal-preferences.glade @@ -20,6 +20,12 @@ 10 10 + + 1000 + 100 + 1 + 10 + @@ -996,6 +1002,19 @@ GTK_FILL + + + True + False + 1 + Tab width + + + 4 + 5 + GTK_FILL + + True @@ -1012,6 +1031,26 @@ GTK_FILL + + + True + True + + 4 + False + False + True + True + tab_width_adjustment + + + 1 + 2 + 4 + 5 + GTK_FILL + + 2 diff --git a/src/lxterminal.c b/src/lxterminal.c index a6dc0b36..5b43e71f 100644 --- a/src/lxterminal.c +++ b/src/lxterminal.c @@ -1129,6 +1129,8 @@ static void terminal_settings_apply_to_term(LXTerminal * terminal, Term * term) /* Create a new terminal. */ static Term * terminal_new(LXTerminal * terminal, const gchar * label, const gchar * pwd, gchar * * env, gchar * * exec) { + Setting * setting = get_setting(); + /* Create and initialize Term structure for new terminal. */ Term * term = g_slice_new0(Term); term->parent = terminal; @@ -1209,7 +1211,7 @@ static Term * terminal_new(LXTerminal * terminal, const gchar * label, const gch term->user_specified_label = FALSE; } term->label = gtk_label_new((label != NULL) ? label : vte_terminal_get_window_title(VTE_TERMINAL(term->vte))); - gtk_widget_set_size_request(GTK_WIDGET(term->label), 100, -1); + gtk_widget_set_size_request(GTK_WIDGET(term->label), setting->tab_width, -1); gtk_label_set_ellipsize(GTK_LABEL(term->label), PANGO_ELLIPSIZE_END); gtk_misc_set_alignment(GTK_MISC(term->label), 0.0, 0.5); gtk_misc_set_padding(GTK_MISC(term->label), 0, 0); diff --git a/src/preferences.c b/src/preferences.c index d8927e66..efa45642 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -431,6 +431,11 @@ void terminal_preferences_dialog(GtkAction * action, LXTerminal * terminal) g_signal_connect(G_OBJECT(w), "toggled", G_CALLBACK(preferences_dialog_generic_toggled_event), &setting->disable_confirm); + w = GTK_WIDGET(gtk_builder_get_object(builder, "tab_width")); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), setting->tab_width); + g_signal_connect(G_OBJECT(w), "value-changed", + G_CALLBACK(preferences_dialog_int_value_changed_event), &setting->tab_width); + /* Shortcuts */ #define PREF_SETUP_SHORTCUT(OBJ, VAR) \ w = GTK_WIDGET(gtk_builder_get_object(builder, OBJ)); \ diff --git a/src/setting.c b/src/setting.c index 72f4bd6d..78ac1fd4 100644 --- a/src/setting.c +++ b/src/setting.c @@ -132,6 +132,7 @@ void print_setting() printf("Disable F10: %i\n", setting->disable_f10); printf("Disable Alt: %i\n", setting->disable_alt); printf("Disable Confirm: %i\n", setting->disable_confirm); + printf("Tab width: %i\n", setting->tab_width); printf("Geometry change: %i\n", setting->geometry_change); /* Shortcut group settings. */ @@ -147,7 +148,7 @@ void print_setting() printf("MOVE_TAB_LEFT_ACCEL: %s\n", setting->move_tab_left_accel); printf("MOVE_TAB_RIGHT_ACCEL: %s\n", setting->move_tab_right_accel); } -#endif +#endif /* 0 */ Setting * get_setting() { @@ -219,6 +220,7 @@ void save_setting() g_key_file_set_boolean(setting->keyfile, GENERAL_GROUP, DISABLE_F10, setting->disable_f10); g_key_file_set_boolean(setting->keyfile, GENERAL_GROUP, DISABLE_ALT, setting->disable_alt); g_key_file_set_boolean(setting->keyfile, GENERAL_GROUP, DISABLE_CONFIRM, setting->disable_confirm); + g_key_file_set_integer(setting->keyfile, GENERAL_GROUP, TAB_WIDTH, setting->tab_width); /* Shortcut group settings. */ g_key_file_set_string(setting->keyfile, SHORTCUT_GROUP, NEW_WINDOW_ACCEL, setting->new_window_accel); @@ -438,6 +440,11 @@ Setting * load_setting() setting->disable_f10 = g_key_file_get_boolean(setting->keyfile, GENERAL_GROUP, DISABLE_F10, NULL); setting->disable_alt = g_key_file_get_boolean(setting->keyfile, GENERAL_GROUP, DISABLE_ALT, NULL); setting->disable_confirm = g_key_file_get_boolean(setting->keyfile, GENERAL_GROUP, DISABLE_CONFIRM, NULL); + g_clear_error(&error); + setting->tab_width = g_key_file_get_integer(setting->keyfile, GENERAL_GROUP, TAB_WIDTH, &error); + if (error && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)) { + setting->tab_width = 100; + } /* Shortcut group settings. */ setting->new_window_accel = g_key_file_get_string(setting->keyfile, SHORTCUT_GROUP, NEW_WINDOW_ACCEL, NULL); diff --git a/src/setting.h b/src/setting.h index e0e54f2c..6719630f 100644 --- a/src/setting.h +++ b/src/setting.h @@ -45,6 +45,7 @@ #define DISABLE_F10 "disablef10" #define DISABLE_ALT "disablealt" #define DISABLE_CONFIRM "disableconfirm" +#define TAB_WIDTH "tabwidth" #define PALETTE_COLOR_PREFIX "palette_color_" #define COLOR_PRESET "color_preset" @@ -111,6 +112,7 @@ typedef struct _setting { gboolean disable_f10; /* True if F10 will be passed to program; false if it brings up File menu */ gboolean disable_alt; /* True if Alt-n is passed to shell; false if it is used to switch between tabs */ gboolean disable_confirm; /* True if confirmation exit dialog shows before terminal window close*/ + gint tab_width; /* Tab width */ gboolean geometry_change; /* True if there is a geometry change, until it has been acted on */ From e40b1c57a94f338cac6524814256f46251aadabe Mon Sep 17 00:00:00 2001 From: Dave Sp Date: Mon, 13 Aug 2018 03:56:27 -0500 Subject: [PATCH 2/4] Local repo commit only: Make tabs re-orderable with mouse. --- src/lxterminal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lxterminal.c b/src/lxterminal.c index 5b43e71f..50e28621 100644 --- a/src/lxterminal.c +++ b/src/lxterminal.c @@ -430,6 +430,7 @@ static void terminal_new_tab(LXTerminal * terminal, const gchar * label) /* Add a tab to the notebook and the "terms" array. */ gtk_notebook_append_page(GTK_NOTEBOOK(terminal->notebook), term->box, term->tab); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(terminal->notebook), term->box, TRUE); term->index = gtk_notebook_get_n_pages(GTK_NOTEBOOK(terminal->notebook)) - 1; g_ptr_array_add(terminal->terms, term); @@ -1591,6 +1592,7 @@ LXTerminal * lxterminal_initialize(LXTermWindow * lxtermwin, CommandArguments * /* Add the first terminal to the notebook and the data structures. */ gtk_notebook_append_page(GTK_NOTEBOOK(terminal->notebook), term->box, term->tab); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(terminal->notebook), term->box, TRUE); term->index = gtk_notebook_get_n_pages(GTK_NOTEBOOK(terminal->notebook)) - 1; g_ptr_array_add(terminal->terms, term); From 543d6012fa83b363e2fc11773e7dd57ff5059deb Mon Sep 17 00:00:00 2001 From: Dave Sp Date: Tue, 21 Aug 2018 05:00:05 -0500 Subject: [PATCH 3/4] In data/lxterminal-preferences.glade, for the Advanced tab, set n_rows appropriately. (It should have been '4' before this branch was created, but Gtk didn't seem to care.) --- data/lxterminal-preferences.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/lxterminal-preferences.glade b/data/lxterminal-preferences.glade index 66daefb4..b0b817de 100644 --- a/data/lxterminal-preferences.glade +++ b/data/lxterminal-preferences.glade @@ -903,7 +903,7 @@ True False - 3 + 5 2 5 3 From 5f51568cc65f372c31d1d57f7a7bae922675d398 Mon Sep 17 00:00:00 2001 From: Dave Sp Date: Mon, 4 May 2020 04:11:03 -0500 Subject: [PATCH 4/4] Removed calls to "gtk_notebook_set_tab_reorderable()". --- src/lxterminal.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lxterminal.c b/src/lxterminal.c index 2456ec37..4bad6597 100644 --- a/src/lxterminal.c +++ b/src/lxterminal.c @@ -432,7 +432,6 @@ static void terminal_new_tab(LXTerminal * terminal, const gchar * label) /* Add a tab to the notebook and the "terms" array. */ gtk_notebook_append_page(GTK_NOTEBOOK(terminal->notebook), term->box, term->tab); - gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(terminal->notebook), term->box, TRUE); term->index = gtk_notebook_get_n_pages(GTK_NOTEBOOK(terminal->notebook)) - 1; g_ptr_array_add(terminal->terms, term); @@ -1624,7 +1623,6 @@ LXTerminal * lxterminal_initialize(LXTermWindow * lxtermwin, CommandArguments * /* Add the first terminal to the notebook and the data structures. */ gtk_notebook_append_page(GTK_NOTEBOOK(terminal->notebook), term->box, term->tab); - gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(terminal->notebook), term->box, TRUE); term->index = gtk_notebook_get_n_pages(GTK_NOTEBOOK(terminal->notebook)) - 1; g_ptr_array_add(terminal->terms, term);