--- a/gnt.h Tue Apr 22 13:18:02 2014 +0530
+++ b/gnt.h Fri Apr 25 16:55:07 2014 +0530
@@ -57,6 +57,17 @@
+ * @config_dir: the path to a configuration directory, may be %NULL. + * Change directory to store gnt configuration files (default is ~). + * You have to call this before #gnt_init. You might want to call this + * with %NULL, to free the resources, but not before a call to #gnt_quit. +void gnt_set_config_dir(const gchar *config_dir); * Start running the mainloop for gnt.
--- a/gntinternal.h Tue Apr 22 13:18:02 2014 +0530
+++ b/gntinternal.h Fri Apr 25 16:55:07 2014 +0530
@@ -44,4 +44,4 @@
extern int gnt_need_conversation_to_locale;
extern const char *C_(const char *x);
+const gchar *gnt_get_config_dir(void); --- a/gntkeys.c Tue Apr 22 13:18:02 2014 +0530
+++ b/gntkeys.c Fri Apr 25 16:55:07 2014 +0530
@@ -51,6 +51,12 @@
term = ""; /* Just in case */
+ gnt_key_cup = GNT_KEY_CTRL_UP; + gnt_key_cdown = GNT_KEY_CTRL_DOWN; + gnt_key_cright = GNT_KEY_CTRL_RIGHT; + gnt_key_cleft = GNT_KEY_CTRL_LEFT; if (strstr(term, "xterm") == term || strcmp(term, "rxvt") == 0) {
gnt_key_cup = "\033" "[1;5A";
gnt_key_cdown = "\033" "[1;5B";
@@ -62,6 +68,7 @@
gnt_key_cright = "\033" "Oc";
gnt_key_cleft = "\033" "Od";
specials = g_hash_table_new(g_str_hash, g_str_equal);
@@ -141,7 +148,7 @@
- for (a = 0; alts[a]; a++) {
+ for (a = 0; alts[a]; a++) { /* XXX: is that loop necessary? */ /* Upper-case alphabets */
for (ch = 0; ch < 26; ch++) {
char str[2] = {'A' + ch, 0}, code[] = {'\033', 'A' + ch, 0};
--- a/gntkeys.h Tue Apr 22 13:18:02 2014 +0530
+++ b/gntkeys.h Fri Apr 25 16:55:07 2014 +0530
@@ -54,40 +54,40 @@
#define GNT_KEY_POPUP CONST("") /* not supported? */
-#define GNT_KEY_UP CONST("\xe0\x48")
-#define GNT_KEY_DOWN CONST("\xe0\x50")
-#define GNT_KEY_LEFT CONST("\xe0\x4B")
-#define GNT_KEY_RIGHT CONST("\xe0\x4D")
+#define GNT_KEY_UP CONST("\033\xe0\x48") +#define GNT_KEY_DOWN CONST("\033\xe0\x50") +#define GNT_KEY_LEFT CONST("\033\xe0\x4B") +#define GNT_KEY_RIGHT CONST("\033\xe0\x4D") -#define GNT_KEY_CTRL_UP CONST("\xe0\x8d")
-#define GNT_KEY_CTRL_DOWN CONST("\xe0\x91")
-#define GNT_KEY_CTRL_LEFT CONST("\xe0\x73")
-#define GNT_KEY_CTRL_RIGHT CONST("\xe0\x74")
+#define GNT_KEY_CTRL_UP CONST("\033\xe0\x8d") +#define GNT_KEY_CTRL_DOWN CONST("\033\xe0\x91") +#define GNT_KEY_CTRL_LEFT CONST("\033\xe0\x73") +#define GNT_KEY_CTRL_RIGHT CONST("\033\xe0\x74") -#define GNT_KEY_PGUP CONST("\xe0\x49")
-#define GNT_KEY_PGDOWN CONST("\xe0\x51")
-#define GNT_KEY_HOME CONST("\xe0\x47")
-#define GNT_KEY_END CONST("\xe0\x4f")
+#define GNT_KEY_PGUP CONST("\033\xe0\x49") +#define GNT_KEY_PGDOWN CONST("\033\xe0\x51") +#define GNT_KEY_HOME CONST("\033\xe0\x47") +#define GNT_KEY_END CONST("\033\xe0\x4f") #define GNT_KEY_ENTER CONST("\x0d")
#define GNT_KEY_BACKSPACE CONST("\x08")
-#define GNT_KEY_DEL CONST("\xe0\x53")
-#define GNT_KEY_INS CONST("\xe0\x52")
-#define GNT_KEY_BACK_TAB CONST("\xe1\x94")
+#define GNT_KEY_DEL CONST("\033\xe0\x53") +#define GNT_KEY_INS CONST("\033\xe0\x52") +#define GNT_KEY_BACK_TAB CONST("\033\xe1\x94") -#define GNT_KEY_F1 CONST("\xe1\x3b")
-#define GNT_KEY_F2 CONST("\xe1\x3c")
-#define GNT_KEY_F3 CONST("\xe1\x3d")
-#define GNT_KEY_F4 CONST("\xe1\x3e")
-#define GNT_KEY_F5 CONST("\xe1\x3f")
-#define GNT_KEY_F6 CONST("\xe1\x40")
-#define GNT_KEY_F7 CONST("\xe1\x41")
-#define GNT_KEY_F8 CONST("\xe1\x42")
-#define GNT_KEY_F9 CONST("\xe1\x43")
-#define GNT_KEY_F10 CONST("\xe1\x44")
-#define GNT_KEY_F11 CONST("\xe0\x85")
-#define GNT_KEY_F12 CONST("\xe0\x86")
+#define GNT_KEY_F1 CONST("\033\xe1\x3b") +#define GNT_KEY_F2 CONST("\033\xe1\x3c") +#define GNT_KEY_F3 CONST("\033\xe1\x3d") +#define GNT_KEY_F4 CONST("\033\xe1\x3e") +#define GNT_KEY_F5 CONST("\033\xe1\x3f") +#define GNT_KEY_F6 CONST("\033\xe1\x40") +#define GNT_KEY_F7 CONST("\033\xe1\x41") +#define GNT_KEY_F8 CONST("\033\xe1\x42") +#define GNT_KEY_F9 CONST("\033\xe1\x43") +#define GNT_KEY_F10 CONST("\033\xe1\x44") +#define GNT_KEY_F11 CONST("\033\xe0\x85") +#define GNT_KEY_F12 CONST("\033\xe0\x86") --- a/gntmain.c Tue Apr 22 13:18:02 2014 +0530
+++ b/gntmain.c Fri Apr 25 16:55:07 2014 +0530
@@ -66,6 +66,7 @@
@@ -92,6 +93,8 @@
int gnt_need_conversation_to_locale;
+static gchar *custom_config_dir = NULL; #define HOLDING_ESCAPE (escape_stuff.timer != 0)
@@ -106,6 +109,25 @@
+gnt_set_config_dir(const gchar *config_dir) + gnt_warning("gnt_set_config_dir failed: %s", + "gnt already initialized"); + free(custom_config_dir); + custom_config_dir = g_strdup(config_dir); +gnt_get_config_dir(void) + return custom_config_dir; + return g_get_home_dir(); @@ -247,22 +269,38 @@
io_invoke(GIOChannel *source, GIOCondition cond, gpointer null)
+ * - 1 for escape prefix + * - 6 for gunichar-to-gchar conversion (see g_unichar_to_utf8) + * - 1 for the terminating NUL + * - 1 for escape prefix + * - 1 for special key prefix + * - 1 for the terminating NUL gboolean is_special = FALSE;
+ gboolean is_escape = FALSE; if (wm->mode == GNT_KP_MODE_WAIT_ON_CHILD)
g_source_remove(escape_stuff.timer);
+ } else if (GetAsyncKeyState(VK_LMENU)) { /* left-ALT key */ - ch = _getch(); /* we could use _getch_nolock */
+ ch = _getwch(); /* we could use _getwch_nolock */ /* a small hack - we don't want to put NUL anywhere */
@@ -270,14 +308,16 @@
if (ch == 0xE0 || ch == 0xE1) {
- if (ch == 0x1B && !is_special) { /* ESC */
+ if (ch == 0x1B && !is_special) { /* ESC key */ escape_stuff.timer = g_timeout_add(250, escape_timeout, NULL);
@@ -285,16 +325,26 @@
gnt_wm_set_event_stack(wm, TRUE);
- gsize converted_len = 0;
+ gnt_warning("a special key out of gchar range (%d)", ch); - converted = g_locale_to_utf8(k, 1, NULL, &converted_len, NULL);
- if (converted_len > 0 && converted_len <= 4) {
- memcpy(k, converted, converted_len);
- k[converted_len] = '\0';
+ result_len = g_unichar_to_utf8(ch, k); + gnt_warning("a key: [%s] %#x %#x %#x %#x %#x %#x", keys, + (guchar)keys[0], (guchar)keys[1], (guchar)keys[2], + (guchar)keys[3], (guchar)keys[4], (guchar)keys[5]); /* TODO: we could call detect_mouse_action here, but no
* events are triggered (yet?) for mouse on win32.
@@ -554,6 +604,12 @@
+ /* TODO: check it with NO_WIDECHAR. */ locale = setlocale(LC_ALL, "");
@@ -578,7 +634,7 @@
- filename = g_build_filename(g_get_home_dir(), ".gntrc", NULL);
+ filename = g_build_filename(gnt_get_config_dir(), ".gntrc", NULL); gnt_style_read_configure_file(filename);
--- a/gntwm.c Tue Apr 22 13:18:02 2014 +0530
+++ b/gntwm.c Fri Apr 25 16:55:07 2014 +0530
@@ -331,7 +331,7 @@
read_window_positions(GntWM *wm)
GKeyFile *gfile = g_key_file_new();
- char *filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL);
+ char *filename = g_build_filename(gnt_get_config_dir(), ".gntpositions", NULL); @@ -427,7 +427,7 @@
w = wm->cws->ordered->data;
orgpos = pos = g_list_index(wm->cws->list, w);
- g_return_if_fail(pos < 0);
+ g_return_if_fail(pos >= 0); @@ -2120,7 +2120,7 @@
- filename = g_build_filename(g_get_home_dir(), ".gntpositions", NULL);
+ filename = g_build_filename(gnt_get_config_dir(), ".gntpositions", NULL); file = fopen(filename, "wb");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libgnt_winres.rc.in Fri Apr 25 16:55:07 2014 +0530
@@ -0,0 +1,30 @@
+VS_VERSION_INFO VERSIONINFO + FILEVERSION @GNT_MAJOR_VERSION@,@GNT_MINOR_VERSION@,@GNT_MICRO_VERSION@,0 + PRODUCTVERSION @GNT_MAJOR_VERSION@,@GNT_MINOR_VERSION@,@GNT_MICRO_VERSION@,0 + FILESUBTYPE VFT2_UNKNOWN + VALUE "CompanyName", "The Pidgin developer community" + VALUE "FileDescription", "Glib ncurses toolkit" + VALUE "FileVersion", "@GNT_VERSION@" + VALUE "InternalName", "libgnt" + VALUE "LegalCopyright", "Copyright (C) 1998-2014 The Pidgin developer community (See the COPYRIGHT file in the source distribution)." + VALUE "OriginalFilename", "libgnt-@GNT_API_VERSION@.dll" + VALUE "ProductName", "libgnt" + VALUE "ProductVersion", "@GNT_VERSION@" + VALUE "Translation", 0x409, 1200