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