zathura/zathura.c

90 lines
2.0 KiB
C
Raw Normal View History

/* See LICENSE file for license and copyright information */
2010-11-12 13:48:18 +01:00
#include "callbacks.h"
#include "config.h"
2010-11-18 02:35:33 +01:00
#include "ft/document.h"
2010-11-12 13:48:18 +01:00
#include "shortcuts.h"
2010-11-10 19:18:01 +01:00
#include "zathura.h"
2009-12-26 17:57:46 +01:00
2010-11-10 19:18:01 +01:00
/* function implementation */
bool
init_zathura()
2010-06-03 18:05:34 +02:00
{
2010-11-17 22:51:15 +01:00
if(!(Zathura.UI.session = girara_session_create())) {
2010-11-10 19:18:01 +01:00
return false;
2010-11-17 22:51:15 +01:00
}
2010-06-03 18:05:34 +02:00
2010-11-17 22:51:15 +01:00
if(!girara_session_init(Zathura.UI.session)) {
2010-11-10 19:18:01 +01:00
return false;
2010-11-17 22:51:15 +01:00
}
2010-06-03 18:05:34 +02:00
2010-11-13 12:40:48 +01:00
/* UI */
2010-11-18 21:22:43 +01:00
Zathura.UI.statusbar.file = girara_statusbar_item_add(Zathura.UI.session, TRUE, TRUE, TRUE, NULL);
if(!Zathura.UI.statusbar.file) {
2010-11-13 12:40:48 +01:00
girara_session_destroy(Zathura.UI.session);
return false;
}
2010-11-18 21:22:43 +01:00
Zathura.UI.statusbar.buffer = girara_statusbar_item_add(Zathura.UI.session, FALSE, FALSE, FALSE, NULL);
if(!Zathura.UI.statusbar.buffer) {
girara_session_destroy(Zathura.UI.session);
return false;
}
Zathura.UI.statusbar.page_number = girara_statusbar_item_add(Zathura.UI.session, FALSE, FALSE, FALSE, NULL);
if(!Zathura.UI.statusbar.page_number) {
girara_session_destroy(Zathura.UI.session);
return false;
}
girara_statusbar_item_set_text(Zathura.UI.session, Zathura.UI.statusbar.file, "[No Name]");
2010-11-12 13:48:18 +01:00
/* signals */
g_signal_connect(G_OBJECT(Zathura.UI.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), NULL);
2010-11-13 12:40:48 +01:00
/* girara events */
Zathura.UI.session->events.buffer_changed = buffer_changed;
2010-11-12 13:48:18 +01:00
/* configuration */
config_load_default();
2010-11-10 19:18:01 +01:00
return true;
2010-06-03 18:05:34 +02:00
}
2009-08-11 23:18:50 +02:00
/* main function */
int main(int argc, char* argv[])
2009-08-11 23:18:50 +02:00
{
g_thread_init(NULL);
gdk_threads_init();
2009-08-11 23:18:50 +02:00
gtk_init(&argc, &argv);
2010-11-18 14:51:13 +01:00
if(!init_zathura()) {
printf("error: coult not initialize zathura\n");
return -1;
}
2010-11-18 02:35:33 +01:00
if(argc > 1) {
zathura_document_t* document = zathura_document_open(argv[1], NULL);
2010-11-18 14:51:13 +01:00
2010-11-18 02:35:33 +01:00
if(!document) {
return -1;
}
2010-11-18 14:51:13 +01:00
zathura_page_t* page = zathura_page_get(document, 0);
if(!page) {
zathura_document_free(document);
return -2;
}
zathura_page_free(page);
2010-11-18 02:35:33 +01:00
zathura_document_free(document);
}
2010-01-01 13:54:21 +01:00
2010-11-18 14:51:13 +01:00
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
2009-08-11 23:18:50 +02:00
return 0;
}