Compare commits
23 Commits
khorben/gt
...
master
Author | SHA1 | Date | |
---|---|---|---|
e7f13cc3ca | |||
ba8e67add5 | |||
91503c14cd | |||
984634cf87 | |||
b76674e414 | |||
8b8769970c | |||
269cd67a57 | |||
e637b8c995 | |||
e5b205bc11 | |||
e29a6a18d9 | |||
57226cb4b2 | |||
aac2af926c | |||
63084f226c | |||
7fd37d6f92 | |||
06cc9c9ec5 | |||
7a28896e5b | |||
5701c605f5 | |||
618dab4472 | |||
0055fda87f | |||
14b8ac2fb2 | |||
592aa42055 | |||
6fee9d8017 | |||
48cd0b8aa8 |
27
.github/workflows/deforaos-c-ci_ubuntu-latest.yml
vendored
Normal file
27
.github/workflows/deforaos-c-ci_ubuntu-latest.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
name: DeforaOS C CI (ubuntu-latest)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: bootstrap libSystem
|
||||
run: git clone https://github.com/DeforaOS/libSystem.git libSystem && for dir in include data src; do (cd libSystem/$dir && make PREFIX="$HOME/opt/DeforaOS" CCSHARED="cc -shared" install); done
|
||||
- name: bootstrap configure
|
||||
run: git clone https://github.com/DeforaOS/configure.git configure && (cd configure/src && PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make PREFIX="$HOME/opt/DeforaOS" CCSHARED="cc -shared" install)
|
||||
- name: configure
|
||||
run: $HOME/opt/DeforaOS/bin/configure -p "$HOME/opt/DeforaOS"
|
||||
- name: make
|
||||
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared"
|
||||
- name: make tests
|
||||
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared" tests
|
||||
- name: make distcheck
|
||||
run: PKG_CONFIG_PATH="$HOME/opt/DeforaOS/lib/pkgconfig" make CCSHARED="cc -shared" distcheck
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2011-2020 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2011-2022 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
|
@ -31,7 +31,7 @@ DEVNULL="/dev/null"
|
|||
PROGNAME="pkgconfig.sh"
|
||||
#executables
|
||||
DEBUG="_debug"
|
||||
INSTALL="install -m 0644"
|
||||
INSTALL="install"
|
||||
MKDIR="mkdir -m 0755 -p"
|
||||
RM="rm -f"
|
||||
SED="sed"
|
||||
|
@ -40,6 +40,101 @@ SED="sed"
|
|||
|
||||
|
||||
#functions
|
||||
#pkgconfig
|
||||
_pkgconfig()
|
||||
{
|
||||
#check the variables
|
||||
if [ -z "$PACKAGE" ]; then
|
||||
_error "The PACKAGE variable needs to be set"
|
||||
return $?
|
||||
fi
|
||||
if [ -z "$VERSION" ]; then
|
||||
_error "The VERSION variable needs to be set"
|
||||
return $?
|
||||
fi
|
||||
[ -z "$BINDIR" ] && BINDIR="$PREFIX/bin"
|
||||
[ -z "$DATADIR" ] && DATADIR="$PREFIX/share"
|
||||
[ -z "$INCLUDEDIR" ] && INCLUDEDIR="$PREFIX/include"
|
||||
[ -z "$LIBDIR" ] && LIBDIR="$PREFIX/lib"
|
||||
[ -z "$LIBEXECDIR" ] && LIBEXECDIR="$PREFIX/libexec"
|
||||
[ -z "$MANDIR" ] && MANDIR="$DATADIR/man"
|
||||
[ -z "$SBINDIR" ] && SBINDIR="$PREFIX/sbin"
|
||||
if [ -z "$SYSCONFDIR" ]; then
|
||||
SYSCONFDIR="$PREFIX/etc"
|
||||
[ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc"
|
||||
fi
|
||||
PKGCONFIG="$PREFIX/lib/pkgconfig"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
shift
|
||||
|
||||
#clean
|
||||
[ "$clean" -ne 0 ] && continue
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
$DEBUG $RM -- "$PKGCONFIG/$target" || return 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
source="${target#$OBJDIR}"
|
||||
$DEBUG $MKDIR -- "$PKGCONFIG" || return 2
|
||||
mode="-m 0644"
|
||||
basename="$source"
|
||||
if [ "${source##*/}" != "$source" ]; then
|
||||
basename="${source##*/}"
|
||||
fi
|
||||
$DEBUG $INSTALL $mode "$target" "$PKGCONFIG/$basename" \
|
||||
|| return 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#portability
|
||||
RPATH=
|
||||
if [ "$PREFIX" != "/usr" ]; then
|
||||
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
|
||||
case $(uname -s) in
|
||||
"Darwin")
|
||||
RPATH="-Wl,-rpath,\${libdir}"
|
||||
;;
|
||||
"SunOS")
|
||||
RPATH="-Wl,-R\${libdir}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#create
|
||||
source="${target#$OBJDIR}"
|
||||
source="${source}.in"
|
||||
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") \
|
||||
|| return 2
|
||||
$DEBUG $SED -e "s;@VENDOR@;$VENDOR;g" \
|
||||
-e "s;@PACKAGE@;$PACKAGE;g" \
|
||||
-e "s;@VERSION@;$VERSION;g" \
|
||||
-e "s;@PREFIX@;$PREFIX;g" \
|
||||
-e "s;@BINDIR@;$BINDIR;g" \
|
||||
-e "s;@DATADIR@;$DATADIR;g" \
|
||||
-e "s;@INCLUDEDIR@;$INCLUDEDIR;g" \
|
||||
-e "s;@LIBDIR@;$LIBDIR;g" \
|
||||
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
|
||||
-e "s;@MANDIR@;$MANDIR;g" \
|
||||
-e "s;@PWD@;$PWD;g" \
|
||||
-e "s;@RPATH@;$RPATH;g" \
|
||||
-e "s;@SBINDIR@;$SBINDIR;g" \
|
||||
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
|
||||
-- "$source" > "$target"
|
||||
if [ $? -ne 0 ]; then
|
||||
$RM -- "$target" 2> "$DEVNULL"
|
||||
return 2
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
|
@ -94,91 +189,10 @@ while getopts "ciuO:P:" name; do
|
|||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
if [ $# -lt 0 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#check the variables
|
||||
if [ -z "$PACKAGE" ]; then
|
||||
_error "The PACKAGE variable needs to be set"
|
||||
exit $?
|
||||
fi
|
||||
if [ -z "$VERSION" ]; then
|
||||
_error "The VERSION variable needs to be set"
|
||||
exit $?
|
||||
fi
|
||||
[ -z "$BINDIR" ] && BINDIR="$PREFIX/bin"
|
||||
[ -z "$DATADIR" ] && DATADIR="$PREFIX/share"
|
||||
[ -z "$INCLUDEDIR" ] && INCLUDEDIR="$PREFIX/include"
|
||||
[ -z "$LIBDIR" ] && LIBDIR="$PREFIX/lib"
|
||||
[ -z "$LIBEXECDIR" ] && LIBEXECDIR="$PREFIX/libexec"
|
||||
[ -z "$MANDIR" ] && MANDIR="$DATADIR/man"
|
||||
if [ -z "$SYSCONFDIR" ]; then
|
||||
SYSCONFDIR="$PREFIX/etc"
|
||||
[ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc"
|
||||
fi
|
||||
|
||||
PKGCONFIG="$PREFIX/lib/pkgconfig"
|
||||
exec 3>&1
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
shift
|
||||
|
||||
#clean
|
||||
[ "$clean" -ne 0 ] && continue
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
$DEBUG $RM -- "$PKGCONFIG/$target" || exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
source="${target#$OBJDIR}"
|
||||
$DEBUG $MKDIR -- "$PKGCONFIG" || exit 2
|
||||
basename="$source"
|
||||
if [ "${source##*/}" != "$source" ]; then
|
||||
basename="${source##*/}"
|
||||
fi
|
||||
$DEBUG $INSTALL "$target" "$PKGCONFIG/$basename"|| exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#portability
|
||||
RPATH=
|
||||
if [ "$PREFIX" != "/usr" ]; then
|
||||
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
|
||||
case $(uname -s) in
|
||||
"Darwin")
|
||||
RPATH="-Wl,-rpath,\${libdir}"
|
||||
;;
|
||||
"SunOS")
|
||||
RPATH="-Wl,-R\${libdir}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#create
|
||||
source="${target#$OBJDIR}"
|
||||
source="${source}.in"
|
||||
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") || exit 2
|
||||
$DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;g" \
|
||||
-e "s;@VERSION@;$VERSION;g" \
|
||||
-e "s;@PREFIX@;$PREFIX;g" \
|
||||
-e "s;@BINDIR@;$BINDIR;g" \
|
||||
-e "s;@DATADIR@;$DATADIR;g" \
|
||||
-e "s;@INCLUDEDIR@;$INCLUDEDIR;g" \
|
||||
-e "s;@LIBDIR@;$LIBDIR;g" \
|
||||
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
|
||||
-e "s;@MANDIR@;$MANDIR;g" \
|
||||
-e "s;@PWD@;$PWD;g" \
|
||||
-e "s;@RPATH@;$RPATH;g" \
|
||||
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
|
||||
-- "$source" > "$target"
|
||||
if [ $? -ne 0 ]; then
|
||||
$DEBUG $RM -- "$target"
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
_pkgconfig "$@"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2012-2021 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2012-2024 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
|
@ -28,14 +28,17 @@
|
|||
CONFIGSH="${0%/docbook.sh}/../config.sh"
|
||||
PREFIX="/usr/local"
|
||||
PROGNAME="docbook.sh"
|
||||
XSL_HTML="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
|
||||
XSL_MAN="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
|
||||
XSL_PDF="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"
|
||||
#executables
|
||||
DEBUG="_debug"
|
||||
FOP="fop"
|
||||
INSTALL="install -m 0644"
|
||||
MKDIR="mkdir -m 0755 -p"
|
||||
RM="rm -f"
|
||||
XMLLINT="xmllint --nonet --xinclude"
|
||||
XSLTPROC="xsltproc --nonet --xinclude"
|
||||
XMLLINT="xmllint --noent --nonet --xinclude --path ${PWD}"
|
||||
XSLTPROC="xsltproc --nonet --xinclude --path ${PWD}"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
|
||||
|
@ -60,18 +63,20 @@ _docbook()
|
|||
ext="${ext##.}"
|
||||
case "$ext" in
|
||||
html)
|
||||
XSL="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
|
||||
XSL="$XSL_HTML"
|
||||
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
|
||||
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
|
||||
if [ -f "${target%.*}.css.xml" ]; then
|
||||
XSLTPROC="$XSLTPROC --param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1"
|
||||
XSLTPROC_PARAMS="--param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1"
|
||||
elif [ -f "${source%.*}.css.xml" ]; then
|
||||
XSLTPROC="$XSLTPROC --param custom.css.source \"${source%.*}.css.xml\" --param generate.css.header 1"
|
||||
XSLTPROC_PARAMS="--param custom.css.source \"${source%.*}.css.xml\" --param generate.css.header 1"
|
||||
else
|
||||
XSLTPROC_PARAMS=
|
||||
fi
|
||||
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
|
||||
$DEBUG $XSLTPROC $XSLTPROC_PARAMS -o "$target" "$XSL" "$source"
|
||||
;;
|
||||
pdf)
|
||||
XSL="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"
|
||||
XSL="$XSL_PDF"
|
||||
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
|
||||
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
|
||||
$DEBUG $XSLTPROC -o "${target%.*}.fo" "$XSL" "$source" &&
|
||||
|
@ -79,7 +84,7 @@ _docbook()
|
|||
$RM -- "${target%.*}.fo"
|
||||
;;
|
||||
1|2|3|4|5|6|7|8|9)
|
||||
XSL="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
|
||||
XSL="$XSL_MAN"
|
||||
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
|
||||
;;
|
||||
*)
|
||||
|
@ -170,7 +175,7 @@ while [ $# -gt 0 ]; do
|
|||
source="${target#$OBJDIR}"
|
||||
source="${source%.*}.xml"
|
||||
xpath="string(/refentry/refmeta/manvolnum)"
|
||||
section=$($XMLLINT --xpath "$xpath" "$source")
|
||||
section=$($DEBUG $XMLLINT --xpath "$xpath" "$source")
|
||||
if [ $? -eq 0 -a -n "$section" ]; then
|
||||
instdir="$MANDIR/html$section"
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vendor=Desktop
|
||||
package=libDesktop
|
||||
version=0.4.0
|
||||
version=0.4.2
|
||||
config=ent,h,sh
|
||||
|
||||
subdirs=data,doc,include,src,tests,tools
|
||||
|
|
11
src/compat.c
11
src/compat.c
|
@ -1,5 +1,5 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2012-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2012-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop libDesktop */
|
||||
/* All rights reserved.
|
||||
*
|
||||
|
@ -28,7 +28,10 @@
|
|||
|
||||
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdk.h>
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
# include <gdk/gdkx.h>
|
||||
#endif
|
||||
#include "Desktop.h"
|
||||
|
||||
|
||||
|
@ -38,6 +41,7 @@
|
|||
/* gdk_window_clear */
|
||||
void gdk_window_clear(GdkWindow * window)
|
||||
{
|
||||
# if defined(GDK_WINDOWING_X11)
|
||||
Display * display;
|
||||
Window wid;
|
||||
|
||||
|
@ -46,6 +50,9 @@ void gdk_window_clear(GdkWindow * window)
|
|||
gdk_error_trap_push();
|
||||
XClearWindow(display, wid);
|
||||
gdk_error_trap_pop();
|
||||
# else
|
||||
(void) window;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
217
src/message.c
217
src/message.c
|
@ -1,5 +1,5 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop libDesktop */
|
||||
/* All rights reserved.
|
||||
*
|
||||
|
@ -37,10 +37,16 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <gtk/gtk.h>
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
# include <gtk/gtkx.h>
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||
# include <gtk/gtkx.h>
|
||||
# else
|
||||
# include <gdk/gdkx.h>
|
||||
# endif
|
||||
#else
|
||||
# include <gdk/gdkx.h>
|
||||
# include <sys/socket.h>
|
||||
# include <sys/un.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <System.h>
|
||||
#include "Desktop.h"
|
||||
|
@ -52,11 +58,17 @@
|
|||
typedef struct _MessageCallback
|
||||
{
|
||||
GtkWidget * window;
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||
Atom atom;
|
||||
#else
|
||||
# else
|
||||
GtkWidget * widget;
|
||||
Window xwindow;
|
||||
# endif
|
||||
#else
|
||||
int socket;
|
||||
GIOChannel * channel;
|
||||
guint id;
|
||||
#endif
|
||||
DesktopMessageCallback callback;
|
||||
void * data;
|
||||
|
@ -70,8 +82,13 @@ static size_t _callbacks_cnt = 0;
|
|||
|
||||
/* prototypes */
|
||||
/* callbacks */
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
static GdkFilterReturn _desktop_message_on_callback(GdkXEvent * xevent,
|
||||
GdkEvent * event, gpointer data);
|
||||
#else
|
||||
static gboolean _desktop_message_on_connect(GIOChannel * channel,
|
||||
GIOCondition condition, gpointer data);
|
||||
#endif
|
||||
|
||||
|
||||
/* public */
|
||||
|
@ -82,9 +99,13 @@ int desktop_message_register(GtkWidget * window, char const * destination,
|
|||
{
|
||||
MessageCallback ** p;
|
||||
MessageCallback * mc;
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
GdkWindow * gwindow;
|
||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||
# if !GTK_CHECK_VERSION(3, 0, 0)
|
||||
GdkAtom atom;
|
||||
# endif
|
||||
#else
|
||||
(void) window;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -99,12 +120,13 @@ int desktop_message_register(GtkWidget * window, char const * destination,
|
|||
_callbacks[_callbacks_cnt++] = mc;
|
||||
mc->callback = callback;
|
||||
mc->data = data;
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||
mc->atom = XInternAtom(gdk_x11_get_default_xdisplay(), destination,
|
||||
FALSE);
|
||||
gwindow = (window != NULL) ? gtk_widget_get_window(window) : NULL;
|
||||
gdk_window_add_filter(gwindow, _desktop_message_on_callback, mc);
|
||||
#else
|
||||
# else
|
||||
if((mc->window = window) == NULL)
|
||||
{
|
||||
mc->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
|
@ -116,6 +138,50 @@ int desktop_message_register(GtkWidget * window, char const * destination,
|
|||
mc->xwindow = GDK_WINDOW_XWINDOW(gwindow);
|
||||
atom = gdk_atom_intern(destination, FALSE);
|
||||
gdk_add_client_message_filter(atom, _desktop_message_on_callback, mc);
|
||||
# endif
|
||||
#else
|
||||
GdkDisplay * display;
|
||||
struct sockaddr_un addr;
|
||||
|
||||
display = gdk_display_get_default();
|
||||
if((p = realloc(_callbacks, sizeof(*p) * (_callbacks_cnt + 1))) == NULL)
|
||||
return -error_set_code(1, "%s", strerror(errno));
|
||||
_callbacks = p;
|
||||
if((mc = object_new(sizeof(*mc))) == NULL)
|
||||
return -1;
|
||||
_callbacks[_callbacks_cnt] = mc;
|
||||
mc->callback = callback;
|
||||
mc->data = data;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s-%s",
|
||||
g_get_tmp_dir(), gdk_display_get_name(display),
|
||||
destination);
|
||||
addr.sun_len = sizeof(addr) - sizeof(addr.sun_path)
|
||||
+ strlen(addr.sun_path) + 1;
|
||||
if((mc->socket = socket(addr.sun_family, SOCK_STREAM, 0)) < 0)
|
||||
return -error_set_code(1, "%s: %s", "socket", strerror(errno));
|
||||
if(bind(mc->socket, (struct sockaddr *)&addr, sizeof(addr)) != 0)
|
||||
{
|
||||
error_set_code(1, "%s: %s: %s", "bind", addr.sun_path,
|
||||
strerror(errno));
|
||||
close(mc->socket);
|
||||
unlink(addr.sun_path);
|
||||
return -1;
|
||||
}
|
||||
if(listen(mc->socket, 5) != 0)
|
||||
{
|
||||
error_set_code(1, "%s: %s: %s", "listen", addr.sun_path,
|
||||
strerror(errno));
|
||||
close(mc->socket);
|
||||
unlink(addr.sun_path);
|
||||
return -1;
|
||||
}
|
||||
mc->channel = g_io_channel_unix_new(mc->socket);
|
||||
g_io_channel_set_encoding(mc->channel, NULL, NULL);
|
||||
mc->id = g_io_add_watch(mc->channel, G_IO_IN,
|
||||
_desktop_message_on_connect, NULL);
|
||||
_callbacks_cnt++;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -125,12 +191,17 @@ int desktop_message_register(GtkWidget * window, char const * destination,
|
|||
int desktop_message_send(char const * destination, uint32_t value1,
|
||||
uint32_t value2, uint32_t value3)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||
GdkDisplay * display;
|
||||
Display * xdisplay;
|
||||
XEvent xev;
|
||||
XClientMessageEvent * xcme = &xev.xclient;
|
||||
|
||||
# ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%s, 0x%x, 0x%x, 0x%x)\n", __func__,
|
||||
destination, value1, value2, value3);
|
||||
# endif
|
||||
display = gdk_display_get_default();
|
||||
xdisplay = gdk_x11_display_get_xdisplay(display);
|
||||
memset(&xev, 0, sizeof(xev));
|
||||
|
@ -148,11 +219,15 @@ int desktop_message_send(char const * destination, uint32_t value1,
|
|||
SubstructureNotifyMask | SubstructureRedirectMask,
|
||||
&xev);
|
||||
return (gdk_x11_display_error_trap_pop(display) == 0) ? 0 : -1;
|
||||
#else
|
||||
# else
|
||||
GdkAtom atom;
|
||||
GdkEvent event;
|
||||
GdkEventClient * client = &event.client;
|
||||
|
||||
# ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%s, 0x%x, 0x%x, 0x%x)\n", __func__,
|
||||
destination, value1, value2, value3);
|
||||
# endif
|
||||
atom = gdk_atom_intern(destination, FALSE);
|
||||
memset(&event, 0, sizeof(event));
|
||||
client->type = GDK_CLIENT_EVENT;
|
||||
|
@ -165,6 +240,42 @@ int desktop_message_send(char const * destination, uint32_t value1,
|
|||
client->data.l[2] = value3;
|
||||
gdk_event_send_clientmessage_toall(&event);
|
||||
return 0;
|
||||
# endif
|
||||
#else
|
||||
GdkDisplay * display;
|
||||
int fd;
|
||||
struct sockaddr_un addr;
|
||||
char buf[33];
|
||||
|
||||
# ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%s, 0x%x, 0x%x, 0x%x)\n", __func__,
|
||||
destination, value1, value2, value3);
|
||||
# endif
|
||||
display = gdk_display_get_default();
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s-%s",
|
||||
g_get_tmp_dir(), gdk_display_get_name(display),
|
||||
destination);
|
||||
addr.sun_len = sizeof(addr) - sizeof(addr.sun_path)
|
||||
+ strlen(addr.sun_path) + 1;
|
||||
if((fd = socket(addr.sun_family, SOCK_STREAM, 0)) < 0)
|
||||
return -error_set_code(1, "%s: %s", "socket", strerror(errno));
|
||||
if(connect(fd, (struct sockaddr *)&addr, sizeof(addr)) != 0)
|
||||
{
|
||||
close(fd);
|
||||
return -error_set_code(1, "%s: %s: %s", "connect",
|
||||
addr.sun_path, strerror(errno));
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "0x%x:0x%x:0x%x", value1, value2, value3);
|
||||
if(send(fd, buf, strlen(buf), 0) != (ssize_t)strlen(buf))
|
||||
{
|
||||
close(fd);
|
||||
return -error_set_code(1, "%s: %s: %s", "send", addr.sun_path,
|
||||
strerror(errno));
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -176,11 +287,13 @@ void desktop_message_unregister(GtkWidget * window,
|
|||
size_t i;
|
||||
MessageCallback ** p;
|
||||
MessageCallback * mc;
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
GdkWindow * w;
|
||||
#endif
|
||||
|
||||
# ifdef DEBUG
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%p, %p)\n", __func__, callback, data);
|
||||
# endif
|
||||
#endif
|
||||
for(i = 0; i < _callbacks_cnt; i++)
|
||||
{
|
||||
mc = _callbacks[i];
|
||||
|
@ -191,15 +304,24 @@ void desktop_message_unregister(GtkWidget * window,
|
|||
}
|
||||
if(i == _callbacks_cnt)
|
||||
return;
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||
w = (window != NULL) ? gtk_widget_get_window(window) : NULL;
|
||||
#else
|
||||
# else
|
||||
w = gtk_widget_get_window(mc->widget);
|
||||
#endif
|
||||
# endif
|
||||
gdk_window_remove_filter(w, _desktop_message_on_callback, mc);
|
||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||
# if !GTK_CHECK_VERSION(3, 0, 0)
|
||||
if(mc->window == NULL)
|
||||
gtk_widget_destroy(mc->widget);
|
||||
# endif
|
||||
#else
|
||||
if(mc->id > 0)
|
||||
g_source_remove(mc->id);
|
||||
if(mc->channel != NULL)
|
||||
g_io_channel_unref(mc->channel);
|
||||
if(mc->socket >= 0)
|
||||
close(mc->socket);
|
||||
#endif
|
||||
object_delete(mc);
|
||||
p = &_callbacks[i];
|
||||
|
@ -212,6 +334,7 @@ void desktop_message_unregister(GtkWidget * window,
|
|||
|
||||
/* private */
|
||||
/* callbacks */
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
/* desktop_message_on_callback */
|
||||
static GdkFilterReturn _desktop_message_on_callback(GdkXEvent * xevent,
|
||||
GdkEvent * event, gpointer data)
|
||||
|
@ -227,25 +350,25 @@ static GdkFilterReturn _desktop_message_on_callback(GdkXEvent * xevent,
|
|||
if(xev->type != ClientMessage)
|
||||
return GDK_FILTER_CONTINUE;
|
||||
xcme = &xev->xclient;
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
# ifdef DEBUG
|
||||
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||
# ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%lu %lu %p)\n", __func__, xcme->serial,
|
||||
xcme->window, (void *)mc);
|
||||
# endif
|
||||
# endif
|
||||
if(mc->atom != xcme->message_type)
|
||||
return GDK_FILTER_CONTINUE;
|
||||
#else
|
||||
# ifdef DEBUG
|
||||
# else
|
||||
# ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%lu %lu %p) %lu\n", __func__, xcme->serial,
|
||||
xcme->window, mc, (void *)mc->xwindow);
|
||||
# endif
|
||||
# endif
|
||||
if(mc->xwindow != xcme->window)
|
||||
return GDK_FILTER_CONTINUE;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
# endif
|
||||
# ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() %p(%p)\n", __func__, (void *)mc->callback,
|
||||
(void *)mc->data);
|
||||
#endif
|
||||
# endif
|
||||
value1 = xcme->data.l[0];
|
||||
value2 = xcme->data.l[1];
|
||||
value3 = xcme->data.l[2];
|
||||
|
@ -254,3 +377,45 @@ static GdkFilterReturn _desktop_message_on_callback(GdkXEvent * xevent,
|
|||
desktop_message_unregister(mc->window, mc->callback, mc->data);
|
||||
return GDK_FILTER_REMOVE;
|
||||
}
|
||||
#else
|
||||
static gboolean _desktop_message_on_connect(GIOChannel * channel,
|
||||
GIOCondition condition, gpointer data)
|
||||
{
|
||||
size_t i;
|
||||
MessageCallback * mc;
|
||||
int fd;
|
||||
char buf[33];
|
||||
ssize_t len;
|
||||
uint32_t value1;
|
||||
uint32_t value2;
|
||||
uint32_t value3;
|
||||
(void) data;
|
||||
|
||||
# ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
# endif
|
||||
if(condition != G_IO_IN)
|
||||
return FALSE;
|
||||
for(i = 0; i < _callbacks_cnt; i++)
|
||||
if(_callbacks[i]->channel == channel)
|
||||
break;
|
||||
if(i == _callbacks_cnt)
|
||||
return FALSE;
|
||||
mc = _callbacks[i];
|
||||
if((fd = accept(mc->socket, NULL, NULL)) < 0)
|
||||
/* XXX ignore these errors */
|
||||
return TRUE;
|
||||
len = recv(fd, buf, sizeof(buf) - 1, 0);
|
||||
close(fd);
|
||||
if(len > 0 && (size_t)len < sizeof(buf))
|
||||
{
|
||||
buf[len] = '\0';
|
||||
if(sscanf(buf, "0x%x:0x%x:0x%x", &value1, &value2, &value3) == 3
|
||||
&& mc->callback(mc->data, value1, value2,
|
||||
value3) != 0)
|
||||
desktop_message_unregister(mc->window, mc->callback,
|
||||
mc->data);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
|
39
src/mime.c
39
src/mime.c
|
@ -1,5 +1,5 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS libDesktop */
|
||||
/* All rights reserved.
|
||||
*
|
||||
|
@ -97,7 +97,16 @@ Mime * mime_new(GtkIconTheme * theme)
|
|||
"/usr/pkg/share/mime/globs2",
|
||||
NULL
|
||||
};
|
||||
char ** g = globs2;
|
||||
char * globs[] =
|
||||
{
|
||||
DATADIR "/mime/globs",
|
||||
"/usr/share/mime/globs",
|
||||
"/usr/local/share/mime/globs",
|
||||
"/usr/pkg/share/mime/globs",
|
||||
NULL
|
||||
};
|
||||
int priority = 1;
|
||||
char ** g;
|
||||
FILE * fp = NULL;
|
||||
char buf[256];
|
||||
size_t len;
|
||||
|
@ -116,14 +125,15 @@ Mime * mime_new(GtkIconTheme * theme)
|
|||
if((fp = fopen(*g, "r")) != NULL)
|
||||
break;
|
||||
if(fp == NULL)
|
||||
{
|
||||
error_set_code(1, "%s", "Could not load MIME globs");
|
||||
object_delete(mime);
|
||||
return NULL;
|
||||
}
|
||||
for(g = globs, priority = 0; *g != NULL; g++)
|
||||
if((fp = fopen(*g, "r")) != NULL)
|
||||
break;
|
||||
mime->types = NULL;
|
||||
mime->types_cnt = 0;
|
||||
_new_config(mime);
|
||||
if(fp == NULL)
|
||||
/* XXX no globs could be loaded */
|
||||
return mime;
|
||||
while(fgets(buf, sizeof(buf), fp) != NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
|
@ -133,11 +143,16 @@ Mime * mime_new(GtkIconTheme * theme)
|
|||
if(buf[0] == '#')
|
||||
continue;
|
||||
buf[len] = '\0';
|
||||
/* parse the priority */
|
||||
errno = 0;
|
||||
strtoul(buf, &p, 0);
|
||||
if(errno != 0 || *(p++) != ':')
|
||||
continue;
|
||||
if(priority)
|
||||
{
|
||||
/* parse the priority */
|
||||
errno = 0;
|
||||
strtoul(buf, &p, 0);
|
||||
if(errno != 0 || *(p++) != ':')
|
||||
continue;
|
||||
}
|
||||
else
|
||||
p = buf;
|
||||
glob = strchr(p, ':');
|
||||
*(glob++) = '\0';
|
||||
for(i = 0; i < mime->types_cnt; i++)
|
||||
|
|
|
@ -597,7 +597,13 @@ int mimehandler_load_by_name(MimeHandler * handler, String const * name)
|
|||
return ret;
|
||||
/* read through every XDG application folder */
|
||||
if((path = getenv("XDG_DATA_DIRS")) == NULL || strlen(path) == 0)
|
||||
path = "/usr/local/share:" DATADIR ":/usr/share";
|
||||
{
|
||||
/* XXX avoid duplicates if PREFIX is "/usr/local" */
|
||||
if(string_compare("/usr/local/share", DATADIR) != 0)
|
||||
path = "/usr/local/share:" DATADIR ":/usr/share";
|
||||
else
|
||||
path = "/usr/local/share:/usr/share";
|
||||
}
|
||||
if((p = string_new(path)) == NULL)
|
||||
return -1;
|
||||
for(q = strtok_r(p, ":", &last); q != NULL;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2017-2021 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2017-2022 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
|
@ -95,7 +95,7 @@ _fixme_callback()
|
|||
echo "_fixme_callback_asm"
|
||||
return 0
|
||||
;;
|
||||
c|cc|cpp|cxx|h|js|v)
|
||||
c|cc|cpp|cxx|go|h|js|v)
|
||||
echo "_fixme_callback_c"
|
||||
return 0
|
||||
;;
|
||||
|
@ -122,7 +122,7 @@ _fixme_callback()
|
|||
echo "_fixme_callback_python"
|
||||
return 0
|
||||
;;
|
||||
"<html"*|"<?xml"*)
|
||||
"<!DOCTYPE"*|"<!doctype"*|"<HTML"*|"<html"*|"<?xml"*)
|
||||
echo "_fixme_callback_xml"
|
||||
return 0
|
||||
;;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2016-2018 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2016-2024 Pierre Pronchery <khorben@defora.org>
|
||||
#This file is part of DeforaOS Desktop libDesktop
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
|
@ -27,8 +27,11 @@
|
|||
#variables
|
||||
[ -n "$OBJDIR" ] || OBJDIR="./"
|
||||
PROGNAME="tests.sh"
|
||||
SYSTEM="$(uname -s)"
|
||||
#executables
|
||||
DATE="date"
|
||||
ECHO="echo"
|
||||
[ "$SYSTEM" = "Darwin" ] && ECHO="/bin/echo"
|
||||
|
||||
|
||||
#functions
|
||||
|
@ -47,7 +50,7 @@ _run()
|
|||
[ $# -eq 1 ] || sep=" "
|
||||
|
||||
shift
|
||||
echo -n "$test:" 1>&2
|
||||
$ECHO -n "$test:" 1>&2
|
||||
(echo
|
||||
echo "Testing: $test" "$@"
|
||||
testexe="./$test"
|
||||
|
@ -79,7 +82,7 @@ _test()
|
|||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: $PROGNAME [-c][-P prefix]" 1>&2
|
||||
echo "Usage: $PROGNAME [-c][-P prefix] target" 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
@ -92,7 +95,7 @@ while getopts "cP:" name; do
|
|||
clean=1
|
||||
;;
|
||||
P)
|
||||
#XXX ignored
|
||||
#XXX ignored for compatibility
|
||||
;;
|
||||
?)
|
||||
_usage
|
||||
|
@ -107,7 +110,7 @@ if [ $# -ne 1 ]; then
|
|||
fi
|
||||
target="$1"
|
||||
|
||||
[ "$clean" -ne 0 ] && exit 0
|
||||
[ $clean -ne 0 ] && exit 0
|
||||
|
||||
tests="mime mimehandler pkgconfig.sh"
|
||||
failures=
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2012-2022 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
|
@ -29,18 +29,19 @@ CONFIGSH="${0%/subst.sh}/../config.sh"
|
|||
PREFIX="/usr/local"
|
||||
BINDIR=
|
||||
DATADIR=
|
||||
DEVNULL="/dev/null"
|
||||
INCLUDEDIR=
|
||||
LDSO=
|
||||
LIBDIR=
|
||||
LIBEXECDIR=
|
||||
MANDIR=
|
||||
PROGNAME="subst.sh"
|
||||
SBINDIR=
|
||||
SYSCONFDIR=
|
||||
#executables
|
||||
CHMOD="chmod"
|
||||
DATE="date"
|
||||
DEBUG="_debug"
|
||||
DEVNULL="/dev/null"
|
||||
INSTALL="install"
|
||||
MKDIR="mkdir -m 0755 -p"
|
||||
RM="rm -f"
|
||||
|
@ -85,6 +86,7 @@ _subst()
|
|||
SYSCONFDIR="$PREFIX/etc"
|
||||
[ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc"
|
||||
fi
|
||||
[ -z "$SBINDIR" ] && SBINDIR="$PREFIX/sbin"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
|
@ -115,7 +117,8 @@ _subst()
|
|||
source="${source}.in"
|
||||
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") \
|
||||
|| return 2
|
||||
$DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;g" \
|
||||
$DEBUG $SED -e "s;@VENDOR@;$VENDOR;g" \
|
||||
-e "s;@PACKAGE@;$PACKAGE;g" \
|
||||
-e "s;@VERSION@;$VERSION;g" \
|
||||
-e "s;@PREFIX@;$PREFIX;g" \
|
||||
-e "s;@BINDIR@;$BINDIR;g" \
|
||||
|
@ -127,6 +130,7 @@ _subst()
|
|||
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
|
||||
-e "s;@MANDIR@;$MANDIR;g" \
|
||||
-e "s;@PWD@;$PWD;g" \
|
||||
-e "s;@SBINDIR@;$SBINDIR;g" \
|
||||
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
|
||||
-- "$source" > "$target"
|
||||
if [ $? -ne 0 ]; then
|
||||
|
@ -139,6 +143,7 @@ _subst()
|
|||
return 0
|
||||
}
|
||||
|
||||
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user