mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-26 22:16:01 +01:00
Set page and update status
This commit is contained in:
parent
0f2e9508ef
commit
488fb4aefb
2 changed files with 31 additions and 9 deletions
|
@ -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 } },
|
||||
|
|
38
zathura.c
38
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();
|
||||
|
|
Loading…
Reference in a new issue