Commit 16310747 authored by Moritz Lipp's avatar Moritz Lipp

Merge branch 'develop'

parents 51fa849a 68aabc93
......@@ -47,7 +47,9 @@ version.h: version.h.in config.mk
${OBJECTS}: config.mk version.h
${DOBJECTS}: config.mk version.h
${PROJECT}: lib${PROJECT}.a lib${PROJECT}.so.${SOVERSION}
${PROJECT}: static shared
static: lib${PROJECT}.a
shared: lib${PROJECT}.so.${SOVERSION}
lib${PROJECT}.a: ${OBJECTS}
$(ECHO) AR rcs $@
......@@ -119,16 +121,22 @@ po:
update-po:
$(QUIET)${MAKE} -C po update-po
install: all install-headers
$(ECHO) installing library file
install-static: static
$(ECHO) installing static library
$(QUIET)mkdir -m 755 -p ${DESTDIR}${LIBDIR}
$(QUIET)install -m 644 lib${PROJECT}.a ${DESTDIR}${LIBDIR}
install-shared: shared
$(ECHO) installing shared library
$(QUIET)mkdir -m 755 -p ${DESTDIR}${LIBDIR}
$(QUIET)install -m 644 lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}
$(QUIET)ln -s lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}/lib${PROJECT}.so.${SOMAJOR} || \
echo "Failed to create lib${PROJECT}.so.${SOMAJOR}. Please check if it exists and points to the correct version of lib${PROJECT}.so."
$(QUIET)ln -s lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}/lib${PROJECT}.so || \
echo "Failed to create lib${PROJECT}.so. Please check if it exists and points to the correct version of lib${PROJECT}.so."
$(QUIET)${MAKE} -C po install
install: options po install-static install-shared install-headers
$(QUIET)${MAKE} -C po install
install-headers: version.h ${PROJECT}.pc
$(ECHO) installing pkgconfig file
......@@ -151,7 +159,8 @@ uninstall-headers:
$(QUIET)rm -f ${LIBDIR}/pkgconfig/${PROJECT}.pc
.PHONY: all options clean debug doc test dist install install-headers uninstall \
uninstall-headers ${PROJECT} ${PROJECT}-debug po update-po
uninstall-headers ${PROJECT} ${PROJECT}-debug po update-po \
static shared install-static install-shared
TDEPENDS = ${OBJECTS:.o=.o.dep}
DEPENDS = ${TDEPENDS:^=.depend/}
......
......@@ -158,7 +158,8 @@ girara_callback_view_key_press_event(GtkWidget* UNUSED(widget),
/* buffer could match a command */
if (!strncmp(session->buffer.command->str, shortcut->buffered_command, session->buffer.command->len)) {
/* command matches buffer exactly */
if (!strcmp(session->buffer.command->str, shortcut->buffered_command)) {
if (!strcmp(session->buffer.command->str, shortcut->buffered_command)
&& (session->modes.current_mode == shortcut->mode || shortcut->mode == 0)) {
g_string_free(session->buffer.command, TRUE);
g_string_free(session->global.buffer, TRUE);
session->buffer.command = NULL;
......
......@@ -625,37 +625,9 @@ girara_command_free(girara_command_t* command)
bool
girara_cmd_exec(girara_session_t* session, girara_list_t* argument_list)
{
char* cmd = NULL;
girara_setting_get(session, "exec-command", &cmd);
if (cmd == NULL || strlen(cmd) == 0) {
girara_debug("exec-command is empty, executing directly.");
g_free(cmd);
cmd = NULL;
if (session == NULL || argument_list == NULL) {
return true;
}
bool dont_append_first_space = cmd == NULL;
GString* command = g_string_new(cmd ? cmd : "");
g_free(cmd);
GIRARA_LIST_FOREACH(argument_list, char*, iter, value)
if (dont_append_first_space == false) {
g_string_append_c(command, ' ');
}
dont_append_first_space = false;
char* tmp = g_shell_quote(value);
g_string_append(command, tmp);
g_free(tmp);
GIRARA_LIST_FOREACH_END(argument_list, char*, iter, value);
GError* error = NULL;
girara_info("executing: %s", command->str);
gboolean ret = g_spawn_command_line_async(command->str, &error);
if (error != NULL) {
girara_warning("Failed to execute command: %s", error->message);
girara_notify(session, GIRARA_ERROR, _("Failed to execute command: %s"), error->message);
g_error_free(error);
}
g_string_free(command, TRUE);
return ret;
return girara_exec_with_argument_list(session, argument_list);
}
......@@ -511,6 +511,9 @@ girara_completion_row_create(girara_session_t* session, const char* command, con
gtk_label_set_use_markup(show_command, TRUE);
gtk_label_set_use_markup(show_description, TRUE);
gtk_label_set_ellipsize(show_command, PANGO_ELLIPSIZE_END);
gtk_label_set_ellipsize(show_description, PANGO_ELLIPSIZE_END);
gchar* c = g_markup_printf_escaped(FORMAT_COMMAND, command ? command : "");
gchar* d = g_markup_printf_escaped(FORMAT_DESCRIPTION, description ? description : "");
gtk_label_set_markup(show_command, c);
......
......@@ -237,14 +237,14 @@ girara_config_handle_free(girara_config_handle_t* handle)
g_slice_free(girara_config_handle_t, handle);
}
void
girara_config_parse(girara_session_t* session, const char* path)
static bool
config_parse(girara_session_t* session, const char* path)
{
/* open file */
FILE* file = girara_file_open(path, "r");
if (file == NULL) {
return;
return false;
}
/* read lines */
......@@ -264,7 +264,7 @@ girara_config_parse(girara_session_t* session, const char* path)
if (argument_list == NULL) {
free(line);
fclose(file);
return;
return false;
}
girara_list_set_free_function(argument_list, g_free);
......@@ -277,23 +277,51 @@ girara_config_parse(girara_session_t* session, const char* path)
girara_list_free(argument_list);
fclose(file);
free(line);
return;
return false;
}
/* search for config handle */
girara_config_handle_t* handle = NULL;
GIRARA_LIST_FOREACH(session->config.handles, girara_config_handle_t*, iter, tmp)
handle = tmp;
if (strcmp(handle->identifier, argv[0]) == 0) {
handle->handle(session, argument_list);
break;
/* include gets a special treatment */
if (strcmp(argv[0], "include") == 0) {
if (argc != 2) {
girara_warning("Could not process line %d in '%s': usage: include path.", line_number, path);
} else {
handle = NULL;
char* newpath = NULL;
if (g_path_is_absolute(argv[1]) == TRUE) {
newpath = g_strdup(argv[1]);
} else {
char* basename = g_path_get_dirname(path);
char* tmp = g_build_filename(basename, argv[1], NULL);
newpath = girara_fix_path(tmp);
g_free(tmp);
g_free(basename);
}
if (strcmp(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);
if (config_parse(session, newpath) == FALSE) {
girara_warning("Could not process line %d in '%s': failed to load '%s'.", line_number, path, newpath);
}
}
g_free(newpath);
}
} else {
/* search for config handle */
girara_config_handle_t* handle = NULL;
GIRARA_LIST_FOREACH(session->config.handles, girara_config_handle_t*, iter, tmp)
handle = tmp;
if (strcmp(handle->identifier, argv[0]) == 0) {
handle->handle(session, argument_list);
break;
} else {
handle = NULL;
}
GIRARA_LIST_FOREACH_END(session->config.handles, girara_config_handle_t*, iter, tmp);
if (handle == NULL) {
girara_warning("Could not process line %d in '%s': Unknown handle '%s'", line_number, path, argv[0]);
}
GIRARA_LIST_FOREACH_END(session->config.handles, girara_config_handle_t*, iter, tmp);
if (handle == NULL) {
girara_warning("Could not process line %d in '%s': Unknown handle '%s'", line_number, path, argv[0]);
}
line_number++;
......@@ -303,4 +331,12 @@ girara_config_parse(girara_session_t* session, const char* path)
}
fclose(file);
return true;
}
void
girara_config_parse(girara_session_t* session, const char* path)
{
config_parse(session, path);
}
......@@ -2,7 +2,7 @@
GIRARA_VERSION_MAJOR = 0
GIRARA_VERSION_MINOR = 1
GIRARA_VERSION_REV = 3
GIRARA_VERSION_REV = 4
VERSION = ${GIRARA_VERSION_MAJOR}.${GIRARA_VERSION_MINOR}.${GIRARA_VERSION_REV}
# Rules for the SOMAJOR and SOMINOR.
# Before a release check perform the following checks against the last release:
......
......@@ -3,10 +3,12 @@
include ../config.mk
include ../common.mk
PROJECTNV = girara
PROJECT = girara-gtk${GIRARA_GTK_VERSION}
CATALOGS = $(wildcard *.po)
MOS = $(patsubst %.po, %/LC_MESSAGES/${GETTEXT_PACKAGE}.mo, $(CATALOGS))
PROJECTNV = girara
PROJECT = girara-gtk${GIRARA_GTK_VERSION}
CATALOGS = $(wildcard *.po)
LINGUAS ?= $(patsubst %.po, %, $(CATALOGS))
ALINGUAS = $(shell find $(patsubst %, %.po, $(LINGUAS)) 2>/dev/null)
MOS = $(patsubst %, %/LC_MESSAGES/${GETTEXT_PACKAGE}.mo, $(patsubst %.po, %, $(ALINGUAS)))
all: ${MOS}
......
......@@ -8,10 +8,10 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-08 19:06+0200\n"
"PO-Revision-Date: 2012-04-03 15:11+0000\n"
"POT-Creation-Date: 2012-08-30 19:53+0200\n"
"PO-Revision-Date: 2012-08-05 14:14+0000\n"
"Last-Translator: Sebastian Ramacher <sebastian+dev@ramacher.at>\n"
"Language-Team: German (http://www.transifex.net/projects/p/girara/language/"
"Language-Team: German (http://www.transifex.com/projects/p/girara/language/"
"de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n"
......@@ -20,7 +20,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
#. unhandled command
#: ../callbacks.c:498
#: ../callbacks.c:500
#, c-format
msgid "Not a valid command: %s"
msgstr "Ungültige zugewiesene Funktion: %s"
......@@ -95,11 +95,6 @@ msgstr "Kein Wert für Option definiert: %s"
msgid "Unknown value for option: %s"
msgstr "Unbekannter Wert für Option: %s"
#: ../commands.c:655
#, c-format
msgid "Failed to execute command: %s"
msgstr "Konnte Befehl nicht ausführen: %s"
#. settings
#: ../config.c:124
msgid "Font"
......@@ -219,7 +214,7 @@ msgstr "Befehl, der von :exec ausgeführt werden soll"
#: ../config.c:154
msgid "Show or hide certain GUI elements"
msgstr ""
msgstr "Zeige oder verstecke bestimmte GUI Elemente"
#. commands
#: ../config.c:186
......@@ -241,3 +236,8 @@ msgstr "Setze eine Option"
#: ../config.c:190
msgid "Unmap a key sequence"
msgstr "Tastenfolge entbinden"
#: ../utils.c:515
#, c-format
msgid "Failed to execute command: %s"
msgstr "Konnte Befehl nicht ausführen: %s"
......@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-08 19:06+0200\n"
"POT-Creation-Date: 2012-08-30 19:53+0200\n"
"PO-Revision-Date: 2012-04-21 13:55+0000\n"
"Last-Translator: Sebastian Ramacher <sebastian+dev@ramacher.at>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -17,7 +17,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
#. unhandled command
#: ../callbacks.c:498
#: ../callbacks.c:500
#, c-format
msgid "Not a valid command: %s"
msgstr "Nevalida kurtnomo de funkcio: %s"
......@@ -91,11 +91,6 @@ msgstr "Neniu valoro difinita por opcio: %s"
msgid "Unknown value for option: %s"
msgstr "Nekonata valoro por opcio: %s"
#: ../commands.c:655
#, c-format
msgid "Failed to execute command: %s"
msgstr "Fiaskis plenumi komandon: %s"
#. settings
#: ../config.c:124
msgid "Font"
......@@ -237,3 +232,8 @@ msgstr "Agordu opcion"
#: ../config.c:190
msgid "Unmap a key sequence"
msgstr "Malmapu klavan sinsekvon"
#: ../utils.c:515
#, c-format
msgid "Failed to execute command: %s"
msgstr "Fiaskis plenumi komandon: %s"
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-08 19:06+0200\n"
"POT-Creation-Date: 2012-08-30 19:53+0200\n"
"PO-Revision-Date: 2012-04-03 15:11+0000\n"
"Last-Translator: Sebastian Ramacher <sebastian+dev@ramacher.at>\n"
"Language-Team: Spanish (Castilian) (http://www.transifex.net/projects/p/"
......@@ -19,7 +19,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
#. unhandled command
#: ../callbacks.c:498
#: ../callbacks.c:500
#, c-format
msgid "Not a valid command: %s"
msgstr "Función 'atajo' no valida: %s"
......@@ -93,11 +93,6 @@ msgstr "Valor indefinido para la opción: %s"
msgid "Unknown value for option: %s"
msgstr "Valor desconocido para la opción: %s"
#: ../commands.c:655
#, c-format
msgid "Failed to execute command: %s"
msgstr "No se pudo ejecutar el comando: %s"
#. settings
#: ../config.c:124
msgid "Font"
......@@ -239,3 +234,8 @@ msgstr "Asignar un valor a una opción"
#: ../config.c:190
msgid "Unmap a key sequence"
msgstr "Quitar el mapeo de una secuencia de teclas"
#: ../utils.c:515
#, c-format
msgid "Failed to execute command: %s"
msgstr "No se pudo ejecutar el comando: %s"
......@@ -7,18 +7,18 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: http://bt.pwmt.org/\n"
"POT-Creation-Date: 2012-05-08 19:06+0200\n"
"POT-Creation-Date: 2012-08-30 19:53+0200\n"
"PO-Revision-Date: 2012-05-10 08:44+0000\n"
"Last-Translator: Richard Gill <richard@houbathecat.fr>\n"
"Language-Team: French\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1)\n"
#. unhandled command
#: ../callbacks.c:498
#: ../callbacks.c:500
#, c-format
msgid "Not a valid command: %s"
msgstr "La fonction suivante n'est pas valide : %s"
......@@ -92,11 +92,6 @@ msgstr "Aucune valeur définie pour l'option : %s"
msgid "Unknown value for option: %s"
msgstr "Valeur inconnue pour l'option : %s"
#: ../commands.c:655
#, c-format
msgid "Failed to execute command: %s"
msgstr "Echec d'exécution de la commande : %s"
#. settings
#: ../config.c:124
msgid "Font"
......@@ -238,3 +233,8 @@ msgstr "Placer une option"
#: ../config.c:190
msgid "Unmap a key sequence"
msgstr "Désassocier une séquence clé"
#: ../utils.c:515
#, c-format
msgid "Failed to execute command: %s"
msgstr "Echec d'exécution de la commande : %s"
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-08 19:06+0200\n"
"POT-Creation-Date: 2012-08-30 19:53+0200\n"
"PO-Revision-Date: 2012-04-17 19:55+0000\n"
"Last-Translator: TheLemonMan <segnalazionidalweb@gmail.com>\n"
"Language-Team: Italian (http://www.transifex.net/projects/p/girara/language/"
......@@ -19,7 +19,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
#. unhandled command
#: ../callbacks.c:498
#: ../callbacks.c:500
#, c-format
msgid "Not a valid command: %s"
msgstr "Scorciatoia invalida:%s"
......@@ -93,11 +93,6 @@ msgstr "Nessun valore definito per l' opzione:%s"
msgid "Unknown value for option: %s"
msgstr "Valore sconosciuto per l' opzione:%s"
#: ../commands.c:655
#, c-format
msgid "Failed to execute command: %s"
msgstr "Impossibile eseguire:%s"
#. settings
#: ../config.c:124
msgid "Font"
......@@ -239,3 +234,8 @@ msgstr "Imposta un opzione"
#: ../config.c:190
msgid "Unmap a key sequence"
msgstr "Cancella mappatura di una sequenza di tasti"
#: ../utils.c:515
#, c-format
msgid "Failed to execute command: %s"
msgstr "Impossibile eseguire:%s"
......@@ -7,18 +7,20 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: http://bt.pwmt.org/\n"
"POT-Creation-Date: 2012-05-08 19:06+0200\n"
"POT-Creation-Date: 2012-08-30 19:53+0200\n"
"PO-Revision-Date: 2012-05-10 10:03+0000\n"
"Last-Translator: p <poczciwiec@gmail.com>\n"
"Language-Team: Polish (http://www.transifex.net/projects/p/girara/language/pl/)\n"
"Language-Team: Polish (http://www.transifex.net/projects/p/girara/language/"
"pl/)\n"
"Language: pl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: pl\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2)\n"
#. unhandled command
#: ../callbacks.c:498
#: ../callbacks.c:500
#, c-format
msgid "Not a valid command: %s"
msgstr "Nieprawidłowa funkcja skrótu: %s"
......@@ -92,11 +94,6 @@ msgstr "Niezdefiniowana wartość opcji: %s"
msgid "Unknown value for option: %s"
msgstr "Nieznana wartość opcji: %s"
#: ../commands.c:655
#, c-format
msgid "Failed to execute command: %s"
msgstr "Nieudane uruchomienie polecenia: %s"
#. settings
#: ../config.c:124
msgid "Font"
......@@ -238,3 +235,8 @@ msgstr "Ustaw opcję"
#: ../config.c:190
msgid "Unmap a key sequence"
msgstr "Usuń sekwencję klawiszy"
#: ../utils.c:515
#, c-format
msgid "Failed to execute command: %s"
msgstr "Nieudane uruchomienie polecenia: %s"
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: girara\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-08 19:06+0200\n"
"POT-Creation-Date: 2012-08-30 19:53+0200\n"
"PO-Revision-Date: 2012-04-03 19:27+0000\n"
"Last-Translator: femnad <femnad@gmail.com>\n"
"Language-Team: Turkish (http://www.transifex.net/projects/p/girara/language/"
......@@ -19,7 +19,7 @@ msgstr ""
"Plural-Forms: nplurals=1; plural=0\n"
#. unhandled command
#: ../callbacks.c:498
#: ../callbacks.c:500
#, c-format
msgid "Not a valid command: %s"
msgstr "Geçerli bir kısayol fonksiyonu değil: %s"
......@@ -95,11 +95,6 @@ msgstr "Seçenek için değer belirtilmedi: %s"
msgid "Unknown value for option: %s"
msgstr "Seçenek için bilinmeyen değer: %s"
#: ../commands.c:655
#, c-format
msgid "Failed to execute command: %s"
msgstr "Komut yürütülemedi: %s"
#. settings
#: ../config.c:124
msgid "Font"
......@@ -241,3 +236,8 @@ msgstr "Seçenekleri değiştir"
#: ../config.c:190
msgid "Unmap a key sequence"
msgstr "Tuş kombinasyonu eşleşimini kaldır"
#: ../utils.c:515
#, c-format
msgid "Failed to execute command: %s"
msgstr "Komut yürütülemedi: %s"
......@@ -52,10 +52,12 @@ girara_session_create()
/* init modes */
session->modes.identifiers = girara_list_new2(
(girara_free_function_t) girara_mode_string_free);
(girara_free_function_t) girara_mode_string_free);
girara_mode_t normal_mode = girara_mode_add(session, "normal");
girara_mode_t inputbar_mode = girara_mode_add(session, "inputbar");
session->modes.normal = normal_mode;
session->modes.current_mode = normal_mode;
session->modes.inputbar = inputbar_mode;
/* config handles */
session->config.handles = girara_list_new2(
......@@ -136,6 +138,12 @@ girara_session_init(girara_session_t* session, const char* sessionname)
gtk_window_set_has_resize_grip(GTK_WINDOW(session->gtk.window), FALSE);
#endif
#if (GTK_MAJOR_VERSION == 3)
gtk_widget_override_background_color(GTK_WIDGET(session->gtk.window), GTK_STATE_NORMAL, &(session->style.default_background));
#else
gtk_widget_modify_bg(GTK_WIDGET(session->gtk.window), GTK_STATE_NORMAL, &(session->style.default_background));
#endif
/* view */
session->signals.view_key_pressed = g_signal_connect(G_OBJECT(session->gtk.view), "key-press-event",
G_CALLBACK(girara_callback_view_key_press_event), session);
......@@ -166,6 +174,12 @@ girara_session_init(girara_session_t* session, const char* sessionname)
gtk_container_add(GTK_CONTAINER(session->gtk.view), session->gtk.viewport);
gtk_viewport_set_shadow_type(GTK_VIEWPORT(session->gtk.viewport), GTK_SHADOW_NONE);
#if (GTK_MAJOR_VERSION == 3)
gtk_widget_override_background_color(GTK_WIDGET(session->gtk.viewport), GTK_STATE_NORMAL, &(session->style.default_background));
#else
gtk_widget_modify_bg(GTK_WIDGET(session->gtk.viewport), GTK_STATE_NORMAL, &(session->style.default_background));
#endif
/* box */
gtk_box_set_spacing(session->gtk.box, 0);
gtk_container_add(GTK_CONTAINER(session->gtk.window), GTK_WIDGET(session->gtk.box));
......
......@@ -127,6 +127,7 @@ struct girara_session_s
girara_mode_t current_mode; /**< Current mode */
girara_list_t *identifiers; /**< List of modes with its string identifiers */
girara_mode_t normal; /**< The normal mode */
girara_mode_t inputbar; /**< The inputbar mode */
} modes;
struct
......
......@@ -37,7 +37,7 @@ options:
${XDG_HELPER}: ${XDG_HELPER_SOURCE} ../libgirara-gtk${GIRARA_GTK_VERSION}.a
@mkdir -p .depend
$(ECHO) CC $<
$(QUIET)${CC} -I.. ${CPPFLAGS} ${CFLAGS} -o $@ $< ../libgirara-gtk${GIRARA_GTK_VERSION}.a ${LIBS} -MMD -MF .depend/$@.dep
$(QUIET)${CC} -I.. ${CPPFLAGS} ${CFLAGS} -o $@ $< ../libgirara-gtk${GIRARA_GTK_VERSION}.a ${LDFLAGS} ${LIBS} -MMD -MF .depend/$@.dep
%-gtk${GIRARA_GTK_VERSION}.do: %.c
@mkdir -p .depend
......
......@@ -20,9 +20,12 @@
#include <errno.h>
#include <stdint.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "utils.h"
#include "datastructures.h"
#include "session.h"
#include "settings.h"
#define BLOCK_SIZE 64
......@@ -474,3 +477,46 @@ char* girara_escape_string(const char* value)
return g_string_free(str, FALSE);
}
bool
girara_exec_with_argument_list(girara_session_t* session, girara_list_t* argument_list)
{
if (session == NULL || argument_list == NULL) {
return false;
}
char* cmd = NULL;
girara_setting_get(session, "exec-command", &cmd);
if (cmd == NULL || strlen(cmd) == 0) {
girara_debug("exec-command is empty, executing directly.");
g_free(cmd);
cmd = NULL;
}
bool dont_append_first_space = cmd == NULL;
GString* command = g_string_new(cmd ? cmd : "");
g_free(cmd);
GIRARA_LIST_FOREACH(argument_list, char*, iter, value)
if (dont_append_first_space == false) {
g_string_append_c(command, ' ');
}
dont_append_first_space = false;
char* tmp = g_shell_quote(value);
g_string_append(command, tmp);
g_free(tmp);
GIRARA_LIST_FOREACH_END(argument_list, char*, iter, value);
GError* error = NULL;
girara_info("executing: %s", command->str);
gboolean ret = g_spawn_command_line_async(command->str, &error);
if (error != NULL) {
girara_warning("Failed to execute command: %s", error->message);
girara_notify(session, GIRARA_ERROR, _("Failed to execute command: %s"), error->message);
g_error_free(error);
}
g_string_free(command, TRUE);
return ret;
}
......@@ -142,4 +142,13 @@ void girara_set_debug_level(girara_debug_level_t level);
*/
char* girara_escape_string(const char* value);
/**
* Execute command from argument list
*
* @param session The used girara session
* @param argument_list The argument list
* @return true if no error occured
*/
bool girara_exec_with_argument_list(girara_session_t* session, girara_list_t* argument_list);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment