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