summary refs log tree commit diff stats
path: root/src/fe-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-gtk')
-rw-r--r--src/fe-gtk/fe-gtk.c1
-rw-r--r--src/fe-gtk/fkeys.c44
-rw-r--r--src/fe-gtk/maingui.c2
3 files changed, 45 insertions, 2 deletions
diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c
index 57ffa2f6..9f6c439a 100644
--- a/src/fe-gtk/fe-gtk.c
+++ b/src/fe-gtk/fe-gtk.c
@@ -674,6 +674,7 @@ fe_print_text (struct session *sess, char *text, time_t stamp)
 		 sess->gui->is_tab && !sess->nick_said && stamp == 0)
 	{
 		sess->new_data = TRUE;
+		lastact_update (sess);
 		if (sess->msg_said)
 			fe_set_tab_color (sess, 2);
 		else
diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c
index e606dfd5..99d244ea 100644
--- a/src/fe-gtk/fkeys.c
+++ b/src/fe-gtk/fkeys.c
@@ -159,9 +159,9 @@ static struct key_binding *keys_root = NULL;
 static const struct key_action key_actions[KEY_MAX_ACTIONS + 1] = {
 
 	{key_action_handle_command, "Run Command",
-	 N_("The \002Run Command\002 action runs the data in Data 1 as if it has been typed into the entry box where you pressed the key sequence. Thus it can contain text (which will be sent to the channel/person), commands or user commands. When run all \002\\n\002 characters in Data 1 are used to deliminate seperate commands so it is possible to run more than one command. If you want a \002\\\002 in the actual text run then enter \002\\\\\002")},
+	 N_("The \002Run Command\002 action runs the data in Data 1 as if it had been typed into the entry box where you pressed the key sequence. Thus it can contain text (which will be sent to the channel/person), commands or user commands. When run all \002\\n\002 characters in Data 1 are used to deliminate seperate commands so it is possible to run more than one command. If you want a \002\\\002 in the actual text run then enter \002\\\\\002")},
 	{key_action_page_switch, "Change Page",
-	 N_("The \002Change Page\002 command switches between pages in the notebook. Set Data 1 to the page you want to switch to. If Data 2 is set to anything then the switch will be relative to the current position")},
+	 N_("The \002Change Page\002 command switches between pages in the notebook. Set Data 1 to the page you want to switch to. If Data 2 is set to anything then the switch will be relative to the current position. Set Data 1 to auto to switch to the page with the most recent and important activity (queries first, then channels with hilight, channels with dialogue, channels with other data)")},
 	{key_action_insert, "Insert in Buffer",
 	 N_("The \002Insert in Buffer\002 command will insert the contents of Data 1 into the entry where the key sequence was pressed at the current cursor position")},
 	{key_action_scroll_page, "Scroll Page",
@@ -405,6 +405,7 @@ key_load_defaults ()
 		"A\n3\nChange Page\nD1:3\nD2!\n\n"\
 		"A\n2\nChange Page\nD1:2\nD2!\n\n"\
 		"A\n1\nChange Page\nD1:1\nD2!\n\n"\
+		"A\ngrave\nChange Page\nD1:auto\nD2!\n\n"\
 		"C\no\nInsert in Buffer\nD1:\nD2!\n\n"\
 		"C\nb\nInsert in Buffer\nD1:\nD2!\n\n"\
 		"C\nk\nInsert in Buffer\nD1:\nD2!\n\n"\
@@ -1199,10 +1200,25 @@ key_action_handle_command (GtkWidget * wid, GdkEventKey * evt, char *d1,
 	return 0;
 }
 
+/*
+ * Check if the given session is inside the main window. This predicate
+ * is passed to lastact_getfirst() as a way to filter out detached sessions.
+ * XXX: Consider moving this in a different file?
+ */
+static int
+session_check_is_tab(session *sess)
+{
+	if (!sess || !sess->gui)
+		return FALSE;
+
+	return (sess->gui->is_tab);
+}
+
 static int
 key_action_page_switch (GtkWidget * wid, GdkEventKey * evt, char *d1,
 								char *d2, struct session *sess)
 {
+	session *newsess;
 	int len, i, num;
 
 	if (!d1)
@@ -1212,6 +1228,30 @@ key_action_page_switch (GtkWidget * wid, GdkEventKey * evt, char *d1,
 	if (!len)
 		return 1;
 
+	if (strcasecmp(d1, "auto") == 0)
+	{
+		/* Auto switch makes no sense in detached sessions */
+		if (!sess->gui->is_tab)
+			return 1;
+
+		/* Obtain a session with recent activity */
+		newsess = lastact_getfirst(session_check_is_tab);
+
+		if (newsess)
+		{
+			/*
+			 * Only sessions in the current window should be considered (i.e.
+			 * we don't want to move the focus on a different window). This
+			 * call could, in theory, do this, but we checked before that
+			 * newsess->gui->is_tab and sess->gui->is_tab.
+			 */
+			mg_bring_tofront_sess(newsess);
+			return 0;
+		}
+		else
+			return 1;
+	}
+
 	for (i = 0; i < len; i++)
 	{
 		if (d1[i] < '0' || d1[i] > '9')
diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c
index a52aa9d4..388ca97d 100644
--- a/src/fe-gtk/maingui.c
+++ b/src/fe-gtk/maingui.c
@@ -307,6 +307,7 @@ fe_set_tab_color (struct session *sess, int col)
 				
 			break;
 		}
+		lastact_update (sess);
 	}
 }
 
@@ -604,6 +605,7 @@ mg_focus (session *sess)
 		sess->nick_said = FALSE;
 		sess->msg_said = FALSE;
 		sess->new_data = FALSE;
+		lastact_update (sess);
 		/* when called via mg_changui_new, is_tab might be true, but
 			sess->res->tab is still NULL. */
 		if (sess->res->tab)