mirror of
https://github.com/irssi/irssi.git
synced 2026-08-20 17:12:51 +02:00
sort windows_seq helpers to top
This commit is contained in:
parent
03f5dc63fe
commit
9a018a782c
1 changed files with 42 additions and 42 deletions
|
|
@ -42,6 +42,12 @@ static int daytag;
|
||||||
static int daycheck; /* 0 = don't check, 1 = time is 00:00, check,
|
static int daycheck; /* 0 = don't check, 1 = time is 00:00, check,
|
||||||
2 = time is 00:00, already checked */
|
2 = time is 00:00, already checked */
|
||||||
|
|
||||||
|
static int window_refnum_lookup(WINDOW_REC *window, void *refnum_p)
|
||||||
|
{
|
||||||
|
int refnum = GPOINTER_TO_INT(refnum_p);
|
||||||
|
return window->refnum == refnum ? 0 : window->refnum < refnum ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
static GSequenceIter *windows_seq_begin(void)
|
static GSequenceIter *windows_seq_begin(void)
|
||||||
{
|
{
|
||||||
return g_sequence_get_begin_iter(windows_seq);
|
return g_sequence_get_begin_iter(windows_seq);
|
||||||
|
|
@ -52,6 +58,42 @@ static GSequenceIter *windows_seq_end(void)
|
||||||
return g_sequence_get_end_iter(windows_seq);
|
return g_sequence_get_end_iter(windows_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GSequenceIter *windows_seq_insert(WINDOW_REC *rec)
|
||||||
|
{
|
||||||
|
return g_sequence_insert_sorted(windows_seq, rec, (GCompareDataFunc)window_refnum_cmp, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GSequenceIter *windows_seq_refnum_lookup(int refnum)
|
||||||
|
{
|
||||||
|
return g_sequence_lookup(windows_seq, GINT_TO_POINTER(refnum), (GCompareDataFunc)window_refnum_lookup, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void windows_seq_changed(GSequenceIter *iter)
|
||||||
|
{
|
||||||
|
g_sequence_sort_changed(iter, (GCompareDataFunc)window_refnum_cmp, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GSequenceIter *windows_seq_window_lookup(WINDOW_REC *rec)
|
||||||
|
{
|
||||||
|
return g_sequence_lookup(windows_seq, rec, (GCompareDataFunc)window_refnum_cmp, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* search to the numerically right iterator of refnum */
|
||||||
|
static GSequenceIter *windows_seq_refnum_search_right(int refnum)
|
||||||
|
{
|
||||||
|
return g_sequence_search(windows_seq, GINT_TO_POINTER(refnum), (GCompareDataFunc)window_refnum_lookup, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we want to find the numerically left iterator of refnum, so we
|
||||||
|
search the right of the previous refnum. but we need to figure out
|
||||||
|
the case where the iterator is already at the beginning, i.e
|
||||||
|
iter->refnum >= refnum */
|
||||||
|
static GSequenceIter *windows_seq_refnum_search_left(int refnum)
|
||||||
|
{
|
||||||
|
GSequenceIter *iter = windows_seq_refnum_search_right(refnum - 1);
|
||||||
|
return iter == windows_seq_begin() ? NULL : g_sequence_iter_prev(iter);
|
||||||
|
}
|
||||||
|
|
||||||
static int window_get_new_refnum(void)
|
static int window_get_new_refnum(void)
|
||||||
{
|
{
|
||||||
WINDOW_REC *win;
|
WINDOW_REC *win;
|
||||||
|
|
@ -75,11 +117,6 @@ static int window_get_new_refnum(void)
|
||||||
return refnum;
|
return refnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSequenceIter *windows_seq_insert(WINDOW_REC *rec)
|
|
||||||
{
|
|
||||||
return g_sequence_insert_sorted(windows_seq, rec, (GCompareDataFunc)window_refnum_cmp, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
|
WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
|
||||||
{
|
{
|
||||||
WINDOW_REC *rec;
|
WINDOW_REC *rec;
|
||||||
|
|
@ -114,22 +151,6 @@ static void window_set_refnum0(WINDOW_REC *window, int refnum)
|
||||||
signal_emit("window refnum changed", 2, window, GINT_TO_POINTER(old_refnum));
|
signal_emit("window refnum changed", 2, window, GINT_TO_POINTER(old_refnum));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int window_refnum_lookup(WINDOW_REC *window, void *refnum_p)
|
|
||||||
{
|
|
||||||
int refnum = GPOINTER_TO_INT(refnum_p);
|
|
||||||
return window->refnum == refnum ? 0 : window->refnum < refnum ? -1 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GSequenceIter *windows_seq_refnum_lookup(int refnum)
|
|
||||||
{
|
|
||||||
return g_sequence_lookup(windows_seq, GINT_TO_POINTER(refnum), (GCompareDataFunc)window_refnum_lookup, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void windows_seq_changed(GSequenceIter *iter)
|
|
||||||
{
|
|
||||||
g_sequence_sort_changed(iter, (GCompareDataFunc)window_refnum_cmp, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* removed_refnum was removed from the windows list, pack the windows so
|
/* removed_refnum was removed from the windows list, pack the windows so
|
||||||
there won't be any holes. If there is any holes after removed_refnum,
|
there won't be any holes. If there is any holes after removed_refnum,
|
||||||
leave the windows behind it alone. */
|
leave the windows behind it alone. */
|
||||||
|
|
@ -155,11 +176,6 @@ static void windows_pack(int removed_refnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSequenceIter *windows_seq_window_lookup(WINDOW_REC *rec)
|
|
||||||
{
|
|
||||||
return g_sequence_lookup(windows_seq, rec, (GCompareDataFunc)window_refnum_cmp, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void window_destroy(WINDOW_REC *window)
|
void window_destroy(WINDOW_REC *window)
|
||||||
{
|
{
|
||||||
GSequenceIter *iter;
|
GSequenceIter *iter;
|
||||||
|
|
@ -466,22 +482,6 @@ WINDOW_REC *window_find_item(SERVER_REC *server, const char *name)
|
||||||
return window_item_window(item);
|
return window_item_window(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search to the numerically right iterator of refnum */
|
|
||||||
static GSequenceIter *windows_seq_refnum_search_right(int refnum)
|
|
||||||
{
|
|
||||||
return g_sequence_search(windows_seq, GINT_TO_POINTER(refnum), (GCompareDataFunc)window_refnum_lookup, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we want to find the numerically left iterator of refnum, so we
|
|
||||||
search the right of the previous refnum. but we need to figure out
|
|
||||||
the case where the iterator is already at the beginning, i.e
|
|
||||||
iter->refnum >= refnum */
|
|
||||||
static GSequenceIter *windows_seq_refnum_search_left(int refnum)
|
|
||||||
{
|
|
||||||
GSequenceIter *iter = windows_seq_refnum_search_right(refnum - 1);
|
|
||||||
return iter == windows_seq_begin() ? NULL : g_sequence_iter_prev(iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
int window_refnum_prev(int refnum, int wrap)
|
int window_refnum_prev(int refnum, int wrap)
|
||||||
{
|
{
|
||||||
WINDOW_REC *rec;
|
WINDOW_REC *rec;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue