[gnome-terminal] Don't flash restored windows



commit 59d7953002d1e6d2f6a11d26a76c1f81998f58d4
Author: Christian Persch <chpe gnome org>
Date:   Sun Aug 16 13:41:02 2009 +0200

    Don't flash restored windows
    
    Clear the demands-attention flag for restored windows on map, so they
    don't flash the taskbar. Bug #586308.

 src/terminal-app.c     |   14 ++++++++++++--
 src/terminal-options.c |   11 +++++++----
 src/terminal-options.h |    3 +++
 src/terminal-window.c  |   15 +++++++++++++++
 src/terminal-window.h  |    2 ++
 5 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/src/terminal-app.c b/src/terminal-app.c
index bcc7bbc..bc5d957 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -137,6 +137,12 @@ enum
   NUM_COLUMNS
 };
 
+enum
+{
+  SOURCE_DEFAULT = 0,
+  SOURCE_SESSION = 1
+};
+
 static TerminalApp *global_app = NULL;
 
 #define MONOSPACE_FONT_DIR "/desktop/gnome/interface"
@@ -1684,7 +1690,7 @@ terminal_app_handle_options (TerminalApp *app,
 
       key_file = g_key_file_new ();
       result = g_key_file_load_from_file (key_file, options->config_file, 0, error) &&
-               terminal_options_merge_config (options, key_file, error);
+               terminal_options_merge_config (options, key_file, SOURCE_DEFAULT, error);
       g_key_file_free (key_file);
 
       if (!result)
@@ -1705,7 +1711,7 @@ terminal_app_handle_options (TerminalApp *app,
 
       key_file = egg_sm_client_get_state_file (sm_client);
       if (key_file != NULL &&
-          !terminal_options_merge_config (options, key_file, error))
+          !terminal_options_merge_config (options, key_file, SOURCE_SESSION, error))
         return FALSE;
     }
 }
@@ -1725,6 +1731,10 @@ terminal_app_handle_options (TerminalApp *app,
       /* Create & setup new window */
       window = terminal_app_new_window (app, gdk_screen);
 
+      /* Restored windows shouldn't demand attention; see bug #586308. */
+      if (iw->source_tag == SOURCE_SESSION)
+        terminal_window_set_is_restored (window);
+
       if (options->startup_id)
         terminal_window_set_startup_id (window, options->startup_id);
 
diff --git a/src/terminal-options.c b/src/terminal-options.c
index 7522ce5..5980a3d 100644
--- a/src/terminal-options.c
+++ b/src/terminal-options.c
@@ -66,11 +66,12 @@ initial_tab_free (InitialTab *it)
 }
 
 static InitialWindow*
-initial_window_new (void)
+initial_window_new (guint source_tag)
 {
   InitialWindow *iw;
 
   iw = g_slice_new0 (InitialWindow);
+  iw->source_tag = source_tag;
 
   return iw;
 }
@@ -117,7 +118,7 @@ ensure_top_window (TerminalOptions *options)
 
   if (options->initial_windows == NULL)
     {
-      iw = initial_window_new ();
+      iw = initial_window_new (0);
       iw->tabs = g_list_append (NULL, initial_tab_new (NULL, FALSE));
       apply_defaults (options, iw);
 
@@ -155,7 +156,7 @@ add_new_window (TerminalOptions *options,
 {
   InitialWindow *iw;
 
-  iw = initial_window_new ();
+  iw = initial_window_new (0);
   iw->tabs = g_list_prepend (NULL, initial_tab_new (profile, is_id));
   apply_defaults (options, iw);
 
@@ -776,6 +777,7 @@ terminal_options_parse (const char *working_directory,
  * terminal_options_merge_config:
  * @options:
  * @key_file: a #GKeyFile containing to merge the options from
+ * @source_tag: a source_tag to use in new #InitialWindow<!-- -->s
  * @error: a #GError to fill in
  *
  * Merges the saved options from @key_file into @options.
@@ -786,6 +788,7 @@ terminal_options_parse (const char *working_directory,
 gboolean
 terminal_options_merge_config (TerminalOptions *options,
                                GKeyFile *key_file,
+                               guint source_tag,
                                GError **error)
 {
   int version, compat_version;
@@ -830,7 +833,7 @@ terminal_options_merge_config (TerminalOptions *options,
       if (!tab_groups)
         continue; /* no tabs in this window, skip it */
 
-      iw = initial_window_new ();
+      iw = initial_window_new (source_tag);
       initial_windows = g_list_append (initial_windows, iw);
       apply_defaults (options, iw);
 
diff --git a/src/terminal-options.h b/src/terminal-options.h
index 5dfab3a..bd5aa79 100644
--- a/src/terminal-options.h
+++ b/src/terminal-options.h
@@ -68,6 +68,8 @@ typedef struct
 
 typedef struct
 {
+  guint source_tag;
+
   GList *tabs; /* list of InitialTab */
 
   gboolean force_menubar_state;
@@ -101,6 +103,7 @@ TerminalOptions *terminal_options_parse (const char *working_directory,
 
 gboolean terminal_options_merge_config (TerminalOptions *options,
                                         GKeyFile *key_file,
+                                        guint source_tag,
                                         GError **error);
 
 void terminal_options_ensure_window (TerminalOptions *options);
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 95c4dfa..4879b93 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -2155,6 +2155,21 @@ terminal_window_new (void)
   return g_object_new (TERMINAL_TYPE_WINDOW, NULL);
 }
 
+/**
+ * terminal_window_set_is_restored:
+ * @window:
+ *
+ * Marks the window as restored from session.
+ */
+void
+terminal_window_set_is_restored (TerminalWindow *window)
+{
+  g_return_if_fail (TERMINAL_IS_WINDOW (window));
+  g_return_if_fail (!GTK_WIDGET_MAPPED (window));
+
+  window->priv->clear_demands_attention = TRUE;
+}
+
 static void
 update_notebook (TerminalWindow *window)
 {
diff --git a/src/terminal-window.h b/src/terminal-window.h
index 3376754..6d0807d 100644
--- a/src/terminal-window.h
+++ b/src/terminal-window.h
@@ -53,6 +53,8 @@ GType terminal_window_get_type (void) G_GNUC_CONST;
 
 TerminalWindow* terminal_window_new (void);
 
+void terminal_window_set_is_restored (TerminalWindow *window);
+
 GtkUIManager *terminal_window_get_ui_manager (TerminalWindow *window);
 
 void terminal_window_add_screen (TerminalWindow *window,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]