comparison 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
comparison
equal deleted inserted replaced
14395:d72cbd259357 14396:9e9699792bb9
31 #define PREFS_EVENT_CHAT_NICK PREFS_EVENT "/chatnick" 31 #define PREFS_EVENT_CHAT_NICK PREFS_EVENT "/chatnick"
32 #define PREFS_BEEP PREFS_PREFIX "/beep" 32 #define PREFS_BEEP PREFS_PREFIX "/beep"
33 33
34 #define MAX_COLS 3 34 #define MAX_COLS 3
35 35
36 #ifdef HAVE_X11
37 #define PREFS_URGENT PREFS_PREFIX "/urgent"
38
39 #include <X11/Xlib.h>
40 #include <X11/Xutil.h>
41 #endif
42
36 #include <glib.h> 43 #include <glib.h>
37 44
38 #include <plugin.h> 45 #include <plugin.h>
39 #include <version.h> 46 #include <version.h>
40 #include <blist.h> 47 #include <blist.h>
101 gpsw[col] = 0; 108 gpsw[col] = 0;
102 109
103 return FALSE; 110 return FALSE;
104 } 111 }
105 112
113 #ifdef HAVE_X11
114 static void
115 urgent()
116 {
117 /* This is from deryni/tuomov's urgent_test.c */
118 Display *dpy;
119 Window id;
120 const char *ids;
121 XWMHints *hints;
122
123 ids = getenv("WINDOWID");
124 if (ids == NULL)
125 return;
126
127 id = atoi(ids);
128
129 dpy = XOpenDisplay(NULL);
130 if (dpy == NULL)
131 return;
132
133 hints = XGetWMHints(dpy, id);
134 hints->flags|=XUrgencyHint;
135 XSetWMHints(dpy, id, hints);
136
137 XFlush(dpy);
138 XCloseDisplay(dpy);
139 }
140 #endif
141
106 static void 142 static void
107 notify(const char *fmt, ...) 143 notify(const char *fmt, ...)
108 { 144 {
109 GntWidget *window; 145 GntWidget *window;
110 GntToast *toast; 146 GntToast *toast;
112 int h, w, i; 148 int h, w, i;
113 va_list args; 149 va_list args;
114 150
115 if (gaim_prefs_get_bool(PREFS_BEEP)) 151 if (gaim_prefs_get_bool(PREFS_BEEP))
116 beep(); 152 beep();
153 #ifdef HAVE_X11
154 if (gaim_prefs_get_bool(PREFS_URGENT))
155 urgent();
156 #endif
117 157
118 window = gnt_vbox_new(FALSE); 158 window = gnt_vbox_new(FALSE);
119 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); 159 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT);
120 GNT_WIDGET_UNSET_FLAGS(window, GNT_WIDGET_NO_BORDER); 160 GNT_WIDGET_UNSET_FLAGS(window, GNT_WIDGET_NO_BORDER);
121 161
252 { 292 {
253 gaim_prefs_set_bool(key, gnt_tree_get_choice(tree, key)); 293 gaim_prefs_set_bool(key, gnt_tree_get_choice(tree, key));
254 } 294 }
255 295
256 static void 296 static void
257 beep_toggled(GntCheckBox *check, gpointer null) 297 toggle_option(GntCheckBox *check, gpointer str)
258 { 298 {
259 gaim_prefs_set_bool(PREFS_BEEP, gnt_check_box_get_checked(check)); 299 gaim_prefs_set_bool(str, gnt_check_box_get_checked(check));
260 } 300 }
261 301
262 static GntWidget * 302 static GntWidget *
263 config_frame() 303 config_frame()
264 { 304 {
286 gnt_tree_set_col_width(GNT_TREE(tree), 0, 40); 326 gnt_tree_set_col_width(GNT_TREE(tree), 0, 40);
287 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(pref_toggled), NULL); 327 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(pref_toggled), NULL);
288 328
289 check = gnt_check_box_new(_("Beep too!")); 329 check = gnt_check_box_new(_("Beep too!"));
290 gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_BEEP)); 330 gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_BEEP));
291 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(beep_toggled), NULL); 331 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(toggle_option), PREFS_BEEP);
292 gnt_box_add_widget(GNT_BOX(window), check); 332 gnt_box_add_widget(GNT_BOX(window), check);
333
334 #ifdef HAVE_X11
335 check = gnt_check_box_new(_("Set URGENT for the terminal window."));
336 gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_URGENT));
337 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(toggle_option), PREFS_URGENT);
338 gnt_box_add_widget(GNT_BOX(window), check);
339 #endif
293 340
294 return window; 341 return window;
295 } 342 }
296 343
297 static GaimPluginInfo info = 344 static GaimPluginInfo info =
333 gaim_prefs_add_bool(PREFS_EVENT_IM_MSG, TRUE); 380 gaim_prefs_add_bool(PREFS_EVENT_IM_MSG, TRUE);
334 gaim_prefs_add_bool(PREFS_EVENT_CHAT_MSG, TRUE); 381 gaim_prefs_add_bool(PREFS_EVENT_CHAT_MSG, TRUE);
335 gaim_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE); 382 gaim_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE);
336 383
337 gaim_prefs_add_bool(PREFS_BEEP, TRUE); 384 gaim_prefs_add_bool(PREFS_BEEP, TRUE);
385 #ifdef HAVE_X11
386 gaim_prefs_add_bool(PREFS_URGENT, TRUE);
387 #endif
338 } 388 }
339 389
340 GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info) 390 GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)