r538 - trunk
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Mar 2 01:22:09 EST 2008
Author: icculus
Date: 2008-03-02 01:22:08 -0500 (Sun, 02 Mar 2008)
New Revision: 538
Modified:
trunk/gui.h
trunk/gui_gtkplus2.c
trunk/gui_macosx.c
trunk/gui_ncurses.c
trunk/gui_stdio.c
trunk/gui_www.c
Log:
Cleaned up the entry-> spam in the GUI plugins.
Modified: trunk/gui.h
===================================================================
--- trunk/gui.h 2008-03-02 06:18:26 UTC (rev 537)
+++ trunk/gui.h 2008-03-02 06:22:08 UTC (rev 538)
@@ -116,13 +116,6 @@
void MojoGui_deinitGuiPlugin(void);
#else
-// can't use normal STUBBED in gui plugins, since it references logDebug
-// without entry-> ...
-#ifndef DOXYGEN_SHOULD_IGNORE_THIS
-#undef STUBBED
-#define STUBBED(x) STUBBED2(entry->,x)
-#endif
-
__EXPORT__ const MojoGui *MOJOGUI_ENTRY_POINT(int revision,
const MojoSetupEntryPoints *e);
@@ -191,9 +184,74 @@
return MojoGuiPlugin_##module(rev, e); \
} \
+
+// Redefine things that need to go through the plugin entry point interface,
+// so plugins calling into the MojoSetup core can use the same code as the
+// rest of the app.
+
+#ifdef _
+#undef _
#endif
+#define _(x) entry->translate(x)
+#ifdef xmalloc
+#undef xmalloc
+#endif
+#define xmalloc(x) entry->xmalloc(x)
+#ifdef xrealloc
+#undef xrealloc
+#endif
+#define xrealloc(x,y) entry->xrealloc(x,y)
+
+#ifdef xstrdup
+#undef xstrdup
+#endif
+#define xstrdup(x) entry->xstrdup(x)
+
+#ifdef xstrncpy
+#undef xstrncpy
+#endif
+#define xstrncpy(x,y,z) entry->xstrcpy(x,y,z)
+
+#ifdef logWarning
+#undef logWarning
+#endif
+#define logWarning entry->logWarning
+
+#ifdef logError
+#undef logError
+#endif
+#define logError entry->logError
+
+#ifdef logInfo
+#undef logInfo
+#endif
+#define logInfo entry->logInfo
+
+#ifdef logDebug
+#undef logDebug
+#endif
+#define logDebug entry->logDebug
+
+#ifdef format
+#undef format
+#endif
+#define format entry->format
+
+#ifdef numstr
+#undef numstr
+#endif
+#define numstr(x) entry->numstr(x)
+
+#ifdef ticks
+#undef ticks
+#endif
+#define ticks() entry->ticks()
+
+#endif
+
+
/*
* make some decisions about which GUI plugins to build...
* We list them all here, but some are built, some aren't. Some are DLLs,
Modified: trunk/gui_gtkplus2.c
===================================================================
--- trunk/gui_gtkplus2.c 2008-03-02 06:18:26 UTC (rev 537)
+++ trunk/gui_gtkplus2.c 2008-03-02 06:22:08 UTC (rev 538)
@@ -27,14 +27,16 @@
CREATE_MOJOGUI_ENTRY_POINT(gtkplus2)
#endif
+#undef format
#include <gtk/gtk.h>
+#define format entry->format
typedef enum
{
PAGE_INTRO,
PAGE_README,
PAGE_OPTIONS,
- PAGE_DESTINATION,
+ PAGE_DEST,
PAGE_PROGRESS,
PAGE_FINAL
} WizardPages;
@@ -99,8 +101,8 @@
gtk_main_iteration();
if (click_value == CLICK_CANCEL)
{
- char *title = entry->xstrdup(entry->_("Cancel installation"));
- char *text = entry->xstrdup(entry->_("Are you sure you want to cancel installation?"));
+ char *title = xstrdup(_("Cancel installation"));
+ char *text = xstrdup(_("Are you sure you want to cancel installation?"));
if (!MojoGui_gtkplus2_promptyn(title, text, false))
click_value = CLICK_NONE;
free(title);
@@ -162,7 +164,7 @@
static void signal_browse_clicked(GtkButton *_button, gpointer data)
{
GtkWidget *dialog = gtk_file_chooser_dialog_new (
- entry->_("Destination"),
+ _("Destination"),
NULL,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -198,7 +200,7 @@
static void signal_dest_changed(GtkComboBox *combo, gpointer user_data)
{
// Disable the forward button when the destination entry is blank.
- if ((currentpage == PAGE_DESTINATION) && (canfwd))
+ if ((currentpage == PAGE_DEST) && (canfwd))
{
gchar *str = gtk_combo_box_get_active_text(combo);
const gboolean filled_in = ((str != NULL) && (*str != '\0'));
@@ -225,7 +227,7 @@
char **tmpargv = args;
if (!gtk_init_check(&tmpargc, &tmpargv))
{
- entry->logInfo("gtkplus2: gtk_init_check() failed, use another UI.");
+ logInfo("gtkplus2: gtk_init_check() failed, use another UI.");
return false;
} // if
return true;
@@ -292,8 +294,8 @@
static void promptynanButtonCallback(GtkWidget *_msgbox)
{
- char *always = entry->xstrdup(entry->_("_Always"));
- char *never = entry->xstrdup(entry->_("N_ever"));
+ char *always = xstrdup(_("_Always"));
+ char *never = xstrdup(_("N_ever"));
gtk_dialog_add_buttons(GTK_DIALOG(_msgbox),
GTK_STOCK_YES, GTK_RESPONSE_YES,
GTK_STOCK_NO, GTK_RESPONSE_NO,
@@ -362,7 +364,7 @@
if ((splash->rgba == NULL) || (splashlen == 0))
return NULL;
- rgba = (guchar *) entry->xmalloc(splashlen);
+ rgba = (guchar *) xmalloc(splashlen);
memcpy(rgba, splash->rgba, splashlen);
pixbuf = gdk_pixbuf_new_from_data(rgba, GDK_COLORSPACE_RGB, TRUE, 8,
splash->w, splash->h, splash->w * 4,
@@ -462,10 +464,10 @@
gtk_button_box_set_spacing(GTK_BUTTON_BOX (widget), 6);
box = widget;
- cancel = create_button(box, "gtk-cancel", entry->_("Cancel"), signal_clicked);
- back = create_button(box, "gtk-go-back", entry->_("Back"), signal_clicked);
- next = create_button(box, "gtk-go-forward", entry->_("Next"), signal_clicked);
- finish = create_button(box, "gtk-goto-last", entry->_("Finish"), signal_clicked);
+ cancel = create_button(box, "gtk-cancel", _("Cancel"), signal_clicked);
+ back = create_button(box, "gtk-go-back", _("Back"), signal_clicked);
+ next = create_button(box, "gtk-go-forward", _("Next"), signal_clicked);
+ finish = create_button(box, "gtk-goto-last", _("Finish"), signal_clicked);
gtk_widget_hide(finish);
// !!! FIXME: intro page.
@@ -503,7 +505,7 @@
gtk_widget_show(box);
hbox = gtk_hbox_new (FALSE, 6);
- widget = gtk_label_new(entry->_("Folder:"));
+ widget = gtk_label_new(_("Folder:"));
gtk_widget_show(widget);
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_CENTER);
@@ -515,7 +517,7 @@
gtk_container_add(GTK_CONTAINER(alignment), destination);
gtk_box_pack_start(GTK_BOX(hbox), alignment, TRUE, TRUE, 0);
browse = create_button(hbox, "gtk-open",
- entry->_("B_rowse..."), signal_browse_clicked);
+ _("B_rowse..."), signal_browse_clicked);
gtk_widget_show_all (hbox);
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(notebook), box);
@@ -736,10 +738,7 @@
gtk_box_pack_start(GTK_BOX(page), box, FALSE, FALSE, 0);
build_options(opts, box, TRUE);
-
- retval = run_wizard(entry->_("Options"), PAGE_OPTIONS,
- can_back, can_fwd, true);
-
+ retval = run_wizard(_("Options"), PAGE_OPTIONS, can_back, can_fwd, true);
gtk_widget_destroy(box);
return retval;
} // MojoGui_gtkplus2_options
@@ -758,15 +757,14 @@
gtk_combo_box_prepend_text(combo, recommends[i]);
gtk_combo_box_set_active (combo, 0);
- *command = run_wizard(entry->_("Destination"), PAGE_DESTINATION,
- can_back, can_fwd, true);
+ *command = run_wizard(_("Destination"),PAGE_DEST,can_back,can_fwd,true);
str = gtk_combo_box_get_active_text(combo);
// shouldn't ever be empty ("next" should be disabled in that case).
assert( (*command <= 0) || ((str != NULL) && (*str != '\0')) );
- retval = entry->xstrdup(str);
+ retval = xstrdup(str);
g_free(str);
for (i = recnum-1; i >= 0; i--)
@@ -781,10 +779,10 @@
gint rc = 0;
// !!! FIXME: Use stock GTK icon for "media"?
// !!! FIXME: better text.
- const char *title = entry->xstrdup(entry->_("Media change"));
+ const char *title = xstrdup(_("Media change"));
// !!! FIXME: better text.
- const char *fmt = entry->xstrdup(entry->_("Please insert '%0'"));
- const char *text = entry->format(fmt, medianame);
+ const char *fmt = xstrdup(_("Please insert '%0'"));
+ const char *text = format(fmt, medianame);
rc = do_msgbox(title, text, GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, NULL);
free((void *) text);
@@ -805,7 +803,7 @@
boolean can_cancel)
{
static uint32 lastTicks = 0;
- const uint32 ticks = entry->ticks();
+ const uint32 ticks = ticks();
int rc;
if ((ticks - lastTicks) > 200) // just not to spam this...
@@ -833,7 +831,7 @@
gtk_widget_hide(next);
gtk_widget_show(finish);
gtk_label_set_text(GTK_LABEL(finallabel), msg);
- run_wizard(entry->_("Finish"), PAGE_FINAL, false, true, false);
+ run_wizard(_("Finish"), PAGE_FINAL, false, true, false);
} // MojoGui_gtkplus2_final
// end of gui_gtkplus2.c ...
Modified: trunk/gui_macosx.c
===================================================================
--- trunk/gui_macosx.c 2008-03-02 06:18:26 UTC (rev 537)
+++ trunk/gui_macosx.c 2008-03-02 06:22:08 UTC (rev 538)
@@ -133,7 +133,7 @@
static boolean MojoGui_macosx_promptyn(const char *title, const char *text,
boolean defval)
{
- return do_prompt(title, text, defval, entry->_("Yes"), entry->_("No"));
+ return do_prompt(title, text, defval, _("Yes"), _("No"));
} // MojoGui_macosx_promptyn
@@ -183,7 +183,7 @@
// !!! FIXME: write me.
STUBBED("macosx destination");
*command = 1;
- return entry->xstrdup("/Applications");
+ return xstrdup("/Applications");
} // MojoGui_macosx_destination
@@ -191,8 +191,7 @@
{
// !!! FIXME: "please insert '%s' ..."
// !!! FIXME: localization.
- return do_prompt("Please insert", medianame, true,
- entry->_("OK"), entry->_("Cancel"));
+ return do_prompt("Please insert", medianame, true, _("OK"), _("Cancel"));
} // MojoGui_macosx_insertmedia
Modified: trunk/gui_ncurses.c
===================================================================
--- trunk/gui_ncurses.c 2008-03-02 06:18:26 UTC (rev 537)
+++ trunk/gui_ncurses.c 2008-03-02 06:22:08 UTC (rev 538)
@@ -111,10 +111,9 @@
if ((ch == '\r') || (ch == '\n'))
{
count++;
- retval = (char **) entry->xrealloc(retval,
- count * sizeof (char *));
+ retval = (char **) xrealloc(retval, count * sizeof (char *));
text[i] = '\0';
- retval[count-1] = entry->xstrdup(text);
+ retval[count-1] = xstrdup(text);
text += i;
*text = ch;
if ((ch == '\r') && (text[1] == '\n'))
@@ -145,9 +144,9 @@
{
char ch = text[pos];
count++;
- retval = (char **) entry->xrealloc(retval, count * sizeof (char*));
+ retval = (char **) xrealloc(retval, count * sizeof (char*));
text[pos] = '\0';
- retval[count-1] = entry->xstrdup(text);
+ retval[count-1] = xstrdup(text);
text += pos;
*text = ch;
if (pos > w)
@@ -250,9 +249,9 @@
scrh--; // -1 to save the title at the top of the screen...
if (scrw < 30) // too thin
- msg = entry->xstrdup(entry->_("[Make the window wider!]"));
+ msg = xstrdup(_("[Make the window wider!]"));
else if (scrh < 10) // too short
- msg = entry->xstrdup(entry->_("[Make the window taller!]"));
+ msg = xstrdup(_("[Make the window taller!]"));
else
break; // we're good, get out.
@@ -300,18 +299,18 @@
getmaxyx(stdscr, scrh, scrw);
scrh--; // -1 to save the title at the top of the screen...
- retval = (MojoBox *) entry->xmalloc(sizeof (MojoBox));
+ retval = (MojoBox *) xmalloc(sizeof (MojoBox));
retval->hidecursor = hidecursor;
retval->ndelay = ndelay;
retval->cursval = ((hidecursor) ? curs_set(0) : ERR);
- retval->title = entry->xstrdup(title);
- retval->text = entry->xstrdup(text);
+ retval->title = xstrdup(title);
+ retval->text = xstrdup(text);
retval->buttoncount = bcount;
- retval->buttons = (WINDOW **) entry->xmalloc(sizeof (WINDOW*) * bcount);
- retval->buttontext = (char **) entry->xmalloc(sizeof (char*) * bcount);
+ retval->buttons = (WINDOW **) xmalloc(sizeof (WINDOW*) * bcount);
+ retval->buttontext = (char **) xmalloc(sizeof (char*) * bcount);
for (i = 0; i < bcount; i++)
- retval->buttontext[i] = entry->xstrdup(buttons[i]);
+ retval->buttontext[i] = xstrdup(buttons[i]);
retval->textlines = splitText(retval->text, &retval->textlinecount, &w);
@@ -628,7 +627,7 @@
{
if (initscr() == NULL)
{
- entry->logInfo("ncurses: initscr() failed, use another UI.");
+ logInfo("ncurses: initscr() failed, use another UI.");
return false;
} // if
@@ -676,7 +675,7 @@
static void MojoGui_ncurses_msgbox(const char *title, const char *text)
{
- char *localized_ok = entry->xstrdup(entry->_("OK"));
+ char *localized_ok = xstrdup(_("OK"));
MojoBox *mojobox = makeBox(title, text, &localized_ok, 1, false, true);
while (upkeepBox(&mojobox, wgetch(mojobox->mainwin)) == -1) {}
freeBox(mojobox, true);
@@ -687,8 +686,8 @@
static boolean MojoGui_ncurses_promptyn(const char *title, const char *text,
boolean defval)
{
- char *localized_yes = entry->xstrdup(entry->_("Yes"));
- char *localized_no = entry->xstrdup(entry->_("No"));
+ char *localized_yes = xstrdup(_("Yes"));
+ char *localized_no = xstrdup(_("No"));
char *buttons[] = { localized_yes, localized_no };
MojoBox *mojobox = makeBox(title, text, buttons, 2, false, true);
int rc = 0;
@@ -715,10 +714,10 @@
const char *text,
boolean defval)
{
- char *loc_yes = entry->xstrdup(entry->_("Yes"));
- char *loc_no = entry->xstrdup(entry->_("No"));
- char *loc_always = entry->xstrdup(entry->_("Always"));
- char *loc_never = entry->xstrdup(entry->_("Never"));
+ char *loc_yes = xstrdup(_("Yes"));
+ char *loc_no = xstrdup(_("No"));
+ char *loc_always = xstrdup(_("Always"));
+ char *loc_never = xstrdup(_("Never"));
char *buttons[] = { loc_yes, loc_always, loc_never, loc_no };
MojoBox *mojobox = makeBox(title, text, buttons, 4, false, true);
int rc = 0;
@@ -757,7 +756,7 @@
const MojoGuiSplash *splash)
{
free(title);
- title = entry->xstrdup(_title);
+ title = xstrdup(_title);
drawBackground(stdscr);
wrefresh(stdscr);
return true;
@@ -788,16 +787,16 @@
if (can_fwd)
{
fwdbutton = bcount++;
- buttons[fwdbutton] = entry->xstrdup(entry->_("Next"));
+ buttons[fwdbutton] = xstrdup(_("Next"));
} // if
if (can_back)
{
backbutton = bcount++;
- buttons[backbutton] = entry->xstrdup(entry->_("Back"));
+ buttons[backbutton] = xstrdup(_("Back"));
} // if
- buttons[bcount++] = entry->xstrdup(entry->_("Cancel"));
+ buttons[bcount++] = xstrdup(_("Cancel"));
mojobox = makeBox(name, (char *) data, buttons, bcount, false, true);
while ((rc = upkeepBox(&mojobox, wgetch(mojobox->mainwin))) == -1) {}
@@ -873,8 +872,8 @@
if (opts != NULL)
{
const char *desc = opts->description;
- char *spacebuf = (char *) entry->xmalloc(maxw + 1);
- char *buf = (char *) entry->xmalloc(maxw + 1);
+ char *spacebuf = (char *) xmalloc(maxw + 1);
+ char *buf = (char *) xmalloc(maxw + 1);
int len = 0;
int spacing = level * 2;
@@ -907,7 +906,7 @@
if (len > 0)
{
const size_t newlen = strlen(*lines) + strlen(buf) + 2;
- *lines = (char*) entry->xrealloc(*lines, newlen);
+ *lines = (char*) xrealloc(*lines, newlen);
strcat(*lines, buf);
strcat(*lines, "\n"); // I'm sorry, Joel Spolsky!
} // if
@@ -946,19 +945,19 @@
if (can_fwd)
{
fwdbutton = bcount++;
- buttons[fwdbutton] = entry->xstrdup(entry->_("Next"));
+ buttons[fwdbutton] = xstrdup(_("Next"));
} // if
if (can_back)
{
backbutton = bcount++;
- buttons[backbutton] = entry->xstrdup(entry->_("Back"));
+ buttons[backbutton] = xstrdup(_("Back"));
} // if
lasthoverover = togglebutton = bcount++;
- buttons[togglebutton] = entry->xstrdup(entry->_("Toggle"));
+ buttons[togglebutton] = xstrdup(_("Toggle"));
cancelbutton = bcount++;
- buttons[cancelbutton] = entry->xstrdup(entry->_("Cancel"));
+ buttons[cancelbutton] = xstrdup(_("Cancel"));
do
{
@@ -968,7 +967,7 @@
int line = 0;
int maxw, maxh;
getmaxyx(stdscr, maxh, maxw);
- char *text = entry->xstrdup("");
+ char *text = xstrdup("");
build_options(opts, &line, 0, maxw-6, &text);
mojobox = makeBox(title, text, buttons, bcount, false, true);
free(text);
@@ -1119,7 +1118,7 @@
static int MojoGui_ncurses_options(MojoGuiSetupOptions *opts,
boolean can_back, boolean can_fwd)
{
- char *title = entry->xstrdup(entry->_("Options"));
+ char *title = xstrdup(_("Options"));
int rc = optionBox(title, opts, can_back, can_fwd);
free(title);
return rc;
@@ -1136,7 +1135,7 @@
MojoBox *mojobox = NULL;
size_t retvalalloc = 64;
size_t retvallen = 0;
- char *retval = (char *) entry->xmalloc(retvalalloc);
+ char *retval = (char *) xmalloc(retvalalloc);
char *buttons[3] = { NULL, NULL, NULL };
int drawpos = 0;
int drawlen = 0;
@@ -1144,20 +1143,20 @@
int backbutton = -1;
int cancelbutton = -1;
- buttons[bcount++] = entry->xstrdup(entry->_("OK"));
+ buttons[bcount++] = xstrdup(_("OK"));
if (can_back)
{
backbutton = bcount++;
- buttons[backbutton] = entry->xstrdup(entry->_("Back"));
+ buttons[backbutton] = xstrdup(_("Back"));
} // if
cancelbutton = bcount++;
- buttons[cancelbutton] = entry->xstrdup(entry->_("Cancel"));
+ buttons[cancelbutton] = xstrdup(_("Cancel"));
getmaxyx(stdscr, h, w);
w -= 10;
- text = (char *) entry->xmalloc(w+4);
+ text = (char *) xmalloc(w+4);
text[0] = '\n';
memset(text+1, ' ', w);
text[w+1] = '\n';
@@ -1189,7 +1188,7 @@
if (retvalalloc <= retvallen)
{
retvalalloc *= 2;
- retval = entry->xrealloc(retval, retvalalloc);
+ retval = xrealloc(retval, retvalalloc);
} // if
retval[retvallen++] = (char) ch;
retval[retvallen] = '\0';
@@ -1206,7 +1205,7 @@
wrefresh(stdscr);
getmaxyx(stdscr, h, w);
w -= 10;
- text = (char *) entry->xrealloc(mojobox->text, w+4);
+ text = (char *) xrealloc(mojobox->text, w+4);
text[0] = '\n';
memset(text+1, ' ', w);
text[w+1] = '\n';
@@ -1268,15 +1267,15 @@
int i;
for (i = 0; i < recnum; i++)
{
- opt = (MojoGuiSetupOptions *) entry->xmalloc(sizeof (*opt));
+ opt = (MojoGuiSetupOptions *) xmalloc(sizeof (*opt));
opt->description = recommends[i];
opt->size = -1;
prev->next_sibling = opt;
prev = opt;
} // for
- choosetxt = entry->xstrdup(entry->_("(I want to specify a path.)"));
- opt = (MojoGuiSetupOptions *) entry->xmalloc(sizeof (*opt));
+ choosetxt = xstrdup(_("(I want to specify a path.)"));
+ opt = (MojoGuiSetupOptions *) xmalloc(sizeof (*opt));
opt->description = choosetxt;
opt->size = -1;
prev->next_sibling = opt;
@@ -1288,7 +1287,7 @@
opts.is_group_parent = true;
opts.size = -1;
- title = entry->xstrdup(entry->_("Destination"));
+ title = xstrdup(_("Destination"));
rc = optionBox(title, &opts, can_back, can_fwd);
free(title);
@@ -1308,13 +1307,13 @@
return NULL;
else if ((chosen >= 0) && (chosen < recnum)) // a specific entry
- return entry->xstrdup(recommends[chosen]);
+ return xstrdup(recommends[chosen]);
} // if
// either no recommendations or user wants to enter own path...
- localized = entry->_("Enter path where files will be installed.");
- title = entry->xstrdup(localized);
+ localized = _("Enter path where files will be installed.");
+ title = xstrdup(localized);
retval = inputBox(title, &rc, (can_back) || (recnum > 0));
free(title);
@@ -1337,15 +1336,15 @@
static boolean MojoGui_ncurses_insertmedia(const char *medianame)
{
- char *fmt = entry->xstrdup(entry->_("Please insert '%0'"));
- char *text = entry->format(fmt, medianame);
- char *localized_ok = entry->xstrdup(entry->_("OK"));
- char *localized_cancel = entry->xstrdup(entry->_("Cancel"));
+ char *fmt = xstrdup(_("Please insert '%0'"));
+ char *text = format(fmt, medianame);
+ char *localized_ok = xstrdup(_("OK"));
+ char *localized_cancel = xstrdup(_("Cancel"));
char *buttons[] = { localized_ok, localized_cancel };
MojoBox *mojobox = NULL;
int rc = 0;
- mojobox = makeBox(entry->_("Media change"), text, buttons, 2, false, true);
+ mojobox = makeBox(_("Media change"), text, buttons, 2, false, true);
while ((rc = upkeepBox(&mojobox, wgetch(mojobox->mainwin))) == -1) {}
freeBox(mojobox, true);
@@ -1367,7 +1366,7 @@
int percent, const char *item,
boolean can_cancel)
{
- const uint32 now = entry->ticks();
+ const uint32 now = ticks();
boolean rebuild = (progressBox == NULL);
int ch = 0;
int rc = -1;
@@ -1380,8 +1379,8 @@
{
free(lastProgressType);
free(lastComponent);
- lastProgressType = entry->xstrdup(type);
- lastComponent = entry->xstrdup(component);
+ lastProgressType = xstrdup(type);
+ lastComponent = xstrdup(component);
lastCanCancel = can_cancel;
rebuild = true;
} // if
@@ -1390,18 +1389,17 @@
{
int w, h;
char *text = NULL;
- char *localized_cancel =
- (can_cancel) ? entry->xstrdup(entry->_("Cancel")) : NULL;
+ char *localized_cancel = (can_cancel) ? xstrdup(_("Cancel")) : NULL;
char *buttons[] = { localized_cancel };
const int buttoncount = (can_cancel) ? 1 : 0;
char *spacebuf = NULL;
getmaxyx(stdscr, h, w);
w -= 10;
- text = (char *) entry->xmalloc((w * 3) + 16);
+ text = (char *) xmalloc((w * 3) + 16);
if (snprintf(text, w, "%s", component) > (w-4))
strcpy((text+w)-4, "..."); // !!! FIXME: Unicode problem.
strcat(text, "\n\n");
- spacebuf = (char *) entry->xmalloc(w+1);
+ spacebuf = (char *) xmalloc(w+1);
memset(spacebuf, ' ', w); // xmalloc provides null termination.
strcat(text, spacebuf);
free(spacebuf);
@@ -1422,7 +1420,7 @@
int w, h;
getmaxyx(win, h, w);
w -= 2;
- buf = (char *) entry->xmalloc(w+1);
+ buf = (char *) xmalloc(w+1);
if (percent < 0)
{
@@ -1483,7 +1481,7 @@
static void MojoGui_ncurses_final(const char *msg)
{
- char *title = entry->xstrdup(entry->_("Finish"));
+ char *title = xstrdup(_("Finish"));
MojoGui_ncurses_msgbox(title, msg);
free(title);
} // MojoGui_ncurses_final
Modified: trunk/gui_stdio.c
===================================================================
--- trunk/gui_stdio.c 2008-03-02 06:18:26 UTC (rev 537)
+++ trunk/gui_stdio.c 2008-03-02 06:22:08 UTC (rev 538)
@@ -46,15 +46,15 @@
// !!! FIXME: abort in read_stdin() if i/o fails?
int retval = 0;
- char *backstr = (back) ? entry->xstrdup(entry->_("back")) : NULL;
+ char *backstr = (back) ? xstrdup(_("back")) : NULL;
if (prompt != NULL)
printf("%s\n", prompt);
if (back)
{
- char *fmt = entry->xstrdup(entry->_("Type '%0' to go back."));
- char *msg = entry->format(fmt, backstr);
+ char *fmt = xstrdup(_("Type '%0' to go back."));
+ char *msg = format(fmt, backstr);
printf("%s\n", msg);
free(msg);
free(fmt);
@@ -62,11 +62,11 @@
if (fwd)
{
- printf(entry->_("Press enter to continue."));
+ printf(_("Press enter to continue."));
printf("\n");
} // if
- printf(entry->_("> "));
+ printf(_("> "));
fflush(stdout);
if ((retval = read_stdin(buf, len)) >= 0)
@@ -113,8 +113,8 @@
static void MojoGui_stdio_msgbox(const char *title, const char *text)
{
char buf[128];
- char *fmt = entry->xstrdup(entry->_("NOTICE: %0\n[hit enter]"));
- char *msg = entry->format(fmt, text);
+ char *fmt = xstrdup(_("NOTICE: %0\n[hit enter]"));
+ char *msg = format(fmt, text);
printf("%s\n", msg);
free(msg);
free(fmt);
@@ -129,14 +129,11 @@
boolean retval = false;
if (!feof(stdin))
{
- const char *_fmt = ((defval) ?
- entry->_("%0 [Y/n]: ") :
- entry->_("%0 [y/N]: "));
-
- char *fmt = entry->xstrdup(_fmt);
- char *msg = entry->format(fmt, text);
- char *localized_no = entry->xstrdup(entry->_("N"));
- char *localized_yes = entry->xstrdup(entry->_("Y"));
+ const char *_fmt = ((defval) ? _("%0 [Y/n]: ") : _("%0 [y/N]: "));
+ char *fmt = xstrdup(_fmt);
+ char *msg = format(fmt, text);
+ char *localized_no = xstrdup(_("N"));
+ char *localized_yes = xstrdup(_("Y"));
boolean getout = false;
char buf[128];
@@ -177,12 +174,12 @@
MojoGuiYNAN retval = MOJOGUI_NO;
if (!feof(stdin))
{
- char *fmt = entry->xstrdup(_("%0\n[y/n/Always/Never]: "));
- char *msg = entry->format(fmt, txt);
- char *localized_no = entry->xstrdup(entry->_("N"));
- char *localized_yes = entry->xstrdup(entry->_("Y"));
- char *localized_always = entry->xstrdup(entry->_("Always"));
- char *localized_never = entry->xstrdup(entry->_("Never"));
+ char *fmt = xstrdup(_("%0\n[y/n/Always/Never]: "));
+ char *msg = format(fmt, txt);
+ char *localized_no = xstrdup(_("N"));
+ char *localized_yes = xstrdup(_("Y"));
+ char *localized_always = xstrdup(_("Always"));
+ char *localized_never = xstrdup(_("Never"));
boolean getout = false;
char buf[128];
@@ -242,7 +239,7 @@
// !!! FIXME: this is not really Unicode friendly...
static char **splitText(const char *_text, int *_count, int *_w)
{
- char *ptr = entry->xstrdup(_text);
+ char *ptr = xstrdup(_text);
char *text = ptr;
int i;
int scrw = 80;
@@ -262,10 +259,9 @@
if ((ch == '\r') || (ch == '\n'))
{
count++;
- retval = (char **) entry->xrealloc(retval,
- count * sizeof (char *));
+ retval = (char **) xrealloc(retval, count * sizeof (char *));
text[i] = '\0';
- retval[count-1] = entry->xstrdup(text);
+ retval[count-1] = xstrdup(text);
text += i;
*text = ch;
if ((ch == '\r') && (text[1] == '\n'))
@@ -296,9 +292,9 @@
{
char ch = text[pos];
count++;
- retval = (char **) entry->xrealloc(retval, count * sizeof (char*));
+ retval = (char **) xrealloc(retval, count * sizeof (char*));
text[pos] = '\0';
- retval[count-1] = entry->xstrdup(text);
+ retval[count-1] = xstrdup(text);
text += pos;
*text = ch;
if (pos > w)
@@ -316,7 +312,7 @@
static void dumb_pager(const char *name, const char *data, size_t datalen)
{
const int MAX_PAGE_LINES = 21;
- char *fmt = entry->xstrdup(entry->_("(%0-%1 of %2 lines, see more?)"));
+ char *fmt = xstrdup(_("(%0-%1 of %2 lines, see more?)"));
int i = 0;
int w = 0;
int linecount = 0;
@@ -343,9 +339,8 @@
{
char *msg = NULL;
printf("\n");
- msg = entry->format(fmt, entry->numstr((printed-i)+1),
- entry->numstr(printed),
- entry->numstr(linecount));
+ msg = format(fmt, numstr((printed-i)+1),
+ numstr(printed), numstr(linecount));
getout = !MojoGui_stdio_promptyn("", msg, true);
free(msg);
printf("\n");
@@ -485,8 +480,8 @@
static int MojoGui_stdio_options(MojoGuiSetupOptions *opts,
boolean can_back, boolean can_fwd)
{
- const char *inst_opts_str = entry->xstrdup(entry->_("Options"));
- const char *prompt = entry->xstrdup(entry->_("Choose number to change."));
+ const char *inst_opts_str = xstrdup(_("Options"));
+ const char *prompt = xstrdup(_("Choose number to change."));
int retval = -1;
boolean getout = false;
char buf[128];
@@ -532,7 +527,7 @@
int *command, boolean can_back,
boolean can_fwd)
{
- const char *instdeststr = entry->xstrdup(entry->_("Destination"));
+ const char *instdeststr = xstrdup(_("Destination"));
const char *prompt = NULL;
char *retval = NULL;
boolean getout = false;
@@ -543,9 +538,9 @@
*command = -1;
if (recnum > 0)
- prompt = entry->xstrdup(entry->_("Choose install destination by number (hit enter for #1), or enter your own."));
+ prompt = xstrdup(_("Choose install destination by number (hit enter for #1), or enter your own."));
else
- prompt = entry->xstrdup(entry->_("Enter path where files will be installed."));
+ prompt = xstrdup(_("Enter path where files will be installed."));
while (!getout)
{
@@ -559,7 +554,7 @@
else if ((len == 0) && (recnum > 0)) // default to first in list.
{
- retval = entry->xstrdup(recommends[0]);
+ retval = xstrdup(recommends[0]);
*command = 1;
getout = true;
} // else if
@@ -570,9 +565,9 @@
int target = (int) strtol(buf, &endptr, 10);
// complete string was a valid number?
if ((*endptr == '\0') && (target > 0) && (target <= recnum))
- retval = entry->xstrdup(recommends[target-1]);
+ retval = xstrdup(recommends[target-1]);
else
- retval = entry->xstrdup(buf);
+ retval = xstrdup(buf);
*command = 1;
getout = true;
@@ -589,9 +584,9 @@
static boolean MojoGui_stdio_insertmedia(const char *medianame)
{
char buf[32];
- char *fmt = entry->xstrdup(entry->_("Please insert '%0'"));
- char *msg = entry->format(fmt, medianame);
- printf("%s\n", entry->_("Media change"));
+ char *fmt = xstrdup(_("Please insert '%0'"));
+ char *msg = format(fmt, medianame);
+ printf("%s\n", _("Media change"));
printf("%s\n", msg);
free(msg);
free(fmt);
@@ -610,7 +605,7 @@
int percent, const char *item,
boolean can_cancel)
{
- const uint32 now = entry->ticks();
+ const uint32 now = ticks();
if ( (lastComponent == NULL) ||
(strcmp(lastComponent, component) != 0) ||
@@ -619,8 +614,8 @@
{
free(lastProgressType);
free(lastComponent);
- lastProgressType = entry->xstrdup(type);
- lastComponent = entry->xstrdup(component);
+ lastProgressType = xstrdup(type);
+ lastComponent = xstrdup(component);
printf("%s\n%s\n", type, component);
} // if
@@ -636,8 +631,8 @@
printf("%s\n", item);
else
{
- fmt = entry->xstrdup(entry->_("%0 (total progress: %1%%)"));
- msg = entry->format(fmt, item, entry->numstr(percent));
+ fmt = xstrdup(_("%0 (total progress: %1%%)"));
+ msg = format(fmt, item, numstr(percent));
printf("%s\n", msg);
free(msg);
free(fmt);
Modified: trunk/gui_www.c
===================================================================
--- trunk/gui_www.c 2008-03-02 06:18:26 UTC (rev 537)
+++ trunk/gui_www.c 2008-03-02 06:22:08 UTC (rev 538)
@@ -53,19 +53,18 @@
int rc = WSAStartup(MAKEWORD(1, 1), &data);
if (rc != 0)
{
- entry->logError("www: WSAStartup() failed: %0", sockStrErrVal(rc));
+ logError("www: WSAStartup() failed: %0", sockStrErrVal(rc));
return false;
} // if
- entry->logInfo("www: WinSock initialized (want %0.%1, got %2.%3).",
- entry->numstr((int) (LOBYTE(data.wVersion))),
- entry->numstr((int) (HIBYTE(data.wVersion))),
- entry->numstr((int) (LOBYTE(data.wHighVersion))),
- entry->numstr((int) (HIBYTE(data.wHighVersion))));
- entry->logInfo("www: WinSock description: %0", data.szDescription);
- entry->logInfo("www: WinSock system status: %0", data.szSystemStatus);
- entry->logInfo("www: WinSock max sockets: %0",
- entry->numstr((int) data.iMaxSockets));
+ logInfo("www: WinSock initialized (want %0.%1, got %2.%3).",
+ numstr((int) (LOBYTE(data.wVersion))),
+ numstr((int) (HIBYTE(data.wVersion))),
+ numstr((int) (LOBYTE(data.wHighVersion))),
+ numstr((int) (HIBYTE(data.wHighVersion))));
+ logInfo("www: WinSock description: %0", data.szDescription);
+ logInfo("www: WinSock system status: %0", data.szSystemStatus);
+ logInfo("www: WinSock max sockets: %0", numstr((int) data.iMaxSockets));
return true;
} // initSocketSupport
@@ -155,12 +154,12 @@
{
if ((key != NULL) && (*key != '\0'))
{
- WebRequest *req = (WebRequest *) entry->xmalloc(sizeof (WebRequest));
- req->key = entry->xstrdup(key);
- req->value = entry->xstrdup(val);
+ WebRequest *req = (WebRequest *) xmalloc(sizeof (WebRequest));
+ req->key = xstrdup(key);
+ req->value = xstrdup(val);
req->next = webRequest;
webRequest = req;
- entry->logDebug("www: request element '%0' = '%1'", key, val);
+ logDebug("www: request element '%0' = '%1'", key, val);
} // if
} // addWebRequest
@@ -218,7 +217,7 @@
const size_t add = (*alloc + (bw + 1)); // double plus the new len.
*alloc += add;
avail += add;
- *ptr = entry->xrealloc(*ptr, *alloc);
+ *ptr = xrealloc(*ptr, *alloc);
va_start(ap, fmt);
bw = vsnprintf(*ptr + *len, avail, fmt, ap);
va_end(ap);
@@ -310,7 +309,7 @@
const int err = sockErrno();
if (!intrError(err))
{
- entry->logError("www: send() failed: %0", sockStrErrVal(err));
+ logError("www: send() failed: %0", sockStrErrVal(err));
break;
} // if
} // else
@@ -323,7 +322,7 @@
static void respond404(SOCKET *s)
{
- char *text = htmlescape(entry->_("Not Found"));
+ char *text = htmlescape(_("Not Found"));
char *str = NULL;
size_t len = 0, alloc = 0;
char *html = NULL;
@@ -458,7 +457,7 @@
assert(!blocking);
else
{
- entry->logError("www: accept() failed: %0", sockStrErrVal(err));
+ logError("www: accept() failed: %0", sockStrErrVal(err));
closesocket(listenSocket); // make all future i/o fail too.
listenSocket = INVALID_SOCKET;
} // else
@@ -476,7 +475,7 @@
const int err = sockErrno();
if (!intrError(err)) // just try again on interrupt.
{
- entry->logError("www: recv() failed: %0", sockStrErrVal(err));
+ logError("www: recv() failed: %0", sockStrErrVal(err));
FREE_AND_NULL(reqstr);
closesocket(s);
s = INVALID_SOCKET;
@@ -509,7 +508,7 @@
} // if
// reqstr is the GET (or whatever) request, ptr is the rest.
- get = entry->xstrdup(reqstr);
+ get = xstrdup(reqstr);
if (ptr == NULL)
{
*ptr = '\0';
@@ -521,15 +520,15 @@
memmove(reqstr, ptr, len+1);
} // else
- entry->logDebug("www: request '%0'", get);
+ logDebug("www: request '%0'", get);
// okay, now (get) and (reqptr) are separate strings.
// These parse*() functions update (webRequest).
if ( (parseGet(get)) && (parseRequest(reqstr)) )
- entry->logDebug("www: accepted request");
+ logDebug("www: accepted request");
else
{
- entry->logError("www: rejected bogus request");
+ logError("www: rejected bogus request");
freeWebRequest();
respond404(&s);
} // else
@@ -556,7 +555,7 @@
s = socket(PF_INET, SOCK_STREAM, protocol);
if (s == INVALID_SOCKET)
- entry->logInfo("www: socket() failed ('%0')", sockStrError());
+ logInfo("www: socket() failed ('%0')", sockStrError());
else
{
boolean success = false;
@@ -574,13 +573,13 @@
#endif
if (bind(s, (struct sockaddr *) &addr, sizeof (addr)) == SOCKET_ERROR)
- entry->logError("www: bind() failed ('%0')", sockStrError());
+ logError("www: bind() failed ('%0')", sockStrError());
else if (listen(s, 5) == SOCKET_ERROR)
- entry->logError("www: listen() failed ('%0')", sockStrError());
+ logError("www: listen() failed ('%0')", sockStrError());
else
{
- entry->logInfo("www: socket created on port %0",
- entry->numstr(portnum));
+ logInfo("www: socket created on port %0",
+ numstr(portnum));
success = true;
} // else
@@ -603,14 +602,14 @@
if (!initSocketSupport())
{
- entry->logInfo("www: socket subsystem init failed, use another UI.");
+ logInfo("www: socket subsystem init failed, use another UI.");
return false;
} // if
listenSocket = create_listen_socket(portnum);
if (listenSocket < 0)
{
- entry->logInfo("www: no listen socket, use another UI.");
+ logInfo("www: no listen socket, use another UI.");
return false;
} // if
@@ -624,8 +623,8 @@
static void MojoGui_www_deinit(void)
{
// Catch any waiting browser connections...and tell them to buzz off! :)
- char *donetitle = htmlescape(entry->_("Shutting down..."));
- char *donetext = htmlescape(entry->_("You can close this browser now."));
+ char *donetitle = htmlescape(_("Shutting down..."));
+ char *donetext = htmlescape(_("You can close this browser now."));
size_t len = 0, alloc = 0;
char *html = NULL;
@@ -733,7 +732,7 @@
static void MojoGui_www_msgbox(const char *title, const char *text)
{
const char *buttons[] = { "ok" };
- const char *locButtons[] = { htmlescape(entry->_("OK")) };
+ const char *locButtons[] = { htmlescape(_("OK")) };
char *htmltext = htmlescape(text);
doPromptPage(title, htmltext, true, "msgbox", buttons, locButtons, 1);
free(htmltext);
@@ -750,10 +749,8 @@
int i, rc;
char *htmltext = htmlescape(text);
const char *buttons[] = { "no", "yes" };
- const char *locButtons[] = {
- htmlescape(entry->_("No")),
- htmlescape(entry->_("Yes")),
- };
+ const char *locButtons[] = { htmlescape(_("No")), htmlescape(_("Yes")) };
+
assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons));
rc = doPromptPage(title, htmltext, true, "promptyn", buttons, locButtons,
@@ -777,10 +774,10 @@
char *htmltext = htmlescape(text);
const char *buttons[] = { "no", "yes", "always", "never" };
const char *locButtons[] = {
- htmlescape(entry->_("No")),
- htmlescape(entry->_("Yes")),
- htmlescape(entry->_("Always")),
- htmlescape(entry->_("Never")),
+ htmlescape(_("No")),
+ htmlescape(_("Yes")),
+ htmlescape(_("Always")),
+ htmlescape(_("Never")),
};
assert(STATICARRAYLEN(buttons) == STATICARRAYLEN(locButtons));
@@ -826,20 +823,20 @@
cancelbutton = bcount++;
buttons[cancelbutton] = "cancel";
- locButtons[cancelbutton] = entry->xstrdup(entry->_("Cancel"));
+ locButtons[cancelbutton] = xstrdup(_("Cancel"));
if (can_back)
{
backbutton = bcount++;
buttons[backbutton] = "back";
- locButtons[backbutton] = entry->xstrdup(entry->_("Back"));
+ locButtons[backbutton] = xstrdup(_("Back"));
} // if
if (can_fwd)
{
fwdbutton = bcount++;
buttons[fwdbutton] = "next";
- locButtons[fwdbutton] = entry->xstrdup(entry->_("Next"));
+ locButtons[fwdbutton] = xstrdup(_("Next"));
} // if
strAdd(&text, &len, &alloc, "<pre>\n%s\n</pre>", htmldata);
@@ -873,7 +870,7 @@
boolean can_fwd)
{
char *retval = NULL;
- char *title = entry->xstrdup(entry->_("Destination"));
+ char *title = xstrdup(_("Destination"));
char *html = NULL;
size_t len = 0, alloc = 0;
boolean checked = true;
@@ -889,20 +886,20 @@
cancelbutton = bcount++;
buttons[cancelbutton] = "cancel";
- locButtons[cancelbutton] = entry->xstrdup(entry->_("Cancel"));
+ locButtons[cancelbutton] = xstrdup(_("Cancel"));
if (can_back)
{
backbutton = bcount++;
buttons[backbutton] = "back";
- locButtons[backbutton] = entry->xstrdup(entry->_("Back"));
+ locButtons[backbutton] = xstrdup(_("Back"));
} // if
if (can_fwd)
{
fwdbutton = bcount++;
buttons[fwdbutton] = "next";
- locButtons[fwdbutton] = entry->xstrdup(entry->_("Next"));
+ locButtons[fwdbutton] = xstrdup(_("Next"));
} // if
strAdd(&html, &len, &alloc,
@@ -969,7 +966,7 @@
*command = 0; // !!! FIXME: maybe loop with doPromptPage again.
else
{
- retval = entry->xstrdup(dest);
+ retval = xstrdup(dest);
*command = 1;
} // else
} // else
@@ -986,14 +983,11 @@
int i, rc;
const char *buttons[] = { "cancel", "ok" };
- const char *locButtons[] = {
- htmlescape(entry->_("Cancel")),
- htmlescape(entry->_("OK")),
- };
+ const char *locButtons[] = { htmlescape(_("Cancel")), htmlescape(_("OK")) };
- char *title = entry->xstrdup(entry->_("Media change"));
- char *fmt = entry->xstrdup(entry->_("Please insert '%0'"));
- char *msg = entry->format(fmt, medianame);
+ char *title = xstrdup(_("Media change"));
+ char *fmt = xstrdup(_("Please insert '%0'"));
+ char *msg = format(fmt, medianame);
strAdd(&text, &len, &alloc, msg);
free(msg);
free(fmt);
@@ -1031,7 +1025,7 @@
static void MojoGui_www_final(const char *msg)
{
- MojoGui_www_msgbox(entry->_("Finish"), msg);
+ MojoGui_www_msgbox(_("Finish"), msg);
} // MojoGui_www_final
// end of gui_www.c ...
More information about the mojosetup-commits
mailing list