2021-05-02 17:24:40 +03:00
|
|
|
#include <lua.h>
|
|
|
|
#include <lualib.h>
|
|
|
|
#include <lauxlib.h>
|
|
|
|
#include <luajit.h>
|
2021-05-02 15:07:43 +03:00
|
|
|
#include "ui.h"
|
|
|
|
|
2021-05-02 17:24:40 +03:00
|
|
|
struct application_state* page_application_new() {
|
|
|
|
struct application_state* state = malloc(sizeof(struct application_state));
|
|
|
|
state->gapp = gtk_application_new("xyz.hippoz.nettle", G_APPLICATION_FLAGS_NONE);
|
|
|
|
return state;
|
|
|
|
}
|
2021-05-02 15:07:43 +03:00
|
|
|
|
2021-05-02 17:24:40 +03:00
|
|
|
void page_application_init(struct application_state* state) {
|
|
|
|
state->page_window = gtk_application_window_new(state->gapp);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(state->page_window), "Window");
|
|
|
|
gtk_window_set_default_size(GTK_WINDOW(state->page_window), 200, 200);
|
2021-05-02 15:07:43 +03:00
|
|
|
|
2021-05-02 17:24:40 +03:00
|
|
|
state->scrolled = gtk_scrolled_window_new(NULL, NULL);
|
2021-05-02 15:07:43 +03:00
|
|
|
|
2021-05-02 17:24:40 +03:00
|
|
|
state->pageview_buffer = gtk_text_buffer_new(NULL);
|
|
|
|
state->pageview = gtk_text_view_new_with_buffer(GTK_TEXT_BUFFER(state->pageview_buffer));
|
|
|
|
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(state->pageview), GTK_WRAP_WORD_CHAR);
|
|
|
|
gtk_text_view_set_editable(GTK_TEXT_VIEW(state->pageview), 0);
|
|
|
|
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(state->pageview), 0);
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(state->scrolled), GTK_WIDGET(state->pageview));
|
|
|
|
gtk_container_add(GTK_CONTAINER(state->page_window), GTK_WIDGET(state->scrolled));
|
|
|
|
}
|
|
|
|
|
|
|
|
void page_application_show(struct application_state* state) {
|
|
|
|
gtk_widget_show_all(state->page_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
void page_application_text_buffer_append_text(struct application_state* state, const char* display_text) {
|
|
|
|
GtkTextIter iter;
|
|
|
|
gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(state->pageview_buffer), &iter);
|
|
|
|
gtk_text_buffer_insert(GTK_TEXT_BUFFER(state->pageview_buffer), &iter, display_text, -1);
|
2021-05-03 14:51:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void page_application_text_buffer_set_text(struct application_state* state, const char* text) {
|
|
|
|
gtk_text_buffer_set_text(state->pageview_buffer, text, -1);
|
2021-05-02 15:07:43 +03:00
|
|
|
}
|