diff --git a/config.def.h b/config.def.h index 21f10bf..14be650 100644 --- a/config.def.h +++ b/config.def.h @@ -42,7 +42,7 @@ Shortcut shortcuts[] = { {0, GDK_i, sc_change_mode, NORMAL, { INSERT } }, {0, GDK_v, sc_change_mode, NORMAL, { VISUAL } }, {0, GDK_colon, sc_focus_inputbar, -1, { .data = ":" } }, - {0, GDK_o, sc_focus_inputbar, -1, { .data = ":open" } }, + {0, GDK_o, sc_focus_inputbar, -1, { .data = ":open " } }, {0, GDK_r, sc_rotate, -1, {0} }, {0, GDK_h, sc_scroll, -1, { LEFT } }, {0, GDK_j, sc_scroll, -1, { UP } }, diff --git a/zathura.c b/zathura.c index 5e5db58..6e6aa44 100644 --- a/zathura.c +++ b/zathura.c @@ -155,6 +155,12 @@ struct GtkLabel *status_state; } Global; + struct + { + char* filename; + char* pages; + } State; + struct { PopplerDocument *document; @@ -170,8 +176,9 @@ struct void init_zathura(); void change_mode(int); void notify(int, char*); -void update_status(char*, char*); +void update_status(); void setCompletionRowColor(GtkBox*, int, int); +void set_page(int); GtkEventBox* createCompletionRow(GtkBox*, char*, char*, gboolean); /* shortcut declarations */ @@ -246,6 +253,9 @@ init_zathura() /* other */ Zathura.Global.mode = NORMAL; + Zathura.State.filename = "[No Name]"; + Zathura.State.pages = ""; + /* UI */ Zathura.UI.window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); Zathura.UI.box = GTK_BOX(gtk_vbox_new(FALSE, 0)); @@ -370,15 +380,13 @@ void notify(int level, char* message) } void -update_status(char* text, char* state) +update_status() { /* update text */ - if(text) - gtk_label_set_markup((GtkLabel*) Zathura.Global.status_text, text); + gtk_label_set_markup((GtkLabel*) Zathura.Global.status_text, Zathura.State.filename); /* update state */ - if(state) - gtk_label_set_markup((GtkLabel*) Zathura.Global.status_state, state); + gtk_label_set_markup((GtkLabel*) Zathura.Global.status_state, Zathura.State.pages); } GtkEventBox* @@ -462,6 +470,19 @@ setCompletionRowColor(GtkBox* results, int mode, int id) } } +void +set_page(int page) +{ + if(page > Zathura.PDF.number_of_pages || page < 1) + { + notify(WARNING, "Could not open page"); + return; + } + + Zathura.PDF.page_number = page; + Zathura.State.pages = g_strdup_printf("[%i/%i]", page, Zathura.PDF.number_of_pages); +} + /* shortcut implementation */ void sc_abort(Argument* argument) @@ -901,10 +922,11 @@ cmd_open(int argc, char** argv) return FALSE; } - Zathura.PDF.page_number = 0; Zathura.PDF.number_of_pages = poppler_document_get_n_pages(Zathura.PDF.document); Zathura.PDF.file = file; + set_page(1); + return TRUE; } @@ -1156,7 +1178,7 @@ int main(int argc, char* argv[]) gtk_init(&argc, &argv); init_zathura(); - update_status("Text", "State"); + update_status(); gtk_widget_show_all(GTK_WIDGET(Zathura.UI.window)); gtk_main();