2a01f73
From 4f4d8b52b9e8db40513cb9b928218ae571e7ec79 Mon Sep 17 00:00:00 2001
Debarshi Ray 7308132
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 7308132
Date: Wed, 7 Jan 2015 16:01:00 +0100
Debarshi Ray 525ec1b
Subject: [PATCH 1/6] emulation: Add sequences and signals for desktop
Debarshi Ray 525ec1b
 notification
Debarshi Ray 7308132
Debarshi Ray 7308132
Add sequences
Debarshi Ray 7308132
  OSC 777 ; notify ; SUMMARY ; BODY BEL
Debarshi Ray 7308132
  OSC 777 ; notify ; SUMMARY BEL
Debarshi Ray 7308132
  OSC 777 ; notify ; SUMMARY ; BODY ST
Debarshi Ray 7308132
  OSC 777 ; notify ; SUMMARY ST
Debarshi Ray 7308132
Debarshi Ray 7308132
that let terminal applications send a notification to the desktop
Debarshi Ray 7308132
environment.
Debarshi Ray 7308132
Debarshi Ray 7308132
Based on Enlightenment's Terminology:
Debarshi Ray 7308132
https://phab.enlightenment.org/T1765
Debarshi Ray 7308132
Debarshi Ray 7308132
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 7308132
---
Debarshi Ray 3069778
 src/caps.cc           |  4 +++
Debarshi Ray 3069778
 src/marshal.list      |  1 +
Debarshi Ray 2952472
 src/vte.cc            | 12 +++++++
Debarshi Ray 525ec1b
 src/vte/vteterminal.h |  3 +-
Debarshi Ray 2952472
 src/vtegtk.cc         | 21 ++++++++++++
Debarshi Ray 2952472
 src/vtegtk.hh         |  1 +
Debarshi Ray a9aabb4
 src/vteinternal.hh    |  5 +++
Debarshi Ray 3069778
 src/vteseq-n.gperf    |  1 +
Debarshi Ray 3069778
 src/vteseq.cc         | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++
Debarshi Ray 525ec1b
 9 files changed, 137 insertions(+), 1 deletion(-)
Debarshi Ray 7308132
Debarshi Ray 3069778
diff --git a/src/caps.cc b/src/caps.cc
2a01f73
index 47571269b883..3e496ff33194 100644
Debarshi Ray 3069778
--- a/src/caps.cc
Debarshi Ray 3069778
+++ b/src/caps.cc
Debarshi Ray 955c24e
@@ -255,6 +255,8 @@ const char _vte_xterm_capability_strings[] =
Debarshi Ray 7308132
         ENTRY(OSC "118" BEL, "reset-tek-cursor-color")
Debarshi Ray 7308132
         ENTRY(OSC "119" BEL, "reset-highlight-foreground-color")
Debarshi Ray 955c24e
         ENTRY(OSC "777;%s" BEL, "urxvt-777")
Debarshi Ray 7308132
+        ENTRY(OSC "777;%s;%s;%s" BEL, "send-notification")
Debarshi Ray 7308132
+        ENTRY(OSC "777;%s;%s" BEL, "send-notification")
8f57b4a
         ENTRY(OSC "1337;%s" BEL, "iterm2-1337")
Debarshi Ray 7308132
 
Debarshi Ray 7308132
         COMMENT(/* Set text parameters, ST-terminated versions. */)
8f57b4a
@@ -292,6 +294,8 @@ const char _vte_xterm_capability_strings[] =
Debarshi Ray 7308132
         ENTRY(OSC "118" ST, "reset-tek-cursor-color")
Debarshi Ray 7308132
         ENTRY(OSC "119" ST, "reset-highlight-foreground-color")
Debarshi Ray 955c24e
         ENTRY(OSC "777;%s" ST, "urxvt-777")
Debarshi Ray 7308132
+        ENTRY(OSC "777;%s;%s;%s" ST, "send-notification")
Debarshi Ray 7308132
+        ENTRY(OSC "777;%s;%s" ST, "send-notification")
8f57b4a
         ENTRY(OSC "1337;%s" ST, "iterm2-1337")
Debarshi Ray 7308132
 
Debarshi Ray 7308132
         COMMENT(/* These may be bogus, I can't find docs for them anywhere (#104154). */)
Debarshi Ray 7308132
diff --git a/src/marshal.list b/src/marshal.list
Debarshi Ray 3069778
index 0276422ec6d4..2c35c685930a 100644
Debarshi Ray 7308132
--- a/src/marshal.list
Debarshi Ray 7308132
+++ b/src/marshal.list
Debarshi Ray 7308132
@@ -1,4 +1,5 @@
Debarshi Ray 7308132
 VOID:INT,INT
Debarshi Ray 7308132
 VOID:OBJECT,OBJECT
Debarshi Ray 7308132
+VOID:STRING,STRING
Debarshi Ray 7308132
 VOID:STRING,UINT
Debarshi Ray 7308132
 VOID:UINT,UINT
Debarshi Ray 3069778
diff --git a/src/vte.cc b/src/vte.cc
2a01f73
index 609d4e2e5d55..1c8cd2edc73e 100644
Debarshi Ray 3069778
--- a/src/vte.cc
Debarshi Ray 3069778
+++ b/src/vte.cc
2a01f73
@@ -8292,6 +8292,9 @@ VteTerminalPrivate::~VteTerminalPrivate()
Debarshi Ray 7308132
 
Debarshi Ray a9aabb4
 	remove_update_timeout(this);
Debarshi Ray 7308132
 
Debarshi Ray 2952472
+	g_free (m_notification_summary);
Debarshi Ray 2952472
+	g_free (m_notification_body);
Debarshi Ray 7308132
+
Debarshi Ray 7308132
 	/* discard title updates */
