summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2014-06-15 16:22:54 +0200
committerPeter Hofmann <scm@uninformativ.de>2014-06-15 16:29:38 +0200
commit1adcab7950aff5dee143fc2472935cc985895cff (patch)
tree25cbf855a835e70a7bf9b856346f3925c5590178
parentda89f4935ec7111579bd1f063f388784162b320a (diff)
downloadlariza-1adcab7950aff5dee143fc2472935cc985895cff.tar.gz
Don't fiddle with __NAME__ at runtime
-rw-r--r--Makefile4
-rw-r--r--browser.c25
2 files changed, 9 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 465a93c..bdace38 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,13 @@
CFLAGS += -Wall -Wextra -O3
__NAME__ = lariza
+__NAME_UPPERCASE__ = `echo $(__NAME__) | sed 's/.*/\U&/'`
+__NAME_CAPITALIZED__ = `echo $(__NAME__) | sed 's/^./\U&\E/'`
$(__NAME__): browser.c
$(CC) $(CFLAGS) $(LDFLAGS) \
-D__NAME__=\"$(__NAME__)\" \
+ -D__NAME_UPPERCASE__=\"$(__NAME_UPPERCASE__)\" \
+ -D__NAME_CAPITALIZED__=\"$(__NAME_CAPITALIZED__)\" \
-o $@ $< \
`pkg-config --cflags --libs gtk+-2.0 glib-2.0 webkit-1.0`
diff --git a/browser.c b/browser.c
index 81ddf99..6075a1f 100644
--- a/browser.c
+++ b/browser.c
@@ -160,7 +160,7 @@ void
client_new(const gchar *uri)
{
struct Client *c;
- gchar *capitalized_name = NULL, *f;
+ gchar *f;
if (cooperative_instances && !cooperative_alone)
{
@@ -192,11 +192,7 @@ client_new(const gchar *uri)
if (c->win == NULL)
{
c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-
- capitalized_name = g_strdup(__NAME__);
- capitalized_name[0] = g_ascii_toupper(capitalized_name[0]);
- gtk_window_set_wmclass(GTK_WINDOW(c->win), __NAME__, capitalized_name);
- g_free(capitalized_name);
+ gtk_window_set_wmclass(GTK_WINDOW(c->win), __NAME__, __NAME_CAPITALIZED__);
}
/* When using Gtk2, it only shows a white area when run in suckless'
@@ -443,36 +439,25 @@ ensure_url_scheme(const gchar *t)
void
grab_environment_configuration(void)
{
- gchar *u, *v;
const gchar *e;
- u = g_ascii_strup(__NAME__, -1);
-
- v = g_strdup_printf("%s_ACCEPTED_LANGUAGE", u);
- e = g_getenv(v);
+ e = g_getenv(__NAME_UPPERCASE__"_ACCEPTED_LANGUAGE");
if (e != NULL)
{
accepted_language = g_strdup(e);
}
- g_free(v);
- v = g_strdup_printf("%s_DOWNLOAD_DIR", u);
- e = g_getenv(v);
+ e = g_getenv(__NAME_UPPERCASE__"_DOWNLOAD_DIR");
if (e != NULL)
{
download_dir = g_strdup(e);
}
- g_free(v);
- v = g_strdup_printf("%s_ZOOM", u);
- e = g_getenv(v);
+ e = g_getenv(__NAME_UPPERCASE__"_ZOOM");
if (e != NULL)
{
global_zoom = atof(e);
}
- g_free(v);
-
- g_free(u);
}
void