mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 18:13:46 +01:00
Add copy file path mapping
This commit is contained in:
parent
01ee79eeab
commit
8369e79b11
@ -355,6 +355,7 @@ config_load_default(zathura_t* zathura)
|
||||
girara_shortcut_add(gsession, 0, GDK_KEY_y, NULL, sc_scroll, (mode), FULL_RIGHT, NULL); \
|
||||
girara_shortcut_add(gsession, 0, GDK_KEY_space, NULL, sc_scroll, (mode), FULL_DOWN, NULL); \
|
||||
girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_space, NULL, sc_scroll, (mode), FULL_UP, NULL); \
|
||||
girara_shortcut_add(gsession, 0, GDK_KEY_Y, NULL, sc_copy_filepath, (mode), 0, NULL); \
|
||||
\
|
||||
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_o, NULL, sc_jumplist, (mode), BACKWARD, NULL); \
|
||||
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_i, NULL, sc_jumplist, (mode), FORWARD, NULL); \
|
||||
@ -522,6 +523,7 @@ config_load_default(zathura_t* zathura)
|
||||
girara_shortcut_mapping_add(gsession, "change_mode", sc_change_mode);
|
||||
girara_shortcut_mapping_add(gsession, "display_link", sc_display_link);
|
||||
girara_shortcut_mapping_add(gsession, "copy_link", sc_copy_link);
|
||||
girara_shortcut_mapping_add(gsession, "copy_filepath", sc_copy_filepath);
|
||||
girara_shortcut_mapping_add(gsession, "exec", sc_exec);
|
||||
girara_shortcut_mapping_add(gsession, "focus_inputbar", sc_focus_inputbar);
|
||||
girara_shortcut_mapping_add(gsession, "follow", sc_follow);
|
||||
|
@ -174,6 +174,31 @@ sc_copy_link(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
sc_copy_filepath(girara_session_t* session, girara_argument_t* UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(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;
|
||||
|
||||
GdkAtom* selection = get_selection(zathura);
|
||||
if (selection == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* file_path = zathura_document_get_path(zathura->document);
|
||||
if (file_path == NULL) {
|
||||
girara_debug("Could not get file path for copying");
|
||||
return false;
|
||||
}
|
||||
|
||||
girara_debug("Copying file path to clipboard");
|
||||
gtk_clipboard_set_text(gtk_clipboard_get(*selection), file_path, -1);
|
||||
|
||||
g_free(selection);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
|
@ -60,6 +60,18 @@ bool sc_display_link(girara_session_t* session, girara_argument_t* argument, gir
|
||||
*/
|
||||
bool sc_copy_link(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
|
||||
|
||||
|
||||
/**
|
||||
* Copy opened file path
|
||||
*
|
||||
* @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 occurred otherwise false
|
||||
*/
|
||||
bool sc_copy_filepath(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
|
||||
|
||||
/**
|
||||
* Shortcut function to focus the inputbar
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user