...
 
Commits (46)
Copyright (c) 2010-2017 pwmt.org
Copyright (c) 2010-2018 pwmt.org
This software is provided 'as-is', without any express or implied warranty. In
no event will the authors be held liable for any damages arising from the use of
......
......@@ -11,7 +11,7 @@ enhance the user interface that is used by zathura.
Requirements
------------
meson (>= 0.43)
meson (>= 0.47)
glib (>= 2.50)
gtk3 (>= 3.20)
intltool
......@@ -19,7 +19,7 @@ libnotify (optional, for notification support)
json-c (optional, for configuration dumping support)
To disable the optional support for libnotify and json-c, configure the build
system with -Denable-notify=false or -Denable-json=false.
system with -Dnotify=disabled or -Djson=disabled.
Installation
------------
......@@ -38,5 +38,4 @@ refer to the meson documentation for platform specific dependencies.
Bugs
----
Please report bugs at http://bugs.pwmt.org or contact us on our mailing list at
girara@lists.pwmt.org.
Please report bugs at https://git.pwmt.org/pwmt/girara.
# See LICENSE file for license and copyright information
# SPDX-License-Identifier: Zlib
# General information
PROJECT_NAME = girara
......
doxygen = find_program('doxygen', required: false)
if get_option('enable-docs') and doxygen.found()
doxygen = find_program('doxygen', required: get_option('docs'))
if doxygen.found()
conf_data = configuration_data()
conf_data.set('DOXYGEN_INPUT', meson.source_root())
conf_data.set('DOXYGEN_OUTPUT', meson.current_build_dir())
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "callbacks.h"
......@@ -162,7 +162,7 @@ girara_callback_view_key_press_event(GtkWidget* widget,
/* buffer could match a command */
if (!strncmp(session_private->buffer.command->str, shortcut->buffered_command, session_private->buffer.command->len)) {
/* command matches buffer exactly */
if (!strcmp(session_private->buffer.command->str, shortcut->buffered_command)
if (!g_strcmp0(session_private->buffer.command->str, shortcut->buffered_command)
&& (session->modes.current_mode == shortcut->mode || shortcut->mode == 0)) {
g_string_free(session_private->buffer.command, TRUE);
g_string_free(session->global.buffer, TRUE);
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_CALLBACKS_H
#define GIRARA_CALLBACKS_H
#include "macros.h"
#include "types.h"
#include <gtk/gtk.h>
......@@ -37,7 +38,7 @@ typedef gboolean (*girara_callback_inputbar_activate_t)(GtkEntry* entry,
* @return FALSE An error occurred
*/
gboolean girara_callback_view_key_press_event(GtkWidget* widget, GdkEventKey* event,
girara_session_t* session);
girara_session_t* session) GIRARA_VISIBLE;
/**
* Default callback when a button (typically a mouse button) has been pressed
......@@ -49,7 +50,7 @@ gboolean girara_callback_view_key_press_event(GtkWidget* widget, GdkEventKey* ev
* @return false to propagate the event further.
*/
gboolean girara_callback_view_button_press_event(GtkWidget* widget,
GdkEventButton* button, girara_session_t* session);
GdkEventButton* button, girara_session_t* session) GIRARA_VISIBLE;
/**
* Default callback when a button (typically a mouse button) has been released
......@@ -61,7 +62,7 @@ gboolean girara_callback_view_button_press_event(GtkWidget* widget,
* @return false to propagate the event further.
*/
gboolean girara_callback_view_button_release_event(GtkWidget* widget,
GdkEventButton* button, girara_session_t* session);
GdkEventButton* button, girara_session_t* session) GIRARA_VISIBLE;
/**
* Default callback when the pointer moves over the widget
......@@ -73,7 +74,7 @@ gboolean girara_callback_view_button_release_event(GtkWidget* widget,
* @return false to propagate the event further.
*/
gboolean girara_callback_view_button_motion_notify_event(GtkWidget* widget,
GdkEventMotion* button, girara_session_t* session);
GdkEventMotion* button, girara_session_t* session) GIRARA_VISIBLE;
/**
* Default callback then a scroll event is triggered by the view
......@@ -85,7 +86,7 @@ gboolean girara_callback_view_button_motion_notify_event(GtkWidget* widget,
* @return false to propagate the event further.
*/
gboolean girara_callback_view_scroll_event(GtkWidget* widget, GdkEventScroll* event,
girara_session_t* session);
girara_session_t* session) GIRARA_VISIBLE;
/**
* Default callback if the inputbar gets activated
......@@ -96,7 +97,7 @@ gboolean girara_callback_view_scroll_event(GtkWidget* widget, GdkEventScroll* ev
* @return FALSE An error occurred
*/
gboolean girara_callback_inputbar_activate(GtkEntry* entry,
girara_session_t* session);
girara_session_t* session) GIRARA_VISIBLE;
/**
* Default callback if an key in the input bar gets pressed
......@@ -108,7 +109,7 @@ gboolean girara_callback_inputbar_activate(GtkEntry* entry,
* @return FALSE An error occurred
*/
gboolean girara_callback_inputbar_key_press_event(GtkWidget* widget,
GdkEventKey* event, girara_session_t* session);
GdkEventKey* event, girara_session_t* session) GIRARA_VISIBLE;
/**
* Default callback if the text of the input bar has changed
......@@ -119,6 +120,6 @@ gboolean girara_callback_inputbar_key_press_event(GtkWidget* widget,
* @return FALSE An error occurred
*/
gboolean girara_callback_inputbar_changed_event(GtkEditable* widget,
girara_session_t* session);
girara_session_t* session) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "commands.h"
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_COMMANDS_H
#define GIRARA_COMMANDS_H
#include "macros.h"
#include "types.h"
/**
......@@ -20,7 +21,7 @@
bool girara_inputbar_command_add(girara_session_t* session,
const char* command, const char* abbreviation,
girara_command_function_t function, girara_completion_function_t completion,
const char* description);
const char* description) GIRARA_VISIBLE;
/**
* Adds a special command
......@@ -37,6 +38,6 @@ bool girara_inputbar_command_add(girara_session_t* session,
*/
bool girara_special_command_add(girara_session_t* session, char identifier,
girara_inputbar_special_function_t function, bool always, int argument_n,
void* argument_data);
void* argument_data) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include <math.h>
#include <string.h>
......@@ -199,8 +199,8 @@ girara_isc_completion(girara_session_t* session, girara_argument_t* argument, gi
* there is only one completion entry
*/
if ( (argument->n == GIRARA_HIDE) ||
(current_parameter && previous_parameter && strcmp(current_parameter, previous_parameter)) ||
(current_command && previous_command && strcmp(current_command, previous_command)) ||
(current_parameter && previous_parameter && g_strcmp0(current_parameter, previous_parameter)) ||
(current_command && previous_command && g_strcmp0(current_command, previous_command)) ||
(input_length != previous_length) ||
is_single_entry
)
......@@ -434,8 +434,8 @@ girara_isc_completion(girara_session_t* session, girara_argument_t* argument, gi
/* hide other items */
unsigned int n_completion_items = 15;
girara_setting_get(session, "n-completion-items", &n_completion_items);
unsigned int uh = ceil( n_completion_items / 2);
unsigned int lh = floor(n_completion_items / 2);
unsigned int uh = ceil(n_completion_items / 2.0);
unsigned int lh = floor(n_completion_items / 2.0);
unsigned int current_item = g_list_position(entries, entries_current);
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_COMPLETION_H
#define GIRARA_COMPLETION_H
#include "macros.h"
#include "types.h"
/**
......@@ -11,7 +12,7 @@
* @return Completion object
* @return NULL An error occurred
*/
girara_completion_t* girara_completion_init(void);
girara_completion_t* girara_completion_init(void) GIRARA_VISIBLE;
/**
* Creates an girara completion group
......@@ -20,14 +21,14 @@ girara_completion_t* girara_completion_init(void);
* @return NULL An error occurred
*/
girara_completion_group_t* girara_completion_group_create(
girara_session_t* session, const char* name);
girara_session_t* session, const char* name) GIRARA_VISIBLE;
/**
* Frees a completion group
*
* @param group The group
*/
void girara_completion_group_free(girara_completion_group_t* group);
void girara_completion_group_free(girara_completion_group_t* group) GIRARA_VISIBLE;
/**
* Adds an group to a completion object
......@@ -36,14 +37,14 @@ void girara_completion_group_free(girara_completion_group_t* group);
* @param group The completion group
*/
void girara_completion_add_group(girara_completion_t* completion,
girara_completion_group_t* group);
girara_completion_group_t* group) GIRARA_VISIBLE;
/**
* Frees an completion and all of its groups and elements
*
* @param completion The completion
*/
void girara_completion_free(girara_completion_t* completion);
void girara_completion_free(girara_completion_t* completion) GIRARA_VISIBLE;
/**
* Adds an element to a completion group
......@@ -53,6 +54,6 @@ void girara_completion_free(girara_completion_t* completion);
* @param description Description of the entry
*/
void girara_completion_group_add_element(girara_completion_group_t* group,
const char* value, const char* description);
const char* value, const char* description) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "config.h"
......@@ -126,11 +126,11 @@ cb_scrollbars(girara_session_t* session, const char* name,
bool show_hscrollbar = strchr(guioptions, 'h') != NULL;
bool show_vscrollbar = strchr(guioptions, 'v') != NULL;
if (strcmp(name, "show-scrollbars") == 0) {
if (g_strcmp0(name, "show-scrollbars") == 0) {
show_hscrollbar = show_vscrollbar = val;
} else if (strcmp(name, "show-h-scrollbar") == 0) {
} else if (g_strcmp0(name, "show-h-scrollbar") == 0) {
show_hscrollbar = val;
} else if (strcmp(name, "show-v-scrollbar") == 0) {
} else if (g_strcmp0(name, "show-v-scrollbar") == 0) {
show_vscrollbar = val;
}
......@@ -209,8 +209,8 @@ girara_config_load_default(girara_session_t* session)
girara_setting_add(session, "word-separator", " /.-=&#?", STRING, TRUE, NULL, NULL, NULL);
girara_setting_add(session, "window-width", &window_width, INT, TRUE, _("Initial window width"), NULL, NULL);
girara_setting_add(session, "window-height", &window_height, INT, TRUE, _("Initial window height"), NULL, NULL);
girara_setting_add(session, "statusbar-h-padding", &statusbar_h_padding, INT, TRUE, _("Horizontal padding for the status input and notification bars"), NULL, NULL);
girara_setting_add(session, "statusbar-v-padding", &statusbar_v_padding, INT, TRUE, _("Vertical padding for the status input and notification bars"), NULL, NULL);
girara_setting_add(session, "statusbar-h-padding", &statusbar_h_padding, INT, TRUE, _("Horizontal padding for the status, input, and notification bars"), NULL, NULL);
girara_setting_add(session, "statusbar-v-padding", &statusbar_v_padding, INT, TRUE, _("Vertical padding for the status, input, and notification bars"), NULL, NULL);
girara_setting_add(session, "n-completion-items", &n_completion_items, INT, TRUE, _("Number of completion items"), NULL, NULL);
girara_setting_add(session, "show-scrollbars", &show_scrollbars, BOOLEAN, FALSE, _("Show both the horizontal and vertical scrollbars"), cb_scrollbars, NULL);
girara_setting_add(session, "show-h-scrollbar", &show_scrollbars, BOOLEAN, FALSE, _("Show the horizontal scrollbar"), cb_scrollbars, NULL);
......@@ -289,7 +289,7 @@ girara_config_handle_add(girara_session_t* session, const char* identifier, gira
/* search for existing config handle */
GIRARA_LIST_FOREACH_BODY(session_private->config.handles, girara_config_handle_t*, data,
if (strcmp(data->identifier, identifier) == 0) {
if (g_strcmp0(data->identifier, identifier) == 0) {
data->handle = handle;
found = true;
break;
......@@ -364,7 +364,7 @@ config_parse(girara_session_t* session, const char* path)
}
/* include gets a special treatment */
if (strcmp(argv[0], "include") == 0) {
if (g_strcmp0(argv[0], "include") == 0) {
if (argc != 2) {
girara_warning("Could not process line %d in '%s': usage: include path.", line_number, path);
} else {
......@@ -379,7 +379,7 @@ config_parse(girara_session_t* session, const char* path)
g_free(basename);
}
if (strcmp(newpath, path) == 0) {
if (g_strcmp0(newpath, path) == 0) {
girara_warning("Could not process line %d in '%s': trying to include itself.", line_number, path);
} else {
girara_debug("Loading config file '%s'.", newpath);
......@@ -395,7 +395,7 @@ config_parse(girara_session_t* session, const char* path)
girara_config_handle_t* handle = NULL;
GIRARA_LIST_FOREACH_BODY(session_private->config.handles, girara_config_handle_t*, tmp,
handle = tmp;
if (strcmp(handle->identifier, argv[0]) == 0) {
if (g_strcmp0(handle->identifier, argv[0]) == 0) {
handle->handle(session, argument_list);
break;
} else {
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_CONFIG_H
#define GIRARA_CONFIG_H
#include "macros.h"
#include "types.h"
/**
......@@ -11,7 +12,7 @@
* @param session The used girara session
* @param path Path to the configuration file
*/
void girara_config_parse(girara_session_t* session, const char* path);
void girara_config_parse(girara_session_t* session, const char* path) GIRARA_VISIBLE;
/**
* Adds an additional config handler
......@@ -22,6 +23,6 @@ void girara_config_parse(girara_session_t* session, const char* path);
* @return true if no error occurred, otherwise false
*/
bool girara_config_handle_add(girara_session_t* session, const char* identifier,
girara_command_function_t handle);
girara_command_function_t handle) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include <stdlib.h>
#include <glib.h>
......@@ -40,7 +40,7 @@ girara_list_new(void)
girara_list_t*
girara_list_new2(girara_free_function_t gfree)
{
girara_list_t* list = g_try_malloc0(sizeof(girara_list_t));
girara_list_t* list = g_slice_new0(girara_list_t);
if (list == NULL) {
return NULL;
}
......@@ -103,7 +103,7 @@ girara_list_free(girara_list_t* list)
}
girara_list_clear(list);
g_free(list);
g_slice_free(girara_list_t, list);
}
void
......@@ -203,7 +203,7 @@ girara_list_iterator(girara_list_t* list)
return NULL;
}
girara_list_iterator_t* iter = g_try_malloc0(sizeof(girara_list_iterator_t));
girara_list_iterator_t* iter = g_slice_new0(girara_list_iterator_t);
if (iter == NULL) {
return NULL;
}
......@@ -219,14 +219,7 @@ girara_list_iterator_copy(girara_list_iterator_t* iter)
{
g_return_val_if_fail(iter != NULL, NULL);
girara_list_iterator_t* iter2 = g_try_malloc0(sizeof(girara_list_iterator_t));
if (iter2 == NULL) {
return NULL;
}
iter2->list = iter->list;
iter2->element = iter->element;
return iter2;
return g_slice_copy(sizeof(girara_list_iterator_t), iter);
}
girara_list_iterator_t*
......@@ -286,7 +279,7 @@ girara_list_iterator_remove(girara_list_iterator_t* iter) {
}
GList* el = iter->element;
if (iter->list != NULL && iter->list->free != NULL) {
if (iter->list->free != NULL) {
(iter->list->free)(iter->element->data);
}
......@@ -328,7 +321,7 @@ girara_list_iterator_free(girara_list_iterator_t* iter)
return;
}
g_free(iter);
g_slice_free(girara_list_iterator_t, iter);
}
size_t
......
This diff is collapsed.
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_H
#define GIRARA_H
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "input-history.h"
#include "macros.h"
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "input-history.h"
#include "datastructures.h"
G_DEFINE_TYPE(GiraraInputHistory, girara_input_history, G_TYPE_OBJECT)
#include "internal.h"
/**
* Private data of the settings manager
* Private data of the input history
*/
typedef struct ih_private_s {
girara_list_t* history; /**< List of stored inputs */
......@@ -15,11 +14,9 @@ typedef struct ih_private_s {
size_t current_match;
GiraraInputHistoryIO* io;
char* command_line;
} ih_private_t;
} GiraraInputHistoryPrivate;
#define GIRARA_INPUT_HISTORY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIRARA_TYPE_INPUT_HISTORY, \
ih_private_t))
G_DEFINE_TYPE_WITH_CODE(GiraraInputHistory, girara_input_history, G_TYPE_OBJECT, G_ADD_PRIVATE(GiraraInputHistory))
/* Methods */
static void ih_dispose(GObject* object);
......@@ -46,9 +43,6 @@ enum {
static void
girara_input_history_class_init(GiraraInputHistoryClass* class)
{
/* add private members */
g_type_class_add_private(class, sizeof(ih_private_t));
/* overwrite methods */
GObjectClass* object_class = G_OBJECT_CLASS(class);
object_class->dispose = ih_dispose;
......@@ -74,7 +68,7 @@ girara_input_history_class_init(GiraraInputHistoryClass* class)
static void
girara_input_history_init(GiraraInputHistory* history)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
priv->history = girara_list_new2((girara_free_function_t) g_free);
priv->reset = true;
priv->io = NULL;
......@@ -84,7 +78,8 @@ girara_input_history_init(GiraraInputHistory* history)
static void
ih_dispose(GObject* object)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(object);
GiraraInputHistory* ih = GIRARA_INPUT_HISTORY(object);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(ih);
g_clear_object(&priv->io);
......@@ -95,7 +90,8 @@ ih_dispose(GObject* object)
static void
ih_finalize(GObject* object)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(object);
GiraraInputHistory* ih = GIRARA_INPUT_HISTORY(object);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(ih);
girara_list_free(priv->history);
g_free(priv->command_line);
......@@ -107,7 +103,8 @@ static void
ih_set_property(GObject* object, guint prop_id, const GValue* value,
GParamSpec* pspec)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(object);
GiraraInputHistory* ih = GIRARA_INPUT_HISTORY(object);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(ih);
switch (prop_id) {
case PROP_IO: {
......@@ -130,7 +127,8 @@ static void
ih_get_property(GObject* object, guint prop_id, GValue* value,
GParamSpec* pspec)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(object);
GiraraInputHistory* ih = GIRARA_INPUT_HISTORY(object);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(ih);
switch (prop_id) {
case PROP_IO:
......@@ -164,13 +162,13 @@ ih_append(GiraraInputHistory* history, const char* input)
}
void* data = NULL;
while ((data = girara_list_find(list, (girara_compare_function_t) g_strcmp0, data)) != NULL) {
while ((data = girara_list_find(list, list_strcmp, data)) != NULL) {
girara_list_remove(list, data);
}
girara_list_append(list, g_strdup(input));
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
if (priv->io != NULL) {
girara_input_history_io_append(priv->io, input);
}
......@@ -182,14 +180,14 @@ ih_append(GiraraInputHistory* history, const char* input)
static girara_list_t*
ih_list(GiraraInputHistory* history)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
return priv->history;
}
static const char*
find_next(GiraraInputHistory* history, const char* current_input, bool next)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
girara_list_t* list = girara_input_history_list(history);
if (list == NULL) {
......@@ -232,8 +230,6 @@ find_next(GiraraInputHistory* history, const char* current_input, bool next)
} else {
++priv->current;
}
} else {
return NULL;
}
command = girara_list_nth(list, priv->current);
......@@ -271,7 +267,7 @@ ih_previous(GiraraInputHistory* history, const char* current_input)
static void
ih_reset(GiraraInputHistory* history)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
priv->reset = true;
if (priv->io != NULL) {
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_INPUT_HISTORY_H
#define GIRARA_INPUT_HISTORY_H
#include <glib-object.h>
#include "macros.h"
#include "types.h"
struct girara_input_history_io_interface_s {
......@@ -43,11 +44,11 @@ struct girara_input_history_io_interface_s {
#define GIRARA_INPUT_HISTORY_IO_GET_INTERFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE((obj), GIRARA_TYPE_INPUT_HISTORY_IO, GiraraInputHistoryIOInterface))
GType girara_input_history_io_get_type(void) G_GNUC_CONST;
GType girara_input_history_io_get_type(void) G_GNUC_CONST GIRARA_VISIBLE;
void girara_input_history_io_append(GiraraInputHistoryIO* io, const char* input);
void girara_input_history_io_append(GiraraInputHistoryIO* io, const char* input) GIRARA_VISIBLE;
girara_list_t* girara_input_history_io_read(GiraraInputHistoryIO* io);
girara_list_t* girara_input_history_io_read(GiraraInputHistoryIO* io) GIRARA_VISIBLE;
struct girara_input_history_s {
......@@ -128,7 +129,7 @@ struct girara_input_history_class_s {
*
* @return the type
*/
GType girara_input_history_get_type(void) G_GNUC_CONST;
GType girara_input_history_get_type(void) G_GNUC_CONST GIRARA_VISIBLE;
/**
* Create new input history object.
......@@ -136,7 +137,7 @@ GType girara_input_history_get_type(void) G_GNUC_CONST;
* @param io a GiraraInputHistoryIO instance, may be NULL
* @returns an input history object
*/
GiraraInputHistory* girara_input_history_new(GiraraInputHistoryIO* io);
GiraraInputHistory* girara_input_history_new(GiraraInputHistoryIO* io) GIRARA_VISIBLE;
/**
* Append a new line of input.
......@@ -144,7 +145,7 @@ GiraraInputHistory* girara_input_history_new(GiraraInputHistoryIO* io);
* @param history an input history instance
* @param input the input
*/
void girara_input_history_append(GiraraInputHistory* history, const char* input);
void girara_input_history_append(GiraraInputHistory* history, const char* input) GIRARA_VISIBLE;
/**
* Get the "next" input from the history
......@@ -154,7 +155,7 @@ void girara_input_history_append(GiraraInputHistory* history, const char* input)
* @returns "next" input
*/
const char* girara_input_history_next(GiraraInputHistory* history,
const char* current_input);
const char* current_input) GIRARA_VISIBLE;
/**
* Get the "previous" input from the history
......@@ -164,14 +165,14 @@ const char* girara_input_history_next(GiraraInputHistory* history,
* @returns "previous" input
*/
const char* girara_input_history_previous(GiraraInputHistory* history,
const char* current_input);
const char* current_input) GIRARA_VISIBLE;
/**
* Reset state of the input history
*
* @param history an input history instance
*/
void girara_input_history_reset(GiraraInputHistory* history);
void girara_input_history_reset(GiraraInputHistory* history) GIRARA_VISIBLE;
/**
* Get a list of all the inputs stored.
......@@ -179,6 +180,6 @@ void girara_input_history_reset(GiraraInputHistory* history);
* @param history an input history instance
* @returns a list containing all inputs
*/
girara_list_t* girara_input_history_list(GiraraInputHistory* history);
girara_list_t* girara_input_history_list(GiraraInputHistory* history) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_INTERNAL_H
#define GIRARA_INTERNAL_H
......@@ -150,6 +150,8 @@ HIDDEN bool girara_sc_feedkeys(girara_session_t* session, girara_argument_t* arg
HIDDEN void css_template_fill_font(GiraraTemplate* csstemplate, const char* font);
HIDDEN int list_strcmp(const void* data1, const void* data2);
/**
* Structure of a command
*/
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "log.h"
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_LOG_H
#define GIRARA_LOG_H
......@@ -49,7 +49,7 @@ typedef enum girara_log_level_e
* @param format printf like format string
*/
void girara_log(const char* location, const char* function, girara_log_level_t level,
const char* format, ...) GIRARA_PRINTF(4, 5);
const char* format, ...) GIRARA_PRINTF(4, 5) GIRARA_VISIBLE;
/**
* Print a message.
......@@ -61,19 +61,19 @@ void girara_log(const char* location, const char* function, girara_log_level_t l
* @param ap varag list
*/
void girara_vlog(const char* location, const char* function, girara_log_level_t level,
const char* format, va_list ap);
const char* format, va_list ap) GIRARA_VISIBLE;
/**
* Get the log level.
* @returns The log level.
*/
girara_log_level_t girara_get_log_level(void);
girara_log_level_t girara_get_log_level(void) GIRARA_VISIBLE;
/**
* Set the log level. Any message with a level lower than the log level will
* be discarded.
* @param level The new log level.
*/
void girara_set_log_level(girara_log_level_t level);
void girara_set_log_level(girara_log_level_t level) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_MACROS_H
#define GIRARA_MACROS_H
......@@ -7,6 +7,10 @@
#define __has_attribute(x) 0
#endif
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#ifndef GIRARA_PRINTF
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) || defined(__clang__)
# define GIRARA_PRINTF(format_idx, arg_idx) \
......@@ -27,7 +31,7 @@
#endif
#ifndef GIRARA_HIDDEN
# if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
# if (defined(__GNUC__) && (__GNUC__ >= 4)) || __has_attribute(visibility)
# define GIRARA_HIDDEN __attribute__((visibility("hidden")))
# elif defined(__SUNPRO_C)
# define GIRARA_HIDDEN __hidden
......@@ -37,7 +41,7 @@
#endif
#ifndef GIRARA_VISIBLE
# if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
# if (defined(__GNUC__) && (__GNUC__ >= 4)) || __has_attribute(visibility)
# define GIRARA_VISIBLE __attribute__((visibility("default")))
# else
# define GIRARA_VISIBLE
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "session.h"
......@@ -25,8 +25,11 @@
static int
cb_sort_settings(girara_setting_t* lhs, girara_setting_t* rhs)
cb_sort_settings(const void* data1, const void* data2)
{
const girara_setting_t* lhs = data1;
const girara_setting_t* rhs = data2;
return g_strcmp0(girara_setting_get_name(lhs), girara_setting_get_name(rhs));
}
......@@ -314,7 +317,7 @@ girara_session_create(void)
/* settings */
session_private->settings = girara_sorted_list_new2(
(girara_compare_function_t) cb_sort_settings,
cb_sort_settings,
(girara_free_function_t) girara_setting_free);
/* CSS style provider */
......@@ -449,12 +452,12 @@ girara_session_init(girara_session_t* session, const char* sessionname)
char* guioptions = NULL;
girara_setting_get(session, "guioptions", &guioptions);
const bool show_hscrollbar = strchr(guioptions, 'h') != NULL;
const bool show_vscrollbar = strchr(guioptions, 'v') != NULL;
const bool show_hscrollbar = guioptions != NULL && strchr(guioptions, 'h') != NULL;
const bool show_vscrollbar = guioptions != NULL && strchr(guioptions, 'v') != NULL;
g_free(guioptions);
scrolled_window_set_scrollbar_visibility(
GTK_SCROLLED_WINDOW(session->gtk.view), show_hscrollbar, show_vscrollbar);
g_free(guioptions);
/* viewport */
gtk_container_add(GTK_CONTAINER(session->gtk.view), session->gtk.viewport);
......@@ -475,6 +478,7 @@ girara_session_init(girara_session_t* session, const char* sessionname)
widget_add_class(GTK_WIDGET(session->gtk.inputbar_entry), "bottom_box");
widget_add_class(session->gtk.notification_text, "bottom_box");
widget_add_class(GTK_WIDGET(session->gtk.statusbar_entries), "bottom_box");
session->signals.inputbar_key_pressed = g_signal_connect(
G_OBJECT(session->gtk.inputbar_entry),
......@@ -562,10 +566,10 @@ girara_session_init(girara_session_t* session, const char* sessionname)
char* window_icon = NULL;
girara_setting_get(session, "window-icon", &window_icon);
if (window_icon != NULL) {
if (window_icon != NULL && strlen(window_icon) != 0) {
girara_set_window_icon(session, window_icon);
g_free(window_icon);
}
g_free(window_icon);
gtk_widget_grab_focus(GTK_WIDGET(session->gtk.view));
......@@ -888,6 +892,11 @@ girara_set_window_icon(girara_session_t* session, const char* name)
return false;
}
if (strlen(name) == 0) {
girara_warning("Empty icon name.");
return false;
}
GtkWindow* window = GTK_WINDOW(session->gtk.window);
char* path = girara_fix_path(name);
bool success = true;
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_SESSION_H
#define GIRARA_SESSION_H
......@@ -91,7 +91,7 @@ struct girara_session_s
* @return A valid session object
* @return NULL when an error occurred
*/
girara_session_t* girara_session_create(void);
girara_session_t* girara_session_create(void) GIRARA_VISIBLE;
/**
* Initializes an girara session
......@@ -101,7 +101,7 @@ girara_session_t* girara_session_create(void);
* @return TRUE No error occurred
* @return FALSE An error occurred
*/
bool girara_session_init(girara_session_t* session, const char* appname);
bool girara_session_init(girara_session_t* session, const char* appname) GIRARA_VISIBLE;
/**
* Destroys an girara session
......@@ -110,7 +110,7 @@ bool girara_session_init(girara_session_t* session, const char* appname);
* @return TRUE No error occurred
* @return FALSE An error occurred
*/
bool girara_session_destroy(girara_session_t* session);
bool girara_session_destroy(girara_session_t* session) GIRARA_VISIBLE;
/**
* Sets the view widget of girara
......@@ -120,7 +120,7 @@ bool girara_session_destroy(girara_session_t* session);
* @return TRUE No error occurred
* @return FALSE An error occurred
*/
bool girara_set_view(girara_session_t* session, GtkWidget* widget);
bool girara_set_view(girara_session_t* session, GtkWidget* widget) GIRARA_VISIBLE;
/**
* Returns a copy of the buffer
......@@ -128,7 +128,7 @@ bool girara_set_view(girara_session_t* session, GtkWidget* widget);
* @param session The used girara session
* @return Copy of the current buffer
*/
char* girara_buffer_get(girara_session_t* session);
char* girara_buffer_get(girara_session_t* session) GIRARA_VISIBLE;
/**
* Displays a notification popup for the user using libnotify. Basic styling
......@@ -140,7 +140,7 @@ char* girara_buffer_get(girara_session_t* session);
* @param body The content
*/
void girara_libnotify(girara_session_t* session, const char *summary,
const char *body);
const char *body) GIRARA_VISIBLE;
/**
* Displays a notification for the user. It is possible to pass GIRARA_INFO,
......@@ -152,7 +152,7 @@ void girara_libnotify(girara_session_t* session, const char *summary,
* @param ...
*/
void girara_notify(girara_session_t* session, int level,
const char* format, ...) GIRARA_PRINTF(3, 4);
const char* format, ...) GIRARA_PRINTF(3, 4) GIRARA_VISIBLE;
/**
* Creates a girara dialog
......@@ -166,7 +166,7 @@ void girara_notify(girara_session_t* session, int level,
*/
void girara_dialog(girara_session_t* session, const char* dialog, bool
invisible, girara_callback_inputbar_key_press_event_t key_press_event,
girara_callback_inputbar_activate_t activate_event, void* data);
girara_callback_inputbar_activate_t activate_event, void* data) GIRARA_VISIBLE;
/**
* Adds a new mode by its string identifier
......@@ -175,7 +175,7 @@ void girara_dialog(girara_session_t* session, const char* dialog, bool
* @param name The string identifier used in configs/inputbar etc to refer by
* @return A newly defined girara_mode_t associated with name
*/
girara_mode_t girara_mode_add(girara_session_t* session, const char* name);
girara_mode_t girara_mode_add(girara_session_t* session, const char* name) GIRARA_VISIBLE;
/**
* Sets the current mode
......@@ -183,7 +183,7 @@ girara_mode_t girara_mode_add(girara_session_t* session, const char* name);
* @param session The used girara session
* @param mode The new mode
*/
void girara_mode_set(girara_session_t* session, girara_mode_t mode);
void girara_mode_set(girara_session_t* session, girara_mode_t mode) GIRARA_VISIBLE;
/**
* Returns the current mode
......@@ -191,7 +191,7 @@ void girara_mode_set(girara_session_t* session, girara_mode_t mode);
* @param session The used girara session
* @return The current mode
*/
girara_mode_t girara_mode_get(girara_session_t* session);
girara_mode_t girara_mode_get(girara_session_t* session) GIRARA_VISIBLE;
/**
* Set name of the window title
......@@ -201,7 +201,7 @@ girara_mode_t girara_mode_get(girara_session_t* session);
* @return true if no error occurred
* @return false if an error occurred
*/
bool girara_set_window_title(girara_session_t* session, const char* name);
bool girara_set_window_title(girara_session_t* session, const char* name) GIRARA_VISIBLE;
/**
* Set icon of the window
......@@ -211,7 +211,7 @@ bool girara_set_window_title(girara_session_t* session, const char* name);
* @return true if no error occurred
* @return false if an error occurred
*/
bool girara_set_window_icon(girara_session_t* session, const char* name);
bool girara_set_window_icon(girara_session_t* session, const char* name) GIRARA_VISIBLE;
/**
* Returns the command history
......@@ -219,7 +219,7 @@ bool girara_set_window_icon(girara_session_t* session, const char* name);
* @param session The used girara session
* @return The command history (list of strings) or NULL
*/
girara_list_t* girara_get_command_history(girara_session_t* session);
girara_list_t* girara_get_command_history(girara_session_t* session) GIRARA_VISIBLE;
/**
* Returns the internal template object to apply custom theming options
......@@ -227,7 +227,7 @@ girara_list_t* girara_get_command_history(girara_session_t* session);
* @param session The girara session
* @returns GiraraTemplate object
*/
GiraraTemplate* girara_session_get_template(girara_session_t* session);
GiraraTemplate* girara_session_get_template(girara_session_t* session) GIRARA_VISIBLE;
/**
* Replaces the internal template object, thus provides entirely user-defined styling.
......@@ -240,6 +240,6 @@ GiraraTemplate* girara_session_get_template(girara_session_t* session);
* @note Using the template @c girara_template_new("") will use the default gtk style
*
*/
void girara_session_set_template(girara_session_t* session, GiraraTemplate* template, bool init_variables);
void girara_session_set_template(girara_session_t* session, GiraraTemplate* template, bool init_variables) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include <stdlib.h>
#include <glib.h>
......@@ -187,7 +187,7 @@ girara_setting_find(girara_session_t* session, const char* name)
}
const char*
girara_setting_get_name(girara_setting_t* setting) {
girara_setting_get_name(const girara_setting_t* setting) {
g_return_val_if_fail(setting, NULL);
return setting->name;
}
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_SETTINGS_H
#define GIRARA_SETTINGS_H
#include "types.h"
#include "macros.h"
/**
* Adds an additional entry in the settings list
......@@ -21,7 +22,7 @@
*/
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);
const char* description, girara_setting_callback_t callback, void* data) GIRARA_VISIBLE;
/**
* Sets the value of a setting
......@@ -32,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);
bool girara_setting_set(girara_session_t* session, const char* name, void* value) GIRARA_VISIBLE;
/**
* Retrieve the value of a setting. If the setting is a string, the value stored
......@@ -42,7 +43,7 @@ bool girara_setting_set(girara_session_t* session, const char* name, void* value
* @param dest A pointer to the destination of the result.
* @return true if the setting exists, false otherwise.
*/
bool girara_setting_get(girara_session_t* session, const char* name, void* dest);
bool girara_setting_get(girara_session_t* session, const char* name, void* dest) GIRARA_VISIBLE;
/**
* Find a setting.
......@@ -51,7 +52,7 @@ bool girara_setting_get(girara_session_t* session, const char* name, void* dest)
* @param name name of the setting
* @return the setting or NULL if it doesn't exist
*/
girara_setting_t* girara_setting_find(girara_session_t* session, const char* name);
girara_setting_t* girara_setting_find(girara_session_t* session, const char* name) GIRARA_VISIBLE;
/**
* Get the setting's name.
......@@ -59,7 +60,7 @@ girara_setting_t* girara_setting_find(girara_session_t* session, const char* nam
* @param setting The setting
* @return the setting's name
*/
const char* girara_setting_get_name(girara_setting_t* setting);
const char* girara_setting_get_name(const girara_setting_t* setting) GIRARA_VISIBLE;
/**
* Get the setting's value. If the setting is a string, the value stored
......@@ -69,7 +70,7 @@ const char* girara_setting_get_name(girara_setting_t* setting);
* @param dest A pointer to the destination of the result.
* @return true if the setting exists, false otherwise.
*/
bool girara_setting_get_value(girara_setting_t* setting, void* dest);
bool girara_setting_get_value(girara_setting_t* setting, void* dest) GIRARA_VISIBLE;
/**
* Get the setting's value.
......@@ -77,7 +78,7 @@ bool girara_setting_get_value(girara_setting_t* setting, void* dest);
* @param setting The setting
* @return the value
*/
girara_setting_type_t girara_setting_get_type(girara_setting_t* setting);
girara_setting_type_t girara_setting_get_type(girara_setting_t* setting) GIRARA_VISIBLE;
/**
* Set the setting's value. If session is NULL, the setting's callback won't be
......@@ -88,6 +89,6 @@ girara_setting_type_t girara_setting_get_type(girara_setting_t* setting);
* @param value The new value
*/
void girara_setting_set_value(girara_session_t* session,
girara_setting_t* setting, void* value);
girara_setting_t* setting, void* value) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "shortcuts.h"
......@@ -28,7 +28,7 @@ girara_shortcut_add(girara_session_t* session, guint modifier, guint key, const
bool found_existing_shortcut = false;
GIRARA_LIST_FOREACH_BODY_WITH_ITER(session->bindings.shortcuts, girara_shortcut_t*, iter, shortcuts_it,
if (((shortcuts_it->mask == modifier && shortcuts_it->key == key && (modifier != 0 || key != 0)) ||
(buffer && shortcuts_it->buffered_command && !strcmp(shortcuts_it->buffered_command, buffer)))
(buffer && shortcuts_it->buffered_command && !g_strcmp0(shortcuts_it->buffered_command, buffer)))
&& ((shortcuts_it->mode == mode) || (mode == 0)))
{
if (shortcuts_it->argument.data != NULL) {
......@@ -74,7 +74,7 @@ girara_shortcut_remove(girara_session_t* session, guint modifier, guint key, con
/* search for existing binding */
GIRARA_LIST_FOREACH_BODY(session->bindings.shortcuts, girara_shortcut_t*, shortcuts_it,
if (((shortcuts_it->mask == modifier && shortcuts_it->key == key && (modifier != 0 || key != 0)) ||
(buffer && shortcuts_it->buffered_command && !strcmp(shortcuts_it->buffered_command, buffer)))
(buffer && shortcuts_it->buffered_command && !g_strcmp0(shortcuts_it->buffered_command, buffer)))
&& shortcuts_it->mode == mode) {
girara_list_remove(session->bindings.shortcuts, shortcuts_it);
handled = true;
......@@ -218,7 +218,7 @@ girara_isc_string_manipulation(girara_session_t* session, girara_argument_t* arg
}
/* find the beginning of the word */
while ((i == (pos - 1)) || ((i > 0) && !strchr(separator, input[i]))) {
while ((i == (pos - 1)) || ((i > 0) && separator != NULL && !strchr(separator, input[i]))) {
i--;
}
......@@ -554,7 +554,7 @@ girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument,
}
/* Possible special key */
} else {
for (unsigned int j = 0; i < LENGTH(gdk_keyboard_buttons); ++j) {
for (unsigned int j = 0; j < LENGTH(gdk_keyboard_buttons); ++j) {
if (g_strcmp0(tmp, gdk_keyboard_buttons[j].identifier) == 0) {
keyval = gdk_keyboard_buttons[j].keyval;
found = true;
......@@ -594,7 +594,7 @@ girara_shortcut_mapping_add(girara_session_t* session, const char* identifier, g
bool found = false;
GIRARA_LIST_FOREACH_BODY(session_private->config.shortcut_mappings, girara_shortcut_mapping_t*, data,
if (strcmp(data->identifier, identifier) == 0) {
if (g_strcmp0(data->identifier, identifier) == 0) {
data->function = function;
found = true;
break;
......@@ -743,15 +743,13 @@ simulate_key_press(girara_session_t* session, int state, int key)
GdkEvent* event = gdk_event_new(GDK_KEY_PRESS);
event->key.type = GDK_KEY_PRESS;
event->key.window = gtk_widget_get_parent_window(GTK_WIDGET(session->gtk.box));
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;
g_object_ref(event->key.window);
GdkDisplay* display = gtk_widget_get_display(GTK_WIDGET(session->gtk.box));
GdkKeymapKey* keys = NULL;
gint number_of_keys = 0;
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_SHORTCUTS_H
#define GIRARA_SHORTCUTS_H
#include "types.h"
#include "macros.h"
#include <glib.h>
/**
......@@ -24,7 +25,7 @@
*/
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);
int argument_n, void* argument_data) GIRARA_VISIBLE;
/**
* Removes a shortcut
......@@ -38,7 +39,7 @@ bool girara_shortcut_add(girara_session_t* session, guint modifier, guint key,
* @return false An error occurred
*/
bool girara_shortcut_remove(girara_session_t* session, guint modifier, guint
key, const char* buffer, girara_mode_t mode);
key, const char* buffer, girara_mode_t mode) GIRARA_VISIBLE;
/**
* Adds an inputbar shortcut
......@@ -54,7 +55,7 @@ bool girara_shortcut_remove(girara_session_t* session, guint modifier, guint
*/
bool girara_inputbar_shortcut_add(girara_session_t* session, guint modifier,
guint key, girara_shortcut_function_t function, int argument_n, void*
argument_data);
argument_data) GIRARA_VISIBLE;
/**
* Removes an inputbar shortcut
......@@ -66,7 +67,7 @@ bool girara_inputbar_shortcut_add(girara_session_t* session, guint modifier,
* @return false An error occurred
*/
bool girara_inputbar_shortcut_remove(girara_session_t* session, guint modifier,
guint key);
guint key) GIRARA_VISIBLE;
/**
* Default shortcut function to focus the inputbar
......@@ -79,7 +80,7 @@ bool girara_inputbar_shortcut_remove(girara_session_t* session, guint modifier,
* @return false An error occurred (abort execution)
*/
bool girara_sc_focus_inputbar(girara_session_t* session, girara_argument_t*
argument, girara_event_t* event, unsigned int t);
argument, girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Default shortcut function to abort
......@@ -92,7 +93,7 @@ bool girara_sc_focus_inputbar(girara_session_t* session, girara_argument_t*
* @return false An error occurred (abort execution)
*/
bool girara_sc_abort(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t);
girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Default shortcut function to quit the application
......@@ -105,7 +106,7 @@ bool girara_sc_abort(girara_session_t* session, girara_argument_t* argument,
* @return false An error occurred (abort execution)
*/
bool girara_sc_quit(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t);
girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Toggles the visibility of the inputbar
......@@ -118,7 +119,7 @@ bool girara_sc_quit(girara_session_t* session, girara_argument_t* argument,
* @return false An error occurred (abort execution)
*/
bool girara_sc_toggle_inputbar(girara_session_t* session, girara_argument_t*
argument, girara_event_t* event, unsigned int t);
argument, girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Toggles the visibility of the statusbar
......@@ -131,7 +132,7 @@ bool girara_sc_toggle_inputbar(girara_session_t* session, girara_argument_t*
* @return false An error occurred (abort execution)
*/
bool girara_sc_toggle_statusbar(girara_session_t* session, girara_argument_t*
argument, girara_event_t* event, unsigned int t);
argument, girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Passes the argument to the set command
......@@ -144,7 +145,7 @@ bool girara_sc_toggle_statusbar(girara_session_t* session, girara_argument_t*
* @return false An error occurred (abort execution)
*/
bool girara_sc_set(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t);
girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Executes a command.
......@@ -157,7 +158,7 @@ bool girara_sc_set(girara_session_t* session, girara_argument_t* argument,
* @return false An error occurred (abort execution)
*/
bool girara_sc_exec(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t);
girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Default shortcut function to activate
......@@ -170,7 +171,7 @@ bool girara_sc_exec(girara_session_t* session, girara_argument_t* argument,
* @return false An error occurred (abort execution)
*/
bool girara_isc_activate(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t);
girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Default inputbar shortcut to abort
......@@ -183,7 +184,7 @@ bool girara_isc_activate(girara_session_t* session, girara_argument_t* argument,
* @return false An error occurred (abort execution)
*/
bool girara_isc_abort(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t);
girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Default inputbar shortcut that completes the given input
......@@ -197,7 +198,7 @@ bool girara_isc_abort(girara_session_t* session, girara_argument_t* argument,
* @return false An error occurred (abort execution)
*/
bool girara_isc_completion(girara_session_t* session, girara_argument_t*
argument, girara_event_t* event, unsigned int t);
argument, girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Default inputbar shortcut to manipulate the inputbar string
......@@ -210,7 +211,7 @@ bool girara_isc_completion(girara_session_t* session, girara_argument_t*
* @return false An error occurred (abort execution)
*/
bool girara_isc_string_manipulation(girara_session_t* session,
girara_argument_t* argument, girara_event_t* event, unsigned int t);
girara_argument_t* argument, girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Default inputbar shortcut to navigate through the command history
......@@ -223,7 +224,7 @@ bool girara_isc_string_manipulation(girara_session_t* session,
* @return false An error occurred (abort execution)
*/
bool girara_isc_command_history(girara_session_t* session,
girara_argument_t* argument, girara_event_t* event, unsigned int t);
girara_argument_t* argument, girara_event_t* event, unsigned int t) GIRARA_VISIBLE;
/**
* Creates a mapping between a shortcut function and an identifier and is used
......@@ -235,7 +236,7 @@ bool girara_isc_command_history(girara_session_t* session,
* @return true if no error occurred
*/
bool girara_shortcut_mapping_add(girara_session_t* session,
const char* identifier, girara_shortcut_function_t function);
const char* identifier, girara_shortcut_function_t function) GIRARA_VISIBLE;
/**
* Creates a mapping between a shortcut argument and an identifier and is used
......@@ -247,7 +248,7 @@ bool girara_shortcut_mapping_add(girara_session_t* session,
* @return true if no error occurred
*/
bool girara_argument_mapping_add(girara_session_t* session,
const char* identifier, int value);
const char* identifier, int value) GIRARA_VISIBLE;
/**
* Adds a mouse event
......@@ -265,7 +266,7 @@ bool girara_argument_mapping_add(girara_session_t* session,
*/
bool girara_mouse_event_add(girara_session_t* session, guint mask, guint button,
girara_shortcut_function_t function, girara_mode_t mode,
girara_event_type_t event_type, int argument_n, void* argument_data);
girara_event_type_t event_type, int argument_n, void* argument_data) GIRARA_VISIBLE;
/**
* Removes a mouse event
......@@ -278,6 +279,6 @@ bool girara_mouse_event_add(girara_session_t* session, guint mask, guint button,
* @return false An error occurred
*/
bool girara_mouse_event_remove(girara_session_t* session, guint mask,
guint button, girara_mode_t mode);
guint button, girara_mode_t mode) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "statusbar.h"
#include "session.h"
......
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#ifndef GIRARA_STATUSBAR_H
#define GIRARA_STATUSBAR_H
......@@ -31,7 +31,7 @@ typedef bool (*girara_statusbar_event_t)(GtkWidget* widget, GdkEvent* event,
* @return NULL An error occurred
*/
girara_statusbar_item_t* girara_statusbar_item_add(girara_session_t* session,
bool expand, bool fill, bool left, girara_statusbar_event_t callback);
bool expand, bool fill, bool left, girara_statusbar_event_t callback) GIRARA_VISIBLE;
/**
* Sets the shown text of an statusbar item
......@@ -43,6 +43,6 @@ girara_statusbar_item_t* girara_statusbar_item_add(girara_session_t* session,
* @return FALSE An error occurred
*/
bool girara_statusbar_item_set_text(girara_session_t* session,
girara_statusbar_item_t* item, const char* text);
girara_statusbar_item_t* item, const char* text) GIRARA_VISIBLE;
#endif
/* See LICENSE file for license and copyright information */
/* SPDX-License-Identifier: Zlib */
#include "template.h"
#include "utils.h"
#include "datastructures.h"
#include "internal.h"
#include <glib.h>
G_DEFINE_TYPE(GiraraTemplate, girara_template, G_TYPE_OBJECT)
/**
* Private data of the template
*/
......@@ -18,12 +17,9 @@ typedef struct private_s {
girara_list_t* variables_in_base;
girara_list_t* variables;
bool valid;
} private_t;
typedef struct private_s GiraraTemplatePrivate;
} GiraraTemplatePrivate;
#define GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GIRARA_TYPE_TEMPLATE, private_t))
G_DEFINE_TYPE_WITH_CODE(GiraraTemplate, girara_template, G_TYPE_OBJECT, G_ADD_PRIVATE(GiraraTemplate))
/**
* Internal variables
......@@ -40,7 +36,7 @@ new_variable(const char* name)
return NULL;
}
variable_t* variable = g_try_malloc0(sizeof(variable_t));
variable_t* variable = g_slice_new0(variable_t);
if (variable == NULL) {
return NULL;
}
......@@ -62,7 +58,7 @@ free_variable(void* data)
variable->name = NULL;
variable->value = NULL;
g_free(variable);
g_slice_free(variable_t, data);
}