Commit 148a592b authored by AG's avatar AG Committed by Alan Coopersmith
Browse files

Add 'reset' button



It's very tedious to deselect multiple XLFD field names if you want to
start from scratch (it's often easier to relaunch the app). Hence, a
simple reset button can be handy.
Signed-off-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent d55f7ed9
Pipeline #551385 passed with stages
in 1 minute and 7 seconds
......@@ -50,8 +50,13 @@ XFontSel.cursor: left_ptr
*quitButton.left: chainLeft
*quitButton.right: chainLeft
*resetButton.Label: reset
*resetButton.fromHoriz: quitButton
*resetButton.left: chainLeft
*resetButton.right: chainLeft
*ownButton.Label: select
*ownButton.fromHoriz: quitButton
*ownButton.fromHoriz: resetButton
*ownButton.left: chainLeft
*ownButton.right: chainLeft
......
......@@ -68,6 +68,7 @@ void GetFontNames(XtPointer closure);
Boolean Matches(String pattern, String fontName, Boolean fields[], int *maxfields);
Boolean DoWorkPiece(XtPointer closure);
void Quit(Widget w, XtPointer closure, XtPointer callData) _X_NORETURN;
void Reset(Widget w, XtPointer closure, XtPointer callData);
void OwnSelection(Widget w, XtPointer closure, XtPointer callData);
void SelectField(Widget w, XtPointer closure, XtPointer callData);
void ParseFontNames(XtPointer closure);
......@@ -223,6 +224,7 @@ static void ScheduleWork(XtProc proc, XtPointer closure, int priority);
static void SetCurrentFontCount(void);
static void SetNoFonts(void);
static void SetParsingFontCount(int count);
static void reset_currentFontNameString(void);
static XtAppContext appCtx;
static int numFonts;
......@@ -234,6 +236,7 @@ static FieldValueList *fieldValues[FIELD_COUNT];
static FontValues currentFont;
static int matchingFontCount;
static Boolean anyDisabled = False;
static Widget resetButton;
static Widget ownButton;
static Widget fieldBox;
static Widget countLabel;
......@@ -283,11 +286,14 @@ see 'xfontsel' manual page."
commandBox = XtCreateManagedWidget("commandBox",formWidgetClass,pane,NZ);
{
Widget quitButton /*, ownButton , countLabel*/;
Widget quitButton /*, resetButton, ownButton , countLabel*/;
quitButton =
XtCreateManagedWidget("quitButton",commandWidgetClass,commandBox,NZ);
resetButton =
XtCreateManagedWidget("resetButton",commandWidgetClass,commandBox,NZ);
ownButton =
XtCreateManagedWidget("ownButton",toggleWidgetClass,commandBox,NZ);
......@@ -295,6 +301,7 @@ see 'xfontsel' manual page."
XtCreateManagedWidget("countLabel",labelWidgetClass,commandBox,NZ);
XtAddCallback(quitButton, XtNcallback, Quit, NULL);
XtAddCallback(resetButton, XtNcallback, Reset, NULL);
XtAddCallback(ownButton,XtNcallback,OwnSelection,(XtPointer)True);
}
......@@ -322,10 +329,7 @@ see 'xfontsel' manual page."
/* currentFontName = */
{
Arg args[1];
currentFontNameSize = strlen(AppRes.pattern);
if (currentFontNameSize < 128) currentFontNameSize = 128;
currentFontNameString = XtMalloc(currentFontNameSize);
strcpy(currentFontNameString, AppRes.pattern);
reset_currentFontNameString();
XtSetArg(args[0], XtNlabel, currentFontNameString);
currentFontName =
XtCreateManagedWidget("fontName",labelWidgetClass,pane,args,ONE);
......@@ -910,6 +914,7 @@ static void SetNoFonts(void)
matchingFontCount = 0;
SetCurrentFontCount();
XtSetSensitive(fieldBox, False);
XtSetSensitive(resetButton, False);
XtSetSensitive(ownButton, False);
if (AppRes.app_defaults_version >= MIN_APP_DEFAULTS_VERSION) {
XtUnmapWidget(sampleText);
......@@ -1398,6 +1403,28 @@ void Quit(Widget w, XtPointer closure, XtPointer callData)
}
void Reset(Widget w, XtPointer closure, XtPointer callData) {
Arg args[1];
reset_currentFontNameString();
XtSetArg(args[0], XtNlabel, currentFontNameString);
XtSetValues(currentFontName, args, ONE);
for (int f = 0; f < FIELD_COUNT; f++)
currentFont.value_index[f] = patternFieldSpecified[f] ? 0 : -1;
SetCurrentFont(NULL);
EnableRemainingItems(SkipCurrentField); /* menu */
}
static void reset_currentFontNameString(void) {
currentFontNameSize = strlen(AppRes.pattern);
if (currentFontNameSize < 128) currentFontNameSize = 128;
XtFree(currentFontNameString);
currentFontNameString = XtMalloc(currentFontNameSize);
strcpy(currentFontNameString, AppRes.pattern);
}
static Boolean
ConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type,
XtPointer *value, unsigned long *length, int *format)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment