mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 20:53:46 +01:00
Continuous basics
This commit is contained in:
parent
eebdc8dece
commit
3f961f6c18
28
utils.c
28
utils.c
@ -120,3 +120,31 @@ execute_command(char* const argv[], char** output)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdkPixbuf*
|
||||||
|
page_blank(unsigned int width, unsigned int height)
|
||||||
|
{
|
||||||
|
if((width == 0) || (height == 0)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
guchar* buffer = malloc(sizeof(guchar) * (width * height * 1));
|
||||||
|
if(!buffer) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* draw white */
|
||||||
|
for(unsigned int i = 0; i < width * height; i++) {
|
||||||
|
buffer[i] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(buffer, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||||
|
width, height, 1, NULL, NULL);
|
||||||
|
|
||||||
|
if(!pixbuf) {
|
||||||
|
free(buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pixbuf;
|
||||||
|
}
|
||||||
|
2
utils.h
2
utils.h
@ -4,9 +4,11 @@
|
|||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
bool file_exists(const char* path);
|
bool file_exists(const char* path);
|
||||||
const char* file_get_extension(const char* path);
|
const char* file_get_extension(const char* path);
|
||||||
bool execute_command(char* const argv[], char** output);
|
bool execute_command(char* const argv[], char** output);
|
||||||
|
GdkPixbuf* page_blank(unsigned int width, unsigned int height);
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
31
zathura.c
31
zathura.c
@ -1,10 +1,13 @@
|
|||||||
/* See LICENSE file for license and copyright information */
|
/* See LICENSE file for license and copyright information */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "ft/document.h"
|
#include "ft/document.h"
|
||||||
#include "shortcuts.h"
|
#include "shortcuts.h"
|
||||||
#include "zathura.h"
|
#include "zathura.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
/* function implementation */
|
/* function implementation */
|
||||||
bool
|
bool
|
||||||
@ -81,10 +84,30 @@ document_open(const char* path, const char* password)
|
|||||||
|
|
||||||
Zathura.document = document;
|
Zathura.document = document;
|
||||||
|
|
||||||
/*if(!page_set(0)) {*/
|
GtkWidget* page_view = gtk_vbox_new(FALSE, 0);
|
||||||
/*zathura_document_free(document);*/
|
gtk_box_set_spacing(GTK_BOX(page_view), 0);
|
||||||
/*return false;*/
|
|
||||||
/*}*/
|
for(unsigned int i = 0; i < document->number_of_pages; i++)
|
||||||
|
{
|
||||||
|
GdkPixbuf* pixbuf = page_blank(document->pages[i]->width, document->pages[i]->height);
|
||||||
|
if(!pixbuf) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget* image = gtk_image_new();
|
||||||
|
if(!image) {
|
||||||
|
g_object_unref(pixbuf);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
|
||||||
|
gtk_widget_show(image);
|
||||||
|
gtk_box_pack_start(GTK_BOX(page_view), image, TRUE, TRUE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_show(page_view);
|
||||||
|
|
||||||
|
girara_set_view(Zathura.UI.session, page_view);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user