diff options
author | Peng Huang <shawn.p.huang@gmail.com> | 2009-03-30 14:31:15 +0800 |
---|---|---|
committer | Peng Huang <shawn.p.huang@gmail.com> | 2009-03-30 14:31:15 +0800 |
commit | aab43511420f04c37d96c39b6b807fe799036b9c (patch) | |
tree | 65168a4ad000f0607f2998fa5bba8e6b083354c0 /src | |
parent | 81963e23e2688f28ef0acbdbf72d831be097bd62 (diff) | |
download | ibus-aab43511420f04c37d96c39b6b807fe799036b9c.tar.gz ibus-aab43511420f04c37d96c39b6b807fe799036b9c.tar.xz ibus-aab43511420f04c37d96c39b6b807fe799036b9c.zip |
Get display name from gdk_display_get_name
Diffstat (limited to 'src')
-rw-r--r-- | src/ibusshare.c | 17 | ||||
-rw-r--r-- | src/ibusshare.h | 1 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/ibusshare.c b/src/ibusshare.c index f87bb0c..c8f37a8 100644 --- a/src/ibusshare.c +++ b/src/ibusshare.c @@ -24,6 +24,16 @@ #include <pwd.h> #include "ibusshare.h" +static gchar *display = NULL; + +void +ibus_set_display (const gchar *display) +{ + if (display != NULL) + g_free (display); + display = g_strdup (display); +} + const gchar * ibus_get_user_name (void) { @@ -64,14 +74,16 @@ ibus_get_socket_path (void) static gchar *path = NULL; if (path == NULL) { - gchar *display; gchar *hostname = ""; gchar *displaynumber = "0"; gchar *screennumber = "0"; const gchar *username = NULL; gchar *p; - display = g_strdup (g_getenv ("DISPLAY")); + if (display == NULL) { + display = g_strdup (g_getenv ("DISPLAY")); + } + if (display == NULL) { g_warning ("DISPLAY is empty! We use default DISPLAY (:0.0)"); } @@ -104,7 +116,6 @@ ibus_get_socket_path (void) "/tmp/ibus-%s/ibus-%s-%s", username, hostname, displaynumber); - g_free (display); } return path; diff --git a/src/ibusshare.h b/src/ibusshare.h index 142bd47..f3b34c4 100644 --- a/src/ibusshare.h +++ b/src/ibusshare.h @@ -45,6 +45,7 @@ G_BEGIN_DECLS +void ibus_set_display (const gchar *display); const gchar *ibus_get_address (void); const gchar *ibus_get_user_name (void); const gchar *ibus_get_socket_path (void); |