Merge pull request #292 from johnchen902/cleandebt
Fix `#include`s and use only glib for memory management
This commit is contained in:
commit
21b4194031
33
src/dbus.c
33
src/dbus.c
@ -1,15 +1,15 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <gio/gio.h>
|
|
||||||
#include "dunst.h"
|
|
||||||
#include "dbus.h"
|
#include "dbus.h"
|
||||||
|
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "dunst.h"
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
GDBusConnection *dbus_conn;
|
GDBusConnection *dbus_conn;
|
||||||
|
|
||||||
@ -131,10 +131,7 @@ static void on_notify(GDBusConnection * connection,
|
|||||||
gchar *icon = NULL;
|
gchar *icon = NULL;
|
||||||
gchar *summary = NULL;
|
gchar *summary = NULL;
|
||||||
gchar *body = NULL;
|
gchar *body = NULL;
|
||||||
Actions *actions = malloc(sizeof(Actions));
|
Actions *actions = g_malloc0(sizeof(Actions));
|
||||||
if(actions == NULL) {
|
|
||||||
die("Unable to allocate memory", EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
gint timeout = -1;
|
gint timeout = -1;
|
||||||
|
|
||||||
/* hints */
|
/* hints */
|
||||||
@ -145,10 +142,6 @@ static void on_notify(GDBusConnection * connection,
|
|||||||
gchar *category = NULL;
|
gchar *category = NULL;
|
||||||
RawImage *raw_icon = NULL;
|
RawImage *raw_icon = NULL;
|
||||||
|
|
||||||
actions->actions = NULL;
|
|
||||||
actions->count = 0;
|
|
||||||
actions->dmenu_str = NULL;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
GVariantIter *iter = g_variant_iter_new(parameters);
|
GVariantIter *iter = g_variant_iter_new(parameters);
|
||||||
GVariant *content;
|
GVariant *content;
|
||||||
@ -308,13 +301,13 @@ static void on_notify(GDBusConnection * connection,
|
|||||||
n->progress = (progress < 0 || progress > 100) ? 0 : progress + 1;
|
n->progress = (progress < 0 || progress > 100) ? 0 : progress + 1;
|
||||||
n->urgency = urgency;
|
n->urgency = urgency;
|
||||||
n->category = category;
|
n->category = category;
|
||||||
n->dbus_client = strdup(sender);
|
n->dbus_client = g_strdup(sender);
|
||||||
if (actions->count > 0) {
|
if (actions->count > 0) {
|
||||||
n->actions = actions;
|
n->actions = actions;
|
||||||
} else {
|
} else {
|
||||||
n->actions = NULL;
|
n->actions = NULL;
|
||||||
g_strfreev(actions->actions);
|
g_strfreev(actions->actions);
|
||||||
free(actions);
|
g_free(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ColLast; i++) {
|
for (int i = 0; i < ColLast; i++) {
|
||||||
@ -433,7 +426,7 @@ static void on_name_lost(GDBusConnection * connection,
|
|||||||
|
|
||||||
static RawImage * get_raw_image_from_data_hint(GVariant *icon_data)
|
static RawImage * get_raw_image_from_data_hint(GVariant *icon_data)
|
||||||
{
|
{
|
||||||
RawImage *image = malloc(sizeof(RawImage));
|
RawImage *image = g_malloc(sizeof(RawImage));
|
||||||
GVariant *data_variant;
|
GVariant *data_variant;
|
||||||
gsize expected_len;
|
gsize expected_len;
|
||||||
|
|
||||||
@ -455,7 +448,7 @@ static RawImage * get_raw_image_from_data_hint(GVariant *icon_data)
|
|||||||
" but got a " "length of %" G_GSIZE_FORMAT,
|
" but got a " "length of %" G_GSIZE_FORMAT,
|
||||||
expected_len,
|
expected_len,
|
||||||
g_variant_get_size (data_variant));
|
g_variant_get_size (data_variant));
|
||||||
free(image);
|
g_free(image);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
#ifndef DUNST_DBUS_H
|
#ifndef DUNST_DBUS_H
|
||||||
#define DUNST_DBUS_H
|
#define DUNST_DBUS_H
|
||||||
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
|
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
|
|
||||||
int initdbus(void);
|
int initdbus(void);
|
||||||
|
50
src/dunst.c
50
src/dunst.c
@ -3,41 +3,23 @@
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#define XLIB_ILLEGAL_ACCESS
|
#define XLIB_ILLEGAL_ACCESS
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <fnmatch.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <glib-unix.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/XKBlib.h>
|
|
||||||
#include <X11/Xatom.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#ifdef XINERAMA
|
|
||||||
#include <X11/extensions/Xinerama.h>
|
|
||||||
#endif
|
|
||||||
#include <X11/extensions/scrnsaver.h>
|
|
||||||
|
|
||||||
#include "dunst.h"
|
#include "dunst.h"
|
||||||
#include "x.h"
|
|
||||||
#include "dbus.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "rules.h"
|
|
||||||
#include "notification.h"
|
|
||||||
#include "menu.h"
|
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <glib-unix.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "dbus.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "notification.h"
|
||||||
#include "option_parser.h"
|
#include "option_parser.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "x.h"
|
||||||
|
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
|
||||||
@ -345,9 +327,9 @@ int dunst_main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (settings.startup_notification) {
|
if (settings.startup_notification) {
|
||||||
notification *n = notification_create();
|
notification *n = notification_create();
|
||||||
n->appname = strdup("dunst");
|
n->appname = g_strdup("dunst");
|
||||||
n->summary = strdup("startup");
|
n->summary = g_strdup("startup");
|
||||||
n->body = strdup("dunst is up and running");
|
n->body = g_strdup("dunst is up and running");
|
||||||
n->progress = 0;
|
n->progress = 0;
|
||||||
n->timeout = 10;
|
n->timeout = 10;
|
||||||
n->markup = MARKUP_NO;
|
n->markup = MARKUP_NO;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "x.h"
|
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
|
|
||||||
#define ERR(msg) printf("%s : %d\n", (msg), __LINE__)
|
#define ERR(msg) printf("%s : %d\n", (msg), __LINE__)
|
||||||
|
45
src/menu.c
45
src/menu.c
@ -1,20 +1,23 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <stdlib.h>
|
#include "menu.h"
|
||||||
#include <stdbool.h>
|
|
||||||
#include <regex.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <glib.h>
|
||||||
#include <string.h>
|
#include <regex.h>
|
||||||
#include <unistd.h>
|
#include <stdbool.h>
|
||||||
#include <errno.h>
|
#include <stdio.h>
|
||||||
#include <sys/wait.h>
|
#include <stdlib.h>
|
||||||
#include <glib.h>
|
#include <string.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "dunst.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "dbus.h"
|
#include "dbus.h"
|
||||||
|
#include "dunst.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "notification.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
static bool is_initialized = false;
|
static bool is_initialized = false;
|
||||||
static regex_t cregex;
|
static regex_t cregex;
|
||||||
@ -76,11 +79,11 @@ char *extract_urls(const char *to_match)
|
|||||||
start = m.rm_so + (p - to_match);
|
start = m.rm_so + (p - to_match);
|
||||||
finish = m.rm_eo + (p - to_match);
|
finish = m.rm_eo + (p - to_match);
|
||||||
|
|
||||||
char *match = strndup(to_match + start, finish - start);
|
char *match = g_strndup(to_match + start, finish - start);
|
||||||
|
|
||||||
urls = string_append(urls, match, "\n");
|
urls = string_append(urls, match, "\n");
|
||||||
|
|
||||||
free(match);
|
g_free(match);
|
||||||
|
|
||||||
p += m.rm_eo;
|
p += m.rm_eo;
|
||||||
}
|
}
|
||||||
@ -159,7 +162,7 @@ void invoke_action(const char *action)
|
|||||||
*/
|
*/
|
||||||
void dispatch_menu_result(const char *input)
|
void dispatch_menu_result(const char *input)
|
||||||
{
|
{
|
||||||
char *in = strdup(input);
|
char *in = g_strdup(input);
|
||||||
g_strstrip(in);
|
g_strstrip(in);
|
||||||
switch (in[0]) {
|
switch (in[0]) {
|
||||||
case '#':
|
case '#':
|
||||||
@ -174,12 +177,12 @@ void dispatch_menu_result(const char *input)
|
|||||||
char *maybe_url = extract_urls(in);
|
char *maybe_url = extract_urls(in);
|
||||||
if (maybe_url) {
|
if (maybe_url) {
|
||||||
open_browser(maybe_url);
|
open_browser(maybe_url);
|
||||||
free(maybe_url);
|
g_free(maybe_url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(in);
|
g_free(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -212,12 +215,12 @@ void context_menu(void)
|
|||||||
int parent_io[2];
|
int parent_io[2];
|
||||||
if (pipe(child_io) != 0) {
|
if (pipe(child_io) != 0) {
|
||||||
PERR("pipe()", errno);
|
PERR("pipe()", errno);
|
||||||
free(dmenu_input);
|
g_free(dmenu_input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pipe(parent_io) != 0) {
|
if (pipe(parent_io) != 0) {
|
||||||
PERR("pipe()", errno);
|
PERR("pipe()", errno);
|
||||||
free(dmenu_input);
|
g_free(dmenu_input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
@ -247,7 +250,7 @@ void context_menu(void)
|
|||||||
|
|
||||||
size_t len = read(parent_io[0], buf, 1023);
|
size_t len = read(parent_io[0], buf, 1023);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
free(dmenu_input);
|
g_free(dmenu_input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,6 +262,6 @@ void context_menu(void)
|
|||||||
|
|
||||||
dispatch_menu_result(buf);
|
dispatch_menu_result(buf);
|
||||||
|
|
||||||
free(dmenu_input);
|
g_free(dmenu_input);
|
||||||
}
|
}
|
||||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
#ifndef DUNST_MENU_H
|
#ifndef DUNST_MENU_H
|
||||||
#define DUNST_MENU_H
|
#define DUNST_MENU_H
|
||||||
|
|
||||||
#include "dunst.h"
|
|
||||||
#include <regex.h>
|
|
||||||
|
|
||||||
char *extract_urls(const char *to_match);
|
char *extract_urls(const char *to_match);
|
||||||
void open_browser(const char *url);
|
void open_browser(const char *url);
|
||||||
void invoke_action(const char *action);
|
void invoke_action(const char *action);
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <stdlib.h>
|
#include "notification.h"
|
||||||
#include <time.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "dbus.h"
|
#include "dbus.h"
|
||||||
#include "x.h"
|
|
||||||
#include "notification.h"
|
|
||||||
#include "dunst.h"
|
#include "dunst.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "rules.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
#include "rules.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "x.h"
|
||||||
|
|
||||||
int next_notification_id = 1;
|
int next_notification_id = 1;
|
||||||
|
|
||||||
@ -166,12 +168,12 @@ int notification_is_duplicate(const notification *a, const notification *b)
|
|||||||
void notification_free(notification * n)
|
void notification_free(notification * n)
|
||||||
{
|
{
|
||||||
assert(n != NULL);
|
assert(n != NULL);
|
||||||
free(n->appname);
|
g_free(n->appname);
|
||||||
free(n->summary);
|
g_free(n->summary);
|
||||||
free(n->body);
|
g_free(n->body);
|
||||||
free(n->icon);
|
g_free(n->icon);
|
||||||
free(n->msg);
|
g_free(n->msg);
|
||||||
free(n->dbus_client);
|
g_free(n->dbus_client);
|
||||||
g_free(n->category);
|
g_free(n->category);
|
||||||
|
|
||||||
if (n->text_to_render)
|
if (n->text_to_render)
|
||||||
@ -182,16 +184,16 @@ void notification_free(notification * n)
|
|||||||
|
|
||||||
if (n->actions) {
|
if (n->actions) {
|
||||||
g_strfreev(n->actions->actions);
|
g_strfreev(n->actions->actions);
|
||||||
free(n->actions->dmenu_str);
|
g_free(n->actions->dmenu_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n->raw_icon) {
|
if (n->raw_icon) {
|
||||||
if (n->raw_icon->data)
|
if (n->raw_icon->data)
|
||||||
free(n->raw_icon->data);
|
g_free(n->raw_icon->data);
|
||||||
free(n->raw_icon);
|
g_free(n->raw_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(n);
|
g_free(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -244,10 +246,10 @@ char *notification_replace_format(const char *needle, const char *replacement,
|
|||||||
char* ret;
|
char* ret;
|
||||||
|
|
||||||
if (markup_mode == MARKUP_NO) {
|
if (markup_mode == MARKUP_NO) {
|
||||||
tmp = strdup(replacement);
|
tmp = g_strdup(replacement);
|
||||||
tmp = notification_quote_markup(tmp);
|
tmp = notification_quote_markup(tmp);
|
||||||
} else {
|
} else {
|
||||||
tmp = strdup(replacement);
|
tmp = g_strdup(replacement);
|
||||||
if (settings.ignore_newline) {
|
if (settings.ignore_newline) {
|
||||||
tmp = string_replace_all("<br>", " ", tmp);
|
tmp = string_replace_all("<br>", " ", tmp);
|
||||||
tmp = string_replace_all("<br/>", " ", tmp);
|
tmp = string_replace_all("<br/>", " ", tmp);
|
||||||
@ -271,7 +273,7 @@ char *notification_replace_format(const char *needle, const char *replacement,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = string_replace_all(needle, tmp, haystack);
|
ret = string_replace_all(needle, tmp, haystack);
|
||||||
free(tmp);
|
g_free(tmp);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -284,7 +286,7 @@ char *notification_extract_markup_urls(char **str_ptr) {
|
|||||||
while ((start = strstr(str, "<a href")) != NULL) {
|
while ((start = strstr(str, "<a href")) != NULL) {
|
||||||
end = strstr(start, ">");
|
end = strstr(start, ">");
|
||||||
if (end != NULL) {
|
if (end != NULL) {
|
||||||
replace_buf = strndup(start, end - start + 1);
|
replace_buf = g_strndup(start, end - start + 1);
|
||||||
url = extract_urls(replace_buf);
|
url = extract_urls(replace_buf);
|
||||||
if (url != NULL) {
|
if (url != NULL) {
|
||||||
str = string_replace(replace_buf, "[", str);
|
str = string_replace(replace_buf, "[", str);
|
||||||
@ -295,18 +297,18 @@ char *notification_extract_markup_urls(char **str_ptr) {
|
|||||||
} else {
|
} else {
|
||||||
char *tmp = urls;
|
char *tmp = urls;
|
||||||
urls = g_strconcat(tmp, "\n", index_buf, " ", url, NULL);
|
urls = g_strconcat(tmp, "\n", index_buf, " ", url, NULL);
|
||||||
free(tmp);
|
g_free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
index_buf[0] = ' ';
|
index_buf[0] = ' ';
|
||||||
str = string_replace("</a>", index_buf, str);
|
str = string_replace("</a>", index_buf, str);
|
||||||
free(index_buf);
|
g_free(index_buf);
|
||||||
free(url);
|
g_free(url);
|
||||||
} else {
|
} else {
|
||||||
str = string_replace(replace_buf, "", str);
|
str = string_replace(replace_buf, "", str);
|
||||||
str = string_replace("</a>", "", str);
|
str = string_replace("</a>", "", str);
|
||||||
}
|
}
|
||||||
free(replace_buf);
|
g_free(replace_buf);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -321,10 +323,7 @@ char *notification_extract_markup_urls(char **str_ptr) {
|
|||||||
*/
|
*/
|
||||||
notification *notification_create(void)
|
notification *notification_create(void)
|
||||||
{
|
{
|
||||||
notification *n = malloc(sizeof(notification));
|
return g_malloc0(sizeof(notification));
|
||||||
if(n == NULL) die("Unable to allocate memory", EXIT_FAILURE);
|
|
||||||
memset(n, 0, sizeof(notification));
|
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void notification_init_defaults(notification *n)
|
void notification_init_defaults(notification *n)
|
||||||
@ -396,12 +395,12 @@ int notification_init(notification * n, int id)
|
|||||||
n->msg = g_strchomp(n->msg);
|
n->msg = g_strchomp(n->msg);
|
||||||
|
|
||||||
if (n->icon != NULL && strlen(n->icon) <= 0) {
|
if (n->icon != NULL && strlen(n->icon) <= 0) {
|
||||||
free(n->icon);
|
g_free(n->icon);
|
||||||
n->icon = NULL;
|
n->icon = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n->raw_icon == NULL && n->icon == NULL) {
|
if (n->raw_icon == NULL && n->icon == NULL) {
|
||||||
n->icon = strdup(settings.icons[n->urgency]);
|
n->icon = g_strdup(settings.icons[n->urgency]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
@ -430,8 +429,8 @@ int notification_init(notification * n, int id)
|
|||||||
/* notifications that differ only in progress hints should be expected equal,
|
/* notifications that differ only in progress hints should be expected equal,
|
||||||
* but we want the latest message, with the latest hint value
|
* but we want the latest message, with the latest hint value
|
||||||
*/
|
*/
|
||||||
free(orig->msg);
|
g_free(orig->msg);
|
||||||
orig->msg = strdup(n->msg);
|
orig->msg = g_strdup(n->msg);
|
||||||
notification_free(n);
|
notification_free(n);
|
||||||
wake_up();
|
wake_up();
|
||||||
return orig->id;
|
return orig->id;
|
||||||
@ -445,8 +444,8 @@ int notification_init(notification * n, int id)
|
|||||||
/* notifications that differ only in progress hints should be expected equal,
|
/* notifications that differ only in progress hints should be expected equal,
|
||||||
* but we want the latest message, with the latest hint value
|
* but we want the latest message, with the latest hint value
|
||||||
*/
|
*/
|
||||||
free(orig->msg);
|
g_free(orig->msg);
|
||||||
orig->msg = strdup(n->msg);
|
orig->msg = g_strdup(n->msg);
|
||||||
/* If the progress differs this was probably intended to replace the notification
|
/* If the progress differs this was probably intended to replace the notification
|
||||||
* but notify-send was used. So don't increment dup_count in this case
|
* but notify-send was used. So don't increment dup_count in this case
|
||||||
*/
|
*/
|
||||||
@ -504,7 +503,7 @@ int notification_init(notification * n, int id)
|
|||||||
if (tmp_urls != NULL) {
|
if (tmp_urls != NULL) {
|
||||||
if (n->urls != NULL) {
|
if (n->urls != NULL) {
|
||||||
n->urls = string_append(n->urls, tmp_urls, "\n");
|
n->urls = string_append(n->urls, tmp_urls, "\n");
|
||||||
free(tmp_urls);
|
g_free(tmp_urls);
|
||||||
} else {
|
} else {
|
||||||
n->urls = tmp_urls;
|
n->urls = tmp_urls;
|
||||||
}
|
}
|
||||||
@ -520,12 +519,12 @@ int notification_init(notification * n, int id)
|
|||||||
char *act_str = g_strdup_printf("#%s [%s]", human_readable, n->appname);
|
char *act_str = g_strdup_printf("#%s [%s]", human_readable, n->appname);
|
||||||
if (act_str) {
|
if (act_str) {
|
||||||
n->actions->dmenu_str = string_append(n->actions->dmenu_str, act_str, "\n");
|
n->actions->dmenu_str = string_append(n->actions->dmenu_str, act_str, "\n");
|
||||||
free(act_str);
|
g_free(act_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tmp);
|
g_free(tmp);
|
||||||
|
|
||||||
if (settings.print_notifications)
|
if (settings.print_notifications)
|
||||||
notification_print(n);
|
notification_print(n);
|
||||||
@ -588,7 +587,7 @@ int notification_close(notification * n, int reason)
|
|||||||
void notification_update_text_to_render(notification *n)
|
void notification_update_text_to_render(notification *n)
|
||||||
{
|
{
|
||||||
if (n->text_to_render) {
|
if (n->text_to_render) {
|
||||||
free(n->text_to_render);
|
g_free(n->text_to_render);
|
||||||
n->text_to_render = NULL;
|
n->text_to_render = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,7 +635,7 @@ void notification_update_text_to_render(notification *n)
|
|||||||
new_buf = g_strdup_printf("%s (%ds old)", buf, seconds);
|
new_buf = g_strdup_printf("%s (%ds old)", buf, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf);
|
g_free(buf);
|
||||||
buf = new_buf;
|
buf = new_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
#ifndef DUNST_NOTIFICATION_H
|
#ifndef DUNST_NOTIFICATION_H
|
||||||
#define DUNST_NOTIFICATION_H
|
#define DUNST_NOTIFICATION_H
|
||||||
|
|
||||||
#include "x.h"
|
#include <glib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#define LOW 0
|
#define LOW 0
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include "option_parser.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <glib.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <glib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "option_parser.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
typedef struct _entry_t {
|
typedef struct _entry_t {
|
||||||
@ -49,7 +48,7 @@ section_t *new_section(char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
section_count++;
|
section_count++;
|
||||||
sections = realloc(sections, sizeof(section_t) * section_count);
|
sections = g_realloc(sections, sizeof(section_t) * section_count);
|
||||||
if(sections == NULL) die("Unable to allocate memory.\n", 1);
|
if(sections == NULL) die("Unable to allocate memory.\n", 1);
|
||||||
sections[section_count - 1].name = g_strdup(name);
|
sections[section_count - 1].name = g_strdup(name);
|
||||||
sections[section_count - 1].entries = NULL;
|
sections[section_count - 1].entries = NULL;
|
||||||
@ -61,13 +60,13 @@ void free_ini(void)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < section_count; i++) {
|
for (int i = 0; i < section_count; i++) {
|
||||||
for (int j = 0; j < sections[i].entry_count; j++) {
|
for (int j = 0; j < sections[i].entry_count; j++) {
|
||||||
free(sections[i].entries[j].key);
|
g_free(sections[i].entries[j].key);
|
||||||
free(sections[i].entries[j].value);
|
g_free(sections[i].entries[j].value);
|
||||||
}
|
}
|
||||||
free(sections[i].entries);
|
g_free(sections[i].entries);
|
||||||
free(sections[i].name);
|
g_free(sections[i].name);
|
||||||
}
|
}
|
||||||
free(sections);
|
g_free(sections);
|
||||||
section_count = 0;
|
section_count = 0;
|
||||||
sections = NULL;
|
sections = NULL;
|
||||||
}
|
}
|
||||||
@ -91,7 +90,7 @@ void add_entry(char *section_name, char *key, char *value)
|
|||||||
|
|
||||||
s->entry_count++;
|
s->entry_count++;
|
||||||
int len = s->entry_count;
|
int len = s->entry_count;
|
||||||
s->entries = realloc(s->entries, sizeof(entry_t) * len);
|
s->entries = g_realloc(s->entries, sizeof(entry_t) * len);
|
||||||
s->entries[s->entry_count - 1].key = g_strdup(key);
|
s->entries[s->entry_count - 1].key = g_strdup(key);
|
||||||
s->entries[s->entry_count - 1].value = clean_value(value);
|
s->entries[s->entry_count - 1].value = clean_value(value);
|
||||||
}
|
}
|
||||||
@ -235,7 +234,7 @@ int load_ini_file(FILE * fp)
|
|||||||
*end = '\0';
|
*end = '\0';
|
||||||
|
|
||||||
if (current_section)
|
if (current_section)
|
||||||
free(current_section);
|
g_free(current_section);
|
||||||
current_section = (g_strdup(start + 1));
|
current_section = (g_strdup(start + 1));
|
||||||
new_section(current_section);
|
new_section(current_section);
|
||||||
continue;
|
continue;
|
||||||
@ -263,12 +262,10 @@ int load_ini_file(FILE * fp)
|
|||||||
printf("Missing '\"'\n");
|
printf("Missing '\"'\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
closing_quote = '\0';
|
|
||||||
} else {
|
} else {
|
||||||
char *comment = strpbrk(value, "#;");
|
char *comment = strpbrk(value, "#;");
|
||||||
if (comment)
|
if (comment)
|
||||||
comment = '\0';
|
*comment = '\0';
|
||||||
}
|
}
|
||||||
value = g_strstrip(value);
|
value = g_strstrip(value);
|
||||||
|
|
||||||
@ -283,7 +280,7 @@ int load_ini_file(FILE * fp)
|
|||||||
}
|
}
|
||||||
free(line);
|
free(line);
|
||||||
if (current_section)
|
if (current_section)
|
||||||
free(current_section);
|
g_free(current_section);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +306,7 @@ int cmdline_find_option(char *key)
|
|||||||
/* look for first key */
|
/* look for first key */
|
||||||
for (int i = 0; i < cmdline_argc; i++) {
|
for (int i = 0; i < cmdline_argc; i++) {
|
||||||
if (strcmp(key1, cmdline_argv[i]) == 0) {
|
if (strcmp(key1, cmdline_argv[i]) == 0) {
|
||||||
free(key1);
|
g_free(key1);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,13 +315,13 @@ int cmdline_find_option(char *key)
|
|||||||
if (key2) {
|
if (key2) {
|
||||||
for (int i = 0; i < cmdline_argc; i++) {
|
for (int i = 0; i < cmdline_argc; i++) {
|
||||||
if (strcmp(key2, cmdline_argv[i]) == 0) {
|
if (strcmp(key2, cmdline_argv[i]) == 0) {
|
||||||
free(key1);
|
g_free(key1);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(key1);
|
g_free(key1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,16 +464,16 @@ void cmdline_usage_append(char *key, char *type, char *description)
|
|||||||
if (!usage_str) {
|
if (!usage_str) {
|
||||||
usage_str =
|
usage_str =
|
||||||
g_strdup_printf("%-40s - %s\n", key_type, description);
|
g_strdup_printf("%-40s - %s\n", key_type, description);
|
||||||
free(key_type);
|
g_free(key_type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
tmp =
|
tmp =
|
||||||
g_strdup_printf("%s%-40s - %s\n", usage_str, key_type, description);
|
g_strdup_printf("%s%-40s - %s\n", usage_str, key_type, description);
|
||||||
free(key_type);
|
g_free(key_type);
|
||||||
|
|
||||||
free(usage_str);
|
g_free(usage_str);
|
||||||
usage_str = tmp;
|
usage_str = tmp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#ifndef DUNST_OPTION_PARSER_H
|
#ifndef DUNST_OPTION_PARSER_H
|
||||||
#define DUNST_OPTION_PARSER_H
|
#define DUNST_OPTION_PARSER_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int load_ini_file(FILE *);
|
int load_ini_file(FILE *);
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
|
|
||||||
#include <glib.h>
|
#include "rules.h"
|
||||||
|
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include "dunst.h"
|
#include "dunst.h"
|
||||||
#include "rules.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apply rule to notification.
|
* Apply rule to notification.
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#define DUNST_RULES_H
|
#define DUNST_RULES_H
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "dunst.h"
|
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
|
|
||||||
#include <glib.h>
|
#include "settings.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#ifndef STATIC_CONFIG
|
#ifndef STATIC_CONFIG
|
||||||
#include <basedir.h>
|
#include <basedir.h>
|
||||||
#include <basedir_fs.h>
|
#include <basedir_fs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dunst.h"
|
#include "rules.h" // put before config.h to fix missing include
|
||||||
#include "rules.h"
|
|
||||||
#include "option_parser.h"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "dunst.h"
|
||||||
|
#include "notification.h"
|
||||||
|
#include "option_parser.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
settings_t settings;
|
settings_t settings;
|
||||||
@ -64,7 +65,7 @@ static int ini_get_urgency(char *section, char *key, int def)
|
|||||||
urg);
|
urg);
|
||||||
}
|
}
|
||||||
if (urg)
|
if (urg)
|
||||||
free(urg);
|
g_free(urg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
);
|
);
|
||||||
|
|
||||||
settings.markup = parse_markup_mode(c);
|
settings.markup = parse_markup_mode(c);
|
||||||
free(c);
|
g_free(c);
|
||||||
} else if (ini_is_set("global", "allow_markup")) {
|
} else if (ini_is_set("global", "allow_markup")) {
|
||||||
bool allow_markup = option_get_bool(
|
bool allow_markup = option_get_bool(
|
||||||
"global",
|
"global",
|
||||||
@ -178,7 +179,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
|
|
||||||
if (strlen(c) > 0) {
|
if (strlen(c) > 0) {
|
||||||
parse_follow_mode(c);
|
parse_follow_mode(c);
|
||||||
free(c);
|
g_free(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +242,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
else
|
else
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Warning: unknown alignment\n");
|
"Warning: unknown alignment\n");
|
||||||
free(c);
|
g_free(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +318,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
settings.sep_color = CUSTOM;
|
settings.sep_color = CUSTOM;
|
||||||
settings.sep_custom_color_str = g_strdup(c);
|
settings.sep_custom_color_str = g_strdup(c);
|
||||||
}
|
}
|
||||||
free(c);
|
g_free(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +374,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
else
|
else
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Warning: unknown icon position: %s\n", c);
|
"Warning: unknown icon position: %s\n", c);
|
||||||
free(c);
|
g_free(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,7 +575,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
|
|
||||||
if (strlen(c) > 0) {
|
if (strlen(c) > 0) {
|
||||||
r->markup = parse_markup_mode(c);
|
r->markup = parse_markup_mode(c);
|
||||||
free(c);
|
g_free(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#ifndef DUNST_SETTINGS_H
|
#ifndef DUNST_SETTINGS_H
|
||||||
#define DUNST_SETTINGS_H
|
#define DUNST_SETTINGS_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "x.h"
|
||||||
|
|
||||||
enum alignment { left, center, right };
|
enum alignment { left, center, right };
|
||||||
enum icon_position_t { icons_left, icons_right, icons_off };
|
enum icon_position_t { icons_left, icons_right, icons_off };
|
||||||
enum separator_color { FOREGROUND, AUTO, FRAME, CUSTOM };
|
enum separator_color { FOREGROUND, AUTO, FRAME, CUSTOM };
|
||||||
|
19
src/utils.c
19
src/utils.c
@ -1,14 +1,11 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "dunst.h"
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
char *string_replace_char(char needle, char replacement, char *haystack) {
|
char *string_replace_char(char needle, char replacement, char *haystack) {
|
||||||
char *current = haystack;
|
char *current = haystack;
|
||||||
@ -29,7 +26,7 @@ char *string_replace_at(char *buf, int pos, int len, const char *repl)
|
|||||||
if (repl_len <= len) {
|
if (repl_len <= len) {
|
||||||
tmp = buf;
|
tmp = buf;
|
||||||
} else {
|
} else {
|
||||||
tmp = malloc(size);
|
tmp = g_malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(tmp, buf, pos);
|
memcpy(tmp, buf, pos);
|
||||||
@ -37,7 +34,7 @@ char *string_replace_at(char *buf, int pos, int len, const char *repl)
|
|||||||
memmove(tmp + pos + repl_len, buf + pos + len, buf_len - (pos + len) + 1);
|
memmove(tmp + pos + repl_len, buf + pos + len, buf_len - (pos + len) + 1);
|
||||||
|
|
||||||
if(tmp != buf) {
|
if(tmp != buf) {
|
||||||
free(buf);
|
g_free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -87,7 +84,7 @@ char *string_append(char *a, const char *b, const char *sep)
|
|||||||
new = g_strconcat(a, b, NULL);
|
new = g_strconcat(a, b, NULL);
|
||||||
else
|
else
|
||||||
new = g_strconcat(a, sep, b, NULL);
|
new = g_strconcat(a, sep, b, NULL);
|
||||||
free(a);
|
g_free(a);
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
|
|
||||||
|
45
src/x.c
45
src/x.c
@ -1,26 +1,30 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
#include <math.h>
|
#include "x.h"
|
||||||
#include <sys/time.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <pango/pangocairo.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#ifdef XINERAMA
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#endif
|
||||||
#include <cairo-xlib.h>
|
#include <cairo-xlib.h>
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <pango/pangocairo.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "x.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "dunst.h"
|
#include "dunst.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#define WIDTH 400
|
#define WIDTH 400
|
||||||
#define HEIGHT 400
|
#define HEIGHT 400
|
||||||
@ -332,14 +336,14 @@ static GdkPixbuf *get_pixbuf_from_path(char *icon_path)
|
|||||||
end = strchr(start, ':');
|
end = strchr(start, ':');
|
||||||
if (end == NULL) end = strchr(settings.icon_folders, '\0'); /* end = end of string */
|
if (end == NULL) end = strchr(settings.icon_folders, '\0'); /* end = end of string */
|
||||||
|
|
||||||
current_folder = strndup(start, end - start);
|
current_folder = g_strndup(start, end - start);
|
||||||
/* try svg */
|
/* try svg */
|
||||||
maybe_icon_path = g_strconcat(current_folder, "/", icon_path, ".svg", NULL);
|
maybe_icon_path = g_strconcat(current_folder, "/", icon_path, ".svg", NULL);
|
||||||
if (!does_file_exist(maybe_icon_path)) {
|
if (!does_file_exist(maybe_icon_path)) {
|
||||||
/* fallback to png */
|
/* fallback to png */
|
||||||
maybe_icon_path = g_strconcat(current_folder, "/", icon_path, ".png", NULL);
|
maybe_icon_path = g_strconcat(current_folder, "/", icon_path, ".png", NULL);
|
||||||
}
|
}
|
||||||
free(current_folder);
|
g_free(current_folder);
|
||||||
|
|
||||||
pixbuf = get_pixbuf_from_file(maybe_icon_path);
|
pixbuf = get_pixbuf_from_file(maybe_icon_path);
|
||||||
g_free(maybe_icon_path);
|
g_free(maybe_icon_path);
|
||||||
@ -380,10 +384,7 @@ static GdkPixbuf *get_pixbuf_from_raw_image(const RawImage *raw_image)
|
|||||||
|
|
||||||
static colored_layout *r_init_shared(cairo_t *c, notification *n)
|
static colored_layout *r_init_shared(cairo_t *c, notification *n)
|
||||||
{
|
{
|
||||||
colored_layout *cl = malloc(sizeof(colored_layout));
|
colored_layout *cl = g_malloc(sizeof(colored_layout));
|
||||||
if(cl == NULL) {
|
|
||||||
die("Unable to allocate memory", EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
cl->l = pango_cairo_create_layout(c);
|
cl->l = pango_cairo_create_layout(c);
|
||||||
|
|
||||||
if (!settings.word_wrap) {
|
if (!settings.word_wrap) {
|
||||||
@ -1414,7 +1415,7 @@ void x_shortcut_init(keyboard_shortcut * ks)
|
|||||||
ks->is_valid = true;
|
ks->is_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(str_begin);
|
g_free(str_begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||||
|
10
src/x.h
10
src/x.h
@ -2,16 +2,10 @@
|
|||||||
#ifndef DUNST_X_H
|
#ifndef DUNST_X_H
|
||||||
#define DUNST_X_H
|
#define DUNST_X_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include "glib.h"
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/XKBlib.h>
|
|
||||||
#include <X11/Xatom.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#ifdef XINERAMA
|
|
||||||
#include <X11/extensions/Xinerama.h>
|
|
||||||
#endif
|
|
||||||
#include <X11/extensions/scrnsaver.h>
|
#include <X11/extensions/scrnsaver.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
#define FONT_HEIGHT_BORDER 2
|
#define FONT_HEIGHT_BORDER 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user