mtah (owner)

Revisions

gist: 226506 Download_button fork
public
Public Clone URL: git://gist.github.com/226506.git
Embed All Files: show embed
patch1.diff #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
Index: src/terminal-screen.c
===================================================================
--- src/terminal-screen.c (revision 3436)
+++ src/terminal-screen.c (working copy)
@@ -73,6 +73,7 @@
   double font_scale;
   gboolean user_title; /* title was manually set */
   GSList *match_tags;
+ gboolean bell_raised;
 };
 
 enum
@@ -91,7 +92,8 @@
   PROP_ICON_TITLE_SET,
   PROP_OVERRIDE_COMMAND,
   PROP_TITLE,
- PROP_INITIAL_ENVIRONMENT
+ PROP_INITIAL_ENVIRONMENT,
+ PROP_BELL_RAISED
 };
 
 enum
@@ -129,6 +131,11 @@
 static void terminal_screen_icon_title_changed (VteTerminal *vte_terminal,
                                                        TerminalScreen *screen);
 
+static gboolean terminal_screen_beep_cb (TerminalScreen *screen);
+static gboolean terminal_screen_focus_cb (TerminalScreen *screen);
+static gboolean terminal_screen_focus_in_event_cb (TerminalScreen *screen);
+static gboolean terminal_screen_key_press_event_cb (TerminalScreen *screen);
+
 static void update_color_scheme (TerminalScreen *screen);
 
 static gboolean terminal_screen_format_title (TerminalScreen *screen, const char *raw_title, char **old_cooked_title);
@@ -394,6 +401,19 @@
 
   g_signal_connect (screen, "parent-set", G_CALLBACK (parent_set_callback), NULL);
 
