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