Compare commits
14 Commits
f0d9b21fb8
...
0a74b1b63a
Author | SHA1 | Date |
---|---|---|
Kim Woelders | 0a74b1b63a | |
Kim Woelders | b8f6fce97d | |
Kim Woelders | cbfdd0872b | |
Kim Woelders | 2bddb03c4e | |
Kim Woelders | 0507ae2053 | |
Kim Woelders | bee386768c | |
Kim Woelders | 930a0059fe | |
Kim Woelders | 4e3f9d5955 | |
Kim Woelders | 95ca821c14 | |
Kim Woelders | 57b877a827 | |
Kim Woelders | 6c8d057b8b | |
Kim Woelders | deec303250 | |
Kim Woelders | f613023c74 | |
Kim Woelders | baf0e58791 |
|
@ -1 +1,23 @@
|
|||
-i3 -bl -bad -nbap -sob -ncdb -di20 -nbc -lp -nce -npcs -sc -ncs -l80
|
||||
--k-and-r-style
|
||||
|
||||
--procnames-start-lines
|
||||
--brace-indent0
|
||||
--break-after-boolean-operator
|
||||
|
||||
--no-tabs
|
||||
--indent-level4
|
||||
--braces-after-if-line
|
||||
--blank-lines-after-declarations
|
||||
--no-blank-lines-after-procedures
|
||||
--swallow-optional-blank-lines
|
||||
--no-comment-delimiters-on-blank-lines
|
||||
--declaration-indentation16
|
||||
--no-blank-lines-after-commas
|
||||
--continue-at-parentheses
|
||||
--dont-cuddle-else
|
||||
--no-space-after-function-call-names
|
||||
--start-left-side-of-comments
|
||||
--no-space-after-casts
|
||||
--braces-on-struct-decl-line
|
||||
--line-length80
|
||||
--no-blank-lines-after-declarations
|
||||
|
|
24
Makefile.am
24
Makefile.am
|
@ -6,9 +6,9 @@ MAINTAINERCLEANFILES = aclocal.m4 config.* compile configure depcomp \
|
|||
install-sh missing \
|
||||
Makefile.in
|
||||
|
||||
CLEANFILES = e16-keyedit.desktop
|
||||
CLEANFILES = $(PACKAGE).spec e16-keyedit.desktop
|
||||
|
||||
EXTRA_DIST = e16-keyedit.desktop.in
|
||||
EXTRA_DIST = $(PACKAGE).spec.in e16-keyedit.desktop.in
|
||||
|
||||
bin_PROGRAMS = e16keyedit
|
||||
|
||||
|
@ -25,3 +25,23 @@ e16-keyedit.desktop: $(srcdir)/e16-keyedit.desktop.in Makefile
|
|||
|
||||
e16-keyedit.desktop:
|
||||
sed -e "s=@e16datadir@=${datadir}=" $(srcdir)/$@.in > $@
|
||||
|
||||
dist-hook: $(top_builddir)/$(PACKAGE).spec
|
||||
|
||||
RPR_DEV = `echo -n "1.%(date '+%y%m%d').git"; git rev-parse --short=8 HEAD`
|
||||
RPR_REL = 1
|
||||
SED_DEV = "s/\@PACKAGE\@/@PACKAGE@/;s/\@VERSION\@/@VERSION@/;s/\@RPM_RELEASE\@/$(RPR_DEV)/"
|
||||
SED_REL = "s/\@PACKAGE\@/@PACKAGE@/;s/\@VERSION\@/@VERSION@/;s/\@RPM_RELEASE\@/$(RPR_REL)/"
|
||||
|
||||
$(top_builddir)/$(PACKAGE).spec: FORCE
|
||||
@if [ -f $(top_srcdir)/.git-src -a -z "$(release)" ]; then \
|
||||
sed $(SED_DEV) $(top_srcdir)/$(PACKAGE).spec.in > $@; \
|
||||
else \
|
||||
sed $(SED_REL) $(top_srcdir)/$(PACKAGE).spec.in > $@; \
|
||||
fi
|
||||
|
||||
.PHONY: release
|
||||
release:
|
||||
$(MAKE) dist release=y
|
||||
|
||||
FORCE:
|
||||
|
|
29
configure.ac
29
configure.ac
|
@ -1,16 +1,9 @@
|
|||
m4_define([pkg_version], [0.9])
|
||||
#m4_define([pkg_revision], [000])
|
||||
m4_define([pkg_version], m4_ifdef([pkg_revision], [pkg_version.pkg_revision], [pkg_version]))
|
||||
m4_define([rpm_revision], m4_ifdef([pkg_revision], ["0.%(date '+%y%m%d')"], [1]))
|
||||
|
||||
AC_INIT([e16-keyedit],[pkg_version],[enlightenment-devel@lists.sourceforge.net])
|
||||
AC_INIT([e16-keyedit],[0.9],[enlightenment-devel@lists.sourceforge.net])
|
||||
AM_INIT_AUTOMAKE([foreign dist-xz])
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AC_SUBST(E_RPM_REVISION, [rpm_revision])
|
||||
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
dnl Checks for programs.
|
||||
|
@ -24,20 +17,15 @@ AC_ARG_WITH(gtk,
|
|||
[ --with-gtk Select GTK version to use (auto/gtk2/gtk3) @<:@default=auto@:>@],,
|
||||
with_gtk=auto)
|
||||
|
||||
test_gtk="$with_gtk"
|
||||
if test "x$with_gtk" = "xauto" ; then test_gtk="gtk2"; fi
|
||||
|
||||
if test "x$test_gtk" = "xgtk2" ; then
|
||||
if test "x$with_gtk" = "xauto" -o "x$with_gtk" = "xgtk2"; then
|
||||
AC_MSG_CHECKING([for GTK2]);
|
||||
pkg_modules="gtk+-2.0 >= 2.0.0"
|
||||
PKG_CHECK_MODULES(GTK, [$pkg_modules],,
|
||||
[if test "x$with_gtk" = "xauto" ; then test_gtk="gtk3"; fi])
|
||||
|
||||
PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.0.0], with_gtk="gtk2"
|
||||
AC_DEFINE(USE_GTK, 2, [Using GTK 2]), no="y")
|
||||
fi
|
||||
if test "x$test_gtk" = "xgtk3" ; then
|
||||
if test "x$with_gtk" = "xauto" -o "x$with_gtk" = "xgtk3"; then
|
||||
AC_MSG_CHECKING([for GTK3]);
|
||||
pkg_modules="gtk+-3.0 >= 3.0.0"
|
||||
PKG_CHECK_MODULES(GTK, [$pkg_modules])
|
||||
PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= 3.0.0], with_gtk="gtk3"
|
||||
AC_DEFINE(USE_GTK, 3, [Using GTK 3]), no="y")
|
||||
fi
|
||||
if test "x$GTK_CFLAGS" = "x" ; then
|
||||
AC_MSG_ERROR([GTK 2 or 3 is required.])
|
||||
|
@ -45,10 +33,9 @@ fi
|
|||
|
||||
dnl Checks for header files.
|
||||
AC_PATH_X
|
||||
AC_CHECK_HEADERS(unistd.h)
|
||||
|
||||
EC_C_WARNINGS()
|
||||
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_FILES(Makefile e16-keyedit.spec)
|
||||
AC_CONFIG_FILES(Makefile)
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
Summary: GUI Tool for Editing Enlightenment e16 Keybindings
|
||||
Name: @PACKAGE@
|
||||
Version: @VERSION@
|
||||
Release: @E_RPM_REVISION@%{?_vendorsuffix:.%{_vendorsuffix}}
|
||||
License: BSD-like
|
||||
Release: @RPM_RELEASE@%{?_vendorsuffix:.%{_vendorsuffix}}
|
||||
License: BSD
|
||||
Group: User Interface/Desktops
|
||||
URL: http://www.enlightenment.org/
|
||||
Source: http://prdownloads.sourceforge.net/enlightenment/%{name}-%{version}.tar.gz
|
||||
Vendor: The Enlightenment Project (http://www.enlightenment.org/)
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
||||
Requires: e16 >= 1.0.1
|
||||
Obsoletes: e16keyedit
|
||||
Obsoletes: e16keyedit <= 0.8
|
||||
|
||||
%description
|
||||
e16-keyedit provides a graphical interface for managing keybindings in
|
||||
|
|
46
e16keyedit.h
46
e16keyedit.h
|
@ -1,38 +1,38 @@
|
|||
#ifndef _E16KEYEDIT_H_
|
||||
#define _E16KEYEDIT_H_
|
||||
#ifndef E16KEYEDIT_H
|
||||
#define E16KEYEDIT_H
|
||||
|
||||
#if __GNUC__ /* FIXME - Use autofoo */
|
||||
#if __GNUC__ /* FIXME - Use autofoo */
|
||||
#define __UNUSED__ __attribute__((unused))
|
||||
#else
|
||||
#define __UNUSED__
|
||||
#endif
|
||||
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
#define USE_GTK 3
|
||||
#pragma GCC diagnostic push
|
||||
#if USE_GTK == 2
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
||||
#endif
|
||||
#include <gtk/gtk.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#if USE_GTK == 3
|
||||
#define gtk_hbox_new(homogeneous, spacing) \
|
||||
gtk_box_new(GTK_ORIENTATION_HORIZONTAL, spacing)
|
||||
gtk_box_new(GTK_ORIENTATION_HORIZONTAL, spacing)
|
||||
#define gtk_vbox_new(homogeneous, spacing) \
|
||||
gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing)
|
||||
|
||||
#else
|
||||
#define USE_GTK 2
|
||||
gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing)
|
||||
#endif
|
||||
|
||||
/* ipc.c */
|
||||
extern gint CommsInit(void (*msg_receive_func) (gchar * msg));
|
||||
extern void CommsSend(const gchar * s);
|
||||
extern int CommsInit(void (*msg_receive_func)(char *msg));
|
||||
extern void CommsSend(const char *s);
|
||||
|
||||
/* menus.c */
|
||||
extern GtkWidget *CreateBarSubMenu(GtkWidget * menu, const char *szName);
|
||||
extern GtkWidget *CreateRightAlignBarSubMenu(GtkWidget * menu,
|
||||
const char *szName);
|
||||
extern GtkWidget *CreateMenuItem(GtkWidget * menu, const char *szName,
|
||||
const char *szAccel, const char *szTip,
|
||||
GCallback func, const void *data);
|
||||
extern GtkWidget *CreateBarSubMenu(GtkWidget * menu, const char *szName);
|
||||
extern GtkWidget *CreateRightAlignBarSubMenu(GtkWidget * menu,
|
||||
const char *szName);
|
||||
extern GtkWidget *CreateMenuItem(GtkWidget * menu, GtkAccelGroup * agrp,
|
||||
const char *szName,
|
||||
const char *szAccel, const char *szTip,
|
||||
GCallback func, const void *data);
|
||||
|
||||
/* viewer.c */
|
||||
extern GtkAccelGroup *accel_group;
|
||||
void on_exit_application(void);
|
||||
|
||||
#endif /* _E16KEYEDIT_H_ */
|
||||
#endif /* E16KEYEDIT_H */
|
||||
|
|
589
ipc.c
589
ipc.c
|
@ -1,7 +1,5 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -12,348 +10,279 @@
|
|||
#include "e16keyedit.h"
|
||||
|
||||
#define gdk_window_foreign_new(xwin) \
|
||||
gdk_x11_window_foreign_new_for_display(gdk_display_get_default(), xwin)
|
||||
gdk_x11_window_foreign_new_for_display(gdk_display_get_default(), xwin)
|
||||
|
||||
typedef struct _client
|
||||
{
|
||||
gchar *name;
|
||||
Window win;
|
||||
gchar *msg;
|
||||
gchar *clientname;
|
||||
gchar *version;
|
||||
gchar *author;
|
||||
gchar *email;
|
||||
gchar *web;
|
||||
gchar *address;
|
||||
gchar *info;
|
||||
#if USE_GTK == 3
|
||||
#define gdk_error_trap_push() \
|
||||
gdk_x11_display_error_trap_push(gdk_display_get_default())
|
||||
#define gdk_error_trap_pop() \
|
||||
gdk_x11_display_error_trap_pop(gdk_display_get_default())
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
Window win;
|
||||
char *msg;
|
||||
#if 0
|
||||
char *name;
|
||||
char *clientname;
|
||||
char *version;
|
||||
char *author;
|
||||
char *email;
|
||||
char *web;
|
||||
char *address;
|
||||
char *info;
|
||||
#endif
|
||||
} Client;
|
||||
|
||||
Client *e_client = NULL;
|
||||
static Display *dpy = NULL;
|
||||
static Window root_win = None;
|
||||
static Window comms_win = None;
|
||||
static Window my_msg_win = None;
|
||||
static Client *e_client = NULL;
|
||||
static void (*msg_receive_callback)(char *msg) = NULL;
|
||||
static unsigned int Atom_ENL_MSG;
|
||||
|
||||
static Window root_win = None;
|
||||
static Window comms_win = None;
|
||||
static Window my_win = None;
|
||||
static GdkWindow *gdkwin = NULL;
|
||||
static GdkWindow *gdkwin2 = NULL;
|
||||
static void (*msg_receive_callback) (gchar * msg) = NULL;
|
||||
|
||||
static void CommsSetup(void);
|
||||
static GdkFilterReturn CommsFilter(GdkXEvent * gdk_xevent, GdkEvent * event,
|
||||
gpointer data);
|
||||
static Window CommsFindCommsWindow(void);
|
||||
static gchar *CommsGet(Client ** c, XEvent * ev);
|
||||
static Client *MakeClient(Window win);
|
||||
static void ListFreeClient(void *ptr);
|
||||
static gchar in_init = 0;
|
||||
|
||||
gint
|
||||
CommsInit(void (*msg_receive_func) (gchar * msg))
|
||||
static int
|
||||
CommsSetup(void)
|
||||
{
|
||||
Window win;
|
||||
gchar st[32];
|
||||
Client *cl;
|
||||
char *str;
|
||||
|
||||
CommsSetup();
|
||||
comms_win = win = CommsFindCommsWindow();
|
||||
if (win == None)
|
||||
return 1;
|
||||
dpy = gdk_x11_get_default_xdisplay();
|
||||
|
||||
cl = MakeClient(win);
|
||||
g_snprintf(st, sizeof(st), "%8x", (int)win);
|
||||
cl->name = g_strdup(st);
|
||||
e_client = cl;
|
||||
gdkwin = gdk_window_foreign_new(win);
|
||||
gdk_window_add_filter(gdkwin, CommsFilter, NULL);
|
||||
gdkwin2 = gdk_window_foreign_new(my_win);
|
||||
gdk_window_add_filter(gdkwin2, CommsFilter, NULL);
|
||||
gdk_window_set_events(gdkwin, GDK_STRUCTURE_MASK);
|
||||
msg_receive_callback = msg_receive_func;
|
||||
str = getenv("ENL_WM_ROOT");
|
||||
root_win = (str) ? strtoul(str, NULL, 0) : DefaultRootWindow(dpy);
|
||||
|
||||
return 0;
|
||||
gdk_error_trap_push();
|
||||
my_msg_win = XCreateSimpleWindow(dpy, root_win, -10, -10, 1, 1, 0, 0, 0);
|
||||
XSync(dpy, False);
|
||||
if (gdk_error_trap_pop())
|
||||
return 1;
|
||||
|
||||
Atom_ENL_MSG = XInternAtom(dpy, "ENL_MSG", False);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Window
|
||||
CommsFindCommsWindow(void)
|
||||
{
|
||||
unsigned char *s;
|
||||
Atom Atom_ENL_COMMS, ar;
|
||||
unsigned long num, after;
|
||||
int format;
|
||||
Window win = None;
|
||||
Window rt;
|
||||
int dint;
|
||||
unsigned int duint;
|
||||
|
||||
Atom_ENL_COMMS = XInternAtom(dpy, "ENLIGHTENMENT_COMMS", True);
|
||||
if (Atom_ENL_COMMS == None)
|
||||
return None;
|
||||
|
||||
s = NULL;
|
||||
XGetWindowProperty(dpy, root_win, Atom_ENL_COMMS, 0, 14, False,
|
||||
AnyPropertyType, &ar, &format, &num, &after, &s);
|
||||
if (s)
|
||||
{
|
||||
sscanf((char *)s, "%*s %x", (unsigned int *)&win);
|
||||
XFree(s);
|
||||
}
|
||||
|
||||
if (win == None)
|
||||
return None;
|
||||
|
||||
if (!XGetGeometry(dpy, win, &rt,
|
||||
&dint, &dint, &duint, &duint, &duint, &duint))
|
||||
return None;
|
||||
|
||||
s = NULL;
|
||||
XGetWindowProperty(dpy, win, Atom_ENL_COMMS, 0, 14, False,
|
||||
AnyPropertyType, &ar, &format, &num, &after, &s);
|
||||
if (!s)
|
||||
return None;
|
||||
|
||||
XFree(s);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
static Client *
|
||||
ClientCreate(Window win)
|
||||
{
|
||||
Client *cl;
|
||||
|
||||
cl = calloc(1, sizeof(Client));
|
||||
if (!cl)
|
||||
return cl;
|
||||
|
||||
cl->win = win;
|
||||
|
||||
#if 0
|
||||
char st[32];
|
||||
snprintf(st, sizeof(st), "%8x", (int)win);
|
||||
cl->name = strdup(st);
|
||||
#endif
|
||||
|
||||
return cl;
|
||||
}
|
||||
|
||||
static char *
|
||||
CommsGet(XEvent *ev)
|
||||
{
|
||||
char buf[13], *msg;
|
||||
unsigned int win;
|
||||
Client *cl = e_client;
|
||||
|
||||
if (!cl)
|
||||
return NULL;
|
||||
|
||||
if (!ev)
|
||||
return NULL;
|
||||
if (ev->type != ClientMessage)
|
||||
return NULL;
|
||||
if (ev->xclient.message_type != Atom_ENL_MSG)
|
||||
return NULL;
|
||||
|
||||
/* Message should start with comms_win but we don't check */
|
||||
memcpy(buf, ev->xclient.data.b, 8);
|
||||
buf[8] = 0;
|
||||
sscanf(buf, "%x", &win);
|
||||
|
||||
memcpy(buf, ev->xclient.data.b + 8, 12);
|
||||
buf[12] = 0;
|
||||
|
||||
if (cl->msg)
|
||||
{
|
||||
/* append text to end of msg */
|
||||
cl->msg = realloc(cl->msg, strlen(cl->msg) + strlen(buf) + 1);
|
||||
if (!cl->msg)
|
||||
return NULL;
|
||||
strcat(cl->msg, buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* new msg */
|
||||
cl->msg = malloc(strlen(buf) + 1);
|
||||
if (!cl->msg)
|
||||
return NULL;
|
||||
strcpy(cl->msg, buf);
|
||||
}
|
||||
|
||||
msg = NULL;
|
||||
if (strlen(buf) < 12)
|
||||
{
|
||||
msg = cl->msg;
|
||||
cl->msg = NULL;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
static GdkFilterReturn
|
||||
FilterCommsWin(GdkXEvent *gdk_xevent, GdkEvent *event __UNUSED__,
|
||||
void *data __UNUSED__)
|
||||
{
|
||||
XEvent *xevent = gdk_xevent;
|
||||
|
||||
switch (xevent->type)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return GDK_FILTER_REMOVE;
|
||||
}
|
||||
|
||||
static GdkFilterReturn
|
||||
FilterMyMsgWin(GdkXEvent *gdk_xevent, GdkEvent *event __UNUSED__,
|
||||
void *data __UNUSED__)
|
||||
{
|
||||
XEvent *xevent = gdk_xevent;
|
||||
char *msg;
|
||||
|
||||
switch (xevent->type)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case ClientMessage:
|
||||
if (xevent->xclient.message_type != Atom_ENL_MSG)
|
||||
return GDK_FILTER_CONTINUE;
|
||||
|
||||
msg = CommsGet(xevent);
|
||||
if (msg)
|
||||
{
|
||||
if (msg_receive_callback)
|
||||
(*msg_receive_callback) (msg);
|
||||
free(msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return GDK_FILTER_REMOVE;
|
||||
}
|
||||
|
||||
int
|
||||
CommsInit(void (*msg_receive_func)(char *msg))
|
||||
{
|
||||
GdkWindow *gdkwin;
|
||||
|
||||
if (CommsSetup())
|
||||
return 1;
|
||||
|
||||
comms_win = CommsFindCommsWindow();
|
||||
if (comms_win == None)
|
||||
return 1;
|
||||
|
||||
e_client = ClientCreate(comms_win);
|
||||
|
||||
gdkwin = gdk_window_foreign_new(comms_win);
|
||||
gdk_window_set_events(gdkwin, GDK_STRUCTURE_MASK);
|
||||
gdk_window_add_filter(gdkwin, FilterCommsWin, NULL);
|
||||
|
||||
gdkwin = gdk_window_foreign_new(my_msg_win);
|
||||
gdk_window_add_filter(gdkwin, FilterMyMsgWin, NULL);
|
||||
|
||||
msg_receive_callback = msg_receive_func;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CommsSend(const gchar * s)
|
||||
CommsSend(const char *s)
|
||||
{
|
||||
gchar ss[21];
|
||||
int i, j, k, len;
|
||||
XEvent ev;
|
||||
static Atom a = 0;
|
||||
Client *c;
|
||||
char ss[21];
|
||||
int i, j, k, len;
|
||||
XEvent ev;
|
||||
Client *cl = e_client;
|
||||
|
||||
c = e_client;
|
||||
if ((!s) || (!c))
|
||||
return;
|
||||
len = strlen(s);
|
||||
if (!s || !cl)
|
||||
return;
|
||||
|
||||
if (!a)
|
||||
a = gdk_x11_get_xatom_by_name("ENL_MSG");
|
||||
len = strlen(s);
|
||||
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.serial = 0;
|
||||
ev.xclient.send_event = True;
|
||||
ev.xclient.window = c->win;
|
||||
ev.xclient.message_type = a;
|
||||
ev.xclient.format = 8;
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.serial = 0;
|
||||
ev.xclient.send_event = True;
|
||||
ev.xclient.window = cl->win;
|
||||
ev.xclient.message_type = Atom_ENL_MSG;
|
||||
ev.xclient.format = 8;
|
||||
|
||||
for (i = 0; i < len + 1; i += 12)
|
||||
{
|
||||
g_snprintf(ss, sizeof(ss), "%8x", (int)my_win);
|
||||
for (j = 0; j < 12; j++)
|
||||
{
|
||||
ss[8 + j] = s[i + j];
|
||||
if (!s[i + j])
|
||||
j = 12;
|
||||
}
|
||||
ss[20] = 0;
|
||||
for (k = 0; k < 20; k++)
|
||||
ev.xclient.data.b[k] = ss[k];
|
||||
XSendEvent(gdk_x11_get_default_xdisplay(), c->win, False, 0,
|
||||
(XEvent *) & ev);
|
||||
}
|
||||
XFlush(gdk_x11_get_default_xdisplay());
|
||||
}
|
||||
|
||||
static GdkFilterReturn
|
||||
CommsFilter(GdkXEvent * gdk_xevent, GdkEvent * event __UNUSED__,
|
||||
gpointer data __UNUSED__)
|
||||
{
|
||||
XEvent *xevent;
|
||||
gchar *msg = NULL;
|
||||
Client *c = NULL;
|
||||
static Atom a;
|
||||
|
||||
data = NULL;
|
||||
|
||||
if (!a)
|
||||
a = gdk_x11_get_xatom_by_name("ENL_MSG");
|
||||
|
||||
xevent = (XEvent *) gdk_xevent;
|
||||
switch (xevent->type)
|
||||
{
|
||||
case DestroyNotify:
|
||||
if (xevent->xdestroywindow.window == comms_win)
|
||||
{
|
||||
gint i;
|
||||
|
||||
comms_win = 0;
|
||||
if (!in_init)
|
||||
{
|
||||
for (i = 0; ((i < 20) && (!comms_win)); i++)
|
||||
{
|
||||
if ((comms_win = CommsFindCommsWindow()))
|
||||
{
|
||||
gchar st[256];
|
||||
|
||||
ListFreeClient(e_client);
|
||||
e_client = MakeClient(comms_win);
|
||||
g_snprintf(st, sizeof(st), "%8x", (int)comms_win);
|
||||
e_client->name = g_strdup(st);
|
||||
if (gdkwin)
|
||||
g_object_unref(gdkwin);
|
||||
gdkwin = gdk_window_foreign_new(comms_win);
|
||||
gdk_window_add_filter(gdkwin, CommsFilter, NULL);
|
||||
gdk_window_set_events(gdkwin, GDK_STRUCTURE_MASK);
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
if (!comms_win)
|
||||
{
|
||||
GtkWidget *win, *frame, *vbox, *label, *button;
|
||||
|
||||
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
|
||||
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);
|
||||
vbox = gtk_vbox_new(FALSE, 5);
|
||||
button = gtk_button_new_with_label("Bye bye!");
|
||||
g_signal_connect(G_OBJECT(button), "clicked",
|
||||
on_exit_application, NULL);
|
||||
label =
|
||||
gtk_label_new("EEEEEEEEEEEEEEK! HELP! HEEEEEEEEEELP!\n"
|
||||
"\n" "Enlightenment disappeared on me!\n"
|
||||
"\n"
|
||||
"Someone help me - I'm drowning - drowning\n"
|
||||
"\n"
|
||||
"That's it. I'm out of here. I can't deal with the\n"
|
||||
"idea of losing Enlightenment. I'm going to jump and\n"
|
||||
"don't try and stop me.\n" "\n");
|
||||
gtk_container_add(GTK_CONTAINER(win), frame);
|
||||
gtk_container_add(GTK_CONTAINER(vbox), vbox);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox), 32);
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if USE_GTK == 0 /* Needed? */
|
||||
gdk_window_destroy_notify(((GdkEventAny *) event)->window);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case ClientMessage:
|
||||
if (xevent->xclient.message_type != a)
|
||||
return GDK_FILTER_CONTINUE;
|
||||
msg = CommsGet(&c, xevent);
|
||||
if (msg)
|
||||
{
|
||||
if (msg_receive_callback)
|
||||
(*msg_receive_callback) (msg);
|
||||
g_free(msg);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return GDK_FILTER_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
CommsSetup(void)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = getenv("ENL_WM_ROOT");
|
||||
root_win = (str) ? strtoul(str, NULL, 0) : GDK_ROOT_WINDOW();
|
||||
|
||||
my_win = XCreateSimpleWindow(gdk_x11_get_default_xdisplay(), root_win,
|
||||
-100, -100, 5, 5, 0, 0, 0);
|
||||
}
|
||||
|
||||
static Window
|
||||
CommsFindCommsWindow(void)
|
||||
{
|
||||
unsigned char *s;
|
||||
Atom a, ar;
|
||||
unsigned long num, after;
|
||||
int format;
|
||||
Window win = None;
|
||||
Window rt;
|
||||
int dint;
|
||||
unsigned int duint;
|
||||
|
||||
a = gdk_x11_get_xatom_by_name("ENLIGHTENMENT_COMMS");
|
||||
if (a == None)
|
||||
return None;
|
||||
|
||||
s = NULL;
|
||||
XGetWindowProperty(gdk_x11_get_default_xdisplay(), root_win, a, 0, 14,
|
||||
False, AnyPropertyType, &ar, &format, &num, &after, &s);
|
||||
if (s)
|
||||
{
|
||||
sscanf((char *)s, "%*s %x", (unsigned int *)&win);
|
||||
XFree(s);
|
||||
}
|
||||
|
||||
if (win == None)
|
||||
return None;
|
||||
|
||||
if (!XGetGeometry
|
||||
(gdk_x11_get_default_xdisplay(), win, &rt, &dint, &dint,
|
||||
&duint, &duint, &duint, &duint))
|
||||
return None;
|
||||
|
||||
s = NULL;
|
||||
XGetWindowProperty(gdk_x11_get_default_xdisplay(), win, a, 0,
|
||||
14, False, AnyPropertyType, &ar, &format,
|
||||
&num, &after, &s);
|
||||
if (!s)
|
||||
return None;
|
||||
|
||||
XFree(s);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
CommsGet(Client ** c, XEvent * ev)
|
||||
{
|
||||
gchar s[13], s2[9], *msg;
|
||||
int i;
|
||||
Window win;
|
||||
Client *cl;
|
||||
static Atom a;
|
||||
|
||||
if (!a)
|
||||
a = gdk_x11_get_xatom_by_name("ENL_MSG");
|
||||
|
||||
if ((!ev) || (!c))
|
||||
return (NULL);
|
||||
if (ev->type != ClientMessage)
|
||||
return (NULL);
|
||||
if (ev->xclient.message_type != a)
|
||||
return (NULL);
|
||||
s[12] = 0;
|
||||
s2[8] = 0;
|
||||
msg = NULL;
|
||||
for (i = 0; i < 8; i++)
|
||||
s2[i] = ev->xclient.data.b[i];
|
||||
for (i = 0; i < 12; i++)
|
||||
s[i] = ev->xclient.data.b[i + 8];
|
||||
sscanf(s2, "%x", (int *)&win);
|
||||
cl = e_client;
|
||||
if (!cl)
|
||||
return (NULL);
|
||||
if (cl->msg)
|
||||
{
|
||||
/* append text to end of msg */
|
||||
cl->msg = g_realloc(cl->msg, strlen(cl->msg) + strlen(s) + 1);
|
||||
if (!cl->msg)
|
||||
return (NULL);
|
||||
strcat(cl->msg, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* new msg */
|
||||
cl->msg = g_malloc(strlen(s) + 1);
|
||||
if (!cl->msg)
|
||||
return (NULL);
|
||||
strcpy(cl->msg, s);
|
||||
}
|
||||
if (strlen(s) < 12)
|
||||
{
|
||||
msg = cl->msg;
|
||||
cl->msg = NULL;
|
||||
*c = cl;
|
||||
}
|
||||
return (msg);
|
||||
}
|
||||
|
||||
static Client *
|
||||
MakeClient(Window win)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
c = g_malloc0(sizeof(Client));
|
||||
if (c)
|
||||
c->win = win;
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
ListFreeClient(void *ptr)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
c = (Client *) ptr;
|
||||
if (!c)
|
||||
return;
|
||||
g_free(c->name);
|
||||
g_free(c->msg);
|
||||
g_free(c->clientname);
|
||||
g_free(c->version);
|
||||
g_free(c->author);
|
||||
g_free(c->email);
|
||||
g_free(c->web);
|
||||
g_free(c->address);
|
||||
g_free(c->info);
|
||||
g_free(c);
|
||||
for (i = 0; i < len + 1; i += 12)
|
||||
{
|
||||
snprintf(ss, sizeof(ss), "%8x", (int)my_msg_win);
|
||||
for (j = 0; j < 12; j++)
|
||||
{
|
||||
ss[8 + j] = s[i + j];
|
||||
if (!s[i + j])
|
||||
j = 12;
|
||||
}
|
||||
ss[20] = 0;
|
||||
for (k = 0; k < 20; k++)
|
||||
ev.xclient.data.b[k] = ss[k];
|
||||
XSendEvent(dpy, cl->win, False, 0, &ev);
|
||||
}
|
||||
XFlush(dpy);
|
||||
}
|
||||
|
|
98
menus.c
98
menus.c
|
@ -5,74 +5,72 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "e16keyedit.h"
|
||||
|
||||
GtkWidget *
|
||||
CreateBarSubMenu(GtkWidget * menu, const char *szName)
|
||||
GtkWidget *
|
||||
CreateBarSubMenu(GtkWidget *menu, const char *szName)
|
||||
{
|
||||
GtkWidget *menuitem;
|
||||
GtkWidget *submenu;
|
||||
GtkWidget *menuitem;
|
||||
GtkWidget *submenu;
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label(szName);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
gtk_widget_show(menuitem);
|
||||
submenu = gtk_menu_new();
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
|
||||
menuitem = gtk_menu_item_new_with_label(szName);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
gtk_widget_show(menuitem);
|
||||
submenu = gtk_menu_new();
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
|
||||
|
||||
return submenu;
|
||||
return submenu;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
CreateRightAlignBarSubMenu(GtkWidget * menu, const char *szName)
|
||||
GtkWidget *
|
||||
CreateRightAlignBarSubMenu(GtkWidget *menu, const char *szName)
|
||||
{
|
||||
GtkWidget *menuitem;
|
||||
GtkWidget *submenu;
|
||||
GtkWidget *menuitem;
|
||||
GtkWidget *submenu;
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label(szName);
|
||||
menuitem = gtk_menu_item_new_with_label(szName);
|
||||
#if USE_GTK == 2
|
||||
gtk_menu_item_right_justify(GTK_MENU_ITEM(menuitem));
|
||||
gtk_menu_item_right_justify(GTK_MENU_ITEM(menuitem));
|
||||
#endif
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
gtk_widget_show(menuitem);
|
||||
submenu = gtk_menu_new();
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
gtk_widget_show(menuitem);
|
||||
submenu = gtk_menu_new();
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
|
||||
|
||||
return submenu;
|
||||
return submenu;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
CreateMenuItem(GtkWidget * menu, const char *szName, const char *szAccel,
|
||||
const char *szTip, GCallback func, const void *data)
|
||||
GtkWidget *
|
||||
CreateMenuItem(GtkWidget *menu, GtkAccelGroup *agrp,
|
||||
const char *szName, const char *szAccel, const char *szTip,
|
||||
GCallback func, const void *data)
|
||||
{
|
||||
GtkWidget *menuitem;
|
||||
GtkWidget *menuitem;
|
||||
|
||||
if (szName && strlen(szName))
|
||||
{
|
||||
menuitem = gtk_menu_item_new_with_label(szName);
|
||||
if (func)
|
||||
g_signal_connect(G_OBJECT(menuitem), "activate", func,
|
||||
(gpointer) data);
|
||||
}
|
||||
else
|
||||
{
|
||||
menuitem = gtk_menu_item_new();
|
||||
}
|
||||
if (szName && strlen(szName))
|
||||
{
|
||||
menuitem = gtk_menu_item_new_with_label(szName);
|
||||
if (func)
|
||||
g_signal_connect(G_OBJECT(menuitem), "activate", func,
|
||||
(void *)data);
|
||||
}
|
||||
else
|
||||
{
|
||||
menuitem = gtk_menu_item_new();
|
||||
}
|
||||
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
gtk_widget_show(menuitem);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
gtk_widget_show(menuitem);
|
||||
|
||||
if (szAccel && szAccel[0] == '^')
|
||||
{
|
||||
gtk_widget_add_accelerator(menuitem, "activate", accel_group,
|
||||
szAccel[1], GDK_CONTROL_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
}
|
||||
if (szAccel && szAccel[0] == '^')
|
||||
{
|
||||
gtk_widget_add_accelerator(menuitem, "activate", agrp,
|
||||
szAccel[1], GDK_CONTROL_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
}
|
||||
|
||||
if (szTip && *szTip)
|
||||
gtk_widget_set_tooltip_text(menuitem, szTip);
|
||||
if (szTip && *szTip)
|
||||
gtk_widget_set_tooltip_text(menuitem, szTip);
|
||||
|
||||
return menuitem;
|
||||
return menuitem;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue