Commit c24136f4 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Merge branch 'release/0.3.6'

parents af6016f9 11721e2c
Pipeline #369 passed with stages
in 2 minutes and 1 second
......@@ -2,6 +2,7 @@
#include "callbacks.h"
#include "commands.h"
#include "datastructures.h"
#include "input-history.h"
#include "internal.h"
......@@ -248,7 +249,7 @@ girara_callback_view_button_press_event(GtkWidget* UNUSED(widget),
&& mouse_event->event_type == event.type
&& (session->modes.current_mode == mouse_event->mode || mouse_event->mode == 0)
) {
mouse_event->function(session, &(mouse_event->argument), &event, session_private->buffer.n);
mouse_event->function(session, &mouse_event->argument, &event, session_private->buffer.n);
handled = true;
break;
}
......@@ -447,76 +448,9 @@ girara_callback_inputbar_activate(GtkEntry* entry, girara_session_t* session)
}
);
/* parse input */
gchar** argv = NULL;
gint argc = 0;
if (g_shell_parse_argv(input, &argc, &argv, NULL) == FALSE) {
girara_debug("Failed to parse argument.");
g_free(input);
return false;
}
gchar *cmd = argv[0];
/* search commands */
GIRARA_LIST_FOREACH_BODY_WITH_ITER(session->bindings.commands, girara_command_t*, iter, binding_command,
if ((g_strcmp0(cmd, binding_command->command) == 0) ||
(g_strcmp0(cmd, binding_command->abbr) == 0)) {
girara_list_t* argument_list = girara_list_new();
if (argument_list == NULL) {
g_free(input);
g_strfreev(argv);
girara_list_iterator_free(iter);
return false;
}
girara_list_set_free_function(argument_list, g_free);
for(int i = 1; i < argc; i++) {
char* argument = g_strdup(argv[i]);
girara_list_append(argument_list, (void*) argument);
}
binding_command->function(session, argument_list);
girara_list_free(argument_list);
bool ret = girara_command_run(session, input);
g_free(input);
g_strfreev(argv);
girara_isc_abort(session, NULL, NULL, 0);
if (session->global.autohide_inputbar == true) {
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar));
}
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar_dialog));
girara_list_iterator_free(iter);
return true;
}
);
/* check for unknown command event handler */
if (session->events.unknown_command != NULL) {
if (session->events.unknown_command(session, input) == true) {
g_strfreev(argv);
g_free(input);
girara_isc_abort(session, NULL, NULL, 0);
if (session->global.autohide_inputbar == true) {
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar));
}
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar_dialog));
return true;
}
}
/* unhandled command */
girara_notify(session, GIRARA_ERROR, _("Not a valid command: %s"), cmd);
g_strfreev(argv);
girara_isc_abort(session, NULL, NULL, 0);
return false;
return ret;
}
gboolean
......
......@@ -632,3 +632,74 @@ girara_cmd_exec(girara_session_t* session, girara_list_t* argument_list)
return girara_exec_with_argument_list(session, argument_list);
}
bool
girara_command_run(girara_session_t* session, const char* input)
{
/* parse input */
gchar** argv = NULL;
gint argc = 0;
if (g_shell_parse_argv(input, &argc, &argv, NULL) == FALSE) {
girara_debug("Failed to parse argument.");
return false;
}
gchar *cmd = argv[0];
/* search commands */
GIRARA_LIST_FOREACH_BODY_WITH_ITER(session->bindings.commands, girara_command_t*, iter, binding_command,
if ((g_strcmp0(cmd, binding_command->command) == 0) ||
(g_strcmp0(cmd, binding_command->abbr) == 0)) {
girara_list_t* argument_list = girara_list_new();
if (argument_list == NULL) {
g_strfreev(argv);
girara_list_iterator_free(iter);
return false;
}
girara_list_set_free_function(argument_list, g_free);
for(int i = 1; i < argc; i++) {
char* argument = g_strdup(argv[i]);
girara_list_append(argument_list, (void*) argument);
}
binding_command->function(session, argument_list);
girara_list_free(argument_list);
g_strfreev(argv);
girara_isc_abort(session, NULL, NULL, 0);
if (session->global.autohide_inputbar == true) {
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar));
}
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar_dialog));
girara_list_iterator_free(iter);
return true;
}
);
/* check for unknown command event handler */
if (session->events.unknown_command != NULL) {
if (session->events.unknown_command(session, input) == true) {
g_strfreev(argv);
girara_isc_abort(session, NULL, NULL, 0);
if (session->global.autohide_inputbar == true) {
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar));
}
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar_dialog));
return true;
}
}
/* unhandled command */
girara_notify(session, GIRARA_ERROR, _("Not a valid command: %s"), cmd);
g_strfreev(argv);
girara_isc_abort(session, NULL, NULL, 0);
return false;
}
......@@ -40,4 +40,14 @@ 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) GIRARA_VISIBLE;
/**
* Parse input and execute the command
*
* @param session The used girara session
* @param input User input
* @return TRUE No error occurred
* @return FALSE An error occured */
bool girara_command_run(girara_session_t* session, const char* input) GIRARA_VISIBLE;
#endif
......@@ -111,59 +111,6 @@ cb_guioptions(girara_session_t* session, const char* UNUSED(name),
GTK_SCROLLED_WINDOW(session->gtk.view), show_hscrollbar, show_vscrollbar);
}
static void
cb_scrollbars(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
const bool val = *(const bool*) value;
char* guioptions = NULL;
girara_setting_get(session, "guioptions", &guioptions);
g_return_if_fail(guioptions != NULL);
bool show_hscrollbar = strchr(guioptions, 'h') != NULL;
bool show_vscrollbar = strchr(guioptions, 'v') != NULL;
if (g_strcmp0(name, "show-scrollbars") == 0) {
show_hscrollbar = show_vscrollbar = val;
} else if (g_strcmp0(name, "show-h-scrollbar") == 0) {
show_hscrollbar = val;
} else if (g_strcmp0(name, "show-v-scrollbar") == 0) {
show_vscrollbar = val;
}
const size_t guioptions_len = strlen(guioptions);
char* new_guioptions = g_try_malloc0(sizeof(char) * (guioptions_len + 3));
char* iterator = new_guioptions;
if (new_guioptions == NULL) {
g_free(guioptions);
return;
}
/* copy everything apart from h and v */
for (size_t i = 0; i != guioptions_len; ++i) {
if (guioptions[i] != 'h' && guioptions[i] != 'v') {
*iterator = guioptions[i];
++iterator;
}
}
g_free(guioptions);
if (show_hscrollbar == true) {
*iterator = 'h';
++iterator;
}
if (show_vscrollbar == true) {
*iterator = 'v';
++iterator;
}
girara_setting_set(session, "guioptions", new_guioptions);
g_free(new_guioptions);
}
void
girara_config_load_default(girara_session_t* session)
{
......@@ -177,7 +124,6 @@ girara_config_load_default(girara_session_t* session)
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;
/* other values */
......@@ -211,9 +157,6 @@ girara_config_load_default(girara_session_t* session)
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);
girara_setting_add(session, "show-v-scrollbar", &show_scrollbars, BOOLEAN, FALSE, _("Show the vertical scrollbar"), cb_scrollbars, NULL);
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);
......
......@@ -94,10 +94,16 @@ css_template_fill_font(GiraraTemplate* csstemplate, const char* font)
girara_template_set_variable_value(csstemplate, "font-family",
pango_font_description_get_family(descr));
const int font_size = pango_font_description_get_size(descr);
if (!font_size) {
girara_debug("no font size given, defaulting to 9");
girara_template_set_variable_value(csstemplate, "font-size", "9pt");
} else {
char* size = g_strdup_printf("%d%s", pango_font_description_get_size(descr) / PANGO_SCALE,
pango_font_description_get_size_is_absolute(descr) == FALSE ? "pt" : "");
girara_template_set_variable_value(csstemplate, "font-size", size);
g_free(size);
}
switch (pango_font_description_get_weight(descr)) {
case PANGO_WEIGHT_THIN:
......
project('girara', 'c',
version: '0.3.5',
version: '0.3.6',
meson_version: '>=0.48',
default_options: ['c_std=c11', 'warning_level=3'],
)
......
......@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-17 00:04+0200\n"
"POT-Creation-Date: 2021-07-13 09:01+0200\n"
"PO-Revision-Date: 2019-06-01 09:25+0000\n"
"Last-Translator: Sebastian Ramacher <sebastian+dev@ramacher.at>\n"
"Language-Team: Arabic (http://www.transifex.com/pwmt/girara/language/ar/)\n"
......@@ -17,12 +17,6 @@ msgstr ""
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 "
"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
#. unhandled command
#: girara/callbacks.c:515
#, c-format
msgid "Not a valid command: %s"
msgstr ""
#: girara/commands.c:111 girara/commands.c:311
#, c-format
msgid "Invalid number of arguments passed: %zu instead of at least %u"
......@@ -84,157 +78,151 @@ msgstr ""
msgid "Unknown value for option: %s"
msgstr ""
#. unhandled command
#: girara/commands.c:700
#, c-format
msgid "Not a valid command: %s"
msgstr ""
#. settings
#: girara/config.c:187
#: girara/config.c:133
msgid "Font"
msgstr ""
#: girara/config.c:188
#: girara/config.c:134
msgid "Default foreground color"
msgstr ""
#: girara/config.c:189
#: girara/config.c:135
msgid "Default background color"
msgstr ""
#: girara/config.c:190
#: girara/config.c:136
msgid "Inputbar foreground color"
msgstr ""
#: girara/config.c:191
#: girara/config.c:137
msgid "Inputbar background color"
msgstr ""
#: girara/config.c:192
#: girara/config.c:138
msgid "Statusbar foreground color"
msgstr ""
#: girara/config.c:193
#: girara/config.c:139
msgid "Statsubar background color"
msgstr ""
#: girara/config.c:194
#: girara/config.c:140
msgid "Completion foreground color"
msgstr ""
#: girara/config.c:195
#: girara/config.c:141
msgid "Completion background color"
msgstr ""
#: girara/config.c:196
#: girara/config.c:142
msgid "Completion group foreground color"
msgstr ""
#: girara/config.c:197
#: girara/config.c:143
msgid "Completion group background color"
msgstr ""
#: girara/config.c:198
#: girara/config.c:144
msgid "Completion highlight foreground color"
msgstr ""
#: girara/config.c:199
#: girara/config.c:145
msgid "Completion highlight background color"
msgstr ""
#: girara/config.c:200
#: girara/config.c:146
msgid "Error notification foreground color"
msgstr ""
#: girara/config.c:201
#: girara/config.c:147
msgid "Error notification background color"
msgstr ""
#: girara/config.c:202
#: girara/config.c:148
msgid "Warning notification foreground color"
msgstr ""
#: girara/config.c:203
#: girara/config.c:149
msgid "Warning notifaction background color"
msgstr ""
#: girara/config.c:204
#: girara/config.c:150
msgid "Notification foreground color"
msgstr ""
#: girara/config.c:205
#: girara/config.c:151
msgid "Notification background color"
msgstr ""
#: girara/config.c:206
#: girara/config.c:152
msgid "Scrollbar foreground color"
msgstr ""
#: girara/config.c:207
#: girara/config.c:153
msgid "Scrollbar background color"
msgstr ""
#: girara/config.c:209
#: girara/config.c:155
msgid "Initial window width"
msgstr ""
#: girara/config.c:210
#: girara/config.c:156
msgid "Initial window height"
msgstr ""
#: girara/config.c:211
#: girara/config.c:157
msgid "Horizontal padding for the status, input, and notification bars"
msgstr ""
#: girara/config.c:212
#: girara/config.c:158
msgid "Vertical padding for the status, input, and notification bars"
msgstr ""
#: girara/config.c:213
#: girara/config.c:159
msgid "Number of completion items"
msgstr ""
#: girara/config.c:214
msgid "Show both the horizontal and vertical scrollbars"
msgstr ""
#: girara/config.c:215
msgid "Show the horizontal scrollbar"
msgstr ""
#: girara/config.c:216
msgid "Show the vertical scrollbar"
msgstr ""
#: girara/config.c:217
#: girara/config.c:160
msgid "Window icon"
msgstr ""
#: girara/config.c:218
#: girara/config.c:161
msgid "Command to execute in :exec"
msgstr ""
#: girara/config.c:219
#: girara/config.c:162
msgid "Show or hide certain GUI elements"
msgstr ""
#. commands
#: girara/config.c:255
#: girara/config.c:198
msgid "Execute a command"
msgstr ""
#: girara/config.c:256
#: girara/config.c:199
msgid "Map a key sequence"
msgstr ""
#: girara/config.c:257
#: girara/config.c:200
msgid "Quit the program"
msgstr ""
#: girara/config.c:258
#: girara/config.c:201
msgid "Set an option"
msgstr ""
#: girara/config.c:259
#: girara/config.c:202
msgid "Unmap a key sequence"
msgstr ""
#: girara/config.c:261
#: girara/config.c:204
msgid "Dump settings to a file"
msgstr ""
......
......@@ -11,7 +11,7 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-17 00:04+0200\n"
"POT-Creation-Date: 2021-07-13 09:01+0200\n"
"PO-Revision-Date: 2019-06-01 09:25+0000\n"
"Last-Translator: Sebastian Ramacher <sebastian+dev@ramacher.at>\n"
"Language-Team: German (http://www.transifex.com/pwmt/girara/language/de/)\n"
......@@ -21,12 +21,6 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. unhandled command
#: girara/callbacks.c:515
#, c-format
msgid "Not a valid command: %s"
msgstr "Ungültige zugewiesene Funktion: %s"
#: girara/commands.c:111 girara/commands.c:311
#, c-format
msgid "Invalid number of arguments passed: %zu instead of at least %u"
......@@ -68,7 +62,7 @@ msgstr "Zu viele Argumente."
#: girara/commands.c:441
#, c-format
msgid "Unknown option: %s"
msgstr "Unbekannte Otion: %s"
msgstr "Unbekannte Option: %s"
#: girara/commands.c:455
msgid "true"
......@@ -88,161 +82,155 @@ msgstr "Kein Wert für Option definiert: %s"
msgid "Unknown value for option: %s"
msgstr "Unbekannter Wert für Option: %s"
#. unhandled command
#: girara/commands.c:700
#, c-format
msgid "Not a valid command: %s"
msgstr "Ungültige zugewiesene Funktion: %s"
#. settings
#: girara/config.c:187
#: girara/config.c:133
msgid "Font"
msgstr "Schriftart"
#: girara/config.c:188
#: girara/config.c:134
msgid "Default foreground color"
msgstr "Standardfarbe des Vordergrunds"
#: girara/config.c:189
#: girara/config.c:135
msgid "Default background color"
msgstr "Standardfarbe des Hintergrunds"
#: girara/config.c:190
#: girara/config.c:136
msgid "Inputbar foreground color"
msgstr "Vordergrundfarbe der Eingabezeile"
#: girara/config.c:191
#: girara/config.c:137
msgid "Inputbar background color"
msgstr "Hintergrundfarbe der Eingabezeile"
#: girara/config.c:192
#: girara/config.c:138
msgid "Statusbar foreground color"
msgstr "Vordergrundfarbe der Statuszeile"
#: girara/config.c:193
#: girara/config.c:139
msgid "Statsubar background color"
msgstr "Hintergrundfarbe der Statuszeile"
#: girara/config.c:194
#: girara/config.c:140
msgid "Completion foreground color"
msgstr "Vordergrundfarbe der Vervollständigung"
#: girara/config.c:195
#: girara/config.c:141
msgid "Completion background color"
msgstr "Hintergrundfarbe der Vervollständigung"
#: girara/config.c:196
#: girara/config.c:142
msgid "Completion group foreground color"
msgstr "Vordergrundfarbe der Vervollständigung (Gruppe)"
#: girara/config.c:197
#: girara/config.c:143
msgid "Completion group background color"
msgstr "Hintergrundfarbe der Vervollständigung (Gruppe)"
#: girara/config.c:198
#: girara/config.c:144
msgid "Completion highlight foreground color"
msgstr "Vordergrundfarbe der Vervollständigung (Hervorhebung)"
#: girara/config.c:199
#: girara/config.c:145
msgid "Completion highlight background color"
msgstr "Hintergrundfarbe der Vervollständigung (Hervorhebung)"
#: girara/config.c:200
#: girara/config.c:146
msgid "Error notification foreground color"
msgstr "Vordergrundfarbe der Benachrichtigung (Fehler)"
#: girara/config.c:201
#: girara/config.c:147
msgid "Error notification background color"
msgstr "Hintergrundfarbe der Benachrichtigung (Fehler)"
#: girara/config.c:202
#: girara/config.c:148
msgid "Warning notification foreground color"
msgstr "Vordergrundfarbe der Benachrichtigung (Warnung)"
#: girara/config.c:203
#: girara/config.c:149
msgid "Warning notifaction background color"
msgstr "Hintergrundfarbe der Benachrichtigung (Warnung)"
#: girara/config.c:204
#: girara/config.c:150
msgid "Notification foreground color"
msgstr "Vordergrundfarbe der Benachrichtigung"
#: girara/config.c:205
#: girara/config.c:151
msgid "Notification background color"
msgstr "Hintergrundfarbe der Benachrichtigung"
#: girara/config.c:206
#: girara/config.c:152
msgid "Scrollbar foreground color"
msgstr "Vordergrundfarbe der Bildlaufleiste"
#: girara/config.c:207
#: girara/config.c:153
msgid "Scrollbar background color"
msgstr "Hintergrundfarbe der Bildlaufleiste"
#: girara/config.c:209
#: girara/config.c:155
msgid "Initial window width"
msgstr "Ausgangsbreite des Fensters"
#: girara/config.c:210
#: girara/config.c:156
msgid "Initial window height"
msgstr "Ausgangshöhe des Fensters"
#: girara/config.c:211
#: girara/config.c:157
msgid "Horizontal padding for the status, input, and notification bars"
msgstr ""
"Horizontaler innerer Rand für die Status-, Eingabe- und "
"Benachrichtigungsleisten"
#: girara/config.c:212
#: girara/config.c:158
msgid "Vertical padding for the status, input, and notification bars"
msgstr ""
"Vertikaler innerer Rand für die Status-, Eingabe- und "
"Benachrichtigungsleisten"
#: girara/config.c:213
#: girara/config.c:159
msgid "Number of completion items"
msgstr "Anzahl der Elemente in der Vervollständigung"
#: girara/config.c:214
msgid "Show both the horizontal and vertical scrollbars"
msgstr "Zeige horizontale und vertikale Bildlaufleiste"
#: girara/config.c:215
msgid "Show the horizontal scrollbar"
msgstr "Zeige horizontale Bildlaufleiste"
#: girara/config.c:216
msgid "Show the vertical scrollbar"
msgstr "Zeige vertikale Bildlaufleiste"
#: girara/config.c:217
#: girara/config.c:160
msgid "Window icon"
msgstr "Fenstericon"
#: girara/config.c:218
#: girara/config.c:161
msgid "Command to execute in :exec"
msgstr "Befehl, der von :exec ausgeführt werden soll"
#: girara/config.c:219
#: girara/config.c:162
msgid "Show or hide certain GUI elements"
msgstr "Zeige oder verstecke bestimmte GUI Elemente"
#. commands
#: girara/config.c:255
#: girara/config.c:198
msgid "Execute a command"
msgstr "Führe einen Befehl aus."
#: girara/config.c:256
#: girara/config.c:199
msgid "Map a key sequence"
msgstr "Tastenfolge zuweisen"
#: girara/config.c:257
#: girara/config.c:200
msgid "Quit the program"
msgstr "Beende das Programm"
#: girara/config.c:258
#: girara/config.c:201
msgid "Set an option"
msgstr "Setze eine Option"
#: girara/config.c:259
#: girara/config.c:202
msgid "Unmap a key sequence"
msgstr "Tastenfolge entbinden"
#: girara/config.c:261
#: girara/config.c:204
msgid "Dump settings to a file"
msgstr "Speichere Einstellungen in einer Datei"
......
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-17 00:04+0200\n"
"POT-Creation-Date: 2021-07-13 09:01+0200\n"
"PO-Revision-Date: 2019-06-01 09:25+0000\n"
"Last-Translator: Sebastian Ramacher <sebastian+dev@ramacher.at>\n"
"Language-Team: Greek (http://www.transifex.com/pwmt/girara/language/el/)\n"
......@@ -18,12 +18,6 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"