Avoid using PROGNAME in the programs installed

This commit is contained in:
Pierre Pronchery 2018-02-10 15:29:57 +01:00
parent 01c36e5f8e
commit 5eefc9cbf6
4 changed files with 33 additions and 28 deletions

View File

@ -27,17 +27,17 @@
#define _(string) gettext(string) #define _(string) gettext(string)
/* constants */ /* constants */
#ifndef PROGNAME #ifndef PROGNAME_PANEL_EMBED
# define PROGNAME "panel-embed" # define PROGNAME_PANEL_EMBED "panel-embed"
#endif #endif
#ifndef PREFIX #ifndef PREFIX
# define PREFIX "/usr/local" # define PREFIX "/usr/local"
#endif #endif
#ifndef DATADIR #ifndef DATADIR
# define DATADIR PREFIX "/share" # define DATADIR PREFIX "/share"
#endif #endif
#ifndef LOCALEDIR #ifndef LOCALEDIR
# define LOCALEDIR DATADIR "/locale" # define LOCALEDIR DATADIR "/locale"
#endif #endif
@ -140,7 +140,7 @@ static void _embed_on_child(GPid pid, gint status, gpointer data)
/* error */ /* error */
static int _error(char const * message, int ret) static int _error(char const * message, int ret)
{ {
fprintf(stderr, "%s%s\n", PROGNAME ": ", message); fprintf(stderr, "%s%s\n", PROGNAME_PANEL_EMBED ": ", message);
return ret; return ret;
} }
@ -148,7 +148,8 @@ static int _error(char const * message, int ret)
/* usage */ /* usage */
static int _usage(void) static int _usage(void)
{ {
fprintf(stderr, _("Usage: %s command [arguments...]\n"), PROGNAME); fprintf(stderr, _("Usage: %s command [arguments...]\n"),
PROGNAME_PANEL_EMBED);
return 1; return 1;
} }

View File

@ -31,17 +31,17 @@
#define _(string) gettext(string) #define _(string) gettext(string)
/* constants */ /* constants */
#ifndef PROGNAME #ifndef PROGNAME_PANEL_MESSAGE
# define PROGNAME "panel-message" # define PROGNAME_PANEL_MESSAGE "panel-message"
#endif #endif
#ifndef PREFIX #ifndef PREFIX
# define PREFIX "/usr/local" # define PREFIX "/usr/local"
#endif #endif
#ifndef DATADIR #ifndef DATADIR
# define DATADIR PREFIX "/share" # define DATADIR PREFIX "/share"
#endif #endif
#ifndef LOCALEDIR #ifndef LOCALEDIR
# define LOCALEDIR DATADIR "/locale" # define LOCALEDIR DATADIR "/locale"
#endif #endif
@ -151,7 +151,7 @@ static gboolean _message_on_timeout(gpointer data)
/* error */ /* error */
static int _error(char const * message, int ret) static int _error(char const * message, int ret)
{ {
fputs(PROGNAME ": ", stderr); fputs(PROGNAME_PANEL_MESSAGE ": ", stderr);
perror(message); perror(message);
return ret; return ret;
} }
@ -161,7 +161,8 @@ static int _error(char const * message, int ret)
static int _usage(void) static int _usage(void)
{ {
fprintf(stderr, _("Usage: %s [-EIQW][-T title][-t timeout] message\n" fprintf(stderr, _("Usage: %s [-EIQW][-T title][-t timeout] message\n"
" %s [-N name][-T title][-t timeout] message\n"), PROGNAME, PROGNAME); " %s [-N name][-T title][-t timeout] message\n"), PROGNAME_PANEL_MESSAGE,
PROGNAME_PANEL_MESSAGE);
return 1; return 1;
} }

View File

