# include <unistd.h>
#endif
+#ifdef ENABLE_NLS
+# include <locale.h>
+#endif /* ENABLE_NLS */
+
#ifndef VMS
# include <pwd.h> /* for getpwuid() */
#else /* VMS */
char *vers = strdup (screensaver_id + 4);
char *s;
char copy[1024];
- char *desc = "For updates, check http://www.jwz.org/xscreensaver/";
+ char *desc = _("For updates, check http://www.jwz.org/xscreensaver/");
s = strchr (vers, ',');
*s = 0;
s += 2;
- sprintf(copy, "Copyright \251 1991-2002 %s", s);
+ sprintf(copy, _("Copyright \251 1991-2002 %s"), s);
sprintf (msg, "%s\n\n%s", copy, desc);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
hb, TRUE, TRUE, 0);
- ok = gtk_button_new_with_label ("OK");
+ ok = gtk_button_new_with_label (_("OK"));
gtk_container_add (GTK_CONTAINER (hb), ok);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
if (!p->help_url || !*p->help_url)
{
warning_dialog (s->toplevel_widget,
- "Error:\n\n"
- "No Help URL has been specified.\n", False, 100);
+ _("Error:\n\n"
+ "No Help URL has been specified.\n"), False, 100);
return;
}
Bool root_p = (geteuid () == 0);
strcpy (buf,
- "Error:\n\n"
- "The xscreensaver daemon did not start up properly.\n"
- "\n");
+ _("Error:\n\n"
+ "The xscreensaver daemon did not start up properly.\n"
+ "\n"));
if (root_p)
strcat (buf,
- "You are running as root. This usually means that xscreensaver\n"
+ _("You are running as root. This usually means that xscreensaver\n"
"was unable to contact your X server because access control is\n"
"turned on. Try running this command:\n"
"\n"
"manual and FAQ for more information.\n"
"\n"
"You shouldn't run X as root. Instead, you should log in as a\n"
- "normal user, and `su' as necessary.");
+ "normal user, and `su' as necessary."));
else
- strcat (buf, "Please check your $PATH and permissions.");
+ strcat (buf, _("Please check your $PATH and permissions."));
warning_dialog (s->toplevel_widget, buf, False, 1);
}
const char *f = init_file_name();
if (!f || !*f)
warning_dialog (s->toplevel_widget,
- "Error:\n\nCouldn't determine init file name!\n",
+ _("Error:\n\nCouldn't determine init file name!\n"),
False, 100);
else
{
char *b = (char *) malloc (strlen(f) + 1024);
- sprintf (b, "Error:\n\nCouldn't write %s\n", f);
+ sprintf (b, _("Error:\n\nCouldn't write %s\n"), f);
warning_dialog (s->toplevel_widget, b, False, 100);
free (b);
}
else
{
warning_dialog (GTK_WIDGET (button),
- "Error:\n\nno `manualCommand' resource set.",
+ _("Error:\n\nno `manualCommand' resource set."),
False, 100);
}
{
char b[255];
sprintf (b,
- "Error:\n\n"
- "Unparsable time format: \"%s\"\n",
+ _("Error:\n\n"
+ "Unparsable time format: \"%s\"\n"),
line);
warning_dialog (s->toplevel_widget, b, False, 100);
}
{
gdk_beep (); /* unparsable */
visual = "";
- gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (vis)->entry), "Any");
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (vis)->entry), _("Any"));
}
changed = flush_changes (s, list_elt, -1, command, visual);
if (!directory_p (path))
{
char b[255];
- sprintf (b, "Error:\n\n" "Directory does not exist: \"%s\"\n", path);
+ sprintf (b, _("Error:\n\n" "Directory does not exist: \"%s\"\n"), path);
warning_dialog (GTK_WIDGET (top), b, False, 100);
return;
}
saver_preferences *p = &s->prefs;
char str[100];
+ /* The file supports timeouts of less than a minute, but the GUI does
+ not, so throttle the values to be at least one minute (since "0" is
+ a bad rounding choice...)
+ */
+# define THROTTLE(NAME) if (p->NAME != 0 && p->NAME < 60000) p->NAME = 60000
+ THROTTLE (timeout);
+ THROTTLE (cycle);
+ THROTTLE (passwd_timeout);
+# undef THROTTLE
+
# define FMT_MINUTES(NAME,N) \
- sprintf (str, "%d", ((N) + 59) / (60 * 1000)); \
+ sprintf (str, "%d", (((N / 1000) + 59) / 60)); \
gtk_entry_set_text (GTK_ENTRY (name_to_widget (s, (NAME))), str)
# define FMT_SECONDS(NAME,N) \
screenhack *hack = (hack_number >= 0 ? p->screenhacks[hack_number] : 0);
char *doc_string = 0;
+ /* #### not in Gtk 1.2
+ gtk_label_set_selectable (doc);
+ */
+
# ifdef HAVE_XML
if (s->cdata)
{
? s->cdata->description
: 0);
# else /* !HAVE_XML */
- doc_string = "Descriptions not available: no XML support compiled in.";
+ doc_string = _("Descriptions not available: no XML support compiled in.");
# endif /* !HAVE_XML */
gtk_label_set_text (doc, (doc_string
- ? doc_string
- : "No description available."));
+ ? _(doc_string)
+ : _("No description available.")));
}
if (p->mode == BLANK_ONLY)
{
hack = 0;
- pretty_name = strdup ("Blank Screen");
+ pretty_name = strdup (_("Blank Screen"));
schedule_preview (s, 0);
}
else if (p->mode == DONT_BLANK)
{
hack = 0;
- pretty_name = strdup ("Screen Saver Disabled");
+ pretty_name = strdup (_("Screen Saver Disabled"));
schedule_preview (s, 0);
}
else
}
if (!pretty_name)
- pretty_name = strdup ("Preview");
+ pretty_name = strdup (_("Preview"));
gtk_frame_set_label (frame1, pretty_name);
gtk_frame_set_label (frame2, pretty_name);
(hack
? (hack->visual && *hack->visual
? hack->visual
- : "Any")
+ : _("Any"))
: ""));
sensitize_demo_widgets (s, (hack ? True : False));
if (!f || !*f) return 0;
b = (char *) malloc (strlen(f) + 1024);
sprintf (b,
- "Warning:\n\n"
- "file \"%s\" has changed, reloading.\n",
+ _("Warning:\n\n"
+ "file \"%s\" has changed, reloading.\n"),
f);
warning_dialog (s->toplevel_widget, b, False, 100);
free (b);
if (s->running_preview_error_p)
{
- const char * const lines[] = { "No Preview", "Available" };
+ const char * const lines[] = { N_("No Preview"), N_("Available") };
int lh = p->style->font->ascent + p->style->font->descent;
int y, i;
gint w, h;
y += p->style->font->ascent;
for (i = 0; i < countof(lines); i++)
{
- int sw = gdk_string_width (p->style->font, lines[i]);
+ int sw = gdk_string_width (p->style->font, _(lines[i]));
int x = (w - sw) / 2;
gdk_draw_string (window, p->style->font,
p->style->fg_gc[GTK_STATE_NORMAL],
- x, y, lines[i]);
+ x, y, _(lines[i]));
y += lh;
}
}
{
saver_preferences *p = &s->prefs;
Window id;
- char *new_cmd;
+ char *new_cmd = 0;
pid_t forked;
const char *cmd = s->desired_preview_cmd;
if (s->preview_suppressed_p)
{
kill_preview_subproc (s);
- return;
+ goto DONE;
}
new_cmd = malloc (strlen (cmd) + 40);
{
s->running_preview_error_p = True;
clear_preview_window (s);
- return;
+ goto DONE;
}
switch ((int) (forked = fork ()))
sprintf (buf, "%s: couldn't fork", blurb());
perror (buf);
s->running_preview_error_p = True;
- return;
+ goto DONE;
+ break;
}
case 0:
{
}
schedule_preview_check (s);
+
+ DONE:
+ if (new_cmd) free (new_cmd);
+ new_cmd = 0;
}
if (s->debug_p)
fprintf (stderr, "%s: %s\n", blurb(), ndpy);
+ /* don't free(ndpy) -- some implementations of putenv (BSD 4.4, glibc
+ 2.0) copy the argument, but some (libc4,5, glibc 2.1.2) do not.
+ So we must leak it (and/or the previous setting). Yay.
+ */
+
if (def_path && *def_path)
{
const char *opath = getenv("PATH");
if (putenv (npath))
abort ();
+ /* do not free(npath) -- see above */
if (s->debug_p)
fprintf (stderr, "%s: added \"%s\" to $PATH\n", blurb(), def_path);
the_network_is_not_the_computer (state *s)
{
Display *dpy = GDK_DISPLAY();
- char *rversion, *ruser, *rhost;
+ char *rversion = 0, *ruser = 0, *rhost = 0;
char *luser, *lhost;
char *msg = 0;
struct passwd *p = getpwuid (getuid ());
if (!rversion || !*rversion)
{
sprintf (msg,
- "Warning:\n\n"
- "The XScreenSaver daemon doesn't seem to be running\n"
- "on display \"%s\". Launch it now?",
+ _("Warning:\n\n"
+ "The XScreenSaver daemon doesn't seem to be running\n"
+ "on display \"%s\". Launch it now?"),
d);
}
else if (p && ruser && *ruser && !!strcmp (ruser, p->pw_name))
/* Warn that the two processes are running as different users.
*/
sprintf(msg,
- "Warning:\n\n"
+ _("Warning:\n\n"
"%s is running as user \"%s\" on host \"%s\".\n"
"But the xscreensaver managing display \"%s\"\n"
"is running as user \"%s\" on host \"%s\".\n"
"You should either re-run %s as \"%s\", or re-run\n"
"xscreensaver as \"%s\".\n"
"\n"
- "Restart the xscreensaver daemon now?\n",
+ "Restart the xscreensaver daemon now?\n"),
blurb(), luser, lhost,
d,
(ruser ? ruser : "???"), (rhost ? rhost : "???"),
/* Warn that the two processes are running on different hosts.
*/
sprintf (msg,
- "Warning:\n\n"
+ _("Warning:\n\n"
"%s is running as user \"%s\" on host \"%s\".\n"
"But the xscreensaver managing display \"%s\"\n"
"is running as user \"%s\" on host \"%s\".\n"
"if they don't see the same ~%s/.xscreensaver file) then\n"
"%s won't work right.\n"
"\n"
- "Restart the daemon on \"%s\" as \"%s\" now?\n",
+ "Restart the daemon on \"%s\" as \"%s\" now?\n"),
blurb(), luser, lhost,
d,
(ruser ? ruser : "???"), (rhost ? rhost : "???"),
/* Warn that the version numbers don't match.
*/
sprintf (msg,
- "Warning:\n\n"
+ _("Warning:\n\n"
"This is %s version %s.\n"
"But the xscreensaver managing display \"%s\"\n"
"is version %s. This could cause problems.\n"
- "\n"
- "Restart the xscreensaver daemon now?\n",
- blurb(), s->short_version,
+ "\n"
+ "Restart the xscreensaver daemon now?\n"),
+ progname, s->short_version,
d,
rversion);
}
if (*msg)
warning_dialog (s->toplevel_widget, msg, True, 1);
+ if (rversion) free (rversion);
+ if (ruser) free (ruser);
+ if (rhost) free (rhost);
free (msg);
}
{
state *s = global_state_kludge; /* I hate C so much... */
fprintf (stderr, "\nX error in %s:\n", blurb());
- if (XmuPrintDefaultErrorMessage (dpy, error, stderr))
- {
- kill_preview_subproc (s);
- exit (-1);
- }
- else
- fprintf (stderr, " (nonfatal.)\n");
+ XmuPrintDefaultErrorMessage (dpy, error, stderr);
+ kill_preview_subproc (s);
+ exit (-1);
return 0;
}
# ifdef HAVE_CRAPPLET
" [--crapplet]"
# endif
- " [--debug]";
-
+ "\n\t\t [--debug] [--sync] [--no-xshm]";
static void
map_popup_window_cb (GtkWidget *w, gpointer user_data)
Bool crapplet_p = False;
char *str;
+#ifdef ENABLE_NLS
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+
+# ifdef HAVE_GTK2
+ bindtextdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+# else /* ! HAVE_GTK2 */
+ if (!setlocale (LC_ALL, ""))
+ fprintf (stderr, "%s: locale not supported by C library\n", real_progname);
+# endif /* ! HAVE_GTK2 */
+
+#endif /* ENABLE_NLS */
+
str = strrchr (real_progname, '/');
if (str) real_progname = str+1;
}
#ifdef DEFAULT_ICONDIR /* from -D on compile line */
- add_pixmap_directory (DEFAULT_ICONDIR);
+ {
+ const char *dir = DEFAULT_ICONDIR;
+ if (*dir) add_pixmap_directory (dir);
+ }
#endif
/* This is gross, but Gtk understands --display and not -display...
;
else
{
- fprintf (stderr, "%s: unknown option: %s\n", real_progname, argv[i]);
+ fprintf (stderr, _("%s: unknown option: %s\n"), real_progname, argv[i]);
fprintf (stderr, "%s: %s\n", real_progname, usage);
exit (1);
}