mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-27 11:56:00 +01:00
Make modifiers configurable
In particular modifiers used to trigger the synctex edit action and drawing with a highlighter.
This commit is contained in:
parent
9ab68dd1ee
commit
68e985db91
5 changed files with 67 additions and 30 deletions
|
@ -756,41 +756,41 @@ cb_page_widget_link(ZathuraPage* page, void* data)
|
|||
|
||||
void
|
||||
cb_page_widget_scaled_button_release(ZathuraPage* page_widget, GdkEventButton* event,
|
||||
void* data)
|
||||
void* data)
|
||||
{
|
||||
zathura_t* zathura = data;
|
||||
zathura_page_t* page = zathura_page_widget_get_page(page_widget);
|
||||
|
||||
if (event->button != GDK_BUTTON_PRIMARY) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* set page number (but don't scroll there. it was clicked on, so it's visible) */
|
||||
if (event->button == GDK_BUTTON_PRIMARY) {
|
||||
zathura_document_set_current_page_number(zathura->document, zathura_page_get_index(page));
|
||||
refresh_view(zathura);
|
||||
}
|
||||
zathura_document_set_current_page_number(zathura->document, zathura_page_get_index(page));
|
||||
refresh_view(zathura);
|
||||
|
||||
if (event->button != GDK_BUTTON_PRIMARY || !(event->state & GDK_CONTROL_MASK)) {
|
||||
return;
|
||||
}
|
||||
if (event->state & zathura->global.synctex_edit_modmask) {
|
||||
bool synctex = false;
|
||||
girara_setting_get(zathura->ui.session, "synctex", &synctex);
|
||||
if (synctex == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool synctex = false;
|
||||
girara_setting_get(zathura->ui.session, "synctex", &synctex);
|
||||
if (synctex == false) {
|
||||
return;
|
||||
}
|
||||
if (zathura->dbus != NULL) {
|
||||
zathura_dbus_edit(zathura->dbus, zathura_page_get_index(page), event->x, event->y);
|
||||
}
|
||||
|
||||
if (zathura->dbus != NULL) {
|
||||
zathura_dbus_edit(zathura->dbus, zathura_page_get_index(page), event->x, event->y);
|
||||
}
|
||||
char* editor = NULL;
|
||||
girara_setting_get(zathura->ui.session, "synctex-editor-command", &editor);
|
||||
if (editor == NULL || *editor == '\0') {
|
||||
girara_debug("No SyncTeX editor specified.");
|
||||
g_free(editor);
|
||||
return;
|
||||
}
|
||||
|
||||
char* editor = NULL;
|
||||
girara_setting_get(zathura->ui.session, "synctex-editor-command", &editor);
|
||||
if (editor == NULL || *editor == '\0') {
|
||||
girara_debug("No SyncTeX editor specified.");
|
||||
synctex_edit(editor, page, event->x, event->y);
|
||||
g_free(editor);
|
||||
return;
|
||||
}
|
||||
|
||||
synctex_edit(editor, page, event->x, event->y);
|
||||
g_free(editor);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
#define ZATHURA_RC "zathurarc"
|
||||
|
||||
static void
|
||||
cb_jumplist_change(girara_session_t* session, const char* name,
|
||||
cb_jumplist_change(girara_session_t* session, const char* UNUSED(name),
|
||||
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
g_return_if_fail(session->global.data != NULL);
|
||||
g_return_if_fail(name != NULL);
|
||||
zathura_t* zathura = session->global.data;
|
||||
|
||||
const int* ivalue = value;
|
||||
|
@ -104,6 +103,38 @@ cb_doubleclick_changed(girara_session_t* session, const char* UNUSED(name),
|
|||
zathura->global.double_click_follow = *(const bool*) value;
|
||||
}
|
||||
|
||||
static void
|
||||
cb_global_modifiers_changed(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t UNUSED(type), const void* value,
|
||||
void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
g_return_if_fail(session->global.data != NULL);
|
||||
zathura_t* zathura = session->global.data;
|
||||
|
||||
GdkModifierType* p;
|
||||
if (g_strcmp0(name, "synctex-edit-modifier") == 0) {
|
||||
p = &(zathura->global.synctex_edit_modmask);
|
||||
} else if (g_strcmp0(name, "highlighter-modifier") == 0) {
|
||||
p = &(zathura->global.highlighter_modmask);
|
||||
} else {
|
||||
girara_error("unreachable");
|
||||
return;
|
||||
}
|
||||
|
||||
const char* modifier = value;
|
||||
if (g_strcmp0(modifier, "shift") == 0) {
|
||||
*p = GDK_SHIFT_MASK;
|
||||
} else if (g_strcmp0(modifier, "ctrl") == 0) {
|
||||
*p = GDK_CONTROL_MASK;
|
||||
} else if (g_strcmp0(modifier, "alt") == 0) {
|
||||
*p = GDK_MOD1_MASK;
|
||||
} else {
|
||||
girara_error("Invalid %s option: '%s'", name, modifier);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cb_incsearch_changed(girara_session_t* session, const char* UNUSED(name),
|
||||
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
|
||||
|
@ -118,7 +149,7 @@ cb_incsearch_changed(girara_session_t* session, const char* UNUSED(name),
|
|||
}
|
||||
|
||||
static void
|
||||
cb_sandbox_changed(girara_session_t* session, const char* UNUSED(name),
|
||||
cb_sandbox_changed(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
|
@ -134,7 +165,7 @@ cb_sandbox_changed(girara_session_t* session, const char* UNUSED(name),
|
|||
} else if (g_strcmp0(sandbox, "strict") == 0) {
|
||||
zathura->global.sandbox = ZATHURA_SANDBOX_STRICT;
|
||||
} else {
|
||||
girara_error("Invalid sandbox option");
|
||||
girara_error("Invalid %s option: '%s'", name, sandbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,6 +335,8 @@ config_load_default(zathura_t* zathura)
|
|||
bool_value = true;
|
||||
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
|
||||
girara_setting_add(gsession, "synctex-editor-command", "", STRING, false, _("Synctex editor command"), NULL, NULL);
|
||||
girara_setting_add(gsession, "synctex-edit-modifier", "ctrl", STRING, false, _("Synctex edit modifier"), cb_global_modifiers_changed, NULL);
|
||||
girara_setting_add(gsession, "highlighter-modifier", "shift", STRING, false, _("Highlighter modifier"), cb_global_modifiers_changed, NULL);
|
||||
bool_value = true;
|
||||
girara_setting_add(gsession, "dbus-service", &bool_value, BOOLEAN, false, _("Enable D-Bus service"), NULL, NULL);
|
||||
girara_setting_add(gsession, "dbus-raise-window", &bool_value, BOOLEAN, false, _("Raise window on certain D-Bus commands"), NULL, NULL);
|
||||
|
|
|
@ -1129,7 +1129,7 @@ cb_zathura_page_widget_motion_notify(GtkWidget* widget, GdkEventMotion* event)
|
|||
const double scale = zathura_document_get_scale(document);
|
||||
|
||||
if (event->state & GDK_BUTTON1_MASK) { /* holding left mouse button */
|
||||
if (event->state & GDK_CONTROL_MASK) {
|
||||
if (event->state & priv->zathura->global.highlighter_modmask) {
|
||||
double x, y;
|
||||
rotate_point(document, event->x, event->y, &x, &y);
|
||||
priv->highlighter.bounds = next_selection_rectangle(priv->mouse.selection.x1,
|
||||
|
|
|
@ -95,6 +95,8 @@ zathura_create(void)
|
|||
|
||||
/* global settings */
|
||||
zathura->global.search_direction = FORWARD;
|
||||
zathura->global.synctex_edit_modmask = GDK_CONTROL_MASK;
|
||||
zathura->global.highlighter_modmask = GDK_SHIFT_MASK;
|
||||
zathura->global.sandbox = ZATHURA_SANDBOX_NORMAL;
|
||||
zathura->global.double_click_follow = true;
|
||||
|
||||
|
|
|
@ -144,9 +144,11 @@ struct zathura_s
|
|||
|
||||
struct
|
||||
{
|
||||
int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
|
||||
girara_list_t* marks; /**< Marker */
|
||||
char** arguments; /**> Arguments that were passed at startup */
|
||||
int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
|
||||
GdkModifierType synctex_edit_modmask; /**< Modifier to trigger synctex edit */
|
||||
GdkModifierType highlighter_modmask; /**< Modifier to draw with a highlighter */
|
||||
zathura_sandbox_t sandbox; /**< Sandbox mode */
|
||||
bool double_click_follow; /**< Double/Single click to follow link */
|
||||
} global;
|
||||
|
|
Loading…
Reference in a new issue