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