finch/libgnt/gntmain.c

Wed, 28 Apr 2010 19:26:58 +0000

author
Marcus Lundblad <malu@pidgin.im>
date
Wed, 28 Apr 2010 19:26:58 +0000
branch
cpw.malu.ft_thumbnails
changeset 30132
064f5dc73a6f
parent 28937
5f87e66597d9
child 31294
73607ab89c6f
permissions
-rw-r--r--

Disable thumbnails for XMPP (in si.c) by using an #define
This is a temporary measure until XEP 0264 gets draft status.

18114
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
1 /**
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
2 * GNT - The GLib Ncurses Toolkit
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
3 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
4 * GNT is the legal property of its developers, whose names are too numerous
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
6 * source distribution.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
7 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
8 * This library is free software; you can redistribute it and/or modify
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
9 * it under the terms of the GNU General Public License as published by
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
11 * (at your option) any later version.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
12 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
13 * This program is distributed in the hope that it will be useful,
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
16 * GNU General Public License for more details.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
17 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
18 * You should have received a copy of the GNU General Public License
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19317
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
18114
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
21 */
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
22
14539
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
23 #define _GNU_SOURCE
25353
0ce06b4f8a68 Compilation fixes for OpenBSD from the OpenBSD ports tree. Closes #8009.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24822
diff changeset
24 #if (defined(__APPLE__) || defined(__unix__)) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
14800
9fb18f4b8d1a [gaim-migrate @ 17494]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14799
diff changeset
25 #define _XOPEN_SOURCE_EXTENDED
9fb18f4b8d1a [gaim-migrate @ 17494]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14799
diff changeset
26 #endif
14487
12503b6b5268 [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14483
diff changeset
27
14483
82b73e12ce27 [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14477
diff changeset
28 #include "config.h"
82b73e12ce27 [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14477
diff changeset
29
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
30 #include <gmodule.h>
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
31
15863
7411e672a88b Re-order includes to fix this compile error:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15862
diff changeset
32 #include <sys/types.h>
7411e672a88b Re-order includes to fix this compile error:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15862
diff changeset
33 #include <sys/wait.h>
7411e672a88b Re-order includes to fix this compile error:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15862
diff changeset
34
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22856
diff changeset
35 #include "gntinternal.h"
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22856
diff changeset
36 #undef GNT_LOG_DOMAIN
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22856
diff changeset
37 #define GNT_LOG_DOMAIN "Main"
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22856
diff changeset
38
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
39 #include "gnt.h"
13950
bd8d39b3a9e2 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13947
diff changeset
40 #include "gntbox.h"
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
41 #include "gntbutton.h"
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14045
diff changeset
42 #include "gntcolors.h"
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
43 #include "gntclipboard.h"
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
44 #include "gntkeys.h"
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
45 #include "gntlabel.h"
14675
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
46 #include "gntmenu.h"
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14045
diff changeset
47 #include "gntstyle.h"
13978
70d7030b7f26 [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13973
diff changeset
48 #include "gnttree.h"
14539
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
49 #include "gntutils.h"
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
50 #include "gntwindow.h"
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
51 #include "gntwm.h"
13950
bd8d39b3a9e2 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13947
diff changeset
52
14493
c47f415b7e56 [gaim-migrate @ 17145]
Mark Doliner <markdoliner@pidgin.im>
parents: 14490
diff changeset
53 #include <panel.h>
c47f415b7e56 [gaim-migrate @ 17145]
Mark Doliner <markdoliner@pidgin.im>
parents: 14490
diff changeset
54
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
55 #include <stdio.h>
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
56 #include <stdlib.h>
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
57 #include <locale.h>
13950
bd8d39b3a9e2 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13947
diff changeset
58 #include <unistd.h>
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
59 #include <signal.h>
13950
bd8d39b3a9e2 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13947
diff changeset
60 #include <string.h>
14282
4b948c7a0eb4 [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14278
diff changeset
61 #include <ctype.h>
14443
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
62 #include <errno.h>
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
63
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
64 /**
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
65 * Notes: Interesting functions to look at:
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
66 * scr_dump, scr_init, scr_restore: for workspaces
14193
fcfd3eea2160 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14187
diff changeset
67 *
fcfd3eea2160 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14187
diff changeset
68 * Need to wattrset for colors to use with PDCurses.
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
69 */
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
70
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
71 static GIOChannel *channel = NULL;
28427
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
72 static guint channel_read_callback = 0;
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
73 static guint channel_error_callback = 0;
13969
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
74
13989
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
75 static gboolean ascii_only;
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
76 static gboolean mouse_enabled;
13989
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
77
15874
46df7421a1b5 Enable DEBUG_CFLAGS in libgnt and fix up a number of compile warnings and
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15863
diff changeset
78 static void setup_io(void);
13931
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
79
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 21837
diff changeset
80 static gboolean refresh_screen(void);
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
81
18114
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17853
diff changeset
82 static GntWM *wm;
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
83 static GntClipboard *clipboard;
14307
bfdf8ddf6dda [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14282
diff changeset
84
28937
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
85 int gnt_need_conversation_to_locale;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
86
15842
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
87 #define HOLDING_ESCAPE (escape_stuff.timer != 0)
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
88
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
89 static struct {
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
90 int timer;
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
91 } escape_stuff;
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
92
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
93 static gboolean
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
94 escape_timeout(gpointer data)
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
95 {
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
96 gnt_wm_process_input(wm, "\033");
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
97 escape_stuff.timer = 0;
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
98 return FALSE;
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
99 }
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
100
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
101 /**
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
102 * Mouse support:
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
103 * - bring a window on top if you click on its taskbar
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
104 * - click on the top-bar of the active window and drag+drop to move a window
14387
c52a8625eab3 [gaim-migrate @ 17020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14379
diff changeset
105 * - click on a window to bring it to focus
14424
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
106 * - allow scrolling in tree/textview on wheel-scroll event
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
107 * - click to activate button or select a row in tree
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
108 * wishlist:
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
109 * - have a little [X] on the windows, and clicking it will close that window.
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
110 */
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
111 static gboolean
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
112 detect_mouse_action(const char *buffer)
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
113 {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
114 int x, y;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
115 static enum {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
116 MOUSE_NONE,
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
117 MOUSE_LEFT,
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
118 MOUSE_RIGHT,
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
119 MOUSE_MIDDLE
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
120 } button = MOUSE_NONE;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
121 static GntWidget *remember = NULL;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
122 static int offset = 0;
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
123 GntMouseEvent event;
14424
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
124 GntWidget *widget = NULL;
14539
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
125 PANEL *p = NULL;
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
126
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16356
diff changeset
127 if (!wm->cws->ordered || buffer[0] != 27)
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
128 return FALSE;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
129
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
130 buffer++;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
131 if (strlen(buffer) < 5)
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
132 return FALSE;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
133
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
134 x = buffer[3];
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
135 y = buffer[4];
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
136 if (x < 0) x += 256;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
137 if (y < 0) y += 256;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
138 x -= 33;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
139 y -= 33;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
140
14539
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
141 while ((p = panel_below(p)) != NULL) {
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
142 const GntNode *node = panel_userptr(p);
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
143 GntWidget *wid;
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
144 if (!node)
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
145 continue;
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
146 wid = node->me;
14424
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
147 if (x >= wid->priv.x && x < wid->priv.x + wid->priv.width) {
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
148 if (y >= wid->priv.y && y < wid->priv.y + wid->priv.height) {
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
149 widget = wid;
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
150 break;
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
151 }
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
152 }
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
153 }
14539
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
154
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
155 if (strncmp(buffer, "[M ", 3) == 0) {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
156 /* left button down */
14379
d1bd558266b7 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14376
diff changeset
157 /* Bring the window you clicked on to front */
d1bd558266b7 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14376
diff changeset
158 /* If you click on the topbar, then you can drag to move the window */
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
159 event = GNT_LEFT_MOUSE_DOWN;
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
160 } else if (strncmp(buffer, "[M\"", 3) == 0) {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
161 /* right button down */
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
162 event = GNT_RIGHT_MOUSE_DOWN;
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
163 } else if (strncmp(buffer, "[M!", 3) == 0) {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
164 /* middle button down */
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
165 event = GNT_MIDDLE_MOUSE_DOWN;
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
166 } else if (strncmp(buffer, "[M`", 3) == 0) {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
167 /* wheel up*/
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
168 event = GNT_MOUSE_SCROLL_UP;
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
169 } else if (strncmp(buffer, "[Ma", 3) == 0) {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
170 /* wheel down */
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
171 event = GNT_MOUSE_SCROLL_DOWN;
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
172 } else if (strncmp(buffer, "[M#", 3) == 0) {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
173 /* button up */
14424
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
174 event = GNT_MOUSE_UP;
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
175 } else
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
176 return FALSE;
17093
7ad0acaf60ab Do not process clicks on no widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16944
diff changeset
177
17099
7eb7e94588dd Fix the commit from earlier today about null-widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17093
diff changeset
178 if (widget && gnt_wm_process_click(wm, event, x, y, widget))
14424
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
179 return TRUE;
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
180
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
181 if (event == GNT_LEFT_MOUSE_DOWN && widget && widget != wm->_list.window &&
14539
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
182 !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16356
diff changeset
183 if (widget != wm->cws->ordered->data) {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
184 gnt_wm_raise_window(wm, widget);
14424
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
185 }
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
186 if (y == widget->priv.y) {
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
187 offset = x - widget->priv.x;
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
188 remember = widget;
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
189 button = MOUSE_LEFT;
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
190 }
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
191 } else if (event == GNT_MOUSE_UP) {
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
192 if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) {
14424
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
193 /* Clicked on the taskbar */
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16356
diff changeset
194 int n = g_list_length(wm->cws->list);
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
195 if (n) {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
196 int width = getmaxx(stdscr) / n;
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
197 gnt_bindable_perform_action_named(GNT_BINDABLE(wm), "switch-window-n", x/width, NULL);
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
198 }
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
199 } else if (button == MOUSE_LEFT && remember) {
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
200 x -= offset;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
201 if (x < 0) x = 0;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
202 if (y < 0) y = 0;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
203 gnt_screen_move_widget(remember, x, y);
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
204 }
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
205 button = MOUSE_NONE;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
206 remember = NULL;
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
207 offset = 0;
14424
8874ec350ebb [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14405
diff changeset
208 }
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
209
17099
7eb7e94588dd Fix the commit from earlier today about null-widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17093
diff changeset
210 if (widget)
7eb7e94588dd Fix the commit from earlier today about null-widgets.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17093
diff changeset
211 gnt_widget_clicked(widget, event, x, y);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
212 return TRUE;
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
213 }
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
214
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
215 static gboolean
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
216 io_invoke_error(GIOChannel *source, GIOCondition cond, gpointer data)
14539
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14493
diff changeset
217 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
218 int id = GPOINTER_TO_INT(data);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
219 g_source_remove(id);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
220 g_io_channel_unref(source);
14487
12503b6b5268 [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14483
diff changeset
221
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
222 channel = NULL;
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
223 setup_io();
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
224 return TRUE;
14477
7252d4888bf2 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14467
diff changeset
225 }
7252d4888bf2 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14467
diff changeset
226
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
227 static gboolean
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
228 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null)
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
229 {
14405
4398121ce889 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14397
diff changeset
230 char keys[256];
22426
bf0638dd1ef6 Fix the "Finch doesn't work" bug. More specifically, it turned out to be
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22108
diff changeset
231 gssize rd;
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
232 char *k;
20201
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
233 char *cvrt = NULL;
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
234
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
235 if (wm->mode == GNT_KP_MODE_WAIT_ON_CHILD)
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
236 return FALSE;
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
237
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
238 rd = read(STDIN_FILENO, keys + HOLDING_ESCAPE, sizeof(keys) - 1 - HOLDING_ESCAPE);
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
239 if (rd < 0)
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
240 {
14943
ffd493362a87 [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
241 int ch = getch(); /* This should return ERR, but let's see what it really returns */
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
242 endwin();
14742
57b62b1b4646 [gaim-migrate @ 17432]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14689
diff changeset
243 printf("ERROR: %s\n", strerror(errno));
14943
ffd493362a87 [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
244 printf("File descriptor is: %d\n\nGIOChannel is: %p\ngetch() = %d\n", STDIN_FILENO, source, ch);
ffd493362a87 [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
245 raise(SIGABRT);
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
246 }
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
247 else if (rd == 0)
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
248 {
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
249 endwin();
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
250 printf("EOF\n");
14943
ffd493362a87 [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
251 raise(SIGABRT);
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
252 }
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
253
15842
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
254 rd += HOLDING_ESCAPE;
22856
fb5beef84524 Patch from Dylan Simon <dylan@dylex.net> to fix handling escape key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22426
diff changeset
255 if (HOLDING_ESCAPE) {
15842
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
256 keys[0] = '\033';
22856
fb5beef84524 Patch from Dylan Simon <dylan@dylex.net> to fix handling escape key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22426
diff changeset
257 g_source_remove(escape_stuff.timer);
fb5beef84524 Patch from Dylan Simon <dylan@dylex.net> to fix handling escape key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22426
diff changeset
258 escape_stuff.timer = 0;
fb5beef84524 Patch from Dylan Simon <dylan@dylex.net> to fix handling escape key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22426
diff changeset
259 }
20201
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
260 keys[rd] = 0;
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
261 gnt_wm_set_event_stack(wm, TRUE);
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
262
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
263 cvrt = g_locale_to_utf8(keys, rd, (gsize*)&rd, NULL, NULL);
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
264 k = cvrt ? cvrt : keys;
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
265 if (mouse_enabled && detect_mouse_action(k))
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
266 goto end;
19314
472ad9489d68 Fix some white-space and other similar issues. Preparing for a merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19307
diff changeset
267
472ad9489d68 Fix some white-space and other similar issues. Preparing for a merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19307
diff changeset
268 #if 0
472ad9489d68 Fix some white-space and other similar issues. Preparing for a merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19307
diff changeset
269 /* I am not sure what's happening here. If this actually does something,
472ad9489d68 Fix some white-space and other similar issues. Preparing for a merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19307
diff changeset
270 * then this needs to go in gnt_keys_refine. */
472ad9489d68 Fix some white-space and other similar issues. Preparing for a merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19307
diff changeset
271 if (*k < 0) { /* Alt not sending ESC* */
17192
5cc374345f6f Added a few lines to gnt_main::io_invoke to deal with ALT not sending ESC.
Eric Polino <aluink@pidgin.im>
parents: 17099
diff changeset
272 *(k + 1) = 128 - *k;
5cc374345f6f Added a few lines to gnt_main::io_invoke to deal with ALT not sending ESC.
Eric Polino <aluink@pidgin.im>
parents: 17099
diff changeset
273 *k = 27;
5cc374345f6f Added a few lines to gnt_main::io_invoke to deal with ALT not sending ESC.
Eric Polino <aluink@pidgin.im>
parents: 17099
diff changeset
274 *(k + 2) = 0;
5cc374345f6f Added a few lines to gnt_main::io_invoke to deal with ALT not sending ESC.
Eric Polino <aluink@pidgin.im>
parents: 17099
diff changeset
275 rd++;
5cc374345f6f Added a few lines to gnt_main::io_invoke to deal with ALT not sending ESC.
Eric Polino <aluink@pidgin.im>
parents: 17099
diff changeset
276 }
19314
472ad9489d68 Fix some white-space and other similar issues. Preparing for a merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19307
diff changeset
277 #endif
472ad9489d68 Fix some white-space and other similar issues. Preparing for a merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19307
diff changeset
278
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
279 while (rd) {
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
280 char back;
15842
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
281 int p;
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
282
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
283 if (k[0] == '\033' && rd == 1) {
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
284 escape_stuff.timer = g_timeout_add(250, escape_timeout, NULL);
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
285 break;
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
286 }
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
287
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
288 gnt_keys_refine(k);
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
289 p = MAX(1, gnt_keys_find_combination(k));
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
290 back = k[p];
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
291 k[p] = '\0';
15840
442102aa7b24 Some changes to the last change. People should really test this thing out.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15839
diff changeset
292 gnt_wm_process_input(wm, k); /* XXX: */
15839
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
293 k[p] = back;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
294 rd -= p;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
295 k += p;
e2b7b5f4f9aa Change a bit how the keystrokes are processed. When a lot of keystrokes come in at the same time, the shortest key-combination is processed first. This should make typing fast over a very slow connection work properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
296 }
16356
13cc89b3ab7c Dialogs opened resulting from a mouse-click should fain focus.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15906
diff changeset
297 end:
21273
2f91b326b3f0 Minor adjustments to prevent a crash, correct a data type and fix drawing.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21243
diff changeset
298 if (wm)
2f91b326b3f0 Minor adjustments to prevent a crash, correct a data type and fix drawing.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21243
diff changeset
299 gnt_wm_set_event_stack(wm, FALSE);
20201
42996a5896df applied changes from 4bbc209c8076ef89135700af844ec6bb04602c0a
Luke Schierer <lschiere@pidgin.im>
parents: 20121
diff changeset
300 g_free(cvrt);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
301 return TRUE;
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
302 }
13969
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
303
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
304 static void
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
305 setup_io()
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
306 {
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
307 int result;
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
308 channel = g_io_channel_unix_new(STDIN_FILENO);
15842
0b00e18a33f2 Do some funky stuff with the escape key.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15841
diff changeset
309 g_io_channel_set_close_on_unref(channel, TRUE);
13958
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
310
15485
07050dfe816e More closely imitate the input handling of irssi. Hopefully this will fix the excessive CPU usage bug Alver keeps getting.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
311 #if 0
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
312 g_io_channel_set_encoding(channel, NULL, NULL);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
313 g_io_channel_set_buffered(channel, FALSE);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
314 g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL );
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
315 #endif
13978
70d7030b7f26 [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13973
diff changeset
316
18603
99a3588da5b1 The input was causing some weird issues. This fixes it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18599
diff changeset
317 channel_read_callback = result = g_io_add_watch_full(channel, G_PRIORITY_HIGH,
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
318 (G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI),
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
319 io_invoke, NULL, NULL);
28427
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
320
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
321 channel_error_callback = g_io_add_watch_full(channel, G_PRIORITY_HIGH,
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
322 (G_IO_NVAL),
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
323 io_invoke_error, GINT_TO_POINTER(result), NULL);
28427
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
324
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
325 g_io_channel_unref(channel); /* Apparently this caused crashes for some people.
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
326 But irssi does this, so I am going to assume the
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
327 crashes were caused by some other stuff. */
13992
a6bbcc09c4eb [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13989
diff changeset
328
24822
d7774462f2ba Use glib log functions to show error messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22856
diff changeset
329 gnt_warning("setting up IO (%d)", channel_read_callback);
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
330 }
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
331
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
332 static gboolean
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 21837
diff changeset
333 refresh_screen(void)
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
334 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
335 gnt_bindable_perform_action_named(GNT_BINDABLE(wm), "refresh-screen", NULL);
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
336 return FALSE;
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
337 }
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
338
14443
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
339 /* Xerox */
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
340 static void
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
341 clean_pid(void)
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
342 {
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
343 int status;
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
344 pid_t pid;
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
345
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
346 do {
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
347 pid = waitpid(-1, &status, WNOHANG);
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
348 } while (pid != 0 && pid != (pid_t)-1);
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
349
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
350 if ((pid == (pid_t) - 1) && (errno != ECHILD)) {
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
351 char errmsg[BUFSIZ];
14487
12503b6b5268 [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14483
diff changeset
352 g_snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
14443
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
353 perror(errmsg);
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
354 }
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
355 }
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
356
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
357 static void
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
358 exit_confirmed(gpointer null)
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
359 {
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
360 gnt_bindable_perform_action_named(GNT_BINDABLE(wm), "wm-quit", NULL);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
361 }
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
362
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
363 static void
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
364 exit_win_close(GntWidget *w, GntWidget **win)
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
365 {
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
366 *win = NULL;
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
367 }
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
368
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
369 static void
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 21837
diff changeset
370 ask_before_exit(void)
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
371 {
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
372 static GntWidget *win = NULL;
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
373 GntWidget *bbox, *button;
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
374
18623
244951dea82f Hide the menu when ctrl-c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18603
diff changeset
375 if (wm->menu) {
244951dea82f Hide the menu when ctrl-c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18603
diff changeset
376 do {
244951dea82f Hide the menu when ctrl-c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18603
diff changeset
377 gnt_widget_hide(GNT_WIDGET(wm->menu));
244951dea82f Hide the menu when ctrl-c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18603
diff changeset
378 if (wm->menu)
244951dea82f Hide the menu when ctrl-c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18603
diff changeset
379 wm->menu = wm->menu->parentmenu;
244951dea82f Hide the menu when ctrl-c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18603
diff changeset
380 } while (wm->menu);
244951dea82f Hide the menu when ctrl-c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18603
diff changeset
381 }
244951dea82f Hide the menu when ctrl-c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18603
diff changeset
382
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
383 if (win)
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
384 goto raise;
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
385
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
386 win = gnt_vwindow_new(FALSE);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
387 gnt_box_add_widget(GNT_BOX(win), gnt_label_new("Are you sure you want to quit?"));
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
388 gnt_box_set_title(GNT_BOX(win), "Quit?");
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
389 gnt_box_set_alignment(GNT_BOX(win), GNT_ALIGN_MID);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
390 g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(exit_win_close), &win);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
391
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
392 bbox = gnt_hbox_new(FALSE);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
393 gnt_box_add_widget(GNT_BOX(win), bbox);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
394
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
395 button = gnt_button_new("Quit");
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
396 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(exit_confirmed), NULL);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
397 gnt_box_add_widget(GNT_BOX(bbox), button);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
398
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
399 button = gnt_button_new("Cancel");
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
400 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), win);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
401 gnt_box_add_widget(GNT_BOX(bbox), button);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
402
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
403 gnt_widget_show(win);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
404 raise:
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
405 gnt_wm_raise_window(wm, win);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
406 }
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
407
17093
7ad0acaf60ab Do not process clicks on no widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16944
diff changeset
408 #ifdef SIGWINCH
7ad0acaf60ab Do not process clicks on no widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16944
diff changeset
409 static void (*org_winch_handler)(int);
7ad0acaf60ab Do not process clicks on no widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16944
diff changeset
410 #endif
7ad0acaf60ab Do not process clicks on no widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16944
diff changeset
411
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
412 static void
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
413 sighandler(int sig)
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
414 {
14443
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
415 switch (sig) {
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
416 #ifdef SIGWINCH
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
417 case SIGWINCH:
17355
8cb2af48afee I think this fixes #532.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17099
diff changeset
418 erase();
22108
cb9819851163 Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@pidgin.im>
parents: 22104
diff changeset
419 g_idle_add((GSourceFunc)refresh_screen, NULL);
20121
3d3e04bc28df applied changes from 388507622896337fe56945f851e3aabee3c0427f
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
420 if (org_winch_handler)
3d3e04bc28df applied changes from 388507622896337fe56945f851e3aabee3c0427f
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
421 org_winch_handler(sig);
14443
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
422 signal(SIGWINCH, sighandler);
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
423 break;
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
424 #endif
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
425 case SIGCHLD:
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
426 clean_pid();
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
427 signal(SIGCHLD, sighandler);
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
428 break;
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
429 case SIGINT:
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
430 ask_before_exit();
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
431 signal(SIGINT, sighandler);
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
432 break;
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
433 }
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
434 }
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
435
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
436 static void
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 21837
diff changeset
437 init_wm(void)
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
438 {
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
439 const char *name = gnt_style_get(GNT_STYLE_WM);
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
440 gpointer handle;
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
441
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
442 if (name && *name) {
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
443 handle = g_module_open(name, G_MODULE_BIND_LAZY);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
444 if (handle) {
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
445 gboolean (*init)(GntWM **);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
446 if (g_module_symbol(handle, "gntwm_init", (gpointer)&init)) {
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
447 init(&wm);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
448 }
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
449 }
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
450 }
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
451 if (wm == NULL)
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
452 wm = g_object_new(GNT_TYPE_WM, NULL);
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
453 }
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
454
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
455 void gnt_init()
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
456 {
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14045
diff changeset
457 char *filename;
14264
f8399abdcb46 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14201
diff changeset
458 const char *locale;
f8399abdcb46 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14201
diff changeset
459
14045
12b8c2bfd3fb [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14026
diff changeset
460 if (channel)
12b8c2bfd3fb [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14026
diff changeset
461 return;
12b8c2bfd3fb [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14026
diff changeset
462
15485
07050dfe816e More closely imitate the input handling of irssi. Hopefully this will fix the excessive CPU usage bug Alver keeps getting.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
463 locale = setlocale(LC_ALL, "");
14264
f8399abdcb46 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14201
diff changeset
464
15485
07050dfe816e More closely imitate the input handling of irssi. Hopefully this will fix the excessive CPU usage bug Alver keeps getting.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
465 setup_io();
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
466
18262
17ac69b18163 Detect wide character non-support at compile time, if possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18133
diff changeset
467 #ifdef NO_WIDECHAR
17ac69b18163 Detect wide character non-support at compile time, if possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18133
diff changeset
468 ascii_only = TRUE;
17ac69b18163 Detect wide character non-support at compile time, if possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18133
diff changeset
469 #else
28937
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
470 if (locale && (strstr(locale, "UTF") || strstr(locale, "utf"))) {
13989
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
471 ascii_only = FALSE;
28937
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
472 } else {
13989
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
473 ascii_only = TRUE;
28937
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
474 gnt_need_conversation_to_locale = TRUE;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
475 }
18262
17ac69b18163 Detect wide character non-support at compile time, if possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18133
diff changeset
476 #endif
13989
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
477
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
478 initscr();
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
479 typeahead(-1);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
480 noecho();
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
481 curs_set(0);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14121
diff changeset
482
15862
895c0f69faa0 Make sure unbound key-combinations are handled properly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15842
diff changeset
483 gnt_init_keys();
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
484 gnt_init_styles();
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
485
14066
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14045
diff changeset
486 filename = g_build_filename(g_get_home_dir(), ".gntrc", NULL);
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14045
diff changeset
487 gnt_style_read_configure_file(filename);
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14045
diff changeset
488 g_free(filename);
3a97522e09ee [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14045
diff changeset
489
14361
4d6014205744 [gaim-migrate @ 16989]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14354
diff changeset
490 gnt_init_colors();
13931
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
491
21240
b78eaddaae02 Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20201
diff changeset
492 wbkgdset(stdscr, '\0' | gnt_color_pair(GNT_COLOR_NORMAL));
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
493 refresh();
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
494
14379
d1bd558266b7 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14376
diff changeset
495 #ifdef ALL_MOUSE_EVENTS
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
496 if ((mouse_enabled = gnt_style_get_bool(GNT_STYLE_MOUSE, FALSE)))
14379
d1bd558266b7 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14376
diff changeset
497 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
14376
43b7dc7d2a52 [gaim-migrate @ 17007]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14372
diff changeset
498 #endif
14372
61f53bc11687 [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14361
diff changeset
499
21240
b78eaddaae02 Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20201
diff changeset
500 wbkgdset(stdscr, '\0' | gnt_color_pair(GNT_COLOR_NORMAL));
13969
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
501 werase(stdscr);
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
502 wrefresh(stdscr);
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
503
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
504 #ifdef SIGWINCH
17093
7ad0acaf60ab Do not process clicks on no widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16944
diff changeset
505 org_winch_handler = signal(SIGWINCH, sighandler);
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
506 #endif
14443
b7b18eddd910 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14424
diff changeset
507 signal(SIGCHLD, sighandler);
16944
921fc0bccf3a Ask before exiting when ctrl+c is pressed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16837
diff changeset
508 signal(SIGINT, sighandler);
14799
4e25a23ab343 [gaim-migrate @ 17493]
Richard Nelson <wabz@pidgin.im>
parents: 14742
diff changeset
509 signal(SIGPIPE, SIG_IGN);
14335
43dec8ee3096 [gaim-migrate @ 16958]
Mark Schneider <queueram@gmail.com>
parents: 14318
diff changeset
510
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
511 g_type_init();
14397
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
512
e53755c4dcab [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14387
diff changeset
513 init_wm();
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
514
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
515 clipboard = g_object_new(GNT_TYPE_CLIPBOARD, NULL);
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
516 }
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
517
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
518 void gnt_main()
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
519 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
520 wm->loop = g_main_loop_new(NULL, FALSE);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
521 g_main_loop_run(wm->loop);
13852
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
522 }
1d3ae9f34d42 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
523
13931
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
524 /*********************************
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
525 * Stuff for 'window management' *
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
526 *********************************/
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
527
18399
f4043513f791 Allow raising window only from an event-stack, otherwise set the urgent flag.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18262
diff changeset
528 void gnt_window_present(GntWidget *window)
f4043513f791 Allow raising window only from an event-stack, otherwise set the urgent flag.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18262
diff changeset
529 {
f4043513f791 Allow raising window only from an event-stack, otherwise set the urgent flag.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18262
diff changeset
530 if (wm->event_stack)
f4043513f791 Allow raising window only from an event-stack, otherwise set the urgent flag.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18262
diff changeset
531 gnt_wm_raise_window(wm, window);
f4043513f791 Allow raising window only from an event-stack, otherwise set the urgent flag.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18262
diff changeset
532 else
f4043513f791 Allow raising window only from an event-stack, otherwise set the urgent flag.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18262
diff changeset
533 gnt_widget_set_urgent(window);
18133
bc6e30a08d9a add gnt_window_present
Richard Nelson <wabz@pidgin.im>
parents: 18132
diff changeset
534 }
bc6e30a08d9a add gnt_window_present
Richard Nelson <wabz@pidgin.im>
parents: 18132
diff changeset
535
13931
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
536 void gnt_screen_occupy(GntWidget *widget)
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
537 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
538 gnt_wm_new_window(wm, widget);
13931
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
539 }
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
540
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
541 void gnt_screen_release(GntWidget *widget)
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
542 {
19180
a814189b2782 This fixes a few weird crashes in pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18778
diff changeset
543 if (wm)
a814189b2782 This fixes a few weird crashes in pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18778
diff changeset
544 gnt_wm_window_close(wm, widget);
13931
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
545 }
a0a91e17f899 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13922
diff changeset
546
13940
26ed45b11483 [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13931
diff changeset
547 void gnt_screen_update(GntWidget *widget)
26ed45b11483 [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13931
diff changeset
548 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
549 gnt_wm_update_window(wm, widget);
13940
26ed45b11483 [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13931
diff changeset
550 }
26ed45b11483 [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13931
diff changeset
551
13958
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
552 gboolean gnt_widget_has_focus(GntWidget *widget)
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
553 {
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
554 GntWidget *w;
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
555 if (!widget)
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
556 return FALSE;
14675
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
557
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
558 if (GNT_IS_MENU(widget))
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
559 return TRUE;
13958
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
560
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
561 w = widget;
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
562
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
563 while (widget->parent)
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
564 widget = widget->parent;
13992
a6bbcc09c4eb [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13989
diff changeset
565
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
566 if (widget == wm->_list.window)
13992
a6bbcc09c4eb [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13989
diff changeset
567 return TRUE;
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16356
diff changeset
568 if (wm->cws->ordered && wm->cws->ordered->data == widget) {
13969
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
569 if (GNT_IS_BOX(widget) &&
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
570 (GNT_BOX(widget)->active == w || widget == w))
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
571 return TRUE;
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
572 }
13958
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
573 return FALSE;
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
574 }
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13955
diff changeset
575
13959
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
576 void gnt_widget_set_urgent(GntWidget *widget)
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
577 {
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
578 while (widget->parent)
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
579 widget = widget->parent;
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
580
16519
9458657f5b99 Initial workspace support. refs #51
Richard Nelson <wabz@pidgin.im>
parents: 16356
diff changeset
581 if (wm->cws->ordered && wm->cws->ordered->data == widget)
13959
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
582 return;
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
583
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
584 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_URGENT);
14452
a21351048a3a [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14450
diff changeset
585
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
586 gnt_wm_update_window(wm, widget);
13959
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
587 }
49d3a87c2679 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13958
diff changeset
588
13969
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
589 void gnt_quit()
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
590 {
28427
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
591 /* Prevent io_invoke() from being called after wm is destroyed */
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
592 g_source_remove(channel_error_callback);
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
593 g_source_remove(channel_read_callback);
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
594
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
595 channel_error_callback = 0;
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
596 channel_read_callback = 0;
4186acdcd882 Remove IO watches at shutdown in gntmain.c Closes #9872.
Tomasz Mon <desowin@gmail.com>
parents: 25353
diff changeset
597
19180
a814189b2782 This fixes a few weird crashes in pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18778
diff changeset
598 g_object_unref(G_OBJECT(wm));
a814189b2782 This fixes a few weird crashes in pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18778
diff changeset
599 wm = NULL;
a814189b2782 This fixes a few weird crashes in pygnt.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18778
diff changeset
600
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
601 update_panels();
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
602 doupdate();
14026
ad91ce0effe2 [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14019
diff changeset
603 gnt_uninit_colors();
14072
4e64a4f18686 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14066
diff changeset
604 gnt_uninit_styles();
13969
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
605 endwin();
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
606 }
0541f389442e [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13959
diff changeset
607
13989
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
608 gboolean gnt_ascii_only()
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
609 {
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
610 return ascii_only;
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
611 }
9a647311c9ac [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13981
diff changeset
612
14005
198d1658b390 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13996
diff changeset
613 void gnt_screen_resize_widget(GntWidget *widget, int width, int height)
198d1658b390 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13996
diff changeset
614 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
615 gnt_wm_resize_window(wm, widget, width, height);
14005
198d1658b390 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13996
diff changeset
616 }
198d1658b390 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13996
diff changeset
617
14201
d54dc208efe2 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14193
diff changeset
618 void gnt_screen_move_widget(GntWidget *widget, int x, int y)
d54dc208efe2 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14193
diff changeset
619 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
620 gnt_wm_move_window(wm, widget, x, y);
14201
d54dc208efe2 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14193
diff changeset
621 }
d54dc208efe2 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14193
diff changeset
622
14450
1ac2b6e98ef8 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14449
diff changeset
623 void gnt_screen_rename_widget(GntWidget *widget, const char *text)
1ac2b6e98ef8 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14449
diff changeset
624 {
1ac2b6e98ef8 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14449
diff changeset
625 gnt_box_set_title(GNT_BOX(widget), text);
1ac2b6e98ef8 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14449
diff changeset
626 gnt_widget_draw(widget);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
627 gnt_wm_update_window(wm, widget);
14450
1ac2b6e98ef8 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14449
diff changeset
628 }
1ac2b6e98ef8 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14449
diff changeset
629
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 21837
diff changeset
630 void gnt_register_action(const char *label, void (*callback)(void))
14467
359d9aad0f01 [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14452
diff changeset
631 {
359d9aad0f01 [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14452
diff changeset
632 GntAction *action = g_new0(GntAction, 1);
359d9aad0f01 [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14452
diff changeset
633 action->label = g_strdup(label);
359d9aad0f01 [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14452
diff changeset
634 action->callback = callback;
359d9aad0f01 [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14452
diff changeset
635
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
636 wm->acts = g_list_append(wm->acts, action);
14467
359d9aad0f01 [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14452
diff changeset
637 }
359d9aad0f01 [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14452
diff changeset
638
14675
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
639 static void
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
640 reset_menu(GntWidget *widget, gpointer null)
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
641 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
642 wm->menu = NULL;
14675
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
643 }
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
644
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
645 gboolean gnt_screen_menu_show(gpointer newmenu)
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
646 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
647 if (wm->menu) {
14675
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
648 /* For now, if a menu is being displayed, then another menu
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
649 * can NOT take over. */
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
650 return FALSE;
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
651 }
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
652
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
653 wm->menu = newmenu;
14968
2b1ed06a4773 [gaim-migrate @ 17678]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
654 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(wm->menu), GNT_WIDGET_INVISIBLE);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
655 gnt_widget_draw(GNT_WIDGET(wm->menu));
14675
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
656
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14943
diff changeset
657 g_signal_connect(G_OBJECT(wm->menu), "hide", G_CALLBACK(reset_menu), NULL);
16837
d3b8ba967fdc Fix context menu unusualness in the buddylist.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16356
diff changeset
658 g_signal_connect(G_OBJECT(wm->menu), "destroy", G_CALLBACK(reset_menu), NULL);
14675
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
659
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
660 return TRUE;
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
661 }
be8af28d1980 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14606
diff changeset
662
20293
81d324f460bd applied changes from 1f57ebe4e6d16159c74db823ecff2ec0f4c46936
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 20201
diff changeset
663 void gnt_set_clipboard_string(const gchar *string)
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
664 {
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
665 gnt_clipboard_set_string(clipboard, string);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
666 }
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
667
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
668 GntClipboard *gnt_get_clipboard()
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
669 {
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
670 return clipboard;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
671 }
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
672
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
673 gchar *gnt_get_clipboard_string()
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
674 {
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
675 return gnt_clipboard_get_string(clipboard);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents: 15485
diff changeset
676 }
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
677
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
678 #if GLIB_CHECK_VERSION(2,4,0)
18778
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
679 typedef struct
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
680 {
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
681 void (*callback)(int status, gpointer data);
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
682 gpointer data;
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
683 } ChildProcess;
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
684
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
685 static void
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
686 reap_child(GPid pid, gint status, gpointer data)
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
687 {
18778
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
688 ChildProcess *cp = data;
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
689 if (cp->callback) {
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
690 cp->callback(status, cp->data);
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
691 }
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
692 g_free(cp);
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
693 clean_pid();
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
694 wm->mode = GNT_KP_MODE_NORMAL;
21837
16cb747fcda5 Restore the screen properly after the child process ends.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21720
diff changeset
695 endwin();
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
696 setup_io();
21837
16cb747fcda5 Restore the screen properly after the child process ends.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21720
diff changeset
697 refresh();
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
698 refresh_screen();
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
699 }
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
700 #endif
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
701
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
702 gboolean gnt_giveup_console(const char *wd, char **argv, char **envp,
18778
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
703 gint *stin, gint *stout, gint *sterr,
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
704 void (*callback)(int status, gpointer data), gpointer data)
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
705 {
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
706 #if GLIB_CHECK_VERSION(2,4,0)
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
707 GPid pid = 0;
18778
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
708 ChildProcess *cp = NULL;
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
709
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
710 if (!g_spawn_async_with_pipes(wd, argv, envp,
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
711 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
712 (GSpawnChildSetupFunc)endwin, NULL,
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
713 &pid, stin, stout, sterr, NULL))
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
714 return FALSE;
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
715
18778
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
716 cp = g_new0(ChildProcess, 1);
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
717 cp->callback = callback;
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
718 cp->data = data;
18603
99a3588da5b1 The input was causing some weird issues. This fixes it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18599
diff changeset
719 g_source_remove(channel_read_callback);
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
720 wm->mode = GNT_KP_MODE_WAIT_ON_CHILD;
18778
7cf5400593b8 Allow having a callback after the child process terminates. Use the callback
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18623
diff changeset
721 g_child_watch_add(pid, reap_child, cp);
18599
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
722
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
723 return TRUE;
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
724 #else
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
725 return FALSE;
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
726 #endif
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
727 }
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
728
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
729 gboolean gnt_is_refugee()
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
730 {
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
731 #if GLIB_CHECK_VERSION(2,4,0)
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
732 return (wm && wm->mode == GNT_KP_MODE_WAIT_ON_CHILD);
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
733 #else
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
734 return FALSE;
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
735 #endif
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
736 }
7e31405a2cbb Allow executing another application (eg. PAGER) that will use the same
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18399
diff changeset
737
28937
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
738 const char *C_(const char *x)
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
739 {
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
740 static char *c = NULL;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
741 if (gnt_need_conversation_to_locale) {
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
742 GError *error = NULL;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
743 g_free(c);
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
744 c = g_locale_from_utf8(x, -1, NULL, NULL, &error);
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
745 if (c == NULL || error) {
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
746 char *store = c;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
747 c = NULL;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
748 gnt_warning("Error: %s\n", error ? error->message : "(unknown)");
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
749 g_error_free(error);
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
750 error = NULL;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
751 g_free(c);
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
752 c = store;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
753 }
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
754 return c ? c : x;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
755 } else
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
756 return x;
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
757 }
5f87e66597d9 Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28427
diff changeset
758

mercurial