[gnome-terminal/gnome-3-34-ntfy-opn-ttl-ts: 11/16] Revert "screen: Remove unused description and user_title API"
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal/gnome-3-34-ntfy-opn-ttl-ts: 11/16] Revert "screen: Remove unused description and user_title API"
- Date: Tue, 2 Apr 2019 16:17:42 +0000 (UTC)
commit 164fc9bf15dfe638e0465376db3a91c80851d729
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Jun 30 16:02:13 2016 +0200
Revert "screen: Remove unused description and user_title API"
This reverts commit 3bb41272b7509a16ec2a5cd93e44f73d5743b626.
https://bugzilla.redhat.com/show_bug.cgi?id=1296110
src/terminal-screen.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/terminal-screen.h | 5 ++++
2 files changed, 68 insertions(+)
---
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 57e23742..ba761caf 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -89,6 +89,7 @@ struct _TerminalScreenPrivate
guint profile_changed_id;
guint profile_forgotten_id;
char *current_cmdline;
+ char *title;
char *initial_working_directory;
char **initial_env;
char **override_command;
@@ -114,6 +115,7 @@ enum {
PROP_0,
PROP_PROFILE,
PROP_TITLE,
+ PROP_DESCRIPTION,
PROP_INITIAL_ENVIRONMENT
};
@@ -444,6 +446,9 @@ terminal_screen_get_property (GObject *object,
case PROP_TITLE:
g_value_set_string (value, terminal_screen_get_title (screen));
break;
+ case PROP_DESCRIPTION:
+ g_value_take_string (value, terminal_screen_get_description (screen));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -467,6 +472,7 @@ terminal_screen_set_property (GObject *object,
terminal_screen_set_initial_environment (screen, g_value_get_boxed (value));
break;
case PROP_TITLE:
+ case PROP_DESCRIPTION:
/* not writable */
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -556,6 +562,13 @@ terminal_screen_class_init (TerminalScreenClass *klass)
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (object_class,
+ PROP_DESCRIPTION,
+ g_param_spec_string ("description", NULL, NULL,
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property
(object_class,
PROP_INITIAL_ENVIRONMENT,
@@ -654,6 +667,7 @@ terminal_screen_finalize (GObject *object)
terminal_screen_set_profile (screen, NULL);
g_free (priv->current_cmdline);
+ g_free (priv->title);
g_free (priv->initial_working_directory);
g_strfreev (priv->override_command);
g_strfreev (priv->initial_env);
@@ -782,6 +796,21 @@ terminal_screen_get_title (TerminalScreen *screen)
return vte_terminal_get_window_title (VTE_TERMINAL (screen));
}
+char *
+terminal_screen_get_description (TerminalScreen *screen)
+{
+ TerminalScreenPrivate *priv = screen->priv;
+ const char *title;
+
+ /* use --title argument if one was supplied, otherwise ask the profile */
+ if (priv->title)
+ title = priv->title;
+
+ return g_strdup_printf ("%s — %d",
+ title && title[0] ? title : _("Terminal"),
+ screen->priv->child_pid);
+}
+
static void
terminal_screen_profile_changed_cb (GSettings *profile,
const char *prop_name,
@@ -1099,6 +1128,7 @@ terminal_screen_set_profile (TerminalScreen *screen,
g_object_unref (old_profile);
g_object_notify (G_OBJECT (screen), "profile");
+ g_object_notify (G_OBJECT (screen), "description");
}
GSettings*
@@ -1429,6 +1459,8 @@ spawn_result_cb (VteTerminal *terminal,
priv->child_pid = pid;
+ g_object_notify (G_OBJECT (screen), "description");
+
if (error) {
GtkWidget *info_bar;
@@ -1740,6 +1772,35 @@ terminal_screen_focus_in (GtkWidget *widget,
return GTK_WIDGET_CLASS (terminal_screen_parent_class)->focus_in_event (widget, event);
}
+void
+terminal_screen_set_user_title (TerminalScreen *screen,
+ const char *title)
+{
+ TerminalScreenPrivate *priv = screen->priv;
+
+ g_return_if_fail (TERMINAL_IS_SCREEN (screen));
+
+ if (g_strcmp0 (priv->title, title) == 0)
+ return;
+
+ g_free (priv->title);
+ priv->title = title && title[0] ? g_strdup (title) : NULL;
+
+ g_object_notify (G_OBJECT (screen), "description");
+}
+
+const char*
+terminal_screen_get_user_title (TerminalScreen *screen)
+{
+ TerminalScreenPrivate *priv;
+
+ g_return_val_if_fail (TERMINAL_IS_SCREEN (screen), NULL);
+
+ priv = screen->priv;
+
+ return priv->title ? priv->title : _("Terminal");
+}
+
/**
* terminal_screen_get_current_dir:
* @screen:
@@ -1793,6 +1854,8 @@ terminal_screen_child_exited (VteTerminal *terminal,
priv->child_pid = -1;
+ g_object_notify (G_OBJECT (screen), "description");
+
action = g_settings_get_enum (priv->profile, TERMINAL_PROFILE_EXIT_ACTION_KEY);
switch (action)
diff --git a/src/terminal-screen.h b/src/terminal-screen.h
index ff77fcf7..af9583e7 100644
--- a/src/terminal-screen.h
+++ b/src/terminal-screen.h
@@ -103,7 +103,12 @@ void terminal_screen_set_initial_environment (TerminalScreen *screen,
char **argv);
char ** terminal_screen_get_initial_environment (TerminalScreen *screen);
+const char *terminal_screen_get_user_title (TerminalScreen *screen);
const char* terminal_screen_get_title (TerminalScreen *screen);
+char * terminal_screen_get_description (TerminalScreen *screen);
+
+void terminal_screen_set_user_title (TerminalScreen *screen,
+ const char *text);
char *terminal_screen_get_current_dir (TerminalScreen *screen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]