Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
pwmt
zathura
Commits
712e4bd4
Commit
712e4bd4
authored
Oct 15, 2011
by
Sebastian Ramacher
Browse files
use the correct sorting function
parent
09041f7d
Changes
5
Hide whitespace changes
Inline
Side-by-side
bookmarks.c
View file @
712e4bd4
...
...
@@ -97,3 +97,18 @@ zathura_bookmarks_load(zathura_t* zathura, const gchar* file) {
return
true
;
}
int
zathura_bookmarks_compare
(
zathura_bookmark_t
*
lhs
,
zathura_bookmark_t
*
rhs
)
{
if
(
lhs
==
NULL
&&
rhs
==
NULL
)
{
return
0
;
}
if
(
lhs
==
NULL
)
{
return
-
1
;
}
if
(
rhs
==
NULL
)
{
return
1
;
}
return
g_strcmp0
(
lhs
->
id
,
rhs
->
id
);
}
bookmarks.h
View file @
712e4bd4
...
...
@@ -53,4 +53,12 @@ void zathura_bookmark_free(zathura_bookmark_t* bookmark);
*/
bool
zathura_bookmarks_load
(
zathura_t
*
zathura
,
const
gchar
*
file
);
/**
* Compare two bookmarks.
* @param lhs a bookmark
* @param rhs a bookmark
* @returns g_strcmp0(lhs->id, rhs->id)
*/
int
zathura_bookmarks_compare
(
zathura_bookmark_t
*
lhs
,
zathura_bookmark_t
*
rhs
);
#endif // BOOKMARKS_H
database-plain.c
View file @
712e4bd4
...
...
@@ -194,7 +194,8 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
return
NULL
;
}
girara_list_t
*
result
=
girara_list_new
();
girara_list_t
*
result
=
girara_sorted_list_new2
((
girara_compare_function_t
)
zathura_bookmarks_compare
,
(
girara_free_function_t
)
zathura_bookmark_free
);
if
(
result
==
NULL
)
{
return
NULL
;
}
...
...
database-sqlite.c
View file @
712e4bd4
...
...
@@ -182,12 +182,12 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
return
NULL
;
}
girara_list_t
*
result
=
girara_list_new
();
girara_list_t
*
result
=
girara_sorted_list_new2
((
girara_compare_function_t
)
zathura_bookmarks_compare
,
(
girara_free_function_t
)
zathura_bookmark_free
);
if
(
result
==
NULL
)
{
sqlite3_finalize
(
stmt
);
return
NULL
;
}
girara_list_set_free_function
(
result
,
(
girara_free_function_t
)
zathura_bookmark_free
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
)
{
zathura_bookmark_t
*
bookmark
=
g_malloc0
(
sizeof
(
zathura_bookmark_t
));
...
...
zathura.c
View file @
712e4bd4
...
...
@@ -211,7 +211,7 @@ zathura_init(int argc, char* argv[])
}
/* bookmarks */
zathura
->
bookmarks
.
bookmarks
=
girara_sorted_list_new2
((
girara_compare_function_t
)
g_strcmp0
,
zathura
->
bookmarks
.
bookmarks
=
girara_sorted_list_new2
((
girara_compare_function_t
)
zathura_bookmarks_compare
,
(
girara_free_function_t
)
zathura_bookmark_free
);
/* open document if passed */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment