Mercurial > pidgin.yaz
annotate finch/libgnt/gntwm.c @ 19120:b25cb0775be3
explicit merge of 'e53fe113efde971f9f1d14d8a7af937542ee2732'
and 'fac895a331d8ffa475b42a0eaf193587799661b9'
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Thu, 28 Jun 2007 03:09:03 +0000 |
parents | d359e5f3ee87 c0abe71ac1ff |
children | 6dded98d1c80 |
rev | line source |
---|---|
18049
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
1 /** |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
2 * GNT - The GLib Ncurses Toolkit |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
3 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
4 * GNT is the legal property of its developers, whose names are too numerous |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
6 * source distribution. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
7 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
8 * This library is free software; you can redistribute it and/or modify |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
11 * (at your option) any later version. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
12 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
16 * GNU General Public License for more details. |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
17 * |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
21 */ |
1cedd520cd18
Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17528
diff
changeset
|
22 |
15818 | 23 #define _GNU_SOURCE |
17528
c0c17a81f5fe
Fix libgnt compilation on BSD and solaris. This references #516.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17251
diff
changeset
|
24 #if defined(__APPLE__) || defined(__unix__) |
15818 | 25 #define _XOPEN_SOURCE_EXTENDED |
26 #endif | |
27 | |
28 #include "config.h" | |
29 | |
30 #include <ctype.h> | |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
31 #include <glib/gprintf.h> |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
32 #include <gmodule.h> |
15818 | 33 #include <stdlib.h> |
34 #include <string.h> | |
35 #include <time.h> | |
36 | |
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; |
15818 | 89 |
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) { |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
341 wm->cws = gnt_ws_new("default"); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
342 gnt_wm_add_workspace(wm, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
343 } else { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
344 wm->cws = wm->workspaces->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
345 } |
15818 | 346 wm->event_stack = FALSE; |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
347 wm->tagged = NULL; |
15818 | 348 wm->windows = NULL; |
349 wm->actions = NULL; | |
350 wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); | |
351 wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
352 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE)) | |
353 read_window_positions(wm); | |
354 g_timeout_add(IDLE_CHECK_INTERVAL * 1000, check_idle, NULL); | |
355 time(&last_active_time); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
356 gnt_wm_switch_workspace(wm, 0); |
15818 | 357 } |
358 | |
359 static void | |
360 switch_window(GntWM *wm, int direction) | |
361 { | |
362 GntWidget *w = NULL, *wid = NULL; | |
363 int pos; | |
364 | |
365 if (wm->_list.window || wm->menu) | |
366 return; | |
367 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
368 if (!wm->cws->ordered || !wm->cws->ordered->next) |
15818 | 369 return; |
370 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
371 w = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
372 pos = g_list_index(wm->cws->list, w); |
15818 | 373 pos += direction; |
374 | |
375 if (pos < 0) | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
376 wid = g_list_last(wm->cws->list)->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
377 else if (pos >= g_list_length(wm->cws->list)) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
378 wid = wm->cws->list->data; |
15818 | 379 else if (pos >= 0) |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
380 wid = g_list_nth_data(wm->cws->list, pos); |
15818 | 381 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
382 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, wid); |
15818 | 383 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
384 gnt_wm_raise_window(wm, wm->cws->ordered->data); |
15818 | 385 |
386 if (w != wid) { | |
387 gnt_widget_set_focus(w, FALSE); | |
388 } | |
389 } | |
390 | |
391 static gboolean | |
392 window_next(GntBindable *bindable, GList *null) | |
393 { | |
394 GntWM *wm = GNT_WM(bindable); | |
395 switch_window(wm, 1); | |
396 return TRUE; | |
397 } | |
398 | |
399 static gboolean | |
400 window_prev(GntBindable *bindable, GList *null) | |
401 { | |
402 GntWM *wm = GNT_WM(bindable); | |
403 switch_window(wm, -1); | |
404 return TRUE; | |
405 } | |
406 | |
407 static gboolean | |
408 switch_window_n(GntBindable *bind, GList *list) | |
409 { | |
410 GntWM *wm = GNT_WM(bind); | |
411 GntWidget *w = NULL; | |
412 GList *l; | |
413 int n; | |
414 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
415 if (!wm->cws->ordered) |
15818 | 416 return TRUE; |
417 | |
418 if (list) | |
419 n = GPOINTER_TO_INT(list->data); | |
420 else | |
421 n = 0; | |
422 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
423 w = wm->cws->ordered->data; |
15818 | 424 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
425 if ((l = g_list_nth(wm->cws->list, n)) != NULL) |
15818 | 426 { |
427 gnt_wm_raise_window(wm, l->data); | |
428 } | |
429 | |
430 if (l && w != l->data) | |
431 { | |
432 gnt_widget_set_focus(w, FALSE); | |
433 } | |
434 return TRUE; | |
435 } | |
436 | |
437 static gboolean | |
438 window_scroll_up(GntBindable *bindable, GList *null) | |
439 { | |
440 GntWM *wm = GNT_WM(bindable); | |
441 GntWidget *window; | |
442 GntNode *node; | |
443 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
444 if (!wm->cws->ordered) |
15818 | 445 return TRUE; |
446 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
447 window = wm->cws->ordered->data; |
15818 | 448 node = g_hash_table_lookup(wm->nodes, window); |
449 if (!node) | |
450 return TRUE; | |
451 | |
452 if (node->scroll) { | |
453 node->scroll--; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
454 gnt_wm_copy_win(window, node); |
15818 | 455 update_screen(wm); |
456 } | |
457 return TRUE; | |
458 } | |
459 | |
460 static gboolean | |
461 window_scroll_down(GntBindable *bindable, GList *null) | |
462 { | |
463 GntWM *wm = GNT_WM(bindable); | |
464 GntWidget *window; | |
465 GntNode *node; | |
466 int w, h; | |
467 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
468 if (!wm->cws->ordered) |
15818 | 469 return TRUE; |
470 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
471 window = wm->cws->ordered->data; |
15818 | 472 node = g_hash_table_lookup(wm->nodes, window); |
473 if (!node) | |
474 return TRUE; | |
475 | |
476 gnt_widget_get_size(window, &w, &h); | |
477 if (h - node->scroll > getmaxy(node->window)) { | |
478 node->scroll++; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
479 gnt_wm_copy_win(window, node); |
15818 | 480 update_screen(wm); |
481 } | |
482 return TRUE; | |
483 } | |
484 | |
485 static gboolean | |
486 window_close(GntBindable *bindable, GList *null) | |
487 { | |
488 GntWM *wm = GNT_WM(bindable); | |
489 | |
490 if (wm->_list.window) | |
491 return TRUE; | |
492 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
493 if (wm->cws->ordered) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
494 gnt_widget_destroy(wm->cws->ordered->data); |
15818 | 495 } |
496 | |
497 return TRUE; | |
498 } | |
499 | |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
500 static gboolean |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
501 help_for_widget(GntBindable *bindable, GList *null) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
502 { |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
503 GntWM *wm = GNT_WM(bindable); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
504 GntWidget *widget, *tree, *win, *active; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
505 char *title; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
506 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
507 if (!wm->cws->ordered) |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
508 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
509 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
510 widget = wm->cws->ordered->data; |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
511 if (!GNT_IS_BOX(widget)) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
512 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
513 active = GNT_BOX(widget)->active; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
514 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
515 tree = gnt_widget_bindings_view(active); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
516 win = gnt_window_new(); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
517 title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(active))); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
518 gnt_box_set_title(GNT_BOX(win), title); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
519 if (tree) |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
520 gnt_box_add_widget(GNT_BOX(win), tree); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
521 else |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
522 gnt_box_add_widget(GNT_BOX(win), gnt_label_new("This widget has no customizable bindings.")); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
523 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
524 gnt_widget_show(win); |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
525 |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
526 return TRUE; |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
527 } |
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
528 |
15818 | 529 static void |
530 destroy__list(GntWidget *widget, GntWM *wm) | |
531 { | |
532 wm->_list.window = NULL; | |
533 wm->_list.tree = NULL; | |
534 wm->windows = NULL; | |
535 wm->actions = NULL; | |
536 update_screen(wm); | |
537 } | |
538 | |
539 static void | |
540 setup__list(GntWM *wm) | |
541 { | |
542 GntWidget *tree, *win; | |
543 win = wm->_list.window = gnt_box_new(FALSE, FALSE); | |
544 gnt_box_set_toplevel(GNT_BOX(win), TRUE); | |
545 gnt_box_set_pad(GNT_BOX(win), 0); | |
546 GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_TRANSIENT); | |
547 | |
548 tree = wm->_list.tree = gnt_tree_new(); | |
549 gnt_box_add_widget(GNT_BOX(win), tree); | |
550 | |
551 g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(destroy__list), wm); | |
552 } | |
553 | |
554 static void | |
555 window_list_activate(GntTree *tree, GntWM *wm) | |
556 { | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
557 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(tree)); |
15818 | 558 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
559 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
|
560 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
561 if (!sel) |
15818 | 562 return; |
563 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
564 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
|
565 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
|
566 } else { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
567 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
|
568 } |
15818 | 569 } |
570 | |
571 static void | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
572 populate_window_list(GntWM *wm, gboolean workspace) |
15818 | 573 { |
574 GList *iter; | |
575 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
|
576 if (!workspace) { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
577 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
|
578 GntBox *box = GNT_BOX(iter->data); |
15818 | 579 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
580 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
|
581 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
|
582 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
|
583 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
584 } else { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
585 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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 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
|
591 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
592 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
|
593 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
|
594 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
|
595 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
596 } |
15818 | 597 } |
598 } | |
599 | |
600 static gboolean | |
601 window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm) | |
602 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
603 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
|
604 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(widget)); |
15818 | 605 switch (text[0]) { |
606 case '-': | |
16127
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
607 case ',': |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
608 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
|
609 /* reorder the workspace. */ |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
610 } else |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
611 shift_window(wm, GNT_WIDGET(sel), -1); |
15818 | 612 break; |
16127
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
613 case '=': |
063274e9cb27
These bindings are easier for changing window order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16126
diff
changeset
|
614 case '.': |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
615 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
|
616 /* reorder the workspace. */ |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
617 } else |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
618 shift_window(wm, GNT_WIDGET(sel), 1); |
15818 | 619 break; |
620 default: | |
621 return FALSE; | |
622 } | |
623 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
|
624 populate_window_list(wm, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "workspace"))); |
15818 | 625 gnt_tree_set_selected(GNT_TREE(widget), sel); |
626 return TRUE; | |
627 } | |
628 return FALSE; | |
629 } | |
630 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
631 static void |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
632 list_of_windows(GntWM *wm, gboolean workspace) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
633 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
634 GntWidget *tree, *win; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
635 setup__list(wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
636 wm->windows = &wm->_list; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
637 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
638 win = wm->windows->window; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
639 tree = wm->windows->tree; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
640 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
641 gnt_box_set_title(GNT_BOX(win), workspace ? "Workspace List" : "Window List"); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
642 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
643 populate_window_list(wm, workspace); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
644 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
645 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
|
646 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
|
647 else if (workspace) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
648 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
|
649 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
650 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
651 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
652 g_object_set_data(G_OBJECT(tree), "workspace", GINT_TO_POINTER(workspace)); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
653 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
654 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
655 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
656 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
657 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
658 gnt_widget_show(win); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
659 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
660 |
15818 | 661 static gboolean |
662 window_list(GntBindable *bindable, GList *null) | |
663 { | |
664 GntWM *wm = GNT_WM(bindable); | |
665 | |
666 if (wm->_list.window || wm->menu) | |
667 return TRUE; | |
668 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
669 if (!wm->cws->ordered) |
15818 | 670 return TRUE; |
671 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
672 list_of_windows(wm, FALSE); |
15818 | 673 |
674 return TRUE; | |
675 } | |
676 | |
677 static gboolean | |
678 dump_screen(GntBindable *bindable, GList *null) | |
679 { | |
680 int x, y; | |
681 chtype old = 0, now = 0; | |
682 FILE *file = fopen("dump.html", "w"); | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
683 struct { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
684 char ascii; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
685 char *unicode; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
686 } unis[] = { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
687 {'q', "─"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
688 {'t', "├"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
689 {'u', "┤"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
690 {'x', "│"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
691 {'-', "↑"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
692 {'.', "↓"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
693 {'l', "┌"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
694 {'k', "┐"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
695 {'m', "└"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
696 {'j', "┘"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
697 {'a', "▒"}, |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
698 {'\0', NULL} |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
699 }; |
15818 | 700 |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
701 fprintf(file, "<head>\n <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n</head>\n<body>\n"); |
15818 | 702 fprintf(file, "<pre>"); |
703 for (y = 0; y < getmaxy(stdscr); y++) { | |
704 for (x = 0; x < getmaxx(stdscr); x++) { | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
705 char ch[2] = {0, 0}, *print; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
706 #ifdef NO_WIDECHAR |
15818 | 707 now = mvwinch(curscr, y, x); |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
708 ch[0] = now & A_CHARTEXT; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
709 now ^= ch[0]; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
710 #else |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
711 cchar_t wch; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
712 char unicode[12]; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
713 mvwin_wch(curscr, y, x, &wch); |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
714 now = wch.attr; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
715 ch[0] = (char)(wch.chars[0] & 0xff); |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
716 #endif |
15818 | 717 |
718 #define CHECK(attr, start, end) \ | |
719 do \ | |
720 { \ | |
721 if (now & attr) \ | |
722 { \ | |
723 if (!(old & attr)) \ | |
724 fprintf(file, "%s", start); \ | |
725 } \ | |
726 else if (old & attr) \ | |
727 { \ | |
728 fprintf(file, "%s", end); \ | |
729 } \ | |
730 } while (0) | |
731 | |
732 CHECK(A_BOLD, "<b>", "</b>"); | |
733 CHECK(A_UNDERLINE, "<u>", "</u>"); | |
734 CHECK(A_BLINK, "<blink>", "</blink>"); | |
735 | |
736 if ((now & A_COLOR) != (old & A_COLOR) || | |
737 (now & A_REVERSE) != (old & A_REVERSE)) | |
738 { | |
739 int ret; | |
740 short fgp, bgp, r, g, b; | |
741 struct | |
742 { | |
743 int r, g, b; | |
744 } fg, bg; | |
745 | |
746 ret = pair_content(PAIR_NUMBER(now & A_COLOR), &fgp, &bgp); | |
747 if (fgp == -1) | |
748 fgp = COLOR_BLACK; | |
749 if (bgp == -1) | |
750 bgp = COLOR_WHITE; | |
751 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
|
752 { |
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
753 short tmp = fgp; |
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
754 fgp = bgp; |
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
755 bgp = tmp; |
e5cc13b1e0ca
Fix a compiler warning by using a temporary variable for swapping.
Richard Laager <rlaager@wiktel.com>
parents:
17140
diff
changeset
|
756 } |
15818 | 757 ret = color_content(fgp, &r, &g, &b); |
758 fg.r = r; fg.b = b; fg.g = g; | |
759 ret = color_content(bgp, &r, &g, &b); | |
760 bg.r = r; bg.b = b; bg.g = g; | |
761 #define ADJUST(x) (x = x * 255 / 1000) | |
762 ADJUST(fg.r); | |
763 ADJUST(fg.g); | |
764 ADJUST(fg.b); | |
765 ADJUST(bg.r); | |
766 ADJUST(bg.b); | |
767 ADJUST(bg.g); | |
768 | |
769 if (x) fprintf(file, "</span>"); | |
770 fprintf(file, "<span style=\"background:#%02x%02x%02x;color:#%02x%02x%02x\">", | |
771 bg.r, bg.g, bg.b, fg.r, fg.g, fg.b); | |
772 } | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
773 print = ch; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
774 #ifndef NO_WIDECHAR |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
775 if (wch.chars[0] > 255) { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
776 snprintf(unicode, sizeof(unicode), "&#x%x;", wch.chars[0]); |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
777 print = unicode; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
778 } |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
779 #endif |
15818 | 780 if (now & A_ALTCHARSET) |
781 { | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
782 int u; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
783 for (u = 0; unis[u].ascii; u++) { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
784 if (ch[0] == unis[u].ascii) { |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
785 print = unis[u].unicode; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
786 break; |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
787 } |
15818 | 788 } |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
789 if (!unis[u].ascii) |
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
790 print = " "; |
15818 | 791 } |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
792 if (ch[0] == '&') |
15818 | 793 fprintf(file, "&"); |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
794 else if (ch[0] == '<') |
15818 | 795 fprintf(file, "<"); |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
796 else if (ch[0] == '>') |
15818 | 797 fprintf(file, ">"); |
798 else | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
799 fprintf(file, "%s", print); |
15818 | 800 old = now; |
801 } | |
802 fprintf(file, "</span>\n"); | |
803 old = 0; | |
804 } | |
17140
3c4280387259
Generate nicer HTML dumps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17059
diff
changeset
|
805 fprintf(file, "</pre>\n</body>"); |
15818 | 806 fclose(file); |
807 return TRUE; | |
808 } | |
809 | |
810 static void | |
811 shift_window(GntWM *wm, GntWidget *widget, int dir) | |
812 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
813 GList *all = wm->cws->list; |
15818 | 814 GList *list = g_list_find(all, widget); |
815 int length, pos; | |
816 if (!list) | |
817 return; | |
818 | |
819 length = g_list_length(all); | |
820 pos = g_list_position(all, list); | |
821 | |
822 pos += dir; | |
823 if (dir > 0) | |
824 pos++; | |
825 | |
826 if (pos < 0) | |
827 pos = length; | |
828 else if (pos > length) | |
829 pos = 0; | |
830 | |
831 all = g_list_insert(all, widget, pos); | |
832 all = g_list_delete_link(all, list); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
833 wm->cws->list = all; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
834 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 835 } |
836 | |
837 static gboolean | |
838 shift_left(GntBindable *bindable, GList *null) | |
839 { | |
840 GntWM *wm = GNT_WM(bindable); | |
841 if (wm->_list.window) | |
842 return TRUE; | |
843 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
844 shift_window(wm, wm->cws->ordered->data, -1); |
15818 | 845 return TRUE; |
846 } | |
847 | |
848 static gboolean | |
849 shift_right(GntBindable *bindable, GList *null) | |
850 { | |
851 GntWM *wm = GNT_WM(bindable); | |
852 if (wm->_list.window) | |
853 return TRUE; | |
854 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
855 shift_window(wm, wm->cws->ordered->data, 1); |
15818 | 856 return TRUE; |
857 } | |
858 | |
859 static void | |
860 action_list_activate(GntTree *tree, GntWM *wm) | |
861 { | |
862 GntAction *action = gnt_tree_get_selection_data(tree); | |
863 action->callback(); | |
864 gnt_widget_destroy(wm->_list.window); | |
865 } | |
866 | |
867 static int | |
868 compare_action(gconstpointer p1, gconstpointer p2) | |
869 { | |
870 const GntAction *a1 = p1; | |
871 const GntAction *a2 = p2; | |
872 | |
873 return g_utf8_collate(a1->label, a2->label); | |
874 } | |
875 | |
876 static gboolean | |
877 list_actions(GntBindable *bindable, GList *null) | |
878 { | |
879 GntWidget *tree, *win; | |
880 GList *iter; | |
881 GntWM *wm = GNT_WM(bindable); | |
882 if (wm->_list.window || wm->menu) | |
883 return TRUE; | |
884 | |
885 if (wm->acts == NULL) | |
886 return TRUE; | |
887 | |
888 setup__list(wm); | |
889 wm->actions = &wm->_list; | |
890 | |
891 win = wm->actions->window; | |
892 tree = wm->actions->tree; | |
893 | |
894 gnt_box_set_title(GNT_BOX(win), "Actions"); | |
895 GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER); | |
896 /* XXX: Do we really want this? */ | |
897 gnt_tree_set_compare_func(GNT_TREE(tree), compare_action); | |
898 | |
899 for (iter = wm->acts; iter; iter = iter->next) { | |
900 GntAction *action = iter->data; | |
901 gnt_tree_add_row_last(GNT_TREE(tree), action, | |
902 gnt_tree_create_row(GNT_TREE(tree), action->label), NULL); | |
903 } | |
904 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(action_list_activate), wm); | |
905 gnt_widget_set_size(tree, 0, g_list_length(wm->acts)); | |
906 gnt_widget_set_position(win, 0, getmaxy(stdscr) - 3 - g_list_length(wm->acts)); | |
907 | |
908 gnt_widget_show(win); | |
909 return TRUE; | |
910 } | |
911 | |
912 #ifndef NO_WIDECHAR | |
913 static int | |
914 widestringwidth(wchar_t *wide) | |
915 { | |
916 int len, ret; | |
917 char *string; | |
918 | |
919 len = wcstombs(NULL, wide, 0) + 1; | |
920 string = g_new0(char, len); | |
921 wcstombs(string, wide, len); | |
922 ret = gnt_util_onscreen_width(string, NULL); | |
923 g_free(string); | |
924 return ret; | |
925 } | |
926 #endif | |
927 | |
928 /* Returns the onscreen width of the character at the position */ | |
929 static int | |
930 reverse_char(WINDOW *d, int y, int x, gboolean set) | |
931 { | |
932 #define DECIDE(ch) (set ? ((ch) | A_REVERSE) : ((ch) & ~A_REVERSE)) | |
933 | |
934 #ifdef NO_WIDECHAR | |
935 chtype ch; | |
936 ch = mvwinch(d, y, x); | |
937 mvwaddch(d, y, x, DECIDE(ch)); | |
938 return 1; | |
939 #else | |
940 cchar_t ch; | |
941 int wc = 1; | |
942 if (mvwin_wch(d, y, x, &ch) == OK) { | |
943 wc = widestringwidth(ch.chars); | |
944 ch.attr = DECIDE(ch.attr); | |
945 ch.attr &= WA_ATTRIBUTES; /* XXX: This is a workaround for a bug */ | |
946 mvwadd_wch(d, y, x, &ch); | |
947 } | |
948 | |
949 return wc; | |
950 #endif | |
951 } | |
952 | |
953 static void | |
954 window_reverse(GntWidget *win, gboolean set, GntWM *wm) | |
955 { | |
956 int i; | |
957 int w, h; | |
958 WINDOW *d; | |
959 | |
960 if (GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_NO_BORDER)) | |
961 return; | |
962 | |
963 d = win->window; | |
964 gnt_widget_get_size(win, &w, &h); | |
965 | |
966 if (gnt_widget_has_shadow(win)) { | |
967 --w; | |
968 --h; | |
969 } | |
970 | |
971 /* the top and bottom */ | |
972 for (i = 0; i < w; i += reverse_char(d, 0, i, set)); | |
973 for (i = 0; i < w; i += reverse_char(d, h-1, i, set)); | |
974 | |
975 /* the left and right */ | |
976 for (i = 0; i < h; i += reverse_char(d, i, 0, set)); | |
977 for (i = 0; i < h; i += reverse_char(d, i, w-1, set)); | |
978 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
979 gnt_wm_copy_win(win, g_hash_table_lookup(wm->nodes, win)); |
15818 | 980 update_screen(wm); |
981 } | |
982 | |
983 static gboolean | |
984 start_move(GntBindable *bindable, GList *null) | |
985 { | |
986 GntWM *wm = GNT_WM(bindable); | |
987 if (wm->_list.window || wm->menu) | |
988 return TRUE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
989 if (!wm->cws->ordered) |
15818 | 990 return TRUE; |
991 | |
992 wm->mode = GNT_KP_MODE_MOVE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
993 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); |
15818 | 994 |
995 return TRUE; | |
996 } | |
997 | |
998 static gboolean | |
999 start_resize(GntBindable *bindable, GList *null) | |
1000 { | |
1001 GntWM *wm = GNT_WM(bindable); | |
1002 if (wm->_list.window || wm->menu) | |
1003 return TRUE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1004 if (!wm->cws->ordered) |
15818 | 1005 return TRUE; |
1006 | |
1007 wm->mode = GNT_KP_MODE_RESIZE; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1008 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); |
15818 | 1009 |
1010 return TRUE; | |
1011 } | |
1012 | |
1013 static gboolean | |
1014 wm_quit(GntBindable *bindable, GList *list) | |
1015 { | |
1016 GntWM *wm = GNT_WM(bindable); | |
1017 if (write_timeout) | |
1018 write_already(wm); | |
1019 g_main_loop_quit(wm->loop); | |
1020 return TRUE; | |
1021 } | |
1022 | |
1023 static gboolean | |
1024 return_true(GntWM *wm, GntWidget *w, int *a, int *b) | |
1025 { | |
1026 return TRUE; | |
1027 } | |
1028 | |
1029 static gboolean | |
1030 refresh_screen(GntBindable *bindable, GList *null) | |
1031 { | |
1032 GntWM *wm = GNT_WM(bindable); | |
1033 | |
1034 endwin(); | |
1035 | |
1036 g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, NULL); | |
1037 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1038 gnt_ws_draw_taskbar(wm->cws, TRUE); |
18077
2141130ac557
This got lost from a merge I think. This refixes #532.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18075
diff
changeset
|
1039 curs_set(0); /* endwin resets the cursor to normal */ |
15818 | 1040 |
1041 return FALSE; | |
1042 } | |
1043 | |
16526
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1044 static gboolean |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1045 toggle_clipboard(GntBindable *bindable, GList *n) |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1046 { |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1047 static GntWidget *clip; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1048 gchar *text; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1049 int maxx, maxy; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1050 if (clip) { |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1051 gnt_widget_destroy(clip); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1052 clip = NULL; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1053 return TRUE; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1054 } |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1055 getmaxyx(stdscr, maxy, maxx); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1056 text = gnt_get_clipboard_string(); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1057 clip = gnt_hwindow_new(FALSE); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1058 GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_TRANSIENT); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1059 GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_NO_BORDER); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1060 gnt_box_set_pad(GNT_BOX(clip), 0); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1061 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1062 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text)); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1063 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1064 gnt_widget_set_position(clip, 0, 0); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1065 gnt_widget_draw(clip); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1066 g_free(text); |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1067 return TRUE; |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1068 } |
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1069 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1070 static void remove_tag(gpointer wid, gpointer wim) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1071 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1072 GntWM *wm = GNT_WM(wim); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1073 GntWidget *w = GNT_WIDGET(wid); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1074 wm->tagged = g_list_remove(wm->tagged, w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1075 mvwhline(w->window, 0, 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), 3); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1076 gnt_widget_draw(w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1077 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1078 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1079 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1080 tag_widget(GntBindable *b, GList *params) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1081 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1082 GntWM *wm = GNT_WM(b); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1083 GntWidget *widget; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1084 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1085 if (!wm->cws->ordered) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1086 return FALSE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1087 widget = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1088 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1089 if (g_list_find(wm->tagged, widget)) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1090 remove_tag(widget, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1091 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1092 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1093 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1094 wm->tagged = g_list_prepend(wm->tagged, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1095 wbkgdset(widget->window, ' ' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1096 mvwprintw(widget->window, 0, 1, "[T]"); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1097 gnt_widget_draw(widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1098 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1099 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1100 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1101 static void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1102 widget_move_ws(gpointer wid, gpointer w) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1103 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1104 GntWM *wm = GNT_WM(w); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1105 gnt_wm_widget_move_workspace(wm, wm->cws, GNT_WIDGET(wid)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1106 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1107 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1108 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1109 place_tagged(GntBindable *b, GList *params) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1110 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1111 GntWM *wm = GNT_WM(b); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1112 g_list_foreach(wm->tagged, widget_move_ws, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1113 g_list_foreach(wm->tagged, remove_tag, wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1114 g_list_free(wm->tagged); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1115 wm->tagged = NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1116 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1117 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1118 |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1119 static gboolean |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1120 workspace_list(GntBindable *b, GList *params) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1121 { |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1122 GntWM *wm = GNT_WM(b); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1123 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1124 if (wm->_list.window || wm->menu) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1125 return TRUE; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1126 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1127 list_of_windows(wm, TRUE); |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1128 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1129 return TRUE; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1130 } |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1131 |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1132 static gboolean |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1133 workspace_new(GntBindable *bindable, GList *null) |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1134 { |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1135 GntWM *wm = GNT_WM(bindable); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1136 GntWS *ws = gnt_ws_new(NULL); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1137 gnt_wm_add_workspace(wm, ws); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1138 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws)); |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1139 return TRUE; |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1140 } |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1141 |
19109
1cb69ea47a6e
propagate from branch 'im.pidgin.pidgin' (head d2f50519c5ed668dd980277afdc25d71ccb8a852)
Eric Polino <aluink@pidgin.im>
diff
changeset
|
1142 static gboolean |
17722
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1143 ignore_keys_start(GntBindable *bindable, GList *n) |
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1144 { |
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
|
1145 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
|
1146 |
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
|
1147 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
|
1148 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
|
1149 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
|
1150 } |
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
|
1151 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
|
1152 } |
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
|
1153 |
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
|
1154 static gboolean |
17722
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1155 ignore_keys_end(GntBindable *bindable, GList *n) |
17721
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1156 { |
17722
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1157 return ignore_keys ? !(ignore_keys = FALSE) : FALSE; |
17721
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1158 } |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1159 |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1160 static gboolean |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1161 help_for_bindable(GntWM *wm, GntBindable *bindable) |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1162 { |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1163 gboolean ret = TRUE; |
17722
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1164 GntBindableClass *klass = GNT_BINDABLE_GET_CLASS(bindable); |
17721
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1165 |
17722
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1166 if (klass->help_window) { |
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1167 gnt_wm_raise_window(wm, GNT_WIDGET(klass->help_window)); |
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1168 } else { |
17721
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1169 ret = gnt_bindable_build_help_window(bindable); |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1170 } |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1171 return ret; |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1172 |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1173 } |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1174 |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1175 static gboolean |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1176 help_for_wm(GntBindable *bindable, GList *null) |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1177 { |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1178 return help_for_bindable(GNT_WM(bindable),bindable); |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1179 } |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1180 |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1181 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
|
1182 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
|
1183 { |
c918d59d5936
Added the ability to change the key bindings on the active window.
Eric Polino <aluink@pidgin.im>
parents:
17722
diff
changeset
|
1184 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
|
1185 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
|
1186 |
c918d59d5936
Added the ability to change the key bindings on the active window.
Eric Polino <aluink@pidgin.im>
parents:
17722
diff
changeset
|
1187 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
|
1188 } |
c918d59d5936
Added the ability to change the key bindings on the active window.
Eric Polino <aluink@pidgin.im>
parents:
17722
diff
changeset
|
1189 |
c918d59d5936
Added the ability to change the key bindings on the active window.
Eric Polino <aluink@pidgin.im>
parents:
17722
diff
changeset
|
1190 static gboolean |
17721
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1191 help_for_widget(GntBindable *bindable, GList *null) |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1192 { |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1193 GntWM *wm = GNT_WM(bindable); |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1194 GntWidget *widget; |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1195 |
19099
a1ac8b05ecdb
Fixed a few problems that were created by the merge from the propagate.
Eric Polino <aluink@pidgin.im>
parents:
19098
diff
changeset
|
1196 if (!wm->cws->ordered) |
17721
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1197 return TRUE; |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1198 |
19099
a1ac8b05ecdb
Fixed a few problems that were created by the merge from the propagate.
Eric Polino <aluink@pidgin.im>
parents:
19098
diff
changeset
|
1199 widget = wm->cws->ordered->data; |
17721
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1200 if (!GNT_IS_BOX(widget)) |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1201 return TRUE; |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1202 |
17722
15988e2bd270
Mostly whitespace changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17721
diff
changeset
|
1203 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
|
1204 |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1205 } |
3ee6ea8a66f8
Moved rebinding functionality into GntBindable.
Eric Polino <aluink@pidgin.im>
parents:
17720
diff
changeset
|
1206 |
15818 | 1207 static void |
1208 gnt_wm_class_init(GntWMClass *klass) | |
1209 { | |
1210 int i; | |
1211 | |
1212 klass->new_window = gnt_wm_new_window_real; | |
1213 klass->decorate_window = NULL; | |
1214 klass->close_window = NULL; | |
1215 klass->window_resize_confirm = return_true; | |
1216 klass->window_resized = gnt_wm_win_resized; | |
1217 klass->window_move_confirm = return_true; | |
1218 klass->window_moved = gnt_wm_win_moved; | |
1219 klass->window_update = NULL; | |
1220 klass->key_pressed = NULL; | |
1221 klass->mouse_clicked = NULL; | |
1222 klass->give_focus = gnt_wm_give_focus; | |
1223 | |
1224 signals[SIG_NEW_WIN] = | |
1225 g_signal_new("new_win", | |
1226 G_TYPE_FROM_CLASS(klass), | |
1227 G_SIGNAL_RUN_LAST, | |
1228 G_STRUCT_OFFSET(GntWMClass, new_window), | |
1229 NULL, NULL, | |
1230 g_cclosure_marshal_VOID__POINTER, | |
1231 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1232 signals[SIG_DECORATE_WIN] = | |
1233 g_signal_new("decorate_win", | |
1234 G_TYPE_FROM_CLASS(klass), | |
1235 G_SIGNAL_RUN_LAST, | |
1236 G_STRUCT_OFFSET(GntWMClass, decorate_window), | |
1237 NULL, NULL, | |
1238 g_cclosure_marshal_VOID__POINTER, | |
1239 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1240 signals[SIG_CLOSE_WIN] = | |
1241 g_signal_new("close_win", | |
1242 G_TYPE_FROM_CLASS(klass), | |
1243 G_SIGNAL_RUN_LAST, | |
1244 G_STRUCT_OFFSET(GntWMClass, close_window), | |
1245 NULL, NULL, | |
1246 g_cclosure_marshal_VOID__POINTER, | |
1247 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1248 signals[SIG_CONFIRM_RESIZE] = | |
1249 g_signal_new("confirm_resize", | |
1250 G_TYPE_FROM_CLASS(klass), | |
1251 G_SIGNAL_RUN_LAST, | |
1252 G_STRUCT_OFFSET(GntWMClass, window_resize_confirm), | |
1253 gnt_boolean_handled_accumulator, NULL, | |
1254 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER, | |
1255 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER); | |
1256 | |
1257 signals[SIG_CONFIRM_MOVE] = | |
1258 g_signal_new("confirm_move", | |
1259 G_TYPE_FROM_CLASS(klass), | |
1260 G_SIGNAL_RUN_LAST, | |
1261 G_STRUCT_OFFSET(GntWMClass, window_move_confirm), | |
1262 gnt_boolean_handled_accumulator, NULL, | |
1263 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER, | |
1264 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER); | |
1265 | |
1266 signals[SIG_RESIZED] = | |
1267 g_signal_new("window_resized", | |
1268 G_TYPE_FROM_CLASS(klass), | |
1269 G_SIGNAL_RUN_LAST, | |
1270 G_STRUCT_OFFSET(GntWMClass, window_resized), | |
1271 NULL, NULL, | |
1272 g_cclosure_marshal_VOID__POINTER, | |
1273 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1274 signals[SIG_MOVED] = | |
1275 g_signal_new("window_moved", | |
1276 G_TYPE_FROM_CLASS(klass), | |
1277 G_SIGNAL_RUN_LAST, | |
1278 G_STRUCT_OFFSET(GntWMClass, window_moved), | |
1279 NULL, NULL, | |
1280 g_cclosure_marshal_VOID__POINTER, | |
1281 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1282 signals[SIG_UPDATE_WIN] = | |
1283 g_signal_new("window_update", | |
1284 G_TYPE_FROM_CLASS(klass), | |
1285 G_SIGNAL_RUN_LAST, | |
1286 G_STRUCT_OFFSET(GntWMClass, window_update), | |
1287 NULL, NULL, | |
1288 g_cclosure_marshal_VOID__POINTER, | |
1289 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1290 | |
1291 signals[SIG_GIVE_FOCUS] = | |
1292 g_signal_new("give_focus", | |
1293 G_TYPE_FROM_CLASS(klass), | |
1294 G_SIGNAL_RUN_LAST, | |
1295 G_STRUCT_OFFSET(GntWMClass, give_focus), | |
1296 NULL, NULL, | |
1297 g_cclosure_marshal_VOID__POINTER, | |
1298 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
1299 | |
1300 signals[SIG_MOUSE_CLICK] = | |
1301 g_signal_new("mouse_clicked", | |
1302 G_TYPE_FROM_CLASS(klass), | |
1303 G_SIGNAL_RUN_LAST, | |
1304 G_STRUCT_OFFSET(GntWMClass, mouse_clicked), | |
1305 gnt_boolean_handled_accumulator, NULL, | |
1306 gnt_closure_marshal_BOOLEAN__INT_INT_INT_POINTER, | |
1307 G_TYPE_BOOLEAN, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_POINTER); | |
1308 | |
1309 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-next", window_next, | |
1310 "\033" "n", NULL); | |
1311 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-prev", window_prev, | |
1312 "\033" "p", NULL); | |
1313 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-close", window_close, | |
1314 "\033" "c", NULL); | |
1315 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-list", window_list, | |
1316 "\033" "w", NULL); | |
1317 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "dump-screen", dump_screen, | |
1318 "\033" "d", NULL); | |
1319 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-left", shift_left, | |
1320 "\033" ",", NULL); | |
1321 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "shift-right", shift_right, | |
1322 "\033" ".", NULL); | |
1323 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "action-list", list_actions, | |
1324 "\033" "a", NULL); | |
1325 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-move", start_move, | |
1326 "\033" "m", NULL); | |
1327 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "start-resize", start_resize, | |
1328 "\033" "r", NULL); | |
1329 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "wm-quit", wm_quit, | |
1330 "\033" "q", NULL); | |
1331 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "refresh-screen", refresh_screen, | |
1332 "\033" "l", NULL); | |
1333 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "switch-window-n", switch_window_n, | |
1334 NULL, NULL); | |
1335 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-down", window_scroll_down, | |
1336 "\033" GNT_KEY_CTRL_J, NULL); | |
1337 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, | |
1338 "\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
|
1339 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
|
1340 "\033" "/", NULL); |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1341 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-new", workspace_new, |
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1342 GNT_KEY_F9, NULL); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1343 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
|
1344 "\033" ">", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1345 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
|
1346 "\033" "<", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1347 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
|
1348 "\033" "t", NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1349 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
|
1350 "\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
|
1351 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-list", workspace_list, |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1352 "\033" "s", NULL); |
16526
403332494b92
Move the toggle-clipboard operation to the default wm.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16281
diff
changeset
|
1353 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
|
1354 toggle_clipboard, "\033" "C", NULL); |
17714
1abacdef8205
Alt-\ allows to rebind keys to the wm
Eric Polino <aluink@pidgin.im>
parents:
17713
diff
changeset
|
1355 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
|
1356 "\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
|
1357 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
|
1358 "\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
|
1359 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
|
1360 "\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
|
1361 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
|
1362 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
|
1363 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
|
1364 "\033" GNT_KEY_CTRL_G, NULL); |
15818 | 1365 |
1366 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); | |
1367 | |
1368 /* Make sure Alt+x are detected properly. */ | |
1369 for (i = '0'; i <= '9'; i++) { | |
1370 char str[] = "\033X"; | |
1371 str[1] = i; | |
1372 gnt_keys_add_combination(str); | |
1373 } | |
1374 | |
1375 GNTDEBUG; | |
1376 } | |
1377 | |
1378 /****************************************************************************** | |
1379 * GntWM API | |
1380 *****************************************************************************/ | |
1381 GType | |
1382 gnt_wm_get_gtype(void) | |
1383 { | |
1384 static GType type = 0; | |
1385 | |
1386 if(type == 0) { | |
1387 static const GTypeInfo info = { | |
1388 sizeof(GntWMClass), | |
1389 NULL, /* base_init */ | |
1390 NULL, /* base_finalize */ | |
1391 (GClassInitFunc)gnt_wm_class_init, | |
1392 NULL, | |
1393 NULL, /* class_data */ | |
1394 sizeof(GntWM), | |
1395 0, /* n_preallocs */ | |
1396 gnt_wm_init, /* instance_init */ | |
1397 NULL /* value_table */ | |
1398 }; | |
1399 | |
1400 type = g_type_register_static(GNT_TYPE_BINDABLE, | |
1401 "GntWM", | |
1402 &info, 0); | |
1403 } | |
1404 | |
1405 return type; | |
1406 } | |
18075
34e011c8ed2b
F9 to create a new workspace.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18070
diff
changeset
|
1407 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1408 void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1409 gnt_wm_add_workspace(GntWM *wm, GntWS *ws) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1410 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1411 wm->workspaces = g_list_append(wm->workspaces, ws); |
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 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1414 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1415 gnt_wm_switch_workspace(GntWM *wm, gint n) |
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 GntWS *s = g_list_nth_data(wm->workspaces, n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1418 if (!s) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1419 return FALSE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1420 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1421 if (wm->_list.window) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1422 gnt_widget_destroy(wm->_list.window); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1423 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1424 gnt_ws_hide(wm->cws, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1425 wm->cws = s; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1426 gnt_ws_show(wm->cws, wm->nodes); |
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 gnt_ws_draw_taskbar(wm->cws, TRUE); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1429 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
|
1430 if (wm->cws->ordered) { |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1431 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
|
1432 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
|
1433 } |
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
|
1434 |
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
|
1435 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
|
1436 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
|
1437 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
|
1438 } |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1439 return TRUE; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1440 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1441 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1442 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1443 gnt_wm_switch_workspace_prev(GntWM *wm) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1444 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1445 int n = g_list_index(wm->workspaces, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1446 return gnt_wm_switch_workspace(wm, --n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1447 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1448 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1449 gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1450 gnt_wm_switch_workspace_next(GntWM *wm) |
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 int n = g_list_index(wm->workspaces, wm->cws); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1453 return gnt_wm_switch_workspace(wm, ++n); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1454 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1455 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1456 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1457 workspace_next(GntBindable *wm, GList *n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1458 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1459 return gnt_wm_switch_workspace_next(GNT_WM(wm)); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1460 } |
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 static gboolean |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1463 workspace_prev(GntBindable *wm, GList *n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1464 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1465 return gnt_wm_switch_workspace_prev(GNT_WM(wm)); |
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 void |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1469 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
|
1470 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1471 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
|
1472 GntNode *node; |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1473 if (!oldw || oldw == neww) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1474 return; |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1475 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
|
1476 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
|
1477 return; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1478 |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1479 if (node) |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1480 node->ws = neww; |
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1481 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1482 gnt_ws_remove_widget(oldw, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1483 gnt_ws_add_widget(neww, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1484 if (neww == wm->cws) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1485 gnt_ws_widget_show(widget, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1486 } else { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1487 gnt_ws_widget_hide(widget, wm->nodes); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1488 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1489 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1490 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1491 static gint widget_in_workspace(gconstpointer workspace, gconstpointer wid) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1492 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1493 GntWS *s = (GntWS *)workspace; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1494 if (s->list && g_list_find(s->list, wid)) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1495 return 0; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1496 return 1; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1497 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1498 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1499 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
|
1500 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1501 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
|
1502 if (l) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1503 return l->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1504 return NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1505 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1506 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1507 static void free_workspaces(gpointer data, gpointer n) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1508 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1509 GntWS *s = data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1510 g_free(s->name); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1511 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1512 |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1513 void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1514 { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1515 g_list_foreach(wm->workspaces, free_workspaces, NULL); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1516 wm->workspaces = workspaces; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1517 gnt_wm_switch_workspace(wm, 0); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1518 } |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1519 |
15818 | 1520 static void |
1521 update_window_in_list(GntWM *wm, GntWidget *wid) | |
1522 { | |
1523 GntTextFormatFlags flag = 0; | |
1524 | |
1525 if (wm->windows == NULL) | |
1526 return; | |
1527 | |
16471
596c970076df
Alt+s to see the list of workspaces and windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16414
diff
changeset
|
1528 if (wm->cws->ordered && wid == wm->cws->ordered->data) |
15818 | 1529 flag |= GNT_TEXT_FLAG_DIM; |
1530 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT)) | |
1531 flag |= GNT_TEXT_FLAG_BOLD; | |
1532 | |
1533 gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag); | |
1534 } | |
1535 | |
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
|
1536 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
|
1537 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
|
1538 { |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1539 /* XXX: do any regex magic here. */ |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1540 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
|
1541 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
|
1542 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
|
1543 } |
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
|
1544 |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1545 #if !GLIB_CHECK_VERSION(2,4,0) |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1546 struct |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1547 { |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1548 gpointer data; |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1549 gpointer value; |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1550 } table_find_data; |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1551 |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1552 static void |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1553 table_find_helper(gpointer key, gpointer value, gpointer data) |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1554 { |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1555 GHRFunc func = data; |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1556 if (func(key, value, table_find_data.data)) |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1557 table_find_data.value = value; |
19110
60c6090c0e29
Workspace window placement now supports substring checking in window-names
Eric Polino <aluink@pidgin.im>
parents:
19109
diff
changeset
|
1558 } |
60c6090c0e29
Workspace window placement now supports substring checking in window-names
Eric Polino <aluink@pidgin.im>
parents:
19109
diff
changeset
|
1559 |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1560 static gpointer |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1561 g_hash_table_find(GHashTable * table, GHRFunc func, gpointer data) |
19110
60c6090c0e29
Workspace window placement now supports substring checking in window-names
Eric Polino <aluink@pidgin.im>
parents:
19109
diff
changeset
|
1562 { |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1563 table_find_data.data = data; |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1564 table_find_data.value = NULL; |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1565 g_hash_table_foreach(table, table_find_helper, func); |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1566 return table_find_data.value; |
18216
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1567 } |
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1568 #endif |
af7b944374ba
g_hash_table_find is glib 2.4
Richard Nelson <wabz@pidgin.im>
parents:
18097
diff
changeset
|
1569 |
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
|
1570 static GntWS * |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1571 new_widget_find_workspace(GntWM *wm, GntWidget *widget) |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1572 { |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1573 GntWS *ret = NULL; |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1574 const gchar *name, *title; |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1575 title = GNT_BOX(widget)->title; |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1576 if (title) |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1577 ret = g_hash_table_find(wm->title_places, match_title, (gpointer)title); |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1578 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
|
1579 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
|
1580 name = gnt_widget_get_name(widget); |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1581 if (name) |
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1582 ret = g_hash_table_find(wm->name_places, match_title, (gpointer)name); |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1583 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
|
1584 } |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1585 |
15818 | 1586 static void |
1587 gnt_wm_new_window_real(GntWM *wm, GntWidget *widget) | |
1588 { | |
1589 GntNode *node; | |
1590 gboolean transient = FALSE; | |
1591 | |
1592 if (widget->window == NULL) | |
1593 return; | |
1594 | |
1595 node = g_new0(GntNode, 1); | |
1596 node->me = widget; | |
1597 node->scroll = 0; | |
1598 | |
1599 g_hash_table_replace(wm->nodes, widget, node); | |
1600 | |
1601 refresh_node(widget, node, NULL); | |
1602 | |
1603 transient = !!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT); | |
1604 | |
1605 #if 1 | |
1606 { | |
1607 int x, y, w, h, maxx, maxy; | |
1608 gboolean shadow = TRUE; | |
1609 | |
1610 if (!gnt_widget_has_shadow(widget)) | |
1611 shadow = FALSE; | |
1612 x = widget->priv.x; | |
1613 y = widget->priv.y; | |
1614 w = widget->priv.width; | |
1615 h = widget->priv.height; | |
1616 | |
1617 getmaxyx(stdscr, maxy, maxx); | |
1618 maxy -= 1; /* room for the taskbar */ | |
1619 maxy -= shadow; | |
1620 maxx -= shadow; | |
1621 | |
1622 x = MAX(0, x); | |
1623 y = MAX(0, y); | |
1624 if (x + w >= maxx) | |
1625 x = MAX(0, maxx - w); | |
1626 if (y + h >= maxy) | |
1627 y = MAX(0, maxy - h); | |
1628 | |
1629 w = MIN(w, maxx); | |
1630 h = MIN(h, maxy); | |
1631 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
|
1632 gnt_wm_copy_win(widget, node); |
15818 | 1633 } |
1634 #endif | |
1635 | |
1636 node->panel = new_panel(node->window); | |
1637 set_panel_userptr(node->panel, node); | |
1638 | |
1639 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
|
1640 GntWS *ws = wm->cws; |
15818 | 1641 if (node->me != wm->_list.window) { |
1642 GntWidget *w = NULL; | |
1643 | |
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
|
1644 if (GNT_IS_BOX(widget)) { |
19111
c0abe71ac1ff
Define a generic g_hash_table_find for glib < 2.4, which uses
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19110
diff
changeset
|
1645 ws = new_widget_find_workspace(wm, widget); |
16473
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1646 } |
15818 | 1647 |
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
|
1648 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
|
1649 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
|
1650 |
5acee0788697
New windows can be placed on specific workspaces. They can be specified by the window name (e.g. conversation-window), or a substring in the window title. Title takes precedence.
Richard Nelson <wabz@pidgin.im>
parents:
16472
diff
changeset
|
1651 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
|
1652 ws->list = g_list_append(ws->list, widget); |
15818 | 1653 |
1654 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
|
1655 ws->ordered = g_list_prepend(ws->ordered, widget); |
15818 | 1656 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
|
1657 ws->ordered = g_list_append(ws->ordered, widget); |
15818 | 1658 |
1659 gnt_widget_set_focus(widget, TRUE); | |
1660 if (w) | |
1661 gnt_widget_set_focus(w, FALSE); | |
1662 } | |
1663 | |
1664 if (wm->event_stack || node->me == wm->_list.window) { | |
1665 gnt_wm_raise_window(wm, node->me); | |
1666 } else { | |
1667 bottom_panel(node->panel); /* New windows should not grab focus */ | |
18097
16bfad2597fb
Notify a window on startup if it didn't get the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18077
diff
changeset
|
1668 gnt_widget_set_focus(node->me, FALSE); |
15818 | 1669 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
|
1670 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
|
1671 gnt_ws_widget_hide(widget, wm->nodes); |
15818 | 1672 } |
1673 } | |
1674 } | |
1675 | |
1676 void gnt_wm_new_window(GntWM *wm, GntWidget *widget) | |
1677 { | |
1678 while (widget->parent) | |
1679 widget = widget->parent; | |
1680 | |
1681 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_INVISIBLE) || | |
1682 g_hash_table_lookup(wm->nodes, widget)) { | |
1683 update_screen(wm); | |
1684 return; | |
1685 } | |
1686 | |
1687 if (GNT_IS_BOX(widget)) { | |
1688 const char *title = GNT_BOX(widget)->title; | |
1689 GntPosition *p = NULL; | |
1690 if (title && (p = g_hash_table_lookup(wm->positions, title)) != NULL) { | |
1691 sanitize_position(widget, &p->x, &p->y); | |
1692 gnt_widget_set_position(widget, p->x, p->y); | |
1693 mvwin(widget->window, p->y, p->x); | |
1694 } | |
1695 } | |
1696 | |
1697 g_signal_emit(wm, signals[SIG_NEW_WIN], 0, widget); | |
1698 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); | |
1699 | |
1700 if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { | |
1701 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget | |
1702 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) { | |
1703 gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget, | |
1704 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
|
1705 g_object_get_data(G_OBJECT(wm->windows->tree), "workspace") ? wm->cws : NULL); |
15818 | 1706 update_window_in_list(wm, widget); |
1707 } | |
1708 } | |
1709 | |
1710 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1711 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 1712 } |
1713 | |
1714 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget) | |
1715 { | |
1716 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); | |
1717 } | |
1718 | |
1719 void gnt_wm_window_close(GntWM *wm, GntWidget *widget) | |
1720 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1721 GntWS *s; |
15818 | 1722 GntNode *node; |
1723 int pos; | |
1724 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1725 s = gnt_wm_widget_find_workspace(wm, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1726 |
15818 | 1727 if ((node = g_hash_table_lookup(wm->nodes, widget)) == NULL) |
1728 return; | |
1729 | |
1730 g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget); | |
1731 g_hash_table_remove(wm->nodes, widget); | |
1732 | |
1733 if (wm->windows) { | |
1734 gnt_tree_remove(GNT_TREE(wm->windows->tree), widget); | |
1735 } | |
1736 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1737 if (s) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1738 pos = g_list_index(s->list, widget); |
15818 | 1739 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1740 if (pos != -1) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1741 s->list = g_list_remove(s->list, widget); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1742 s->ordered = g_list_remove(s->ordered, widget); |
15818 | 1743 |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1744 if (s->ordered && wm->cws == s) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1745 gnt_wm_raise_window(wm, s->ordered->data); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1746 } |
15818 | 1747 } |
1748 | |
1749 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1750 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 1751 } |
1752 | |
1753 time_t gnt_wm_get_idle_time() | |
1754 { | |
1755 return time(NULL) - last_active_time; | |
1756 } | |
1757 | |
1758 gboolean gnt_wm_process_input(GntWM *wm, const char *keys) | |
1759 { | |
1760 gboolean ret = FALSE; | |
1761 | |
1762 keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys); | |
1763 | |
1764 idle_update = TRUE; | |
17539
c609b4009dbe
1. Cleaned up a bit of dirty formatting in the _register_action lines in _class_init
Eric Polino <aluink@pidgin.im>
parents:
17140
diff
changeset
|
1765 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
|
1766 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
|
1767 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
|
1768 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
|
1769 } |
c609b4009dbe
1. Cleaned up a bit of dirty formatting in the _register_action lines in _class_init
Eric Polino <aluink@pidgin.im>
parents:
17140
diff
changeset
|
1770 } |
19098
ac904659104f
propagate from branch 'im.pidgin.pidgin.2.1.0' (head 121873f517c4c5e2d65c3a1cdd152694834d7db0)
Eric Polino <aluink@pidgin.im>
diff
changeset
|
1771 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
|
1772 } |
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
|
1773 |
16126
d07f5128dd6b
alt-/ to get a list of keybindings for the focused widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15995
diff
changeset
|
1774 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { |
15818 | 1775 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
|
1776 } |
15818 | 1777 |
1778 /* Do some manual checking */ | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1779 if (wm->cws->ordered && wm->mode != GNT_KP_MODE_NORMAL) { |
15818 | 1780 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1; |
1781 int x, y, w, h; | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1782 GntWidget *widget = GNT_WIDGET(wm->cws->ordered->data); |
15818 | 1783 int ox, oy, ow, oh; |
1784 | |
1785 gnt_widget_get_position(widget, &x, &y); | |
1786 gnt_widget_get_size(widget, &w, &h); | |
1787 ox = x; oy = y; | |
1788 ow = w; oh = h; | |
1789 | |
1790 if (wm->mode == GNT_KP_MODE_MOVE) { | |
1791 if (strcmp(keys, GNT_KEY_LEFT) == 0) { | |
1792 if (x > xmin) | |
1793 x--; | |
1794 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { | |
1795 if (x + w < xmax) | |
1796 x++; | |
1797 } else if (strcmp(keys, GNT_KEY_UP) == 0) { | |
1798 if (y > ymin) | |
1799 y--; | |
1800 } else if (strcmp(keys, GNT_KEY_DOWN) == 0) { | |
1801 if (y + h < ymax) | |
1802 y++; | |
1803 } | |
1804 if (ox != x || oy != y) { | |
1805 gnt_screen_move_widget(widget, x, y); | |
1806 window_reverse(widget, TRUE, wm); | |
1807 return TRUE; | |
1808 } | |
1809 } else if (wm->mode == GNT_KP_MODE_RESIZE) { | |
1810 if (strcmp(keys, GNT_KEY_LEFT) == 0) { | |
1811 w--; | |
1812 } else if (strcmp(keys, GNT_KEY_RIGHT) == 0) { | |
1813 if (x + w < xmax) | |
1814 w++; | |
1815 } else if (strcmp(keys, GNT_KEY_UP) == 0) { | |
1816 h--; | |
1817 } else if (strcmp(keys, GNT_KEY_DOWN) == 0) { | |
1818 if (y + h < ymax) | |
1819 h++; | |
1820 } | |
1821 if (oh != h || ow != w) { | |
1822 gnt_screen_resize_widget(widget, w, h); | |
1823 window_reverse(widget, TRUE, wm); | |
1824 return TRUE; | |
1825 } | |
1826 } | |
1827 if (strcmp(keys, "\r") == 0 || strcmp(keys, "\033") == 0) { | |
1828 window_reverse(widget, FALSE, wm); | |
1829 wm->mode = GNT_KP_MODE_NORMAL; | |
1830 } | |
1831 return TRUE; | |
1832 } | |
1833 | |
1834 /* Escape to close the window-list or action-list window */ | |
1835 if (strcmp(keys, "\033") == 0) { | |
1836 if (wm->_list.window) { | |
1837 gnt_widget_destroy(wm->_list.window); | |
1838 return TRUE; | |
1839 } | |
1840 } else if (keys[0] == '\033' && isdigit(keys[1]) && keys[2] == '\0') { | |
1841 /* Alt+x for quick switch */ | |
1842 int n = *(keys + 1) - '0'; | |
1843 GList *list = NULL; | |
1844 | |
1845 if (n == 0) | |
1846 n = 10; | |
1847 | |
1848 list = g_list_append(list, GINT_TO_POINTER(n - 1)); | |
1849 switch_window_n(GNT_BINDABLE(wm), list); | |
1850 g_list_free(list); | |
1851 return TRUE; | |
1852 } | |
1853 | |
1854 if (wm->menu) | |
1855 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys); | |
1856 else if (wm->_list.window) | |
1857 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
|
1858 else if (wm->cws->ordered) |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1859 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->cws->ordered->data), keys); |
15818 | 1860 return ret; |
1861 } | |
1862 | |
1863 static void | |
1864 gnt_wm_win_resized(GntWM *wm, GntNode *node) | |
1865 { | |
1866 /*refresh_node(node->me, node, NULL);*/ | |
1867 } | |
1868 | |
1869 static void | |
1870 gnt_wm_win_moved(GntWM *wm, GntNode *node) | |
1871 { | |
1872 refresh_node(node->me, node, NULL); | |
1873 } | |
1874 | |
1875 void gnt_wm_resize_window(GntWM *wm, GntWidget *widget, int width, int height) | |
1876 { | |
1877 gboolean ret = TRUE; | |
1878 GntNode *node; | |
1879 int shadow; | |
1880 int maxx, maxy; | |
1881 | |
1882 while (widget->parent) | |
1883 widget = widget->parent; | |
1884 node = g_hash_table_lookup(wm->nodes, widget); | |
1885 if (!node) | |
1886 return; | |
1887 | |
1888 g_signal_emit(wm, signals[SIG_CONFIRM_RESIZE], 0, widget, &width, &height, &ret); | |
1889 if (!ret) | |
1890 return; /* resize is not permitted */ | |
1891 hide_panel(node->panel); | |
1892 gnt_widget_set_size(widget, width, height); | |
1893 gnt_widget_draw(widget); | |
1894 | |
1895 shadow = gnt_widget_has_shadow(widget) ? 1 : 0; | |
1896 maxx = getmaxx(stdscr) - shadow; | |
1897 maxy = getmaxy(stdscr) - 1 - shadow; | |
1898 height = MIN(height, maxy); | |
1899 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
|
1900 wresize(node->window, height, width); |
15818 | 1901 replace_panel(node->panel, node->window); |
1902 | |
1903 g_signal_emit(wm, signals[SIG_RESIZED], 0, node); | |
1904 | |
1905 show_panel(node->panel); | |
1906 update_screen(wm); | |
1907 } | |
1908 | |
1909 static void | |
1910 write_gdi(gpointer key, gpointer value, gpointer data) | |
1911 { | |
1912 GntPosition *p = value; | |
1913 fprintf(data, ".%s = %d;%d\n", (char *)key, p->x, p->y); | |
1914 } | |
1915 | |
1916 static gboolean | |
1917 write_already(gpointer data) | |
1918 { | |
1919 GntWM *wm = data; | |
1920 FILE *file; | |
1921 char *filename; | |
1922 | |
1923 filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL); | |
1924 | |
1925 file = fopen(filename, "wb"); | |
1926 if (file == NULL) { | |
1927 g_printerr("GntWM: error opening file to save positions\n"); | |
1928 } else { | |
1929 fprintf(file, "[positions]\n"); | |
1930 g_hash_table_foreach(wm->positions, write_gdi, file); | |
1931 fclose(file); | |
1932 } | |
1933 | |
1934 g_free(filename); | |
1935 g_source_remove(write_timeout); | |
1936 write_timeout = 0; | |
1937 return FALSE; | |
1938 } | |
1939 | |
1940 static void | |
1941 write_positions_to_file(GntWM *wm) | |
1942 { | |
1943 if (write_timeout) { | |
1944 g_source_remove(write_timeout); | |
1945 } | |
1946 write_timeout = g_timeout_add(10000, write_already, wm); | |
1947 } | |
1948 | |
1949 void gnt_wm_move_window(GntWM *wm, GntWidget *widget, int x, int y) | |
1950 { | |
1951 gboolean ret = TRUE; | |
1952 GntNode *node; | |
1953 | |
1954 while (widget->parent) | |
1955 widget = widget->parent; | |
1956 node = g_hash_table_lookup(wm->nodes, widget); | |
1957 if (!node) | |
1958 return; | |
1959 | |
1960 g_signal_emit(wm, signals[SIG_CONFIRM_MOVE], 0, widget, &x, &y, &ret); | |
1961 if (!ret) | |
1962 return; /* resize is not permitted */ | |
1963 | |
1964 gnt_widget_set_position(widget, x, y); | |
1965 move_panel(node->panel, y, x); | |
1966 | |
1967 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
|
1968 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
|
1969 !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { |
15818 | 1970 const char *title = GNT_BOX(widget)->title; |
1971 if (title) { | |
1972 GntPosition *p = g_new0(GntPosition, 1); | |
1973 GntWidget *wid = node->me; | |
1974 p->x = wid->priv.x; | |
1975 p->y = wid->priv.y; | |
1976 g_hash_table_replace(wm->positions, g_strdup(title), p); | |
1977 write_positions_to_file(wm); | |
1978 } | |
1979 } | |
1980 | |
1981 update_screen(wm); | |
1982 } | |
1983 | |
1984 static void | |
1985 gnt_wm_give_focus(GntWM *wm, GntWidget *widget) | |
1986 { | |
1987 GntNode *node = g_hash_table_lookup(wm->nodes, widget); | |
1988 | |
1989 if (!node) | |
1990 return; | |
1991 | |
1992 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
|
1993 wm->cws->ordered->data != widget) { |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1994 GntWidget *w = wm->cws->ordered->data; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
1995 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget); |
15818 | 1996 gnt_widget_set_focus(w, FALSE); |
1997 } | |
1998 | |
1999 gnt_widget_set_focus(widget, TRUE); | |
2000 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT); | |
2001 gnt_widget_draw(widget); | |
2002 top_panel(node->panel); | |
2003 | |
2004 if (wm->_list.window) { | |
2005 GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window); | |
2006 top_panel(nd->panel); | |
2007 } | |
2008 update_screen(wm); | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
2009 gnt_ws_draw_taskbar(wm->cws, FALSE); |
15818 | 2010 } |
2011 | |
2012 void gnt_wm_update_window(GntWM *wm, GntWidget *widget) | |
2013 { | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
2014 GntNode *node = NULL; |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
2015 GntWS *ws; |
15818 | 2016 |
2017 while (widget->parent) | |
2018 widget = widget->parent; | |
2019 if (!GNT_IS_MENU(widget)) | |
2020 gnt_box_sync_children(GNT_BOX(widget)); | |
2021 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
2022 ws = gnt_wm_widget_find_workspace(wm, widget); |
15818 | 2023 node = g_hash_table_lookup(wm->nodes, widget); |
2024 if (node == NULL) { | |
2025 gnt_wm_new_window(wm, widget); | |
2026 } else | |
2027 g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node); | |
2028 | |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
2029 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
|
2030 gnt_wm_copy_win(widget, node); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
2031 update_screen(wm); |
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
2032 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
|
2033 } 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
|
2034 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
|
2035 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
|
2036 update_act_msg(); |
16414
56d2ae9cbb5c
Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents:
16281
diff
changeset
|
2037 } |
15818 | 2038 } |
2039 | |
2040 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget) | |
2041 { | |
2042 gboolean ret = TRUE; | |
2043 idle_update = TRUE; | |
2044 g_signal_emit(wm, signals[SIG_MOUSE_CLICK], 0, event, x, y, widget, &ret); | |
2045 return ret; | |
2046 } | |
2047 | |
2048 void gnt_wm_raise_window(GntWM *wm, GntWidget *widget) | |
2049 { | |
18070 | 2050 GntWS *ws = gnt_wm_widget_find_workspace(wm, widget); |
2051 if (wm->cws != ws) | |
2052 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws)); | |
15818 | 2053 g_signal_emit(wm, signals[SIG_GIVE_FOCUS], 0, widget); |
2054 } | |
2055 | |
16281
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
2056 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
|
2057 { |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
2058 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
|
2059 } |
82b6fdd899a9
Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16127
diff
changeset
|
2060 |