Added panel-message for simple notifications
This commit is contained in:
parent
74c31d1e68
commit
b83a5859ca
1
Makefile
1
Makefile
|
@ -113,6 +113,7 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/src/applets/tasks.atoms \
|
$(PACKAGE)-$(VERSION)/src/applets/tasks.atoms \
|
||||||
$(PACKAGE)-$(VERSION)/src/applets/project.conf \
|
$(PACKAGE)-$(VERSION)/src/applets/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/tools/embed.c \
|
$(PACKAGE)-$(VERSION)/tools/embed.c \
|
||||||
|
$(PACKAGE)-$(VERSION)/tools/message.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/notify.c \
|
$(PACKAGE)-$(VERSION)/tools/notify.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/test.c \
|
$(PACKAGE)-$(VERSION)/tools/test.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
panel-embed
|
panel-embed
|
||||||
|
panel-message
|
||||||
panel-notify
|
panel-notify
|
||||||
panel-test
|
panel-test
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
TARGETS = panel-embed panel-notify panel-test
|
TARGETS = panel-embed panel-message panel-notify panel-test
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
@ -23,6 +23,13 @@ panel-embed_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
panel-embed: $(panel-embed_OBJS)
|
panel-embed: $(panel-embed_OBJS)
|
||||||
$(CC) -o panel-embed $(panel-embed_OBJS) $(panel-embed_LDFLAGS)
|
$(CC) -o panel-embed $(panel-embed_OBJS) $(panel-embed_LDFLAGS)
|
||||||
|
|
||||||
|
panel-message_OBJS = message.o
|
||||||
|
panel-message_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
|
panel-message_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
|
||||||
|
panel-message: $(panel-message_OBJS)
|
||||||
|
$(CC) -o panel-message $(panel-message_OBJS) $(panel-message_LDFLAGS)
|
||||||
|
|
||||||
panel-notify_OBJS = notify.o
|
panel-notify_OBJS = notify.o
|
||||||
panel-notify_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) -D PREFIX=\"$(PREFIX)\" $(CFLAGSF) $(CFLAGS)
|
panel-notify_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) -D PREFIX=\"$(PREFIX)\" $(CFLAGSF) $(CFLAGS)
|
||||||
panel-notify_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
panel-notify_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
@ -40,6 +47,9 @@ panel-test: $(panel-test_OBJS)
|
||||||
embed.o: embed.c ../include/Panel.h ../config.h
|
embed.o: embed.c ../include/Panel.h ../config.h
|
||||||
$(CC) $(panel-embed_CFLAGS) -c embed.c
|
$(CC) $(panel-embed_CFLAGS) -c embed.c
|
||||||
|
|
||||||
|
message.o: message.c ../include/Panel.h
|
||||||
|
$(CC) $(panel-message_CFLAGS) -c message.c
|
||||||
|
|
||||||
notify.o: notify.c helper.c ../src/panel.h ../config.h
|
notify.o: notify.c helper.c ../src/panel.h ../config.h
|
||||||
$(CC) $(panel-notify_CFLAGS) -c notify.c
|
$(CC) $(panel-notify_CFLAGS) -c notify.c
|
||||||
|
|
||||||
|
@ -47,7 +57,7 @@ test.o: test.c helper.c ../src/panel.h ../config.h
|
||||||
$(CC) $(panel-test_CFLAGS) -c test.c
|
$(CC) $(panel-test_CFLAGS) -c test.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -- $(panel-embed_OBJS) $(panel-notify_OBJS) $(panel-test_OBJS)
|
$(RM) -- $(panel-embed_OBJS) $(panel-message_OBJS) $(panel-notify_OBJS) $(panel-test_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) -- $(TARGETS)
|
$(RM) -- $(TARGETS)
|
||||||
|
@ -56,10 +66,13 @@ install: $(TARGETS)
|
||||||
$(MKDIR) $(DESTDIR)$(BINDIR)
|
$(MKDIR) $(DESTDIR)$(BINDIR)
|
||||||
$(INSTALL) -m 0755 -- panel-embed $(DESTDIR)$(BINDIR)/panel-embed
|
$(INSTALL) -m 0755 -- panel-embed $(DESTDIR)$(BINDIR)/panel-embed
|
||||||
$(MKDIR) $(DESTDIR)$(BINDIR)
|
$(MKDIR) $(DESTDIR)$(BINDIR)
|
||||||
|
$(INSTALL) -m 0755 -- panel-message $(DESTDIR)$(BINDIR)/panel-message
|
||||||
|
$(MKDIR) $(DESTDIR)$(BINDIR)
|
||||||
$(INSTALL) -m 0755 -- panel-notify $(DESTDIR)$(BINDIR)/panel-notify
|
$(INSTALL) -m 0755 -- panel-notify $(DESTDIR)$(BINDIR)/panel-notify
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
$(RM) -- $(DESTDIR)$(BINDIR)/panel-embed
|
$(RM) -- $(DESTDIR)$(BINDIR)/panel-embed
|
||||||
|
$(RM) -- $(DESTDIR)$(BINDIR)/panel-message
|
||||||
$(RM) -- $(DESTDIR)$(BINDIR)/panel-notify
|
$(RM) -- $(DESTDIR)$(BINDIR)/panel-notify
|
||||||
|
|
||||||
.PHONY: all clean distclean install uninstall
|
.PHONY: all clean distclean install uninstall
|
||||||
|
|
113
tools/message.c
Normal file
113
tools/message.c
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||||
|
/* This file is part of DeforaOS Desktop Panel */
|
||||||
|
/* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <Desktop.h>
|
||||||
|
#include "../include/Panel.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
/* prototypes */
|
||||||
|
static int _message(unsigned int timeout, GtkMessageType type,
|
||||||
|
char const * message);
|
||||||
|
|
||||||
|
/* callbacks */
|
||||||
|
static gboolean _message_on_timeout(gpointer data);
|
||||||
|
|
||||||
|
static int _error(char const * message, int ret);
|
||||||
|
static int _usage(void);
|
||||||
|
|
||||||
|
|
||||||
|
/* functions */
|
||||||
|
/* message */
|
||||||
|
static int _message(unsigned int timeout, GtkMessageType type,
|
||||||
|
char const * message)
|
||||||
|
{
|
||||||
|
GtkWidget * widget;
|
||||||
|
GtkWidget * label;
|
||||||
|
uint32_t xid;
|
||||||
|
|
||||||
|
widget = gtk_plug_new(0);
|
||||||
|
gtk_container_set_border_width(GTK_CONTAINER(widget), 4);
|
||||||
|
label = gtk_label_new(message);
|
||||||
|
gtk_container_add(GTK_CONTAINER(widget), label);
|
||||||
|
gtk_widget_show_all(widget);
|
||||||
|
xid = gtk_plug_get_id(GTK_PLUG(widget));
|
||||||
|
desktop_message_send(PANEL_CLIENT_MESSAGE, PANEL_MESSAGE_EMBED, xid, 0);
|
||||||
|
if(timeout > 0)
|
||||||
|
g_timeout_add(timeout * 1000, _message_on_timeout, NULL);
|
||||||
|
gtk_main();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* callbacks */
|
||||||
|
/* message_on_timeout */
|
||||||
|
static gboolean _message_on_timeout(gpointer data)
|
||||||
|
{
|
||||||
|
gtk_main_quit();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* error */
|
||||||
|
static int _error(char const * message, int ret)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s%s\n", "panel-message: ", message);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* usage */
|
||||||
|
static int _usage(void)
|
||||||
|
{
|
||||||
|
fputs("Usage: panel-message [-T type][-t timeout] message\n", stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* public */
|
||||||
|
/* functions */
|
||||||
|
/* main */
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
GtkMessageType type = GTK_MESSAGE_INFO;
|
||||||
|
unsigned int timeout = 3;
|
||||||
|
int o;
|
||||||
|
char * p;
|
||||||
|
|
||||||
|
gtk_init(&argc, &argv);
|
||||||
|
while((o = getopt(argc, argv, "t:T:")) != -1)
|
||||||
|
switch(o)
|
||||||
|
{
|
||||||
|
case 'T':
|
||||||
|
/* FIXME implement */
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
timeout = strtoul(optarg, &p, 10);
|
||||||
|
if(optarg[0] == '\0' || *p != '\0')
|
||||||
|
return _usage();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return _usage();
|
||||||
|
}
|
||||||
|
if(argc - optind != 1)
|
||||||
|
return _usage();
|
||||||
|
return (_message(timeout, type, argv[optind]) == 0) ? 0 : 2;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
targets=panel-embed,panel-notify,panel-test
|
targets=panel-embed,panel-message,panel-notify,panel-test
|
||||||
cflags_force=-W `pkg-config --cflags libSystem libDesktop`
|
cflags_force=-W `pkg-config --cflags libSystem libDesktop`
|
||||||
cflags=-Wall -g -O2
|
cflags=-Wall -g -O2
|
||||||
ldflags_force=`pkg-config --libs libSystem libDesktop`
|
ldflags_force=`pkg-config --libs libSystem libDesktop`
|
||||||
|
@ -15,6 +15,11 @@ cppflags=-D PREFIX=\"$(PREFIX)\"
|
||||||
sources=notify.c
|
sources=notify.c
|
||||||
install=$(BINDIR)
|
install=$(BINDIR)
|
||||||
|
|
||||||
|
[panel-message]
|
||||||
|
type=binary
|
||||||
|
sources=message.c
|
||||||
|
install=$(BINDIR)
|
||||||
|
|
||||||
[panel-test]
|
[panel-test]
|
||||||
type=binary
|
type=binary
|
||||||
cppflags=-D PREFIX=\"$(PREFIX)\"
|
cppflags=-D PREFIX=\"$(PREFIX)\"
|
||||||
|
@ -23,6 +28,9 @@ sources=test.c
|
||||||
[embed.c]
|
[embed.c]
|
||||||
depends=../include/Panel.h,../config.h
|
depends=../include/Panel.h,../config.h
|
||||||
|
|
||||||
|
[message.c]
|
||||||
|
depends=../include/Panel.h
|
||||||
|
|
||||||
[notify.c]
|
[notify.c]
|
||||||
depends=helper.c,../src/panel.h,../config.h
|
depends=helper.c,../src/panel.h,../config.h
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user