mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-04 03:25:59 +01:00
Merge branch 'develop' of pwmt.org:zathura into develop
This commit is contained in:
commit
d2fa39884b
4 changed files with 101 additions and 3 deletions
6
config.c
6
config.c
|
@ -134,8 +134,10 @@ config_load_default(zathura_t* zathura)
|
||||||
girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL);
|
girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL);
|
||||||
|
|
||||||
/* mouse events */
|
/* mouse events */
|
||||||
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, 0, NULL);
|
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, 0, NULL);
|
||||||
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, 0, NULL);
|
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, 0, NULL);
|
||||||
|
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, 0, NULL);
|
||||||
|
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, 0, NULL);
|
||||||
|
|
||||||
/* define default inputbar commands */
|
/* define default inputbar commands */
|
||||||
girara_inputbar_command_add(gsession, "bmark", NULL, cmd_bookmark_create, NULL, "Add a bookmark");
|
girara_inputbar_command_add(gsession, "bmark", NULL, cmd_bookmark_create, NULL, "Add a bookmark");
|
||||||
|
|
|
@ -33,6 +33,7 @@ static void zathura_page_widget_get_property(GObject* object, guint prop_id, GVa
|
||||||
static void zathura_page_widget_size_allocate(GtkWidget* widget, GdkRectangle* allocation);
|
static void zathura_page_widget_size_allocate(GtkWidget* widget, GdkRectangle* allocation);
|
||||||
static void redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle);
|
static void redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle);
|
||||||
static void redraw_all_rects(ZathuraPage* widget, girara_list_t* rectangles);
|
static void redraw_all_rects(ZathuraPage* widget, girara_list_t* rectangles);
|
||||||
|
static bool cb_zathura_page_widget_button_press_event(GtkWidget* widget, GdkEventButton* button, zathura_page_t* page);
|
||||||
|
|
||||||
enum properties_e
|
enum properties_e
|
||||||
{
|
{
|
||||||
|
@ -102,7 +103,18 @@ zathura_page_widget_new(zathura_page_t* page)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(page != NULL, NULL);
|
g_return_val_if_fail(page != NULL, NULL);
|
||||||
|
|
||||||
return g_object_new(ZATHURA_TYPE_PAGE, "page", page, NULL);
|
GtkWidget* widget = g_object_new(ZATHURA_TYPE_PAGE, "page", page, NULL);
|
||||||
|
|
||||||
|
if (widget != NULL) {
|
||||||
|
g_signal_connect(
|
||||||
|
G_OBJECT(widget),
|
||||||
|
"button-press-event",
|
||||||
|
G_CALLBACK(cb_zathura_page_widget_button_press_event),
|
||||||
|
page
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -401,3 +413,44 @@ zathura_page_widget_link_get(ZathuraPage* widget, unsigned int index)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
cb_zathura_page_widget_button_press_event(GtkWidget* widget, GdkEventButton* button, zathura_page_t* page)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(widget != NULL, false);
|
||||||
|
g_return_val_if_fail(button != NULL, false);
|
||||||
|
g_return_val_if_fail(page != NULL, false);
|
||||||
|
|
||||||
|
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||||
|
|
||||||
|
/* simple single click */
|
||||||
|
if (button->type == GDK_BUTTON_PRESS) {
|
||||||
|
double x = button->x / page->document->scale;
|
||||||
|
double y = button->y / page->document->scale;
|
||||||
|
|
||||||
|
/* get links */
|
||||||
|
if (priv->links_got == false) {
|
||||||
|
priv->links = zathura_page_links_get(priv->page);
|
||||||
|
priv->links_got = true;
|
||||||
|
priv->number_of_links = (priv->links == NULL) ? 0 : girara_list_size(priv->links);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->links != NULL && priv->number_of_links > 0) {
|
||||||
|
GIRARA_LIST_FOREACH(priv->links, zathura_link_t*, iter, link)
|
||||||
|
if (link->position.x1 <= x && link->position.x2 >= x
|
||||||
|
&& link->position.y1 <= y && link->position.y2 >= y) {
|
||||||
|
switch (link->type) {
|
||||||
|
case ZATHURA_LINK_TO_PAGE:
|
||||||
|
page_set_delayed(page->document->zathura, link->target.page_number);
|
||||||
|
return true;
|
||||||
|
case ZATHURA_LINK_EXTERNAL:
|
||||||
|
girara_xdg_open(link->target.value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GIRARA_LIST_FOREACH_END(priv->links, zathura_link_t*, iter, link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
32
shortcuts.c
32
shortcuts.c
|
@ -207,6 +207,38 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(session != NULL, false);
|
||||||
|
g_return_val_if_fail(session->global.data != NULL, false);
|
||||||
|
zathura_t* zathura = session->global.data;
|
||||||
|
g_return_val_if_fail(argument != NULL, false);
|
||||||
|
g_return_val_if_fail(event != NULL, false);
|
||||||
|
|
||||||
|
if (zathura->document == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* scroll event */
|
||||||
|
if (event->type == GIRARA_EVENT_SCROLL) {
|
||||||
|
switch (event->direction) {
|
||||||
|
case GIRARA_SCROLL_UP:
|
||||||
|
argument->n = ZOOM_IN;
|
||||||
|
break;
|
||||||
|
case GIRARA_SCROLL_DOWN:
|
||||||
|
argument->n = ZOOM_OUT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sc_zoom(session, argument, NULL, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
sc_navigate(girara_session_t* session, girara_argument_t* argument,
|
sc_navigate(girara_session_t* session, girara_argument_t* argument,
|
||||||
girara_event_t* UNUSED(event), unsigned int t)
|
girara_event_t* UNUSED(event), unsigned int t)
|
||||||
|
|
11
shortcuts.h
11
shortcuts.h
|
@ -71,6 +71,17 @@ bool sc_goto(girara_session_t* session, girara_argument_t* argument, girara_even
|
||||||
*/
|
*/
|
||||||
bool sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
|
bool sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle mouse zoom events
|
||||||
|
*
|
||||||
|
* @param session The used girara session
|
||||||
|
* @param argument The used argument
|
||||||
|
* @param event Girara event
|
||||||
|
* @param t Number of executions
|
||||||
|
* @return true if no error occured otherwise false
|
||||||
|
*/
|
||||||
|
bool sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigate through the document
|
* Navigate through the document
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue