Mercurial > pidgin.yaz
annotate finch/libgnt/wms/irssi.c @ 18074:7e309149360f
Make the irssi wm work.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 10 Jun 2007 15:16:53 +0000 |
parents | 08e93462f189 |
children | f52def9dc7c9 |
rev | line source |
---|---|
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 /** |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
2 * 1. Buddylist is aligned on the left. |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
3 * 2. The rest of the screen is split into MxN grid for conversation windows. |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
4 * - M = irssi-split-h in ~/.gntrc:[general] |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
5 * - N = irssi-split-v in ~/.gntrc:[general] |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
6 * - Press alt-shift-k/j/l/h to move the selected window to the frame |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
7 * above/below/left/right of the current frame. |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 * 3. All the other windows are always centered. |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 */ |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
10 #include <stdlib.h> |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 #include <string.h> |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 #include <sys/types.h> |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 #include "gnt.h" |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 #include "gntbox.h" |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 #include "gntmenu.h" |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 #include "gntstyle.h" |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 #include "gntwm.h" |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 #include "gntwindow.h" |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 #include "gntlabel.h" |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 #define TYPE_IRSSI (irssi_get_gtype()) |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 typedef struct _Irssi |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 GntWM inherit; |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
27 int vert; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
28 int horiz; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
29 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
30 /* This is changed whenever the buddylist is opened/closed or resized. */ |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
31 int buddylistwidth; |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 } Irssi; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 typedef struct _IrssiClass |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 GntWMClass inherit; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 } IrssiClass; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 GType irssi_get_gtype(void); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 void gntwm_init(GntWM **wm); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 static void (*org_new_window)(GntWM *wm, GntWidget *win); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
44 static void |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
45 get_xywh_for_frame(Irssi *irssi, int hor, int vert, int *x, int *y, int *w, int *h) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
46 { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
47 int width, height, rx, ry; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
48 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
49 width = (getmaxx(stdscr) - irssi->buddylistwidth) / irssi->horiz; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
50 height = (getmaxy(stdscr) - 1) / irssi->vert; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
51 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
52 rx = irssi->buddylistwidth; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
53 if (hor) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
54 rx += hor * width; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
55 rx++; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
56 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
57 ry = 0; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
58 if (vert) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
59 ry += vert * height + 1; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
60 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
61 if (x) *x = rx; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
62 if (y) *y = ry; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
63 if (w) { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
64 *w = (hor == irssi->horiz - 1) ? (getmaxx(stdscr) - rx) : (width - 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
65 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
66 if (h) { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
67 *h = (vert == irssi->vert - 1) ? (getmaxy(stdscr) - 1 - ry) : (height - !!vert); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
68 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
69 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
70 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
71 static void |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
72 draw_line_separators(Irssi *irssi) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
73 { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
74 int x, y; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
75 int width, height; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
76 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
77 wclear(stdscr); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
78 /* Draw the separator for the buddylist */ |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
79 if (irssi->buddylistwidth) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
80 mvwvline(stdscr, 0, irssi->buddylistwidth, |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
81 ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), getmaxy(stdscr) - 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
82 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
83 /* Now the separators for the conversation windows */ |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
84 width = (getmaxx(stdscr) - irssi->buddylistwidth) / irssi->horiz; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
85 height = (getmaxy(stdscr) - 1) / irssi->vert; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
86 for (x = 1; x < irssi->horiz; x++) { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
87 mvwvline(stdscr, 0, irssi->buddylistwidth + x * width, |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
88 ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), getmaxy(stdscr) - 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
89 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
90 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
91 for (y = 1; y < irssi->vert; y++) { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
92 mvwhline(stdscr, y * height, irssi->buddylistwidth + 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
93 getmaxx(stdscr) - irssi->buddylistwidth); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
94 for (x = 1; x < irssi->horiz; x++) { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
95 mvwaddch(stdscr, y * height, x * width + irssi->buddylistwidth, ACS_PLUS | COLOR_PAIR(GNT_COLOR_NORMAL)); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
96 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
97 if (irssi->buddylistwidth) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
98 mvwaddch(stdscr, y * height, irssi->buddylistwidth, ACS_LTEE | COLOR_PAIR(GNT_COLOR_NORMAL)); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
99 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
100 } |
17991
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
101 |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
102 static gboolean |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
103 is_budddylist(GntWidget *win) |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 { |
17991
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
105 const char *name = gnt_widget_get_name(win); |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
106 if (name && strcmp(name, "buddylist") == 0) |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
107 return TRUE; |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
108 return FALSE; |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 static void |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 remove_border_set_position_size(GntWM *wm, GntWidget *win, int x, int y, int w, int h) |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 gnt_box_set_toplevel(GNT_BOX(win), FALSE); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_CAN_TAKE_FOCUS); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 gnt_widget_set_position(win, x, y); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 mvwin(win->window, y, x); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 gnt_widget_set_size(win, (w < 0) ? -1 : w + 2, h + 2); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 static void |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 irssi_new_window(GntWM *wm, GntWidget *win) |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 const char *name; |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
126 int x, y, w, h; |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 name = gnt_widget_get_name(win); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 if (!name || strcmp(name, "conversation-window")) { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 if (!GNT_IS_MENU(win) && !GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 if ((!name || strcmp(name, "buddylist"))) { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 gnt_widget_get_size(win, &w, &h); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 x = (getmaxx(stdscr) - w) / 2; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 y = (getmaxy(stdscr) - h) / 2; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 gnt_widget_set_position(win, x, y); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 mvwin(win->window, y, x); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 } else { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 remove_border_set_position_size(wm, win, 0, 0, -1, getmaxy(stdscr) - 1); |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
139 gnt_widget_get_size(win, &((Irssi*)wm)->buddylistwidth, NULL); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
140 draw_line_separators((Irssi*)wm); |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 org_new_window(wm, win); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 return; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 |
17991
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
147 /* The window we have here is a conversation window. */ |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
148 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
149 /* XXX: There should be some way to remember which frame a conversation window |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
150 * was in the last time. Perhaps save them in some ~/.gntpositionirssi or some |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
151 * such. */ |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
152 get_xywh_for_frame((Irssi*)wm, 0, 0, &x, &y, &w, &h); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
153 remove_border_set_position_size(wm, win, x, y, w, h); |
17991
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
154 org_new_window(wm, win); |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
155 } |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
156 |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
157 static void |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
158 irssi_window_resized(GntWM *wm, GntNode *node) |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
159 { |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
160 if (!is_budddylist(node->me)) |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
161 return; |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
163 gnt_widget_get_size(node->me, &((Irssi*)wm)->buddylistwidth, NULL); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
164 draw_line_separators((Irssi*)wm); |
17991
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
165 } |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
166 |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
167 static gboolean |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
168 irssi_close_window(GntWM *wm, GntWidget *win) |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
169 { |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
170 if (is_budddylist(win)) |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
171 ((Irssi*)wm)->buddylistwidth = 0; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
172 return FALSE; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
173 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
174 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
175 static gboolean |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
176 update_conv_window_title(GntNode *node) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
177 { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
178 char title[256]; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
179 snprintf(title, sizeof(title), "%d: %s", |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
180 (int)g_object_get_data(G_OBJECT(node->me), "irssi-index") + 1, GNT_BOX(node->me)->title); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
181 wbkgdset(node->window, '\0' | COLOR_PAIR(gnt_widget_has_focus(node->me) ? GNT_COLOR_TITLE : GNT_COLOR_TITLE_D)); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
182 mvwaddstr(node->window, 0, 0, title); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
183 update_panels(); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
184 doupdate(); |
17991
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
185 return FALSE; |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
186 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
187 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
188 static void |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
189 irssi_update_window(GntWM *wm, GntNode *node) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
190 { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
191 GntWidget *win = node->me; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
192 const char *name = gnt_widget_get_name(win); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
193 if (!name || !GNT_IS_BOX(win) || strcmp(name, "conversation-window")) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
194 return; |
18074
7e309149360f
Make the irssi wm work.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
195 g_object_set_data(G_OBJECT(win), "irssi-index", GINT_TO_POINTER(g_list_index(wm->cws->list, win))); |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
196 g_timeout_add(0, (GSourceFunc)update_conv_window_title, node); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
197 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
198 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
199 static void |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
200 find_window_position(Irssi *irssi, GntWidget *win, int *h, int *v) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
201 { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
202 int x, y; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
203 int width, height; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
204 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
205 gnt_widget_get_position(win, &x, &y); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
206 width = (getmaxx(stdscr) - irssi->buddylistwidth) / irssi->horiz; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
207 height = (getmaxy(stdscr) - 1) / irssi->vert; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
208 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
209 if (h) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
210 *h = (x - irssi->buddylistwidth) / width; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
211 if (v) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
212 *v = y / height; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
213 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
214 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
215 static gboolean |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
216 move_direction(GntBindable *bindable, GList *list) |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
217 { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
218 GntWM *wm = GNT_WM(bindable); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
219 Irssi *irssi = (Irssi*)wm; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
220 int vert, hor; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
221 int x, y, w, h; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
222 GntWidget *win; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
223 |
18074
7e309149360f
Make the irssi wm work.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18045
diff
changeset
|
224 if (wm->cws->ordered == NULL || is_budddylist(win = GNT_WIDGET(wm->cws->ordered->data))) |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
225 return FALSE; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
226 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
227 find_window_position(irssi, win, &hor, &vert); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
228 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
229 switch ((int)list->data) { |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
230 case 'k': |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
231 vert = MAX(0, vert - 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
232 break; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
233 case 'j': |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
234 vert = MIN(vert + 1, irssi->vert - 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
235 break; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
236 case 'l': |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
237 hor = MIN(hor + 1, irssi->horiz - 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
238 break; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
239 case 'h': |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
240 hor = MAX(0, hor - 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
241 break; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
242 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
243 get_xywh_for_frame(irssi, hor, vert, &x, &y, &w, &h); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
244 gnt_wm_move_window(wm, win, x, y); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
245 gnt_wm_resize_window(wm, win, w, h); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
246 return TRUE; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
247 } |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
248 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
249 static void |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 irssi_class_init(IrssiClass *klass) |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
251 { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 GntWMClass *pclass = GNT_WM_CLASS(klass); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 org_new_window = pclass->new_window; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 pclass->new_window = irssi_new_window; |
17991
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
257 pclass->window_resized = irssi_window_resized; |
386047fb178b
Draw a separator line between the buddylist and the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17989
diff
changeset
|
258 pclass->close_window = irssi_close_window; |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
259 pclass->window_update = irssi_update_window; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
260 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
261 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "move-up", move_direction, |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
262 "\033" "K", GINT_TO_POINTER('k'), NULL); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
263 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "move-down", move_direction, |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
264 "\033" "J", GINT_TO_POINTER('j'), NULL); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
265 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "move-right", move_direction, |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
266 "\033" "L", GINT_TO_POINTER('l'), NULL); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
267 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "move-left", move_direction, |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
268 "\033" "H", GINT_TO_POINTER('h'), NULL); |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
269 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
270 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 GNTDEBUG; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
274 void gntwm_init(GntWM **wm) |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
275 { |
18045
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
276 const char *style = NULL; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
277 Irssi *irssi; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
278 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
279 irssi = g_object_new(TYPE_IRSSI, NULL); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
280 *wm = GNT_WM(irssi); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
281 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
282 style = gnt_style_get_from_name("irssi-split-v"); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
283 irssi->vert = style ? atoi(style) : 1; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
284 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
285 style = gnt_style_get_from_name("irssi-split-h"); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
286 irssi->horiz = style ? atoi(style) : 1; |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
287 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
288 irssi->vert = MAX(irssi->vert, 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
289 irssi->horiz = MAX(irssi->horiz, 1); |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
290 |
08e93462f189
Update the irssi WM to allow tiling the conversation windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17991
diff
changeset
|
291 irssi->buddylistwidth = 0; |
17989
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
292 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
293 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
294 GType irssi_get_gtype(void) |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
295 { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
296 static GType type = 0; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
297 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
298 if(type == 0) { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
299 static const GTypeInfo info = { |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
300 sizeof(IrssiClass), |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
301 NULL, /* base_init */ |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
302 NULL, /* base_finalize */ |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
303 (GClassInitFunc)irssi_class_init, |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
304 NULL, |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
305 NULL, /* class_data */ |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
306 sizeof(Irssi), |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
307 0, /* n_preallocs */ |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
308 NULL, /* instance_init */ |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
309 NULL |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
310 }; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
311 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
312 type = g_type_register_static(GNT_TYPE_WM, |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
313 "GntIrssi", |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
314 &info, 0); |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
315 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
316 |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
317 return type; |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
318 } |
1bccb9641ef3
Add a new WM, irssi. Put the wm's in $(libdir)/gnt instead of in /finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
319 |