Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request 50 #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/lxterminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static void terminal_about_activate_event(GtkAction * action, LXTerminal * termi

/* Window creation, destruction, and control. */
static void terminal_switch_page_event(GtkNotebook * notebook, GtkWidget * page, guint num, LXTerminal * terminal);
static void terminal_page_reordered_event(GtkNotebook * notebook, GtkWidget * page, guint num, LXTerminal * terminal);
static void terminal_vte_size_allocate_event(GtkWidget *widget, GtkAllocation *allocation, Term *term);
static void terminal_window_title_changed_event(GtkWidget * vte, Term * term);
static gboolean terminal_close_window_confirmation_event(GtkWidget * widget, GdkEventButton * event, LXTerminal * terminal);
Expand Down Expand Up @@ -430,6 +431,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);

Expand Down Expand Up @@ -799,6 +801,28 @@ static void terminal_switch_page_event(GtkNotebook * notebook, GtkWidget * page,
}
}

/* Handler for "page-reordered" event on the tab notebook. */
static void terminal_page_reordered_event(GtkNotebook * notebook, GtkWidget * page, guint num, LXTerminal * terminal)
{
guint i;
Term * term;
gint term_page_number;
GPtrArray * new_terms = g_ptr_array_new();

for (i = 0; i < terminal->terms->len; i++)
{
term = g_ptr_array_index(terminal->terms, i);
term_page_number = gtk_notebook_page_num(notebook, GTK_WIDGET(term->box));
term->index = term_page_number;
g_ptr_array_add(new_terms, term);
}

g_ptr_array_free(terminal->terms, TRUE);
terminal->terms = new_terms;

terminal_update_alt(terminal);
}

/* Handler for "window-title-changed" signal on a Term. */
static void terminal_window_title_changed_event(GtkWidget * vte, Term * term)
{
Expand Down Expand Up @@ -1560,6 +1584,8 @@ LXTerminal * lxterminal_initialize(LXTermWindow * lxtermwin, CommandArguments *
G_CALLBACK(terminal_settings_apply), terminal);
g_signal_connect(G_OBJECT(terminal->notebook), "switch-page",
G_CALLBACK(terminal_switch_page_event), terminal);
g_signal_connect(G_OBJECT(terminal->notebook), "page-reordered",
G_CALLBACK(terminal_page_reordered_event), terminal);
g_signal_connect(G_OBJECT(terminal->window), "delete-event",
G_CALLBACK(terminal_close_window_confirmation_event), terminal);

Expand Down Expand Up @@ -1589,6 +1615,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);

Expand Down