[Xfce4-commits] [apps/xfce4-terminal] 01/01: Add urgent bell functionality: MiscBellUrgent option

noreply at xfce.org noreply at xfce.org
Tue Aug 2 16:41:11 CEST 2016


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit 43b8d559a2f8be119b9c6afd4daccf0405e346a3
Author: Igor <f2404 at yandex.ru>
Date:   Tue Aug 2 17:39:12 2016 +0300

    Add urgent bell functionality: MiscBellUrgent option
    
    Fixes https://bugzilla.xfce.org/show_bug.cgi?id=9928
---
 terminal/terminal-app.c         | 28 ++++++++++++++++++++++++++++
 terminal/terminal-preferences.c | 11 +++++++++++
 terminal/terminal-screen.c      | 32 ++++++++++++++++++++++++++++----
 3 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/terminal/terminal-app.c b/terminal/terminal-app.c
index 0f08061..d7300ed 100644
--- a/terminal/terminal-app.c
+++ b/terminal/terminal-app.c
@@ -58,6 +58,9 @@ static void               terminal_app_update_accels            (TerminalApp
 static void               terminal_app_update_mnemonics         (TerminalApp        *app);
 static gboolean           terminal_app_accel_map_load           (gpointer            user_data);
 static gboolean           terminal_app_accel_map_save           (gpointer            user_data);
+static void               terminal_app_unset_urgent_bell        (TerminalWindow     *window,
+                                                                 GdkEvent           *event,
+                                                                 TerminalApp        *app);
 static void               terminal_app_new_window               (TerminalWindow     *window,
                                                                  const gchar        *working_directory,
                                                                  TerminalApp        *app);
@@ -291,6 +294,27 @@ terminal_app_accel_map_load (gpointer user_data)
 
 
 static void
+terminal_app_unset_urgent_bell (TerminalWindow *window,
+                                GdkEvent       *event,
+                                TerminalApp    *app)
+{
+  GtkWidget *toplevel;
+  gboolean   enabled;
+
+  g_object_get (G_OBJECT (app->preferences),
+                "misc-bell-urgent", &enabled,
+                NULL);
+
+  if (!enabled)
+    return;
+
+  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (window));
+  gtk_window_set_urgency_hint (GTK_WINDOW (toplevel), FALSE);
+}
+
+
+
+static void
 terminal_app_take_window (TerminalApp *app,
                           GtkWindow   *window)
 {
@@ -308,6 +332,10 @@ terminal_app_take_window (TerminalApp *app,
                     G_CALLBACK (terminal_app_new_window), app);
   g_signal_connect (G_OBJECT (window), "new-window-with-screen",
                     G_CALLBACK (terminal_app_new_window_with_terminal), app);
+  g_signal_connect (G_OBJECT (window), "focus-in-event",
+                    G_CALLBACK (terminal_app_unset_urgent_bell), app);
+  g_signal_connect (G_OBJECT (window), "key-release-event",
+                    G_CALLBACK (terminal_app_unset_urgent_bell), app);
   app->windows = g_slist_prepend (app->windows, window);
 }
 
diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index 0cfad95..dbd6ebf 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -76,6 +76,7 @@ enum
   PROP_FONT_NAME,
   PROP_MISC_ALWAYS_SHOW_TABS,
   PROP_MISC_BELL,
+  PROP_MISC_BELL_URGENT,
   PROP_MISC_BORDERS_DEFAULT,
   PROP_MISC_CURSOR_BLINKS,
   PROP_MISC_CURSOR_SHAPE,
@@ -655,6 +656,16 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
+   * TerminalPreferences:misc-bell-urgent:
+   **/
+  preferences_props[PROP_MISC_BELL_URGENT] =
+      g_param_spec_boolean ("misc-bell-urgent",
+                            NULL,
+                            "MiscBellUrgent",
+                            FALSE,
+                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  /**
    * TerminalPreferences:misc-borders-default:
    **/
   preferences_props[PROP_MISC_BORDERS_DEFAULT] =
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index f2f75d5..b721d75 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -144,6 +144,9 @@ static void       terminal_screen_update_label_orientation      (TerminalScreen
 static gchar     *terminal_screen_zoom_font                     (TerminalScreen        *screen,
                                                                  gchar                 *font_name,
                                                                  TerminalZoomLevel      zoom);
+static void       terminal_screen_urgent_bell                   (TerminalWidget        *widget,
+                                                                 TerminalScreen        *screen);
+
 
 
 struct _TerminalScreenClass
@@ -1033,6 +1036,7 @@ terminal_screen_update_misc_bell (TerminalScreen *screen)
   gboolean bval;
   g_object_get (G_OBJECT (screen->preferences), "misc-bell", &bval, NULL);
   vte_terminal_set_audible_bell (VTE_TERMINAL (screen->terminal), bval);
+  g_signal_connect (screen->terminal, "bell", G_CALLBACK (terminal_screen_urgent_bell), screen);
 }
 
 
@@ -1501,10 +1505,10 @@ terminal_screen_update_label_orientation (TerminalScreen *screen)
 
 
 
-static
-gchar* terminal_screen_zoom_font (TerminalScreen *screen,
-                                  gchar *font_name,
-                                  TerminalZoomLevel zoom)
+static gchar*
+terminal_screen_zoom_font (TerminalScreen *screen,
+                           gchar *font_name,
+                           TerminalZoomLevel zoom)
 {
   gdouble               scale;
   PangoFontDescription *font_desc;
@@ -1557,6 +1561,26 @@ gchar* terminal_screen_zoom_font (TerminalScreen *screen,
 
 
 
+static void
+terminal_screen_urgent_bell (TerminalWidget *widget,
+                             TerminalScreen *screen)
+{
+  GtkWidget *toplevel;
+  gboolean   enabled;
+
+  terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
+
+  g_object_get (G_OBJECT (screen->preferences), "misc-bell-urgent", &enabled, NULL);
+
+  if (!enabled)
+    return;
+
+  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
+  gtk_window_set_urgency_hint (GTK_WINDOW (toplevel), TRUE);
+}
+
+
+
 /**
  * terminal_screen_launch_child:
  * @screen  : A #TerminalScreen.

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list