Mercurial > pidgin.yaz
annotate finch/libgnt/gntwm.c @ 18367:1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 30 Jun 2007 01:45:21 +0000 |
parents | d359e5f3ee87 |
children | 93c5c785a811 |
rev | line source |
---|---|
18049
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
1 /** |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
3 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
6 * source distribution. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
7 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
11 * (at your option) any later version. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
12 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
16 * GNU General Public License for more details. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
17 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
21 */ |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
22 |
15818 | 23 #define _GNU_SOURCE |
17528
c0c17a81f5fe
Fix libgnt compilation on BSD and solaris. This references #516.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17251
diff
changeset
|
24 #if defined(__APPLE__) || defined(__unix__) |
15818 | 25 #define _XOPEN_SOURCE_EXTENDED |
26 #endif | |
27 | |
28 #include "config.h" | |
29 | |
30 #include <ctype.h> | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
31 #include <glib/gprintf.h> |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
32 #include <gmodule.h> |
15818 | 33 #include <stdlib.h> |
34 #include <string.h> | |
35 #include <time.h> | |
36 | |
37 #include "gntwm.h" | |
38 #include "gntstyle.h" | |
39 #include "gntmarshal.h" | |
40 #include "gnt.h" | |
41 #include "gntbox.h" | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
42 #include "gntlabel.h" |
15818 | 43 #include "gntmenu.h" |
44 #include "gnttextview.h" | |
45 #include "gnttree.h" | |
46 #include "gntutils.h" | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
47 #include "gntwindow.h" |
15818 | 48 |
49 #define IDLE_CHECK_INTERVAL 5 /* 5 seconds */ | |
50 | |
51 enum | |
52 { | |
53 SIG_NEW_WIN, | |
54 SIG_DECORATE_WIN, | |
55 SIG_CLOSE_WIN, | |
56 SIG_CONFIRM_RESIZE, | |
57 SIG_RESIZED, | |
58 SIG_CONFIRM_MOVE, | |
59 SIG_MOVED, | |
60 SIG_UPDATE_WIN, | |
61 SIG_GIVE_FOCUS, | |
62 SIG_KEY_PRESS, | |
63 SIG_MOUSE_CLICK, | |
18367
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
64 SIG_TERMINAL_REFRESH, |
15818 | 65 SIGS |
66 }; | |
67 | |
68 static guint signals[SIGS] = { 0 }; | |
69 static void gnt_wm_new_window_real(GntWM *wm, GntWidget *widget); | |
70 static void gnt_wm_win_resized(GntWM *wm, GntNode *node); | |
71 static void gnt_wm_win_moved(GntWM *wm, GntNode *node); | |
72 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget); | |
73 static void update_window_in_list(GntWM *wm, GntWidget *wid); | |
74 static void shift_window(GntWM *wm, GntWidget *widget, int dir); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
75 static gboolean workspace_next(GntBindable *wm, GList *n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
76 static gboolean workspace_prev(GntBindable *wm, GList *n); |
15818 | 77 |
17059
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
78 #ifndef NO_WIDECHAR |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
79 static int widestringwidth(wchar_t *wide); |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
80 #endif |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
81 |
15818 | 82 static gboolean write_already(gpointer data); |
83 static int write_timeout; | |
84 static time_t last_active_time; | |
85 static gboolean idle_update; | |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
86 static GList *act = NULL; /* list of WS with unseen activitiy */ |
15818 | 87 |
88 static GList * | |
89 g_list_bring_to_front(GList *list, gpointer data) | |
90 { | |
91 list = g_list_remove(list, data); | |
92 list = g_list_prepend(list, data); | |
93 return list; | |
94 } | |
95 | |
96 static void | |
97 free_node(gpointer data) | |
98 { | |
99 GntNode *node = data; | |
100 hide_panel(node->panel); | |
101 del_panel(node->panel); | |
102 g_free(node); | |
103 } | |
104 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
105 void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
106 gnt_wm_copy_win(GntWidget *widget, GntNode *node) |
15818 | 107 { |
108 WINDOW *src, *dst; | |
109 int shadow; | |
110 if (!node) | |
111 return; | |
112 src = widget->window; | |
113 dst = node->window; | |
114 shadow = gnt_widget_has_shadow(widget) ? 1 : 0; | |
115 copywin(src, dst, node->scroll, 0, 0, 0, getmaxy(dst) - 1, getmaxx(dst) - 1, 0); | |
116 } | |
117 | |
17059
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
118 /** |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
119 * The following is a workaround for a bug in most versions of ncursesw. |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
120 * Read about it in: http://article.gmane.org/gmane.comp.lib.ncurses.bugs/2751 |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
121 * |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
122 * In short, if a panel hides one cell of a multi-cell character, then the rest |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
123 * of the characters in that line get screwed. The workaround here is to erase |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
124 * any such character preemptively. |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
125 * |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
126 * Caveat: If a wide character is erased, and the panel above it is moved enough |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
127 * to expose the entire character, it is not always redrawn. |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
128 */ |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
129 static void |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
130 work_around_for_ncurses_bug() |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
131 { |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
132 #ifndef NO_WIDECHAR |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
133 PANEL *panel = NULL; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
134 while ((panel = panel_below(panel)) != NULL) { |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
135 int sx, ex, sy, ey, w, y; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
136 cchar_t ch; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
137 PANEL *below = panel; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
138 |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
139 sx = panel->win->_begx; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
140 ex = panel->win->_maxx + sx; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
141 sy = panel->win->_begy; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
142 ey = panel->win->_maxy + sy; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
143 |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
144 while ((below = panel_below(below)) != NULL) { |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
145 if (sy > below->win->_begy + below->win->_maxy || |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
146 ey < below->win->_begy) |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
147 continue; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
148 if (sx > below->win->_begx + below->win->_maxx || |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
149 ex < below->win->_begx) |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
150 continue; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
151 for (y = MAX(sy, below->win->_begy); y <= MIN(ey, below->win->_begy + below->win->_maxy); y++) { |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
152 if (mvwin_wch(below->win, y - below->win->_begy, sx - 1 - below->win->_begx, &ch) != OK) |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
153 goto right; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
154 w = widestringwidth(ch.chars); |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
155 if (w > 1 && (ch.attr & 1)) { |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
156 ch.chars[0] = ' '; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
157 ch.attr &= ~ A_CHARTEXT; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
158 mvwadd_wch(below->win, y - below->win->_begy, sx - 1 - below->win->_begx, &ch); |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
159 touchline(below->win, y - below->win->_begy, 1); |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
160 } |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
161 right: |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
162 if (mvwin_wch(below->win, y - below->win->_begy, ex + 1 - below->win->_begx, &ch) != OK) |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
163 continue; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
164 w = widestringwidth(ch.chars); |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
165 if (w > 1 && !(ch.attr & 1)) { |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
166 ch.chars[0] = ' '; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
167 ch.attr &= ~ A_CHARTEXT; |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
168 mvwadd_wch(below->win, y - below->win->_begy, ex + 1 - below->win->_begx, &ch); |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
169 touchline(below->win, y - below->win->_begy, 1); |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
170 } |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
171 } |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
172 } |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
173 } |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
174 #endif |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
175 } |
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
176 |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
177 static void |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
178 update_act_msg() |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
179 { |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
180 GntWidget *label; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
181 GList *iter; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
182 static GntWidget *message = NULL; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
183 GString *text = g_string_new("act: "); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
184 if (message) |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
185 gnt_widget_destroy(message); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
186 if (g_list_length(act) == 0) |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
187 return; |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
188 for (iter = act; iter; iter = iter->next) { |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
189 GntWS *ws = iter->data; |
18070 | 190 g_string_append_printf(text, "%s, ", gnt_ws_get_name(ws)); |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
191 } |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
192 g_string_erase(text, text->len - 2, 2); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
193 message = gnt_vbox_new(FALSE); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
194 label = gnt_label_new_with_format(text->str, GNT_TEXT_FLAG_BOLD | GNT_TEXT_FLAG_HIGHLIGHT); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
195 GNT_WIDGET_UNSET_FLAGS(GNT_BOX(message), GNT_WIDGET_CAN_TAKE_FOCUS); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
196 GNT_WIDGET_SET_FLAGS(GNT_BOX(message), GNT_WIDGET_TRANSIENT); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
197 gnt_box_add_widget(GNT_BOX(message), label); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
198 gnt_widget_set_name(message, "wm-message"); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
199 gnt_widget_set_position(message, 0, 0); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
200 gnt_widget_draw(message); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
201 g_string_free(text, TRUE); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
202 } |
17075
4d4a396a478c
propagate from branch 'im.pidgin.pidgin' (head 6f6e8345100a2f026e20c28fa52592fadd9c8193)
Richard Nelson <wabz@pidgin.im>
diff
changeset
|
203 |
15818 | 204 static gboolean |
205 update_screen(GntWM *wm) | |
206 { | |
207 if (wm->menu) { | |
208 GntMenu *top = wm->menu; | |
209 while (top) { | |
210 GntNode *node = g_hash_table_lookup(wm->nodes, top); | |
211 if (node) | |
212 top_panel(node->panel); | |
213 top = top->submenu; | |
214 } | |
215 } | |
17059
f1abdde52538
A workaround for an ncurses bug about multi-cell characters and panels.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16526
diff
changeset
|
216 work_around_for_ncurses_bug(); |
15818 | 217 update_panels(); |
218 doupdate(); | |
219 return TRUE; | |
220 } | |
221 | |
222 static gboolean | |
223 sanitize_position(GntWidget *widget, int *x, int *y) | |
224 { | |
225 int X_MAX = getmaxx(stdscr); | |
226 int Y_MAX = getmaxy(stdscr) - 1; | |
227 int w, h; | |
228 int nx, ny; | |
229 gboolean changed = FALSE; | |
230 | |
231 gnt_widget_get_size(widget, &w, &h); | |
232 if (x) { | |
233 if (*x + w > X_MAX) { | |
234 nx = MAX(0, X_MAX - w); | |
235 if (nx != *x) { | |
236 *x = nx; | |
237 changed = TRUE; | |
238 } | |
239 } | |
240 } | |
241 if (y) { | |
242 if (*y + h > Y_MAX) { | |
243 ny = MAX(0, Y_MAX - h); | |
244 if (ny != *y) { | |
245 *y = ny; | |
246 changed = TRUE; | |
247 } | |
248 } | |
249 } | |
250 return changed; | |
251 } | |
252 | |
253 static void | |
254 refresh_node(GntWidget *widget, GntNode *node, gpointer null) | |
255 { | |
256 int x, y, w, h; | |
257 int nw, nh; | |
258 | |
259 int X_MAX = getmaxx(stdscr); | |
260 int Y_MAX = getmaxy(stdscr) - 1; | |
261 | |
262 gnt_widget_get_position(widget, &x, &y); | |
263 gnt_widget_get_size(widget, &w, &h); | |
264 | |
265 if (sanitize_position(widget, &x, &y)) | |
266 gnt_screen_move_widget(widget, x, y); | |
267 | |
268 nw = MIN(w, X_MAX); | |
269 nh = MIN(h, Y_MAX); | |
270 if (nw != w || nh != h) | |
271 gnt_screen_resize_widget(widget, nw, nh); | |
272 } | |
273 | |
274 static void | |
275 read_window_positions(GntWM *wm) | |
276 { | |
277 #if GLIB_CHECK_VERSION(2,6,0) | |
278 GKeyFile *gfile = g_key_file_new(); | |
279 char *filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL); | |
280 GError *error = NULL; | |
281 char **keys; | |
282 gsize nk; | |
283 | |
284 if (!g_key_file_load_from_file(gfile, filename, G_KEY_FILE_NONE, &error)) { | |
285 g_printerr("GntWM: %s\n", error->message); | |
286 g_error_free(error); | |
287 g_free(filename); | |
288 return; | |
289 } | |
290 | |
291 keys = g_key_file_get_keys(gfile, "positions", &nk, &error); | |
292 if (error) { | |
293 g_printerr("GntWM: %s\n", error->message); | |
294 g_error_free(error); | |
295 error = NULL; | |
296 } else { | |
297 while (nk--) { | |
298 char *title = keys[nk]; | |
299 gsize l; | |
300 char **coords = g_key_file_get_string_list(gfile, "positions", title, &l, NULL); | |
301 if (l == 2) { | |
302 int x = atoi(coords[0]); | |
303 int y = atoi(coords[1]); | |
304 GntPosition *p = g_new0(GntPosition, 1); | |
305 p->x = x; | |
306 p->y = y; | |
307 g_hash_table_replace(wm->positions, g_strdup(title + 1), p); | |
308 } else { | |
309 g_printerr("GntWM: Invalid number of arguments for positioing a window.\n"); | |
310 } | |
311 g_strfreev(coords); | |
312 } | |
313 g_strfreev(keys); | |
314 } | |
315 | |
316 g_free(filename); | |
15964 | 317 g_key_file_free(gfile); |
15818 | 318 #endif |
319 } | |
320 | |
321 static gboolean check_idle(gpointer n) | |
322 { | |
323 if (idle_update) { | |
324 time(&last_active_time); | |
325 idle_update = FALSE; | |
326 } | |
327 return TRUE; | |
328 } | |
329 | |
330 static void | |
331 gnt_wm_init(GTypeInstance *instance, gpointer class) | |
332 { | |
333 GntWM *wm = GNT_WM(instance); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
334 wm->workspaces = NULL; |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
335 wm->name_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
336 wm->title_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
337 gnt_style_read_workspaces(wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
338 if (wm->workspaces == NULL) { |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
339 wm->cws = gnt_ws_new("default"); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
340 gnt_wm_add_workspace(wm, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
341 } else { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
342 wm->cws = wm->workspaces->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
343 } |
15818 | 344 wm->event_stack = FALSE; |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
345 wm->tagged = NULL; |
15818 | 346 wm->windows = NULL; |
347 wm->actions = NULL; | |
348 wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); | |
349 wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
350 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE)) | |
351 read_window_positions(wm); | |
352 g_timeout_add(IDLE_CHECK_INTERVAL * 1000, check_idle, NULL); | |
353 time(&last_active_time); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
354 gnt_wm_switch_workspace(wm, 0); |
15818 | 355 } |
356 | |
357 static void | |
358 switch_window(GntWM *wm, int direction) | |
359 { | |
360 GntWidget *w = NULL, *wid = NULL; | |
361 int pos; | |
362 | |
363 if (wm->_list.window || wm->menu) | |
364 return; | |
365 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
366 if (!wm->cws->ordered || !wm->cws->ordered->next) |
15818 | 367 return; |
368 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
369 w = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
370 pos = g_list_index(wm->cws->list, w); |
15818 | 371 pos += direction; |
372 | |
373 if (pos < 0) | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
374 wid = g_list_last(wm->cws->list)->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
375 else if (pos >= g_list_length(wm->cws->list)) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
376 wid = wm->cws->list->data; |
15818 | 377 else if (pos >= 0) |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
378 wid = g_list_nth_data(wm->cws->list, pos); |
15818 | 379 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
380 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, wid); |
15818 | 381 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
382 gnt_wm_raise_window(wm, wm->cws->ordered->data); |
15818 | 383 |
384 if (w != wid) { | |
385 gnt_widget_set_focus(w, FALSE); | |
386 } | |
387 } | |
388 | |
389 static gboolean | |
390 window_next(GntBindable *bindable, GList *null) | |
391 { | |
392 GntWM *wm = GNT_WM(bindable); | |
393 switch_window(wm, 1); | |
394 return TRUE; | |
395 } | |
396 | |
397 static gboolean | |
398 window_prev(GntBindable *bindable, GList *null) | |
399 { | |
400 GntWM *wm = GNT_WM(bindable); | |
401 switch_window(wm, -1); | |
402 return TRUE; | |
403 } | |
404 | |
405 static gboolean | |
406 switch_window_n(GntBindable *bind, GList *list) | |
407 { | |
408 GntWM *wm = GNT_WM(bind); | |
409 GntWidget *w = NULL; | |
410 GList *l; | |
411 int n; | |
412 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
413 if (!wm->cws->ordered) |
15818 | 414 return TRUE; |
415 | |
416 if (list) | |
417 n = GPOINTER_TO_INT(list->data); | |
418 else | |
419 n = 0; | |
420 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
421 w = wm->cws->ordered->data; |
15818 | 422 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
423 if ((l = g_list_nth(wm->cws->list, n)) != NULL) |
15818 | 424 { |
425 gnt_wm_raise_window(wm, l->data); | |
426 } | |
427 | |
428 if (l && w != l->data) | |
429 { | |
430 gnt_widget_set_focus(w, FALSE); | |
431 } | |
432 return TRUE; | |
433 } | |
434 | |
435 static gboolean | |
436 window_scroll_up(GntBindable *bindable, GList *null) | |
437 { | |
438 GntWM *wm = GNT_WM(bindable); | |
439 GntWidget *window; | |
440 GntNode *node; | |
441 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
442 if (!wm->cws->ordered) |
15818 | 443 return TRUE; |
444 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
445 window = wm->cws->ordered->data; |
15818 | 446 node = g_hash_table_lookup(wm->nodes, window); |
447 if (!node) | |
448 return TRUE; | |
449 | |
450 if (node->scroll) { | |
451 node->scroll--; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
452 gnt_wm_copy_win(window, node); |
15818 | 453 update_screen(wm); |
454 } | |
455 return TRUE; | |
456 } | |
457 | |
458 static gboolean | |
459 window_scroll_down(GntBindable *bindable, GList *null) | |
460 { | |
461 GntWM *wm = GNT_WM(bindable); | |
462 GntWidget *window; | |
463 GntNode *node; | |
464 int w, h; | |
465 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
466 if (!wm->cws->ordered) |
15818 | 467 return TRUE; |
468 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
469 window = wm->cws->ordered->data; |
15818 | 470 node = g_hash_table_lookup(wm->nodes, window); |
471 if (!node) | |
472 return TRUE; | |
473 | |
474 gnt_widget_get_size(window, &w, &h); | |
475 if (h - node->scroll > getmaxy(node->window)) { | |
476 node->scroll++; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
477 gnt_wm_copy_win(window, node); |
15818 | 478 update_screen(wm); |
479 } | |
480 return TRUE; | |
481 } | |
482 | |
483 static gboolean | |
484 window_close(GntBindable *bindable, GList *null) | |
485 { | |
486 GntWM *wm = GNT_WM(bindable); | |
487 | |
488 if (wm->_list.window) | |
489 return TRUE; | |
490 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
491 if (wm->cws->ordered) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
492 gnt_widget_destroy(wm->cws->ordered->data); |
15818 | 493 } |
494 | |
495 return TRUE; | |
496 } | |
497 | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
498 static gboolean |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
499 help_for_widget(GntBindable *bindable, GList *null) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
500 { |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
501 GntWM *wm = GNT_WM(bindable); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
502 GntWidget *widget, *tree, *win, *active; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
503 char *title; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
504 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
505 if (!wm->cws->ordered) |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
506 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
507 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
508 widget = wm->cws->ordered->data; |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
509 if (!GNT_IS_BOX(widget)) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
510 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
511 active = GNT_BOX(widget)->active; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
512 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
513 tree = gnt_widget_bindings_view(active); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
514 win = gnt_window_new(); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
515 title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(active))); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
516 gnt_box_set_title(GNT_BOX(win), title); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
517 if (tree) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
518 gnt_box_add_widget(GNT_BOX(win), tree); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
519 else |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
520 gnt_box_add_widget(GNT_BOX(win), gnt_label_new("This widget has no customizable bindings.")); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
521 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
522 gnt_widget_show(win); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
523 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
524 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
525 } |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
526 |
15818 | 527 static void |
528 destroy__list(GntWidget *widget, GntWM *wm) | |
529 { | |
530 wm->_list.window = NULL; | |
531 wm->_list.tree = NULL; | |
532 wm->windows = NULL; | |
533 wm->actions = NULL; | |
534 update_screen(wm); | |
535 } | |
536 | |
537 static void | |
538 setup__list(GntWM *wm) | |
539 { | |
540 GntWidget *tree, *win; | |
541 win = wm->_list.window = gnt_box_new(FALSE, FALSE); | |
542 gnt_box_set_toplevel(GNT_BOX(win), TRUE); | |
543 gnt_box_set_pad(GNT_BOX(win), 0); | |
544 GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_TRANSIENT); | |
545 | |
546 tree = wm->_list.tree = gnt_tree_new(); | |
547 gnt_box_add_widget(GNT_BOX(win), tree); | |
548 | |
549 g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(destroy__list), wm); | |
550 } | |
551 | |
552 static void | |
553 window_list_activate(GntTree *tree, GntWM *wm) | |
554 { | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
555 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(tree)); |
15818 | 556 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
557 gnt_widget_destroy(wm->_list.window); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
558 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
559 if (!sel) |
15818 | 560 return; |
561 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
562 if (GNT_IS_WS(sel)) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
563 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, sel)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
564 } else { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
565 gnt_wm_raise_window(wm, GNT_WIDGET(sel)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
566 } |
15818 | 567 } |
568 | |
569 static void | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
570 populate_window_list(GntWM *wm, gboolean workspace) |
15818 | 571 { |
572 GList *iter; | |
573 GntTree *tree = GNT_TREE(wm->windows->tree); | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
574 if (!workspace) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
575 for (iter = wm->cws->list; iter; iter = iter->next) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
576 GntBox *box = GNT_BOX(iter->data); |
15818 | 577 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
578 gnt_tree_add_row_last(tree, box, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
579 gnt_tree_create_row(tree, box->title), NULL); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
580 update_window_in_list(wm, GNT_WIDGET(box)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
581 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
582 } else { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
583 GList *ws = wm->workspaces; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
584 for (; ws; ws = ws->next) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
585 gnt_tree_add_row_last(tree, ws->data, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
586 gnt_tree_create_row(tree, gnt_ws_get_name(GNT_WS(ws->data))), NULL); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
587 for (iter = GNT_WS(ws->data)->list; iter; iter = iter->next) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
588 GntBox *box = GNT_BOX(iter->data); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
589 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
590 gnt_tree_add_row_last(tree, box, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
591 gnt_tree_create_row(tree, box->title), ws->data); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
592 update_window_in_list(wm, GNT_WIDGET(box)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
593 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
594 } |
15818 | 595 } |
596 } | |
597 | |
598 static gboolean | |
599 window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm) | |
600 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
601 if (text[1] == 0 && wm->cws->ordered) { |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
602 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(widget)); |
15818 | 603 switch (text[0]) { |
604 case '-': | |
16127
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
605 case ',': |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
606 if (GNT_IS_WS(sel)) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
607 /* reorder the workspace. */ |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
608 } else |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
609 shift_window(wm, GNT_WIDGET(sel), -1); |
15818 | 610 break; |
16127
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
611 case '=': |
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
612 case '.': |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
613 if (GNT_IS_WS(sel)) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
614 /* reorder the workspace. */ |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
615 } else |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
616 shift_window(wm, GNT_WIDGET(sel), 1); |
15818 | 617 break; |
618 default: | |
619 return FALSE; | |
620 } | |
621 gnt_tree_remove_all(GNT_TREE(widget)); | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
622 populate_window_list(wm, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "workspace"))); |
15818 | 623 gnt_tree_set_selected(GNT_TREE(widget), sel); |
624 return TRUE; | |
625 } | |
626 return FALSE; | |
627 } | |
628 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
629 static void |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
630 list_of_windows(GntWM *wm, gboolean workspace) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
631 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
632 GntWidget *tree, *win; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
633 setup__list(wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
634 wm->windows = &wm->_list; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
635 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
636 win = wm->windows->window; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
637 tree = wm->windows->tree; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
638 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
639 gnt_box_set_title(GNT_BOX(win), workspace ? "Workspace List" : "Window List"); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
640 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
641 populate_window_list(wm, workspace); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
642 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
643 if (wm->cws->ordered) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
644 gnt_tree_set_selected(GNT_TREE(tree), wm->cws->ordered->data); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
645 else if (workspace) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
646 gnt_tree_set_selected(GNT_TREE(tree), wm->cws); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
647 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
648 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
649 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
650 g_object_set_data(G_OBJECT(tree), "workspace", GINT_TO_POINTER(workspace)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
651 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
652 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
653 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
654 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
655 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
656 gnt_widget_show(win); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
657 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
658 |
15818 | 659 static gboolean |
660 window_list(GntBindable *bindable, GList *null) | |
661 { | |
662 GntWM *wm = GNT_WM(bindable); | |
663 | |
664 if (wm->_list.window || wm->menu) | |
665 return TRUE; | |
666 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
667 if (!wm->cws->ordered) |
15818 | 668 return TRUE; |
669 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
670 list_of_windows(wm, FALSE); |
15818 | 671 |
672 return TRUE; | |
673 } | |
674 | |
675 static gboolean | |
676 dump_screen(GntBindable *bindable, GList *null) | |
677 { | |
678 int x, y; | |
679 chtype old = 0, now = 0; | |
680 FILE *file = fopen("dump.html", "w"); | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
681 struct { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
682 char ascii; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
683 char *unicode; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
684 } unis[] = { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
685 {'q', "─"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
686 {'t', "├"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
687 {'u', "┤"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
688 {'x', "│"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
689 {'-', "↑"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
690 {'.', "↓"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
691 {'l', "┌"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
692 {'k', "┐"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
693 {'m', "└"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
694 {'j', "┘"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
695 {'a', "▒"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
696 {'\0', NULL} |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
697 }; |
15818 | 698 |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
699 fprintf(file, "<head>\n <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n</head>\n<body>\n"); |
15818 | 700 fprintf(file, "<pre>"); |
701 for (y = 0; y < getmaxy(stdscr); y++) { | |
702 for (x = 0; x < getmaxx(stdscr); x++) { | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
703 char ch[2] = {0, 0}, *print; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
704 #ifdef NO_WIDECHAR |
15818 | 705 now = mvwinch(curscr, y, x); |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
706 ch[0] = now & A_CHARTEXT; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
707 now ^= ch[0]; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
708 #else |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
709 cchar_t wch; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
710 char unicode[12]; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
711 mvwin_wch(curscr, y, x, &wch); |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
712 now = wch.attr; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
713 ch[0] = (char)(wch.chars[0] & 0xff); |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
714 #endif |
15818 | 715 |
716 #define CHECK(attr, start, end) \ | |
717 do \ | |
718 { \ | |
719 if (now & attr) \ | |
720 { \ | |
721 if (!(old & attr)) \ | |
722 fprintf(file, "%s", start); \ | |
723 } \ | |
724 else if (old & attr) \ | |
725 { \ | |
726 fprintf(file, "%s", end); \ | |
727 } \ | |
728 } while (0) | |
729 | |
730 CHECK(A_BOLD, "<b>", "</b>"); | |
731 CHECK(A_UNDERLINE, "<u>", "</u>"); | |
732 CHECK(A_BLINK, "<blink>", "</blink>"); | |
733 | |
734 if ((now & A_COLOR) != (old & A_COLOR) || | |
735 (now & A_REVERSE) != (old & A_REVERSE)) | |
736 { | |
737 int ret; | |
738 short fgp, bgp, r, g, b; | |
739 struct | |
740 { | |
741 int r, g, b; | |
742 } fg, bg; | |
743 | |
744 ret = pair_content(PAIR_NUMBER(now & A_COLOR), &fgp, &bgp); | |
745 if (fgp == -1) | |
746 fgp = COLOR_BLACK; | |
747 if (bgp == -1) | |
748 bgp = COLOR_WHITE; | |
749 if (now & A_REVERSE) | |
17174
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
750 { |
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
751 short tmp = fgp; |
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
752 fgp = bgp; |
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
753 bgp = tmp; |
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
754 } |
15818 | 755 ret = color_content(fgp, &r, &g, &b); |
756 fg.r = r; fg.b = b; fg.g = g; | |
757 ret = color_content(bgp, &r, &g, &b); | |
758 bg.r = r; bg.b = b; bg.g = g; | |
759 #define ADJUST(x) (x = x * 255 / 1000) | |
760 ADJUST(fg.r); | |
761 ADJUST(fg.g); | |
762 ADJUST(fg.b); | |
763 ADJUST(bg.r); | |
764 ADJUST(bg.b); | |
765 ADJUST(bg.g); | |
766 | |
767 if (x) fprintf(file, "</span>"); | |
768 fprintf(file, "<span style=\"background:#%02x%02x%02x;color:#%02x%02x%02x\">", | |
769 bg.r, bg.g, bg.b, fg.r, fg.g, fg.b); | |
770 } | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
771 print = ch; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
772 #ifndef NO_WIDECHAR |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
773 if (wch.chars[0] > 255) { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
774 snprintf(unicode, sizeof(unicode), "&#x%x;", wch.chars[0]); |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
775 print = unicode; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
776 } |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
777 #endif |
15818 | 778 if (now & A_ALTCHARSET) |
779 { | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
780 int u; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
781 for (u = 0; unis[u].ascii; u++) { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
782 if (ch[0] == unis[u].ascii) { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
783 print = unis[u].unicode; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
784 break; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
785 } |
15818 | 786 } |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
787 if (!unis[u].ascii) |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
788 print = " "; |
15818 | 789 } |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
790 if (ch[0] == '&') |
15818 | 791 fprintf(file, "&"); |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
792 else if (ch[0] == '<') |
15818 | 793 fprintf(file, "<"); |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
794 else if (ch[0] == '>') |
15818 | 795 fprintf(file, ">"); |
796 else | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
797 fprintf(file, "%s", print); |
15818 | 798 old = now; |
799 } | |
800 fprintf(file, "</span>\n"); | |
801 old = 0; | |
802 } | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
803 fprintf(file, "</pre>\n</body>"); |
15818 | 804 fclose(file); |
805 return TRUE; | |
806 } | |
807 | |
808 static void | |
809 shift_window(GntWM *wm, GntWidget *widget, int dir) | |
810 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
811 GList *all = wm->cws->list; |
15818 | 812 GList *list = g_list_find(all, widget); |
813 int length, pos; | |
814 if (!list) | |
815 return; | |
816 | |
817 length = g_list_length(all); | |
818 pos = g_list_position(all, list); | |
819 | |
820 pos += dir; | |
821 if (dir > 0) | |
822 pos++; | |
823 | |
824 if (pos < 0) | |
825 pos = length; | |
826 else if (pos > length) | |
827 pos = 0; | |
828 | |
829 all = g_list_insert(all, widget, pos); | |
830 all = g_list_delete_link(all, list); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
831 wm->cws->list = all; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
832 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 833 } |
834 | |
835 static gboolean | |
836 shift_left(GntBindable *bindable, GList *null) | |
837 { | |
838 GntWM *wm = GNT_WM(bindable); | |
839 if (wm->_list.window) | |
840 return TRUE; | |
841 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
842 shift_window(wm, wm->cws->ordered->data, -1); |
15818 | 843 return TRUE; |
844 } | |
845 | |
846 static gboolean | |
847 shift_right(GntBindable *bindable, GList *null) | |
848 { | |
849 GntWM *wm = GNT_WM(bindable); | |
850 if (wm->_list.window) | |
851 return TRUE; | |
852 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
853 shift_window(wm, wm->cws->ordered->data, 1); |
15818 | 854 return TRUE; |
855 } | |
856 | |
857 static void | |
858 action_list_activate(GntTree *tree, GntWM *wm) | |
859 { | |
860 GntAction *action = gnt_tree_get_selection_data(tree); | |
861 action->callback(); | |
862 gnt_widget_destroy(wm->_list.window); | |
863 } | |
864 | |
865 static int | |
866 compare_action(gconstpointer p1, gconstpointer p2) | |
867 { | |
868 const GntAction *a1 = p1; | |
869 const GntAction *a2 = p2; | |
870 | |
871 return g_utf8_collate(a1->label, a2->label); | |
872 } | |
873 | |
874 static gboolean | |
875 list_actions(GntBindable *bindable, GList *null) | |
876 { | |
877 GntWidget *tree, *win; | |
878 GList *iter; | |
879 GntWM *wm = GNT_WM(bindable); | |
880 if (wm->_list.window || wm->menu) | |
881 return TRUE; | |
882 | |
883 if (wm->acts == NULL) | |
884 return TRUE; | |
885 | |
886 setup__list(wm); | |
887 wm->actions = &wm->_list; | |
888 | |
889 win = wm->actions->window; | |
890 tree = wm->actions->tree; | |
891 | |
892 gnt_box_set_title(GNT_BOX(win), "Actions"); | |
893 GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER); | |
894 /* XXX: Do we really want this? */ | |
895 gnt_tree_set_compare_func(GNT_TREE(tree), compare_action); | |
896 | |
897 for (iter = wm->acts; iter; iter = iter->next) { | |
898 GntAction *action = iter->data; | |
899 gnt_tree_add_row_last(GNT_TREE(tree), action, | |
900 gnt_tree_create_row(GNT_TREE(tree), action->label), NULL); | |
901 } | |
902 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(action_list_activate), wm); | |
903 gnt_widget_set_size(tree, 0, g_list_length(wm->acts)); | |
904 gnt_widget_set_position(win, 0, getmaxy(stdscr) - 3 - g_list_length(wm->acts)); | |
905 | |
906 gnt_widget_show(win); | |
907 return TRUE; | |
908 } | |
909 | |
910 #ifndef NO_WIDECHAR | |
911 static int | |
912 widestringwidth(wchar_t *wide) | |
913 { | |
914 int len, ret; | |
915 char *string; | |
916 | |
917 len = wcstombs(NULL, wide, 0) + 1; | |
918 string = g_new0(char, len); | |
919 wcstombs(string, wide, len); | |
920 ret = gnt_util_onscreen_width(string, NULL); | |
921 g_free(string); | |
922 return ret; | |
923 } | |
924 #endif | |
925 | |
926 /* Returns the onscreen width of the character at the position */ | |
927 static int | |
928 reverse_char(WINDOW *d, int y, int x, gboolean set) | |
929 { | |
930 #define DECIDE(ch) (set ? ((ch) | A_REVERSE) : ((ch) & ~A_REVERSE)) | |
931 | |
932 #ifdef NO_WIDECHAR | |
933 chtype ch; | |
934 ch = mvwinch(d, y, x); | |
935 mvwaddch(d, y, x, DECIDE(ch)); | |
936 return 1; | |
937 #else | |
938 cchar_t ch; | |
939 int wc = 1; | |
940 if (mvwin_wch(d, y, x, &ch) == OK) { | |
941 wc = widestringwidth(ch.chars); | |
942 ch.attr = DECIDE(ch.attr); | |
943 ch.attr &= WA_ATTRIBUTES; /* XXX: This is a workaround for a bug */ | |
944 mvwadd_wch(d, y, x, &ch); | |
945 } | |
946 | |
947 return wc; | |
948 #endif | |
949 } | |
950 | |
951 static void | |
952 window_reverse(GntWidget *win, gboolean set, GntWM *wm) | |
953 { | |
954 int i; | |
955 int w, h; | |
956 WINDOW *d; | |
957 | |
958 if (GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_NO_BORDER)) | |
959 return; | |
960 | |
961 d = win->window; | |
962 gnt_widget_get_size(win, &w, &h); | |
963 | |
964 if (gnt_widget_has_shadow(win)) { | |
965 --w; | |
966 --h; | |
967 } | |
968 | |
969 /* the top and bottom */ | |
970 for (i = 0; i < w; i += reverse_char(d, 0, i, set)); | |
971 for (i = 0; i < w; i += reverse_char(d, h-1, i, set)); | |
972 | |
973 /* the left and right */ | |
974 for (i = 0; i < h; i += reverse_char(d, i, 0, set)); | |
975 for (i = 0; i < h; i += reverse_char(d, i, w-1, set)); | |
976 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
977 gnt_wm_copy_win(win, g_hash_table_lookup(wm->nodes, win)); |
15818 | 978 update_screen(wm); |
979 } | |
980 | |
981 static gboolean | |
982 start_move(GntBindable *bindable, GList *null) | |
983 { | |
984 GntWM *wm = GNT_WM(bindable); | |
985 if (wm->_list.window || wm->menu) | |
986 return TRUE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
987 if (!wm->cws->ordered) |
15818 | 988 return TRUE; |
989 | |
990 wm->mode = GNT_KP_MODE_MOVE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
991 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); |
15818 | 992 |
993 return TRUE; | |
994 } | |
995 | |
996 static gboolean | |
997 start_resize(GntBindable *bindable, GList *null) | |
998 { | |
999 GntWM *wm = GNT_WM(bindable); | |
1000 if (wm->_list.window || wm->menu) | |
1001 return TRUE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1002 if (!wm->cws->ordered) |
15818 | 1003 return TRUE; |
1004 | |
1005 wm->mode = GNT_KP_MODE_RESIZE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1006 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); |
15818 | 1007 |
1008 return TRUE; | |
1009 } | |
1010 | |
1011 static gboolean | |
1012 wm_quit(GntBindable *bindable, GList *list) | |
1013 { | |
1014 GntWM *wm = GNT_WM(bindable); | |
1015 if (write_timeout) | |
1016 write_already(wm); | |
1017 g_main_loop_quit(wm->loop); | |
1018 return TRUE; | |
1019 } | |
1020 | |
1021 static gboolean | |
1022 return_true(GntWM *wm, GntWidget *w, int *a, int *b) | |
1023 { | |
1024 return TRUE; | |
1025 } | |
1026 | |
1027 static gboolean | |
1028 refresh_screen(GntBindable *bindable, GList *null) | |
1029 { | |
1030 GntWM *wm = GNT_WM(bindable); | |
1031 | |
1032 endwin(); | |
1033 | |
1034 g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, NULL); | |
18367
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1035 refresh(); |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1036 g_signal_emit(wm, signals[SIG_TERMINAL_REFRESH], 0); |
15818 | 1037 update_screen(wm); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1038 gnt_ws_draw_taskbar(wm->cws, TRUE); |
18077
2141130ac557
This got lost from a merge I think. This refixes #532.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
1039 curs_set(0); /* endwin resets the cursor to normal */ |
15818 | 1040 |
1041 return FALSE; | |
1042 } | |
1043 | |
16526
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1044 static gboolean |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1045 toggle_clipboard(GntBindable *bindable, GList *n) |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1046 { |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1047 static GntWidget *clip; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1048 gchar *text; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1049 int maxx, maxy; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1050 if (clip) { |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1051 gnt_widget_destroy(clip); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1052 clip = NULL; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1053 return TRUE; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1054 } |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1055 getmaxyx(stdscr, maxy, maxx); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1056 text = gnt_get_clipboard_string(); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1057 clip = gnt_hwindow_new(FALSE); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1058 GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_TRANSIENT); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1059 GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_NO_BORDER); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1060 gnt_box_set_pad(GNT_BOX(clip), 0); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1061 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1062 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text)); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1063 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1064 gnt_widget_set_position(clip, 0, 0); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1065 gnt_widget_draw(clip); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1066 g_free(text); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1067 return TRUE; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1068 } |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1069 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1070 static void remove_tag(gpointer wid, gpointer wim) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1071 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1072 GntWM *wm = GNT_WM(wim); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1073 GntWidget *w = GNT_WIDGET(wid); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1074 wm->tagged = g_list_remove(wm->tagged, w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1075 mvwhline(w->window, 0, 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), 3); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1076 gnt_widget_draw(w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1077 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1078 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1079 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1080 tag_widget(GntBindable *b, GList *params) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1081 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1082 GntWM *wm = GNT_WM(b); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1083 GntWidget *widget; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1084 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1085 if (!wm->cws->ordered) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1086 return FALSE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1087 widget = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1088 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1089 if (g_list_find(wm->tagged, widget)) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1090 remove_tag(widget, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1091 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1092 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1093 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1094 wm->tagged = g_list_prepend(wm->tagged, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1095 wbkgdset(widget->window, ' ' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1096 mvwprintw(widget->window, 0, 1, "[T]"); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1097 gnt_widget_draw(widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1098 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1099 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1100 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1101 static void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1102 widget_move_ws(gpointer wid, gpointer w) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1103 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1104 GntWM *wm = GNT_WM(w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1105 gnt_wm_widget_move_workspace(wm, wm->cws, GNT_WIDGET(wid)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1106 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1107 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1108 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1109 place_tagged(GntBindable *b, GList *params) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1110 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1111 GntWM *wm = GNT_WM(b); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1112 g_list_foreach(wm->tagged, widget_move_ws, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1113 g_list_foreach(wm->tagged, remove_tag, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1114 g_list_free(wm->tagged); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1115 wm->tagged = NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1116 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1117 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1118 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1119 static gboolean |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1120 workspace_list(GntBindable *b, GList *params) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1121 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1122 GntWM *wm = GNT_WM(b); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1123 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1124 if (wm->_list.window || wm->menu) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1125 return TRUE; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1126 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1127 list_of_windows(wm, TRUE); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1128 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1129 return TRUE; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1130 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1131 |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1132 static gboolean |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1133 workspace_new(GntBindable *bindable, GList *null) |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1134 { |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1135 GntWM *wm = GNT_WM(bindable); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1136 GntWS *ws = gnt_ws_new(NULL); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1137 gnt_wm_add_workspace(wm, ws); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1138 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws)); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1139 return TRUE; |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1140 } |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1141 |
15818 | 1142 static void |
1143 gnt_wm_class_init(GntWMClass *klass) | |
1144 { | |
1145 int i; | |
1146 | |
1147 klass->new_window = gnt_wm_new_window_real; | |
1148 klass->decorate_window = NULL; | |
1149 klass->close_window = NULL; | |
1150 klass->window_resize_confirm = return_true; | |
1151 klass->window_resized = gnt_wm_win_resized; | |
1152 klass->window_move_confirm = return_true; | |
1153 klass->window_moved = gnt_wm_win_moved; | |
1154 klass->window_update = NULL; | |
1155 klass->key_pressed = NULL; | |
1156 klass->mouse_clicked = NULL; | |
1157 klass->give_focus = gnt_wm_give_focus; | |
1158 | |
1159 signals[SIG_NEW_WIN] = | |
1160 g_signal_new("new_win", | |
1161 G_TYPE_FROM_CLASS(klass), | |
1162 G_SIGNAL_RUN_LAST, | |
1163 G_STRUCT_OFFSET(GntWMClass, new_window), | |
1164 NULL, NULL, | |
1165 g_cclosure_marshal_VOID__POINTER, | |
1166 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1167 signals[SIG_DECORATE_WIN] = | |
1168 g_signal_new("decorate_win", | |
1169 G_TYPE_FROM_CLASS(klass), | |
1170 G_SIGNAL_RUN_LAST, | |
1171 G_STRUCT_OFFSET(GntWMClass, decorate_window), | |
1172 NULL, NULL, | |
1173 g_cclosure_marshal_VOID__POINTER, | |
1174 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1175 signals[SIG_CLOSE_WIN] = | |
1176 g_signal_new("close_win", | |
1177 G_TYPE_FROM_CLASS(klass), | |
1178 G_SIGNAL_RUN_LAST, | |
1179 G_STRUCT_OFFSET(GntWMClass, close_window), | |
1180 NULL, NULL, | |
1181 g_cclosure_marshal_VOID__POINTER, | |
1182 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1183 signals[SIG_CONFIRM_RESIZE] = | |
1184 g_signal_new("confirm_resize", | |
1185 G_TYPE_FROM_CLASS(klass), | |
1186 G_SIGNAL_RUN_LAST, | |
1187 G_STRUCT_OFFSET(GntWMClass, window_resize_confirm), | |
1188 gnt_boolean_handled_accumulator, NULL, | |
1189 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER, | |
1190 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER); | |
1191 | |
1192 signals[SIG_CONFIRM_MOVE] = | |
1193 g_signal_new("confirm_move", | |
1194 G_TYPE_FROM_CLASS(klass), | |
1195 G_SIGNAL_RUN_LAST, | |
1196 G_STRUCT_OFFSET(GntWMClass, window_move_confirm), | |
1197 gnt_boolean_handled_accumulator, NULL, | |
1198 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER, | |
1199 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER); | |
1200 | |
1201 signals[SIG_RESIZED] = | |
1202 g_signal_new("window_resized", | |
1203 G_TYPE_FROM_CLASS(klass), | |
1204 G_SIGNAL_RUN_LAST, | |
1205 G_STRUCT_OFFSET(GntWMClass, window_resized), | |
1206 NULL, NULL, | |
1207 g_cclosure_marshal_VOID__POINTER, | |
1208 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1209 signals[SIG_MOVED] = | |
1210 g_signal_new("window_moved", | |
1211 G_TYPE_FROM_CLASS(klass), | |
1212 G_SIGNAL_RUN_LAST, | |
1213 G_STRUCT_OFFSET(GntWMClass, window_moved), | |
1214 NULL, NULL, | |
1215 g_cclosure_marshal_VOID__POINTER, | |
1216 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1217 signals[SIG_UPDATE_WIN] = | |
1218 g_signal_new("window_update", | |
1219 G_TYPE_FROM_CLASS(klass), | |
1220 G_SIGNAL_RUN_LAST, | |
1221 G_STRUCT_OFFSET(GntWMClass, window_update), | |
1222 NULL, NULL, | |
1223 g_cclosure_marshal_VOID__POINTER, | |
1224 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1225 | |
1226 signals[SIG_GIVE_FOCUS] = | |
1227 g_signal_new("give_focus", | |
1228 G_TYPE_FROM_CLASS(klass), | |
1229 G_SIGNAL_RUN_LAST, | |
1230 G_STRUCT_OFFSET(GntWMClass, give_focus), | |
1231 NULL, NULL, | |
1232 g_cclosure_marshal_VOID__POINTER, | |
1233 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1234 | |
1235 signals[SIG_MOUSE_CLICK] = | |
1236 g_signal_new("mouse_clicked", | |
1237 G_TYPE_FROM_CLASS(klass), | |
1238 G_SIGNAL_RUN_LAST, | |
1239 G_STRUCT_OFFSET(GntWMClass, mouse_clicked), | |
1240 gnt_boolean_handled_accumulator, NULL, | |
1241 gnt_closure_marshal_BOOLEAN__INT_INT_INT_POINTER, | |
1242 G_TYPE_BOOLEAN, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_POINTER); | |
1243 | |
18367
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1244 signals[SIG_TERMINAL_REFRESH] = |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1245 g_signal_new("terminal-refresh", |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1246 G_TYPE_FROM_CLASS(klass), |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1247 G_SIGNAL_RUN_LAST, |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1248 G_STRUCT_OFFSET(GntWMClass, terminal_refresh), |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1249 NULL, NULL, |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1250 g_cclosure_marshal_VOID__VOID, |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1251 G_TYPE_NONE, 0); |
1648cd94dddf
Add a callback that gets triggered by SIGWINCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18235
diff
changeset
|
1252 |
15818 | 1253 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-next", window_next, |
1254 "\033" "n", NULL); | |
1255 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-prev", window_prev, | |
1256 "\033" "p", NULL); | |
1257 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-close", window_close, | |
1258 "\033" "c", NULL); | |
1259 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-list", window_list, | |
1260 "\033" "w", NULL); | |
1261 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "dump-screen", dump_screen, | |
1262 "\033" "d", NULL); | |
1263 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-left", shift_left, | |
1264 "\033" ",", NULL); | |
1265 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-right", shift_right, | |
1266 "\033" ".", NULL); | |
1267 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "action-list", list_actions, | |
1268 "\033" "a", NULL); | |
1269 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-move", start_move, | |
1270 "\033" "m", NULL); | |
1271 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-resize", start_resize, | |
1272 "\033" "r", NULL); | |
1273 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "wm-quit", wm_quit, | |
1274 "\033" "q", NULL); | |
1275 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "refresh-screen", refresh_screen, | |
1276 "\033" "l", NULL); | |
1277 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "switch-window-n", switch_window_n, | |
1278 NULL, NULL); | |
1279 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-down", window_scroll_down, | |
1280 "\033" GNT_KEY_CTRL_J, NULL); | |
1281 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, | |
1282 "\033" GNT_KEY_CTRL_K, NULL); | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1283 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-widget", help_for_widget, |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1284 "\033" "/", NULL); |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1285 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-new", workspace_new, |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1286 GNT_KEY_F9, NULL); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1287 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-next", workspace_next, |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1288 "\033" ">", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1289 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-prev", workspace_prev, |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1290 "\033" "<", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1291 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-tag", tag_widget, |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1292 "\033" "t", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1293 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "place-tagged", place_tagged, |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1294 "\033" "T", NULL); |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1295 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-list", workspace_list, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1296 "\033" "s", NULL); |
16526
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1297 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard", |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1298 toggle_clipboard, "\033" "C", NULL); |
15818 | 1299 |
1300 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); | |
1301 | |
1302 /* Make sure Alt+x are detected properly. */ | |
1303 for (i = '0'; i <= '9'; i++) { | |
1304 char str[] = "\033X"; | |
1305 str[1] = i; | |
1306 gnt_keys_add_combination(str); | |
1307 } | |
1308 | |
1309 GNTDEBUG; | |
1310 } | |
1311 | |
1312 /****************************************************************************** | |
1313 * GntWM API | |
1314 *****************************************************************************/ | |
1315 GType | |
1316 gnt_wm_get_gtype(void) | |
1317 { | |
1318 static GType type = 0; | |
1319 | |
1320 if(type == 0) { | |
1321 static const GTypeInfo info = { | |
1322 sizeof(GntWMClass), | |
1323 NULL, /* base_init */ | |
1324 NULL, /* base_finalize */ | |
1325 (GClassInitFunc)gnt_wm_class_init, | |
1326 NULL, | |
1327 NULL, /* class_data */ | |
1328 sizeof(GntWM), | |
1329 0, /* n_preallocs */ | |
1330 gnt_wm_init, /* instance_init */ | |
1331 NULL /* value_table */ | |
1332 }; | |
1333 | |
1334 type = g_type_register_static(GNT_TYPE_BINDABLE, | |
1335 "GntWM", | |
1336 &info, 0); | |
1337 } | |
1338 | |
1339 return type; | |
1340 } | |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1341 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1342 void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1343 gnt_wm_add_workspace(GntWM *wm, GntWS *ws) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1344 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1345 wm->workspaces = g_list_append(wm->workspaces, ws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1346 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1347 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1348 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1349 gnt_wm_switch_workspace(GntWM *wm, gint n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1350 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1351 GntWS *s = g_list_nth_data(wm->workspaces, n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1352 if (!s) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1353 return FALSE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1354 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1355 if (wm->_list.window) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1356 gnt_widget_destroy(wm->_list.window); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1357 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1358 gnt_ws_hide(wm->cws, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1359 wm->cws = s; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1360 gnt_ws_show(wm->cws, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1361 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1362 gnt_ws_draw_taskbar(wm->cws, TRUE); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1363 update_screen(wm); |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1364 if (wm->cws->ordered) { |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1365 gnt_widget_set_focus(wm->cws->ordered->data, TRUE); |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1366 gnt_wm_raise_window(wm, wm->cws->ordered->data); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1367 } |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1368 |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1369 if (act && g_list_find(act, wm->cws)) { |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1370 act = g_list_remove(act, wm->cws); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1371 update_act_msg(); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1372 } |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1373 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1374 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1375 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1376 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1377 gnt_wm_switch_workspace_prev(GntWM *wm) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1378 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1379 int n = g_list_index(wm->workspaces, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1380 return gnt_wm_switch_workspace(wm, --n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1381 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1382 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1383 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1384 gnt_wm_switch_workspace_next(GntWM *wm) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1385 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1386 int n = g_list_index(wm->workspaces, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1387 return gnt_wm_switch_workspace(wm, ++n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1388 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1389 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1390 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1391 workspace_next(GntBindable *wm, GList *n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1392 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1393 return gnt_wm_switch_workspace_next(GNT_WM(wm)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1394 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1395 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1396 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1397 workspace_prev(GntBindable *wm, GList *n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1398 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1399 return gnt_wm_switch_workspace_prev(GNT_WM(wm)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1400 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1401 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1402 void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1403 gnt_wm_widget_move_workspace(GntWM *wm, GntWS *neww, GntWidget *widget) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1404 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1405 GntWS *oldw = gnt_wm_widget_find_workspace(wm, widget); |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1406 GntNode *node; |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1407 if (!oldw || oldw == neww) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1408 return; |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1409 node = g_hash_table_lookup(wm->nodes, widget); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1410 if (node && node->ws == neww) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1411 return; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1412 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1413 if (node) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1414 node->ws = neww; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1415 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1416 gnt_ws_remove_widget(oldw, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1417 gnt_ws_add_widget(neww, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1418 if (neww == wm->cws) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1419 gnt_ws_widget_show(widget, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1420 } else { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1421 gnt_ws_widget_hide(widget, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1422 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1423 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1424 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1425 static gint widget_in_workspace(gconstpointer workspace, gconstpointer wid) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1426 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1427 GntWS *s = (GntWS *)workspace; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1428 if (s->list && g_list_find(s->list, wid)) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1429 return 0; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1430 return 1; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1431 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1432 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1433 GntWS *gnt_wm_widget_find_workspace(GntWM *wm, GntWidget *widget) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1434 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1435 GList *l = g_list_find_custom(wm->workspaces, widget, widget_in_workspace); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1436 if (l) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1437 return l->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1438 return NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1439 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1440 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1441 static void free_workspaces(gpointer data, gpointer n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1442 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1443 GntWS *s = data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1444 g_free(s->name); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1445 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1446 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1447 void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1448 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1449 g_list_foreach(wm->workspaces, free_workspaces, NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1450 wm->workspaces = workspaces; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1451 gnt_wm_switch_workspace(wm, 0); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1452 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1453 |
15818 | 1454 static void |
1455 update_window_in_list(GntWM *wm, GntWidget *wid) | |
1456 { | |
1457 GntTextFormatFlags flag = 0; | |
1458 | |
1459 if (wm->windows == NULL) | |
1460 return; | |
1461 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1462 if (wm->cws->ordered && wid == wm->cws->ordered->data) |
15818 | 1463 flag |= GNT_TEXT_FLAG_DIM; |
1464 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT)) | |
1465 flag |= GNT_TEXT_FLAG_BOLD; | |
1466 | |
1467 gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag); | |
1468 } | |
1469 | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1470 static gboolean |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1471 match_title(gpointer title, gpointer n, gpointer wid_title) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1472 { |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1473 /* XXX: do any regex magic here. */ |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1474 if (g_strrstr((gchar *)wid_title, (gchar *)title)) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1475 return TRUE; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1476 return FALSE; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1477 } |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1478 |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1479 #if !GLIB_CHECK_VERSION(2,4,0) |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1480 struct |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1481 { |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1482 gpointer data; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1483 gpointer value; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1484 } table_find_data; |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1485 |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1486 static void |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1487 table_find_helper(gpointer key, gpointer value, gpointer data) |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1488 { |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1489 GHRFunc func = data; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1490 if (func(key, value, table_find_data.data)) |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1491 table_find_data.value = value; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1492 } |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1493 |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1494 static gpointer |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1495 g_hash_table_find(GHashTable * table, GHRFunc func, gpointer data) |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1496 { |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1497 table_find_data.data = data; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1498 table_find_data.value = NULL; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1499 g_hash_table_foreach(table, table_find_helper, func); |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1500 return table_find_data.value; |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1501 } |
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1502 #endif |
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1503 |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1504 static GntWS * |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1505 new_widget_find_workspace(GntWM *wm, GntWidget *widget) |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1506 { |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1507 GntWS *ret = NULL; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1508 const gchar *name, *title; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1509 title = GNT_BOX(widget)->title; |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1510 if (title) |
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1511 ret = g_hash_table_find(wm->title_places, match_title, (gpointer)title); |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1512 if (ret) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1513 return ret; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1514 name = gnt_widget_get_name(widget); |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1515 if (name) |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1516 ret = g_hash_table_find(wm->name_places, match_title, (gpointer)name); |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1517 return ret ? ret : wm->cws; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1518 } |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1519 |
15818 | 1520 static void |
1521 gnt_wm_new_window_real(GntWM *wm, GntWidget *widget) | |
1522 { | |
1523 GntNode *node; | |
1524 gboolean transient = FALSE; | |
1525 | |
1526 if (widget->window == NULL) | |
1527 return; | |
1528 | |
1529 node = g_new0(GntNode, 1); | |
1530 node->me = widget; | |
1531 node->scroll = 0; | |
1532 | |
1533 g_hash_table_replace(wm->nodes, widget, node); | |
1534 | |
1535 refresh_node(widget, node, NULL); | |
1536 | |
1537 transient = !!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT); | |
1538 | |
1539 #if 1 | |
1540 { | |
1541 int x, y, w, h, maxx, maxy; | |
1542 gboolean shadow = TRUE; | |
1543 | |
1544 if (!gnt_widget_has_shadow(widget)) | |
1545 shadow = FALSE; | |
1546 x = widget->priv.x; | |
1547 y = widget->priv.y; | |
1548 w = widget->priv.width; | |
1549 h = widget->priv.height; | |
1550 | |
1551 getmaxyx(stdscr, maxy, maxx); | |
1552 maxy -= 1; /* room for the taskbar */ | |
1553 maxy -= shadow; | |
1554 maxx -= shadow; | |
1555 | |
1556 x = MAX(0, x); | |
1557 y = MAX(0, y); | |
1558 if (x + w >= maxx) | |
1559 x = MAX(0, maxx - w); | |
1560 if (y + h >= maxy) | |
1561 y = MAX(0, maxy - h); | |
1562 | |
1563 w = MIN(w, maxx); | |
1564 h = MIN(h, maxy); | |
1565 node->window = newwin(h + shadow, w + shadow, y, x); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1566 gnt_wm_copy_win(widget, node); |
15818 | 1567 } |
1568 #endif | |
1569 | |
1570 node->panel = new_panel(node->window); | |
1571 set_panel_userptr(node->panel, node); | |
1572 | |
1573 if (!transient) { | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1574 GntWS *ws = wm->cws; |
15818 | 1575 if (node->me != wm->_list.window) { |
1576 GntWidget *w = NULL; | |
1577 | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1578 if (GNT_IS_BOX(widget)) { |
18235
d359e5f3ee87
Plucked revision from finchfeat to allow partial matching for window-titles
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18216
diff
changeset
|
1579 ws = new_widget_find_workspace(wm, widget); |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1580 } |
15818 | 1581 |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1582 if (ws->ordered) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1583 w = ws->ordered->data; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1584 |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1585 node->ws = ws; |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1586 ws->list = g_list_append(ws->list, widget); |
15818 | 1587 |
1588 if (wm->event_stack) | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1589 ws->ordered = g_list_prepend(ws->ordered, widget); |
15818 | 1590 else |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1591 ws->ordered = g_list_append(ws->ordered, widget); |
15818 | 1592 |
1593 gnt_widget_set_focus(widget, TRUE); | |
1594 if (w) | |
1595 gnt_widget_set_focus(w, FALSE); | |
1596 } | |
1597 | |
1598 if (wm->event_stack || node->me == wm->_list.window) { | |
1599 gnt_wm_raise_window(wm, node->me); | |
1600 } else { | |
1601 bottom_panel(node->panel); /* New windows should not grab focus */ | |
18097
16bfad2597fb
Notify a window on startup if it didn't get the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18077
diff
changeset
|
1602 gnt_widget_set_focus(node->me, FALSE); |
15818 | 1603 gnt_widget_set_urgent(node->me); |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1604 if (wm->cws != ws) |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1605 gnt_ws_widget_hide(widget, wm->nodes); |
15818 | 1606 } |
1607 } | |
1608 } | |
1609 | |
1610 void gnt_wm_new_window(GntWM *wm, GntWidget *widget) | |
1611 { | |
1612 while (widget->parent) | |
1613 widget = widget->parent; | |
1614 | |
1615 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_INVISIBLE) || | |
1616 g_hash_table_lookup(wm->nodes, widget)) { | |
1617 update_screen(wm); | |
1618 return; | |
1619 } | |
1620 | |
1621 if (GNT_IS_BOX(widget)) { | |
1622 const char *title = GNT_BOX(widget)->title; | |
1623 GntPosition *p = NULL; | |
1624 if (title && (p = g_hash_table_lookup(wm->positions, title)) != NULL) { | |
1625 sanitize_position(widget, &p->x, &p->y); | |
1626 gnt_widget_set_position(widget, p->x, p->y); | |
1627 mvwin(widget->window, p->y, p->x); | |
1628 } | |
1629 } | |
1630 | |
1631 g_signal_emit(wm, signals[SIG_NEW_WIN], 0, widget); | |
1632 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); | |
1633 | |
1634 if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { | |
1635 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget | |
1636 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) { | |
1637 gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget, | |
1638 gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title), | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1639 g_object_get_data(G_OBJECT(wm->windows->tree), "workspace") ? wm->cws : NULL); |
15818 | 1640 update_window_in_list(wm, widget); |
1641 } | |
1642 } | |
1643 | |
1644 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1645 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 1646 } |
1647 | |
1648 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget) | |
1649 { | |
1650 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); | |
1651 } | |
1652 | |
1653 void gnt_wm_window_close(GntWM *wm, GntWidget *widget) | |
1654 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1655 GntWS *s; |
15818 | 1656 GntNode *node; |
1657 int pos; | |
1658 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1659 s = gnt_wm_widget_find_workspace(wm, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1660 |
15818 | 1661 if ((node = g_hash_table_lookup(wm->nodes, widget)) == NULL) |
1662 return; | |
1663 | |
1664 g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget); | |
1665 g_hash_table_remove(wm->nodes, widget); | |
1666 | |
1667 if (wm->windows) { | |
1668 gnt_tree_remove(GNT_TREE(wm->windows->tree), widget); | |
1669 } | |
1670 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1671 if (s) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1672 pos = g_list_index(s->list, widget); |
15818 | 1673 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1674 if (pos != -1) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1675 s->list = g_list_remove(s->list, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1676 s->ordered = g_list_remove(s->ordered, widget); |
15818 | 1677 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1678 if (s->ordered && wm->cws == s) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1679 gnt_wm_raise_window(wm, s->ordered->data); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1680 } |
15818 | 1681 } |
1682 | |
1683 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1684 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 1685 } |
1686 | |
1687 time_t gnt_wm_get_idle_time() | |
1688 { | |
1689 return time(NULL) - last_active_time; | |
1690 } | |
1691 | |
1692 gboolean gnt_wm_process_input(GntWM *wm, const char *keys) | |
1693 { | |
1694 gboolean ret = FALSE; | |
1695 | |
1696 keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys); | |
1697 | |
1698 idle_update = TRUE; | |
1699 | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1700 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { |
15818 | 1701 return TRUE; |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1702 } |
15818 | 1703 |
1704 /* Do some manual checking */ | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1705 if (wm->cws->ordered && wm->mode != GNT_KP_MODE_NORMAL) { |
15818 | 1706 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1; |
1707 int x, y, w, h; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1708 GntWidget *widget = GNT_WIDGET(wm->cws->ordered->data); |
15818 | 1709 int ox, oy, ow, oh; |
1710 | |
1711 gnt_widget_get_position(widget, &x, &y); | |
1712 gnt_widget_get_size(widget, &w, &h); | |
1713 ox = x; oy = y; | |
1714 ow = w; oh = h; | |
1715 | |
1716 if (wm->mode == GNT_KP_MODE_MOVE) { | |
1717 if (strcmp(keys, GNT_KEY_LEFT) == 0) { | |
1718 if (x > xmin) | |
1719 x--; | |
1720 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { | |
1721 if (x + w < xmax) | |
1722 x++; | |
1723 } else if (strcmp(keys, GNT_KEY_UP) == 0) { | |
1724 if (y > ymin) | |
1725 y--; | |
1726 } else if (strcmp(keys, GNT_KEY_DOWN) == 0) { | |
1727 if (y + h < ymax) | |
1728 y++; | |
1729 } | |
1730 if (ox != x || oy != y) { | |
1731 gnt_screen_move_widget(widget, x, y); | |
1732 window_reverse(widget, TRUE, wm); | |
1733 return TRUE; | |
1734 } | |
1735 } else if (wm->mode == GNT_KP_MODE_RESIZE) { | |
1736 if (strcmp(keys, GNT_KEY_LEFT) == 0) { | |
1737 w--; | |
1738 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { | |
1739 if (x + w < xmax) | |
1740 w++; | |
1741 } else if (strcmp(keys, GNT_KEY_UP) == 0) { | |
1742 h--; | |
1743 } else if (strcmp(keys, GNT_KEY_DOWN) == 0) { | |
1744 if (y + h < ymax) | |
1745 h++; | |
1746 } | |
1747 if (oh != h || ow != w) { | |
1748 gnt_screen_resize_widget(widget, w, h); | |
1749 window_reverse(widget, TRUE, wm); | |
1750 return TRUE; | |
1751 } | |
1752 } | |
1753 if (strcmp(keys, "\r") == 0 || strcmp(keys, "\033") == 0) { | |
1754 window_reverse(widget, FALSE, wm); | |
1755 wm->mode = GNT_KP_MODE_NORMAL; | |
1756 } | |
1757 return TRUE; | |
1758 } | |
1759 | |
1760 /* Escape to close the window-list or action-list window */ | |
1761 if (strcmp(keys, "\033") == 0) { | |
1762 if (wm->_list.window) { | |
1763 gnt_widget_destroy(wm->_list.window); | |
1764 return TRUE; | |
1765 } | |
1766 } else if (keys[0] == '\033' && isdigit(keys[1]) && keys[2] == '\0') { | |
1767 /* Alt+x for quick switch */ | |
1768 int n = *(keys + 1) - '0'; | |
1769 GList *list = NULL; | |
1770 | |
1771 if (n == 0) | |
1772 n = 10; | |
1773 | |
1774 list = g_list_append(list, GINT_TO_POINTER(n - 1)); | |
1775 switch_window_n(GNT_BINDABLE(wm), list); | |
1776 g_list_free(list); | |
1777 return TRUE; | |
1778 } | |
1779 | |
1780 if (wm->menu) | |
1781 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys); | |
1782 else if (wm->_list.window) | |
1783 ret = gnt_widget_key_pressed(wm->_list.window, keys); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1784 else if (wm->cws->ordered) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1785 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->cws->ordered->data), keys); |
15818 | 1786 return ret; |
1787 } | |
1788 | |
1789 static void | |
1790 gnt_wm_win_resized(GntWM *wm, GntNode *node) | |
1791 { | |
1792 /*refresh_node(node->me, node, NULL);*/ | |
1793 } | |
1794 | |
1795 static void | |
1796 gnt_wm_win_moved(GntWM *wm, GntNode *node) | |
1797 { | |
1798 refresh_node(node->me, node, NULL); | |
1799 } | |
1800 | |
1801 void gnt_wm_resize_window(GntWM *wm, GntWidget *widget, int width, int height) | |
1802 { | |
1803 gboolean ret = TRUE; | |
1804 GntNode *node; | |
1805 int shadow; | |
1806 int maxx, maxy; | |
1807 | |
1808 while (widget->parent) | |
1809 widget = widget->parent; | |
1810 node = g_hash_table_lookup(wm->nodes, widget); | |
1811 if (!node) | |
1812 return; | |
1813 | |
1814 g_signal_emit(wm, signals[SIG_CONFIRM_RESIZE], 0, widget, &width, &height, &ret); | |
1815 if (!ret) | |
1816 return; /* resize is not permitted */ | |
1817 hide_panel(node->panel); | |
1818 gnt_widget_set_size(widget, width, height); | |
1819 gnt_widget_draw(widget); | |
1820 | |
1821 shadow = gnt_widget_has_shadow(widget) ? 1 : 0; | |
1822 maxx = getmaxx(stdscr) - shadow; | |
1823 maxy = getmaxy(stdscr) - 1 - shadow; | |
1824 height = MIN(height, maxy); | |
1825 width = MIN(width, maxx); | |
15978
2a82bc8d57f7
More fixes for resizing when shadow is turned on.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15964
diff
changeset
|
1826 wresize(node->window, height, width); |
15818 | 1827 replace_panel(node->panel, node->window); |
1828 | |
1829 g_signal_emit(wm, signals[SIG_RESIZED], 0, node); | |
1830 | |
1831 show_panel(node->panel); | |
1832 update_screen(wm); | |
1833 } | |
1834 | |
1835 static void | |
1836 write_gdi(gpointer key, gpointer value, gpointer data) | |
1837 { | |
1838 GntPosition *p = value; | |
1839 fprintf(data, ".%s = %d;%d\n", (char *)key, p->x, p->y); | |
1840 } | |
1841 | |
1842 static gboolean | |
1843 write_already(gpointer data) | |
1844 { | |
1845 GntWM *wm = data; | |
1846 FILE *file; | |
1847 char *filename; | |
1848 | |
1849 filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL); | |
1850 | |
1851 file = fopen(filename, "wb"); | |
1852 if (file == NULL) { | |
1853 g_printerr("GntWM: error opening file to save positions\n"); | |
1854 } else { | |
1855 fprintf(file, "[positions]\n"); | |
1856 g_hash_table_foreach(wm->positions, write_gdi, file); | |
1857 fclose(file); | |
1858 } | |
1859 | |
1860 g_free(filename); | |
1861 g_source_remove(write_timeout); | |
1862 write_timeout = 0; | |
1863 return FALSE; | |
1864 } | |
1865 | |
1866 static void | |
1867 write_positions_to_file(GntWM *wm) | |
1868 { | |
1869 if (write_timeout) { | |
1870 g_source_remove(write_timeout); | |
1871 } | |
1872 write_timeout = g_timeout_add(10000, write_already, wm); | |
1873 } | |
1874 | |
1875 void gnt_wm_move_window(GntWM *wm, GntWidget *widget, int x, int y) | |
1876 { | |
1877 gboolean ret = TRUE; | |
1878 GntNode *node; | |
1879 | |
1880 while (widget->parent) | |
1881 widget = widget->parent; | |
1882 node = g_hash_table_lookup(wm->nodes, widget); | |
1883 if (!node) | |
1884 return; | |
1885 | |
1886 g_signal_emit(wm, signals[SIG_CONFIRM_MOVE], 0, widget, &x, &y, &ret); | |
1887 if (!ret) | |
1888 return; /* resize is not permitted */ | |
1889 | |
1890 gnt_widget_set_position(widget, x, y); | |
1891 move_panel(node->panel, y, x); | |
1892 | |
1893 g_signal_emit(wm, signals[SIG_MOVED], 0, node); | |
15995
bc2dd3358d46
Don't remember the position of transient windows
Richard Nelson <wabz@pidgin.im>
parents:
15978
diff
changeset
|
1894 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE) && GNT_IS_BOX(widget) && |
bc2dd3358d46
Don't remember the position of transient windows
Richard Nelson <wabz@pidgin.im>
parents:
15978
diff
changeset
|
1895 !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { |
15818 | 1896 const char *title = GNT_BOX(widget)->title; |
1897 if (title) { | |
1898 GntPosition *p = g_new0(GntPosition, 1); | |
1899 GntWidget *wid = node->me; | |
1900 p->x = wid->priv.x; | |
1901 p->y = wid->priv.y; | |
1902 g_hash_table_replace(wm->positions, g_strdup(title), p); | |
1903 write_positions_to_file(wm); | |
1904 } | |
1905 } | |
1906 | |
1907 update_screen(wm); | |
1908 } | |
1909 | |
1910 static void | |
1911 gnt_wm_give_focus(GntWM *wm, GntWidget *widget) | |
1912 { | |
1913 GntNode *node = g_hash_table_lookup(wm->nodes, widget); | |
1914 | |
1915 if (!node) | |
1916 return; | |
1917 | |
1918 if (widget != wm->_list.window && !GNT_IS_MENU(widget) && | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1919 wm->cws->ordered->data != widget) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1920 GntWidget *w = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1921 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget); |
15818 | 1922 gnt_widget_set_focus(w, FALSE); |
1923 } | |
1924 | |
1925 gnt_widget_set_focus(widget, TRUE); | |
1926 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT); | |
1927 gnt_widget_draw(widget); | |
1928 top_panel(node->panel); | |
1929 | |
1930 if (wm->_list.window) { | |
1931 GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window); | |
1932 top_panel(nd->panel); | |
1933 } | |
1934 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1935 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 1936 } |
1937 | |
1938 void gnt_wm_update_window(GntWM *wm, GntWidget *widget) | |
1939 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1940 GntNode *node = NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1941 GntWS *ws; |
15818 | 1942 |
1943 while (widget->parent) | |
1944 widget = widget->parent; | |
1945 if (!GNT_IS_MENU(widget)) | |
1946 gnt_box_sync_children(GNT_BOX(widget)); | |
1947 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1948 ws = gnt_wm_widget_find_workspace(wm, widget); |
15818 | 1949 node = g_hash_table_lookup(wm->nodes, widget); |
1950 if (node == NULL) { | |
1951 gnt_wm_new_window(wm, widget); | |
1952 } else | |
1953 g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node); | |
1954 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1955 if (ws == wm->cws || GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1956 gnt_wm_copy_win(widget, node); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1957 update_screen(wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1958 gnt_ws_draw_taskbar(wm->cws, FALSE); |
16472
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1959 } else if (ws != wm->cws && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_URGENT)) { |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1960 if (!act || (act && !g_list_find(act, ws))) |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1961 act = g_list_prepend(act, ws); |
4ea517cb7ceb
Show an activity message when a window in the non-current workspace is flagged urgent
Richard Nelson <wabz@pidgin.im>
parents:
16471
diff
changeset
|
1962 update_act_msg(); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1963 } |
15818 | 1964 } |
1965 | |
1966 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget) | |
1967 { | |
1968 gboolean ret = TRUE; | |
1969 idle_update = TRUE; | |
1970 g_signal_emit(wm, signals[SIG_MOUSE_CLICK], 0, event, x, y, widget, &ret); | |
1971 return ret; | |
1972 } | |
1973 | |
1974 void gnt_wm_raise_window(GntWM *wm, GntWidget *widget) | |
1975 { | |
18070 | 1976 GntWS *ws = gnt_wm_widget_find_workspace(wm, widget); |
1977 if (wm->cws != ws) | |
1978 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws)); | |
15818 | 1979 g_signal_emit(wm, signals[SIG_GIVE_FOCUS], 0, widget); |
1980 } | |
1981 | |
16281
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1982 void gnt_wm_set_event_stack(GntWM *wm, gboolean set) |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1983 { |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1984 wm->event_stack = set; |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1985 } |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
1986 |