diff --git a/Makefile b/Makefile index e0678e2..37284d0 100644 --- a/Makefile +++ b/Makefile @@ -22,21 +22,27 @@ dist: $(LN) -s -- . $(PACKAGE)-$(VERSION) @$(TAR) $(PACKAGE)-$(VERSION).tar.gz -- \ $(PACKAGE)-$(VERSION)/data/Makefile \ + $(PACKAGE)-$(VERSION)/data/panel-settings.desktop \ $(PACKAGE)-$(VERSION)/data/project.conf \ $(PACKAGE)-$(VERSION)/data/16x16/Makefile \ $(PACKAGE)-$(VERSION)/data/16x16/panel-applet-bluetooth.png \ + $(PACKAGE)-$(VERSION)/data/16x16/panel-settings.png \ $(PACKAGE)-$(VERSION)/data/16x16/project.conf \ $(PACKAGE)-$(VERSION)/data/22x22/Makefile \ $(PACKAGE)-$(VERSION)/data/22x22/panel-applet-bluetooth.png \ + $(PACKAGE)-$(VERSION)/data/22x22/panel-settings.png \ $(PACKAGE)-$(VERSION)/data/22x22/project.conf \ $(PACKAGE)-$(VERSION)/data/24x24/Makefile \ $(PACKAGE)-$(VERSION)/data/24x24/panel-applet-bluetooth.png \ + $(PACKAGE)-$(VERSION)/data/24x24/panel-settings.png \ $(PACKAGE)-$(VERSION)/data/24x24/project.conf \ $(PACKAGE)-$(VERSION)/data/32x32/Makefile \ $(PACKAGE)-$(VERSION)/data/32x32/panel-applet-bluetooth.png \ + $(PACKAGE)-$(VERSION)/data/32x32/panel-settings.png \ $(PACKAGE)-$(VERSION)/data/32x32/project.conf \ $(PACKAGE)-$(VERSION)/data/48x48/Makefile \ $(PACKAGE)-$(VERSION)/data/48x48/panel-applet-bluetooth.png \ + $(PACKAGE)-$(VERSION)/data/48x48/panel-settings.png \ $(PACKAGE)-$(VERSION)/data/48x48/project.conf \ $(PACKAGE)-$(VERSION)/data/scalable/Makefile \ $(PACKAGE)-$(VERSION)/data/scalable/panel-applet-bluetooth.svg \ @@ -52,6 +58,7 @@ dist: $(PACKAGE)-$(VERSION)/src/panel.c \ $(PACKAGE)-$(VERSION)/src/window.c \ $(PACKAGE)-$(VERSION)/src/main.c \ + $(PACKAGE)-$(VERSION)/src/settings.c \ $(PACKAGE)-$(VERSION)/src/run.c \ $(PACKAGE)-$(VERSION)/src/Makefile \ $(PACKAGE)-$(VERSION)/src/common.h \ diff --git a/data/16x16/Makefile b/data/16x16/Makefile index 7663214..0eda59f 100644 --- a/data/16x16/Makefile +++ b/data/16x16/Makefile @@ -14,8 +14,11 @@ distclean: clean install: $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps $(INSTALL) -m 0644 -- panel-applet-bluetooth.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/panel-applet-bluetooth.png + $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps + $(INSTALL) -m 0644 -- panel-settings.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/panel-settings.png uninstall: $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/panel-applet-bluetooth.png + $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/panel-settings.png .PHONY: all clean distclean install uninstall diff --git a/data/16x16/panel-settings.png b/data/16x16/panel-settings.png new file mode 100644 index 0000000..851d30e Binary files /dev/null and b/data/16x16/panel-settings.png differ diff --git a/data/16x16/project.conf b/data/16x16/project.conf index a40d5b0..b08da30 100644 --- a/data/16x16/project.conf +++ b/data/16x16/project.conf @@ -1,4 +1,7 @@ -dist=Makefile,panel-applet-bluetooth.png +dist=Makefile,panel-applet-bluetooth.png,panel-settings.png [panel-applet-bluetooth.png] install=$(PREFIX)/share/icons/hicolor/16x16/apps + +[panel-settings.png] +install=$(PREFIX)/share/icons/hicolor/16x16/apps diff --git a/data/22x22/Makefile b/data/22x22/Makefile index 3dac13f..aebb0db 100644 --- a/data/22x22/Makefile +++ b/data/22x22/Makefile @@ -14,8 +14,11 @@ distclean: clean install: $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/22x22/apps $(INSTALL) -m 0644 -- panel-applet-bluetooth.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/22x22/apps/panel-applet-bluetooth.png + $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/22x22/apps + $(INSTALL) -m 0644 -- panel-settings.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/22x22/apps/panel-settings.png uninstall: $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/22x22/apps/panel-applet-bluetooth.png + $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/22x22/apps/panel-settings.png .PHONY: all clean distclean install uninstall diff --git a/data/22x22/panel-settings.png b/data/22x22/panel-settings.png new file mode 100644 index 0000000..b217ee3 Binary files /dev/null and b/data/22x22/panel-settings.png differ diff --git a/data/22x22/project.conf b/data/22x22/project.conf index 2ea3195..ff1fb45 100644 --- a/data/22x22/project.conf +++ b/data/22x22/project.conf @@ -1,4 +1,7 @@ -dist=Makefile,panel-applet-bluetooth.png +dist=Makefile,panel-applet-bluetooth.png,panel-settings.png [panel-applet-bluetooth.png] install=$(PREFIX)/share/icons/hicolor/22x22/apps + +[panel-settings.png] +install=$(PREFIX)/share/icons/hicolor/22x22/apps diff --git a/data/24x24/Makefile b/data/24x24/Makefile index d2557f6..06214c0 100644 --- a/data/24x24/Makefile +++ b/data/24x24/Makefile @@ -14,8 +14,11 @@ distclean: clean install: $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps $(INSTALL) -m 0644 -- panel-applet-bluetooth.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps/panel-applet-bluetooth.png + $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps + $(INSTALL) -m 0644 -- panel-settings.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps/panel-settings.png uninstall: $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps/panel-applet-bluetooth.png + $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps/panel-settings.png .PHONY: all clean distclean install uninstall diff --git a/data/24x24/panel-settings.png b/data/24x24/panel-settings.png new file mode 100644 index 0000000..0691b99 Binary files /dev/null and b/data/24x24/panel-settings.png differ diff --git a/data/24x24/project.conf b/data/24x24/project.conf index 59d8a1a..42543c3 100644 --- a/data/24x24/project.conf +++ b/data/24x24/project.conf @@ -1,4 +1,7 @@ -dist=Makefile,panel-applet-bluetooth.png +dist=Makefile,panel-applet-bluetooth.png,panel-settings.png [panel-applet-bluetooth.png] install=$(PREFIX)/share/icons/hicolor/24x24/apps + +[panel-settings.png] +install=$(PREFIX)/share/icons/hicolor/24x24/apps diff --git a/data/32x32/Makefile b/data/32x32/Makefile index 60db662..7f853c8 100644 --- a/data/32x32/Makefile +++ b/data/32x32/Makefile @@ -14,8 +14,11 @@ distclean: clean install: $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps $(INSTALL) -m 0644 -- panel-applet-bluetooth.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps/panel-applet-bluetooth.png + $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps + $(INSTALL) -m 0644 -- panel-settings.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps/panel-settings.png uninstall: $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps/panel-applet-bluetooth.png + $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps/panel-settings.png .PHONY: all clean distclean install uninstall diff --git a/data/32x32/panel-settings.png b/data/32x32/panel-settings.png new file mode 100644 index 0000000..56eef12 Binary files /dev/null and b/data/32x32/panel-settings.png differ diff --git a/data/32x32/project.conf b/data/32x32/project.conf index 9d3d231..05d29ad 100644 --- a/data/32x32/project.conf +++ b/data/32x32/project.conf @@ -1,4 +1,7 @@ -dist=Makefile,panel-applet-bluetooth.png +dist=Makefile,panel-applet-bluetooth.png,panel-settings.png [panel-applet-bluetooth.png] install=$(PREFIX)/share/icons/hicolor/32x32/apps + +[panel-settings.png] +install=$(PREFIX)/share/icons/hicolor/32x32/apps diff --git a/data/48x48/Makefile b/data/48x48/Makefile index cc01aa5..503bf15 100644 --- a/data/48x48/Makefile +++ b/data/48x48/Makefile @@ -14,8 +14,11 @@ distclean: clean install: $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps $(INSTALL) -m 0644 -- panel-applet-bluetooth.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/panel-applet-bluetooth.png + $(MKDIR) $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps + $(INSTALL) -m 0644 -- panel-settings.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/panel-settings.png uninstall: $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/panel-applet-bluetooth.png + $(RM) -- $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/panel-settings.png .PHONY: all clean distclean install uninstall diff --git a/data/48x48/panel-settings.png b/data/48x48/panel-settings.png new file mode 100644 index 0000000..4cf61cf Binary files /dev/null and b/data/48x48/panel-settings.png differ diff --git a/data/48x48/project.conf b/data/48x48/project.conf index b755a83..96490fd 100644 --- a/data/48x48/project.conf +++ b/data/48x48/project.conf @@ -1,4 +1,7 @@ -dist=Makefile,panel-applet-bluetooth.png +dist=Makefile,panel-applet-bluetooth.png,panel-settings.png [panel-applet-bluetooth.png] install=$(PREFIX)/share/icons/hicolor/48x48/apps + +[panel-settings.png] +install=$(PREFIX)/share/icons/hicolor/48x48/apps diff --git a/data/Makefile b/data/Makefile index 3f8a3e0..fbbf383 100644 --- a/data/Makefile +++ b/data/Makefile @@ -1,4 +1,9 @@ SUBDIRS = 16x16 22x22 24x24 32x32 48x48 scalable +PREFIX = /usr/local +DESTDIR = +MKDIR = mkdir -p +INSTALL = install +RM = rm -f all: subdirs @@ -14,8 +19,11 @@ distclean: install: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) install) || exit; done + $(MKDIR) $(DESTDIR)$(PREFIX)/share/applications + $(INSTALL) -m 0644 -- panel-settings.desktop $(DESTDIR)$(PREFIX)/share/applications/panel-settings.desktop uninstall: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) uninstall) || exit; done + $(RM) -- $(DESTDIR)$(PREFIX)/share/applications/panel-settings.desktop .PHONY: all subdirs clean distclean install uninstall diff --git a/data/panel-settings.desktop b/data/panel-settings.desktop new file mode 100644 index 0000000..3dbd18e --- /dev/null +++ b/data/panel-settings.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=Panel settings +Exec=panel-settings +Icon=panel-settings +Type=Application +Categories=Settings;GTK; diff --git a/data/project.conf b/data/project.conf index 84b677a..5ecf70b 100644 --- a/data/project.conf +++ b/data/project.conf @@ -1,2 +1,5 @@ subdirs=16x16,22x22,24x24,32x32,48x48,scalable -dist=Makefile +dist=Makefile,panel-settings.desktop + +[panel-settings.desktop] +install=$(PREFIX)/share/applications diff --git a/src/.cvsignore b/src/.cvsignore index 7a2930c..ccd8b61 100644 --- a/src/.cvsignore +++ b/src/.cvsignore @@ -1,3 +1,4 @@ .cvsignore panel +panel-settings run diff --git a/src/Makefile b/src/Makefile index f6c70b5..4e5151f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ SUBDIRS = applets -TARGETS = panel run +TARGETS = panel panel-settings run PREFIX = /usr/local DESTDIR = BINDIR = $(PREFIX)/bin @@ -28,6 +28,13 @@ panel_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) panel: $(panel_OBJS) $(CC) -o panel $(panel_OBJS) $(panel_LDFLAGS) +panel-settings_OBJS = settings.o +panel-settings_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +panel-settings_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +panel-settings: $(panel-settings_OBJS) + $(CC) -o panel-settings $(panel-settings_OBJS) $(panel-settings_LDFLAGS) + run_OBJS = run.o run_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) -D PREFIX=\"$(PREFIX)\" $(CFLAGSF) $(CFLAGS) run_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) @@ -44,16 +51,19 @@ window.o: window.c common.h window.h main.o: main.c common.h ../config.h $(CC) $(panel_CFLAGS) -c main.c +settings.o: settings.c + $(CC) $(panel-settings_CFLAGS) -c settings.c + run.o: run.c $(CC) $(run_CFLAGS) -c run.c clean: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done - $(RM) -- $(panel_OBJS) $(run_OBJS) + $(RM) -- $(panel_OBJS) $(panel-settings_OBJS) $(run_OBJS) distclean: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done - $(RM) -- $(panel_OBJS) $(run_OBJS) + $(RM) -- $(panel_OBJS) $(panel-settings_OBJS) $(run_OBJS) $(RM) -- $(TARGETS) install: $(TARGETS) @@ -61,11 +71,14 @@ install: $(TARGETS) $(MKDIR) $(DESTDIR)$(BINDIR) $(INSTALL) -m 0755 -- panel $(DESTDIR)$(BINDIR)/panel $(MKDIR) $(DESTDIR)$(BINDIR) + $(INSTALL) -m 0755 -- panel-settings $(DESTDIR)$(BINDIR)/panel-settings + $(MKDIR) $(DESTDIR)$(BINDIR) $(INSTALL) -m 0755 -- run $(DESTDIR)$(BINDIR)/run uninstall: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) uninstall) || exit; done $(RM) -- $(DESTDIR)$(BINDIR)/panel + $(RM) -- $(DESTDIR)$(BINDIR)/panel-settings $(RM) -- $(DESTDIR)$(BINDIR)/run .PHONY: all subdirs clean distclean install uninstall diff --git a/src/common.h b/src/common.h index 28ab082..6f38195 100644 --- a/src/common.h +++ b/src/common.h @@ -24,6 +24,16 @@ /* Panel */ /* types */ +typedef enum _PanelMessage +{ + PANEL_MESSAGE_SHOW = 0 +} PanelMessage; + +typedef enum _PanelMessageShow +{ + PANEL_MESSAGE_SHOW_SETTINGS = 0 +} PanelMessageShow; + typedef enum _PanelPosition { PANEL_POSITION_BOTTOM = 0x1, @@ -41,12 +51,15 @@ typedef struct _PanelPrefs /* constants */ -#define PANEL_BORDER_WIDTH 4 -#define PANEL_ICON_SIZE_DEFAULT GTK_ICON_SIZE_LARGE_TOOLBAR -#define PANEL_ICON_SIZE_UNSET GTK_ICON_SIZE_INVALID -#define PANEL_ICON_SIZE_SMALL GTK_ICON_SIZE_SMALL_TOOLBAR -#define PANEL_ICON_SIZE_SMALLER GTK_ICON_SIZE_MENU -#define PANEL_ICON_SIZE_LARGE GTK_ICON_SIZE_LARGE_TOOLBAR +# define PANEL_BORDER_WIDTH 4 + +# define PANEL_CLIENT_MESSAGE "DEFORAOS_DESKTOP_PANEL_CLIENT" + +# define PANEL_ICON_SIZE_DEFAULT GTK_ICON_SIZE_LARGE_TOOLBAR +# define PANEL_ICON_SIZE_UNSET GTK_ICON_SIZE_INVALID +# define PANEL_ICON_SIZE_SMALL GTK_ICON_SIZE_SMALL_TOOLBAR +# define PANEL_ICON_SIZE_SMALLER GTK_ICON_SIZE_MENU +# define PANEL_ICON_SIZE_LARGE GTK_ICON_SIZE_LARGE_TOOLBAR /* functions */ diff --git a/src/panel.c b/src/panel.c index 90a6fbb..caccf48 100644 --- a/src/panel.c +++ b/src/panel.c @@ -109,6 +109,8 @@ static GtkIconSize _new_size(Panel * panel, PanelPosition position); static gboolean _on_idle(gpointer data); static void _idle_load(Panel * panel, PanelPosition position, char const * plugins); +static GdkFilterReturn _on_root_event(GdkXEvent * xevent, GdkEvent * event, + gpointer data); Panel * panel_new(PanelPrefs const * prefs) { @@ -175,6 +177,10 @@ Panel * panel_new(PanelPrefs const * prefs) panel->bottom = (prefs->position & PANEL_POSITION_BOTTOM) ? panel_window_new(PANEL_POSITION_BOTTOM, &panel->bottom_helper, &rect) : NULL; + /* manage root window events */ + gdk_add_client_message_filter(gdk_atom_intern(PANEL_CLIENT_MESSAGE, + FALSE), _on_root_event, panel); + /* load plug-ins when idle */ g_idle_add(_on_idle, panel); return panel; } @@ -297,6 +303,31 @@ static void _idle_load(Panel * panel, PanelPosition position, free(p); } +static GdkFilterReturn _on_root_event(GdkXEvent * xevent, GdkEvent * event, + gpointer data) +{ + Panel * panel = data; + XEvent * xe = xevent; + XClientMessageEvent * xcme; + PanelMessage message; + + if(xe->type != ClientMessage) + return GDK_FILTER_CONTINUE; + xcme = &xe->xclient; + if(xcme->message_type != gdk_x11_get_xatom_by_name( + PANEL_CLIENT_MESSAGE)) + return GDK_FILTER_CONTINUE; + message = xcme->data.b[0]; + switch(message) + { + case PANEL_MESSAGE_SHOW: + if(xcme->data.b[1] == PANEL_MESSAGE_SHOW_SETTINGS) + panel_show_preferences(panel, TRUE); + break; + } + return GDK_FILTER_CONTINUE; +} + /* panel_delete */ void panel_delete(Panel * panel) diff --git a/src/project.conf b/src/project.conf index 7d57cb0..d729476 100644 --- a/src/project.conf +++ b/src/project.conf @@ -1,5 +1,5 @@ subdirs=applets -targets=panel,run +targets=panel,panel-settings,run cppflags_force=-I ../include #cppflags=-D EMBEDDED cflags_force=-W `pkg-config --cflags libSystem gtk+-2.0` @@ -23,6 +23,11 @@ depends=common.h,window.h,../include/Panel.h,../config.h [window.c] depends=common.h,window.h +[panel-settings] +type=binary +sources=settings.c +install=$(BINDIR) + [run] type=binary sources=run.c diff --git a/src/settings.c b/src/settings.c new file mode 100644 index 0000000..98d9f74 --- /dev/null +++ b/src/settings.c @@ -0,0 +1,58 @@ +/* $Id$ */ +/* Copyright (c) 2011 Pierre Pronchery */ +/* 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 . */ + + + +#include +#include +#include +#include +#include "common.h" + + +/* usage */ +static int _usage(void) +{ + fputs("Usage: panel-settings\n", stderr); + return 1; +} + + +/* main */ +int main(int argc, char * argv[]) +{ + int o; + GdkEvent event; + GdkEventClient * client = &event.client; + + gtk_init(&argc, &argv); + while((o = getopt(argc, argv, "")) != -1) + switch(o) + { + default: + return _usage(); + } + memset(&event, 0, sizeof(event)); + client->type = GDK_CLIENT_EVENT; + client->window = NULL; + client->send_event = TRUE; + client->message_type = gdk_atom_intern(PANEL_CLIENT_MESSAGE, FALSE); + client->data_format = 8; + client->data.b[0] = PANEL_MESSAGE_SHOW; + client->data.b[1] = PANEL_MESSAGE_SHOW_SETTINGS; + client->data.b[2] = TRUE; + gdk_event_send_clientmessage_toall(&event); + return 0; +}