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