aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-05-23 14:34:15 +0200
committerGerd Hoffmann <kraxel@redhat.com>2019-05-23 14:34:15 +0200
commit332add1956fb574753aee255b889ef7ae3f738c7 (patch)
tree790cf32a8b13b2a6946ae5f317d3c27bd7c9df9c
parent076e0e8f5e06ea7f32d8b9ff6f2fcffd261bfa06 (diff)
downloadgterm-332add1956fb574753aee255b889ef7ae3f738c7.tar.gz
add -title option
-rw-r--r--gterm.18
-rw-r--r--gterm.c14
2 files changed, 22 insertions, 0 deletions
diff --git a/gterm.1 b/gterm.1
index d4374f9..fd779b6 100644
--- a/gterm.1
+++ b/gterm.1
@@ -38,6 +38,14 @@ Config file key: faceSize.
The width and height of the terminal window (in columns/rows, not pixels).
.br
Config file key: geometry.
+.TP
+.BI -title " text"
+Set the window title.
+.br
+Config file key: title.
+.TP
+.BI -T " text"
+Shortcut for -title.
\#
\#
.SH "CONFIG FILE"
diff --git a/gterm.c b/gterm.c
index 1edee11..ea0e60a 100644
--- a/gterm.c
+++ b/gterm.c
@@ -21,6 +21,7 @@
#define GTERM_CFG_KEY_FONT_FACE "faceName"
#define GTERM_CFG_KEY_FONT_SIZE "faceSize"
#define GTERM_CFG_KEY_GEOMETRY "geometry"
+#define GTERM_CFG_KEY_TITLE "title"
typedef struct gterm_opt {
char *opt;
@@ -32,6 +33,8 @@ static const gterm_opt gterm_opts[] = {
{ .opt = "fa", .key = GTERM_CFG_KEY_FONT_FACE },
{ .opt = "fs", .key = GTERM_CFG_KEY_FONT_SIZE },
{ .opt = "geometry", .key = GTERM_CFG_KEY_GEOMETRY },
+ { .opt = "T", .key = GTERM_CFG_KEY_TITLE },
+ { .opt = "title", .key = GTERM_CFG_KEY_TITLE },
};
static const gterm_opt *gterm_opt_find(char *arg)
@@ -176,6 +179,16 @@ static void gterm_window_destroy(GtkWidget *widget, gpointer data)
gtk_main_quit();
}
+static void gterm_window_configure(gterm *gt)
+{
+ char *str;
+
+ str = gterm_cfg_get(gt->cfg, GTERM_CFG_KEY_TITLE);
+ if (str) {
+ gtk_window_set_title(GTK_WINDOW(gt->window), str);
+ }
+}
+
static gterm *gterm_new(GKeyFile *cfg)
{
gterm *gt = g_new0(gterm, 1);
@@ -185,6 +198,7 @@ static gterm *gterm_new(GKeyFile *cfg)
gt->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(gt->window), "destroy",
G_CALLBACK(gterm_window_destroy), gt);
+ gterm_window_configure(gt);
gt->terminal = vte_terminal_new();
g_signal_connect(G_OBJECT(gt->terminal), "child-exited",