mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 21:53:46 +01:00
Delete bookmark
This commit is contained in:
parent
db76477a18
commit
0c5f0dfb0c
@ -101,6 +101,7 @@ Command commands[] = {
|
||||
{"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" },
|
||||
|
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 New Issue
Block a user