implement urgent on beep

This commit is contained in:
Daniel Micay 2012-05-22 07:47:51 -04:00
parent 8a37b88957
commit e398fcb7d2
2 changed files with 21 additions and 0 deletions

View File

@ -3,6 +3,8 @@
#include <stdbool.h> #include <stdbool.h>
#define URGENT_ON_BEEP
static const char *url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+]*"; static const char *url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+]*";
static const char *url_command = "/usr/bin/firefox"; static const char *url_command = "/usr/bin/firefox";

19
term.c
View File

@ -6,6 +6,10 @@
#include "config.h" #include "config.h"
#ifndef __GNUC__
# define __attribute__(x)
#endif
enum search_direction { enum search_direction {
search_forward, search_forward,
search_backward search_backward
@ -123,6 +127,15 @@ static gboolean button_press_cb(VteTerminal *vte, GdkEventButton *event) {
return FALSE; return FALSE;
} }
#ifdef URGENT_ON_BEEP
static void beep_handler(__attribute__((unused)) VteTerminal *vte, GtkWidget *window) {
GtkWindow *gwin = GTK_WINDOW(window);
if (!gtk_window_is_active(gwin)) {
gtk_window_set_urgency_hint(gwin, TRUE);
}
}
#endif
int main(int argc, char **argv) { int main(int argc, char **argv) {
GError *error = NULL; GError *error = NULL;
@ -203,6 +216,12 @@ int main(int argc, char **argv) {
g_signal_connect(vte, "button-press-event", G_CALLBACK(button_press_cb), NULL); g_signal_connect(vte, "button-press-event", G_CALLBACK(button_press_cb), NULL);
g_signal_connect(vte, "key-press-event", G_CALLBACK(key_press_cb), NULL); g_signal_connect(vte, "key-press-event", G_CALLBACK(key_press_cb), NULL);
#ifdef URGENT_ON_BEEP
if (g_signal_lookup("beep", G_TYPE_FROM_INSTANCE(G_OBJECT(vte)))) {
g_signal_connect(vte, "beep", G_CALLBACK(beep_handler), window);
}
#endif
gtk_widget_show_all(window); gtk_widget_show_all(window);
gtk_main(); gtk_main();
return 0; return 0;