+ g_signal_connect (screen, "beep",
+ G_CALLBACK (terminal_screen_beep_cb),
+ NULL);
+ g_signal_connect (screen, "focus",
+ G_CALLBACK (terminal_screen_focus_cb),
+ NULL);
+ g_signal_connect (screen, "focus-in-event",
+ G_CALLBACK (terminal_screen_focus_in_event_cb),
+ NULL);
+ g_signal_connect (screen, "key-press-event",
+ G_CALLBACK (terminal_screen_key_press_event_cb),
+ NULL);
+
 #ifdef GNOME_ENABLE_DEBUG
   _TERMINAL_DEBUG_IF (TERMINAL_DEBUG_GEOMETRY)
     {
@@ -431,6 +451,9 @@
       case PROP_TITLE:
         g_value_set_string (value, terminal_screen_get_title (screen));
         break;
+ case PROP_BELL_RAISED:
+ g_value_set_boolean (value, terminal_screen_get_bell_raised (screen));
+ break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -461,6 +484,9 @@
       case PROP_INITIAL_ENVIRONMENT:
         terminal_screen_set_initial_environment (screen, g_value_get_boxed (value));
         break;
+ case PROP_BELL_RAISED:
+ terminal_screen_set_bell_raised (screen, g_value_get_boolean (value));
+ break;
       case PROP_ICON_TITLE:
       case PROP_ICON_TITLE_SET:
       case PROP_TITLE:
@@ -576,6 +602,14 @@
                          G_TYPE_STRV,
                          G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 
+ g_object_class_install_property
+ (object_class,
+ PROP_BELL_RAISED,
+ g_param_spec_boolean ("bell-raised", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+
   g_type_class_add_private (object_class, sizeof (TerminalScreenPrivate));
 
   /* Precompile the regexes */
@@ -661,6 +695,36 @@
   G_OBJECT_CLASS (terminal_screen_parent_class)->finalize (object);
 }
 
+gboolean
+terminal_screen_beep_cb (TerminalScreen *screen)
+{
+ g_object_set (screen, "bell-raised", TRUE, NULL);
+ return FALSE;
+}
+
+/* The user switched to this tab... */
+gboolean
+terminal_screen_focus_cb (TerminalScreen *screen)
+{
+ g_object_set (screen, "bell-raised", FALSE, NULL);
+ return FALSE;
+}
+
+/* The user switched to the parent window and this tab was the active one... */
+gboolean
+terminal_screen_focus_in_event_cb (TerminalScreen *screen)
+{
+ g_object_set (screen, "bell-raised", FALSE, NULL);
+ return FALSE;
+}
+
+gboolean
+terminal_screen_key_press_event_cb (TerminalScreen *screen)
+{
+ g_object_set (screen, "bell-raised", FALSE, NULL);
+ return FALSE;
+}
+
 TerminalScreen *
 terminal_screen_new (TerminalProfile *profile,
                      char **override_command,
@@ -2314,3 +2378,17 @@
   return TRUE;
 #endif
 }
+
+gboolean
+terminal_screen_get_bell_raised (TerminalScreen *screen)
+{
+ return screen->priv->bell_raised;
+}
+
+void
+terminal_screen_set_bell_raised (TerminalScreen *screen,
+ gboolean raised)
+{
+ screen->priv->bell_raised = raised;
+}
+
Index: src/profile-preferences.glade
===================================================================
--- src/profile-preferences.glade (revision 3436)
+++ src/profile-preferences.glade (working copy)
@@ -291,6 +291,44 @@
  </child>
 
  <child>
+ <widget class="GtkCheckButton" id="highlightonbell-checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Flash window _icon and bold tab title on bell</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="highlightfocusedonbell-checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">..._even if I am working in that tab and window</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
  <widget class="GtkHBox" id="hbox140">
  <property name="visible">True</property>
  <property name="homogeneous">False</property>
Index: src/terminal-tab-label.c
===================================================================
--- src/terminal-tab-label.c (revision 3436)
+++ src/terminal-tab-label.c (working copy)
@@ -22,6 +22,7 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
+#include "terminal-debug.h"
 #include "terminal-tab-label.h"
 
 #define TERMINAL_TAB_LABEL_GET_PRIVATE(tab_label)(G_TYPE_INSTANCE_GET_PRIVATE ((tab_label), TERMINAL_TYPE_TAB_LABEL, TerminalTabLabelPrivate))
@@ -77,6 +78,32 @@
   gtk_widget_set_tooltip_text (hbox, title);
 }
 
+static void
+screen_bell_raised_tab_label_cb (TerminalScreen *screen,
+ GParamSpec *pspec,
+ TerminalTabLabel *tab_label)
+{
+ gboolean bell_raised;
+
+ g_object_get (screen, "bell-raised", &bell_raised, NULL);
+
+ if (bell_raised)
+ {
+ gboolean screen_has_focus;
+ gboolean highlight_focused;
+
+ g_object_get (screen, "has-focus", &screen_has_focus, NULL);
+ highlight_focused = terminal_profile_get_property_boolean (
+ terminal_screen_get_profile (screen),
+ TERMINAL_PROFILE_HIGHLIGHT_FOCUSED_ON_BELL);
+
+ if (!screen_has_focus || highlight_focused)
+ terminal_tab_label_set_bold (tab_label, TRUE);
+ }
+ else
+ terminal_tab_label_set_bold (tab_label, FALSE);
+}
+
 /* public functions */
 
 /* Class implementation */
@@ -161,6 +188,9 @@
   g_signal_connect (close_button, "clicked",
  G_CALLBACK (close_button_clicked_cb), tab_label);
 
+ g_signal_connect (priv->screen, "notify::bell-raised",
+ G_CALLBACK (screen_bell_raised_tab_label_cb), tab_label);
+
   gtk_widget_show_all (hbox);
 
   return object;
Index: src/terminal-screen.h
===================================================================
--- src/terminal-screen.h (revision 3436)
+++ src/terminal-screen.h (working copy)
@@ -70,6 +70,7 @@
                                int flavour,
                                guint state);
   void (* close_screen) (TerminalScreen *screen);
+ void (* bell_raised_handler)(TerminalScreen *screen);
 };
 
 GType terminal_screen_get_type (void) G_GNUC_CONST;
@@ -131,6 +132,10 @@
 
 gboolean terminal_screen_has_foreground_process (TerminalScreen *screen);
 
+gboolean terminal_screen_get_bell_raised (TerminalScreen *screen);
+void terminal_screen_set_bell_raised (TerminalScreen *screen,
+ gboolean raised);
+
 /* Allow scales a bit smaller and a bit larger than the usual pango ranges */
 #define TERMINAL_SCALE_XXX_SMALL (PANGO_SCALE_XX_SMALL/1.2)
 #define TERMINAL_SCALE_XXXX_SMALL (TERMINAL_SCALE_XXX_SMALL/1.2)
Index: src/terminal-profile.c
===================================================================
--- src/terminal-profile.c (revision 3436)
+++ src/terminal-profile.c (working copy)
@@ -80,6 +80,8 @@
   PROP_USE_THEME_COLORS,
   PROP_VISIBLE_NAME,
   PROP_WORD_CHARS,
+ PROP_HIGHLIGHT_ON_BELL,
+ PROP_HIGHLIGHT_FOCUSED_ON_BELL,
   LAST_PROP
 };
 
@@ -97,6 +99,8 @@
 #define KEY_EXIT_ACTION "exit_action"
 #define KEY_FONT "font"
 #define KEY_FOREGROUND_COLOR "foreground_color"
+#define KEY_HIGHLIGHT_ON_BELL "highlight_on_bell"
+#define KEY_HIGHLIGHT_FOCUSED_ON_BELL "highlight_focused_on_bell_focused"
 #define KEY_LOGIN_SHELL "login_shell"
 #define KEY_PALETTE "palette"
 #define KEY_SCROLL_BACKGROUND "scroll_background"
@@ -131,6 +135,8 @@
 #define DEFAULT_EXIT_ACTION (TERMINAL_EXIT_CLOSE)
 #define DEFAULT_FONT ("Monospace 12")
 #define DEFAULT_FOREGROUND_COLOR ("#000000")
+#define DEFAULT_HIGHLIGHT_ON_BELL (FALSE)
+#define DEFAULT_HIGHLIGHT_FOCUSED_ON_BELL (FALSE)
 #define DEFAULT_LOGIN_SHELL (FALSE)
 #define DEFAULT_NAME (NULL)
 #define DEFAULT_PALETTE (terminal_palettes[TERMINAL_PALETTE_TANGO])
@@ -1286,6 +1292,8 @@
 
   TERMINAL_PROFILE_PROPERTY_BOOLEAN (ALLOW_BOLD, DEFAULT_ALLOW_BOLD, KEY_ALLOW_BOLD);
   TERMINAL_PROFILE_PROPERTY_BOOLEAN (DEFAULT_SHOW_MENUBAR, DEFAULT_DEFAULT_SHOW_MENUBAR, KEY_DEFAULT_SHOW_MENUBAR);
+ TERMINAL_PROFILE_PROPERTY_BOOLEAN (HIGHLIGHT_ON_BELL, DEFAULT_HIGHLIGHT_ON_BELL, KEY_HIGHLIGHT_ON_BELL);
+ TERMINAL_PROFILE_PROPERTY_BOOLEAN (HIGHLIGHT_FOCUSED_ON_BELL, DEFAULT_HIGHLIGHT_FOCUSED_ON_BELL, KEY_HIGHLIGHT_FOCUSED_ON_BELL);
   TERMINAL_PROFILE_PROPERTY_BOOLEAN (LOGIN_SHELL, DEFAULT_LOGIN_SHELL, KEY_LOGIN_SHELL);
   TERMINAL_PROFILE_PROPERTY_BOOLEAN (SCROLL_BACKGROUND, DEFAULT_SCROLL_BACKGROUND, KEY_SCROLL_BACKGROUND);
   TERMINAL_PROFILE_PROPERTY_BOOLEAN (SCROLL_ON_KEYSTROKE, DEFAULT_SCROLL_ON_KEYSTROKE, KEY_SCROLL_ON_KEYSTROKE);
Index: src/terminal-profile.h
===================================================================
--- src/terminal-profile.h (revision 3436)
+++ src/terminal-profile.h (working copy)
@@ -80,6 +80,8 @@
 #define TERMINAL_PROFILE_EXIT_ACTION "exit-action"
 #define TERMINAL_PROFILE_FONT "font"
 #define TERMINAL_PROFILE_FOREGROUND_COLOR "foreground-color"
