mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-27 16:54:39 +01:00
CS
This commit is contained in:
parent
bb0a0a7e9c
commit
a1944d762d
3 changed files with 16 additions and 13 deletions
|
@ -649,15 +649,13 @@ zathura_document_get_document_size(zathura_document_t* document,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zathura_document_set_cell_size(zathura_document_t* document,
|
zathura_document_set_cell_size(zathura_document_t* document, unsigned int cell_height,
|
||||||
unsigned int cell_height,
|
|
||||||
unsigned int cell_width)
|
unsigned int cell_width)
|
||||||
{
|
{
|
||||||
document->cell_width = cell_width;
|
document->cell_width = cell_width;
|
||||||
document->cell_height = cell_height;
|
document->cell_height = cell_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding,
|
zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding,
|
||||||
unsigned int pages_per_row, unsigned int first_page_column)
|
unsigned int pages_per_row, unsigned int first_page_column)
|
||||||
|
|
|
@ -328,7 +328,6 @@ ZATHURA_PLUGIN_API void zathura_document_get_cell_size(zathura_document_t* docum
|
||||||
ZATHURA_PLUGIN_API void zathura_document_get_document_size(zathura_document_t* document,
|
ZATHURA_PLUGIN_API void zathura_document_get_document_size(zathura_document_t* document,
|
||||||
unsigned int* height, unsigned int* width);
|
unsigned int* height, unsigned int* width);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cell height and width of the document
|
* Sets the cell height and width of the document
|
||||||
*
|
*
|
||||||
|
|
|
@ -967,19 +967,25 @@ document_open_password_dialog(gpointer data)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct sample_s {
|
typedef struct {
|
||||||
double h;
|
double h;
|
||||||
double w;
|
double w;
|
||||||
unsigned int freq;
|
int freq;
|
||||||
} sample_t;
|
} sample_t;
|
||||||
|
|
||||||
static int document_page_size_comp(const void *a, const void *b) {
|
static int
|
||||||
return ((sample_t *)a)->freq - ((sample_t *)b)->freq;
|
document_page_size_comp(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const sample_t* lhs = a;
|
||||||
|
const sample_t* rhs = b;
|
||||||
|
return lhs->freq - rhs->freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void document_open_page_most_frequent_size(zathura_document_t *document,
|
static void
|
||||||
|
document_open_page_most_frequent_size(zathura_document_t *document,
|
||||||
unsigned int *width,
|
unsigned int *width,
|
||||||
unsigned int *height) {
|
unsigned int *height)
|
||||||
|
{
|
||||||
sample_t samples[32] = {{0}}; /* a max heap */
|
sample_t samples[32] = {{0}}; /* a max heap */
|
||||||
unsigned int number_of_pages = zathura_document_get_number_of_pages(document);
|
unsigned int number_of_pages = zathura_document_get_number_of_pages(document);
|
||||||
unsigned int last_sample = (number_of_pages > 32) ? 32 : number_of_pages;
|
unsigned int last_sample = (number_of_pages > 32) ? 32 : number_of_pages;
|
||||||
|
@ -1001,7 +1007,7 @@ static void document_open_page_most_frequent_size(zathura_document_t *document,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort((void *)samples, 32, sizeof(sample_t), document_page_size_comp);
|
qsort(samples, 32, sizeof(sample_t), document_page_size_comp);
|
||||||
|
|
||||||
*width = samples[31].w;
|
*width = samples[31].w;
|
||||||
*height = samples[31].h;
|
*height = samples[31].h;
|
||||||
|
|
Loading…
Add table
Reference in a new issue