Fossil SCM

Use a two-entry selection-box instead of a checkbox for boolean properties.

drh 2015-02-04 23:56 UTC form-submenu
Commit 1d50f47f6c2b65c2d49a96d8913d5f04232ba7df
2 files changed +35 -3 +2 -2
+35 -3
--- src/style.c
+++ src/style.c
@@ -48,15 +48,17 @@
4848
const char *zName; /* Form query parameter */
4949
const char *zLabel; /* Label. Might be NULL for FF_MULTI */
5050
int eType; /* FF_ENTRY, FF_CKBOX, FF_MULTI */
5151
int iSize; /* Width for FF_ENTRY. Count for FF_MULTI */
5252
const char **azChoice; /* value/display pairs for FF_MULTI */
53
+ const char *zFalse; /* FF_BINARY label when false */
5354
} aSubmenuCtrl[20];
5455
static int nSubmenuCtrl = 0;
55
-#define FF_ENTRY 1
56
-#define FF_CKBOX 2
57
-#define FF_MULTI 3
56
+#define FF_ENTRY 1
57
+#define FF_CKBOX 2
58
+#define FF_MULTI 3
59
+#define FF_BINARY 4
5860
5961
/*
6062
** Remember that the header has been generated. The footer is omitted
6163
** if an error occurs before the header.
6264
*/
@@ -262,10 +264,22 @@
262264
assert( nSubmenuCtrl < ArraySize(aSubmenuCtrl) );
263265
aSubmenuCtrl[nSubmenuCtrl].zName = zName;
264266
aSubmenuCtrl[nSubmenuCtrl].zLabel = zLabel;
265267
aSubmenuCtrl[nSubmenuCtrl].eType = FF_CKBOX;
266268
nSubmenuCtrl++;
269
+}
270
+void style_submenu_binary(
271
+ const char *zName, /* Query parameter name */
272
+ const char *zTrue, /* Label to show when parameter is true */
273
+ const char *zFalse /* Label to show when the parameter is false */
274
+){
275
+ assert( nSubmenuCtrl < ArraySize(aSubmenuCtrl) );
276
+ aSubmenuCtrl[nSubmenuCtrl].zName = zName;
277
+ aSubmenuCtrl[nSubmenuCtrl].zLabel = zTrue;
278
+ aSubmenuCtrl[nSubmenuCtrl].zFalse = zFalse;
279
+ aSubmenuCtrl[nSubmenuCtrl].eType = FF_BINARY;
280
+ nSubmenuCtrl++;
267281
}
268282
void style_submenu_multichoice(
269283
const char *zName, /* Query parameter name */
270284
int nChoice, /* Number of options */
271285
const char **azChoice /* value/display pairs. 2*nChoice entries */
@@ -527,10 +541,28 @@
527541
zQPV,
528542
fossil_strcmp(zVal,zQPV)==0 ? " selected" : "",
529543
aSubmenuCtrl[i].azChoice[j+1]
530544
);
531545
}
546
+ @ </select>
547
+ break;
548
+ }
549
+ case FF_BINARY: {
550
+ int isTrue = PB(zQPN);
551
+ cgi_printf(
552
+ "<select class='submenuctrl' size='1' name='%s' "
553
+ "onchange='gebi(\"f01\").submit();'>\n",
554
+ zQPN
555
+ );
556
+ cgi_printf(
557
+ "<option value='1'%s>%h</option>\n",
558
+ isTrue ? " selected":"", aSubmenuCtrl[i].zLabel
559
+ );
560
+ cgi_printf(
561
+ "<option value='0'%s>%h</option>\n",
562
+ (!isTrue) ? " selected":"", aSubmenuCtrl[i].zFalse
563
+ );
532564
@ </select>
533565
break;
534566
}
535567
}
536568
}
537569
--- src/style.c
+++ src/style.c
@@ -48,15 +48,17 @@
48 const char *zName; /* Form query parameter */
49 const char *zLabel; /* Label. Might be NULL for FF_MULTI */
50 int eType; /* FF_ENTRY, FF_CKBOX, FF_MULTI */
51 int iSize; /* Width for FF_ENTRY. Count for FF_MULTI */
52 const char **azChoice; /* value/display pairs for FF_MULTI */
 
