Implement undo tab close
Signed-off-by: Eduardo Lima (Etrunko) <eblima@gmail.com>
This commit is contained in:
parent
2a3e66a764
commit
007299bb52
@ -70,7 +70,7 @@ void key_action_tab_clean (void);
|
||||
*/
|
||||
|
||||
/* Remember that the *number* of actions is this *plus* 1 --AGL */
|
||||
#define KEY_MAX_ACTIONS 14
|
||||
#define KEY_MAX_ACTIONS 15
|
||||
|
||||
struct key_binding
|
||||
{
|
||||
@ -132,6 +132,9 @@ static int key_action_move_tab_family_right (GtkWidget * wid, GdkEventKey * evt,
|
||||
static int key_action_put_history (GtkWidget * wid, GdkEventKey * evt,
|
||||
char *d1, char *d2,
|
||||
struct session *sess);
|
||||
static int key_action_undo_tab_close (GtkWidget * wid, GdkEventKey * evt,
|
||||
char *d1, char *d2,
|
||||
struct session *sess);
|
||||
|
||||
static GSList *keybind_list = NULL;
|
||||
|
||||
@ -167,6 +170,8 @@ static const struct key_action key_actions[KEY_MAX_ACTIONS + 1] = {
|
||||
N_("This command moves the current tab family to the right")},
|
||||
{key_action_put_history, "Push input line into history",
|
||||
N_("Push input line into history but doesn't send to server")},
|
||||
{key_action_undo_tab_close, "Undo tab close",
|
||||
N_("Undo tab close")},
|
||||
};
|
||||
|
||||
#define default_kb_cfg \
|
||||
@ -208,7 +213,8 @@ static const struct key_action key_actions[KEY_MAX_ACTIONS + 1] = {
|
||||
"ACCEL=<Alt>Right\nMove front tab right\nD1!\nD2!\n\n"\
|
||||
"ACCEL=<Primary><Shift>Page_Up\nMove tab family left\nD1!\nD2!\n\n"\
|
||||
"ACCEL=<Primary><Shift>Page_Down\nMove tab family right\nD1!\nD2!\n\n"\
|
||||
"ACCEL=F9\nRun Command\nD1:/GUI MENU TOGGLE\nD2!\n\n"
|
||||
"ACCEL=F9\nRun Command\nD1:/GUI MENU TOGGLE\nD2!\n\n"\
|
||||
"ACCEL=<Primary><Shift>t\nUndo tab close\nD1:!\nD2!\n\n"\
|
||||
|
||||
void
|
||||
key_init ()
|
||||
@ -1771,6 +1777,14 @@ key_action_put_history (GtkWidget * wid, GdkEventKey * ent, char *d1,
|
||||
return 2; /* -''- */
|
||||
}
|
||||
|
||||
static int
|
||||
key_action_undo_tab_close (GtkWidget * wid, GdkEventKey * ent, char *d1,
|
||||
char *d2, struct session *sess)
|
||||
{
|
||||
mg_undo_tab_close (sess);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
/* -------- */
|
||||
|
||||
|
@ -1051,6 +1051,14 @@ mg_tab_close_cb (GtkWidget *dialog, gint arg1, session *sess)
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct closed_channel {
|
||||
server *server;
|
||||
char channel[CHANLEN];
|
||||
char key[64];
|
||||
} closed_channel;
|
||||
|
||||
static GQueue closed_channels = G_QUEUE_INIT;
|
||||
|
||||
void
|
||||
mg_tab_close (session *sess)
|
||||
{
|
||||
@ -1058,6 +1066,24 @@ mg_tab_close (session *sess)
|
||||
GSList *list;
|
||||
int i;
|
||||
|
||||
if (hexchat_is_quitting)
|
||||
{
|
||||
closed_channel *chan;
|
||||
while (!g_queue_is_empty(&closed_channels))
|
||||
{
|
||||
chan = g_queue_pop_head(&closed_channels);
|
||||
g_free(chan);
|
||||
}
|
||||
}
|
||||
else if (is_channel (sess->server, sess->channel))
|
||||
{
|
||||
closed_channel *chan = g_new0(closed_channel, 1);
|
||||
chan->server = sess->server;
|
||||
g_strlcpy(chan->channel, sess->channel, CHANLEN);
|
||||
g_strlcpy(chan->key, sess->channelkey, 64);
|
||||
g_queue_push_head(&closed_channels, chan);
|
||||
}
|
||||
|
||||
if (chan_remove (sess->res->tab, FALSE))
|
||||
{
|
||||
sess->res->tab = NULL;
|
||||
@ -1089,6 +1115,21 @@ mg_tab_close (session *sess)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mg_undo_tab_close (session *sess)
|
||||
{
|
||||
closed_channel *chan;
|
||||
|
||||
if (g_queue_is_empty(&closed_channels))
|
||||
return;
|
||||
|
||||
chan = g_queue_pop_head(&closed_channels);
|
||||
if (is_server (chan->server))
|
||||
chan->server->p_join (chan->server, chan->channel, chan->key);
|
||||
|
||||
g_free(chan);
|
||||
}
|
||||
|
||||
static void
|
||||
mg_menu_destroy (GtkWidget *menu, gpointer userdata)
|
||||
{
|
||||
|
@ -39,6 +39,7 @@ void mg_set_access_icon (session_gui *gui, GdkPixbuf *pix, gboolean away);
|
||||
void mg_apply_setup (void);
|
||||
void mg_close_sess (session *);
|
||||
void mg_tab_close (session *sess);
|
||||
void mg_undo_tab_close (session *sess);
|
||||
void mg_detach (session *sess, int mode);
|
||||
void mg_progressbar_create (session_gui *gui);
|
||||
void mg_progressbar_destroy (session_gui *gui);
|
||||
|
Loading…
Reference in New Issue
Block a user