Skip to content

Commit

Permalink
Don't show media chooser when there is only one source (Issue #125)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Feb 4, 2021
1 parent 8621cf4 commit 014a3b8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changes in v1.0.2

- The `papplSystemSetVersions` function now allows changes while the system is
running (Issue #123)
- The printing defaults page no longer shows a media chooser when there is a
single source (Issue #125)
- The DNS-SD support functions did not handle when the Avahi daemon is not
running (Issue #129)
- Deleting and adding a printer with the same name will cause a crash
Expand Down
40 changes: 25 additions & 15 deletions pappl/printer-webif.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,30 +483,40 @@ _papplPrinterWebDefaults(
" <tbody>\n");

// media-col-default
papplClientHTMLPuts(client, " <tr><th>Media:</th><td><select name=\"media-source\">");
for (i = 0; i < data.num_source; i ++)
papplClientHTMLPuts(client, " <tr><th>Media:</th><td>");

if (data.num_source > 1)
{
// See if any two sources have the same size...
for (j = i + 1; j < data.num_source; j ++)
papplClientHTMLPuts(client, "<select name=\"media-source\">");

for (i = 0; i < data.num_source; i ++)
{
if (data.media_ready[i].size_width > 0 && data.media_ready[i].size_width == data.media_ready[j].size_width && data.media_ready[i].size_length == data.media_ready[j].size_length)
// See if any two sources have the same size...
for (j = i + 1; j < data.num_source; j ++)
{
show_source = true;
break;
if (data.media_ready[i].size_width > 0 && data.media_ready[i].size_width == data.media_ready[j].size_width && data.media_ready[i].size_length == data.media_ready[j].size_length)
{
show_source = true;
break;
}
}
}
}

for (i = 0; i < data.num_source; i ++)
{
keyword = data.source[i];

if (strcmp(keyword, "manual"))
for (i = 0; i < data.num_source; i ++)
{
papplClientHTMLPrintf(client, "<option value=\"%s\"%s>%s</option>", keyword, !strcmp(keyword, data.media_default.source) ? " selected" : "", localize_media(data.media_ready + i, show_source, text, sizeof(text)));
keyword = data.source[i];

if (strcmp(keyword, "manual"))
{
papplClientHTMLPrintf(client, "<option value=\"%s\"%s>%s</option>", keyword, !strcmp(keyword, data.media_default.source) ? " selected" : "", localize_media(data.media_ready + i, show_source, text, sizeof(text)));
}
}
papplClientHTMLPuts(client, "</select>");
}
papplClientHTMLPrintf(client, "</select> <a class=\"btn\" href=\"%s/media\">Configure Media</a></td></tr>\n", printer->uriname);
else
papplClientHTMLEscape(client, localize_media(data.media_ready, false, text, sizeof(text)), 0);

papplClientHTMLPrintf(client, " <a class=\"btn\" href=\"%s/media\">Configure Media</a></td></tr>\n", printer->uriname);

// orientation-requested-default
papplClientHTMLPuts(client, " <tr><th>Orientation:</th><td>");
Expand Down
3 changes: 1 addition & 2 deletions testsuite/pwg-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ pwg_callback(
driver_data->num_media = (int)(sizeof(pwg_4inch_media) / sizeof(pwg_4inch_media[0]));
memcpy(driver_data->media, pwg_4inch_media, sizeof(pwg_4inch_media));

driver_data->num_source = 2;
driver_data->num_source = 1;
driver_data->source[0] = "main-roll";
driver_data->source[1] = "alternate-roll";

strlcpy(driver_data->media_ready[0].size_name, "na_index-4x6_4x6in", sizeof(driver_data->media_ready[0].size_name));
strlcpy(driver_data->media_ready[1].size_name, "oe_address-label_1.25x3.5in", sizeof(driver_data->media_ready[1].size_name));
Expand Down
2 changes: 1 addition & 1 deletion xcode/pappl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_IDENTITY = "Apple Development";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
Expand Down

0 comments on commit 014a3b8

Please sign in to comment.