+#define TERMINAL_PROFILE_HIGHLIGHT_ON_BELL "highlight-on-bell"
+#define TERMINAL_PROFILE_HIGHLIGHT_FOCUSED_ON_BELL "highlight-focused-on-bell"
 #define TERMINAL_PROFILE_LOGIN_SHELL "login-shell"
 #define TERMINAL_PROFILE_NAME "name"
 #define TERMINAL_PROFILE_PALETTE "palette"
Index: src/terminal-window.c
===================================================================
--- src/terminal-window.c (revision 3436)
+++ src/terminal-window.c (working copy)
@@ -1345,6 +1345,45 @@
   terminal_window_remove_screen (window, screen);
 }
 
+static void
+screen_bell_raised_window_cb (TerminalScreen *screen,
+ GParamSpec *pspec,
+ TerminalWindow *window)
+{
+ gboolean bell_raised;
+
+ g_object_get (screen, "bell-raised", &bell_raised, NULL);
+ if (bell_raised)
+ {
+ gboolean should_highlight;
+
+ should_highlight = terminal_profile_get_property_boolean (
+ terminal_screen_get_profile (screen),
+ TERMINAL_PROFILE_HIGHLIGHT_ON_BELL);
+
+ if (should_highlight)
+ {
+ gboolean has_toplevel_focus;
+ gboolean highlight_focused;
+
+ g_object_get (window,
+ "has-toplevel-focus", &has_toplevel_focus,
+ NULL);
+
+ highlight_focused = terminal_profile_get_property_boolean (
+ terminal_screen_get_profile (screen),
+ TERMINAL_PROFILE_HIGHLIGHT_FOCUSED_ON_BELL);
+
+ if (!has_toplevel_focus || highlight_focused)
+ gtk_window_set_urgency_hint (GTK_WINDOW (window), TRUE);
+ }
+ }
+ else
+ {
+ gtk_window_set_urgency_hint (GTK_WINDOW (window), FALSE);
+ }
+}
+
 static gboolean
 terminal_window_accel_activate_cb (GtkAccelGroup *accel_group,
                                    GObject *acceleratable,
@@ -1571,6 +1610,13 @@
   terminal_window_update_encoding_menu (window);
 }
 
+static gboolean
+terminal_window_focus_cb (TerminalWindow *window)
+{
+ gtk_window_set_urgency_hint (GTK_WINDOW (window), FALSE);
+ return FALSE;
+}
+
 static void
 terminal_window_init (TerminalWindow *window)
 {
@@ -1873,6 +1919,10 @@
 
   terminal_window_update_size_to_menu (window);
 
+ g_signal_connect (window, "focus-in-event",
+ G_CALLBACK (terminal_window_focus_cb), NULL);
+
+
   /* We have to explicitly call this, since screen-changed is NOT
    * emitted for the toplevel the first time!
    */
@@ -2601,6 +2651,10 @@
   g_signal_connect (screen, "close-screen",
                     G_CALLBACK (screen_close_cb), window);
 
+ g_signal_connect (screen, "notify::bell-raised",
+ G_CALLBACK (screen_bell_raised_window_cb), window);
+
+
   update_notebook (window);
 
   update_tab_visibility (window, 0);
@@ -2690,6 +2744,10 @@
                                         G_CALLBACK (screen_close_cb),
                                         window);
 
+ g_signal_handlers_disconnect_by_func (screen,
+ G_CALLBACK (screen_bell_raised_window_cb),
+ window);
+
   priv->terms--;
 
   update_notebook (window);
Index: src/gnome-terminal.schemas.in
===================================================================
--- src/gnome-terminal.schemas.in (revision 3436)
+++ src/gnome-terminal.schemas.in (working copy)
@@ -247,6 +247,41 @@
     </schema>
 
     <schema>
+ <key>/schemas/apps/gnome-terminal/profiles/Default/highlight_on_bell</key>
+
+ <applyto>/apps/gnome-terminal/profiles/Default/highlight_on_bell</applyto>
+ <owner>gnome-terminal</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Whether to flash the window icon and bold the tab when the terminal emits a bell</short>
+ <long>
+ If true, the X urgency hint will be set on the window
+ and the tab's title will be made bold when the terminal
+ emits a bell.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnome-terminal/profiles/Default/highlight_focus_on_bell</key>
+
+ <applyto>/apps/gnome-terminal/profiles/Default/highlight_focus_on_bell</applyto>
+ <owner>gnome-terminal</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Whether to highlight the tab and flash the window icon when the terminal emits a bell even if the tab is focused</short>
+ <long>
+ If true and the GNOME Terminal window doesn't have the
+ focus, the X urgency hint will be set on the window.
+ If true and the GNOME Terminal tab doesn't have the
+ focus, the tab's title will made bold.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
       <key>/schemas/apps/gnome-terminal/profiles/Default/word_chars</key>
       <applyto>/apps/gnome-terminal/profiles/Default/word_chars</applyto>
       <owner>gnome-terminal</owner>
Index: src/profile-editor.c
===================================================================
--- src/profile-editor.c (revision 3436)
+++ src/profile-editor.c (working copy)
@@ -217,6 +217,14 @@
     SET_SENSITIVE ("bell-checkbutton",
                    !terminal_profile_property_locked (profile, TERMINAL_PROFILE_SILENT_BELL));
 
+ if (!prop_name || prop_name == I_(TERMINAL_PROFILE_HIGHLIGHT_ON_BELL))
+ SET_SENSITIVE ("highlightonbell-checkbutton",
+ !terminal_profile_property_locked (profile, TERMINAL_PROFILE_HIGHLIGHT_ON_BELL));
+
+ if (!prop_name || prop_name == I_(TERMINAL_PROFILE_HIGHLIGHT_FOCUSED_ON_BELL))
+ SET_SENSITIVE ("highlightfocusedonbell-checkbutton",
+ !terminal_profile_property_locked (profile, TERMINAL_PROFILE_HIGHLIGHT_FOCUSED_ON_BELL));
+
   if (!prop_name || prop_name == I_(TERMINAL_PROFILE_WORD_CHARS))
     SET_SENSITIVE ("word-chars-entry",
                    !terminal_profile_property_locked (profile, TERMINAL_PROFILE_WORD_CHARS));
@@ -812,6 +820,8 @@
   CONNECT ("exit-action-combobox", TERMINAL_PROFILE_EXIT_ACTION);
   CONNECT ("font-selector", TERMINAL_PROFILE_FONT);
   CONNECT ("foreground-colorpicker", TERMINAL_PROFILE_FOREGROUND_COLOR);
+ CONNECT ("highlightonbell-checkbutton", TERMINAL_PROFILE_HIGHLIGHT_ON_BELL);
+ CONNECT ("highlightfocusedonbell-checkbutton", TERMINAL_PROFILE_HIGHLIGHT_FOCUSED_ON_BELL);
   CONNECT ("image-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
   CONNECT ("login-shell-checkbutton", TERMINAL_PROFILE_LOGIN_SHELL);
   CONNECT ("profile-name-entry", TERMINAL_PROFILE_VISIBLE_NAME);
Index: help/C/gnome-terminal.xml
===================================================================
--- help/C/gnome-terminal.xml (revision 3436)
+++ help/C/gnome-terminal.xml (working copy)
@@ -857,6 +857,25 @@
              </listitem>
           </varlistentry>
           <varlistentry>
+ <term>
+ <guilabel>Flash window icon and bold the tab title on bell</guilabel> </term>
+ <listitem>
+ <para>
+ Select this option to bold the tab title and flash the window icon if the terminal emits a bell.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <guilabel>Flash window icon and bold the tab title on bell even if I'm working in that tab</guilabel> </term>
+ <listitem>
+ <para>
+ Select this option to make the above option apply even if the tab is focused
+ (or if the window is focused if there are no tabs).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
              <term>
                 <guilabel>Select-by-word characters</guilabel> </term>
              <listitem>