Mercurial > pidgin
diff console/plugins/gntgf.c @ 14396:9e9699792bb9
[gaim-migrate @ 17104]
Add option in gntgf to set the URGENT hint for the terminal's window (in X).
Unescape the status-string in the statusbox.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 01 Sep 2006 02:07:23 +0000 |
parents | fd46a9845fc2 |
children | 080b16e08b2b |
line wrap: on
line diff
--- a/console/plugins/gntgf.c Thu Aug 31 22:04:16 2006 +0000 +++ b/console/plugins/gntgf.c Fri Sep 01 02:07:23 2006 +0000 @@ -33,6 +33,13 @@ #define MAX_COLS 3 +#ifdef HAVE_X11 +#define PREFS_URGENT PREFS_PREFIX "/urgent" + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#endif + #include <glib.h> #include <plugin.h> @@ -103,6 +110,35 @@ return FALSE; } +#ifdef HAVE_X11 +static void +urgent() +{ + /* This is from deryni/tuomov's urgent_test.c */ + Display *dpy; + Window id; + const char *ids; + XWMHints *hints; + + ids = getenv("WINDOWID"); + if (ids == NULL) + return; + + id = atoi(ids); + + dpy = XOpenDisplay(NULL); + if (dpy == NULL) + return; + + hints = XGetWMHints(dpy, id); + hints->flags|=XUrgencyHint; + XSetWMHints(dpy, id, hints); + + XFlush(dpy); + XCloseDisplay(dpy); +} +#endif + static void notify(const char *fmt, ...) { @@ -114,6 +150,10 @@ if (gaim_prefs_get_bool(PREFS_BEEP)) beep(); +#ifdef HAVE_X11 + if (gaim_prefs_get_bool(PREFS_URGENT)) + urgent(); +#endif window = gnt_vbox_new(FALSE); GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); @@ -254,9 +294,9 @@ } static void -beep_toggled(GntCheckBox *check, gpointer null) +toggle_option(GntCheckBox *check, gpointer str) { - gaim_prefs_set_bool(PREFS_BEEP, gnt_check_box_get_checked(check)); + gaim_prefs_set_bool(str, gnt_check_box_get_checked(check)); } static GntWidget * @@ -288,9 +328,16 @@ check = gnt_check_box_new(_("Beep too!")); gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_BEEP)); - g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(beep_toggled), NULL); + g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(toggle_option), PREFS_BEEP); gnt_box_add_widget(GNT_BOX(window), check); +#ifdef HAVE_X11 + check = gnt_check_box_new(_("Set URGENT for the terminal window.")); + gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_URGENT)); + g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(toggle_option), PREFS_URGENT); + gnt_box_add_widget(GNT_BOX(window), check); +#endif + return window; } @@ -335,6 +382,9 @@ gaim_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE); gaim_prefs_add_bool(PREFS_BEEP, TRUE); +#ifdef HAVE_X11 + gaim_prefs_add_bool(PREFS_URGENT, TRUE); +#endif } GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)