Merge lp:~daniellimws/gnome-terminal/command-notify into lp:~ubuntu-desktop/gnome-terminal/ubuntu

Proposed by Daniel Lim
Status: Work in progress
Proposed branch: lp:~daniellimws/gnome-terminal/command-notify
Merge into: lp:~ubuntu-desktop/gnome-terminal/ubuntu
Diff against target: 450 lines (+413/-1)
5 files modified
debian/changelog (+11/-0)
debian/control (+1/-1)
debian/patches/command-notify-debug.patch (+80/-0)
debian/patches/command-notify.patch (+319/-0)
debian/patches/series (+2/-0)
To merge this branch: bzr merge lp:~daniellimws/gnome-terminal/command-notify
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Needs Fixing
Review via email: mp+336112@code.launchpad.net

Commit message

Add command line notification patches from Fedora

Description of the change

Add command line notification patches from Fedora.

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Putting them on hold for after GCI, Still some fixes to do (in addition to update debian/control.in)

review: Needs Fixing

Unmerged revisions

207. By Daniel Lim

* debian/patches/command-notify.patch:
  Support desktop notification from OSC 777
* debian/patches/command-notify-debug.patch:
  Sprinkle debug messages for notifications
* debian/control:
  Update to use libvte-2.91-dev (>= 0.48.4)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2017-07-13 15:07:53 +0000
