all repos — openbox @ 2f0e73cf9d20154c5c84b6ea90e658cf44a6f0c4

openbox fork - make it a bit more like ryudo

add functions for setting locale strings (on top of existing functions for setting utf8 strings). they are untested though! wonder if they work?
Dana Jansens danakj@orodu.net
commit

2f0e73cf9d20154c5c84b6ea90e658cf44a6f0c4

parent

275fdf8c2a0d5c7d8f395b3269e644939e016696

5 files changed, 52 insertions(+), 17 deletions(-)

jump to
M obt/prop.cobt/prop.c

@@ -318,7 +318,7 @@ GSList *strs = NULL, *it;

gchar *raw, *p; guint num, i, count = 0; - if (get_all(win, prop, obt_prop_atom(OBT_PROP_STRING), 8, + if (get_all(win, prop, OBT_PROP_ATOM(STRING), 8, (guchar**)&raw, &num)) { p = raw;

@@ -350,7 +350,7 @@ gchar *raw;

gchar *str; guint num; - if (get_all(win, prop, obt_prop_atom(OBT_PROP_UTF8), 8, + if (get_all(win, prop, OBT_PROP_ATOM(UTF8), 8, (guchar**)&raw, &num)) { str = g_strndup(raw, num); /* grab the first string from the list */

@@ -370,7 +370,7 @@ GSList *strs = NULL, *it;

gchar *raw, *p; guint num, i, count = 0; - if (get_all(win, prop, obt_prop_atom(OBT_PROP_UTF8), 8, + if (get_all(win, prop, OBT_PROP_ATOM(UTF8), 8, (guchar**)&raw, &num)) { p = raw;

@@ -408,16 +408,47 @@ XChangeProperty(obt_display, win, prop, type, 32, PropModeReplace,

(guchar*)val, num); } +void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val) +{ + const gchar *s[2] = { val, NULL }; + obt_prop_set_strings_locale(win, prop, s); +} + +void obt_prop_set_strings_locale(Window win, Atom prop, + const gchar **strs) +{ + gint i, count; + gchar **lstrs; + XTextProperty tprop; + + /* count the strings in strs, and convert them to the locale format */ + for (count = 0; strs[count]; ++count); + lstrs = g_new0(char*, count); + for (i = 0; i < count; ++i) { + lstrs[i] = g_locale_from_utf8(strs[i], -1, NULL, NULL, NULL); + if (!lstrs[i]) { + lstrs[i] = g_strdup(""); /* make it an empty string */ + g_warning("Unable to translate string '%s' from UTF8 to locale " + "format", strs[i]); + } + } + + + XStringListToTextProperty(lstrs, count, &tprop); + XSetTextProperty(obt_display, win, &tprop, prop); + XFree(tprop.value); +} + void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val) { - XChangeProperty(obt_display, win, prop, obt_prop_atom(OBT_PROP_UTF8), 8, + XChangeProperty(obt_display, win, prop, OBT_PROP_ATOM(UTF8), 8, PropModeReplace, (const guchar*)val, strlen(val)); } -void obt_prop_set_strings_utf8(Window win, Atom prop, gchar **strs) +void obt_prop_set_strings_utf8(Window win, Atom prop, const gchar **strs) { GString *str; - gchar **s; + const gchar **s; str = g_string_sized_new(0); for (s = strs; *s; ++s) {
M obt/prop.hobt/prop.h

@@ -225,8 +225,12 @@

void obt_prop_set32(Window win, Atom prop, Atom type, gulong val); void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val, guint num); +void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val); void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val); -void obt_prop_set_strings_utf8(Window win, Atom prop, gchar **strs); +void obt_prop_set_strings_locale(Window win, Atom prop, + const gchar **strs); +void obt_prop_set_strings_utf8(Window win, Atom prop, + const gchar **strs); void obt_prop_erase(Window win, Atom prop);

@@ -254,10 +258,10 @@ (obt_prop_set32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), val))

#define OBT_PROP_SETA32(win, prop, type, val, num) \ (obt_prop_set_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \ val, num)) -#define OBT_PROP_SETS(win, prop, val) \ - (obt_prop_set_string_utf8(win, OBT_PROP_ATOM(prop), val)) -#define OBT_PROP_SETSS(win, prop, strs) \ - (obt_prop_set_strings_utf8(win, OBT_PROP_ATOM(prop), strs)) +#define OBT_PROP_SETS(win, prop, type, val) \ + (obt_prop_set_string_##type(win, OBT_PROP_ATOM(prop), val)) +#define OBT_PROP_SETSS(win, prop, type, strs) \ + (obt_prop_set_strings_##type(win, OBT_PROP_ATOM(prop), strs)) #define OBT_PROP_ERASE(win, prop) (obt_prop_erase(win, OBT_PROP_ATOM(prop)))
M openbox/client.copenbox/client.c

@@ -1978,7 +1978,7 @@ visible = g_strdup_printf("%s - [%s]", data, _("Not Responding"));

g_free(data); } - OBT_PROP_SETS(self->window, NET_WM_VISIBLE_NAME, visible); + OBT_PROP_SETS(self->window, NET_WM_VISIBLE_NAME, utf8, visible); self->title = visible; if (self->frame)

@@ -2010,7 +2010,7 @@ visible = g_strdup_printf("%s - [%s]", data, _("Not Responding"));

g_free(data); } - OBT_PROP_SETS(self->window, NET_WM_VISIBLE_ICON_NAME, visible); + OBT_PROP_SETS(self->window, NET_WM_VISIBLE_ICON_NAME, utf8, visible); self->icon_title = visible; }
M openbox/openbox.copenbox/openbox.c

@@ -262,7 +262,7 @@ if (ob_rr_theme == NULL)

ob_exit_with_error(_("Unable to load a theme.")); OBT_PROP_SETS(RootWindow(obt_display, ob_screen), - OB_THEME, ob_rr_theme->name); + OB_THEME, utf8, ob_rr_theme->name); } if (reconfigure) {
M openbox/screen.copenbox/screen.c

@@ -203,7 +203,7 @@ OBT_PROP_SET32(RootWindow(obt_display, ob_screen),

NET_SUPPORTING_WM_CHECK, WINDOW, screen_support_win); /* set properties on the supporting window */ - OBT_PROP_SETS(screen_support_win, NET_WM_NAME, "Openbox"); + OBT_PROP_SETS(screen_support_win, NET_WM_NAME, utf8, "Openbox"); OBT_PROP_SET32(screen_support_win, NET_SUPPORTING_WM_CHECK, WINDOW, screen_support_win);

@@ -385,7 +385,7 @@ names[i] = g_strdup(it->data);

/* set the root window property */ OBT_PROP_SETSS(RootWindow(obt_display, ob_screen), - NET_DESKTOP_NAMES, names); + NET_DESKTOP_NAMES, utf8, names); g_strfreev(names); }

@@ -1162,7 +1162,7 @@

/* if we changed any names, then set the root property so we can all agree on the names */ OBT_PROP_SETSS(RootWindow(obt_display, ob_screen), NET_DESKTOP_NAMES, - screen_desktop_names); + utf8, screen_desktop_names); } /* resize the pager for these names */