Commit fe7e9194 authored by Moritz Lipp's avatar Moritz Lipp

Merge branch 'release/0.2.7'

parents 6dc6fec2 8779f2eb
Copyright (c) 2010-2015 pwmt.org Copyright (c) 2010-2017 pwmt.org
This software is provided 'as-is', without any express or implied warranty. In 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 no event will the authors be held liable for any damages arising from the use of
......
...@@ -7,7 +7,7 @@ include common.mk ...@@ -7,7 +7,7 @@ include common.mk
PROJECTNV = girara PROJECTNV = girara
PROJECT = girara-gtk3 PROJECT = girara-gtk3
SOURCE = $(wildcard ${PROJECTNV}/*.c) SOURCE = $(sort $(wildcard ${PROJECTNV}/*.c))
CSOURCE = $(filter-out ${PROJECTNV}/css-definitions.c, ${SOURCE}) CSOURCE = $(filter-out ${PROJECTNV}/css-definitions.c, ${SOURCE})
OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${CSOURCE:.c=.o}) \ OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${CSOURCE:.c=.o}) \
...@@ -17,7 +17,7 @@ OBJECTS_DEBUG = $(addprefix ${BUILDDIR_DEBUG}/,${CSOURCE:.c=.o}) \ ...@@ -17,7 +17,7 @@ OBJECTS_DEBUG = $(addprefix ${BUILDDIR_DEBUG}/,${CSOURCE:.c=.o}) \
OBJECTS_GCOV = $(addprefix ${BUILDDIR_GCOV}/,${CSOURCE:.c=.o}) \ OBJECTS_GCOV = $(addprefix ${BUILDDIR_GCOV}/,${CSOURCE:.c=.o}) \
${BUILDDIR_GCOV}/${PROJECTNV}/css-definitions.o ${BUILDDIR_GCOV}/${PROJECTNV}/css-definitions.o
HEADERS = $(filter-out ${PROJECTNV}/internal.h, $(wildcard ${PROJECTNV}/*.h)) HEADERS = $(filter-out ${PROJECTNV}/internal.h, $(sort $(wildcard ${PROJECTNV}/*.h)))
ifneq (${WITH_LIBNOTIFY},0) ifneq (${WITH_LIBNOTIFY},0)
CPPFLAGS += -DWITH_LIBNOTIFY CPPFLAGS += -DWITH_LIBNOTIFY
......
...@@ -9,10 +9,11 @@ enhance the user interface that is used by zathura and jumanji. ...@@ -9,10 +9,11 @@ enhance the user interface that is used by zathura and jumanji.
Requirements Requirements
------------ ------------
glib (>= 2.28) glib (>= 2.36)
gtk3 (>= 3.4) gtk3 (>= 3.4)
intltool intltool
libnotify (optional, for notification support) libnotify (optional, for notification support)
jscon-c (optional, for configuration dumping support)
Please note that you need to have a working pkg-config installation Please note that you need to have a working pkg-config installation
and that the Makefile is only compatible with GNU make. and that the Makefile is only compatible with GNU make.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
GIRARA_VERSION_MAJOR = 0 GIRARA_VERSION_MAJOR = 0
GIRARA_VERSION_MINOR = 2 GIRARA_VERSION_MINOR = 2
GIRARA_VERSION_REV = 6 GIRARA_VERSION_REV = 7
VERSION = ${GIRARA_VERSION_MAJOR}.${GIRARA_VERSION_MINOR}.${GIRARA_VERSION_REV} VERSION = ${GIRARA_VERSION_MAJOR}.${GIRARA_VERSION_MINOR}.${GIRARA_VERSION_REV}
# Rules for the SOMAJOR and SOMINOR. # Rules for the SOMAJOR and SOMINOR.
...@@ -50,7 +50,7 @@ GTK_MIN_VERSION = 3.4 ...@@ -50,7 +50,7 @@ GTK_MIN_VERSION = 3.4
GTK_PKG_CONFIG_NAME = gtk+-3.0 GTK_PKG_CONFIG_NAME = gtk+-3.0
# glib # glib
GLIB_VERSION_CHECK ?= 1 GLIB_VERSION_CHECK ?= 1
GLIB_MIN_VERSION = 2.28 GLIB_MIN_VERSION = 2.36
GLIB_PKG_CONFIG_NAME = glib-2.0 GLIB_PKG_CONFIG_NAME = glib-2.0
# libs # libs
......
#@session@ * {
color: @default-fg@;
background-color: @default-bg@;
background-image: none;
font-family: @font-family@;
font-size: @font-size@;
font-weight: @font-weight@;
}
/* Scrollbar */
#@session@ scrolledwindow scrollbar { #@session@ scrolledwindow scrollbar {
background-color: @scrollbar-bg@; background-color: @scrollbar-bg@;
} }
#@session@ scrolledwindow scrollbar > slider { #@session@ scrolledwindow scrollbar > slider {
background-color: @scrollbar-fg@; background-color: @scrollbar-fg@;
} }
#@session@ * {
color: @default-fg@;
background-color: @default-bg@;
background-image: none;
font: @font@;
}
/* Inputbar */ /* Inputbar */
#@session@ entry.inputbar { #@session@ entry.inputbar {
...@@ -111,4 +116,5 @@ ...@@ -111,4 +116,5 @@
#@session@ scrolledwindow overshoot.right, #@session@ scrolledwindow overshoot.right,
#@session@ scrolledwindow overshoot.right:backdrop { #@session@ scrolledwindow overshoot.right:backdrop {
background-color: transparent; background-color: transparent;
background-image: none;
} }
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
#include "session.h" #include "session.h"
#include "shortcuts.h" #include "shortcuts.h"
#include "input-history.h" #include "input-history.h"
#include "internal.h"
#include "utils.h"
#include <string.h> #include <string.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include "internal.h"
static const guint ALL_ACCELS_MASK = GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK; static const guint ALL_ACCELS_MASK = GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK;
static const guint MOUSE_MASK = GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK | static const guint MOUSE_MASK = GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK |
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK; GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK;
...@@ -72,7 +73,7 @@ clean_mask(guint hardware_keycode, GdkModifierType state, gint group, guint* cle ...@@ -72,7 +73,7 @@ clean_mask(guint hardware_keycode, GdkModifierType state, gint group, guint* cle
} }
/* callback implementation */ /* callback implementation */
bool gboolean
girara_callback_view_key_press_event(GtkWidget* UNUSED(widget), girara_callback_view_key_press_event(GtkWidget* UNUSED(widget),
GdkEventKey* event, girara_session_t* session) GdkEventKey* event, girara_session_t* session)
{ {
...@@ -201,7 +202,7 @@ girara_callback_view_key_press_event(GtkWidget* UNUSED(widget), ...@@ -201,7 +202,7 @@ girara_callback_view_key_press_event(GtkWidget* UNUSED(widget),
return FALSE; return FALSE;
} }
bool gboolean
girara_callback_view_button_press_event(GtkWidget* UNUSED(widget), girara_callback_view_button_press_event(GtkWidget* UNUSED(widget),
GdkEventButton* button, girara_session_t* session) GdkEventButton* button, girara_session_t* session)
{ {
...@@ -248,7 +249,7 @@ girara_callback_view_button_press_event(GtkWidget* UNUSED(widget), ...@@ -248,7 +249,7 @@ girara_callback_view_button_press_event(GtkWidget* UNUSED(widget),
return false; return false;
} }
bool gboolean
girara_callback_view_button_release_event(GtkWidget* UNUSED(widget), GdkEventButton* button, girara_session_t* session) girara_callback_view_button_release_event(GtkWidget* UNUSED(widget), GdkEventButton* button, girara_session_t* session)
{ {
g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session != NULL, false);
...@@ -279,7 +280,7 @@ girara_callback_view_button_release_event(GtkWidget* UNUSED(widget), GdkEventBut ...@@ -279,7 +280,7 @@ girara_callback_view_button_release_event(GtkWidget* UNUSED(widget), GdkEventBut
return false; return false;
} }
bool gboolean
girara_callback_view_button_motion_notify_event(GtkWidget* UNUSED(widget), GdkEventMotion* button, girara_session_t* session) girara_callback_view_button_motion_notify_event(GtkWidget* UNUSED(widget), GdkEventMotion* button, girara_session_t* session)
{ {
g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session != NULL, false);
...@@ -310,7 +311,7 @@ girara_callback_view_button_motion_notify_event(GtkWidget* UNUSED(widget), GdkEv ...@@ -310,7 +311,7 @@ girara_callback_view_button_motion_notify_event(GtkWidget* UNUSED(widget), GdkEv
return false; return false;
} }
bool gboolean
girara_callback_view_scroll_event(GtkWidget* UNUSED(widget), GdkEventScroll* scroll, girara_session_t* session) girara_callback_view_scroll_event(GtkWidget* UNUSED(widget), GdkEventScroll* scroll, girara_session_t* session)
{ {
g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session != NULL, false);
...@@ -362,7 +363,7 @@ girara_callback_view_scroll_event(GtkWidget* UNUSED(widget), GdkEventScroll* scr ...@@ -362,7 +363,7 @@ girara_callback_view_scroll_event(GtkWidget* UNUSED(widget), GdkEventScroll* scr
return false; return false;
} }
bool gboolean
girara_callback_inputbar_activate(GtkEntry* entry, girara_session_t* session) girara_callback_inputbar_activate(GtkEntry* entry, girara_session_t* session)
{ {
g_return_val_if_fail(session != NULL, FALSE); g_return_val_if_fail(session != NULL, FALSE);
...@@ -505,13 +506,13 @@ girara_callback_inputbar_activate(GtkEntry* entry, girara_session_t* session) ...@@ -505,13 +506,13 @@ girara_callback_inputbar_activate(GtkEntry* entry, girara_session_t* session)
return false; return false;
} }
bool gboolean
girara_callback_inputbar_key_press_event(GtkWidget* entry, GdkEventKey* event, girara_session_t* session) girara_callback_inputbar_key_press_event(GtkWidget* entry, GdkEventKey* event, girara_session_t* session)
{ {
g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session != NULL, false);
/* a custom handler has been installed (e.g. by girara_dialog) */ /* a custom handler has been installed (e.g. by girara_dialog) */
bool custom_ret = false; gboolean custom_ret = false;
if (session->signals.inputbar_custom_key_press_event != NULL) { if (session->signals.inputbar_custom_key_press_event != NULL) {
custom_ret = session->signals.inputbar_custom_key_press_event(entry, event, session->signals.inputbar_custom_data); custom_ret = session->signals.inputbar_custom_key_press_event(entry, event, session->signals.inputbar_custom_data);
if (custom_ret == true) { if (custom_ret == true) {
...@@ -526,16 +527,18 @@ girara_callback_inputbar_key_press_event(GtkWidget* entry, GdkEventKey* event, g ...@@ -526,16 +527,18 @@ girara_callback_inputbar_key_press_event(GtkWidget* entry, GdkEventKey* event, g
guint keyval = 0; guint keyval = 0;
guint clean = 0; guint clean = 0;
if (clean_mask(event->hardware_keycode, event->state, event->group, &clean, &keyval) == false) { if (clean_mask(event->hardware_keycode, event->state, event->group, &clean, &keyval) == false) {
girara_debug("clean_mask returned false.");
return false; return false;
} }
girara_debug("Proccessing key %u with mask %x.", keyval, clean);
if (custom_ret == false) { if (custom_ret == false) {
GIRARA_LIST_FOREACH(session->bindings.inputbar_shortcuts, girara_inputbar_shortcut_t*, iter, inputbar_shortcut) GIRARA_LIST_FOREACH(session->bindings.inputbar_shortcuts, girara_inputbar_shortcut_t*, iter, inputbar_shortcut)
if (inputbar_shortcut->key == keyval if (inputbar_shortcut->key == keyval
&& inputbar_shortcut->mask == clean) && inputbar_shortcut->mask == clean)
{ {
girara_debug("found shortcut for key %u and mask %x", keyval, clean);
if (inputbar_shortcut->function != NULL) { if (inputbar_shortcut->function != NULL) {
inputbar_shortcut->function(session, &(inputbar_shortcut->argument), NULL, 0); inputbar_shortcut->function(session, &(inputbar_shortcut->argument), NULL, 0);
} }
...@@ -556,7 +559,7 @@ girara_callback_inputbar_key_press_event(GtkWidget* entry, GdkEventKey* event, g ...@@ -556,7 +559,7 @@ girara_callback_inputbar_key_press_event(GtkWidget* entry, GdkEventKey* event, g
return custom_ret; return custom_ret;
} }
bool gboolean
girara_callback_inputbar_changed_event(GtkEditable* entry, girara_session_t* session) girara_callback_inputbar_changed_event(GtkEditable* entry, girara_session_t* session)
{ {
g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session != NULL, false);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* @param data Custom data * @param data Custom data
* @return true if no error occurred * @return true if no error occurred
*/ */
typedef bool (*girara_callback_inputbar_key_press_event_t)(GtkWidget* widget, typedef gboolean (*girara_callback_inputbar_key_press_event_t)(GtkWidget* widget,
GdkEventKey* event, void* data); GdkEventKey* event, void* data);
/** /**
...@@ -24,7 +24,7 @@ typedef bool (*girara_callback_inputbar_key_press_event_t)(GtkWidget* widget, ...@@ -24,7 +24,7 @@ typedef bool (*girara_callback_inputbar_key_press_event_t)(GtkWidget* widget,
* @param data Custom data * @param data Custom data
* @return true if no error occurred * @return true if no error occurred
*/ */
typedef bool (*girara_callback_inputbar_activate_t)(GtkEntry* entry, typedef gboolean (*girara_callback_inputbar_activate_t)(GtkEntry* entry,
void* data); void* data);
/** /**
...@@ -36,7 +36,7 @@ typedef bool (*girara_callback_inputbar_activate_t)(GtkEntry* entry, ...@@ -36,7 +36,7 @@ typedef bool (*girara_callback_inputbar_activate_t)(GtkEntry* entry,
* @return TRUE No error occurred * @return TRUE No error occurred
* @return FALSE An error occurred * @return FALSE An error occurred
*/ */
bool girara_callback_view_key_press_event(GtkWidget* widget, GdkEventKey* event, gboolean girara_callback_view_key_press_event(GtkWidget* widget, GdkEventKey* event,
girara_session_t* session); girara_session_t* session);
/** /**
...@@ -48,7 +48,7 @@ bool girara_callback_view_key_press_event(GtkWidget* widget, GdkEventKey* event, ...@@ -48,7 +48,7 @@ bool girara_callback_view_key_press_event(GtkWidget* widget, GdkEventKey* event,
* @return true to stop other handlers from being invoked for the event. * @return true to stop other handlers from being invoked for the event.
* @return false to propagate the event further. * @return false to propagate the event further.
*/ */
bool girara_callback_view_button_press_event(GtkWidget* widget, gboolean girara_callback_view_button_press_event(GtkWidget* widget,
GdkEventButton* button, girara_session_t* session); GdkEventButton* button, girara_session_t* session);
/** /**
...@@ -60,7 +60,7 @@ bool girara_callback_view_button_press_event(GtkWidget* widget, ...@@ -60,7 +60,7 @@ bool girara_callback_view_button_press_event(GtkWidget* widget,
* @return true to stop other handlers from being invoked for the event. * @return true to stop other handlers from being invoked for the event.
* @return false to propagate the event further. * @return false to propagate the event further.
*/ */
bool girara_callback_view_button_release_event(GtkWidget* widget, gboolean girara_callback_view_button_release_event(GtkWidget* widget,
GdkEventButton* button, girara_session_t* session); GdkEventButton* button, girara_session_t* session);
/** /**
...@@ -72,7 +72,7 @@ bool girara_callback_view_button_release_event(GtkWidget* widget, ...@@ -72,7 +72,7 @@ bool girara_callback_view_button_release_event(GtkWidget* widget,
* @return true to stop other handlers from being invoked for the event. * @return true to stop other handlers from being invoked for the event.
* @return false to propagate the event further. * @return false to propagate the event further.
*/ */
bool girara_callback_view_button_motion_notify_event(GtkWidget* widget, gboolean girara_callback_view_button_motion_notify_event(GtkWidget* widget,
GdkEventMotion* button, girara_session_t* session); GdkEventMotion* button, girara_session_t* session);
/** /**
...@@ -84,7 +84,7 @@ bool girara_callback_view_button_motion_notify_event(GtkWidget* widget, ...@@ -84,7 +84,7 @@ bool girara_callback_view_button_motion_notify_event(GtkWidget* widget,
* @return true to stop other handlers from being invoked for the event. * @return true to stop other handlers from being invoked for the event.
* @return false to propagate the event further. * @return false to propagate the event further.
*/ */
bool girara_callback_view_scroll_event(GtkWidget* widget, GdkEventScroll* event, gboolean girara_callback_view_scroll_event(GtkWidget* widget, GdkEventScroll* event,
girara_session_t* session); girara_session_t* session);
/** /**
...@@ -95,7 +95,7 @@ bool girara_callback_view_scroll_event(GtkWidget* widget, GdkEventScroll* event, ...@@ -95,7 +95,7 @@ bool girara_callback_view_scroll_event(GtkWidget* widget, GdkEventScroll* event,
* @return TRUE No error occurred * @return TRUE No error occurred
* @return FALSE An error occurred * @return FALSE An error occurred
*/ */
bool girara_callback_inputbar_activate(GtkEntry* entry, gboolean girara_callback_inputbar_activate(GtkEntry* entry,
girara_session_t* session); girara_session_t* session);
/** /**
...@@ -107,7 +107,7 @@ bool girara_callback_inputbar_activate(GtkEntry* entry, ...@@ -107,7 +107,7 @@ bool girara_callback_inputbar_activate(GtkEntry* entry,
* @return TRUE No error occurred * @return TRUE No error occurred
* @return FALSE An error occurred * @return FALSE An error occurred
*/ */
bool girara_callback_inputbar_key_press_event(GtkWidget* widget, gboolean girara_callback_inputbar_key_press_event(GtkWidget* widget,
GdkEventKey* event, girara_session_t* session); GdkEventKey* event, girara_session_t* session);
/** /**
...@@ -118,7 +118,7 @@ bool girara_callback_inputbar_key_press_event(GtkWidget* widget, ...@@ -118,7 +118,7 @@ bool girara_callback_inputbar_key_press_event(GtkWidget* widget,
* @return TRUE No error occurred * @return TRUE No error occurred
* @return FALSE An error occurred * @return FALSE An error occurred
*/ */
bool girara_callback_inputbar_changed_event(GtkEditable* widget, gboolean girara_callback_inputbar_changed_event(GtkEditable* widget,
girara_session_t* session); girara_session_t* session);
#endif #endif
...@@ -349,6 +349,11 @@ girara_isc_completion(girara_session_t* session, girara_argument_t* argument, gi ...@@ -349,6 +349,11 @@ girara_isc_completion(girara_session_t* session, girara_argument_t* argument, gi
} }
GIRARA_LIST_FOREACH(result->groups, girara_completion_group_t*, iter, group) GIRARA_LIST_FOREACH(result->groups, girara_completion_group_t*, iter, group)
if (group->elements == NULL || girara_list_size(group->elements) == 0) {
girara_list_iterator_next(iter);
continue;
}
/* create group entry */ /* create group entry */
if (group->value != NULL) { if (group->value != NULL) {
girara_internal_completion_entry_t* entry = g_slice_new(girara_internal_completion_entry_t); girara_internal_completion_entry_t* entry = g_slice_new(girara_internal_completion_entry_t);
......
...@@ -50,8 +50,7 @@ cb_font(girara_session_t* session, const char* UNUSED(name), ...@@ -50,8 +50,7 @@ cb_font(girara_session_t* session, const char* UNUSED(name),
{ {
g_return_if_fail(session != NULL && value != NULL); g_return_if_fail(session != NULL && value != NULL);
girara_template_set_variable_value(session->private_data->csstemplate, "font", css_template_fill_font(session->private_data->csstemplate, value);
value);
} }
static void static void
......
/* See LICENSE file for license and copyright information */
#include "utils.h"
#include <stdarg.h>
#include <stdio.h>
static girara_debug_level_t debug_level = GIRARA_DEBUG;
void
_girara_debug(const char* function, int line, girara_debug_level_t level, const char* format, ...)
{
if (level < debug_level) {
return;
}
switch (level)
{
case GIRARA_WARNING:
fprintf(stderr, "warning: ");
break;
case GIRARA_ERROR:
fprintf(stderr, "error: ");
break;
case GIRARA_INFO:
fprintf(stderr, "info: ");
break;
case GIRARA_DEBUG:
fprintf(stderr, "debug: (%s:%d) ", function, line);
break;
default:
return;
}
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
fprintf(stderr, "\n");
}
girara_debug_level_t
girara_get_debug_level()
{
return debug_level;
}
void
girara_set_debug_level(girara_debug_level_t level)
{
debug_level = level;
}
...@@ -148,6 +148,8 @@ HIDDEN bool girara_cmd_dump_config(girara_session_t* session, ...@@ -148,6 +148,8 @@ HIDDEN bool girara_cmd_dump_config(girara_session_t* session,
HIDDEN bool girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument, HIDDEN bool girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t); girara_event_t* event, unsigned int t);
HIDDEN void css_template_fill_font(GiraraTemplate* csstemplate, const char* font);
/** /**
* Structure of a command * Structure of a command
*/ */
......
/* See LICENSE file for license and copyright information */
#include "log.h"
#include <stdarg.h>
#include <stdio.h>
static girara_log_level_t log_level = GIRARA_DEBUG;
static const char* NAMES[] = {
[GIRARA_DEBUG] = "debug",
[GIRARA_INFO] = "info",
[GIRARA_WARNING] = "warning",
[GIRARA_ERROR] = "error"
};
void
girara_vlog(const char* location, const char* function, girara_log_level_t level, const char* format, va_list ap)
{
if (level < log_level || level < GIRARA_DEBUG || level > GIRARA_ERROR ) {
return;
}
fprintf(stderr, "%s: ", NAMES[level]);
if (level == GIRARA_DEBUG) {
if (location != NULL) {
fprintf(stderr, "%s: ", location);
}
if (function != NULL) {
fprintf(stderr, "%s(): ", function);
}
}
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
}
void
girara_log(const char* location, const char* function, girara_log_level_t level, const char* format, ...)
{
va_list ap;
va_start(ap, format);
girara_vlog(location, function, level, format, ap);
va_end(ap);
}
girara_log_level_t
girara_get_log_level(void)
{
return log_level;
}
void
girara_set_log_level(girara_log_level_t level)
{
log_level = level;
}
/* old compat function, remove once we bump the SONAME */
void
_girara_debug(const char* function, int line, girara_log_level_t level, const char* format, ...)
{
char buffer[G_ASCII_DTOSTR_BUF_SIZE] = { '\0' };
g_ascii_dtostr(buffer, G_ASCII_DTOSTR_BUF_SIZE, line);
va_list ap;
va_start(ap, format);
girara_vlog(function, buffer, level, format, ap);
va_end(ap);
}
girara_log_level_t
girara_get_debug_level()
{
return girara_get_log_level();
}
void
girara_set_debug_level(girara_log_level_t level)
{
girara_set_log_level(level);
}
/* See LICENSE file for license and copyright information */
#ifndef GIRARA_LOG_H
#define GIRARA_LOG_H
#include <glib.h>
#include <stdarg.h>
#include "types.h"
#include "macros.h"
#define GIRARA_INDIRECT(x) x
/**
* Prints a debug message. The arguments are passed to @ref _girara_log as
* last argument.
*/
#define girara_debug(...) girara_log(G_STRLOC, __func__, GIRARA_DEBUG, __VA_ARGS__)
/**
* Prints an info message. The arguments are passed to @ref _girara_log as
* last argument.
*/
#define girara_info(...) girara_log(G_STRLOC, __func__, GIRARA_INFO, __VA_ARGS__)
/**
* Prints a warning message. The arguments are passed to @ref _girara_log as
* last argument.
*/
#define girara_warning(...) girara_log(G_STRLOC, __func__, GIRARA_WARNING, __VA_ARGS__)
/**
* Prints an error message. The arguments are passed to @ref _girara_log as
* last argument.
*/
#define girara_error(...) girara_log(G_STRLOC, __func__, GIRARA_ERROR, __VA_ARGS__)
/**
* Print a message.
*
* @param location location of the call
* @param function calling function
* @param level The log level of the message.
* @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);
/**
* Print a message.
*
* @param location location of the call
* @param function calling function
* @param level The log level of the message.
* @param format printf like format string
* @param ap varag list
*/
void girara_vlog(const char* location, const char* function, girara_log_level_t level,
const char* format, va_list ap);
/**
* Get the log level.
* @returns The log level.
*/
girara_log_level_t girara_get_log_level(void);
/**
* 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);
#endif
...@@ -44,7 +44,6 @@ init_template_engine(GiraraTemplate* csstemplate) ...@@ -44,7 +44,6 @@ init_template_engine(GiraraTemplate* csstemplate)
{ {
static const char* variable_names[] = { static const char* variable_names[] = {
"session", "session",
"font",
"default-fg", "default-fg",
"default-bg", "default-bg",
"inputbar-fg", "inputbar-fg",
...@@ -78,6 +77,88 @@ init_template_engine(GiraraTemplate* csstemplate) ...@@ -78,6 +77,88 @@ init_template_engine(GiraraTemplate* csstemplate)
for (size_t idx = 0; idx < LENGTH(variable_names); ++idx) { for (size_t idx = 0; idx < LENGTH(variable_names); ++idx) {
girara_template_add_variable(csstemplate, variable_names[idx]); girara_template_add_variable(csstemplate, variable_names[idx]);
} }
if (gtk_check_version(3, 20, 0) == NULL) {
girara_template_add_variable(csstemplate, "font-family");
girara_template_add_variable(csstemplate, "font-size");
girara_template_add_variable(csstemplate, "font-weight");
} else {
girara_template_add_variable(csstemplate, "font");
}
}
void
css_template_fill_font(GiraraTemplate* csstemplate, const char* font)
{
if (gtk_check_version(3, 20, 0) != NULL) {
girara_template_set_variable_value(csstemplate, "font", font);
return;
}
PangoFontDescription* descr = pango_font_description_from_string(font);
if (descr == NULL) {
return;
}
girara_template_set_variable_value(csstemplate, "font-family",
pango_font_description_get_family(descr));
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:
girara_template_set_variable_value(csstemplate, "font-weight", "thin");
break;
case PANGO_WEIGHT_ULTRALIGHT:
girara_template_set_variable_value(csstemplate, "font-weight", "ultralight");
break;
case PANGO_WEIGHT_SEMILIGHT:
girara_template_set_variable_value(csstemplate, "font-weight", "light");
break;
case PANGO_WEIGHT_LIGHT:
girara_template_set_variable_value(csstemplate, "font-weight", "light");
break;
case PANGO_WEIGHT_BOOK:
girara_template_set_variable_value(csstemplate, "font-weight", "book");
break;