2006-03-18 11:36:31 -08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-02-06 11:42:19 -08:00
|
|
|
#include <gtk/gtk.h>
|
2006-03-18 11:13:15 -08:00
|
|
|
#include <ctype.h>
|
2000-02-06 11:42:19 -08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2006-03-18 11:13:15 -08:00
|
|
|
#include <string.h>
|
2000-02-06 11:42:19 -08:00
|
|
|
#include <sys/stat.h>
|
2000-02-11 14:36:18 -08:00
|
|
|
#include <X11/Xlib.h>
|
2013-02-12 11:07:39 -08:00
|
|
|
#include <X11/XKBlib.h>
|
2000-02-11 14:36:18 -08:00
|
|
|
#include <gdk/gdkx.h>
|
2000-02-06 11:42:19 -08:00
|
|
|
#include <unistd.h>
|
2006-03-18 11:13:15 -08:00
|
|
|
|
2000-02-07 11:53:40 -08:00
|
|
|
#include "viewer.h"
|
2000-02-08 13:23:22 -08:00
|
|
|
#include "menus.h"
|
2000-02-08 15:23:44 -08:00
|
|
|
#include "ipc.h"
|
2000-02-06 11:42:19 -08:00
|
|
|
|
2006-03-18 07:32:19 -08:00
|
|
|
#if __GNUC__ /* FIXME - Use autofoo */
|
2006-03-18 07:16:24 -08:00
|
|
|
#define __UNUSED__ __attribute__((unused))
|
|
|
|
#else
|
|
|
|
#define __UNUSED__
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DEBUG 0
|
|
|
|
|
2009-10-17 10:58:14 -07:00
|
|
|
#define VER(maj, min, mic) (10000 * (maj) + 100 * (min) + (mic))
|
|
|
|
|
2000-02-07 11:53:40 -08:00
|
|
|
extern GtkTooltips *tooltips;
|
|
|
|
extern GtkAccelGroup *accel_group;
|
2000-02-06 11:42:19 -08:00
|
|
|
|
2006-03-18 02:34:25 -08:00
|
|
|
static GtkWidget *clist;
|
|
|
|
static GtkWidget *act_key;
|
|
|
|
static GtkWidget *act_params;
|
|
|
|
static GtkWidget *act_mod;
|
|
|
|
static GtkWidget *act_clist;
|
2006-03-18 02:23:33 -08:00
|
|
|
|
2006-03-18 02:34:25 -08:00
|
|
|
static gchar *e_ipc_msg = NULL;
|
|
|
|
static char dont_update = 0;
|
|
|
|
static int last_row = 0;
|
|
|
|
static int real_rows = 0;
|
2006-03-18 02:23:33 -08:00
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *name_short;
|
|
|
|
const char *name_long;
|
|
|
|
} Modifier;
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
typedef struct
|
2006-03-18 02:23:33 -08:00
|
|
|
{
|
2006-03-18 02:34:25 -08:00
|
|
|
const char *text;
|
2006-03-18 02:23:33 -08:00
|
|
|
gchar param_tpe;
|
2006-03-18 02:34:25 -08:00
|
|
|
const char *params;
|
2006-03-18 07:16:24 -08:00
|
|
|
const char *command;
|
2000-02-08 16:02:14 -08:00
|
|
|
} ActionOpt;
|
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
/* *INDENT-OFF* */
|
|
|
|
static const Modifier modifiers[] = {
|
|
|
|
{"-", ""},
|
|
|
|
{"C", "CTRL"},
|
|
|
|
{"S", "SHIFT"},
|
|
|
|
{"A", "ALT"},
|
|
|
|
{"CS", "CTRL+SHIFT"},
|
|
|
|
{"CA", "CTRL+ALT"},
|
|
|
|
{"SA", "ALT+SHIFT"},
|
|
|
|
{"CSA", "CTRL+ALT+SHIFT"},
|
|
|
|
{"2", "MOD2"},
|
|
|
|
{"3", "MOD3"},
|
|
|
|
{"4", "MOD4"},
|
|
|
|
{"5", "MOD5"},
|
|
|
|
{"C2", "MOD2+CTRL"},
|
|
|
|
{"S2", "MOD2+SHIFT"},
|
|
|
|
{"A2", "MOD2+ALT"},
|
|
|
|
{"C4", "MOD4+CTRL"},
|
|
|
|
{"S4", "MOD4+SHIFT"},
|
|
|
|
{"A4", "MOD4+ALT"},
|
|
|
|
{"CS4", "MOD4+CTRL+SHIFT"},
|
|
|
|
{"C5", "MOD5+CTRL"},
|
|
|
|
{"S5", "MOD5+SHIFT"},
|
|
|
|
{"A5", "MOD5+ALT"},
|
|
|
|
{"CS5", "MOD5+CTRL+SHIFT"},
|
2000-02-08 16:21:14 -08:00
|
|
|
};
|
2009-09-20 02:27:00 -07:00
|
|
|
#define N_MODIFIERS (sizeof(modifiers)/sizeof(Modifier))
|
|
|
|
#define MOD_TEXT(mod) modifiers[mod].name_long
|
2000-02-08 16:21:14 -08:00
|
|
|
|
2006-03-18 11:13:15 -08:00
|
|
|
static const ActionOpt actions_default[] = {
|
2009-05-03 04:41:03 -07:00
|
|
|
{"Run command", 1, NULL, "exec "},
|
|
|
|
|
|
|
|
{"Restart Enlightenment", 0, "restart", "restart"},
|
|
|
|
{"Exit Enlightenment", 0, NULL, "exit"},
|
|
|
|
|
|
|
|
{"Goto Next Desktop", 0, NULL, "desk next"},
|
|
|
|
{"Goto Previous Deskop", 0, NULL, "desk prev"},
|
|
|
|
{"Goto Desktop", 2, NULL, "desk goto "},
|
|
|
|
{"Raise Desktop", 0, NULL, "desk raise"},
|
|
|
|
{"Lower Desktop", 0, NULL, "desk lower"},
|
|
|
|
{"Reset Desktop In Place", 0, NULL, "desk this"},
|
|
|
|
|
|
|
|
{"Cleanup Windows", 0, NULL, "misc arrange size"},
|
|
|
|
|
|
|
|
{"Move mouse pointer to next screen", 0, NULL, "warp screen"},
|
|
|
|
|
|
|
|
{"Move mouse pointer to left", 0, "-1 0", "warp rel -1 0"},
|
|
|
|
{"Move mouse pointer to right", 0, "1 0", "warp rel 1 0"},
|
|
|
|
{"Move mouse pointer up", 0, "0 -1", "warp rel 0 -1"},
|
|
|
|
{"Move mouse pointer down", 0, "0 1", "warp rel 0 1"},
|
|
|
|
{"Move mouse pointer by [X Y]", 3, NULL, "warp rel "},
|
|
|
|
|
|
|
|
{"Goto Desktop area [X Y]", 3, NULL, "area goto"},
|
|
|
|
{"Move to Desktop area on the left", 0, "-1 0", "area move -1 0"},
|
|
|
|
{"Move to Desktop area on the right", 0, "1 0", "area move 1 0"},
|
|
|
|
{"Move to Desktop area above", 0, "0 -1", "area move 0 -1"},
|
|
|
|
{"Move to Desktop area below", 0, "0 1", "area move 0 1"},
|
|
|
|
|
|
|
|
{"Raise Window", 0, NULL, "wop * raise"},
|
|
|
|
{"Lower Window", 0, NULL, "wop * lower"},
|
|
|
|
{"Close Window", 0, NULL, "wop * close"},
|
|
|
|
{"Annihilate Window", 0, NULL, "wop * kill"},
|
|
|
|
{"Stick / Unstick Window", 0, NULL, "wop * stick"},
|
|
|
|
{"Iconify Window", 0, NULL, "wop * iconify"},
|
|
|
|
{"Shade / Unshade Window", 0, NULL, "wop * shade"},
|
|
|
|
{"Maximise Height of Window", 0, "conservative", "wop * th conservative"},
|
|
|
|
{"Maximise Height of Window to available space", 0, "available", "wop * th available"},
|
|
|
|
{"Maximise Height of Window to whole screen", 0, NULL, "wop * th"},
|
|
|
|
{"Maximise Width of Window", 0, "conservative", "wop * tw conservative"},
|
|
|
|
{"Maximise Width of Window to available space", 0, "available", "wop * tw available"},
|
|
|
|
{"Maximise Width of Window to whole screen", 0, NULL, "wop * tw"},
|
|
|
|
{"Maximise Size of Window", 0, "conservative", "wop * ts conservative"},
|
|
|
|
{"Maximise Size of Window to available space", 0, "available", "wop * ts available"},
|
|
|
|
{"Maximise Size of Window to whole screen", 0, NULL, "wop * ts"},
|
|
|
|
{"Toggle Window fullscreen state", 0, NULL, "wop * fullscreen"},
|
|
|
|
{"Toggle Window zoom state", 0, NULL, "wop * zoom"},
|
|
|
|
{"Send window to next desktop", 0, NULL, "wop * desk next"},
|
|
|
|
{"Send window to previous desktop", 0, NULL, "wop * desk prev"},
|
|
|
|
{"Switch focus to next window", 0, NULL, "focus next"},
|
|
|
|
{"Switch focus to previous window", 0, NULL, "focus prev"},
|
|
|
|
{"Glue / Unglue Window to Desktop screen", 0, NULL, "wop * no_user_move"},
|
|
|
|
{"Set Window layer to On Top", 0, "20", "wop * layer 20"},
|
|
|
|
{"Set Window layer to Above", 0, "6", "wop * layer 6"},
|
|
|
|
{"Set Window layer to Normal", 0, "4", "wop * layer 4"},
|
|
|
|
{"Set Window layer to Below", 0, "2", "wop * layer 2"},
|
|
|
|
{"Set Window layer", 2, NULL, "wop * layer "},
|
|
|
|
{"Move Window to area on left", 0, "-1 0", "wop * area move -1 0"},
|
|
|
|
{"Move Window to area on right", 0, "1 0", "wop * area move 1 0"},
|
|
|
|
{"Move Window to area above", 0, "0 -1", "wop * area move 0 -1"},
|
|
|
|
{"Move Window to area below", 0, "0 1", "wop * area move 0 1"},
|
|
|
|
{"Move Window by area [X Y]", 3, NULL, "wop * area "},
|
|
|
|
|
|
|
|
{"Set Window border style to the Default", 0, "DEFAULT", "wop * border DEFAULT"},
|
|
|
|
{"Set Window border style to the Borderless", 0, "BORDERLESS", "wop * border BORDERLESS"},
|
|
|
|
|
|
|
|
{"Forget everything about Window", 0, "none", "wop * snap none"},
|
|
|
|
{"Remember all Window settings", 0, NULL, "wop * snap all"},
|
|
|
|
{"Remember Window Border", 0, "border", "wop * snap border"},
|
|
|
|
{"Remember Window Desktop", 0, "desktop", "wop * snap desktop"},
|
|
|
|
{"Remember Window Desktop Area", 0, "area", "wop * snap area"},
|
|
|
|
{"Remember Window Size", 0, "size", "wop * snap size"},
|
|
|
|
{"Remember Window Location", 0, "location", "wop * snap location"},
|
|
|
|
{"Remember Window Layer", 0, "layer", "wop * snap layer"},
|
|
|
|
{"Remember Window Stickyness", 0, "sticky", "wop * snap sticky"},
|
|
|
|
{"Remember Window Shadedness", 0, "shade", "wop * snap shade"},
|
|
|
|
|
|
|
|
{"Show Root Menu", 0, "ROOT_2", "menus show ROOT_2"},
|
|
|
|
{"Show Winops Menu", 0, "WINOPS_MENU", "menus show WINOPS_MENU"},
|
|
|
|
{"Show Named Menu", 1, NULL, "menus show "},
|
|
|
|
|
|
|
|
{NULL, 0, NULL, NULL}
|
2000-02-08 16:02:14 -08:00
|
|
|
};
|
2006-03-18 02:23:33 -08:00
|
|
|
/* *INDENT-ON* */
|
2000-02-08 16:02:14 -08:00
|
|
|
|
2006-12-16 05:49:13 -08:00
|
|
|
static const ActionOpt *actions = NULL;
|
|
|
|
static unsigned int action_count = sizeof(actions_default) / sizeof(ActionOpt);
|
|
|
|
static unsigned int *action_index_to_row = NULL;
|
|
|
|
static unsigned int *action_row_to_index = NULL;
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static int
|
2009-09-20 02:27:00 -07:00
|
|
|
match_action_by_binding(const char *params)
|
2006-03-18 07:16:24 -08:00
|
|
|
{
|
|
|
|
int k, len;
|
|
|
|
|
|
|
|
for (k = 0; actions[k].text; k++)
|
|
|
|
{
|
2009-05-03 04:41:01 -07:00
|
|
|
len = strlen(actions[k].command);
|
|
|
|
if (strncmp(actions[k].command, params, len))
|
|
|
|
continue;
|
2006-03-18 07:16:24 -08:00
|
|
|
|
2009-05-03 04:41:01 -07:00
|
|
|
return k;
|
2006-03-18 07:16:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
match_action_by_selection(const char *text)
|
|
|
|
{
|
|
|
|
int k;
|
|
|
|
|
|
|
|
for (k = 0; actions[k].text; k++)
|
|
|
|
{
|
|
|
|
if (strcmp(text, actions[k].text))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
static unsigned
|
|
|
|
mod_short_to_index(const char *name_short)
|
|
|
|
{
|
|
|
|
unsigned int k;
|
|
|
|
|
|
|
|
for (k = 0; k < N_MODIFIERS; k++)
|
|
|
|
{
|
|
|
|
if (!strcmp(name_short, modifiers[k].name_short))
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0; /* Discard modifier */
|
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
2006-03-18 13:44:37 -08:00
|
|
|
e_cb_key_change(GtkWidget * widget __UNUSED__, gpointer data __UNUSED__)
|
2000-02-11 14:36:18 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
GtkWidget *win, *label, *frame, *align;
|
|
|
|
|
|
|
|
win = gtk_window_new(GTK_WINDOW_POPUP);
|
|
|
|
gtk_window_set_policy(GTK_WINDOW(win), 0, 0, 1);
|
|
|
|
gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_MOUSE);
|
|
|
|
frame = gtk_frame_new(NULL);
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
|
|
|
|
align = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(align), 32);
|
|
|
|
label = gtk_label_new("Please press the key on the keyboard\n"
|
|
|
|
"you wish to modify this keyboard-shortcut\n"
|
|
|
|
"to use from now on.");
|
|
|
|
gtk_container_add(GTK_CONTAINER(win), frame);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), align);
|
|
|
|
gtk_container_add(GTK_CONTAINER(align), label);
|
|
|
|
gtk_widget_show_all(win);
|
|
|
|
while (gtk_events_pending())
|
|
|
|
gtk_main_iteration();
|
|
|
|
gdk_flush();
|
|
|
|
while (gtk_events_pending())
|
|
|
|
gtk_main_iteration();
|
|
|
|
|
|
|
|
{
|
|
|
|
char *key;
|
|
|
|
XEvent ev;
|
|
|
|
|
|
|
|
gdk_window_set_events(win->window, GDK_KEY_PRESS_MASK);
|
|
|
|
XSetInputFocus(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(win->window),
|
|
|
|
RevertToPointerRoot, CurrentTime);
|
|
|
|
gdk_keyboard_grab(win->window, TRUE, CurrentTime);
|
|
|
|
XWindowEvent(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(win->window),
|
|
|
|
KeyPressMask, &ev);
|
2004-07-26 00:51:18 -07:00
|
|
|
#ifdef ENABLE_GTK2
|
2006-03-18 02:23:33 -08:00
|
|
|
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
|
|
|
|
#else
|
|
|
|
gdk_keyboard_ungrab(gdk_time_get());
|
|
|
|
#endif
|
2013-02-12 11:07:39 -08:00
|
|
|
key = XKeysymToString(XkbKeycodeToKeysym(GDK_DISPLAY(),
|
|
|
|
ev.xkey.keycode, 0, 0));
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(act_key), key);
|
|
|
|
gtk_clist_set_text(GTK_CLIST(clist), last_row, 1, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy(win);
|
2000-02-11 14:36:18 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
2006-03-18 13:44:37 -08:00
|
|
|
e_cb_modifier(GtkWidget * widget __UNUSED__, gpointer data)
|
2000-02-11 14:36:18 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
gint value;
|
2000-02-11 14:12:40 -08:00
|
|
|
|
2009-05-03 04:41:01 -07:00
|
|
|
value = (gint) (glong) data;
|
2009-09-20 02:27:00 -07:00
|
|
|
gtk_clist_set_text(GTK_CLIST(clist), last_row, 0, MOD_TEXT(value));
|
2000-02-08 16:52:18 -08:00
|
|
|
}
|
2000-02-08 16:02:14 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
static gchar *
|
|
|
|
wait_for_ipc_msg(void)
|
2000-02-08 16:02:14 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_main();
|
|
|
|
return e_ipc_msg;
|
2000-02-08 16:02:14 -08:00
|
|
|
}
|
2000-02-08 15:23:44 -08:00
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
|
|
|
change_action(GtkWidget * my_clist __UNUSED__, gint row, gint column __UNUSED__,
|
|
|
|
GdkEventButton * event __UNUSED__, gpointer data __UNUSED__)
|
2000-02-08 16:02:14 -08:00
|
|
|
{
|
2006-12-16 05:49:13 -08:00
|
|
|
int k;
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
if (dont_update)
|
|
|
|
return;
|
2006-03-18 02:23:33 -08:00
|
|
|
|
2006-12-16 05:49:13 -08:00
|
|
|
k = action_row_to_index[row];
|
|
|
|
|
|
|
|
if (actions[k].param_tpe != 0)
|
2006-03-18 02:23:33 -08:00
|
|
|
{
|
2006-03-18 07:16:24 -08:00
|
|
|
gtk_entry_set_editable(GTK_ENTRY(act_params), TRUE);
|
|
|
|
gtk_widget_set_sensitive(act_params, TRUE);
|
2006-03-18 02:23:33 -08:00
|
|
|
}
|
2006-03-18 07:16:24 -08:00
|
|
|
else
|
2006-03-18 02:23:33 -08:00
|
|
|
{
|
2006-03-18 07:16:24 -08:00
|
|
|
gtk_entry_set_editable(GTK_ENTRY(act_params), FALSE);
|
|
|
|
gtk_widget_set_sensitive(act_params, FALSE);
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(act_params), "");
|
2006-03-18 02:23:33 -08:00
|
|
|
}
|
|
|
|
|
2009-05-03 04:41:01 -07:00
|
|
|
if (actions[k].command)
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(act_params), actions[k].command);
|
2006-03-18 07:16:24 -08:00
|
|
|
else
|
2009-05-03 04:41:01 -07:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(act_params), "* Not available *");
|
2006-12-16 05:49:13 -08:00
|
|
|
gtk_clist_set_text(GTK_CLIST(clist), last_row, 2, actions[k].text);
|
2006-03-18 07:16:24 -08:00
|
|
|
gtk_clist_set_text(GTK_CLIST(clist), last_row, 3,
|
|
|
|
gtk_entry_get_text(GTK_ENTRY(act_params)));
|
2000-02-10 16:36:26 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static char *
|
|
|
|
dupcat(char *dst, const char *src)
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
int len1, len2;
|
|
|
|
|
|
|
|
if (!dst)
|
|
|
|
return strdup(src);
|
|
|
|
|
|
|
|
len1 = strlen(dst);
|
|
|
|
len2 = strlen(src);
|
|
|
|
|
|
|
|
s = realloc(dst, len1 + len2 + 1);
|
|
|
|
strcpy(s + len1, src);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-18 13:44:37 -08:00
|
|
|
on_save_data(GtkWidget * widget __UNUSED__, gpointer data __UNUSED__)
|
2000-02-11 15:45:51 -08:00
|
|
|
{
|
2006-03-18 07:16:24 -08:00
|
|
|
char *buf = NULL;
|
2006-03-18 02:23:33 -08:00
|
|
|
int i;
|
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
buf = dupcat(buf, "ac kb set\nAclass KEYBINDINGS global\n");
|
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
for (i = 0; i < real_rows; i++)
|
|
|
|
{
|
|
|
|
char tmp[1024];
|
|
|
|
char *params;
|
|
|
|
char *key;
|
|
|
|
char *mod;
|
|
|
|
int modifier = 0;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
gtk_clist_get_text(GTK_CLIST(clist), i, 0, &mod);
|
|
|
|
for (j = 0; j < 21; j++)
|
|
|
|
{
|
2009-09-20 02:27:00 -07:00
|
|
|
if (!strcmp(MOD_TEXT(j), mod))
|
2006-03-18 02:23:33 -08:00
|
|
|
{
|
|
|
|
modifier = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gtk_clist_get_text(GTK_CLIST(clist), i, 1, &key);
|
2006-03-18 07:16:24 -08:00
|
|
|
gtk_clist_get_text(GTK_CLIST(clist), i, 3, ¶ms);
|
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
snprintf(tmp, sizeof(tmp), "%s %s %s %s\n", "KeyDown",
|
|
|
|
modifiers[modifier].name_short, key, params);
|
2006-03-18 07:16:24 -08:00
|
|
|
buf = dupcat(buf, tmp);
|
2006-03-18 02:23:33 -08:00
|
|
|
}
|
2006-03-18 07:16:24 -08:00
|
|
|
|
|
|
|
#if DEBUG > 0
|
|
|
|
printf("%s", buf);
|
2009-09-20 02:27:00 -07:00
|
|
|
#endif
|
2006-03-18 02:23:33 -08:00
|
|
|
CommsSend(buf);
|
2009-09-20 02:27:00 -07:00
|
|
|
#if 0
|
2006-03-18 02:23:33 -08:00
|
|
|
CommsSend("save_config");
|
2006-03-18 07:16:24 -08:00
|
|
|
#endif
|
|
|
|
free(buf);
|
2000-02-11 15:45:51 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
|
|
|
selection_made(GtkWidget * my_clist __UNUSED__, gint row,
|
|
|
|
gint column __UNUSED__, GdkEventButton * event __UNUSED__,
|
|
|
|
gpointer data __UNUSED__)
|
2000-02-08 14:49:32 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
gchar *modstring;
|
|
|
|
gchar *keyused;
|
|
|
|
gchar *actperform;
|
|
|
|
gchar *paramsused;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dont_update = 1;
|
2006-03-18 07:16:24 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_get_text(GTK_CLIST(clist), row, 0, &modstring);
|
|
|
|
gtk_option_menu_set_history(GTK_OPTION_MENU(act_mod), 0);
|
2006-03-18 13:44:37 -08:00
|
|
|
for (i = 1; i < 21; i++)
|
2006-03-18 02:23:33 -08:00
|
|
|
{
|
2009-09-20 02:27:00 -07:00
|
|
|
if (!strcmp(MOD_TEXT(i), modstring))
|
2006-03-18 02:23:33 -08:00
|
|
|
{
|
|
|
|
gtk_option_menu_set_history(GTK_OPTION_MENU(act_mod), i);
|
|
|
|
}
|
|
|
|
}
|
2006-03-18 07:16:24 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_get_text(GTK_CLIST(clist), row, 1, &keyused);
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(act_key), keyused);
|
2006-03-18 07:16:24 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_get_text(GTK_CLIST(clist), row, 2, &actperform);
|
2006-03-18 07:16:24 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_get_text(GTK_CLIST(clist), row, 3, ¶msused);
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(act_params), paramsused);
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
i = match_action_by_selection(actperform);
|
|
|
|
if (i < 0 || actions[i].param_tpe == 0)
|
|
|
|
{
|
|
|
|
gtk_entry_set_editable(GTK_ENTRY(act_params), FALSE);
|
|
|
|
gtk_widget_set_sensitive(act_params, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_entry_set_editable(GTK_ENTRY(act_params), TRUE);
|
|
|
|
gtk_widget_set_sensitive(act_params, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i >= 0)
|
|
|
|
{
|
2006-12-16 05:49:13 -08:00
|
|
|
i = action_index_to_row[i];
|
2006-03-18 07:16:24 -08:00
|
|
|
gtk_clist_select_row(GTK_CLIST(act_clist), i, 0);
|
|
|
|
gtk_clist_moveto(GTK_CLIST(act_clist), i, 0, 0.5, 0.5);
|
|
|
|
}
|
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
/* printf("%s\n%s\n%s\n%s\n",modstring,keyused,actperform,paramsused); */
|
|
|
|
|
|
|
|
last_row = row;
|
2006-03-18 07:16:24 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
dont_update = 0;
|
2000-02-08 14:49:32 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
static gchar *get_line(gchar * str, int num);
|
2000-02-08 16:02:14 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
static gchar *
|
|
|
|
get_line(gchar * str, int num)
|
2000-02-08 16:02:14 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
gchar *s1, *s2, *s;
|
|
|
|
gint i, count, l;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
count = 0;
|
|
|
|
s1 = str;
|
|
|
|
if (*str == '\n')
|
|
|
|
i = 1;
|
|
|
|
s2 = NULL;
|
|
|
|
for (i = 0;; i++)
|
|
|
|
{
|
|
|
|
if ((str[i] == '\n') || (str[i] == 0))
|
|
|
|
{
|
|
|
|
s2 = &(str[i]);
|
|
|
|
if ((count == num) && (s2 > s1))
|
|
|
|
{
|
|
|
|
l = s2 - s1;
|
|
|
|
s = g_malloc(l + 1);
|
|
|
|
strncpy(s, s1, l);
|
|
|
|
s[l] = 0;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
if (str[i] == 0)
|
|
|
|
return NULL;
|
|
|
|
s1 = s2 + 1;
|
|
|
|
}
|
|
|
|
}
|
2000-02-08 16:02:14 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
2006-03-18 13:44:37 -08:00
|
|
|
on_resort_columns(GtkWidget * widget __UNUSED__, gint column,
|
|
|
|
gpointer data __UNUSED__)
|
2000-02-08 14:49:32 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
static int order = 0;
|
|
|
|
static int last_col = 0;
|
2000-02-08 14:49:32 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_set_sort_column(GTK_CLIST(clist), column);
|
|
|
|
if (last_col == column)
|
|
|
|
{
|
|
|
|
if (order)
|
|
|
|
{
|
|
|
|
order = 0;
|
|
|
|
gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_DESCENDING);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
order = 1;
|
|
|
|
gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_ASCENDING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
order = 1;
|
|
|
|
gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_ASCENDING);
|
|
|
|
last_col = column;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_clist_sort(GTK_CLIST(clist));
|
2000-02-08 14:49:32 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
2006-03-18 13:44:37 -08:00
|
|
|
on_delete_row(GtkWidget * widget __UNUSED__, gpointer data __UNUSED__)
|
2000-02-11 15:45:51 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_remove(GTK_CLIST(clist), last_row);
|
2006-12-16 05:49:13 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
real_rows--;
|
2006-12-16 05:49:13 -08:00
|
|
|
if (last_row >= real_rows)
|
|
|
|
last_row--;
|
|
|
|
gtk_clist_select_row(GTK_CLIST(clist), last_row, 0);
|
|
|
|
gtk_clist_moveto(GTK_CLIST(clist), last_row, 0, 0.5, 0.5);
|
2000-02-11 15:45:51 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
2006-03-18 13:44:37 -08:00
|
|
|
on_create_row(GtkWidget * widget __UNUSED__, gpointer data __UNUSED__)
|
2000-02-11 15:45:51 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
char *stuff[4];
|
2000-02-11 15:45:51 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
stuff[0] = malloc(2);
|
|
|
|
strcpy(stuff[0], "");
|
|
|
|
stuff[1] = malloc(2);
|
|
|
|
strcpy(stuff[1], "");
|
|
|
|
stuff[2] = malloc(2);
|
|
|
|
strcpy(stuff[2], "");
|
|
|
|
stuff[3] = malloc(2);
|
|
|
|
strcpy(stuff[3], "");
|
|
|
|
gtk_clist_select_row(GTK_CLIST(clist),
|
|
|
|
gtk_clist_append(GTK_CLIST(clist), stuff), 0);
|
|
|
|
|
|
|
|
if (stuff[0])
|
|
|
|
free(stuff[0]);
|
|
|
|
if (stuff[1])
|
|
|
|
free(stuff[1]);
|
|
|
|
if (stuff[2])
|
|
|
|
free(stuff[2]);
|
|
|
|
if (stuff[3])
|
|
|
|
free(stuff[3]);
|
|
|
|
|
2006-12-16 05:49:13 -08:00
|
|
|
last_row = real_rows++;
|
|
|
|
gtk_clist_select_row(GTK_CLIST(clist), last_row, 0);
|
|
|
|
gtk_clist_moveto(GTK_CLIST(clist), last_row, 0, 0.5, 0.5);
|
2000-02-11 15:45:51 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
2006-03-18 13:44:37 -08:00
|
|
|
on_change_params(GtkWidget * widget __UNUSED__, gpointer data __UNUSED__)
|
2000-02-11 14:12:40 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
if (!dont_update)
|
|
|
|
{
|
|
|
|
gtk_clist_set_text(GTK_CLIST(clist), last_row, 3,
|
|
|
|
gtk_entry_get_text(GTK_ENTRY(act_params)));
|
|
|
|
}
|
2000-02-11 14:12:40 -08:00
|
|
|
}
|
2000-02-08 14:49:32 -08:00
|
|
|
|
2000-02-08 13:23:22 -08:00
|
|
|
void
|
2006-03-18 13:44:37 -08:00
|
|
|
on_exit_application(GtkWidget * widget __UNUSED__, gpointer data __UNUSED__)
|
2000-02-08 13:23:22 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_exit(0);
|
2000-02-08 13:23:22 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:16:24 -08:00
|
|
|
static void
|
2006-03-18 13:44:37 -08:00
|
|
|
on_save_and_exit_application(GtkWidget * widget, gpointer data)
|
2000-03-03 15:06:35 -08:00
|
|
|
{
|
2006-03-18 13:44:37 -08:00
|
|
|
on_save_data(widget, data);
|
|
|
|
on_exit_application(widget, data);
|
2000-03-03 15:06:35 -08:00
|
|
|
}
|
|
|
|
|
2006-03-18 07:32:19 -08:00
|
|
|
static GtkWidget *
|
2000-02-08 13:23:22 -08:00
|
|
|
create_list_window(void)
|
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
GtkWidget *list_window;
|
|
|
|
GtkWidget *bigvbox;
|
|
|
|
GtkWidget *menubar;
|
|
|
|
GtkWidget *panes;
|
|
|
|
GtkWidget *scrollybit;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *frames;
|
|
|
|
GtkWidget *alignment;
|
|
|
|
GtkWidget *frame_vbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *m, *mi, *om;
|
2006-03-18 02:34:25 -08:00
|
|
|
GtkWidget *menu, *menuitem;
|
2006-03-18 02:23:33 -08:00
|
|
|
|
|
|
|
list_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
2006-03-18 11:13:15 -08:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(list_window), 400, 400);
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_object_set_data(GTK_OBJECT(list_window), "key_editor", list_window);
|
|
|
|
GTK_WIDGET_SET_FLAGS(list_window, GTK_CAN_FOCUS);
|
|
|
|
GTK_WIDGET_SET_FLAGS(list_window, GTK_CAN_DEFAULT);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(list_window), "E Keys Editor");
|
|
|
|
|
|
|
|
bigvbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(bigvbox);
|
|
|
|
gtk_container_add(GTK_CONTAINER(list_window), bigvbox);
|
|
|
|
|
|
|
|
menubar = gtk_menu_bar_new();
|
|
|
|
gtk_widget_show(menubar);
|
|
|
|
gtk_box_pack_start(GTK_BOX(bigvbox), menubar, FALSE, FALSE, 0);
|
|
|
|
|
2006-03-18 02:34:25 -08:00
|
|
|
menu = CreateBarSubMenu(menubar, "File");
|
|
|
|
menuitem = CreateMenuItem(menu, "Save", "", "Save Current Data", NULL,
|
|
|
|
"save data");
|
|
|
|
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
|
|
|
|
GTK_SIGNAL_FUNC(on_save_data), NULL);
|
|
|
|
menuitem = CreateMenuItem(menu, "Save & Quit", "",
|
|
|
|
"Save Current Data & Quit Application", NULL,
|
|
|
|
"save quit");
|
|
|
|
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
|
|
|
|
GTK_SIGNAL_FUNC(on_save_and_exit_application), NULL);
|
|
|
|
menuitem =
|
|
|
|
CreateMenuItem(menu, "Quit", "", "Quit Without Saving", NULL,
|
|
|
|
"quit program");
|
|
|
|
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
|
|
|
|
GTK_SIGNAL_FUNC(on_exit_application), NULL);
|
2006-03-18 02:23:33 -08:00
|
|
|
|
2006-03-18 02:34:25 -08:00
|
|
|
menu = CreateRightAlignBarSubMenu(menubar, "Help");
|
|
|
|
menuitem = CreateMenuItem(menu, "About", "", "About E Keybinding Editor",
|
|
|
|
NULL, "about");
|
|
|
|
menuitem = CreateMenuItem(menu, "Documentation", "",
|
|
|
|
"Read the Keybinding Editor Documentation", NULL,
|
|
|
|
"read docs");
|
2006-03-18 02:23:33 -08:00
|
|
|
|
|
|
|
panes = gtk_hpaned_new();
|
|
|
|
gtk_widget_show(panes);
|
|
|
|
gtk_paned_set_gutter_size(GTK_PANED(panes), 10);
|
|
|
|
gtk_box_pack_start(GTK_BOX(bigvbox), panes, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
scrollybit = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_widget_show(scrollybit);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollybit),
|
|
|
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_paned_pack1(GTK_PANED(panes), scrollybit, TRUE, FALSE);
|
|
|
|
|
|
|
|
clist = gtk_clist_new(4);
|
|
|
|
gtk_widget_show(clist);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrollybit), clist);
|
|
|
|
|
|
|
|
gtk_clist_set_column_title(GTK_CLIST(clist), 0, "Modifier");
|
2006-03-18 11:13:15 -08:00
|
|
|
gtk_clist_set_column_title(GTK_CLIST(clist), 1, "Key");
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_set_column_title(GTK_CLIST(clist), 2, "Action to Perform");
|
2009-05-03 04:41:01 -07:00
|
|
|
gtk_clist_set_column_title(GTK_CLIST(clist), 3, "Command");
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_column_titles_show(GTK_CLIST(clist));
|
|
|
|
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
|
|
|
|
GTK_SIGNAL_FUNC(selection_made), NULL);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(clist), "click_column",
|
|
|
|
GTK_SIGNAL_FUNC(on_resort_columns), NULL);
|
|
|
|
|
|
|
|
{
|
2006-03-18 07:16:24 -08:00
|
|
|
char *msg, *buf;
|
2009-09-20 02:27:00 -07:00
|
|
|
int i, j, k, modifier;
|
|
|
|
char event[128], mod[128], key[128], *params;
|
|
|
|
const char *stuff[4];
|
|
|
|
int len;
|
2006-03-18 02:23:33 -08:00
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
CommsSend("ac kb");
|
2006-03-18 02:23:33 -08:00
|
|
|
msg = wait_for_ipc_msg();
|
|
|
|
i = 0;
|
|
|
|
while ((buf = get_line(msg, i++)))
|
2000-02-08 13:23:22 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
if (strlen(buf) < 1)
|
|
|
|
break;
|
2006-03-18 07:16:24 -08:00
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
j = sscanf(buf, "%127s %127s %127s %n", event, mod, key, &len);
|
2006-03-18 07:16:24 -08:00
|
|
|
#if DEBUG > 0
|
|
|
|
printf("buf(%d): %s\n", j, buf);
|
|
|
|
#endif
|
2009-09-20 02:27:00 -07:00
|
|
|
if (j < 3)
|
2013-03-17 07:05:39 -07:00
|
|
|
goto next;
|
2009-09-20 02:27:00 -07:00
|
|
|
if (strcmp(event, "KeyDown"))
|
2013-03-17 07:05:39 -07:00
|
|
|
goto next;
|
2006-03-18 07:16:24 -08:00
|
|
|
|
|
|
|
params = buf + len;
|
|
|
|
#if DEBUG > 0
|
2009-09-20 02:27:00 -07:00
|
|
|
printf("event: %s, mod: %s, key: %s, params: %s\n",
|
|
|
|
event, mod, key, params);
|
2006-03-18 07:16:24 -08:00
|
|
|
#endif
|
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
modifier = mod_short_to_index(mod);
|
|
|
|
|
|
|
|
k = match_action_by_binding(params);
|
2006-03-18 07:16:24 -08:00
|
|
|
|
|
|
|
#if DEBUG > 1
|
2006-03-18 07:32:19 -08:00
|
|
|
printf("key: %s, mod: %s, act=%d, params: %s\n", key,
|
2009-09-20 02:27:00 -07:00
|
|
|
MOD_TEXT(modifier), k, params);
|
2006-03-18 07:16:24 -08:00
|
|
|
#endif
|
|
|
|
|
2009-09-20 02:27:00 -07:00
|
|
|
stuff[0] = MOD_TEXT(modifier);
|
2006-03-18 07:16:24 -08:00
|
|
|
stuff[1] = key;
|
|
|
|
stuff[2] = (k >= 0) ? actions[k].text : "* Not recognised *";
|
|
|
|
stuff[3] = params;
|
|
|
|
gtk_clist_append(GTK_CLIST(clist), (char **)stuff);
|
|
|
|
real_rows++;
|
|
|
|
|
2013-03-17 07:05:39 -07:00
|
|
|
next:
|
2006-03-18 02:23:33 -08:00
|
|
|
g_free(buf);
|
2000-02-08 13:23:22 -08:00
|
|
|
}
|
2006-03-18 02:23:33 -08:00
|
|
|
g_free(msg);
|
|
|
|
}
|
2006-03-18 11:13:15 -08:00
|
|
|
gtk_clist_columns_autosize(GTK_CLIST(clist));
|
2006-03-18 02:23:33 -08:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
frames = gtk_frame_new("Edit Keybinding Properties");
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(frames), 2);
|
|
|
|
gtk_widget_show(frames);
|
|
|
|
gtk_paned_pack2(GTK_PANED(panes), vbox, FALSE, TRUE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), frames, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
frame_vbox = gtk_vbox_new(FALSE, 3);
|
|
|
|
gtk_widget_show(frame_vbox);
|
|
|
|
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(frame_vbox), 4);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frames), frame_vbox);
|
|
|
|
|
|
|
|
table = gtk_table_new(3, 3, FALSE);
|
|
|
|
gtk_widget_show(table);
|
|
|
|
gtk_table_set_row_spacings(GTK_TABLE(table), 3);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(table), 3);
|
|
|
|
gtk_box_pack_start(GTK_BOX(frame_vbox), table, FALSE, FALSE, 2);
|
|
|
|
|
|
|
|
alignment = gtk_alignment_new(1.0, 0.5, 0, 0);
|
|
|
|
label = gtk_label_new("Key:");
|
|
|
|
gtk_container_add(GTK_CONTAINER(alignment), label);
|
|
|
|
gtk_widget_show(alignment);
|
|
|
|
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), alignment, 0, 1, 0, 1,
|
|
|
|
GTK_FILL, (GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
|
|
|
alignment = gtk_alignment_new(1.0, 0.5, 0, 0);
|
|
|
|
label = gtk_label_new("Modifier:");
|
|
|
|
gtk_container_add(GTK_CONTAINER(alignment), label);
|
|
|
|
gtk_widget_show(alignment);
|
|
|
|
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), alignment, 0, 1, 1, 2,
|
|
|
|
GTK_FILL, (GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
|
|
|
alignment = gtk_alignment_new(1.0, 0.5, 0, 0);
|
2009-05-03 04:41:01 -07:00
|
|
|
label = gtk_label_new("Command:");
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_container_add(GTK_CONTAINER(alignment), label);
|
|
|
|
gtk_widget_show(alignment);
|
|
|
|
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), alignment, 0, 1, 2, 3,
|
|
|
|
GTK_FILL, (GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
|
|
|
act_key = entry = gtk_entry_new_with_max_length(4096);
|
|
|
|
gtk_widget_show(entry);
|
|
|
|
gtk_widget_set_sensitive(entry, FALSE);
|
|
|
|
/* gtk_widget_set_usize(entry, 24, -1); */
|
|
|
|
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1,
|
|
|
|
GTK_EXPAND | GTK_FILL, (GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label("Change");
|
|
|
|
gtk_widget_show(button);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), button, 2, 3, 0, 1,
|
|
|
|
GTK_EXPAND | GTK_FILL, (GtkAttachOptions) (0), 0, 0);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC(e_cb_key_change), NULL);
|
|
|
|
|
|
|
|
m = gtk_menu_new();
|
|
|
|
gtk_widget_show(m);
|
|
|
|
|
|
|
|
mi = gtk_menu_item_new_with_label("NONE");
|
|
|
|
gtk_widget_show(mi);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(mi), "activate",
|
|
|
|
GTK_SIGNAL_FUNC(e_cb_modifier), (gpointer) 0);
|
|
|
|
gtk_menu_append(GTK_MENU(m), mi);
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 1; i < 21; i++)
|
2000-02-08 16:02:14 -08:00
|
|
|
{
|
2009-09-20 02:27:00 -07:00
|
|
|
mi = gtk_menu_item_new_with_label(MOD_TEXT(i));
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_widget_show(mi);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(mi), "activate",
|
2009-05-03 04:41:01 -07:00
|
|
|
GTK_SIGNAL_FUNC(e_cb_modifier),
|
|
|
|
(gpointer) (glong) i);
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_menu_append(GTK_MENU(m), mi);
|
2000-02-11 14:12:40 -08:00
|
|
|
}
|
2006-03-18 02:23:33 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
act_mod = om = gtk_option_menu_new();
|
|
|
|
gtk_widget_show(om);
|
|
|
|
gtk_option_menu_set_menu(GTK_OPTION_MENU(om), m);
|
|
|
|
gtk_option_menu_set_history(GTK_OPTION_MENU(om), 0);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), om, 1, 3, 1, 2,
|
|
|
|
GTK_EXPAND | GTK_FILL, (GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
|
|
|
act_params = entry = gtk_entry_new_with_max_length(4096);
|
|
|
|
gtk_widget_show(entry);
|
|
|
|
gtk_widget_set_sensitive(entry, FALSE);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), entry, 1, 3, 2, 3,
|
|
|
|
GTK_EXPAND | GTK_FILL, (GtkAttachOptions) (0), 0, 0);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(entry), "changed",
|
|
|
|
GTK_SIGNAL_FUNC(on_change_params), NULL);
|
|
|
|
|
|
|
|
scrollybit = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_widget_show(scrollybit);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollybit),
|
|
|
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
|
|
|
|
act_clist = gtk_clist_new(1);
|
|
|
|
gtk_widget_show(act_clist);
|
|
|
|
gtk_box_pack_start(GTK_BOX(frame_vbox), scrollybit, TRUE, TRUE, 0);
|
|
|
|
gtk_clist_set_column_title(GTK_CLIST(act_clist), 0, "Action Used:");
|
|
|
|
gtk_clist_column_titles_show(GTK_CLIST(act_clist));
|
|
|
|
gtk_signal_connect(GTK_OBJECT(act_clist), "select_row",
|
|
|
|
GTK_SIGNAL_FUNC(change_action), NULL);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrollybit), act_clist);
|
|
|
|
|
|
|
|
{
|
2006-03-18 07:16:24 -08:00
|
|
|
const char *stuff[1];
|
2006-12-16 05:49:13 -08:00
|
|
|
int k, row;
|
|
|
|
|
|
|
|
action_index_to_row = calloc(action_count, sizeof(int));
|
|
|
|
action_row_to_index = calloc(action_count, sizeof(int));
|
2006-03-18 02:23:33 -08:00
|
|
|
|
2006-12-16 05:49:13 -08:00
|
|
|
for (k = row = 0; (actions[k].text); k++)
|
2000-02-08 18:00:11 -08:00
|
|
|
{
|
2006-03-18 07:16:24 -08:00
|
|
|
stuff[0] = actions[k].text;
|
|
|
|
gtk_clist_append(GTK_CLIST(act_clist), (char **)stuff);
|
2006-12-16 05:49:13 -08:00
|
|
|
action_index_to_row[k] = row;
|
|
|
|
action_row_to_index[row++] = k;
|
2000-02-08 18:00:11 -08:00
|
|
|
}
|
2006-03-18 02:23:33 -08:00
|
|
|
}
|
2000-02-08 16:52:18 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(hbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
|
2000-02-08 16:52:18 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
button = gtk_button_new_with_label(" New Keybinding ");
|
|
|
|
gtk_widget_show(button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 5);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC(on_create_row), NULL);
|
2000-02-08 16:52:18 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
button = gtk_button_new_with_label(" Delete Current Row ");
|
|
|
|
gtk_widget_show(button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 5);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC(on_delete_row), NULL);
|
2000-02-08 16:52:18 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
button = gtk_button_new_with_label(" Save ");
|
|
|
|
gtk_widget_show(button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 5);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC(on_save_data), NULL);
|
2000-02-08 16:52:18 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
button = gtk_button_new_with_label(" Quit ");
|
|
|
|
gtk_widget_show(button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 5);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC(on_exit_application), NULL);
|
2000-02-08 16:52:18 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_clist_select_row(GTK_CLIST(clist), 0, 0);
|
2000-02-08 16:52:18 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
return list_window;
|
2000-02-08 13:23:22 -08:00
|
|
|
}
|
|
|
|
|
2000-02-08 16:52:18 -08:00
|
|
|
static void
|
|
|
|
receive_ipc_msg(gchar * msg)
|
2000-02-08 15:23:44 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
gdk_flush();
|
|
|
|
e_ipc_msg = g_strdup(msg);
|
2000-02-08 16:02:14 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_main_quit();
|
2000-02-08 15:23:44 -08:00
|
|
|
}
|
|
|
|
|
2009-10-17 10:58:14 -07:00
|
|
|
static void
|
|
|
|
check_e16_version(void)
|
|
|
|
{
|
|
|
|
char *msg;
|
|
|
|
const char *s;
|
|
|
|
int ver, major, minor, micro;
|
|
|
|
|
|
|
|
ver = major = minor = micro = 0;
|
|
|
|
|
|
|
|
CommsSend("ver");
|
|
|
|
msg = wait_for_ipc_msg();
|
|
|
|
if (!msg)
|
2010-02-14 00:52:26 -08:00
|
|
|
goto do_check;
|
2009-10-17 10:58:14 -07:00
|
|
|
|
|
|
|
s = msg;
|
|
|
|
while (*s && *s != '.')
|
|
|
|
s++;
|
|
|
|
s--;
|
|
|
|
sscanf(s, "%d.%d.%d", &major, &minor, µ);
|
|
|
|
ver = VER(major, minor, micro);
|
|
|
|
|
|
|
|
free(msg);
|
|
|
|
|
2010-02-14 00:52:26 -08:00
|
|
|
do_check:
|
2009-10-17 10:58:14 -07:00
|
|
|
if (ver < VER(1, 0, 1))
|
|
|
|
{
|
|
|
|
printf("Sorry, e16 version >= 1.0.1 is required.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-18 11:13:15 -08:00
|
|
|
static void
|
|
|
|
load_actions(void)
|
|
|
|
{
|
|
|
|
char kbdb[1024], buf[1024], text[1024], command[1024];
|
|
|
|
char *s;
|
|
|
|
FILE *f;
|
|
|
|
int n, opt;
|
|
|
|
unsigned int nao;
|
|
|
|
ActionOpt *pao;
|
|
|
|
|
|
|
|
actions = actions_default;
|
|
|
|
|
|
|
|
/* FIXME - Should be fetched via IPC. */
|
|
|
|
|
|
|
|
s = getenv("EROOT");
|
|
|
|
if (!s)
|
2009-05-03 04:41:05 -07:00
|
|
|
s = DATADIR "/e16"; /* Default location */
|
2006-03-18 11:13:15 -08:00
|
|
|
|
|
|
|
snprintf(kbdb, sizeof(kbdb), "%s/config/e16keyedit.db", s);
|
|
|
|
|
|
|
|
f = fopen(kbdb, "r");
|
|
|
|
if (!f)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nao = 0;
|
|
|
|
pao = NULL;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
s = fgets(buf, sizeof(buf), f);
|
|
|
|
if (!s)
|
|
|
|
break;
|
|
|
|
while (isspace(*s))
|
|
|
|
s++;
|
|
|
|
if (*s == '\0' || *s == '#')
|
|
|
|
continue;
|
|
|
|
n = strlen(s);
|
|
|
|
while (n > 0 && (s[n - 1] == '\n' || s[n - 1] == '\r'))
|
|
|
|
n--;
|
|
|
|
if (n <= 0)
|
|
|
|
continue;
|
|
|
|
s[n] = '\0';
|
|
|
|
|
|
|
|
#if DEBUG > 0
|
|
|
|
printf("Got: %s\n", s);
|
|
|
|
#endif
|
|
|
|
text[0] = command[0] = '\0';
|
|
|
|
opt = -1;
|
|
|
|
n = sscanf(s, "\"%1023[^\"]\", %d, \"%1023[^\"]\"", text, &opt,
|
|
|
|
command);
|
|
|
|
if (n < 2)
|
|
|
|
{
|
|
|
|
printf("*** ERROR: %s\n", buf);
|
|
|
|
printf
|
|
|
|
("*** ERROR: Keybindings database (%s) corrupt, using defaults.\n",
|
|
|
|
kbdb);
|
|
|
|
if (pao)
|
|
|
|
free(pao);
|
|
|
|
fclose(f);
|
|
|
|
return;
|
|
|
|
}
|
2009-05-03 04:41:03 -07:00
|
|
|
if (!command[0])
|
|
|
|
continue;
|
2006-03-18 11:13:15 -08:00
|
|
|
#if DEBUG > 0
|
|
|
|
printf("n=%d t=%s o=%d c=%s\n", n, text, opt, command);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pao = realloc(pao, (nao + 1) * sizeof(ActionOpt));
|
|
|
|
memset(pao + nao, 0, sizeof(ActionOpt));
|
|
|
|
pao[nao].text = strdup(text);
|
|
|
|
pao[nao].param_tpe = opt;
|
2009-05-03 04:41:03 -07:00
|
|
|
pao[nao].command = strdup(command);
|
2006-03-18 11:13:15 -08:00
|
|
|
nao++;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
if (nao == 0)
|
|
|
|
return; /* No entries ??? */
|
|
|
|
|
|
|
|
/* Add terminator record */
|
|
|
|
pao = realloc(pao, (nao + 1) * sizeof(ActionOpt));
|
|
|
|
memset(pao + nao, 0, sizeof(ActionOpt));
|
|
|
|
|
|
|
|
actions = pao;
|
2006-12-16 05:49:13 -08:00
|
|
|
action_count = nao;
|
2006-03-18 11:13:15 -08:00
|
|
|
}
|
|
|
|
|
2000-02-08 16:52:18 -08:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
2000-02-07 11:53:40 -08:00
|
|
|
{
|
2006-03-18 02:23:33 -08:00
|
|
|
GtkWidget *lister;
|
2000-02-08 13:23:22 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
gtk_set_locale();
|
|
|
|
gtk_init(&argc, &argv);
|
|
|
|
|
|
|
|
tooltips = gtk_tooltips_new();
|
|
|
|
accel_group = gtk_accel_group_new();
|
|
|
|
|
|
|
|
if (!CommsInit(receive_ipc_msg))
|
|
|
|
{
|
|
|
|
GtkWidget *win, *label, *align, *frame, *button, *vbox;
|
2000-02-07 11:53:40 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
win = gtk_window_new(GTK_WINDOW_POPUP);
|
|
|
|
gtk_window_set_policy(GTK_WINDOW(win), 0, 0, 1);
|
|
|
|
gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
|
|
|
|
frame = gtk_frame_new(NULL);
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
|
|
|
|
align = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(align), 32);
|
|
|
|
vbox = gtk_vbox_new(FALSE, 5);
|
|
|
|
button = gtk_button_new_with_label("Quit");
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC(on_exit_application), NULL);
|
|
|
|
label = gtk_label_new("You are not running Enlightenment\n"
|
|
|
|
"\n"
|
|
|
|
"This window manager has to be running in order\n"
|
|
|
|
"to configure it.\n" "\n");
|
|
|
|
gtk_container_add(GTK_CONTAINER(win), frame);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), align);
|
|
|
|
gtk_container_add(GTK_CONTAINER(align), vbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all(win);
|
|
|
|
gtk_main();
|
|
|
|
exit(1);
|
|
|
|
}
|
2006-03-18 02:34:25 -08:00
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
CommsSend("set clientname Enlightenment Keybinding Configuration Utility");
|
2006-03-18 11:36:31 -08:00
|
|
|
CommsSend("set version " VERSION);
|
2006-03-18 07:16:24 -08:00
|
|
|
#if 0
|
2006-03-18 02:23:33 -08:00
|
|
|
CommsSend("set author Mandrake (Geoff Harrison)");
|
|
|
|
CommsSend("set email mandrake@mandrake.net");
|
|
|
|
CommsSend("set web http://mandrake.net/");
|
|
|
|
CommsSend("set address C/O VA Linux Systems, USA");
|
|
|
|
CommsSend("set info "
|
|
|
|
"This is the Enlightenemnt KeyBindings Configuration Utility\n"
|
|
|
|
"that uses Enlightenment's IPC mechanism to configure\n"
|
|
|
|
"it remotely.");
|
2006-03-18 07:16:24 -08:00
|
|
|
#endif
|
|
|
|
|
2009-10-17 10:58:14 -07:00
|
|
|
check_e16_version();
|
|
|
|
|
2006-03-18 11:13:15 -08:00
|
|
|
load_actions();
|
|
|
|
|
2006-03-18 02:23:33 -08:00
|
|
|
lister = create_list_window();
|
|
|
|
|
|
|
|
gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE);
|
|
|
|
gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 1, TRUE);
|
|
|
|
|
|
|
|
gtk_widget_show(lister);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(lister), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC(on_exit_application), NULL);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(lister), "delete_event",
|
|
|
|
GTK_SIGNAL_FUNC(on_exit_application), NULL);
|
|
|
|
|
|
|
|
gtk_main();
|
|
|
|
|
|
|
|
return 0;
|
2000-02-07 11:53:40 -08:00
|
|
|
}
|