The "panelctl" tool can also hide or show individual panels

This commit is contained in:
Pierre Pronchery 2011-11-07 22:32:00 +00:00
parent 2353525414
commit d77e986020
13 changed files with 107 additions and 54 deletions

View File

@ -68,7 +68,7 @@ dist:
$(PACKAGE)-$(VERSION)/src/panelctl.c \
$(PACKAGE)-$(VERSION)/src/run.c \
$(PACKAGE)-$(VERSION)/src/Makefile \
$(PACKAGE)-$(VERSION)/src/common.h \
$(PACKAGE)-$(VERSION)/src/panel.h \
$(PACKAGE)-$(VERSION)/src/window.h \
$(PACKAGE)-$(VERSION)/src/project.conf \
$(PACKAGE)-$(VERSION)/src/applets/battery.c \

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Panel 0.0.5\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-11-07 23:03+0100\n"
"POT-Creation-Date: 2011-11-07 23:29+0100\n"
"PO-Revision-Date: 2010-04-22 12:45+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n"
@ -21,7 +21,7 @@ msgstr ""
msgid "Unknown"
msgstr "Inconnu"
#: ../src/applets/battery.c:185 ../src/panel.c:454 ../src/panel.c:459
#: ../src/applets/battery.c:185 ../src/panel.c:464 ../src/panel.c:469
#: ../src/run.c:214 ../src/run.c:220
msgid "Error"
msgstr "Erreur"
@ -108,8 +108,8 @@ msgstr "Verrouiller l'écran"
msgid "Logging out is disabled"
msgstr "Se déconnecter est désactivé"
#: ../src/applets/logout.c:69 ../src/panel.c:1318 ../src/panel.c:1325
#: ../src/panel.c:1334
#: ../src/applets/logout.c:69 ../src/panel.c:1328 ../src/panel.c:1335
#: ../src/panel.c:1344
msgid "Logout"
msgstr "Déconnexion"
@ -191,13 +191,13 @@ msgstr "Périphérique réseau USB connecté"
#: ../src/main.c:46
msgid ""
"Usage: panel [-m monitor][-bBsStx]\n"
"Usage: panel [-m monitor][-lsx]\n"
" -l\tUse icons the size of a large toolbar\n"
" -m\tMonitor to use (default: 0)\n"
" -s\tUse icons the size of a small toolbar\n"
" -x\tUse icons the size of menus\n"
msgstr ""
"Usage: panel [-m moniteur][-bBsStx]\n"
"Usage: panel [-m moniteur][-lsx]\n"
" -l\tIcônes de la taille d'une grosse barre d'outils\n"
" -m\tMoniteur à utiliser (par défaut : 0)\n"
" -s\tIcônes de la taille d'une petite barre d'outils\n"
@ -215,35 +215,35 @@ msgstr "Petite"
msgid "Smaller"
msgstr "Très petite"
#: ../src/panel.c:571
#: ../src/panel.c:581
msgid "Panel preferences"
msgstr "Préférences du Panel"
#: ../src/panel.c:585
#: ../src/panel.c:595
msgid "General"
msgstr "Général"
#: ../src/panel.c:614
#: ../src/panel.c:624
msgid "Applets:"
msgstr "Greffons :"
#: ../src/panel.c:689
#: ../src/panel.c:699
msgid "Top panel:"
msgstr "Panneau supérieur :"
#: ../src/panel.c:695 ../src/panel.c:699 ../src/panel.c:730 ../src/panel.c:734
#: ../src/panel.c:705 ../src/panel.c:709 ../src/panel.c:740 ../src/panel.c:744
msgid "Default"
msgstr "Par défaut"
#: ../src/panel.c:724
#: ../src/panel.c:734
msgid "Bottom panel:"
msgstr "Panneau inférieur :"
#: ../src/panel.c:1257
#: ../src/panel.c:1267
msgid "translator-credits"
msgstr "Pierre Pronchery <khorben@defora.org>"
#: ../src/panel.c:1304
#: ../src/panel.c:1314
msgid ""
"This will log you out of the current session, therefore closing any "
"application currently opened and losing any unsaved data.\n"
@ -254,7 +254,7 @@ msgstr ""
"sauvegardées.\n"
"Voulez-vous continuer?"
#: ../src/panel.c:1420
#: ../src/panel.c:1430
msgid ""
"This will shutdown your device, therefore closing any application currently "
"opened and losing any unsaved data.\n"
@ -265,7 +265,7 @@ msgstr ""
"sauvegardées.\n"
"Voulez-vous continuer?"
#: ../src/panel.c:1425
#: ../src/panel.c:1435
msgid ""
"This will shutdown your computer, therefore closing any application "
"currently opened and losing any unsaved data.\n"
@ -276,20 +276,29 @@ msgstr ""
"sauvegardées.\n"
"Voulez-vous continuer?"
#: ../src/panel.c:1439 ../src/panel.c:1446 ../src/panel.c:1455
#: ../src/panel.c:1449 ../src/panel.c:1456 ../src/panel.c:1465
msgid "Shutdown"
msgstr "Arrêter"
#: ../src/panel.c:1445
#: ../src/panel.c:1455
msgid "Restart"
msgstr "Redémarrer"
#: ../src/panelctl.c:71
msgid ""
"Usage: panelctl -S\n"
"Usage: panelctl [-B|-S|-T|-b|-t]\n"
" -B\tShow the bottom panel\n"
" -S\tDisplay or change settings\n"
msgstr "Usage: panelctl -S\n"
" -T\tShow the top panel\n"
" -b\tHide the bottom panel\n"
" -t\tHide the top panel\n"
msgstr ""
"Usage: panelctl [-B|-S|-T|-b|-t]\n"
" -B\tAfficher le panel du bas\n"
" -S\tAfficher ou modifier les préférences\n"
" -T\tAfficher le panel du haut\n"
" -b\tMasquer le panel du bas\n"
" -t\tMasquer le panel du haut\n"
#: ../src/run.c:102 ../src/run.c:114
msgid "Run program..."
@ -323,6 +332,6 @@ msgstr "Permissions insuffisantes"
msgid "Usage: run\n"
msgstr "Usage: run\n"
#: ../src/window.c:63
#: ../src/window.c:62
msgid "Invalid panel size"
msgstr "Taille invalide pour le panel"

