Commit c18a70d7 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Merge branch 'release/0.3.3'

parents 07e88ec5 d11e5e10
......@@ -11,12 +11,25 @@ enhance the user interface that is used by zathura.
Requirements
------------
meson (>= 0.47)
glib (>= 2.50)
gtk3 (>= 3.20)
intltool
libnotify (optional, for notification support)
json-c (optional, for configuration dumping support)
The following dependencies are required:
* gtk3 (>= 3.20)
* glib (>= 2.50)
The following dependencies are optional:
* libnotify: notification support
* json-c: configuration dumping support
For building girara, the following dependencies are also required:
* meson (>= 0.48)
* gettext
The following dependencies are optional build-time only dependencies:
* check: for tests
* doxygen: HTML documentation
To disable the optional support for libnotify and json-c, configure the build
system with -Dnotify=disabled or -Djson=disabled.
......
......@@ -19,7 +19,7 @@
static void
cb_window_icon(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
......@@ -32,7 +32,7 @@ cb_window_icon(girara_session_t* session, const char* UNUSED(name),
static void
cb_font(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
......@@ -41,7 +41,7 @@ cb_font(girara_session_t* session, const char* UNUSED(name),
static void
cb_color(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
......@@ -57,7 +57,7 @@ cb_color(girara_session_t* session, const char* name,
static void
cb_guioptions(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
......@@ -68,7 +68,7 @@ cb_guioptions(girara_session_t* session, const char* UNUSED(name),
bool show_vscrollbar = false;
/* evaluate input */
char* input = (char*) value;
const char* input = value;
const size_t input_length = strlen(input);
for (size_t i = 0; i < input_length; i++) {
......@@ -113,11 +113,11 @@ cb_guioptions(girara_session_t* session, const char* UNUSED(name),
static void
cb_scrollbars(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
const bool val = *(bool*) value;
const bool val = *(const bool*) value;
char* guioptions = NULL;
girara_setting_get(session, "guioptions", &guioptions);
......@@ -172,14 +172,13 @@ girara_config_load_default(girara_session_t* session)
}
/* values */
int statusbar_h_padding = 8;
int statusbar_v_padding = 2;
int window_width = 800;
int window_height = 600;
int n_completion_items = 15;
bool show_scrollbars = false;
const int statusbar_h_padding = 8;
const int statusbar_v_padding = 2;
const int window_width = 800;
const int window_height = 600;
const int n_completion_items = 15;
const bool show_scrollbars = false;
girara_mode_t normal_mode = session->modes.normal;
bool use_smooth_scroll = false;
/* other values */
session->global.autohide_inputbar = true;
......@@ -218,7 +217,6 @@ girara_config_load_default(girara_session_t* session)
girara_setting_add(session, "window-icon", "", STRING, FALSE, _("Window icon"), cb_window_icon, NULL);
girara_setting_add(session, "exec-command", "", STRING, FALSE, _("Command to execute in :exec"), NULL, NULL);
girara_setting_add(session, "guioptions", "s", STRING, FALSE, _("Show or hide certain GUI elements"), cb_guioptions, NULL);
girara_setting_add(session, "smooth-scroll", &use_smooth_scroll, BOOLEAN, TRUE, _("Enable smooth scrolling and zooming"), NULL, NULL);
/* shortcuts */
girara_shortcut_add(session, 0, GDK_KEY_Escape, NULL, girara_sc_abort, normal_mode, 0, NULL);
......@@ -326,6 +324,7 @@ config_parse(girara_session_t* session, const char* path)
FILE* file = girara_file_open(path, "r");
if (file == NULL) {
girara_debug("failed to open config file '%s'", path);
return false;
}
......@@ -339,22 +338,21 @@ config_parse(girara_session_t* session, const char* path)
continue;
}
girara_list_t* argument_list = girara_list_new();
girara_list_t* argument_list = girara_list_new2(g_free);
if (argument_list == NULL) {
g_free(line);
fclose(file);
return false;
}
girara_list_set_free_function(argument_list, g_free);
gchar** argv = NULL;
gint argc = 0;
/* parse current line */
if (g_shell_parse_argv(line, &argc, &argv, NULL) != FALSE) {
for (int i = 1; i < argc; i++) {
char* argument = g_strdup(argv[i]);
girara_list_append(argument_list, (void*) argument);
girara_list_append(argument_list, argument);
}
} else {
girara_list_free(argument_list);
......@@ -392,18 +390,16 @@ config_parse(girara_session_t* session, const char* path)
} else {
/* search for config handle */
girara_session_private_t* session_private = session->private_data;
girara_config_handle_t* handle = NULL;
GIRARA_LIST_FOREACH_BODY(session_private->config.handles, girara_config_handle_t*, tmp,
handle = tmp;
bool found = false;
GIRARA_LIST_FOREACH_BODY(session_private->config.handles, girara_config_handle_t*, handle,
if (g_strcmp0(handle->identifier, argv[0]) == 0) {
found = true;
handle->handle(session, argument_list);
break;
} else {
handle = NULL;
}
);
if (handle == NULL) {
if (found == false) {
girara_warning("Could not process line %d in '%s': Unknown handle '%s'", line_number, path, argv[0]);
}
}
......@@ -421,5 +417,6 @@ config_parse(girara_session_t* session, const char* path)
void
girara_config_parse(girara_session_t* session, const char* path)
{
girara_debug("reading configuration file '%s'", path);
config_parse(session, path);
}
......@@ -48,8 +48,6 @@ HIDDEN void girara_mouse_event_free(girara_mouse_event_t* mouse_event);
HIDDEN void girara_config_load_default(girara_session_t* session);
HIDDEN void update_state_by_keyval(int *state, int keyval);
HIDDEN void widget_add_class(GtkWidget* widget, const char* styleclass);
HIDDEN void widget_remove_class(GtkWidget* widget, const char* styleclass);
......@@ -298,6 +296,8 @@ struct girara_session_private_s
girara_list_t* shortcut_mappings;
girara_list_t* argument_mappings;
} config;
GMutex feedkeys_mutex;
};
#endif
......@@ -11,8 +11,15 @@
#define __has_builtin(x) 0
#endif
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
# define GIRARA_GNUC_CHECK(maj, min) \
(((__GNUC__ << 20) + (__GNUC_MINOR__ << 10)) >= (((maj) << 20) + ((min) << 10)))
#else
# define GIRARA_GNUC_CHECK(maj, min) 0
#endif
#ifndef GIRARA_PRINTF
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) || defined(__clang__)
# if GIRARA_GNUC_CHECK(2, 5) || defined(__clang__)
# define GIRARA_PRINTF(format_idx, arg_idx) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
# else
......@@ -31,7 +38,7 @@
#endif
#ifndef GIRARA_HIDDEN
# if (defined(__GNUC__) && (__GNUC__ >= 4)) || __has_attribute(visibility)
# if GIRARA_GNUC_CHECK(4, 0) || __has_attribute(visibility)
# define GIRARA_HIDDEN __attribute__((visibility("hidden")))
# elif defined(__SUNPRO_C)
# define GIRARA_HIDDEN __hidden
......@@ -41,7 +48,7 @@
#endif
#ifndef GIRARA_VISIBLE
# if (defined(__GNUC__) && (__GNUC__ >= 4)) || __has_attribute(visibility)
# if GIRARA_GNUC_CHECK(4, 0) || __has_attribute(visibility)
# define GIRARA_VISIBLE __attribute__((visibility("default")))
# else
# define GIRARA_VISIBLE
......@@ -49,7 +56,7 @@
#endif
#ifndef GIRARA_DEPRECATED
# if defined(__GNUC__)
# if defined(__GNUC__) || __has_attribute(deprecated)
# define GIRARA_DEPRECATED(x) x __attribute__((deprecated))
# define GIRARA_DEPRECATED_ __attribute__((deprecated))
# else
......@@ -59,7 +66,7 @@
#endif
#ifndef GIRARA_ALLOC_SIZE
# if (!defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \
# if (!defined(__clang__) && GIRARA_GNUC_CHECK(4, 3)) || \
(defined(__clang__) && __has_attribute(__alloc_size__))
# define GIRARA_ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__)))
# else
......
......@@ -172,7 +172,7 @@ fill_template_with_values(girara_session_t* session)
};
/* parse color values */
const char* color_settings[] = {
static const char* const color_settings[] = {
"default-fg",
"default-bg",
"inputbar-fg",
......@@ -314,6 +314,7 @@ girara_session_create(void)
session_private->elements.statusbar_items = girara_list_new2(
(girara_free_function_t) girara_statusbar_item_free);
g_mutex_init(&session_private->feedkeys_mutex);
/* settings */
session_private->settings = girara_sorted_list_new2(
......@@ -355,11 +356,11 @@ girara_session_create(void)
girara_config_load_default(session);
/* create widgets */
session->gtk.box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
session->gtk.box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
session_private->gtk.overlay = gtk_overlay_new();
session_private->gtk.bottom_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
session->gtk.statusbar_entries = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
session->gtk.inputbar_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
session->gtk.statusbar_entries = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
session->gtk.inputbar_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
gtk_box_set_homogeneous(session->gtk.inputbar_box, TRUE);
session->gtk.view = gtk_scrolled_window_new(NULL, NULL);
session->gtk.viewport = gtk_viewport_new(NULL, NULL);
......@@ -388,11 +389,8 @@ girara_session_init(girara_session_t* session, const char* sessionname)
session->private_data->session_name = g_strdup(
(sessionname == NULL) ? "girara" : sessionname);
bool smooth_scroll = false;
girara_setting_get(session, "smooth-scroll", &smooth_scroll);
if (smooth_scroll == true) {
gtk_widget_add_events(session->gtk.viewport, GDK_SMOOTH_SCROLL_MASK);
}
/* enable smooth scroll events */
gtk_widget_add_events(session->gtk.viewport, GDK_SMOOTH_SCROLL_MASK);
/* load CSS style */
fill_template_with_values(session);
......@@ -615,6 +613,9 @@ girara_session_private_free(girara_session_private_t* session)
girara_list_free(session->settings);
session->settings = NULL;
/* clean up mutex */
g_mutex_clear(&session->feedkeys_mutex);
g_slice_free(girara_session_private_t, session);
}
......
......@@ -36,19 +36,19 @@ struct girara_setting_s
};
void
girara_setting_set_value(girara_session_t* session, girara_setting_t* setting, void* value)
girara_setting_set_value(girara_session_t* session, girara_setting_t* setting, const void* value)
{
g_return_if_fail(setting && (value || setting->type == STRING));
switch(setting->type) {
case BOOLEAN:
setting->value.b = *((bool *) value);
setting->value.b = *((const bool *) value);
break;
case FLOAT:
setting->value.f = *((float *) value);
setting->value.f = *((const float *) value);
break;
case INT:
setting->value.i = *((int *) value);
setting->value.i = *((const int *) value);
break;
case STRING:
if (setting->value.s != NULL) {
......@@ -66,7 +66,7 @@ girara_setting_set_value(girara_session_t* session, girara_setting_t* setting, v
}
bool
girara_setting_add(girara_session_t* session, const char* name, void* value, girara_setting_type_t type, bool init_only, const char* description, girara_setting_callback_t callback, void* data)
girara_setting_add(girara_session_t* session, const char* name, const void* value, girara_setting_type_t type, bool init_only, const char* description, girara_setting_callback_t callback, void* data)
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(name != NULL, false);
......@@ -97,7 +97,7 @@ girara_setting_add(girara_session_t* session, const char* name, void* value, gir
}
bool
girara_setting_set(girara_session_t* session, const char* name, void* value)
girara_setting_set(girara_session_t* session, const char* name, const void* value)
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(name != NULL, false);
......@@ -116,24 +116,31 @@ girara_setting_get_value(girara_setting_t* setting, void* dest)
{
g_return_val_if_fail(setting != NULL && dest != NULL, false);
bool *bvalue = (bool*) dest;
float *fvalue = (float*) dest;
int *ivalue = (int*) dest;
char **svalue = (char**) dest;
switch(setting->type) {
case BOOLEAN:
{
bool *bvalue = (bool *)dest;
*bvalue = setting->value.b;
break;
}
case FLOAT:
{
float *fvalue = (float *)dest;
*fvalue = setting->value.f;
break;
}
case INT:
{
int *ivalue = (int*) dest;
*ivalue = setting->value.i;
break;
}
case STRING:
{
char **svalue = (char**) dest;
*svalue = setting->value.s ? g_strdup(setting->value.s) : NULL;
break;
}
default:
g_assert(false);
}
......@@ -244,8 +251,6 @@ girara_cmd_dump_config(girara_session_t* session, girara_list_t* argument_list)
_("Invalid number of arguments passed: %zu instead of 1"),
number_of_arguments);
return false;
return false;
}
json_object* json_config = json_object_new_object();
......
......@@ -21,7 +21,7 @@
* @return FALSE An error occurred
*/
bool girara_setting_add(girara_session_t* session, const char* name,
void* value, girara_setting_type_t type, bool init_only,
const void* value, girara_setting_type_t type, bool init_only,
const char* description, girara_setting_callback_t callback, void* data) GIRARA_VISIBLE;
/**
......@@ -33,7 +33,7 @@ bool girara_setting_add(girara_session_t* session, const char* name,
* @return TRUE No error occurred
* @return FALSE An error occurred
*/
bool girara_setting_set(girara_session_t* session, const char* name, void* value) GIRARA_VISIBLE;
bool girara_setting_set(girara_session_t* session, const char* name, const void* value) GIRARA_VISIBLE;
/**
* Retrieve the value of a setting. If the setting is a string, the value stored
......@@ -89,6 +89,6 @@ girara_setting_type_t girara_setting_get_type(girara_setting_t* setting) GIRARA_
* @param value The new value
*/
void girara_setting_set_value(girara_session_t* session,
girara_setting_t* setting, void* value) GIRARA_VISIBLE;
girara_setting_t* setting, const void* value) GIRARA_VISIBLE;
#endif
......@@ -5,6 +5,7 @@
#include "datastructures.h"
#include "input-history.h"
#include "internal.h"
#include "log.h"
#include "session.h"
#include "settings.h"
......@@ -12,7 +13,6 @@
#include <string.h>
static void girara_toggle_widget_visibility(GtkWidget* widget);
static bool simulate_key_press(girara_session_t* session, int state, int key);
bool
girara_shortcut_add(girara_session_t* session, guint modifier, guint key, const char* buffer, girara_shortcut_function_t function, girara_mode_t mode, int argument_n, void* argument_data)
......@@ -460,6 +460,60 @@ girara_sc_exec(girara_session_t* session, girara_argument_t* argument, girara_ev
return false;
}
static bool
simulate_key_press(girara_session_t* session, int state, int key)
{
if (session == NULL || session->gtk.box == NULL) {
return false;
}
GdkEvent* event = gdk_event_new(GDK_KEY_PRESS);
event->any.type = GDK_KEY_PRESS;
event->key.window = g_object_ref(gtk_widget_get_parent_window(GTK_WIDGET(session->gtk.box)));
event->key.send_event = false;
event->key.time = GDK_CURRENT_TIME;
event->key.state = state;
event->key.keyval = key;
GdkDisplay* display = gtk_widget_get_display(GTK_WIDGET(session->gtk.box));
GdkKeymapKey* keys = NULL;
gint number_of_keys = 0;
if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(display),
event->key.keyval, &keys, &number_of_keys) == FALSE) {
gdk_event_free(event);
return false;
}
event->key.hardware_keycode = keys[0].keycode;
event->key.group = keys[0].group;
g_free(keys);
gdk_event_put(event);
gdk_event_free(event);
gtk_main_iteration_do(FALSE);
return true;
}
static int
update_state_by_keyval(int state, int keyval)
{
/* The following is probably not true for some keyboard layouts. */
if ((keyval >= '!' && keyval <= '/')
|| (keyval >= ':' && keyval <= '@')
|| (keyval >= '[' && keyval <= '`')
|| (keyval >= '{' && keyval <= '~')
) {
state |= GDK_SHIFT_MASK;
}
return state;
}
bool
girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument,
girara_event_t* UNUSED(event), unsigned int t)
......@@ -468,6 +522,11 @@ girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument,
return false;
}
if (g_mutex_trylock(&session->private_data->feedkeys_mutex) == FALSE) {
girara_error("Recursive use of feedkeys detected. Aborting evaluation.");
return false;
}
typedef struct gdk_keyboard_button_s {
char* identifier;
int keyval;
......@@ -507,7 +566,7 @@ girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument,
char* input = (char*) argument->data;
unsigned int input_length = strlen(input);
t = (t == 0) ? 1 : t;
t = MAX(1, t);
for (unsigned int c = 0; c < t; c++) {
for (unsigned i = 0; i < input_length; i++) {
int state = 0;
......@@ -520,7 +579,7 @@ girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument,
goto single_key;
}
int length = end - (input + i) - 1;
const int length = end - (input + i) - 1;
char* tmp = g_strndup(input + i + 1, length);
bool found = false;
......@@ -572,12 +631,12 @@ girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument,
}
single_key:
update_state_by_keyval(&state, keyval);
state = update_state_by_keyval(state, keyval);
simulate_key_press(session, state, keyval);
}
}
g_mutex_unlock(&session->private_data->feedkeys_mutex);
return true;
}
......@@ -709,7 +768,7 @@ girara_mouse_event_add(girara_session_t* session, guint mask, guint button,
bool
girara_mouse_event_remove(girara_session_t* session, guint mask, guint button, girara_mode_t mode)
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session != NULL, false);
bool found = false;
/* search for existing binding */
......@@ -733,42 +792,3 @@ girara_mouse_event_free(girara_mouse_event_t* mouse_event)
}
g_slice_free(girara_mouse_event_t, mouse_event);
}
static bool
simulate_key_press(girara_session_t* session, int state, int key)
{
if (session == NULL || session->gtk.box == NULL) {
return false;
}
GdkEvent* event = gdk_event_new(GDK_KEY_PRESS);
event->any.type = GDK_KEY_PRESS;
event->key.window = g_object_ref(gtk_widget_get_parent_window(GTK_WIDGET(session->gtk.box)));
event->key.send_event = false;
event->key.time = GDK_CURRENT_TIME;
event->key.state = state;
event->key.keyval = key;
GdkDisplay* display = gtk_widget_get_display(GTK_WIDGET(session->gtk.box));
GdkKeymapKey* keys = NULL;
gint number_of_keys = 0;
if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(display),
event->key.keyval, &keys, &number_of_keys) == FALSE) {
gdk_event_free(event);
return false;
}
event->key.hardware_keycode = keys[0].keycode;
event->key.group = keys[0].group;
g_free(keys);
gdk_event_put(event);
gdk_event_free(event);
gtk_main_iteration_do(FALSE);
return true;
}
......@@ -144,7 +144,7 @@ typedef enum girara_setting_type_e
* @param data User data
*/
typedef void (*girara_setting_callback_t)(girara_session_t* session,
const char* name, girara_setting_type_t type, void* value, void* data);
const char* name, girara_setting_type_t type, const void* value, void* data);
/**
* Definition of an argument of a shortcut or buffered command
......
......@@ -19,8 +19,6 @@
#include "settings.h"
#include "internal.h"
#define BLOCK_SIZE 64
char*
girara_fix_path(const char* path)
{
......@@ -63,7 +61,7 @@ girara_fix_path(const char* path)
}
bool
girara_xdg_open(const char* uri)
girara_xdg_open_with_working_directory(const char* uri, const char* working_directory)
{
if (uri == NULL || strlen(uri) == 0) {
return false;
......@@ -73,36 +71,36 @@ girara_xdg_open(const char* uri)
char* argv[] = { g_strdup("xdg-open"), g_strdup(uri), NULL };
GError* error = NULL;
const bool res = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
const bool res = g_spawn_async(working_directory, argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
NULL, NULL, &error);
if (error != NULL) {
girara_warning("Failed to execute command: %s", error->message);
g_error_free(error);
}
g_free(argv[0]);
g_free(argv[1]);
g_free(argv[0]);
return res;
}
char*
girara_get_home_directory(const char* user)
bool
girara_xdg_open(const char* uri)
{
if (user == NULL || g_strcmp0(user, g_get_user_name()) == 0) {
return g_strdup(g_get_home_dir());
}
return girara_xdg_open_with_working_directory(uri, NULL);
}
// XXX: The following code is very unportable.
struct passwd pwd;
struct passwd* result = NULL;
#if defined(HAVE_GETPWNAM_R)
static char*
get_home_directory_getpwnam(const char* user)
{
#ifdef _SC_GETPW_R_SIZE_MAX
int bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (bufsize < 0) {
bufsize = 4096;
}
#else
int bufsize = 4096;
const int bufsize = 4096;
#endif
char* buffer = g_try_malloc0(sizeof(char) * bufsize);
......@@ -110,8 +108,9 @@ girara_get_home_directory(const char* user)
return NULL;
}
getpwnam_r(user, &pwd, buffer, bufsize, &result);
if (result == NULL) {
struct passwd pwd;
struct passwd* result = NULL;
if (getpwnam_r(user, &pwd, buffer, bufsize, &result) != 0) {
g_free(buffer);
return NULL;
}
......@@ -120,6 +119,28 @@ girara_get_home_directory(const char* user)
g_free(buffer);
return dir;
}
#else
static char*
get_home_directory_getpwnam(const char* user)
{
const struct passwd* pwd = getpwnam(user);
if (pwd != NULL) {
return g_strdup(pwd->pw_dir);
}
return NULL;
}
#endif
char*
girara_get_home_directory(const char* user)
{
if (user == NULL || g_strcmp0(user, g_get_user_name()) == 0) {
return g_strdup(g_get_home_dir());
}
return get_home_directory_getpwnam(user);
}
char*
girara_get_xdg_path(girara_xdg_path_t path)
......@@ -187,7 +208,7 @@ girara_file_open(const char* path, const char* mode)
FILE* fp = fopen(fixed_path, mode);
g_free(fixed_path);
if (fp == NULL) {
return NULL;
return NULL;
}
return fp;
......@@ -287,7 +308,7 @@ girara_file_read2(FILE* file)
return NULL;
}
char* buffer = malloc(size + 1);
char* buffer = malloc(size + 1);
if (buffer == NULL) {
return NULL;
}
......@@ -357,22 +378,6 @@ error_free:
return NULL;
}
void
update_state_by_keyval(int *state, int keyval)
{
if (state == NULL) {
return;
}
if ((keyval >= '!' && keyval <= '/')
|| (keyval >= ':' && keyval <= '@')
|| (keyval >= '[' && keyval <= '`')
|| (keyval >= '{' && keyval <= '~')
) {
*state |= GDK_SHIFT_MASK;
}
}