mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 05:36:00 +01:00
Delete bookmark
This commit is contained in:
parent
db76477a18
commit
0c5f0dfb0c
2 changed files with 55 additions and 12 deletions
25
config.def.h
25
config.def.h
|
@ -97,18 +97,19 @@ InputbarShortcut inputbar_shortcuts[] = {
|
|||
|
||||
/* commands */
|
||||
Command commands[] = {
|
||||
/* command, abbreviation, function, completion, description */
|
||||
{"bmark", "b", cmd_bookmark, 0, "Bookmark current page" },
|
||||
{"blist", 0, cmd_open_bookmark, cc_bookmark, "List and open bookmark" },
|
||||
{"close", "c", cmd_close, 0, "Close current file" },
|
||||
{"export", "e", cmd_export, cc_export, "Export images or attached files" },
|
||||
{"info", "i", cmd_info, 0, "Show information about the document" },
|
||||
{"open", "o", cmd_open, cc_open, "Open a file" },
|
||||
{"print", "p", cmd_print, cc_print, "Print the document" },
|
||||
{"rotate", "r", cmd_rotate, 0, "Rotate the page" },
|
||||
{"set", "s", cmd_set, cc_set, "Set an option" },
|
||||
{"quit", "q", cmd_quit, 0, "Quit zjui" },
|
||||
{"write", "w", cmd_save, 0, "Save the document" },
|
||||
/* command, abbreviation, function, completion, description */
|
||||
{"bmark", "b", cmd_bookmark, 0, "Bookmark current page" },
|
||||
{"blist", 0, cmd_open_bookmark, cc_bookmark, "List and open bookmark" },
|
||||
{"close", "c", cmd_close, 0, "Close current file" },
|
||||
{"delbmark", 0, cmd_delete_bookmark, cc_bookmark, "Bookmark current page" },
|
||||
{"export", "e", cmd_export, cc_export, "Export images or attached files" },
|
||||
{"info", "i", cmd_info, 0, "Show information about the document" },
|
||||
{"open", "o", cmd_open, cc_open, "Open a file" },
|
||||
{"print", "p", cmd_print, cc_print, "Print the document" },
|
||||
{"rotate", "r", cmd_rotate, 0, "Rotate the page" },
|
||||
{"set", "s", cmd_set, cc_set, "Set an option" },
|
||||
{"quit", "q", cmd_quit, 0, "Quit zjui" },
|
||||
{"write", "w", cmd_save, 0, "Save the document" },
|
||||
};
|
||||
|
||||
/* buffer commands */
|
||||
|
|
42
zathura.c
42
zathura.c
|
@ -283,6 +283,7 @@ void isc_string_manipulation(Argument*);
|
|||
gboolean cmd_bookmark(int, char**);
|
||||
gboolean cmd_open_bookmark(int, char**);
|
||||
gboolean cmd_close(int, char**);
|
||||
gboolean cmd_delete_bookmark(int, char**);
|
||||
gboolean cmd_export(int, char**);
|
||||
gboolean cmd_info(int, char**);
|
||||
gboolean cmd_open(int, char**);
|
||||
|
@ -1694,6 +1695,47 @@ cmd_close(int argc, char** argv)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_delete_bookmark(int argc, char** argv)
|
||||
{
|
||||
if(!Zathura.PDF.document || argc < 1)
|
||||
return TRUE;
|
||||
|
||||
/* get id */
|
||||
int i;
|
||||
GString *id = g_string_new("");
|
||||
|
||||
for(i = 0; i < argc; i++)
|
||||
{
|
||||
if(i != 0)
|
||||
id = g_string_append_c(id, ' ');
|
||||
|
||||
id = g_string_append(id, argv[i]);
|
||||
}
|
||||
|
||||
/* check for bookmark to delete */
|
||||
for(i = 0; i < Zathura.Bookmarks.number_of_bookmarks; i++)
|
||||
{
|
||||
if(!strcmp(id->str, Zathura.Bookmarks.bookmarks[i].id))
|
||||
{
|
||||
/* update key file */
|
||||
g_key_file_remove_key(Zathura.Bookmarks.data, Zathura.PDF.file, Zathura.Bookmarks.bookmarks[i].id, NULL);
|
||||
|
||||
/* update bookmarks */
|
||||
Zathura.Bookmarks.bookmarks[i].id = Zathura.Bookmarks.bookmarks[Zathura.Bookmarks.number_of_bookmarks - 1].id;
|
||||
Zathura.Bookmarks.bookmarks[i].page = Zathura.Bookmarks.bookmarks[Zathura.Bookmarks.number_of_bookmarks - 1].page;
|
||||
Zathura.Bookmarks.bookmarks = realloc(Zathura.Bookmarks.bookmarks,
|
||||
Zathura.Bookmarks.number_of_bookmarks * sizeof(Bookmark));
|
||||
|
||||
Zathura.Bookmarks.number_of_bookmarks--;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_export(int argc, char** argv)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue