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