lxterminal/lxterminal-0.1.10-fix-desyncronization.patch

40 lines
1.5 KiB
Diff
Raw Normal View History

From 84506b12f892c9504efbfe7d0c484ce423d3f9a5 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Yao=20Wei=20(=E9=AD=8F=E9=8A=98=E5=BB=B7)?= <mwei@lxde.org>
Date: Tue, 26 Jul 2011 09:28:52 +0800
Subject: [PATCH] fix desynchonization of terminal index and notebook index (fixes #3372388)
---
src/lxterminal.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/lxterminal.c b/src/lxterminal.c
index bb1a2b2..5d4940f 100644
--- a/src/lxterminal.c
+++ b/src/lxterminal.c
@@ -567,6 +567,22 @@ static void terminal_move_tab_execute(LXTerminal * terminal, gint direction)
{
GtkNotebook * notebook = GTK_NOTEBOOK(terminal->notebook);
gint current_page_number = gtk_notebook_get_current_page(notebook);
+ gint target_page_number = current_page_number + direction;
+
+ /* prevent out of index */
+ if (target_page_number < 0 || target_page_number >= terminal->terms->len)
+ {
+ return;
+ }
+
+ /* swap index in terms array and its id */
+ Term * term_current = g_ptr_array_index(terminal->terms, current_page_number);
+ Term * term_target = g_ptr_array_index(terminal->terms, target_page_number);
+ g_ptr_array_index(terminal->terms, target_page_number) = term_current;
+ g_ptr_array_index(terminal->terms, current_page_number) = term_target;
+ term_current->index = target_page_number;
+ term_target->index = current_page_number;
+
gtk_notebook_reorder_child(notebook, gtk_notebook_get_nth_page(notebook, current_page_number), current_page_number + direction);
}
--
1.7.0.1