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