Check for numeric events

This commit is contained in:
Moritz Lipp 2012-05-01 19:09:33 +02:00
parent e4c145a67e
commit 800d039293
4 changed files with 39 additions and 3 deletions

View file

@ -335,3 +335,28 @@ cb_setting_recolor_change(girara_session_t* session, const char* name,
render_all(zathura);
}
}
bool
cb_unknown_command(girara_session_t* session, const char* input)
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
g_return_val_if_fail(input != NULL, false);
zathura_t* zathura = session->global.data;
if (zathura->document == NULL) {
return false;
}
/* check for number */
for (unsigned int i = 0; i < strlen(input); i++) {
if (g_ascii_isdigit(input[i]) == FALSE) {
return false;
}
}
page_set(zathura, atoi(input) - 1);
return true;
}

View file

@ -111,4 +111,14 @@ bool cb_view_resized(GtkWidget* widget, GtkAllocation* allocation, zathura_t* za
void cb_setting_recolor_change(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data);
/**
* Unknown command handler which is used to handle the strict numeric goto
* command
*
* @param session The girara session
* @param input The command input
* @return true if the input has been handled
*/
bool cb_unknown_command(girara_session_t* session, const char* input);
#endif // CALLBACKS_H

View file

@ -338,7 +338,7 @@ cc_export(girara_session_t* session, const char* input)
girara_list_t* images = zathura_page_images_get(page, NULL);
if (images != NULL) {
unsigned int image_number = 1;
GIRARA_LIST_FOREACH(images, zathura_image_t*, iter, image)
GIRARA_LIST_FOREACH(images, zathura_image_t*, iter, UNUSED(image))
char* image_string = g_strdup_printf("image-p%d-%d", page_id + 1, image_number);
girara_completion_group_add_element(image_group, image_string, NULL);
g_free(image_string);

View file

@ -165,7 +165,7 @@ zathura_init(int argc, char* argv[])
goto error_out;
}
zathura->ui.session->global.data = zathura;
zathura->ui.session->global.data = zathura;
/* global settings */
zathura->global.recolor = false;
@ -206,7 +206,8 @@ zathura_init(int argc, char* argv[])
}
/* girara events */
zathura->ui.session->events.buffer_changed = cb_buffer_changed;
zathura->ui.session->events.buffer_changed = cb_buffer_changed;
zathura->ui.session->events.unknown_command = cb_unknown_command;
/* page view */
zathura->ui.page_widget = gtk_table_new(0, 0, TRUE);