53 } aSubmenuCtrl[20];
54 static int nSubmenuCtrl = 0;
55 #define FF_ENTRY 1
56 #define FF_CKBOX 2
57 #define FF_MULTI 3
 
58
59 /*
60 ** Remember that the header has been generated. The footer is omitted
61 ** if an error occurs before the header.
62 */
@@ -262,10 +264,22 @@
262 assert( nSubmenuCtrl < ArraySize(aSubmenuCtrl) );
263 aSubmenuCtrl[nSubmenuCtrl].zName = zName;
264 aSubmenuCtrl[nSubmenuCtrl].zLabel = zLabel;
265 aSubmenuCtrl[nSubmenuCtrl].eType = FF_CKBOX;
266 nSubmenuCtrl++;
 
 
 
 
 
 
 
 
 
 
 
 
267 }
268 void style_submenu_multichoice(
269 const char *zName, /* Query parameter name */
270 int nChoice, /* Number of options */
271 const char **azChoice /* value/display pairs. 2*nChoice entries */
@@ -527,10 +541,28 @@
527 zQPV,
528 fossil_strcmp(zVal,zQPV)==0 ? " selected" : "",
529 aSubmenuCtrl[i].azChoice[j+1]
530 );
531 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532 @ </select>
533 break;
534 }
535 }
536 }
537
--- src/style.c
+++ src/style.c
@@ -48,15 +48,17 @@
48 const char *zName; /* Form query parameter */
49 const char *zLabel; /* Label. Might be NULL for FF_MULTI */
50 int eType; /* FF_ENTRY, FF_CKBOX, FF_MULTI */
51 int iSize; /* Width for FF_ENTRY. Count for FF_MULTI */
52 const char **azChoice; /* value/display pairs for FF_MULTI */
53 const char *zFalse; /* FF_BINARY label when false */
54 } aSubmenuCtrl[20];
55 static int nSubmenuCtrl = 0;
56 #define FF_ENTRY 1
57 #define FF_CKBOX 2
58 #define FF_MULTI 3
59 #define FF_BINARY 4
60
61 /*
62 ** Remember that the header has been generated. The footer is omitted
63 ** if an error occurs before the header.
64 */
@@ -262,10 +264,22 @@
264 assert( nSubmenuCtrl < ArraySize(aSubmenuCtrl) );
265 aSubmenuCtrl[nSubmenuCtrl].zName = zName;
266 aSubmenuCtrl[nSubmenuCtrl].zLabel = zLabel;
267 aSubmenuCtrl[nSubmenuCtrl].eType = FF_CKBOX;
268 nSubmenuCtrl++;
269 }
270 void style_submenu_binary(
271 const char *zName, /* Query parameter name */
272 const char *zTrue, /* Label to show when parameter is true */
273 const char *zFalse /* Label to show when the parameter is false */
274 ){
275 assert( nSubmenuCtrl < ArraySize(aSubmenuCtrl) );
276 aSubmenuCtrl[nSubmenuCtrl].zName = zName;
277 aSubmenuCtrl[nSubmenuCtrl].zLabel = zTrue;
278 aSubmenuCtrl[nSubmenuCtrl].zFalse = zFalse;
279 aSubmenuCtrl[nSubmenuCtrl].eType = FF_BINARY;
280 nSubmenuCtrl++;
281 }
282 void style_submenu_multichoice(
283 const char *zName, /* Query parameter name */
284 int nChoice, /* Number of options */
285 const char **azChoice /* value/display pairs. 2*nChoice entries */
@@ -527,10 +541,28 @@
541 zQPV,
542 fossil_strcmp(zVal,zQPV)==0 ? " selected" : "",
543 aSubmenuCtrl[i].azChoice[j+1]
544 );
545 }
546 @ </select>
547 break;
548 }
549 case FF_BINARY: {
550 int isTrue = PB(zQPN);
551 cgi_printf(
552 "<select class='submenuctrl' size='1' name='%s' "
553 "onchange='gebi(\"f01\").submit();'>\n",
554 zQPN
555 );
556 cgi_printf(
557 "<option value='1'%s>%h</option>\n",
558 isTrue ? " selected":"", aSubmenuCtrl[i].zLabel
559 );
560 cgi_printf(
561 "<option value='0'%s>%h</option>\n",
562 (!isTrue) ? " selected":"", aSubmenuCtrl[i].zFalse
563 );
564 @ </select>
565 break;
566 }
567 }
568 }
569
+2 -2
--- src/timeline.c
+++ src/timeline.c
@@ -1298,11 +1298,11 @@
12981298
/* If both p= and d= are set, we don't have the uuid of d yet. */
12991299
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", d_rid);
13001300
}
13011301
url_add_parameter(&url, "d", zUuid);
13021302
}
1303
- style_submenu_checkbox("v","Files");
1303
+ style_submenu_binary("v","With Files","Without Files");
13041304
style_submenu_entry("n","Lines",1);
13051305
timeline_y_submenu();
13061306
}else if( f_rid && g.perm.Read ){
13071307
/* If f= is present, ignore all other parameters other than n= */
13081308
char *zUuid;
@@ -1542,11 +1542,11 @@
15421542
}
15431543
if( zSearch ){
15441544
blob_appendf(&desc, " matching \"%h\"", zSearch);
15451545
}
15461546
if( g.perm.Hyperlink ){
1547
- style_submenu_checkbox("v","Show Files");
1547
+ style_submenu_binary("v","With Files","Without Files");
15481548
if( zAfter || n==nEntry ){
15491549
zDate = db_text(0, "SELECT min(timestamp) FROM timeline /*scan*/");
15501550
timeline_submenu(&url, "Older", "b", zDate, "a");
15511551
free(zDate);
15521552
}
15531553
--- src/timeline.c
+++ src/timeline.c
@@ -1298,11 +1298,11 @@
1298 /* If both p= and d= are set, we don't have the uuid of d yet. */
1299 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", d_rid);
1300 }
1301 url_add_parameter(&url, "d", zUuid);
1302 }
1303 style_submenu_checkbox("v","Files");
1304 style_submenu_entry("n","Lines",1);
1305 timeline_y_submenu();
1306 }else if( f_rid && g.perm.Read ){
1307 /* If f= is present, ignore all other parameters other than n= */
1308 char *zUuid;
@@ -1542,11 +1542,11 @@
1542 }
1543 if( zSearch ){
1544 blob_appendf(&desc, " matching \"%h\"", zSearch);
1545 }
1546 if( g.perm.Hyperlink ){
1547 style_submenu_checkbox("v","Show Files");
1548 if( zAfter || n==nEntry ){
1549 zDate = db_text(0, "SELECT min(timestamp) FROM timeline /*scan*/");
1550 timeline_submenu(&url, "Older", "b", zDate, "a");
1551 free(zDate);
1552 }
1553
--- src/timeline.c
+++ src/timeline.c
@@ -1298,11 +1298,11 @@
1298 /* If both p= and d= are set, we don't have the uuid of d yet. */
1299 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", d_rid);
1300 }
1301 url_add_parameter(&url, "d", zUuid);
1302 }
1303 style_submenu_binary("v","With Files","Without Files");
1304 style_submenu_entry("n","Lines",1);
1305 timeline_y_submenu();
1306 }else if( f_rid && g.perm.Read ){
1307 /* If f= is present, ignore all other parameters other than n= */
1308 char *zUuid;
@@ -1542,11 +1542,11 @@
1542 }
1543 if( zSearch ){
1544 blob_appendf(&desc, " matching \"%h\"", zSearch);
1545 }
1546 if( g.perm.Hyperlink ){
1547 style_submenu_binary("v","With Files","Without Files");
1548 if( zAfter || n==nEntry ){
1549 zDate = db_text(0, "SELECT min(timestamp) FROM timeline /*scan*/");
1550 timeline_submenu(&url, "Older", "b", zDate, "a");
1551 free(zDate);
1552 }
1553

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button