mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-27 13:26:00 +01:00
Added reload shortcut
This commit is contained in:
parent
2efdabc6a0
commit
6f6478b0ad
2 changed files with 34 additions and 22 deletions
|
@ -89,6 +89,7 @@ Shortcut shortcuts[] = {
|
||||||
{0, GDK_o, sc_focus_inputbar, NORMAL, { .data = ":open " } },
|
{0, GDK_o, sc_focus_inputbar, NORMAL, { .data = ":open " } },
|
||||||
{0, GDK_f, sc_follow, NORMAL, {0} },
|
{0, GDK_f, sc_follow, NORMAL, {0} },
|
||||||
{0, GDK_r, sc_rotate, NORMAL, {0} },
|
{0, GDK_r, sc_rotate, NORMAL, {0} },
|
||||||
|
{0, GDK_R, sc_reload, NORMAL, {0} },
|
||||||
{0, GDK_h, sc_scroll, NORMAL, { LEFT } },
|
{0, GDK_h, sc_scroll, NORMAL, { LEFT } },
|
||||||
{0, GDK_j, sc_scroll, NORMAL, { DOWN } },
|
{0, GDK_j, sc_scroll, NORMAL, { DOWN } },
|
||||||
{0, GDK_k, sc_scroll, NORMAL, { UP } },
|
{0, GDK_k, sc_scroll, NORMAL, { UP } },
|
||||||
|
|
55
zathura.c
55
zathura.c
|
@ -315,6 +315,7 @@ void sc_focus_inputbar(Argument*);
|
||||||
void sc_follow(Argument*);
|
void sc_follow(Argument*);
|
||||||
void sc_navigate(Argument*);
|
void sc_navigate(Argument*);
|
||||||
void sc_recolor(Argument*);
|
void sc_recolor(Argument*);
|
||||||
|
void sc_reload(Argument*);
|
||||||
void sc_rotate(Argument*);
|
void sc_rotate(Argument*);
|
||||||
void sc_scroll(Argument*);
|
void sc_scroll(Argument*);
|
||||||
void sc_search(Argument*);
|
void sc_search(Argument*);
|
||||||
|
@ -1527,6 +1528,37 @@ sc_recolor(Argument* argument)
|
||||||
draw(Zathura.PDF.page_number);
|
draw(Zathura.PDF.page_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_reload(Argument* argument)
|
||||||
|
{
|
||||||
|
if(!Zathura.PDF.document)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* save old information */
|
||||||
|
g_static_mutex_lock(&(Zathura.Lock.pdf_obj_lock));
|
||||||
|
char* path = Zathura.PDF.file ? strdup(Zathura.PDF.file) : NULL;
|
||||||
|
char* password = Zathura.PDF.password ? strdup(Zathura.PDF.password) : NULL;
|
||||||
|
int scale = Zathura.PDF.scale;
|
||||||
|
int page = Zathura.PDF.page_number;
|
||||||
|
int rotate = Zathura.PDF.rotate;
|
||||||
|
g_static_mutex_unlock(&(Zathura.Lock.pdf_obj_lock));
|
||||||
|
|
||||||
|
/* reopen and restore settings */
|
||||||
|
cmd_close(0, NULL);
|
||||||
|
open_file(path, password);
|
||||||
|
|
||||||
|
Zathura.PDF.scale = scale;
|
||||||
|
Zathura.PDF.rotate = rotate;
|
||||||
|
|
||||||
|
draw(page);
|
||||||
|
|
||||||
|
if(path)
|
||||||
|
free(path);
|
||||||
|
if(password)
|
||||||
|
free(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_rotate(Argument* argument)
|
sc_rotate(Argument* argument)
|
||||||
{
|
{
|
||||||
|
@ -3586,28 +3618,7 @@ cb_watch_file(GFileMonitor* monitor, GFile* file, GFile* other_file, GFileMonito
|
||||||
if(event != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
|
if(event != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* save old information */
|
sc_reload(NULL);
|
||||||
g_static_mutex_lock(&(Zathura.Lock.pdf_obj_lock));
|
|
||||||
char* path = Zathura.PDF.file ? strdup(Zathura.PDF.file) : NULL;
|
|
||||||
char* password = Zathura.PDF.password ? strdup(Zathura.PDF.password) : NULL;
|
|
||||||
int scale = Zathura.PDF.scale;
|
|
||||||
int page = Zathura.PDF.page_number;
|
|
||||||
g_static_mutex_unlock(&(Zathura.Lock.pdf_obj_lock));
|
|
||||||
|
|
||||||
/* reopen and restore settings */
|
|
||||||
gdk_threads_enter();
|
|
||||||
cmd_close(0, NULL);
|
|
||||||
open_file(path, password);
|
|
||||||
|
|
||||||
Zathura.PDF.scale = scale;
|
|
||||||
|
|
||||||
draw(page);
|
|
||||||
gdk_threads_leave();
|
|
||||||
|
|
||||||
if(path)
|
|
||||||
free(path);
|
|
||||||
if(password)
|
|
||||||
free(password);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue