summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorBerke Viktor <bviktor@hexchat.org>2013-05-12 16:59:21 +0200
committerBerke Viktor <bviktor@hexchat.org>2013-05-12 16:59:21 +0200
commit2c15270be1cdb3c5034373a4d47eae3b11e19688 (patch)
treef26350d7745ceb71420b2c5b2e861e0d247fc721 /src
parentc044bdfe326db8330cfd856432a06270d8010184 (diff)
Remember selected tab
Diffstat (limited to 'src')
-rw-r--r--src/fe-gtk/servlistgui.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/fe-gtk/servlistgui.c b/src/fe-gtk/servlistgui.c
index 2bb65dbc..2e799f8b 100644
--- a/src/fe-gtk/servlistgui.c
+++ b/src/fe-gtk/servlistgui.c
@@ -48,6 +48,8 @@ static int netlist_win_height = 0;
 static int netedit_win_width = 0;
 static int netedit_win_height = 0;
 
+static int netedit_active_tab = 0;
+
 /* global user info */
 static GtkWidget *entry_nick1;
 static GtkWidget *entry_nick2;
@@ -1386,6 +1388,15 @@ servlist_editkey_cb (GtkCellRendererText *cell, gchar *name, gchar *newval, gpoi
 	}
 }
 
+static gboolean
+servlist_edit_tabswitch_cb (GtkNotebook *nb, gpointer *newtab, guint newindex, gpointer user_data)
+{
+	/* remember the active tab */
+	netedit_active_tab = newindex;
+
+	return FALSE;
+}
+
 static void
 servlist_combo_cb (GtkEntry *entry, gpointer userdata)
 {
@@ -1740,6 +1751,12 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
 
 	gtk_widget_show_all (editwindow);
 
+	/* We can't set the active tab without child elements being shown, so this must be *after* gtk_widget_show()s! */
+	gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), netedit_active_tab);
+
+	/* We need to connect this *after* setting the active tab so that the value doesn't get overriden. */
+	g_signal_connect (G_OBJECT (notebook), "switch-page", G_CALLBACK (servlist_edit_tabswitch_cb), notebook);
+
 	return editwindow;
 }