Commit a2addfab authored by Sebastian Ramacher's avatar Sebastian Ramacher

Merge branch 'develop' of pwmt.org:zathura into develop

parents 14350ee8 d8bc9fef
......@@ -11,6 +11,7 @@
#include "utils.h"
#include <girara/session.h>
#include <girara/settings.h>
#include <girara/completion.h>
#include <girara/utils.h>
#include <girara/datastructures.h>
......@@ -29,6 +30,10 @@ compare_case_insensitive(const char* str1, const char* str2)
static girara_list_t*
list_files(zathura_t* zathura, const char* current_path, const char* current_file, int current_file_length, bool is_dir)
{
if (zathura == NULL || zathura->ui.session == NULL || current_path == NULL) {
return NULL;
}
/* read directory */
GDir* dir = g_dir_open(current_path, 0, NULL);
if (dir == NULL) {
......@@ -38,6 +43,9 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
girara_list_t* res = girara_sorted_list_new2((girara_compare_function_t)compare_case_insensitive,
(girara_free_function_t)g_free);
bool show_hidden = false;
girara_setting_get(zathura->ui.session, "show-hidden", &show_hidden);
/* read files */
char* name = NULL;
while ((name = (char*) g_dir_read_name(dir)) != NULL) {
......@@ -45,15 +53,25 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
if (e_name == NULL) {
goto error_free;
}
int e_length = strlen(e_name);
if ((current_file_length > e_length) || strncmp(current_file, e_name,
current_file_length)) {
int e_length = strlen(e_name);
if (show_hidden == false && e_name[0] == '.') {
g_free(e_name);
continue;
}
if ((current_file_length > e_length) || strncmp(current_file, e_name, current_file_length)) {
g_free(e_name);
continue;
}
char* full_path = g_strdup_printf("%s%s%s", current_path, is_dir ? "" : "/", e_name);
char* tmp = "/";
if (is_dir == true || g_strcmp0(current_path, "/") == 0) {
tmp = "";
};
char* full_path = g_strdup_printf("%s%s%s", current_path, tmp, e_name);
if (full_path == NULL) {
g_free(e_name);
goto error_free;
......
This diff is collapsed.
......@@ -6,6 +6,7 @@
#include <girara/shortcuts.h>
#include <girara/utils.h>
#include <gtk/gtk.h>
#include <libgen.h>
#include "callbacks.h"
#include "shortcuts.h"
......@@ -116,6 +117,63 @@ sc_change_mode(girara_session_t* session, girara_argument_t* argument,
return false;
}
bool
sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara_event_t* UNUSED(event), unsigned int UNUSED(t))
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->gtk.inputbar_entry != 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);
if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.inputbar)) == false) {
gtk_widget_show(GTK_WIDGET(session->gtk.inputbar));
}
if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.notification_area)) == true) {
gtk_widget_hide(GTK_WIDGET(session->gtk.notification_area));
}
gtk_widget_grab_focus(GTK_WIDGET(session->gtk.inputbar_entry));
if (argument->data != NULL) {
gtk_entry_set_text(session->gtk.inputbar_entry, (char*) argument->data);
/* append filepath */
if (argument->n == APPEND_FILEPATH && zathura->document != NULL) {
char* file_path = g_strdup(zathura->document->file_path);
if (file_path == NULL) {
return false;
}
char* path = dirname(file_path);
char* tmp = g_strdup_printf("%s%s/", (char*) argument->data, (g_strcmp0(path, "/") == 0) ? "" : path);
if (tmp == NULL) {
g_free(file_path);
return false;
}
gtk_entry_set_text(session->gtk.inputbar_entry, tmp);
g_free(tmp);
g_free(file_path);
}
/* we save the X clipboard that will be clear by "grab_focus" */
gchar* x_clipboard_text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
gtk_editable_set_position(GTK_EDITABLE(session->gtk.inputbar_entry), -1);
if (x_clipboard_text != NULL) {
/* we reset the X clipboard with saved text */
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), x_clipboard_text, -1);
g_free(x_clipboard_text);
}
}
return true;
}
bool
sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
......
......@@ -38,6 +38,18 @@ bool sc_adjust_window(girara_session_t* session, girara_argument_t* argument, gi
*/
bool sc_change_mode(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
/**
* Shortcut function to focus the inputbar
*
* @param session The used girara session
* @param argument The argument
* @param event Girara event
* @param t Number of executions
* @return true No error occured
* @return false An error occured (abort execution)
*/
bool sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
/**
* Follow a link
*
......
......@@ -557,6 +557,8 @@ page_set(zathura_t* zathura, unsigned int page_id)
goto error_out;
}
zathura->document->current_page_number = page_id;
page_offset_t offset;
page_calculate_offset(page, &offset);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment