diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c index 0809118..466bb08 100644 --- a/terminal/terminal-preferences.c +++ b/terminal/terminal-preferences.c @@ -70,6 +70,7 @@ enum PROP_ACCEL_SWITCH_TO_TAB8, PROP_ACCEL_SWITCH_TO_TAB9, PROP_ACCEL_CONTENTS, + PROP_ACCEL_INACTIVITY, PROP_BACKGROUND_MODE, PROP_BACKGROUND_IMAGE_FILE, PROP_BACKGROUND_IMAGE_STYLE, @@ -132,7 +133,10 @@ enum PROP_TERM, PROP_WORD_CHARS, PROP_TAB_ACTIVITY_COLOR, + PROP_TAB_BELL_COLOR, + PROP_TAB_INACTIVITY_COLOR, PROP_TAB_ACTIVITY_TIMEOUT, + PROP_TAB_INACTIVITY_TIMEOUT, N_PROPERTIES, }; @@ -244,6 +248,15 @@ transform_string_to_uint (const GValue *src, static void +transform_string_to_int (const GValue *src, + GValue *dst) +{ + g_value_set_int (dst, strtoul (g_value_get_string (src), NULL, 10)); +} + + + +static void transform_string_to_enum (const GValue *src, GValue *dst) { @@ -283,6 +296,8 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass) g_value_register_transform_func (G_TYPE_STRING, GDK_TYPE_COLOR, transform_string_to_color); if (!g_value_type_transformable (G_TYPE_STRING, G_TYPE_DOUBLE)) g_value_register_transform_func (G_TYPE_STRING, G_TYPE_DOUBLE, transform_string_to_double); + if (!g_value_type_transformable (G_TYPE_STRING, G_TYPE_INT)) + g_value_register_transform_func (G_TYPE_STRING, G_TYPE_INT, transform_string_to_int); if (!g_value_type_transformable (G_TYPE_STRING, G_TYPE_UINT)) g_value_register_transform_func (G_TYPE_STRING, G_TYPE_UINT, transform_string_to_uint); if (!g_value_type_transformable (G_TYPE_STRING, GTK_TYPE_POSITION_TYPE)) @@ -609,6 +624,17 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass) EXO_PARAM_READWRITE)); /** + * TerminalPreferences:accel-inactivity: + **/ + g_object_class_install_property (gobject_class, + PROP_ACCEL_INACTIVITY, + g_param_spec_string ("accel-inactivity", + _("Inactivity"), + "AccelInactivity", + "i", + EXO_PARAM_READWRITE)); + + /** * TerminalPreferences:background-mode: **/ g_object_class_install_property (gobject_class, @@ -924,15 +950,49 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass) "TabActivityColor", "#afff00000000", EXO_PARAM_READWRITE)); + + /** + * TerminalPreferences:tab-bell-color: + **/ + g_object_class_install_property (gobject_class, + PROP_TAB_BELL_COLOR, + g_param_spec_string ("tab-bell-color", + "tab-bell-color", + "TabBellColor", + "#0000afff0000", + EXO_PARAM_READWRITE)); + + /** + * TerminalPreferences:tab-inactivity-color: + **/ + g_object_class_install_property (gobject_class, + PROP_TAB_INACTIVITY_COLOR, + g_param_spec_string ("tab-inactivity-color", + "tab-inactivity-color", + "TabInactivityColor", + "#00000000afff", + EXO_PARAM_READWRITE)); + /** * TerminalPreferences:tab-activity-timeout: **/ g_object_class_install_property (gobject_class, PROP_TAB_ACTIVITY_TIMEOUT, - g_param_spec_uint ("tab-activity-timeout", + g_param_spec_int ("tab-activity-timeout", "tab-activity-timeout", "TabActivityTimeout", - 0, 30, 2, + -1, 30, 2, + EXO_PARAM_READWRITE)); + + /** + * TerminalPreferences:tab-inactivity-timeout: + **/ + g_object_class_install_property (gobject_class, + PROP_TAB_INACTIVITY_TIMEOUT, + g_param_spec_uint ("tab-inactivity-timeout", + "tab-inactivity-timeout", + "TabInactivityTimeout", + 1, 30, 5, EXO_PARAM_READWRITE)); /** diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c index 0333206..284a24d 100644 --- a/terminal/terminal-screen.c +++ b/terminal/terminal-screen.c @@ -106,6 +106,8 @@ static void terminal_screen_update_title (TerminalScreen static void terminal_screen_update_word_chars (TerminalScreen *screen); static void terminal_screen_vte_child_exited (VteTerminal *terminal, TerminalScreen *screen); +static void terminal_screen_bell_notification (VteTerminal *terminal, + TerminalScreen *screen); static void terminal_screen_vte_eof (VteTerminal *terminal, TerminalScreen *screen); static GtkWidget *terminal_screen_vte_get_context_menu (TerminalWidget *widget, @@ -153,7 +155,10 @@ struct _TerminalScreen guint launch_idle_id; guint activity_timeout_id; + guint inactivity_timeout_id; time_t last_size_change; + gboolean bell_notification; + gboolean monitor_inactivity; }; @@ -234,10 +239,13 @@ terminal_screen_init (TerminalScreen *screen) { screen->working_directory = g_get_current_dir (); screen->session_id = ++screen_last_session_id; + screen->bell_notification = FALSE; + screen->monitor_inactivity = FALSE; screen->terminal = g_object_new (TERMINAL_TYPE_WIDGET, NULL); g_object_connect (G_OBJECT (screen->terminal), "signal::child-exited", G_CALLBACK (terminal_screen_vte_child_exited), screen, + "signal::beep", G_CALLBACK (terminal_screen_bell_notification), screen, "signal::eof", G_CALLBACK (terminal_screen_vte_eof), screen, "signal::context-menu", G_CALLBACK (terminal_screen_vte_get_context_menu), screen, "signal::selection-changed", G_CALLBACK (terminal_screen_vte_selection_changed), screen, @@ -1014,6 +1022,15 @@ terminal_screen_update_word_chars (TerminalScreen *screen) static void +terminal_screen_bell_notification (VteTerminal *terminal, + TerminalScreen *screen) +{ + screen->bell_notification = TRUE; +} + + + +static void terminal_screen_vte_child_exited (VteTerminal *terminal, TerminalScreen *screen) { @@ -1134,6 +1151,29 @@ terminal_screen_reset_activity_timeout (gpointer user_data) GTK_STATE_ACTIVE, NULL); GDK_THREADS_LEAVE (); + /* reset bell notification pending */ + TERMINAL_SCREEN (user_data)->bell_notification = FALSE; + + return FALSE; +} + + + +static gboolean +terminal_screen_reset_inactivity_timeout (gpointer user_data) +{ + gboolean has_fg; + GdkColor color; + + has_fg = terminal_preferences_get_color (TERMINAL_SCREEN(user_data)->preferences, + "tab-inactivity-color", &color); + + /* reset label color */ + GDK_THREADS_ENTER (); + gtk_widget_modify_fg (TERMINAL_SCREEN (user_data)->tab_label, + GTK_STATE_ACTIVE, has_fg ? &color : NULL); + GDK_THREADS_LEAVE (); + return FALSE; } @@ -1147,11 +1187,31 @@ terminal_screen_reset_activity_destroyed (gpointer user_data) +void +terminal_screen_reset_inactivity (TerminalScreen *screen) +{ + terminal_return_if_fail (TERMINAL_IS_SCREEN (screen)); + + terminal_screen_reset_activity_timeout (screen); + if (screen->inactivity_timeout_id != 0) + g_source_remove (screen->inactivity_timeout_id); +} + + + +static void +terminal_screen_reset_inactivity_destroyed (gpointer user_data) +{ + TERMINAL_SCREEN (user_data)->inactivity_timeout_id = 0; +} + + + static void terminal_screen_vte_window_contents_changed (VteTerminal *terminal, TerminalScreen *screen) { - guint timeout; + gint timeout; GdkColor color; gboolean has_fg; @@ -1168,22 +1228,43 @@ terminal_screen_vte_window_contents_changed (VteTerminal *terminal, /* get the reset time, leave if this feature is disabled */ g_object_get (G_OBJECT (screen->preferences), "tab-activity-timeout", &timeout, NULL); - if (timeout < 1) + if (timeout == 0) return; /* set label color */ - has_fg = terminal_preferences_get_color (screen->preferences, "tab-activity-color", &color); - gtk_widget_modify_fg (screen->tab_label, GTK_STATE_ACTIVE, has_fg ? &color : NULL); + if (screen->monitor_inactivity) + { + terminal_screen_reset_inactivity (screen); - /* stop running reset timeout */ - if (screen->activity_timeout_id != 0) - g_source_remove (screen->activity_timeout_id); + g_object_get (G_OBJECT (screen->preferences), "tab-inactivity-timeout", &timeout, NULL); + screen->inactivity_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, timeout, + terminal_screen_reset_inactivity_timeout, + screen, terminal_screen_reset_inactivity_destroyed); + } + else + { + if (screen->bell_notification) + { + has_fg = terminal_preferences_get_color (screen->preferences, "tab-bell-color", &color); + gtk_widget_modify_fg (screen->tab_label, GTK_STATE_ACTIVE, has_fg ? &color : NULL); + } + else + { + has_fg = terminal_preferences_get_color (screen->preferences, "tab-activity-color", &color); + gtk_widget_modify_fg (screen->tab_label, GTK_STATE_ACTIVE, has_fg ? &color : NULL); + } + + /* stop running reset timeout */ + if (screen->activity_timeout_id != 0) + g_source_remove (screen->activity_timeout_id); - /* start new timeout to unset the activity */ - screen->activity_timeout_id = - g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, timeout, - terminal_screen_reset_activity_timeout, - screen, terminal_screen_reset_activity_destroyed); + /* start new timeout to unset the activity */ + if (timeout != -1) + screen->activity_timeout_id = + g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, timeout, + terminal_screen_reset_activity_timeout, + screen, terminal_screen_reset_activity_destroyed); + } } @@ -1803,6 +1884,15 @@ terminal_screen_reset (TerminalScreen *screen, +void +terminal_screen_toggle_inactivity_monitor (TerminalScreen *screen) +{ + terminal_return_if_fail (TERMINAL_IS_SCREEN (screen)); + screen->monitor_inactivity = screen->monitor_inactivity ? FALSE : TRUE; +} + + + /** * terminal_screen_im_append_menuitems: * @screen : A #TerminalScreen. @@ -1870,11 +1960,9 @@ terminal_screen_reset_activity (TerminalScreen *screen) { terminal_return_if_fail (TERMINAL_IS_SCREEN (screen)); + terminal_screen_reset_activity_timeout (screen); if (screen->activity_timeout_id != 0) - { - g_source_remove (screen->activity_timeout_id); - terminal_screen_reset_activity_timeout (screen); - } + g_source_remove (screen->activity_timeout_id); } diff --git a/terminal/terminal-screen.h b/terminal/terminal-screen.h index 7498409..672dd06 100644 --- a/terminal/terminal-screen.h +++ b/terminal/terminal-screen.h @@ -77,6 +77,8 @@ void terminal_screen_paste_primary (TerminalScreen *scree void terminal_screen_reset (TerminalScreen *screen, gboolean clear); +void terminal_screen_toggle_inactivity_monitor (TerminalScreen *screen); + void terminal_screen_im_append_menuitems (TerminalScreen *screen, GtkMenuShell *menushell); @@ -84,6 +86,8 @@ GSList *terminal_screen_get_restart_command (TerminalScreen *scree void terminal_screen_reset_activity (TerminalScreen *screen); +void terminal_screen_reset_inactivity (TerminalScreen *screen); + GtkWidget *terminal_screen_get_tab_label (TerminalScreen *screen); void terminal_screen_focus (TerminalScreen *screen); diff --git a/terminal/terminal-window-ui.h b/terminal/terminal-window-ui.h index bd39fe2..60ca78b 100644 --- a/terminal/terminal-window-ui.h +++ b/terminal/terminal-window-ui.h @@ -1,4 +1,4 @@ -/* automatically generated from ./terminal-window-ui.xml */ +/* automatically generated from terminal-window-ui.xml */ #ifdef __SUNPRO_C #pragma align 4 (terminal_window_ui) #endif @@ -19,19 +19,19 @@ static const char terminal_window_ui[] = "\" />" - "" - "" - "" + "" + "" }; -static const unsigned terminal_window_ui_length = 1488u; +static const unsigned terminal_window_ui_length = 1520u; diff --git a/terminal/terminal-window-ui.xml b/terminal/terminal-window-ui.xml index 9709078..3016d56 100644 --- a/terminal/terminal-window-ui.xml +++ b/terminal/terminal-window-ui.xml @@ -35,6 +35,7 @@ + diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c index 6294ef2..7a95f43 100644 --- a/terminal/terminal-window.c +++ b/terminal/terminal-window.c @@ -176,6 +176,8 @@ static void terminal_window_action_set_title (GtkAction TerminalWindow *window); static void terminal_window_action_reset (GtkAction *action, TerminalWindow *window); +static void terminal_window_action_toggle_inactivity (GtkAction *action, + TerminalWindow *window); static void terminal_window_action_reset_and_clear (GtkAction *action, TerminalWindow *window); static void terminal_window_action_contents (GtkAction *action, @@ -235,6 +237,7 @@ static const GtkActionEntry action_entries[] = { "set-title", NULL, N_ ("_Set Title..."), NULL, N_ ("Set a custom title for the current tab"), G_CALLBACK (terminal_window_action_set_title), }, { "reset", GTK_STOCK_REFRESH, N_ ("_Reset"), NULL, N_ ("Reset"), G_CALLBACK (terminal_window_action_reset), }, { "reset-and-clear", GTK_STOCK_CLEAR, N_ ("Reset and C_lear"), NULL, N_ ("Reset and clear"), G_CALLBACK (terminal_window_action_reset_and_clear), }, + { "inactivity", NULL, N_ ("Monitor _Inactivity"), NULL, N_ ("Toggle inactivity monitoring"), G_CALLBACK (terminal_window_action_toggle_inactivity), }, { "go-menu", NULL, N_ ("_Go"), NULL, NULL, NULL, }, { "prev-tab", GTK_STOCK_GO_BACK, N_ ("_Previous Tab"), NULL, N_ ("Switch to previous tab"), G_CALLBACK (terminal_window_action_prev_tab), }, { "next-tab", GTK_STOCK_GO_FORWARD, N_ ("_Next Tab"), NULL, N_ ("Switch to next tab"), G_CALLBACK (terminal_window_action_next_tab), }, @@ -833,6 +836,9 @@ terminal_window_notebook_page_switched (GtkNotebook *notebook, /* reset the activity counter */ terminal_screen_reset_activity (active); + /* reset the inactivity counter */ + terminal_screen_reset_inactivity (active); + /* set the new geometry widget */ if (G_LIKELY (!was_null)) terminal_screen_set_window_geometry_hints (active, GTK_WINDOW (window)); @@ -1595,6 +1601,16 @@ terminal_window_action_set_title (GtkAction *action, static void +terminal_window_action_toggle_inactivity (GtkAction *action, + TerminalWindow *window) +{ + if (G_LIKELY (window->active != NULL)) + terminal_screen_toggle_inactivity_monitor (window->active); +} + + + +static void terminal_window_action_reset (GtkAction *action, TerminalWindow *window) {