annotate finch/libgnt/gntwm.c @ 26527:9a2e4aebfa91

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