View File

@ -40,13 +40,13 @@ run_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) `pkg-config --libs libSystem gtk+-2.0`
run: $(run_OBJS)
$(CC) -o run $(run_OBJS) $(run_LDFLAGS)
panel.o: panel.c common.h window.h ../include/Panel.h ../config.h
panel.o: panel.c panel.h window.h ../include/Panel.h ../config.h
$(CC) $(panel_CFLAGS) -c panel.c
window.o: window.c common.h window.h
window.o: window.c panel.h window.h
$(CC) $(panel_CFLAGS) -c window.c
main.o: main.c common.h ../config.h
main.o: main.c panel.h ../config.h
$(CC) $(panel_CFLAGS) -c main.c
panelctl.o: panelctl.c ../config.h

View File

@ -23,7 +23,7 @@
#include <locale.h>
#include <libintl.h>
#include <gtk/gtk.h>
#include "common.h"
#include "panel.h"
#include "../config.h"
#define _(string) gettext(string)
@ -43,7 +43,7 @@
/* usage */
static int _usage(void)
{
fputs(_("Usage: panel [-m monitor][-bBsStx]\n"
fputs(_("Usage: panel [-m monitor][-lsx]\n"
" -l Use icons the size of a large toolbar\n"
" -m Monitor to use (default: 0)\n"
" -s Use icons the size of a small toolbar\n"

View File

@ -37,7 +37,7 @@ static char const _license[] =
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "window.h"
#include "common.h"
#include "panel.h"
#include "../config.h"
#define _(string) gettext(string)
#define N_(string) (string)
@ -394,6 +394,8 @@ static GdkFilterReturn _event_client_message(XClientMessageEvent * xevent,
Panel * panel)
{
PanelMessage message;
PanelMessageShow what;
gboolean show;
if(xevent->message_type != gdk_x11_get_xatom_by_name(
PANEL_CLIENT_MESSAGE))
@ -402,8 +404,16 @@ static GdkFilterReturn _event_client_message(XClientMessageEvent * xevent,
switch(message)
{
case PANEL_MESSAGE_SHOW:
if(xevent->data.b[1] == PANEL_MESSAGE_SHOW_SETTINGS)
panel_show_preferences(panel, TRUE);
what = xevent->data.b[1];
show = xevent->data.b[2];
if(what == PANEL_MESSAGE_SHOW_PANEL_BOTTOM
&& panel->bottom != NULL)
panel_window_show(panel->bottom, show);
else if(what == PANEL_MESSAGE_SHOW_PANEL_TOP
&& panel->top != NULL)
panel_window_show(panel->top, show);
else if(what == PANEL_MESSAGE_SHOW_SETTINGS)
panel_show_preferences(panel, show);
break;
}
return GDK_FILTER_CONTINUE;

View File

@ -31,7 +31,9 @@ typedef enum _PanelMessage
typedef enum _PanelMessageShow
{
PANEL_MESSAGE_SHOW_SETTINGS = 0
PANEL_MESSAGE_SHOW_PANEL_BOTTOM = 0,
PANEL_MESSAGE_SHOW_PANEL_TOP,
PANEL_MESSAGE_SHOW_SETTINGS
} PanelMessageShow;
typedef enum _PanelPosition

View File

@ -21,7 +21,7 @@
#include <locale.h>
#include <libintl.h>
#include <gtk/gtk.h>
#include "common.h"
#include "panel.h"
#include "../config.h"
#define _(string) gettext(string)
@ -41,12 +41,12 @@
/* panelctl */
/* private */
/* prototypes */
static int _panelctl(PanelMessageShow show);
static int _panelctl(PanelMessageShow what, gboolean show);
static int _usage(void);
/* functions */
static int _panelctl(PanelMessageShow show)
static int _panelctl(PanelMessageShow what, gboolean show)
{
GdkEvent event;
GdkEventClient * client = &event.client;
@ -58,8 +58,8 @@ static int _panelctl(PanelMessageShow show)
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] = show;
client->data.b[2] = TRUE;
client->data.b[1] = what;
client->data.b[2] = show;
gdk_event_send_clientmessage_toall(&event);
return 0;
}
@ -68,8 +68,12 @@ static int _panelctl(PanelMessageShow show)
/* usage */
static int _usage(void)
{
fputs(_("Usage: panelctl -S\n"
" -S Display or change settings\n"), stderr);
fputs(_("Usage: panelctl [-B|-S|-T|-b|-t]\n"
" -B Show the bottom panel\n"
" -S Display or change settings\n"
" -T Show the top panel\n"
" -b Hide the bottom panel\n"
" -t Hide the top panel\n"), stderr);
return 1;
}
@ -80,22 +84,40 @@ static int _usage(void)
int main(int argc, char * argv[])
{
int o;
int show = -1;
int what = -1;
gboolean show = TRUE;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
gtk_init(&argc, &argv);
while((o = getopt(argc, argv, "S")) != -1)
while((o = getopt(argc, argv, "BSTbt")) != -1)
switch(o)
{
case 'B':
what = PANEL_MESSAGE_SHOW_PANEL_BOTTOM;
show = TRUE;
break;
case 'S':
show = PANEL_MESSAGE_SHOW_SETTINGS;
what = PANEL_MESSAGE_SHOW_SETTINGS;
show = TRUE;
break;
case 'T':
what = PANEL_MESSAGE_SHOW_PANEL_TOP;
show = TRUE;
break;
case 'b':
what = PANEL_MESSAGE_SHOW_PANEL_BOTTOM;
show = FALSE;
break;
case 't':
what = PANEL_MESSAGE_SHOW_PANEL_TOP;
show = FALSE;
break;
default:
return _usage();
}
if(argc != optind || show < 0)
if(argc != optind || what < 0)
return _usage();
return (_panelctl(show) == 0) ? 0 : 2;
return (_panelctl(what, show) == 0) ? 0 : 2;
}

View File

@ -4,7 +4,7 @@ cppflags_force=-I ../include
#cppflags=-D EMBEDDED
cflags_force=-W
cflags=-Wall -g -O2 -pedantic
dist=Makefile,common.h,window.h
dist=Makefile,panel.h,window.h
[panel]
type=binary
@ -15,13 +15,13 @@ ldflags=`pkg-config --libs libSystem libDesktop`
install=$(BINDIR)
[main.c]
depends=common.h,../config.h
depends=panel.h,../config.h
[panel.c]
depends=common.h,window.h,../include/Panel.h,../config.h
depends=panel.h,window.h,../include/Panel.h,../config.h
[window.c]
depends=common.h,window.h
depends=panel.h,window.h
[panelctl]
type=binary

View File

@ -19,7 +19,6 @@
#include <string.h>
#include <libintl.h>
#include <gtk/gtk.h>
#include "common.h"
#include "window.h"
#define _(string) gettext(string)
#define N_(string) (string)
@ -130,6 +129,16 @@ void panel_window_reset(PanelWindow * panel, PanelPosition position,
}
/* panel_window_show */
void panel_window_show(PanelWindow * panel, gboolean show)
{
if(show)
gtk_widget_show(panel->window);
else
gtk_widget_hide(panel->window);
}
/* private */
/* functions */
/* panel_window_reset */

View File

@ -18,7 +18,7 @@
#ifndef PANEL_WINDOW_H
# define PANEL_WINDOW_H
# include "common.h"
# include "panel.h"
/* PanelWindow */
@ -39,5 +39,6 @@ void panel_window_append(PanelWindow * panel, GtkWidget * widget,
gboolean expand, gboolean fill);
void panel_window_reset(PanelWindow * panel, PanelPosition position,
GdkRectangle * root);
void panel_window_show(PanelWindow * panel, gboolean show);
#endif /* !PANEL_WINDOW_H */

View File

@ -3,7 +3,7 @@ PREFIX = /usr/local
DESTDIR =
BINDIR = $(PREFIX)/bin
CC ?= cc
CPPFLAGSF= -I ../include
CPPFLAGSF= -I ../include -I ../src
CPPFLAGS?=
CFLAGSF = -W `pkg-config --cflags libSystem gtk+-2.0`
CFLAGS = -Wall -g -O2
@ -23,7 +23,7 @@ panel_test_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
panel_test: $(panel_test_OBJS)
$(CC) -o panel_test $(panel_test_OBJS) $(panel_test_LDFLAGS)
test.o: test.c ../src/common.h ../config.h
test.o: test.c ../src/panel.h ../config.h
$(CC) $(panel_test_CFLAGS) -c test.c
clean:

View File

@ -1,5 +1,5 @@
targets=panel_test
cppflags_force=-I ../include
cppflags_force=-I ../include -I ../src
cflags_force=-W `pkg-config --cflags libSystem gtk+-2.0`
cflags=-Wall -g -O2
ldflags_force=`pkg-config --libs libSystem gtk+-2.0`
@ -12,4 +12,4 @@ sources=test.c
install=$(BINDIR)
[test.c]
depends=../src/common.h,../config.h
depends=../src/panel.h,../config.h

View File

@ -26,7 +26,7 @@
#include <gtk/gtk.h>
#include <System.h>
#include "Panel.h"
#include "../src/common.h"
#include "panel.h"
#include "../config.h"