summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app-defaults/XFontSel7
-rw-r--r--xfontsel.c37
2 files changed, 38 insertions, 6 deletions
diff --git a/app-defaults/XFontSel b/app-defaults/XFontSel
index b0ef993..371eab1 100644
--- a/app-defaults/XFontSel
+++ b/app-defaults/XFontSel
@@ -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
diff --git a/xfontsel.c b/xfontsel.c
index 2adf61d..cfa3d58 100644
--- a/xfontsel.c
+++ b/xfontsel.c
@@ -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)