Set page and update status

This commit is contained in:
Moritz Lipp 2009-12-26 17:44:13 +01:00
parent 0f2e9508ef
commit 488fb4aefb
2 changed files with 31 additions and 9 deletions

View file

@ -155,6 +155,12 @@ struct
GtkLabel *status_state; GtkLabel *status_state;
} Global; } Global;
struct
{
char* filename;
char* pages;
} State;
struct struct
{ {
PopplerDocument *document; PopplerDocument *document;
@ -170,8 +176,9 @@ struct
void init_zathura(); void init_zathura();
void change_mode(int); void change_mode(int);
void notify(int, char*); void notify(int, char*);
void update_status(char*, char*); void update_status();
void setCompletionRowColor(GtkBox*, int, int); void setCompletionRowColor(GtkBox*, int, int);
void set_page(int);
GtkEventBox* createCompletionRow(GtkBox*, char*, char*, gboolean); GtkEventBox* createCompletionRow(GtkBox*, char*, char*, gboolean);
/* shortcut declarations */ /* shortcut declarations */
@ -246,6 +253,9 @@ init_zathura()
/* other */ /* other */
Zathura.Global.mode = NORMAL; Zathura.Global.mode = NORMAL;
Zathura.State.filename = "[No Name]";
Zathura.State.pages = "";
/* UI */ /* UI */
Zathura.UI.window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); Zathura.UI.window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
Zathura.UI.box = GTK_BOX(gtk_vbox_new(FALSE, 0)); Zathura.UI.box = GTK_BOX(gtk_vbox_new(FALSE, 0));
@ -370,15 +380,13 @@ void notify(int level, char* message)
} }
void void
update_status(char* text, char* state) update_status()
{ {
/* update text */ /* update text */
if(text) gtk_label_set_markup((GtkLabel*) Zathura.Global.status_text, Zathura.State.filename);
gtk_label_set_markup((GtkLabel*) Zathura.Global.status_text, text);
/* update state */ /* update state */
if(state) gtk_label_set_markup((GtkLabel*) Zathura.Global.status_state, Zathura.State.pages);
gtk_label_set_markup((GtkLabel*) Zathura.Global.status_state, state);
} }
GtkEventBox* 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 */ /* shortcut implementation */
void void
sc_abort(Argument* argument) sc_abort(Argument* argument)
@ -901,10 +922,11 @@ cmd_open(int argc, char** argv)
return FALSE; return FALSE;
} }
Zathura.PDF.page_number = 0;
Zathura.PDF.number_of_pages = poppler_document_get_n_pages(Zathura.PDF.document); Zathura.PDF.number_of_pages = poppler_document_get_n_pages(Zathura.PDF.document);
Zathura.PDF.file = file; Zathura.PDF.file = file;
set_page(1);
return TRUE; return TRUE;
} }
@ -1156,7 +1178,7 @@ int main(int argc, char* argv[])
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
init_zathura(); init_zathura();
update_status("Text", "State"); update_status();
gtk_widget_show_all(GTK_WIDGET(Zathura.UI.window)); gtk_widget_show_all(GTK_WIDGET(Zathura.UI.window));
gtk_main(); gtk_main();