@ -33,22 +33,23 @@
#define N_(string) string #define N_(string) string
/* constants */ /* constants */
#ifndef PROGNAME #ifndef PROGNAME_PANEL_NOTIFY
# define PROGNAME "panel-notify" # define PROGNAME_PANEL_NOTIFY "panel-notify"
#endif #endif
#define PROGNAME PROGNAME_PANEL_NOTIFY
#include "helper.c" #include "helper.c"
#ifndef PREFIX #ifndef PREFIX
# define PREFIX "/usr/local" # define PREFIX "/usr/local"
#endif #endif
#ifndef LIBDIR #ifndef LIBDIR
# define LIBDIR PREFIX "/lib" # define LIBDIR PREFIX "/lib"
#endif #endif
#ifndef DATADIR #ifndef DATADIR
# define DATADIR PREFIX "/share" # define DATADIR PREFIX "/share"
#endif #endif
#ifndef LOCALEDIR #ifndef LOCALEDIR
# define LOCALEDIR DATADIR "/locale" # define LOCALEDIR DATADIR "/locale"
#endif #endif
@ -84,7 +85,7 @@ static int _notify_embed(GtkIconSize iconsize, int timeout, char * applets[])
PANEL_WINDOW_TYPE_NOTIFICATION, iconsize); PANEL_WINDOW_TYPE_NOTIFICATION, iconsize);
for(i = 0; applets[i] != NULL; i++) for(i = 0; applets[i] != NULL; i++)
if(_panel_append(&panel, PANEL_POSITION_TOP, applets[i]) != 0) if(_panel_append(&panel, PANEL_POSITION_TOP, applets[i]) != 0)
error_print(PROGNAME); error_print(PROGNAME_PANEL_NOTIFY);
if((xid = _panel_get_xid(&panel)) == 0) if((xid = _panel_get_xid(&panel)) == 0)
/* XXX report error */ /* XXX report error */
return -1; return -1;
@ -105,7 +106,7 @@ static int _notify_panel(GtkIconSize iconsize, int timeout, char * applets[])
_panel_set_title(&panel, _("Notification")); _panel_set_title(&panel, _("Notification"));
for(i = 0; applets[i] != NULL; i++) for(i = 0; applets[i] != NULL; i++)
if(_panel_append(&panel, PANEL_POSITION_TOP, applets[i]) != 0) if(_panel_append(&panel, PANEL_POSITION_TOP, applets[i]) != 0)
error_print(PROGNAME); error_print(PROGNAME_PANEL_NOTIFY);
_panel_show(&panel, TRUE); _panel_show(&panel, TRUE);
if(timeout > 0) if(timeout > 0)
panel.timeout = g_timeout_add(timeout * 1000, panel.timeout = g_timeout_add(timeout * 1000,
@ -140,7 +141,8 @@ static int _usage(void)
" -X Use huge icons\n" " -X Use huge icons\n"
" -x Use icons the size of menus\n" " -x Use icons the size of menus\n"
" -t Time to wait before disappearing (0: unlimited)\n" " -t Time to wait before disappearing (0: unlimited)\n"
" -l Lists the plug-ins available\n"), PROGNAME, PROGNAME); " -l Lists the plug-ins available\n"), PROGNAME_PANEL_NOTIFY,
PROGNAME_PANEL_NOTIFY);
return 1; return 1;
} }

View File

@ -31,9 +31,10 @@
#define _(string) gettext(string) #define _(string) gettext(string)
#define N_(string) string #define N_(string) string
#ifndef PROGNAME #ifndef PROGNAME_PANEL_TEST
# define PROGNAME "panel-test" # define PROGNAME_PANEL_TEST "panel-test"
#endif #endif
#define PROGNAME PROGNAME_PANEL_TEST
#include "helper.c" #include "helper.c"
/* constants */ /* constants */
@ -71,7 +72,7 @@ static int _test(PanelWindowType type, PanelWindowPosition position,
_panel_set_title(&panel, "Applet tester"); _panel_set_title(&panel, "Applet tester");
for(i = 0; applets[i] != NULL; i++) for(i = 0; applets[i] != NULL; i++)
if(_panel_append(&panel, PANEL_POSITION_TOP, applets[i]) != 0) if(_panel_append(&panel, PANEL_POSITION_TOP, applets[i]) != 0)
error_print(PROGNAME); error_print(PROGNAME_PANEL_TEST);
_panel_show(&panel, TRUE); _panel_show(&panel, TRUE);
gtk_main(); gtk_main();
_panel_destroy(&panel); _panel_destroy(&panel);
@ -82,8 +83,8 @@ static int _test(PanelWindowType type, PanelWindowPosition position,
/* usage */ /* usage */
static int _usage(void) static int _usage(void)
{ {
fputs("Usage: " PROGNAME " [-C|-F|-M][-L|-S|-X|-x][-n] applet...\n" fputs("Usage: " PROGNAME_PANEL_TEST " [-C|-F|-M][-L|-S|-X|-x][-n] applet...\n"
" " PROGNAME " -l\n" " " PROGNAME_PANEL_TEST " -l\n"
" -l Lists the plug-ins available\n", stderr); " -l Lists the plug-ins available\n", stderr);
return 1; return 1;
} }