+++ debian/changelog 2018-01-15 15:00:04 +0000
@@ -1,3 +1,14 @@
1gnome-terminal (3.24.2-0ubuntu6) UNRELEASED; urgency=medium
2
3 * debian/patches/command-notify.patch:
4 Support desktop notification from OSC 777
5 * debian/patches/command-notify-debug.patch:
6 Sprinkle debug messages for notifications
7 * debian/control:
8 Update to use libvte-2.91-dev (>= 0.48.4)
9
10 -- daniel <daniel@daniels-ubuntu> Mon, 15 Jan 2018 18:06:38 +0800
11
1gnome-terminal (3.24.2-0ubuntu4) artful; urgency=medium12gnome-terminal (3.24.2-0ubuntu4) artful; urgency=medium
213
3 * debian/patches/0001-screen-window-Extra-padding-around-transparent-termi.patch:14 * debian/patches/0001-screen-window-Extra-padding-around-transparent-termi.patch:
415
=== modified file 'debian/control'
--- debian/control 2017-07-13 15:07:48 +0000
+++ debian/control 2018-01-15 15:00:04 +0000
@@ -19,7 +19,7 @@
19 libgtk-3-dev (>= 3.20),19 libgtk-3-dev (>= 3.20),
20 libglib2.0-dev (>= 2.42.0),20 libglib2.0-dev (>= 2.42.0),
21# libpcre2-dev (>= 10.00),21# libpcre2-dev (>= 10.00),
22 libvte-2.91-dev (>= 0.48.2),22 libvte-2.91-dev (>= 0.48.4),
23 libsm-dev,23 libsm-dev,
24 gnome-pkg-tools (>= 0.10),24 gnome-pkg-tools (>= 0.10),
25 docbook-to-man,25 docbook-to-man,
2626
=== added file 'debian/patches/command-notify-debug.patch'
--- debian/patches/command-notify-debug.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/command-notify-debug.patch 2018-01-15 15:00:04 +0000
@@ -0,0 +1,80 @@
1From 1a3ff85b3c404f762f01808b802ffe2ed86d4074 Mon Sep 17 00:00:00 2001
2From: Debarshi Ray <debarshir@gnome.org>
3Date: Thu, 29 Jan 2015 11:47:21 +0100
4Subject: [PATCH] Sprinkle debug messages for notifications
5
6This can be useful for finding out whether the escape sequence wasn't
7emitted or the filtering was faulty.
8
9https://bugzilla.gnome.org/show_bug.cgi?id=711059
10---
11 src/terminal-debug.c | 1 +
12 src/terminal-debug.h | 3 ++-
13 src/terminal-screen.c | 6 ++++++
14 3 files changed, 9 insertions(+), 1 deletion(-)
15
16diff --git a/src/terminal-debug.c b/src/terminal-debug.c
17index 0ff321f1f0e2..dac79c38d82b 100644
18--- a/src/terminal-debug.c
19+++ b/src/terminal-debug.c
20@@ -38,6 +38,7 @@ _terminal_debug_init(void)
21 { "settings-list", TERMINAL_DEBUG_SETTINGS_LIST },
22 { "appmenu", TERMINAL_DEBUG_APPMENU },
23 { "search", TERMINAL_DEBUG_SEARCH },
24+ { "notifications", TERMINAL_DEBUG_NOTIFICATIONS },
25 };
26
27 _terminal_debug_flags = g_parse_debug_string (g_getenv ("GNOME_TERMINAL_DEBUG"),
28diff --git a/src/terminal-debug.h b/src/terminal-debug.h
29index 5dc3ca4f3df0..7499ebe06c88 100644
30--- a/src/terminal-debug.h
31+++ b/src/terminal-debug.h
32@@ -34,7 +34,8 @@ typedef enum {
33 TERMINAL_DEBUG_PROFILE = 1 << 6,
34 TERMINAL_DEBUG_SETTINGS_LIST = 1 << 7,
35 TERMINAL_DEBUG_APPMENU = 1 << 8,
36- TERMINAL_DEBUG_SEARCH = 1 << 9
37+ TERMINAL_DEBUG_SEARCH = 1 << 9,
38+ TERMINAL_DEBUG_NOTIFICATIONS = 1 << 10
39 } TerminalDebugFlags;
40
41 void _terminal_debug_init(void);
42diff --git a/src/terminal-screen.c b/src/terminal-screen.c
43index 6c96227c2f20..897147903240 100644
44--- a/src/terminal-screen.c
45+++ b/src/terminal-screen.c
46@@ -1728,6 +1728,8 @@ terminal_screen_focus_in (GtkWidget *widget,
47 TerminalApp *app;
48 TerminalWindow *window;
49
50+ _terminal_debug_print (TERMINAL_DEBUG_NOTIFICATIONS, "Notification withdrawn\n");
51+
52 window = terminal_screen_get_window (screen);
53 if (window != NULL)
54 {
55@@ -1866,6 +1868,8 @@ terminal_screen_notification_received (VteTerminal *terminal,
56 TerminalScreenPrivate *priv = screen->priv;
57 TerminalWindow *window;
58
59+ _terminal_debug_print (TERMINAL_DEBUG_NOTIFICATIONS, "Notification received: [%s]: %s\n", summary, body);
60+
61 if (G_UNLIKELY (!priv->shell_prompt_shown))
62 {
63 priv->shell_prompt_shown = TRUE;
64@@ -1897,6 +1901,7 @@ terminal_screen_notification_received (VteTerminal *terminal,
65 tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (mdi_container), GTK_WIDGET (screen_container));
66 terminal_tab_label_set_bold (TERMINAL_TAB_LABEL (tab_label), TRUE);
67 terminal_tab_label_set_icon (TERMINAL_TAB_LABEL (tab_label), "dialog-information-symbolic", summary);
68+ _terminal_debug_print (TERMINAL_DEBUG_NOTIFICATIONS, "Notify tab\n");
69 }
70 }
71 else
72@@ -1912,6 +1917,7 @@ terminal_screen_notification_received (VteTerminal *terminal,
73
74 app = terminal_app_get ();
75 g_application_send_notification (G_APPLICATION (app), priv->uuid, notification);
76+ _terminal_debug_print (TERMINAL_DEBUG_NOTIFICATIONS, "Notify desktop\n");
77 }
78 }
79
80--
081
=== added file 'debian/patches/command-notify.patch'
--- debian/patches/command-notify.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/command-notify.patch 2018-01-15 15:00:04 +0000
@@ -0,0 +1,319 @@
1From 5caa9e6a6179ea1408f0c546fb0022d022056de3 Mon Sep 17 00:00:00 2001
2From: Debarshi Ray <debarshir@gnome.org>
3Date: Tue, 27 Jan 2015 18:40:13 +0100
4Subject: [PATCH] Support desktop notifications from OSC 777
5
6https://bugzilla.gnome.org/show_bug.cgi?id=711059
7---
8 src/terminal-app.c | 32 ++++++++++++++
9 src/terminal-screen.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++
10 src/terminal-tab-label.c | 28 +++++++++++-
11 src/terminal-tab-label.h | 4 ++
12 4 files changed, 171 insertions(+), 1 deletion(-)
13
14diff --git a/src/terminal-app.c b/src/terminal-app.c
15index 6c783bc1df79..6a79e98183b3 100644
16--- a/src/terminal-app.c
17+++ b/src/terminal-app.c
18@@ -374,6 +374,31 @@ app_menu_quit_cb (GSimpleAction *action,
19 gtk_widget_destroy (GTK_WIDGET (window));
20 }
21
22+/* Other action callbacks */
23+
24+static void
25+action_activate_tab_cb (GSimpleAction *action,
26+ GVariant *parameter,
27+ gpointer user_data)
28+{
29+ GtkApplication *application = user_data;
30+ GtkWidget *toplevel;
31+ TerminalScreen *screen;
32+ const char *uuid;
33+
34+ g_variant_get (parameter, "&s", &uuid);
35+ screen = terminal_app_get_screen_by_uuid (TERMINAL_APP (application), uuid);
36+ if (screen == NULL)
37+ return;
38+
39+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
40+ if (!gtk_widget_is_toplevel (toplevel))
41+ return;
42+
43+ terminal_window_switch_screen (TERMINAL_WINDOW (toplevel), screen);
44+ gtk_window_present (GTK_WINDOW (toplevel));
45+}
46+
47 /* Class implementation */
48
49 G_DEFINE_TYPE (TerminalApp, terminal_app, GTK_TYPE_APPLICATION)
50@@ -396,6 +421,10 @@ terminal_app_startup (GApplication *application)
51 { "quit", app_menu_quit_cb, NULL, NULL, NULL }
52 };
53
54+ const GActionEntry other_actions[] = {
55+ { "activate-tab", action_activate_tab_cb, "s", NULL, NULL }
56+ };
57+
58 g_application_set_resource_base_path (application, TERMINAL_RESOURCES_PATH_PREFIX);
59
60 G_APPLICATION_CLASS (terminal_app_parent_class)->startup (application);
61@@ -406,6 +435,9 @@ terminal_app_startup (GApplication *application)
62 g_action_map_add_action_entries (G_ACTION_MAP (application),
63 app_menu_actions, G_N_ELEMENTS (app_menu_actions),
64 application);
65+ g_action_map_add_action_entries (G_ACTION_MAP (application),
66+ other_actions, G_N_ELEMENTS (other_actions),
67+ application);
68
69
70 app_load_css (application);
71diff --git a/src/terminal-screen.c b/src/terminal-screen.c
72index c67de274f8a1..6c96227c2f20 100644
73--- a/src/terminal-screen.c
74+++ b/src/terminal-screen.c
75@@ -54,6 +54,7 @@
76 #include "terminal-marshal.h"
77 #include "terminal-schemas.h"
78 #include "terminal-screen-container.h"
79+#include "terminal-tab-label.h"
80 #include "terminal-util.h"
81 #include "terminal-window.h"
82 #include "terminal-info-bar.h"
83@@ -89,6 +90,7 @@ struct _TerminalScreenPrivate
84 char **initial_env;
85 char **override_command;
86 gboolean shell;
87+ gboolean shell_prompt_shown;
88 int child_pid;
89 GSList *match_tags;
90 guint launch_child_source_id;
91@@ -141,11 +143,16 @@ static gboolean terminal_screen_button_press (GtkWidget *widget,
92 GdkEventButton *event);
93 static void terminal_screen_hierarchy_changed (GtkWidget *widget,
94 GtkWidget *previous_toplevel);
95+static gboolean terminal_screen_focus_in (GtkWidget *widget,
96+ GdkEventFocus *event);
97 static gboolean terminal_screen_do_exec (TerminalScreen *screen,
98 FDSetupData *data,
99 GError **error);
100 static void terminal_screen_child_exited (VteTerminal *terminal,
101 int status);
102+static void terminal_screen_notification_received (VteTerminal *terminal,
103+ const char *summary,
104+ const char *body);
105
106 static void terminal_screen_window_title_changed (VteTerminal *vte_terminal,
107 TerminalScreen *screen);
108@@ -485,6 +492,7 @@ terminal_screen_class_init (TerminalScreenClass *klass)
109 object_class->get_property = terminal_screen_get_property;
110 object_class->set_property = terminal_screen_set_property;
111
112+ widget_class->focus_in_event = terminal_screen_focus_in;
113 widget_class->realize = terminal_screen_realize;
114 widget_class->style_updated = terminal_screen_style_updated;
115 widget_class->drag_data_received = terminal_screen_drag_data_received;
116@@ -493,6 +501,7 @@ terminal_screen_class_init (TerminalScreenClass *klass)
117 widget_class->hierarchy_changed = terminal_screen_hierarchy_changed;
118
119 terminal_class->child_exited = terminal_screen_child_exited;
120+ terminal_class->notification_received = terminal_screen_notification_received;
121
122 signals[PROFILE_SET] =
123 g_signal_new (I_("profile-set"),
124@@ -602,6 +611,10 @@ terminal_screen_dispose (GObject *object)
125 TerminalScreen *screen = TERMINAL_SCREEN (object);
126 TerminalScreenPrivate *priv = screen->priv;
127 GtkSettings *settings;
128+ TerminalApp *app;
129+
130+ app = terminal_app_get ();
131+ g_application_withdraw_notification (G_APPLICATION (app), priv->uuid);
132
133 settings = gtk_widget_get_settings (GTK_WIDGET (screen));
134 g_signal_handlers_disconnect_matched (settings, G_SIGNAL_MATCH_DATA,
135@@ -1707,6 +1720,43 @@ terminal_screen_button_press (GtkWidget *widget,
136 return FALSE;
137 }
138
139+static gboolean
140+terminal_screen_focus_in (GtkWidget *widget,
141+ GdkEventFocus *event)
142+{
143+ TerminalScreen *screen = TERMINAL_SCREEN (widget);
144+ TerminalApp *app;
145+ TerminalWindow *window;
146+
147+ window = terminal_screen_get_window (screen);
148+ if (window != NULL)
149+ {
150+ TerminalScreenContainer *screen_container;
151+
152+ screen_container = terminal_screen_container_get_from_screen (screen);
153+ if (screen_container != NULL)
154+ {
155+ GtkWidget *mdi_container;
156+
157+ mdi_container = terminal_window_get_mdi_container (window);
158+ /* FIXME: add interface method to retrieve tab label */
159+ if (GTK_IS_NOTEBOOK (mdi_container))
160+ {
161+ GtkWidget *tab_label;
162+
163+ tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (mdi_container), GTK_WIDGET (screen_container));
164+ terminal_tab_label_set_bold (TERMINAL_TAB_LABEL (tab_label), FALSE);
165+ terminal_tab_label_set_icon (TERMINAL_TAB_LABEL (tab_label), NULL, NULL);
166+ }
167+ }
168+ }
169+
170+ app = terminal_app_get ();
171+ g_application_withdraw_notification (G_APPLICATION (app), screen->priv->uuid);
172+
173+ return GTK_WIDGET_CLASS (terminal_screen_parent_class)->focus_in_event (widget, event);
174+}
175+
176 /**
177 * terminal_screen_get_current_dir:
178 * @screen:
179@@ -1807,6 +1857,64 @@ terminal_screen_child_exited (VteTerminal *terminal,
180 }
181 }
182
183+static void
184+terminal_screen_notification_received (VteTerminal *terminal,
185+ const char *summary,
186+ const char *body)
187+{
188+ TerminalScreen *screen = TERMINAL_SCREEN (terminal);
189+ TerminalScreenPrivate *priv = screen->priv;
190+ TerminalWindow *window;
191+
192+ if (G_UNLIKELY (!priv->shell_prompt_shown))
193+ {
194+ priv->shell_prompt_shown = TRUE;
195+ return;
196+ }
197+
198+ window = terminal_screen_get_window (screen);
199+ if (window == NULL)
200+ return;
201+
202+ if (gtk_window_is_active (GTK_WINDOW (window)))
203+ {
204+ GtkWidget *mdi_container;
205+ TerminalScreenContainer *screen_container;
206+
207+ if (screen == terminal_window_get_active (window))
208+ return;
209+
210+ screen_container = terminal_screen_container_get_from_screen (screen);
211+ if (screen_container == NULL)
212+ return;
213+
214+ mdi_container = terminal_window_get_mdi_container (window);
215+ /* FIXME: add interface method to retrieve tab label */
216+ if (GTK_IS_NOTEBOOK (mdi_container))
217+ {
218+ GtkWidget *tab_label;
219+
220+ tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (mdi_container), GTK_WIDGET (screen_container));
221+ terminal_tab_label_set_bold (TERMINAL_TAB_LABEL (tab_label), TRUE);
222+ terminal_tab_label_set_icon (TERMINAL_TAB_LABEL (tab_label), "dialog-information-symbolic", summary);
223+ }
224+ }
225+ else
226+ {
227+ gs_unref_object GNotification *notification = NULL;
228+ TerminalApp *app;
229+ gs_free char *detailed_action = NULL;
230+
231+ notification = g_notification_new (summary);
232+ g_notification_set_body (notification, body);
233+ detailed_action = g_strdup_printf ("app.activate-tab::%s", priv->uuid);
234+ g_notification_set_default_action (notification, detailed_action);
235+
236+ app = terminal_app_get ();
237+ g_application_send_notification (G_APPLICATION (app), priv->uuid, notification);
238+ }
239+}
240+
241 static void
242 terminal_screen_drag_data_received (GtkWidget *widget,
243 GdkDragContext *context,
244diff --git a/src/terminal-tab-label.c b/src/terminal-tab-label.c
245index cdd73d0653be..d6909a13ca65 100644
246--- a/src/terminal-tab-label.c
247+++ b/src/terminal-tab-label.c
248@@ -34,6 +34,7 @@
249 struct _TerminalTabLabelPrivate
250 {
251 TerminalScreen *screen;
252+ GtkWidget *icon;
253 GtkWidget *label;
254 GtkWidget *close_button;
255 gboolean bold;
256@@ -179,7 +180,7 @@ terminal_tab_label_constructed (GObject *object)
257 {
258 TerminalTabLabel *tab_label = TERMINAL_TAB_LABEL (object);
259 TerminalTabLabelPrivate *priv = tab_label->priv;
260- GtkWidget *hbox, *label, *close_button;
261+ GtkWidget *hbox, *icon, *label, *close_button;
262
263 G_OBJECT_CLASS (terminal_tab_label_parent_class)->constructed (object);
264
265@@ -189,6 +190,10 @@ terminal_tab_label_constructed (GObject *object)
266
267 gtk_box_set_spacing (GTK_BOX (hbox), SPACING);
268
269+ priv->icon = icon = gtk_image_new ();
270+ gtk_widget_set_no_show_all (icon, TRUE);
271+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
272+
273 priv->label = label = gtk_label_new (NULL);
274 gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
275 gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
276@@ -376,6 +381,27 @@ terminal_tab_label_set_bold (TerminalTabLabel *tab_label,
277 pango_attr_list_unref (attr_list);
278 }
279
280+/**
281+ * terminal_tab_label_set_icon:
282+ * @tab_label: a #TerminalTabLabel
283+ * @icon_name: (allow-none): an icon name
284+ * @tooltip: (allow-none): text to be used as tooltip
285+ *
286+ * Shows an icon at the beginning of @tab_label. If @icon_name is
287+ * %NULL, then the icon will be hidden.
288+ */
289+void
290+terminal_tab_label_set_icon (TerminalTabLabel *tab_label,
291+ const char *icon_name,
292+ const char *tooltip)
293+{
294+ TerminalTabLabelPrivate *priv = tab_label->priv;
295+
296+ gtk_widget_set_visible (priv->icon, icon_name != NULL);
297+ gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon), icon_name, GTK_ICON_SIZE_MENU);
298+ gtk_widget_set_tooltip_text (GTK_WIDGET (priv->icon), tooltip);
299+}
300+
301 /**
302 * terminal_tab_label_get_screen:
303 * @tab_label: a #TerminalTabLabel
304diff --git a/src/terminal-tab-label.h b/src/terminal-tab-label.h
305index 20cfbceb36b0..a987025e0524 100644
306--- a/src/terminal-tab-label.h
307+++ b/src/terminal-tab-label.h
308@@ -59,6 +59,10 @@ GtkWidget * terminal_tab_label_new (TerminalScreen *screen);
309 void terminal_tab_label_set_bold (TerminalTabLabel *tab_label,
310 gboolean bold);
311
312+void terminal_tab_label_set_icon (TerminalTabLabel *tab_label,
313+ const char *icon_name,
314+ const char *tooltip);
315+
316 TerminalScreen *terminal_tab_label_get_screen (TerminalTabLabel *tab_label);
317
318 G_END_DECLS
319--
0320
=== modified file 'debian/patches/series'
--- debian/patches/series 2017-07-13 15:05:17 +0000
+++ debian/patches/series 2018-01-15 15:00:04 +0000
@@ -11,3 +11,5 @@
11scrollbar-background-theming.patch11scrollbar-background-theming.patch
12Provide-fallback-for-reading-current-directory-if-OS.patch12Provide-fallback-for-reading-current-directory-if-OS.patch
13revert-pcre2.patch13revert-pcre2.patch
14command-notify.patch
15command-notify-debug.patch

Subscribers

People subscribed via source and target branches

to all changes: