summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-08-03 22:54:08 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-08-03 22:54:08 +0000
commitce0bd80b05fb368d1e80d8c289b8579160ce0d2f (patch)
treea96fa4464efb5cd4bd5a30febaf481323778994a /src
parentdaaf2756cafcb81e11e4246005b01e2d39b1caeb (diff)
downloadirssi-ce0bd80b05fb368d1e80d8c289b8579160ce0d2f.zip
Added sticky window information to /WINDOW.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1701 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/core/fe-windows.c2
-rw-r--r--src/fe-common/core/fe-windows.h1
-rw-r--r--src/fe-common/core/window-commands.c2
-rw-r--r--src/fe-text/mainwindows.c40
-rw-r--r--src/fe-text/module-formats.c1
-rw-r--r--src/fe-text/module-formats.h3
6 files changed, 47 insertions, 2 deletions
diff --git a/src/fe-common/core/fe-windows.c b/src/fe-common/core/fe-windows.c
index a79f99b3..01aae056 100644
--- a/src/fe-common/core/fe-windows.c
+++ b/src/fe-common/core/fe-windows.c
@@ -376,7 +376,7 @@ int windows_refnum_last(void)
return max;
}
-static int window_refnum_cmp(WINDOW_REC *w1, WINDOW_REC *w2)
+int window_refnum_cmp(WINDOW_REC *w1, WINDOW_REC *w2)
{
return w1->refnum < w2->refnum ? -1 : 1;
}
diff --git a/src/fe-common/core/fe-windows.h b/src/fe-common/core/fe-windows.h
index 7de6fc5a..796285a8 100644
--- a/src/fe-common/core/fe-windows.h
+++ b/src/fe-common/core/fe-windows.h
@@ -78,6 +78,7 @@ int window_refnum_prev(int refnum, int wrap);
int window_refnum_next(int refnum, int wrap);
int windows_refnum_last(void);
+int window_refnum_cmp(WINDOW_REC *w1, WINDOW_REC *w2);
GSList *windows_get_sorted(void);
WINDOW_BIND_REC *window_bind_add(WINDOW_REC *window, const char *servertag,
diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c
index 9cf917fb..960e9cfa 100644
--- a/src/fe-common/core/window-commands.c
+++ b/src/fe-common/core/window-commands.c
@@ -136,6 +136,8 @@ static void cmd_window_info(WINDOW_REC *win)
if (win->items != NULL)
window_print_items(win);
+ signal_emit("window print info", 1, win);
+
printformat_window(win, MSGLEVEL_CLIENTCRAP,
TXT_WINDOW_INFO_FOOTER);
}
diff --git a/src/fe-text/mainwindows.c b/src/fe-text/mainwindows.c
index 63820894..6fa37fac 100644
--- a/src/fe-text/mainwindows.c
+++ b/src/fe-text/mainwindows.c
@@ -848,6 +848,44 @@ static void cmd_window_stick(const char *data)
}
}
+static void windows_print_sticky(MAIN_WINDOW_REC *win)
+{
+ GSList *tmp, *sorted;
+ GString *str;
+
+ /* sort the sticky windows */
+ sorted = NULL;
+ for (tmp = win->sticky_windows; tmp != NULL; tmp = tmp->next) {
+ WINDOW_REC *rec = tmp->data;
+
+ sorted = g_slist_insert_sorted(sorted, rec, (GCompareFunc)
+ window_refnum_cmp);
+ }
+
+ /* convert to string */
+ str = g_string_new(NULL);
+ while (sorted != NULL) {
+ WINDOW_REC *rec = sorted->data;
+
+ g_string_sprintfa(str, "#%d, ", rec->refnum);
+ sorted = g_slist_remove(sorted, rec);
+ }
+ g_string_truncate(str, str->len-2);
+
+ printformat_window(win->active, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_STICKY, str->str);
+ g_string_free(str, TRUE);
+}
+
+static void sig_window_print_info(WINDOW_REC *win)
+{
+ MAIN_WINDOW_REC *mainwin;
+
+ mainwin = WINDOW_GUI(win)->parent;
+ if (mainwin->sticky_windows != NULL)
+ windows_print_sticky(mainwin);
+}
+
void mainwindows_init(void)
{
old_screen_width = screen_width;
@@ -871,6 +909,7 @@ void mainwindows_init(void)
command_bind("window left", NULL, (SIGNAL_FUNC) cmd_window_left);
command_bind("window right", NULL, (SIGNAL_FUNC) cmd_window_right);
command_bind("window stick", NULL, (SIGNAL_FUNC) cmd_window_stick);
+ signal_add("window print info", (SIGNAL_FUNC) sig_window_print_info);
}
void mainwindows_deinit(void)
@@ -889,4 +928,5 @@ void mainwindows_deinit(void)
command_unbind("window left", (SIGNAL_FUNC) cmd_window_left);
command_unbind("window right", (SIGNAL_FUNC) cmd_window_right);
command_unbind("window stick", (SIGNAL_FUNC) cmd_window_stick);
+ signal_remove("window print info", (SIGNAL_FUNC) sig_window_print_info);
}
diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c
index be3c0eab..248bd03e 100644
--- a/src/fe-text/module-formats.c
+++ b/src/fe-text/module-formats.c
@@ -37,6 +37,7 @@ FORMAT_REC gui_text_formats[] =
{ "window_not_sticky", "Window is not sticky", 0 },
{ "window_set_sticky", "Window set sticky", 0 },
{ "window_unset_sticky", "Window is not sticky anymore", 0 },
+ { "window_info_sticky", "Sticky : $0", 1, { 0 } },
{ NULL, NULL, 0 }
};
diff --git a/src/fe-text/module-formats.h b/src/fe-text/module-formats.h
index fe33c8e2..055b2b04 100644
--- a/src/fe-text/module-formats.h
+++ b/src/fe-text/module-formats.h
@@ -14,7 +14,8 @@ enum {
TXT_CANT_SHOW_STICKY_WINDOWS,
TXT_WINDOW_NOT_STICKY,
TXT_WINDOW_SET_STICKY,
- TXT_WINDOW_UNSET_STICKY
+ TXT_WINDOW_UNSET_STICKY,
+ TXT_WINDOW_INFO_STICKY
};
extern FORMAT_REC gui_text_formats[];