Debarshi Ray 2952472
         g_free(m_window_title);
Debarshi Ray 2952472
         g_free(m_window_title_changed);
2a01f73
@@ -10328,6 +10331,15 @@ VteTerminalPrivate::emit_pending_signals()
Debarshi Ray 7308132
 
Debarshi Ray 2952472
 	emit_adjustment_changed();
Debarshi Ray 7308132
 
Debarshi Ray 2952472
+	if (m_notification_received) {
Debarshi Ray 2952472
+                _vte_debug_print (VTE_DEBUG_SIGNALS,
Debarshi Ray 2952472
+                                  "Emitting `notification-received'.\n");
Debarshi Ray 2952472
+                g_signal_emit(object, signals[SIGNAL_NOTIFICATION_RECEIVED], 0,
Debarshi Ray 2952472
+                              m_notification_summary,
Debarshi Ray 2952472
+                              m_notification_body);
Debarshi Ray 2952472
+                m_notification_received = FALSE;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 2952472
 	if (m_window_title_changed) {
Debarshi Ray 2952472
 		g_free (m_window_title);
Debarshi Ray 2952472
 		m_window_title = m_window_title_changed;
Debarshi Ray 3069778
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
8f57b4a
index 7836271db108..efed7bf5dab8 100644
Debarshi Ray 3069778
--- a/src/vte/vteterminal.h
Debarshi Ray 3069778
+++ b/src/vte/vteterminal.h
8f57b4a
@@ -72,6 +72,7 @@ struct _VteTerminalClass {
Debarshi Ray 525ec1b
 	void (*child_exited)(VteTerminal* terminal, int status);
Debarshi Ray 525ec1b
 	void (*encoding_changed)(VteTerminal* terminal);
Debarshi Ray 525ec1b
 	void (*char_size_changed)(VteTerminal* terminal, guint char_width, guint char_height);
Debarshi Ray 525ec1b
+	void (*notification_received)(VteTerminal* terminal, const gchar *summary, const gchar *body);
Debarshi Ray 525ec1b
 	void (*window_title_changed)(VteTerminal* terminal);
Debarshi Ray 525ec1b
 	void (*icon_title_changed)(VteTerminal* terminal);
Debarshi Ray 525ec1b
 	void (*selection_changed)(VteTerminal* terminal);
8f57b4a
@@ -105,7 +106,7 @@ struct _VteTerminalClass {
Debarshi Ray 3069778
 	void (*bell)(VteTerminal* terminal);
Debarshi Ray 3069778
 
Debarshi Ray 3069778
         /* Padding for future expansion. */
Debarshi Ray 3069778
-        gpointer padding[16];
Debarshi Ray 3069778
+        gpointer padding[15];
Debarshi Ray 3069778
 
Debarshi Ray 3069778
         VteTerminalClassPrivate *priv;
Debarshi Ray 3069778
 };
Debarshi Ray 2952472
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
2a01f73
index 924b5a084dd3..a65a2a98b44a 100644
Debarshi Ray 2952472
--- a/src/vtegtk.cc
Debarshi Ray 2952472
+++ b/src/vtegtk.cc
8f57b4a
@@ -657,6 +657,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 2952472
 	klass->child_exited = NULL;
Debarshi Ray 2952472
 	klass->encoding_changed = NULL;
Debarshi Ray 2952472
 	klass->char_size_changed = NULL;
Debarshi Ray 2952472
+	klass->notification_received = NULL;
Debarshi Ray 2952472
 	klass->window_title_changed = NULL;
Debarshi Ray 2952472
 	klass->icon_title_changed = NULL;
Debarshi Ray 2952472
 	klass->selection_changed = NULL;
8f57b4a
@@ -733,6 +734,26 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray 2952472
                              1, G_TYPE_INT);
Debarshi Ray 2952472
 
Debarshi Ray 2952472
         /**
Debarshi Ray 2952472
+         * VteTerminal::notification-received:
Debarshi Ray 2952472
+         * @vteterminal: the object which received the signal
Debarshi Ray 2952472
+         * @summary: The summary
Debarshi Ray 2952472
+         * @body: (allow-none): Extra optional text
Debarshi Ray 2952472
+         *
Debarshi Ray 2952472
+         * Emitted when a process running in the terminal wants to
Debarshi Ray 2952472
+         * send a notification to the desktop environment.
Debarshi Ray 2952472
+         */
Debarshi Ray 2952472
+        signals[SIGNAL_NOTIFICATION_RECEIVED] =
Debarshi Ray 2952472
+                g_signal_new(I_("notification-received"),
Debarshi Ray 2952472
+                             G_OBJECT_CLASS_TYPE(klass),
Debarshi Ray 2952472
+                             G_SIGNAL_RUN_LAST,
Debarshi Ray 2952472
+                             G_STRUCT_OFFSET(VteTerminalClass, notification_received),
Debarshi Ray 2952472
+                             NULL,
Debarshi Ray 2952472
+                             NULL,
Debarshi Ray 2952472
+                             _vte_marshal_VOID__STRING_STRING,
Debarshi Ray 2952472
+                             G_TYPE_NONE,
Debarshi Ray 2952472
+                             2, G_TYPE_STRING, G_TYPE_STRING);
Debarshi Ray 2952472
+
Debarshi Ray 2952472
+        /**
Debarshi Ray 2952472
          * VteTerminal::window-title-changed:
Debarshi Ray 2952472
          * @vteterminal: the object which received the signal
Debarshi Ray 2952472
          *
Debarshi Ray 2952472
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
8f57b4a
index 5340725d374c..f8a83525b18c 100644
Debarshi Ray 2952472
--- a/src/vtegtk.hh
Debarshi Ray 2952472
+++ b/src/vtegtk.hh
8f57b4a
@@ -55,6 +55,7 @@ enum {
Debarshi Ray 2952472
         SIGNAL_TEXT_INSERTED,
Debarshi Ray 2952472
         SIGNAL_TEXT_MODIFIED,
Debarshi Ray 2952472
         SIGNAL_TEXT_SCROLLED,
Debarshi Ray 2952472
+        SIGNAL_NOTIFICATION_RECEIVED,
Debarshi Ray 2952472
         SIGNAL_WINDOW_TITLE_CHANGED,
8f57b4a
         LAST_SIGNAL
8f57b4a
 };
Debarshi Ray 3069778
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
8f57b4a
index cff2157cc0d0..31636f0bc56b 100644
Debarshi Ray 3069778
--- a/src/vteinternal.hh
Debarshi Ray 3069778
+++ b/src/vteinternal.hh
8f57b4a
@@ -493,6 +493,11 @@ public:
Debarshi Ray a9aabb4
         gboolean m_cursor_moved_pending;
Debarshi Ray a9aabb4
         gboolean m_contents_changed_pending;
Debarshi Ray 3069778
 
Debarshi Ray 3069778
+	/* desktop notification */
Debarshi Ray a9aabb4
+	gboolean m_notification_received;
Debarshi Ray a9aabb4
+	gchar *m_notification_summary;
Debarshi Ray a9aabb4
+	gchar *m_notification_body;
Debarshi Ray 3069778
+
Debarshi Ray 3069778
 	/* window name changes */
Debarshi Ray a9aabb4
         char* m_window_title;
Debarshi Ray a9aabb4
         char* m_window_title_changed;
Debarshi Ray 7308132
diff --git a/src/vteseq-n.gperf b/src/vteseq-n.gperf
2a01f73
index f060c98200dd..b530e3194eac 100644
Debarshi Ray 7308132
--- a/src/vteseq-n.gperf
Debarshi Ray 7308132
+++ b/src/vteseq-n.gperf
8f57b4a
@@ -169,4 +169,5 @@ struct vteseq_n_struct {
Debarshi Ray 7308132
 "set-current-directory-uri", VTE_SEQUENCE_HANDLER(vte_sequence_handler_set_current_directory_uri)
Debarshi Ray 7308132
 "set-current-file-uri", VTE_SEQUENCE_HANDLER(vte_sequence_handler_set_current_file_uri)
Debarshi Ray 955c24e
 "urxvt-777", VTE_SEQUENCE_HANDLER(vte_sequence_handler_urxvt_777)
Debarshi Ray 7308132
+"send-notification", VTE_SEQUENCE_HANDLER(vte_sequence_handler_send_notification)
8f57b4a
 "iterm2-1337", VTE_SEQUENCE_HANDLER(vte_sequence_handler_iterm2_1337)
Debarshi Ray 3069778
diff --git a/src/vteseq.cc b/src/vteseq.cc
8f57b4a
index 2330939d8068..53ade2e3d4ad 100644
Debarshi Ray 3069778
--- a/src/vteseq.cc
Debarshi Ray 3069778
+++ b/src/vteseq.cc
Debarshi Ray 955c24e
@@ -2322,6 +2322,96 @@ vte_sequence_handler_return_terminal_id (VteTerminalPrivate *that, GValueArray *
Debarshi Ray 2952472
 	vte_sequence_handler_send_primary_device_attributes (that, params);
Debarshi Ray 7308132
 }
Debarshi Ray 7308132
 
Debarshi Ray 7308132
+static void
Debarshi Ray 2952472
+vte_sequence_handler_send_notification (VteTerminalPrivate *that, GValueArray *params)
Debarshi Ray 7308132
+{
Debarshi Ray 7308132
+	GValue *value;
Debarshi Ray 7308132
+	const char *end;
Debarshi Ray 7308132
+	char *option = NULL;
Debarshi Ray 7308132
+	char *str = NULL;
Debarshi Ray 7308132
+	char *p, *validated;
Debarshi Ray 7308132
+
Debarshi Ray a9aabb4
+	g_clear_pointer (&that->m_notification_summary, g_free);
Debarshi Ray a9aabb4
+	g_clear_pointer (&that->m_notification_body, g_free);
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	value = g_value_array_get_nth (params, 0);
Debarshi Ray 7308132
+	if (value == NULL) {
Debarshi Ray 7308132
+		goto out;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	if (G_VALUE_HOLDS_STRING (value)) {
Debarshi Ray 7308132
+		option = g_value_dup_string (value);
Debarshi Ray 7308132
+	} else if (G_VALUE_HOLDS_POINTER (value)) {
Debarshi Ray 2952472
+		option = that->ucs4_to_utf8 ((const guchar *)g_value_get_pointer (value));
Debarshi Ray 7308132
+	} else {
Debarshi Ray 7308132
+		goto out;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	if (g_strcmp0 (option, "notify") != 0) {
Debarshi Ray 7308132
+		goto out;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	value = g_value_array_get_nth (params, 1);
Debarshi Ray 7308132
+	if (value == NULL) {
Debarshi Ray 7308132
+		goto out;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	if (G_VALUE_HOLDS_STRING (value)) {
Debarshi Ray 7308132
+		str = g_value_dup_string (value);
Debarshi Ray 7308132
+	} else if (G_VALUE_HOLDS_POINTER (value)) {
Debarshi Ray 2952472
+		str = that->ucs4_to_utf8 ((const guchar *)g_value_get_pointer (value));
Debarshi Ray 7308132
+	} else {
Debarshi Ray 7308132
+		goto out;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	g_utf8_validate (str, strlen (str), &end;;
Debarshi Ray 7308132
+	validated = g_strndup (str, end - str);
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	/* No control characters allowed. */
Debarshi Ray 7308132
+	for (p = validated; *p != '\0'; p++) {
Debarshi Ray 7308132
+		if ((*p & 0x1f) == *p) {
Debarshi Ray 7308132
+			*p = ' ';
Debarshi Ray 7308132
+		}
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray a9aabb4
+	that->m_notification_summary = validated;
Debarshi Ray 7308132
+	g_free (str);
Debarshi Ray 7308132
+
Debarshi Ray a9aabb4
+	that->m_notification_received = TRUE;
Debarshi Ray 7308132
+	if (params->n_values == 2) {
Debarshi Ray 7308132
+		goto out;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	value = g_value_array_get_nth (params, 2);
Debarshi Ray 7308132
+	if (value == NULL) {
Debarshi Ray 7308132
+		goto out;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	if (G_VALUE_HOLDS_STRING (value)) {
Debarshi Ray 7308132
+		str = g_value_dup_string (value);
Debarshi Ray 7308132
+	} else if (G_VALUE_HOLDS_POINTER (value)) {
Debarshi Ray 2952472
+		str = that->ucs4_to_utf8 ((const guchar *)g_value_get_pointer (value));
Debarshi Ray 7308132
+	} else {
Debarshi Ray 7308132
+		goto out;
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	g_utf8_validate (str, strlen (str), &end;;
Debarshi Ray 7308132
+	validated = g_strndup (str, end - str);
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+	/* No control characters allowed. */
Debarshi Ray 7308132
+	for (p = validated; *p != '\0'; p++) {
Debarshi Ray 7308132
+		if ((*p & 0x1f) == *p) {
Debarshi Ray 7308132
+			*p = ' ';
Debarshi Ray 7308132
+		}
Debarshi Ray 7308132
+	}
Debarshi Ray 7308132
+
Debarshi Ray a9aabb4
+	that->m_notification_body = validated;
Debarshi Ray 7308132
+	g_free (str);
Debarshi Ray 7308132
+
Debarshi Ray 7308132
+ out:
Debarshi Ray 7308132
+	g_free (option);
Debarshi Ray 7308132
+}
Debarshi Ray 7308132
+
Debarshi Ray 7308132
 /* Send secondary device attributes. */
Debarshi Ray 7308132
 static void
Debarshi Ray 2952472
 vte_sequence_handler_send_secondary_device_attributes (VteTerminalPrivate *that, GValueArray *params)
Debarshi Ray 7308132
-- 
8f57b4a
2.7.4
Debarshi Ray 7308132
Debarshi Ray 7308132
2a01f73
From 0779d12dc97b05959da0d73f34ad3e2907484224 Mon Sep 17 00:00:00 2001
Debarshi Ray 7308132
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 7308132
Date: Thu, 29 Jan 2015 13:09:17 +0100
Debarshi Ray 525ec1b
Subject: [PATCH 2/6] vte.sh: Emit OSC 777 from PROMPT_COMMAND
Debarshi Ray 7308132
Debarshi Ray 7308132
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 7308132
---
Debarshi Ray 7308132
 src/vte.sh | 4 +++-
Debarshi Ray 7308132
 1 file changed, 3 insertions(+), 1 deletion(-)
Debarshi Ray 7308132
Debarshi Ray 7308132
diff --git a/src/vte.sh b/src/vte.sh
Debarshi Ray 3069778
index 2d211caa2f17..1c0543bd9d26 100644
Debarshi Ray 7308132
--- a/src/vte.sh
Debarshi Ray 7308132
+++ b/src/vte.sh
Debarshi Ray 7308132
@@ -50,9 +50,11 @@ __vte_osc7 () {
Debarshi Ray 7308132
 }
Debarshi Ray 7308132
 
Debarshi Ray 7308132
 __vte_prompt_command() {
Debarshi Ray 7308132
+  local command=$(HISTTIMEFORMAT= history 1 | sed 's/^ *[0-9]\+ *//')
Debarshi Ray 7308132
+  command="${command//;/ }"
Debarshi Ray 7308132
   local pwd='~'
Debarshi Ray 7308132
   [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
Debarshi Ray 7308132
-  printf "\033]0;%s@%s:%s\007%s" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
Debarshi Ray 7308132
+  printf "\033]777;notify;Command completed;%s\007\033]0;%s@%s:%s\007%s" "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
Debarshi Ray 7308132
 }
Debarshi Ray 7308132
 
Debarshi Ray 7308132
 case "$TERM" in
Debarshi Ray 7308132
-- 
8f57b4a
2.7.4
Debarshi Ray 7308132
Debarshi Ray 7308132
2a01f73
From cd48fc069c16f5128b21d3f0a4d24f53c4a12630 Mon Sep 17 00:00:00 2001
Debarshi Ray 7308132
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 7308132
Date: Thu, 22 Jan 2015 16:37:10 +0100
Debarshi Ray 525ec1b
Subject: [PATCH 3/6] vteapp: Add a test for the notification-received signal
Debarshi Ray 7308132
Debarshi Ray 7308132
---
Debarshi Ray 7308132
 src/app.vala | 7 +++++++
Debarshi Ray 7308132
 1 file changed, 7 insertions(+)
Debarshi Ray 7308132
Debarshi Ray 7308132
diff --git a/src/app.vala b/src/app.vala
8f57b4a
index 4fef74999693..0da18339ed58 100644
Debarshi Ray 7308132
--- a/src/app.vala
Debarshi Ray 7308132
+++ b/src/app.vala
8f57b4a
@@ -316,6 +316,8 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 7308132
     if (App.Options.object_notifications)
Debarshi Ray 7308132
       terminal.notify.connect(notify_cb);
Debarshi Ray 7308132
 
Debarshi Ray 7308132
+    terminal.notification_received.connect(notification_received_cb);
Debarshi Ray 7308132
+
Debarshi Ray 7308132
     /* Settings */
Debarshi Ray 7308132
     if (App.Options.no_double_buffer)
Debarshi Ray 8639850
       terminal.set_double_buffered(false);
8f57b4a
@@ -779,6 +781,11 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray 7308132
     set_title(terminal.get_window_title());
Debarshi Ray 7308132
   }
Debarshi Ray 7308132
 
Debarshi Ray 7308132
+  private void notification_received_cb(Vte.Terminal terminal, string summary, string? body)
Debarshi Ray 7308132
+  {
Debarshi Ray 7308132
+    print ("[%s]: %s\n", summary, body);
Debarshi Ray 7308132
+  }
Debarshi Ray 7308132
+
Debarshi Ray 7308132
 } /* class Window */
Debarshi Ray 7308132
 
Debarshi Ray 7308132
 class App : Gtk.Application
Debarshi Ray 7308132
-- 
8f57b4a
2.7.4
Debarshi Ray 7308132
Debarshi Ray 955c24e
2a01f73
From c1d1f4f1b754169af1c64875ad76533775575072 Mon Sep 17 00:00:00 2001
Debarshi Ray 525ec1b
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray 525ec1b
Date: Mon, 9 May 2016 12:48:46 +0200
Debarshi Ray 525ec1b
Subject: [PATCH 4/6] Fix the order of vfunc pointers in VteTerminalClass to
Debarshi Ray 525ec1b
 undo ABI break
Debarshi Ray 525ec1b
Debarshi Ray 525ec1b
https://bugzilla.gnome.org/show_bug.cgi?id=711059
Debarshi Ray 525ec1b
---
Debarshi Ray 525ec1b
 src/vte/vteterminal.h | 3 ++-
Debarshi Ray 525ec1b
 1 file changed, 2 insertions(+), 1 deletion(-)
Debarshi Ray 525ec1b
Debarshi Ray 525ec1b
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
8f57b4a
index efed7bf5dab8..f514c3b227f9 100644
Debarshi Ray 525ec1b
--- a/src/vte/vteterminal.h
Debarshi Ray 525ec1b
+++ b/src/vte/vteterminal.h
8f57b4a
@@ -72,7 +72,6 @@ struct _VteTerminalClass {
Debarshi Ray 525ec1b
 	void (*child_exited)(VteTerminal* terminal, int status);
Debarshi Ray 525ec1b
 	void (*encoding_changed)(VteTerminal* terminal);
Debarshi Ray 525ec1b
 	void (*char_size_changed)(VteTerminal* terminal, guint char_width, guint char_height);
Debarshi Ray 525ec1b
-	void (*notification_received)(VteTerminal* terminal, const gchar *summary, const gchar *body);
Debarshi Ray 525ec1b
 	void (*window_title_changed)(VteTerminal* terminal);
Debarshi Ray 525ec1b
 	void (*icon_title_changed)(VteTerminal* terminal);
Debarshi Ray 525ec1b
 	void (*selection_changed)(VteTerminal* terminal);
8f57b4a
@@ -105,6 +104,8 @@ struct _VteTerminalClass {
Debarshi Ray 525ec1b
 
Debarshi Ray 525ec1b
 	void (*bell)(VteTerminal* terminal);
Debarshi Ray 525ec1b
 
Debarshi Ray 525ec1b
+	void (*notification_received)(VteTerminal* terminal, const gchar *summary, const gchar *body);
Debarshi Ray 525ec1b
+
Debarshi Ray 525ec1b
         /* Padding for future expansion. */
Debarshi Ray 525ec1b
         gpointer padding[15];
Debarshi Ray 525ec1b
 
Debarshi Ray 525ec1b
-- 
8f57b4a
2.7.4
Debarshi Ray 525ec1b
Debarshi Ray 525ec1b
2a01f73
From 2e4a7740e70f755fe5635262691f6c26f68b9e0b Mon Sep 17 00:00:00 2001
Debarshi Ray 955c24e
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray f1ae7f9
Date: Fri, 13 May 2016 17:53:54 +0200
Debarshi Ray 525ec1b
Subject: [PATCH 5/6] Add a property to configure the scroll speed
Debarshi Ray 955c24e
Debarshi Ray f1ae7f9
By default, it is set to zero which gives the current behaviour of
Debarshi Ray f1ae7f9
moving the buffer by a function of the number of visible rows.
Debarshi Ray f1ae7f9
Debarshi Ray f1ae7f9
https://bugzilla.redhat.com/show_bug.cgi?id=1103380
Debarshi Ray 955c24e
---
Debarshi Ray f1ae7f9
 doc/reference/vte-sections.txt |  1 +
Debarshi Ray f1ae7f9
 src/vte.cc                     | 19 +++++++++++++++++-
Debarshi Ray f1ae7f9
 src/vte/vteterminal.h          |  4 ++++
Debarshi Ray f1ae7f9
 src/vtegtk.cc                  | 45 ++++++++++++++++++++++++++++++++++++++++++
Debarshi Ray f1ae7f9
 src/vtegtk.hh                  |  1 +
Debarshi Ray f1ae7f9
 src/vteinternal.hh             |  2 ++
Debarshi Ray f1ae7f9
 6 files changed, 71 insertions(+), 1 deletion(-)
Debarshi Ray 955c24e
Debarshi Ray f1ae7f9
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
8f57b4a
index 56ae7754491d..58ce6c2c5c23 100644
Debarshi Ray f1ae7f9
--- a/doc/reference/vte-sections.txt
Debarshi Ray f1ae7f9
+++ b/doc/reference/vte-sections.txt
Debarshi Ray f1ae7f9
@@ -41,6 +41,7 @@ vte_terminal_set_cursor_shape
Debarshi Ray f1ae7f9
 vte_terminal_get_cursor_shape
Debarshi Ray f1ae7f9
 vte_terminal_get_cursor_blink_mode
Debarshi Ray f1ae7f9
 vte_terminal_set_cursor_blink_mode
Debarshi Ray f1ae7f9
+vte_terminal_set_scroll_speed
Debarshi Ray f1ae7f9
 vte_terminal_set_scrollback_lines
Debarshi Ray f1ae7f9
 vte_terminal_set_font
Debarshi Ray f1ae7f9
 vte_terminal_get_font
Debarshi Ray f1ae7f9
diff --git a/src/vte.cc b/src/vte.cc
2a01f73
index 1c8cd2edc73e..20dc6fb82e88 100644
Debarshi Ray f1ae7f9
--- a/src/vte.cc
Debarshi Ray f1ae7f9
+++ b/src/vte.cc
2a01f73
@@ -9611,6 +9611,7 @@ void
Debarshi Ray f1ae7f9
 VteTerminalPrivate::widget_scroll(GdkEventScroll *event)
Debarshi Ray f1ae7f9
 {
Debarshi Ray f1ae7f9
 	gdouble delta_x, delta_y;
Debarshi Ray f1ae7f9
+	gdouble scroll_speed;
Debarshi Ray f1ae7f9
 	gdouble v;
Debarshi Ray f1ae7f9
 	gint cnt, i;
Debarshi Ray f1ae7f9
 	int button;
2a01f73
@@ -9664,7 +9665,13 @@ VteTerminalPrivate::widget_scroll(GdkEventScroll *event)
Debarshi Ray f1ae7f9
 		return;
Debarshi Ray f1ae7f9
 	}
Debarshi Ray f1ae7f9
 
Debarshi Ray f1ae7f9
-	v = MAX (1., ceil (gtk_adjustment_get_page_increment (m_vadjustment) / 10.));
Debarshi Ray f1ae7f9
+	if (m_scroll_speed == 0) {
Debarshi Ray f1ae7f9
+		scroll_speed = ceil (gtk_adjustment_get_page_increment (m_vadjustment) / 10.);
Debarshi Ray f1ae7f9
+	} else {
Debarshi Ray f1ae7f9
+		scroll_speed = m_scroll_speed;
Debarshi Ray f1ae7f9
+	}
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+	v = MAX (1., scroll_speed);
Debarshi Ray f1ae7f9
 	_vte_debug_print(VTE_DEBUG_EVENTS,
Debarshi Ray f1ae7f9
 			"Scroll speed is %d lines per non-smooth scroll unit\n",
Debarshi Ray f1ae7f9
 			(int) v);
2a01f73
@@ -9881,6 +9888,16 @@ VteTerminalPrivate::decscusr_cursor_shape()
Debarshi Ray f1ae7f9
 }
Debarshi Ray f1ae7f9
 
Debarshi Ray f1ae7f9
 bool
Debarshi Ray f1ae7f9
+VteTerminalPrivate::set_scroll_speed(unsigned int scroll_speed)
Debarshi Ray f1ae7f9
+{
Debarshi Ray f1ae7f9
+        if (scroll_speed == m_scroll_speed)
Debarshi Ray f1ae7f9
+                return false;
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+        m_scroll_speed = scroll_speed;
Debarshi Ray f1ae7f9
+        return true;
Debarshi Ray f1ae7f9
+}
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+bool
Debarshi Ray f1ae7f9
 VteTerminalPrivate::set_scrollback_lines(long lines)
Debarshi Ray f1ae7f9
 {
Debarshi Ray f1ae7f9
         glong low, high, next;
Debarshi Ray 955c24e
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
8f57b4a
index f514c3b227f9..89c267555cf9 100644
Debarshi Ray 955c24e
--- a/src/vte/vteterminal.h
Debarshi Ray 955c24e
+++ b/src/vte/vteterminal.h
8f57b4a
@@ -267,6 +267,10 @@ void vte_terminal_set_cursor_shape(VteTerminal *terminal,
Debarshi Ray f1ae7f9
 _VTE_PUBLIC
Debarshi Ray f1ae7f9
 VteCursorShape vte_terminal_get_cursor_shape(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
Debarshi Ray 955c24e
 
Debarshi Ray f1ae7f9
+_VTE_PUBLIC
Debarshi Ray f1ae7f9
+void vte_terminal_set_scroll_speed(VteTerminal *terminal,
Debarshi Ray f1ae7f9
+                                   guint scroll_speed) _VTE_GNUC_NONNULL(1);
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
 /* Set the number of scrollback lines, above or at an internal minimum. */
Debarshi Ray f1ae7f9
 _VTE_PUBLIC
Debarshi Ray f1ae7f9
 void vte_terminal_set_scrollback_lines(VteTerminal *terminal,
Debarshi Ray f1ae7f9
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
2a01f73
index a65a2a98b44a..20d36449368c 100644
Debarshi Ray f1ae7f9
--- a/src/vtegtk.cc
Debarshi Ray f1ae7f9
+++ b/src/vtegtk.cc
8f57b4a
@@ -464,6 +464,9 @@ vte_terminal_get_property (GObject *object,
Debarshi Ray f1ae7f9
                 case PROP_REWRAP_ON_RESIZE:
Debarshi Ray f1ae7f9
                         g_value_set_boolean (value, vte_terminal_get_rewrap_on_resize (terminal));
Debarshi Ray f1ae7f9
                         break;
Debarshi Ray f1ae7f9
+                case PROP_SCROLL_SPEED:
Debarshi Ray f1ae7f9
+                        g_value_set_uint (value, impl->m_scroll_speed);
Debarshi Ray f1ae7f9
+                        break;
Debarshi Ray f1ae7f9
                 case PROP_SCROLLBACK_LINES:
Debarshi Ray f1ae7f9
                         g_value_set_uint (value, impl->m_scrollback_lines);
Debarshi Ray f1ae7f9
                         break;
8f57b4a
@@ -550,6 +553,9 @@ vte_terminal_set_property (GObject *object,
Debarshi Ray f1ae7f9
                 case PROP_REWRAP_ON_RESIZE:
Debarshi Ray f1ae7f9
                         vte_terminal_set_rewrap_on_resize (terminal, g_value_get_boolean (value));
Debarshi Ray f1ae7f9
                         break;
Debarshi Ray f1ae7f9
+                case PROP_SCROLL_SPEED:
Debarshi Ray f1ae7f9
+                        vte_terminal_set_scroll_speed (terminal, g_value_get_uint (value));
Debarshi Ray f1ae7f9
+                        break;
Debarshi Ray f1ae7f9
                 case PROP_SCROLLBACK_LINES:
Debarshi Ray f1ae7f9
                         vte_terminal_set_scrollback_lines (terminal, g_value_get_uint (value));
Debarshi Ray f1ae7f9
                         break;
8f57b4a
@@ -1406,6 +1412,21 @@ vte_terminal_class_init(VteTerminalClass *klass)
Debarshi Ray f1ae7f9
                                       (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
Debarshi Ray 955c24e
 
Debarshi Ray f1ae7f9
         /**
Debarshi Ray f1ae7f9
+         * VteTerminal:scroll-speed:
Debarshi Ray f1ae7f9
+         *
Debarshi Ray f1ae7f9
+         * The number of lines by which the buffer is moved when
Debarshi Ray f1ae7f9
+         * scrolling with a mouse wheel on top of the terminal
Debarshi Ray f1ae7f9
+         * Setting it to zero will cause the buffer to be moved by an
Debarshi Ray f1ae7f9
+         * amount depending on the number of visible rows the widget
Debarshi Ray f1ae7f9
+         * can display.
Debarshi Ray f1ae7f9
+         */
Debarshi Ray f1ae7f9
+        pspecs[PROP_SCROLL_SPEED] =
Debarshi Ray f1ae7f9
+                g_param_spec_uint ("scroll-speed", NULL, NULL,
Debarshi Ray f1ae7f9
+                                   0, G_MAXUINT,
Debarshi Ray f1ae7f9
+                                   0,
Debarshi Ray f1ae7f9
+                                   (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
Debarshi Ray 955c24e
+
Debarshi Ray f1ae7f9
+        /**
Debarshi Ray f1ae7f9
          * VteTerminal:scrollback-lines:
Debarshi Ray f1ae7f9
          *
Debarshi Ray f1ae7f9
          * The length of the scrollback buffer used by the terminal.  The size of
2a01f73
@@ -3448,6 +3469,30 @@ vte_terminal_get_row_count(VteTerminal *terminal)
Debarshi Ray f1ae7f9
 }
Debarshi Ray f1ae7f9
 
Debarshi Ray f1ae7f9
 /**
Debarshi Ray f1ae7f9
+ * vte_terminal_set_scroll_speed:
Debarshi Ray f1ae7f9
+ * @terminal: a #VteTerminal
Debarshi Ray f1ae7f9
+ * @scroll_speed: move the buffer by this number of lines while scrolling
Debarshi Ray f1ae7f9
+ *
Debarshi Ray f1ae7f9
+ * Sets the number of lines by which the buffer is moved when
Debarshi Ray f1ae7f9
+ * scrolling with a mouse wheel. Setting it to zero will cause the
Debarshi Ray f1ae7f9
+ * buffer to be moved by an amount depending on the number of visible
Debarshi Ray f1ae7f9
+ * rows the widget can display.
Debarshi Ray f1ae7f9
+ */
Debarshi Ray f1ae7f9
+void
Debarshi Ray f1ae7f9
+vte_terminal_set_scroll_speed(VteTerminal *terminal, guint scroll_speed)
Debarshi Ray f1ae7f9
+{
Debarshi Ray f1ae7f9
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+        GObject *object = G_OBJECT(terminal);
Debarshi Ray f1ae7f9
+        g_object_freeze_notify(object);
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+        if (IMPL(terminal)->set_scroll_speed(scroll_speed))
Debarshi Ray f1ae7f9
+                g_object_notify_by_pspec(object, pspecs[PROP_SCROLL_SPEED]);
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+        g_object_thaw_notify(object);
Debarshi Ray f1ae7f9
+}
Debarshi Ray f1ae7f9
+
Debarshi Ray f1ae7f9
+/**
Debarshi Ray f1ae7f9
  * vte_terminal_set_scrollback_lines:
Debarshi Ray f1ae7f9
  * @terminal: a #VteTerminal
Debarshi Ray f1ae7f9
  * @lines: the length of the history buffer
Debarshi Ray f1ae7f9
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
8f57b4a
index f8a83525b18c..98c616f54de6 100644
Debarshi Ray f1ae7f9
--- a/src/vtegtk.hh
Debarshi Ray f1ae7f9
+++ b/src/vtegtk.hh
Debarshi Ray f1ae7f9
@@ -80,6 +80,7 @@ enum {
Debarshi Ray f1ae7f9
         PROP_MOUSE_POINTER_AUTOHIDE,
Debarshi Ray f1ae7f9
         PROP_PTY,
Debarshi Ray f1ae7f9
         PROP_REWRAP_ON_RESIZE,
Debarshi Ray f1ae7f9
+        PROP_SCROLL_SPEED,
Debarshi Ray f1ae7f9
         PROP_SCROLLBACK_LINES,
Debarshi Ray f1ae7f9
         PROP_SCROLL_ON_KEYSTROKE,
Debarshi Ray f1ae7f9
         PROP_SCROLL_ON_OUTPUT,
Debarshi Ray f1ae7f9
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
8f57b4a
index 31636f0bc56b..e38176cb3ff5 100644
Debarshi Ray f1ae7f9
--- a/src/vteinternal.hh
Debarshi Ray f1ae7f9
+++ b/src/vteinternal.hh
8f57b4a
@@ -385,6 +385,7 @@ public:
Debarshi Ray f1ae7f9
         gboolean m_scroll_on_output;
Debarshi Ray f1ae7f9
         gboolean m_scroll_on_keystroke;
Debarshi Ray f1ae7f9
         gboolean m_alternate_screen_scroll;
Debarshi Ray f1ae7f9
+        guint m_scroll_speed;
Debarshi Ray f1ae7f9
         vte::grid::row_t m_scrollback_lines;
Debarshi Ray f1ae7f9
 
Debarshi Ray f1ae7f9
         /* Restricted scrolling */
8f57b4a
@@ -1093,6 +1094,7 @@ public:
Debarshi Ray f1ae7f9
         bool set_mouse_autohide(bool autohide);
Debarshi Ray f1ae7f9
         bool set_pty(VtePty *pty);
Debarshi Ray f1ae7f9
         bool set_rewrap_on_resize(bool rewrap);
Debarshi Ray f1ae7f9
+        bool set_scroll_speed(unsigned int scroll_speed);
Debarshi Ray f1ae7f9
         bool set_scrollback_lines(long lines);
Debarshi Ray f1ae7f9
         bool set_scroll_on_keystroke(bool scroll);
Debarshi Ray f1ae7f9
         bool set_scroll_on_output(bool scroll);
Debarshi Ray f1ae7f9
-- 
8f57b4a
2.7.4
Debarshi Ray f1ae7f9
Debarshi Ray f1ae7f9
2a01f73
From 3b2d52fdc61b89e88e65e90f08965e903d2edc08 Mon Sep 17 00:00:00 2001
Debarshi Ray f1ae7f9
From: Debarshi Ray <debarshir@gnome.org>
Debarshi Ray f1ae7f9
Date: Fri, 13 May 2016 17:54:57 +0200
Debarshi Ray 525ec1b
Subject: [PATCH 6/6] vteapp: Add a test for the scroll-speed property
Debarshi Ray f1ae7f9
Debarshi Ray f1ae7f9
https://bugzilla.redhat.com/show_bug.cgi?id=1103380
Debarshi Ray f1ae7f9
---
Debarshi Ray f1ae7f9
 src/app.vala | 4 ++++
Debarshi Ray f1ae7f9
 1 file changed, 4 insertions(+)
Debarshi Ray f1ae7f9
Debarshi Ray f1ae7f9
diff --git a/src/app.vala b/src/app.vala
8f57b4a
index 0da18339ed58..de9d174570bd 100644
Debarshi Ray f1ae7f9
--- a/src/app.vala
Debarshi Ray f1ae7f9
+++ b/src/app.vala
8f57b4a
@@ -341,6 +341,7 @@ class Window : Gtk.ApplicationWindow
Debarshi Ray f1ae7f9
     terminal.set_rewrap_on_resize(!App.Options.no_rewrap);
Debarshi Ray f1ae7f9
     terminal.set_scroll_on_output(false);
Debarshi Ray f1ae7f9
     terminal.set_scroll_on_keystroke(true);
Debarshi Ray f1ae7f9
+    terminal.set_scroll_speed(App.Options.scroll_speed);
Debarshi Ray f1ae7f9
     terminal.set_scrollback_lines(App.Options.scrollback_lines);
Debarshi Ray 955c24e
 
Debarshi Ray f1ae7f9
     /* Style */
8f57b4a
@@ -854,6 +855,7 @@ class App : Gtk.Application
Debarshi Ray f1ae7f9
     public static bool object_notifications = false;
Debarshi Ray f1ae7f9
     public static string? output_filename = null;
Debarshi Ray f1ae7f9
     public static bool reverse = false;
Debarshi Ray f1ae7f9
+    public static uint scroll_speed = 0;
Debarshi Ray f1ae7f9
     public static int scrollback_lines = 512;
Debarshi Ray f1ae7f9
     public static int transparency_percent = 0;
Debarshi Ray f1ae7f9
     public static bool version = false;
8f57b4a
@@ -1045,6 +1047,8 @@ class App : Gtk.Application
Debarshi Ray f1ae7f9
         "Save terminal contents to file at exit", null },
Debarshi Ray f1ae7f9
       { "reverse", 0, 0, OptionArg.NONE, ref reverse,
Debarshi Ray f1ae7f9
         "Reverse foreground/background colors", null },
Debarshi Ray f1ae7f9
+      { "scroll-speed", 'n', 0, OptionArg.INT, ref scroll_speed,
Debarshi Ray f1ae7f9
+        "Specify the scroll speed", null },
Debarshi Ray f1ae7f9
       { "scrollback-lines", 'n', 0, OptionArg.INT, ref scrollback_lines,
Debarshi Ray f1ae7f9
         "Specify the number of scrollback-lines", null },
Debarshi Ray f1ae7f9
       { "transparent", 'T', 0, OptionArg.INT, ref transparency_percent,
Debarshi Ray 955c24e
-- 
8f57b4a
2.7.4
Debarshi Ray 955c24e