mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 05:25:59 +01:00
Simplify
This commit is contained in:
parent
88e7c7afe8
commit
d63b704808
1 changed files with 21 additions and 19 deletions
|
@ -373,7 +373,7 @@ typedef enum zathura_link_action_e
|
||||||
ZATHURA_LINK_ACTION_DISPLAY
|
ZATHURA_LINK_ACTION_DISPLAY
|
||||||
} zathura_link_action_t;
|
} zathura_link_action_t;
|
||||||
|
|
||||||
static bool
|
static gboolean
|
||||||
handle_link(GtkEntry* entry, girara_session_t* session,
|
handle_link(GtkEntry* entry, girara_session_t* session,
|
||||||
zathura_link_action_t action)
|
zathura_link_action_t action)
|
||||||
{
|
{
|
||||||
|
@ -381,19 +381,19 @@ handle_link(GtkEntry* entry, girara_session_t* session,
|
||||||
g_return_val_if_fail(session->global.data != NULL, FALSE);
|
g_return_val_if_fail(session->global.data != NULL, FALSE);
|
||||||
|
|
||||||
zathura_t* zathura = session->global.data;
|
zathura_t* zathura = session->global.data;
|
||||||
bool eval = true;
|
gboolean eval = TRUE;
|
||||||
|
|
||||||
char* input = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
|
char* input = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
|
||||||
if (input == NULL || strlen(input) == 0) {
|
if (input == NULL || strlen(input) == 0) {
|
||||||
eval = false;
|
eval = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (eval == true) {
|
if (eval == TRUE) {
|
||||||
index = atoi(input);
|
index = atoi(input);
|
||||||
if (index == 0 && g_strcmp0(input, "0") != 0) {
|
if (index == 0 && g_strcmp0(input, "0") != 0) {
|
||||||
girara_notify(session, GIRARA_WARNING, _("Invalid input '%s' given."), input);
|
girara_notify(session, GIRARA_WARNING, _("Invalid input '%s' given."), input);
|
||||||
eval = false;
|
eval = FALSE;
|
||||||
}
|
}
|
||||||
index = index - 1;
|
index = index - 1;
|
||||||
}
|
}
|
||||||
|
@ -410,30 +410,32 @@ handle_link(GtkEntry* entry, girara_session_t* session,
|
||||||
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
|
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
|
||||||
g_object_set(G_OBJECT(page_widget), "draw-links", FALSE, NULL);
|
g_object_set(G_OBJECT(page_widget), "draw-links", FALSE, NULL);
|
||||||
|
|
||||||
if (eval == true) {
|
if (eval == FALSE) {
|
||||||
zathura_link_t* link = zathura_page_widget_link_get(ZATHURA_PAGE(page_widget), index);
|
/* nothing to evaluate */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (link != NULL) {
|
zathura_link_t* link = zathura_page_widget_link_get(ZATHURA_PAGE(page_widget), index);
|
||||||
invalid_index = false;
|
if (link != NULL) {
|
||||||
switch (action) {
|
invalid_index = false;
|
||||||
case ZATHURA_LINK_ACTION_FOLLOW:
|
switch (action) {
|
||||||
zathura_link_evaluate(zathura, link);
|
case ZATHURA_LINK_ACTION_FOLLOW:
|
||||||
break;
|
zathura_link_evaluate(zathura, link);
|
||||||
case ZATHURA_LINK_ACTION_DISPLAY:
|
break;
|
||||||
zathura_link_display(zathura, link);
|
case ZATHURA_LINK_ACTION_DISPLAY:
|
||||||
break;
|
zathura_link_display(zathura, link);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eval == true && invalid_index == true) {
|
if (eval == TRUE && invalid_index == true) {
|
||||||
girara_notify(session, GIRARA_WARNING, _("Invalid index '%s' given."), input);
|
girara_notify(session, GIRARA_WARNING, _("Invalid index '%s' given."), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(input);
|
g_free(input);
|
||||||
|
|
||||||
return (eval == TRUE) ? TRUE : FALSE;
|
return eval;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
Loading…
Reference in a new issue