diff options
Diffstat (limited to 'src')
46 files changed, 455 insertions, 176 deletions
diff --git a/src/eggshell.c b/src/eggshell.c index 95d7994..e06029d 100644 --- a/src/eggshell.c +++ b/src/eggshell.c @@ -1,6 +1,7 @@ /* * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation * Copyright (C) 1999, 2000 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * All rights reserved. * * This file is part of the Mate Library. diff --git a/src/eggshell.h b/src/eggshell.h index 39e5add..33e0ded 100644 --- a/src/eggshell.h +++ b/src/eggshell.h @@ -1,6 +1,7 @@ /* * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation * Copyright (C) 1999, 2000 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * All rights reserved. * * This file is part of the Mate Library. diff --git a/src/extra-strings.c b/src/extra-strings.c index 12078ee..1219d14 100644 --- a/src/extra-strings.c +++ b/src/extra-strings.c @@ -1,5 +1,6 @@ /* * Copyright © 2009 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/profile-editor.c b/src/profile-editor.c index 6c439ef..f4959db 100644 --- a/src/profile-editor.c +++ b/src/profile-editor.c @@ -2,6 +2,7 @@ * Copyright © 2002 Havoc Pennington * Copyright © 2002 Mathias Hasselmann * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/profile-editor.h b/src/profile-editor.h index 8fd6e7f..31f1862 100644 --- a/src/profile-editor.h +++ b/src/profile-editor.h @@ -1,5 +1,6 @@ /* * Copyright © 2002 Havoc Pennington + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/set-title-dialog.ui b/src/set-title-dialog.ui index ead6dcc..836a399 100644 --- a/src/set-title-dialog.ui +++ b/src/set-title-dialog.ui @@ -101,6 +101,7 @@ <property name="can-focus">True</property> <property name="hexpand">True</property> <property name="width-chars">30</property> + <property name="activates-default">True</property> </object> <packing> <property name="expand">False</property> diff --git a/src/skey-popup.c b/src/skey-popup.c index 7209cf6..702aa17 100644 --- a/src/skey-popup.c +++ b/src/skey-popup.c @@ -1,6 +1,7 @@ /* * Copyright © 2002 Jonathan Blandford <[email protected]> * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/skey-popup.h b/src/skey-popup.h index 2bc1452..006f2f0 100644 --- a/src/skey-popup.h +++ b/src/skey-popup.h @@ -1,5 +1,6 @@ /* * Copyright © 2002 Jonathan Blandford <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/skey/btoe.c b/src/skey/btoe.c index bad4e81..f08dd3c 100644 --- a/src/skey/btoe.c +++ b/src/skey/btoe.c @@ -274,7 +274,6 @@ char *btoe(unsigned char *md) } - /* * Extract 'length' bits from the char array 's' * starting with bit 'start' diff --git a/src/skey/md4.c b/src/skey/md4.c index 2335240..ce8eb23 100644 --- a/src/skey/md4.c +++ b/src/skey/md4.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2001 Nikos Mavroyanopoulos + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published @@ -22,7 +23,6 @@ * written by Colin Plumb in 1993. */ - #include <string.h> #include <stdlib.h> #include "config.h" @@ -35,7 +35,6 @@ #else static void byteReverse(unsigned char *buf, unsigned longs); - /* * Note: this code is harmless on little-endian machines. */ @@ -191,7 +190,6 @@ void MD4Final(unsigned char* digest, MD4_CTX *ctx) (a) = rotl32 ((a), (s)); \ } - /* * The core of the MD4 algorithm */ @@ -255,7 +253,6 @@ void MD4Transform(guint32 buf[4], guint32 const in[16]) HH(c, d, a, b, in[7], 11); /* 47 */ HH(b, c, d, a, in[15], 15); /* 48 */ - buf[0] += a; buf[1] += b; buf[2] += c; @@ -291,7 +288,6 @@ int MD4Keycrunch( char *result, const char *seed, const char *passphrase) return 0; } - void MD4SKey(char *x) { MD4_CTX md; diff --git a/src/skey/sha1.c b/src/skey/sha1.c index 4537781..12fb478 100644 --- a/src/skey/sha1.c +++ b/src/skey/sha1.c @@ -35,7 +35,6 @@ static void byteReverse(unsigned char *buf, unsigned longs) } #endif - int SHA1Keycrunch(char *result, const char *seed, const char *passphrase) { char *buf; diff --git a/src/skey/skey.c b/src/skey/skey.c index fde2d15..0d35f9f 100644 --- a/src/skey/skey.c +++ b/src/skey/skey.c @@ -23,7 +23,6 @@ static struct skey_hash hash_table[] = { SHA1Keycrunch, SHA1SKey } }; - char *skey(SKeyAlgorithm algorithm, int seq, const char *seed, const char *passphrase) { char key[SKEY_SIZE]; diff --git a/src/terminal-accels.c b/src/terminal-accels.c index 1445230..06b35e4 100644 --- a/src/terminal-accels.c +++ b/src/terminal-accels.c @@ -1,6 +1,7 @@ /* * Copyright © 2001, 2002 Havoc Pennington, Red Hat Inc. * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/terminal-accels.h b/src/terminal-accels.h index 16a5f74..4fddc2f 100644 --- a/src/terminal-accels.h +++ b/src/terminal-accels.h @@ -1,5 +1,6 @@ /* * Copyright © 2001 Havoc Pennington + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/terminal-app.c b/src/terminal-app.c index db9fbf4..d54da49 100644 --- a/src/terminal-app.c +++ b/src/terminal-app.c @@ -4,6 +4,7 @@ * Copyright © 2002 Sun Microsystems * Copyright © 2003 Mariano Suarez-Alvarez * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,7 +40,6 @@ #include "terminal-encoding.h" #include <string.h> #include <stdlib.h> -#include <time.h> #ifdef HAVE_SMCLIENT #include "eggsmclient.h" @@ -157,7 +157,6 @@ static TerminalApp *global_app = NULL; #define ENCODING_LIST_KEY "active-encodings" - /* two following functions were copied from libmate-desktop to get rid * of dependency on it * @@ -286,7 +285,6 @@ terminal_app_get_workspace_for_window (TerminalWindow *window) return ret; } - /* Menubar mnemonics settings handling */ static int @@ -1437,7 +1435,6 @@ terminal_app_init (TerminalApp *app) G_CALLBACK(terminal_app_system_font_notify_cb), app); - g_signal_connect (settings_global, "changed::" ENABLE_MNEMONICS_KEY, G_CALLBACK(terminal_app_enable_mnemonics_notify_cb), diff --git a/src/terminal-app.h b/src/terminal-app.h index e6f732e..aeaca4c 100644 --- a/src/terminal-app.h +++ b/src/terminal-app.h @@ -1,6 +1,7 @@ /* * Copyright © 2001 Havoc Pennington * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -129,7 +130,6 @@ void terminal_app_edit_keybindings (TerminalApp *app, void terminal_app_edit_encodings (TerminalApp *app, GtkWindow *transient_parent); - GList* terminal_app_get_profile_list (TerminalApp *app); TerminalProfile* terminal_app_ensure_profile_fallback (TerminalApp *app); diff --git a/src/terminal-close-button.c b/src/terminal-close-button.c index 8a1f777..9c5be4b 100644 --- a/src/terminal-close-button.c +++ b/src/terminal-close-button.c @@ -1,5 +1,6 @@ /* * terminal-close-button.c + * Copyright (C) 2012-2021 MATE Developers * * Copyright © 2010 - Paolo Borelli * Copyright © 2011 - Ignacio Casal Quinteiro diff --git a/src/terminal-close-button.h b/src/terminal-close-button.h index 9578010..99e778e 100644 --- a/src/terminal-close-button.h +++ b/src/terminal-close-button.h @@ -1,5 +1,6 @@ /* * terminal-close-button.h + * Copyright (C) 2012-2021 MATE Developers * * Copyright © 2010 - Paolo Borelli * Copyright © 2016 - Wolfgang Ulbrich diff --git a/src/terminal-debug.c b/src/terminal-debug.c index f4be4e2..bcee716 100644 --- a/src/terminal-debug.c +++ b/src/terminal-debug.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2002,2003 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This is free software; you can redistribute it and/or modify it under * the terms of the GNU Library General Public License as published by diff --git a/src/terminal-debug.h b/src/terminal-debug.h index 53f88f1..f6acce6 100644 --- a/src/terminal-debug.h +++ b/src/terminal-debug.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2002 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This is free software; you can redistribute it and/or modify it under * the terms of the GNU Library General Public License as published by diff --git a/src/terminal-encoding.c b/src/terminal-encoding.c index ae7bab9..a470c99 100644 --- a/src/terminal-encoding.c +++ b/src/terminal-encoding.c @@ -1,6 +1,7 @@ /* * Copyright © 2002 Red Hat, Inc. * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -158,8 +159,8 @@ terminal_encoding_new (const char *charset, encoding->refcount = 1; encoding->id = g_strdup (charset); encoding->name = g_strdup (display_name); - encoding->valid = encoding->validity_checked = force_valid; - encoding->is_custom = is_custom; + encoding->valid = encoding->validity_checked = (force_valid != FALSE); + encoding->is_custom = (is_custom != FALSE); encoding->is_active = FALSE; return encoding; @@ -589,7 +590,6 @@ terminal_encodings_get_builtins (void) NULL, (GDestroyNotify) terminal_encoding_unref); - /* Placeholder entry for the current locale's charset */ encoding = terminal_encoding_new ("current", _("Current Locale"), diff --git a/src/terminal-encoding.h b/src/terminal-encoding.h index ee13417..cae1dc3 100644 --- a/src/terminal-encoding.h +++ b/src/terminal-encoding.h @@ -2,6 +2,7 @@ /* * Copyright © 2002 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/terminal-info-bar.c b/src/terminal-info-bar.c index 82583e9..aca9f1d 100644 --- a/src/terminal-info-bar.c +++ b/src/terminal-info-bar.c @@ -1,5 +1,6 @@ /* * Copyright © 2010 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/terminal-info-bar.h b/src/terminal-info-bar.h index 125224b..7958387 100644 --- a/src/terminal-info-bar.h +++ b/src/terminal-info-bar.h @@ -1,5 +1,6 @@ /* * Copyright © 2010 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/terminal-intl.h b/src/terminal-intl.h index ea34df4..81a6941 100644 --- a/src/terminal-intl.h +++ b/src/terminal-intl.h @@ -1,5 +1,6 @@ /* * Copyright © 2002 Havoc Pennington + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/terminal-options.c b/src/terminal-options.c index 58ddbe1..352466f 100644 --- a/src/terminal-options.c +++ b/src/terminal-options.c @@ -4,6 +4,7 @@ * Copyright © 2002 Sun Microsystems * Copyright © 2003 Mariano Suarez-Alvarez * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -179,7 +180,6 @@ unsupported_option_callback (const gchar *option_name, return TRUE; /* we do not want to bail out here but continue */ } - static gboolean G_GNUC_NORETURN option_version_cb (const gchar *option_name, const gchar *value, @@ -281,7 +281,6 @@ option_profile_id_cb (const gchar *option_name, return TRUE; } - static gboolean option_window_callback (const gchar *option_name, const gchar *value, diff --git a/src/terminal-options.h b/src/terminal-options.h index bc601c3..50d8224 100644 --- a/src/terminal-options.h +++ b/src/terminal-options.h @@ -4,6 +4,7 @@ * Copyright © 2002 Sun Microsystems * Copyright © 2003 Mariano Suarez-Alvarez * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/terminal-profile.c b/src/terminal-profile.c index 4e91aef..f789f66 100644 --- a/src/terminal-profile.c +++ b/src/terminal-profile.c @@ -2,6 +2,7 @@ * Copyright © 2001 Havoc Pennington * Copyright © 2002 Mathias Hasselmann * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -519,26 +520,38 @@ terminal_profile_reset_property_internal (TerminalProfile *profile, /* A few properties don't have defaults via the param spec; set them explicitly */ switch (pspec->param_id) { - case PROP_FOREGROUND_COLOR: - case PROP_BOLD_COLOR: - g_value_set_boxed (value, &DEFAULT_FOREGROUND_COLOR); - break; + case PROP_FOREGROUND_COLOR: + case PROP_BOLD_COLOR: + { + GdkRGBA color; - case PROP_BACKGROUND_COLOR: - g_value_set_boxed (value, &DEFAULT_BACKGROUND_COLOR); - break; + if (!gdk_rgba_parse (&color, DEFAULT_FOREGROUND_COLOR)) + return; + color.alpha = 1.0; + g_value_set_boxed (value, &color); + break; + } + case PROP_BACKGROUND_COLOR: + { + GdkRGBA color; - case PROP_FONT: - g_value_take_boxed (value, pango_font_description_from_string (DEFAULT_FONT)); - break; + if (!gdk_rgba_parse (&color, DEFAULT_BACKGROUND_COLOR)) + return; + color.alpha = 1.0; + g_value_set_boxed (value, &color); + break; + } + case PROP_FONT: + g_value_take_boxed (value, pango_font_description_from_string (DEFAULT_FONT)); + break; - case PROP_PALETTE: - set_value_from_palette (value, DEFAULT_PALETTE, TERMINAL_PALETTE_SIZE); - break; + case PROP_PALETTE: + set_value_from_palette (value, DEFAULT_PALETTE, TERMINAL_PALETTE_SIZE); + break; - default: - g_param_value_set_default (pspec, value); - break; + default: + g_param_value_set_default (pspec, value); + break; } if (notify) @@ -1211,12 +1224,14 @@ terminal_profile_class_init (TerminalProfileClass *klass) {\ GParamSpec *pspec = propSpec;\ g_object_class_install_property (object_class, propId, pspec);\ -\ - if (propGSettings)\ - {\ - g_param_spec_set_qdata (pspec, gsettings_key_quark, (gpointer) propGSettings);\ - g_hash_table_insert (klass->gsettings_keys, (gpointer) propGSettings, pspec);\ - }\ + g_param_spec_set_qdata (pspec, gsettings_key_quark, (gpointer) propGSettings);\ + g_hash_table_insert (klass->gsettings_keys, (gpointer) propGSettings, pspec);\ +} + +#define TERMINAL_PROFILE_PROPERTY_OUTER(propId, propSpec) \ +{\ + GParamSpec *pspec = propSpec;\ + g_object_class_install_property (object_class, propId, pspec);\ } #define TERMINAL_PROFILE_PROPERTY_BOOLEAN(prop, propDefault, propGSettings) \ @@ -1255,12 +1270,11 @@ terminal_profile_class_init (TerminalProfileClass *klass) propGSettings) /* these are all read-only */ -#define TERMINAL_PROFILE_PROPERTY_OBJECT(prop, propType, propGSettings)\ - TERMINAL_PROFILE_PROPERTY (PROP_##prop,\ +#define TERMINAL_PROFILE_PROPERTY_OBJECT(prop, propType)\ + TERMINAL_PROFILE_PROPERTY_OUTER (PROP_##prop,\ g_param_spec_object (TERMINAL_PROFILE_##prop, NULL, NULL,\ propType,\ - G_PARAM_READABLE | TERMINAL_PROFILE_PSPEC_STATIC),\ - propGSettings) + G_PARAM_READABLE | TERMINAL_PROFILE_PSPEC_STATIC)) #define TERMINAL_PROFILE_PROPERTY_STRING(prop, propDefault, propGSettings)\ TERMINAL_PROFILE_PROPERTY (PROP_##prop,\ @@ -1269,12 +1283,11 @@ terminal_profile_class_init (TerminalProfileClass *klass) G_PARAM_READWRITE | TERMINAL_PROFILE_PSPEC_STATIC),\ propGSettings) -#define TERMINAL_PROFILE_PROPERTY_STRING_CO(prop, propDefault, propGSettings)\ - TERMINAL_PROFILE_PROPERTY (PROP_##prop,\ +#define TERMINAL_PROFILE_PROPERTY_STRING_CO(prop, propDefault)\ + TERMINAL_PROFILE_PROPERTY_OUTER (PROP_##prop,\ g_param_spec_string (TERMINAL_PROFILE_##prop, NULL, NULL,\ propDefault,\ - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | TERMINAL_PROFILE_PSPEC_STATIC),\ - propGSettings) + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | TERMINAL_PROFILE_PSPEC_STATIC)) #define TERMINAL_PROFILE_PROPERTY_VALUE_ARRAY_BOXED(prop, propElementName, propElementType, propGSettings)\ TERMINAL_PROFILE_PROPERTY (PROP_##prop,\ @@ -1323,9 +1336,10 @@ terminal_profile_class_init (TerminalProfileClass *klass) TERMINAL_PROFILE_PROPERTY_INT (DEFAULT_SIZE_ROWS, 1, 1024, DEFAULT_DEFAULT_SIZE_ROWS, KEY_DEFAULT_SIZE_ROWS); TERMINAL_PROFILE_PROPERTY_INT (SCROLLBACK_LINES, 1, G_MAXINT, DEFAULT_SCROLLBACK_LINES, KEY_SCROLLBACK_LINES); - TERMINAL_PROFILE_PROPERTY_OBJECT (BACKGROUND_IMAGE, GDK_TYPE_PIXBUF, NULL); + TERMINAL_PROFILE_PROPERTY_OBJECT (BACKGROUND_IMAGE, GDK_TYPE_PIXBUF); + + TERMINAL_PROFILE_PROPERTY_STRING_CO (NAME, DEFAULT_NAME); - TERMINAL_PROFILE_PROPERTY_STRING_CO (NAME, DEFAULT_NAME, NULL); TERMINAL_PROFILE_PROPERTY_STRING (BACKGROUND_IMAGE_FILE, DEFAULT_BACKGROUND_IMAGE_FILE, KEY_BACKGROUND_IMAGE_FILE); TERMINAL_PROFILE_PROPERTY_STRING (CUSTOM_COMMAND, DEFAULT_CUSTOM_COMMAND, KEY_CUSTOM_COMMAND); TERMINAL_PROFILE_PROPERTY_STRING (TITLE, _(DEFAULT_TITLE), KEY_TITLE); diff --git a/src/terminal-profile.h b/src/terminal-profile.h index d8f41b2..5ce6ece 100644 --- a/src/terminal-profile.h +++ b/src/terminal-profile.h @@ -2,6 +2,7 @@ * Copyright © 2001 Havoc Pennington * Copyright © 2002 Mathias Hasselmann * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/terminal-screen-container.c b/src/terminal-screen-container.c index 8e7418a..22dd4b7 100644 --- a/src/terminal-screen-container.c +++ b/src/terminal-screen-container.c @@ -1,5 +1,6 @@ /* * Copyright © 2008, 2010 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/terminal-screen-container.h b/src/terminal-screen-container.h index bc8843d..dc620d5 100644 --- a/src/terminal-screen-container.h +++ b/src/terminal-screen-container.h @@ -1,5 +1,6 @@ /* * Copyright © 2008, 2010 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/terminal-screen.c b/src/terminal-screen.c index 01bec75..7282f6d 100644 --- a/src/terminal-screen.c +++ b/src/terminal-screen.c @@ -1,6 +1,7 @@ /* * Copyright © 2001 Havoc Pennington * Copyright © 2007, 2008, 2010 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,7 +55,7 @@ typedef struct { int tag; - TerminalURLFlavour flavor; + TerminalURLFlavor flavor; } TagData; struct _TerminalScreenPrivate @@ -124,6 +125,8 @@ static void terminal_screen_change_font (TerminalScreen *screen); static gboolean terminal_screen_popup_menu (GtkWidget *widget); static gboolean terminal_screen_button_press (GtkWidget *widget, GdkEventButton *event); +static void terminal_screen_hierarchy_changed (GtkWidget *widget, + GtkWidget *previous_toplevel); static void terminal_screen_launch_child_on_idle (TerminalScreen *screen); static void terminal_screen_child_exited (VteTerminal *terminal, int status); @@ -134,6 +137,9 @@ static void terminal_screen_icon_title_changed (VteTerminal *vte_terminal static void update_color_scheme (TerminalScreen *screen); +static char* terminal_screen_check_hyperlink (TerminalScreen *screen, + GdkEvent *event); + static gboolean terminal_screen_format_title (TerminalScreen *screen, const char *raw_title, char **old_cooked_title); static void terminal_screen_cook_title (TerminalScreen *screen); @@ -160,7 +166,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { const char *pattern; - TerminalURLFlavour flavor; + TerminalURLFlavor flavor; guint32 flags; } TerminalRegexPattern; @@ -174,12 +180,11 @@ static const TerminalRegexPattern url_regex_patterns[] = }; static VteRegex **url_regexes; -static TerminalURLFlavour *url_regex_flavors; +static TerminalURLFlavor *url_regex_flavors; static guint n_url_regexes; static void terminal_screen_url_match_remove (TerminalScreen *screen); - #ifdef ENABLE_SKEY static const TerminalRegexPattern skey_regex_patterns[] = { @@ -351,6 +356,8 @@ terminal_screen_init (TerminalScreen *screen) vte_terminal_set_bold_is_bright (VTE_TERMINAL (screen), TRUE); #endif + vte_terminal_set_allow_hyperlink (VTE_TERMINAL (screen), TRUE); + priv->child_pid = -1; priv->font_scale = PANGO_SCALE_MEDIUM; @@ -484,6 +491,7 @@ terminal_screen_class_init (TerminalScreenClass *klass) widget_class->style_updated = terminal_screen_style_updated; widget_class->drag_data_received = terminal_screen_drag_data_received; widget_class->button_press_event = terminal_screen_button_press; + widget_class->hierarchy_changed = terminal_screen_hierarchy_changed; widget_class->popup_menu = terminal_screen_popup_menu; terminal_class->child_exited = terminal_screen_child_exited; @@ -574,7 +582,7 @@ terminal_screen_class_init (TerminalScreenClass *klass) /* Precompile the regexes */ n_url_regexes = G_N_ELEMENTS (url_regex_patterns); url_regexes = g_new0 (VteRegex*, n_url_regexes); - url_regex_flavors = g_new0 (TerminalURLFlavour, n_url_regexes); + url_regex_flavors = g_new0 (TerminalURLFlavor, n_url_regexes); for (i = 0; i < n_url_regexes; ++i) { @@ -1075,6 +1083,26 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile, } static void +update_toplevel_transparency (TerminalScreen *screen) +{ + GtkWidget *widget = GTK_WIDGET (screen); + TerminalScreenPrivate *priv = screen->priv; + TerminalProfile *profile = priv->profile; + TerminalBackgroundType bg_type = terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_BACKGROUND_TYPE); + + if (bg_type == TERMINAL_BACKGROUND_TRANSPARENT) + { + GtkWidget *toplevel; + toplevel = gtk_widget_get_toplevel (widget); + if (toplevel != NULL && gtk_widget_is_toplevel (toplevel) + && !gtk_widget_get_app_paintable (toplevel)) + { + gtk_widget_set_app_paintable (toplevel, TRUE); + } + } +} + +static void update_color_scheme (TerminalScreen *screen) { TerminalScreenPrivate *priv = screen->priv; @@ -1159,6 +1187,8 @@ update_color_scheme (TerminalScreen *screen) if (bold_rgba) vte_terminal_set_color_bold (VTE_TERMINAL (screen), bold_rgba); + + update_toplevel_transparency (screen); } void @@ -1448,8 +1478,6 @@ get_child_environment (TerminalScreen *screen, g_hash_table_replace (env_table, g_strdup ("WINDOWID"), g_strdup_printf ("%ld", GDK_WINDOW_XID (gtk_widget_get_window (window)))); } #endif - g_hash_table_replace (env_table, g_strdup ("DISPLAY"), g_strdup (gdk_display_get_name (display))); - g_settings_schema_source_list_schemas (g_settings_schema_source_get_default (), TRUE, &list_schemas, NULL); schema_exists = FALSE; @@ -1657,7 +1685,8 @@ terminal_screen_popup_info_unref (TerminalScreenPopupInfo *info) return; g_object_unref (info->screen); - g_free (info->string); + g_free (info->hyperlink); + g_free (info->url); g_slice_free (TerminalScreenPopupInfo, info); } @@ -1684,38 +1713,55 @@ terminal_screen_button_press (GtkWidget *widget, TerminalScreen *screen = TERMINAL_SCREEN (widget); gboolean (* button_press_event) (GtkWidget*, GdkEventButton*) = GTK_WIDGET_CLASS (terminal_screen_parent_class)->button_press_event; - char *matched_string; - int matched_flavor = 0; + char *hyperlink; + char *url; + int url_flavor = FLAVOR_AS_IS; guint state; state = event->state & gtk_accelerator_get_default_mod_mask (); + hyperlink = terminal_screen_check_hyperlink (screen, (GdkEvent*)event); + url = terminal_screen_check_match (screen, (GdkEvent*)event, &url_flavor); - matched_string = terminal_screen_check_match (screen, (GdkEvent*)event, &matched_flavor); - - if (matched_string != NULL && - (event->button == 1 || event->button == 2) && - (state & GDK_CONTROL_MASK)) + // left or middle button with Ctrl + if ((event->button == 1 || event->button == 2) && + (state & GDK_CONTROL_MASK)) { gboolean handled = FALSE; + if (hyperlink != NULL) + g_signal_emit (screen, signals[MATCH_CLICKED], 0, + hyperlink, + FLAVOR_AS_IS, + state, + &handled); + + if (handled) { + g_free (url); + g_free (hyperlink); + return TRUE; /* don't do anything else such as select with the click */ + } + #ifdef ENABLE_SKEY - if (matched_flavor != FLAVOR_SKEY || + if (url_flavor != FLAVOR_SKEY || terminal_profile_get_property_boolean (screen->priv->profile, TERMINAL_PROFILE_USE_SKEY)) #endif + if (url != NULL) { g_signal_emit (screen, signals[MATCH_CLICKED], 0, - matched_string, - matched_flavor, + url, + url_flavor, state, &handled); } - g_free (matched_string); - - if (handled) + if (handled) { + g_free (url); + g_free (hyperlink); return TRUE; /* don't do anything else such as select with the click */ + } } + // right button with no Ctrl, Alt or Shift if (event->button == 3 && (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0) { @@ -1725,8 +1771,9 @@ terminal_screen_button_press (GtkWidget *widget, info->button = event->button; info->state = state; info->timestamp = event->time; - info->string = matched_string; /* adopted */ - info->flavour = matched_flavor; + info->url = url; /* adopted */ + info->hyperlink = hyperlink; /* adopted */ + info->flavor = url_flavor; g_signal_emit (screen, signals[SHOW_POPUP_MENU], 0, info); terminal_screen_popup_info_unref (info); @@ -1734,6 +1781,9 @@ terminal_screen_button_press (GtkWidget *widget, return TRUE; } + g_free (url); + g_free (hyperlink); + /* default behavior is to let the terminal widget deal with it */ if (button_press_event) return button_press_event (widget, event); @@ -1742,6 +1792,13 @@ terminal_screen_button_press (GtkWidget *widget, } static void +terminal_screen_hierarchy_changed (GtkWidget *widget, + GtkWidget *previous_toplevel) +{ + update_toplevel_transparency (TERMINAL_SCREEN (widget)); +} + +static void terminal_screen_set_dynamic_title (TerminalScreen *screen, const char *title, gboolean userset) @@ -2351,6 +2408,13 @@ terminal_screen_url_match_remove (TerminalScreen *screen) } static char* +terminal_screen_check_hyperlink (TerminalScreen *screen, + GdkEvent *event) +{ + return vte_terminal_hyperlink_check_event (VTE_TERMINAL (screen), event); +} + +static char* terminal_screen_check_match (TerminalScreen *screen, GdkEvent *event, int *flavor) diff --git a/src/terminal-screen.h b/src/terminal-screen.h index b74372b..ba1c218 100644 --- a/src/terminal-screen.h +++ b/src/terminal-screen.h @@ -1,6 +1,7 @@ /* * Copyright © 2001 Havoc Pennington * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -34,7 +35,7 @@ typedef enum FLAVOR_VOIP_CALL, FLAVOR_EMAIL, FLAVOR_SKEY -} TerminalURLFlavour; +} TerminalURLFlavor; /* Forward decls */ typedef struct _TerminalScreenPopupInfo TerminalScreenPopupInfo; @@ -68,7 +69,7 @@ struct _TerminalScreenClass TerminalScreenPopupInfo *info); gboolean (* match_clicked) (TerminalScreen *screen, const char *url, - int flavour, + int url_flavor, guint state); void (* close_screen) (TerminalScreen *screen); }; @@ -146,8 +147,9 @@ struct _TerminalScreenPopupInfo int ref_count; TerminalWindow *window; TerminalScreen *screen; - char *string; - TerminalURLFlavour flavour; + char *url; + char *hyperlink; + TerminalURLFlavor flavor; guint button; guint state; guint32 timestamp; diff --git a/src/terminal-search-dialog.c b/src/terminal-search-dialog.c index 86d0ce7..2e73ee5 100644 --- a/src/terminal-search-dialog.c +++ b/src/terminal-search-dialog.c @@ -1,6 +1,7 @@ /* * Copyright © 2005 Paolo Maggi * Copyright © 2010 Red Hat (Red Hat author: Behdad Esfahbod) + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,7 +43,6 @@ get_quark (void) return quark; } - #define TERMINAL_SEARCH_DIALOG_GET_PRIVATE(object) \ ((TerminalSearchDialogPrivate *) g_object_get_qdata (G_OBJECT (object), get_quark ())) @@ -67,7 +67,6 @@ typedef struct _TerminalSearchDialogPrivate guint32 regex_compile_flags; } TerminalSearchDialogPrivate; - static void update_sensitivity (void *unused, GtkWidget *dialog); static void response_handler (GtkWidget *dialog, @@ -75,7 +74,6 @@ static void response_handler (GtkWidget *dialog, gpointer data); static void terminal_search_dialog_private_destroy (TerminalSearchDialogPrivate *priv); - GtkWidget * terminal_search_dialog_new (GtkWindow *parent) { @@ -104,7 +102,6 @@ terminal_search_dialog_new (GtkWindow *parent) g_object_set_qdata_full (G_OBJECT (dialog), get_quark (), priv, (GDestroyNotify) terminal_search_dialog_private_destroy); - priv->search_text_entry = gtk_bin_get_child (GTK_BIN (priv->search_entry)); gtk_widget_set_size_request (priv->search_entry, 300, -1); @@ -164,7 +161,6 @@ terminal_search_dialog_private_destroy (TerminalSearchDialogPrivate *priv) g_free (priv); } - static void update_sensitivity (void *unused, GtkWidget *dialog) { @@ -286,7 +282,6 @@ response_handler (GtkWidget *dialog, history_entry_insert (priv->store, str); } - void terminal_search_dialog_set_search_text (GtkWidget *dialog, const gchar *text) diff --git a/src/terminal-search-dialog.h b/src/terminal-search-dialog.h index 8c87e91..8a91d1e 100644 --- a/src/terminal-search-dialog.h +++ b/src/terminal-search-dialog.h @@ -1,6 +1,7 @@ /* * Copyright © 2005 Paolo Maggi * Copyright © 2010 Red Hat (Red Hat author: Behdad Esfahbod) + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +33,6 @@ typedef enum _TerminalSearchFlags TERMINAL_SEARCH_FLAG_WRAP_AROUND = 1 << 1 } TerminalSearchFlags; - GtkWidget *terminal_search_dialog_new (GtkWindow *parent); void terminal_search_dialog_present (GtkWidget *dialog); diff --git a/src/terminal-tab-label.c b/src/terminal-tab-label.c index c7ec6cb..deb0d26 100644 --- a/src/terminal-tab-label.c +++ b/src/terminal-tab-label.c @@ -1,6 +1,7 @@ /* * Copyright © 2001 Havoc Pennington * Copyright © 2007, 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/terminal-tab-label.h b/src/terminal-tab-label.h index 685f5ef..07219db 100644 --- a/src/terminal-tab-label.h +++ b/src/terminal-tab-label.h @@ -1,5 +1,6 @@ /* * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/terminal-tabs-menu.c b/src/terminal-tabs-menu.c index 89622a1..d1a22b5 100644 --- a/src/terminal-tabs-menu.c +++ b/src/terminal-tabs-menu.c @@ -2,6 +2,7 @@ /* * Copyright © 2003 David Bordoley * Copyright © 2003-2004 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/terminal-tabs-menu.h b/src/terminal-tabs-menu.h index 6e609e5..5bb2e19 100644 --- a/src/terminal-tabs-menu.h +++ b/src/terminal-tabs-menu.h @@ -1,5 +1,6 @@ /* * Copyright © 2003 David Bordoley + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/terminal-util.c b/src/terminal-util.c index 1ffb629..3e32a69 100644 --- a/src/terminal-util.c +++ b/src/terminal-util.c @@ -4,6 +4,7 @@ * Copyright © 2002 Sun Microsystems * Copyright © 2003 Mariano Suarez-Alvarez * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,9 +22,9 @@ #include <config.h> +#define _GNU_SOURCE /* for strchrnul */ #include <string.h> #include <stdlib.h> -#include <time.h> #include <unistd.h> #include <sys/types.h> @@ -48,7 +49,8 @@ terminal_util_set_unique_role (GtkWindow *window, const char *prefix) { char *role; - role = g_strdup_printf ("%s-%d-%d-%d", prefix, getpid (), g_random_int (), (int) time (NULL)); + role = g_strdup_printf ("%s-%d-%d-%" G_GINT64_FORMAT, prefix, getpid (), g_random_int (), + g_get_real_time () / G_USEC_PER_SEC); gtk_window_set_role (window, role); g_free (role); } @@ -167,7 +169,6 @@ terminal_util_set_atk_name_description (GtkWidget *widget, return; } - if (!GTK_IS_ACCESSIBLE (obj)) return; /* This means GAIL is not loaded so we have the NoOp accessible */ @@ -181,7 +182,7 @@ terminal_util_set_atk_name_description (GtkWidget *widget, void terminal_util_open_url (GtkWidget *parent, const char *orig_url, - TerminalURLFlavour flavor, + TerminalURLFlavor flavor, guint32 user_time) { GError *error = NULL; @@ -707,6 +708,74 @@ terminal_util_add_proxy_env (GHashTable *env_table) g_object_unref (settings_socks); } +/** + * terminal_util_hyperlink_uri_label: + * @uri: a URI + * + * Formats @uri to be displayed in a tooltip. + * Performs URI-decoding and converts IDN hostname to UTF-8. + * + * Returns: (transfer full): The human readable URI as plain text + */ +char *terminal_util_hyperlink_uri_label (const char *uri) +{ + char *unesc = NULL; + gboolean replace_hostname; + + if (uri == NULL) + return NULL; + + unesc = g_uri_unescape_string(uri, NULL); + if (unesc == NULL) + unesc = g_strdup(uri); + + if (g_ascii_strncasecmp(unesc, "ftp://", 6) == 0 || + g_ascii_strncasecmp(unesc, "http://", 7) == 0 || + g_ascii_strncasecmp(unesc, "https://", 8) == 0) + { + char *unidn = NULL; + + char *hostname = strchr(unesc, '/') + 2; + char *hostname_end = strchrnul(hostname, '/'); + char save = *hostname_end; + *hostname_end = '\0'; + unidn = g_hostname_to_unicode(hostname); + replace_hostname = unidn != NULL && g_ascii_strcasecmp(unidn, hostname) != 0; + *hostname_end = save; + if (replace_hostname) + { + char *new_unesc = g_strdup_printf("%.*s%s%s", + (int) (hostname - unesc), + unesc, + unidn, + hostname_end); + g_free(unesc); + unesc = new_unesc; + } + g_free(unidn); + } + if (g_ascii_strncasecmp(unesc, "mailto:", 7) == 0) + { + const char *hostname = strchr(unesc, '@'); + if (hostname != NULL) + { + const char *unidn = g_hostname_to_unicode(++hostname); + replace_hostname = unidn != NULL && g_ascii_strcasecmp(unidn, hostname) != 0; + if (replace_hostname) + { + char *new_unesc = g_strdup_printf("%.*s%s", + (int) (hostname - unesc), + unesc, + unidn); + g_free(unesc); + unesc = new_unesc; + } + g_free(unidn); + } + } + return unesc; +} + /* Bidirectional object/widget binding */ typedef struct @@ -868,9 +937,9 @@ widget_change_notify_cb (PropertyChange *change) } else if (GTK_IS_SPIN_BUTTON (widget)) { - int value; + gint value; - value = (int) gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget)); + value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget)); g_object_set (object, object_prop, value, NULL); } else if (GTK_IS_ENTRY (widget)) diff --git a/src/terminal-util.h b/src/terminal-util.h index 97b9459..f1ccd43 100644 --- a/src/terminal-util.h +++ b/src/terminal-util.h @@ -1,6 +1,7 @@ /* * Copyright © 2001 Havoc Pennington * Copyright © 2008 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -50,7 +51,7 @@ void terminal_util_set_atk_name_description (GtkWidget *widget, void terminal_util_open_url (GtkWidget *parent, const char *orig_url, - TerminalURLFlavour flavor, + TerminalURLFlavor flavor, guint32 user_time); char *terminal_util_resolve_relative_path (const char *path, @@ -103,6 +104,8 @@ void terminal_util_bind_object_property_to_widget (GObject *object, void terminal_util_x11_clear_demands_attention (GdkWindow *window); +char *terminal_util_hyperlink_uri_label (const char *str); + G_END_DECLS #endif /* TERMINAL_UTIL_H */ diff --git a/src/terminal-version.h.in b/src/terminal-version.h.in index 5bc4f2d..5f5541c 100644 --- a/src/terminal-version.h.in +++ b/src/terminal-version.h.in @@ -1,5 +1,6 @@ /* * Copyright © 2009 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the diff --git a/src/terminal-window.c b/src/terminal-window.c index dc7a495..fd50df7 100644 --- a/src/terminal-window.c +++ b/src/terminal-window.c @@ -2,6 +2,7 @@ * Copyright © 2001 Havoc Pennington * Copyright © 2002 Red Hat, Inc. * Copyright © 2007, 2008, 2009 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -107,7 +108,8 @@ struct _TerminalWindowPrivate /* Workaround until gtk+ bug #535557 is fixed */ guint icon_title_set : 1; - time_t focus_time; + + gint64 focus_time; /* should we copy selection to clibpoard */ int copy_selection; @@ -517,27 +519,23 @@ escape_underscores (const char *name) } static int -find_tab_num_at_pos (GtkNotebook *notebook, +find_tab_num_at_pos (GtkNotebook *nb, int screen_x, int screen_y) { - GtkPositionType tab_pos; int page_num = 0; - GtkNotebook *nb = GTK_NOTEBOOK (notebook); GtkWidget *page; GtkAllocation tab_allocation; - tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook)); - while ((page = gtk_notebook_get_nth_page (nb, page_num))) { GtkWidget *tab; - int max_x, max_y, x_root, y_root; + int x_root, y_root; tab = gtk_notebook_get_tab_label (nb, page); g_return_val_if_fail (tab != NULL, -1); - if (!gtk_widget_get_mapped (GTK_WIDGET (tab))) + if (!gtk_widget_get_mapped (tab)) { page_num++; continue; @@ -546,13 +544,10 @@ find_tab_num_at_pos (GtkNotebook *notebook, gdk_window_get_origin (gtk_widget_get_window (tab), &x_root, &y_root); gtk_widget_get_allocation (tab, &tab_allocation); - max_x = x_root + tab_allocation.x + tab_allocation.width; - max_y = y_root + tab_allocation.y + tab_allocation.height; - - if ((tab_pos == GTK_POS_TOP || tab_pos == GTK_POS_BOTTOM) && screen_x <= max_x) - return page_num; - - if ((tab_pos == GTK_POS_LEFT || tab_pos == GTK_POS_RIGHT) && screen_y <= max_y) + if (screen_x >= x_root + tab_allocation.x && + screen_x <= x_root + tab_allocation.x + tab_allocation.width && + screen_y >= y_root + tab_allocation.y && + screen_y <= y_root + tab_allocation.y + tab_allocation.height) return page_num; page_num++; @@ -1364,6 +1359,38 @@ handle_tab_droped_on_desktop (GtkNotebook *source_notebook, /* Terminal screen popup menu handling */ static void +popup_open_hyperlink_callback (GtkAction *action, + TerminalWindow *window) +{ + TerminalWindowPrivate *priv = window->priv; + TerminalScreenPopupInfo *info = priv->popup_info; + + if (info == NULL) + return; + + terminal_util_open_url (GTK_WIDGET (window), info->hyperlink, FLAVOR_AS_IS, + gtk_get_current_event_time ()); +} + +static void +popup_copy_hyperlink_callback (GtkAction *action, + TerminalWindow *window) +{ + TerminalWindowPrivate *priv = window->priv; + TerminalScreenPopupInfo *info = priv->popup_info; + GtkClipboard *clipboard; + + if (info == NULL) + return; + + if (info->hyperlink == NULL) + return; + + clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window), GDK_SELECTION_CLIPBOARD); + gtk_clipboard_set_text (clipboard, info->hyperlink, -1); +} + +static void popup_open_url_callback (GtkAction *action, TerminalWindow *window) { @@ -1373,7 +1400,7 @@ popup_open_url_callback (GtkAction *action, if (info == NULL) return; - terminal_util_open_url (GTK_WIDGET (window), info->string, info->flavour, + terminal_util_open_url (GTK_WIDGET (window), info->url, info->flavor, gtk_get_current_event_time ()); } @@ -1388,11 +1415,11 @@ popup_copy_url_callback (GtkAction *action, if (info == NULL) return; - if (info->string == NULL) + if (info->url == NULL) return; clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window), GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_text (clipboard, info->string, -1); + gtk_clipboard_set_text (clipboard, info->url, -1); } static void @@ -1474,7 +1501,7 @@ popup_clipboard_targets_received_cb (GtkClipboard *clipboard, TerminalScreen *screen = info->screen; GtkWidget *popup_menu; GtkAction *action; - gboolean can_paste, can_paste_uris, show_link, show_email_link, show_call_link, show_input_method_menu; + gboolean can_paste, can_paste_uris, show_hyperlink, show_link, show_email_link, show_call_link, show_input_method_menu; int n_pages; if (!gtk_widget_get_realized (GTK_WIDGET (screen))) @@ -1492,11 +1519,16 @@ popup_clipboard_targets_received_cb (GtkClipboard *clipboard, can_paste = targets != NULL && gtk_targets_include_text (targets, n_targets); can_paste_uris = targets != NULL && gtk_targets_include_uri (targets, n_targets); - show_link = info->string != NULL && (info->flavour == FLAVOR_AS_IS || info->flavour == FLAVOR_DEFAULT_TO_HTTP); - show_email_link = info->string != NULL && info->flavour == FLAVOR_EMAIL; - show_call_link = info->string != NULL && info->flavour == FLAVOR_VOIP_CALL; + show_hyperlink = info->hyperlink != NULL; + show_link = !show_hyperlink && info->url != NULL && (info->flavor == FLAVOR_AS_IS || info->flavor == FLAVOR_DEFAULT_TO_HTTP); + show_email_link = !show_hyperlink && info->url != NULL && info->flavor == FLAVOR_EMAIL; + show_call_link = !show_hyperlink && info->url != NULL && info->flavor == FLAVOR_VOIP_CALL; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + action = gtk_action_group_get_action (priv->action_group, "PopupOpenHyperlink"); + gtk_action_set_visible (action, show_hyperlink); + action = gtk_action_group_get_action (priv->action_group, "PopupCopyHyperlinkAddress"); + gtk_action_set_visible (action, show_hyperlink); action = gtk_action_group_get_action (priv->action_group, "PopupSendEmail"); gtk_action_set_visible (action, show_email_link); action = gtk_action_group_get_action (priv->action_group, "PopupCopyEmailAddress"); @@ -1553,6 +1585,8 @@ popup_clipboard_targets_received_cb (GtkClipboard *clipboard, NULL, NULL, info->button, info->timestamp); + gtk_style_context_add_class(gtk_widget_get_style_context (popup_menu), + GTK_STYLE_CLASS_CONTEXT_MENU); } static void @@ -1572,8 +1606,8 @@ screen_show_popup_menu_callback (TerminalScreen *screen, static gboolean screen_match_clicked_cb (TerminalScreen *screen, - const char *match, - int flavour, + const char *url, + int url_flavor, guint state, TerminalWindow *window) { @@ -1582,16 +1616,16 @@ screen_match_clicked_cb (TerminalScreen *screen, if (screen != priv->active_screen) return FALSE; - switch (flavour) + switch (url_flavor) { #ifdef ENABLE_SKEY case FLAVOR_SKEY: - terminal_skey_do_popup (GTK_WINDOW (window), screen, match); + terminal_skey_do_popup (GTK_WINDOW (window), screen, url); break; #endif default: gtk_widget_grab_focus (GTK_WIDGET (screen)); - terminal_util_open_url (GTK_WIDGET (window), match, flavour, + terminal_util_open_url (GTK_WIDGET (window), url, url_flavor, gtk_get_current_event_time ()); break; } @@ -1709,6 +1743,39 @@ terminal_window_realize (GtkWidget *widget) } static gboolean +terminal_window_draw (GtkWidget *widget, + cairo_t *cr) +{ + if (gtk_widget_get_app_paintable(widget)) + { + GtkAllocation child_allocation; + GtkStyleContext *context; + int width; + int height; + GtkWidget *child; + + /* Get the *child* allocation, so we don't overwrite window borders */ + child = gtk_bin_get_child (GTK_BIN (widget)); + gtk_widget_get_allocation (child, &child_allocation); + + context = gtk_widget_get_style_context (widget); + width = gtk_widget_get_allocated_width (widget); + height = gtk_widget_get_allocated_height (widget); + gtk_render_background (context, cr, 0, 0, width, height); + gtk_render_frame (context, cr, 0, 0, width, height); + + gtk_render_background (context, cr, + child_allocation.x, child_allocation.y, + child_allocation.width, child_allocation.height); + gtk_render_frame (context, cr, + child_allocation.x, child_allocation.y, + child_allocation.width, child_allocation.height); + } + + return GTK_WIDGET_CLASS (terminal_window_parent_class)->draw (widget, cr); +} + +static gboolean terminal_window_map_event (GtkWidget *widget, GdkEventAny *event) { @@ -1740,7 +1807,6 @@ terminal_window_map_event (GtkWidget *widget, return FALSE; } - static gboolean terminal_window_state_event (GtkWidget *widget, GdkEventWindowState *event) @@ -1872,17 +1938,17 @@ terminal_window_init (TerminalWindow *window) const GtkActionEntry menu_entries[] = { /* Toplevel */ - { "File", NULL, N_("_File") }, - { "FileNewWindowProfiles", "utilities-terminal", N_("Open _Terminal")}, - { "FileNewTabProfiles", STOCK_NEW_TAB, N_("Open Ta_b") }, - { "Edit", NULL, N_("_Edit") }, - { "View", NULL, N_("_View") }, - { "Search", NULL, N_("_Search") }, - { "Terminal", NULL, N_("_Terminal") }, - { "Tabs", NULL, N_("Ta_bs") }, - { "Help", NULL, N_("_Help") }, - { "Popup", NULL, NULL }, - { "NotebookPopup", NULL, "" }, + { "File", NULL, N_("_File"), NULL, NULL, NULL }, + { "FileNewWindowProfiles", "utilities-terminal", N_("Open _Terminal"), NULL, NULL, NULL }, + { "FileNewTabProfiles", STOCK_NEW_TAB, N_("Open Ta_b"), NULL, NULL, NULL }, + { "Edit", NULL, N_("_Edit"), NULL, NULL, NULL }, + { "View", NULL, N_("_View"), NULL, NULL, NULL }, + { "Search", NULL, N_("_Search"), NULL, NULL, NULL }, + { "Terminal", NULL, N_("_Terminal"), NULL, NULL, NULL }, + { "Tabs", NULL, N_("Ta_bs"), NULL, NULL, NULL }, + { "Help", NULL, N_("_Help"), NULL, NULL, NULL }, + { "Popup", NULL, NULL, NULL, NULL, NULL }, + { "NotebookPopup", NULL, "", NULL, NULL, NULL }, /* File menu */ { @@ -2005,7 +2071,7 @@ terminal_window_init (TerminalWindow *window) #endif /* Terminal menu */ - { "TerminalProfiles", NULL, N_("Change _Profile") }, + { "TerminalProfiles", NULL, N_("Change _Profile"), NULL, NULL, NULL }, { "ProfilePrevious", NULL, N_("_Previous Profile"), "<alt>Page_Up", NULL, @@ -2021,7 +2087,7 @@ terminal_window_init (TerminalWindow *window) NULL, G_CALLBACK (terminal_set_title_callback) }, - { "TerminalSetEncoding", NULL, N_("Set _Character Encoding") }, + { "TerminalSetEncoding", NULL, N_("Set _Character Encoding"), NULL, NULL, NULL }, { "TerminalReset", NULL, N_("_Reset"), NULL, NULL, @@ -2081,6 +2147,16 @@ terminal_window_init (TerminalWindow *window) /* Popup menu */ { + "PopupOpenHyperlink", NULL, N_("_Open Hyperlink"), NULL, + NULL, + G_CALLBACK (popup_open_hyperlink_callback) + }, + { + "PopupCopyHyperlinkAddress", NULL, N_("_Copy Hyperlink Address"), NULL, + NULL, + G_CALLBACK (popup_copy_hyperlink_callback) + }, + { "PopupSendEmail", NULL, N_("_Send Mail To…"), NULL, NULL, G_CALLBACK (popup_open_url_callback) @@ -2110,7 +2186,7 @@ terminal_window_init (TerminalWindow *window) NULL, G_CALLBACK (popup_copy_url_callback) }, - { "PopupTerminalProfiles", NULL, N_("P_rofiles") }, + { "PopupTerminalProfiles", NULL, N_("P_rofiles"), NULL, NULL, NULL }, { "PopupCopy", "edit-copy", N_("_Copy"), "", NULL, @@ -2151,7 +2227,7 @@ terminal_window_init (TerminalWindow *window) NULL, G_CALLBACK (popup_leave_fullscreen_callback) }, - { "PopupInputMethods", NULL, N_("_Input Methods") } + { "PopupInputMethods", NULL, N_("_Input Methods"), NULL, NULL, NULL } }; const GtkToggleActionEntry toggle_menu_entries[] = @@ -2342,6 +2418,7 @@ terminal_window_class_init (TerminalWindowClass *klass) widget_class->show = terminal_window_show; widget_class->realize = terminal_window_realize; + widget_class->draw = terminal_window_draw; widget_class->map_event = terminal_window_map_event; widget_class->window_state_event = terminal_window_state_event; widget_class->screen_changed = terminal_window_screen_changed; @@ -2432,7 +2509,7 @@ terminal_window_focus_in_event (GtkWidget *widget, TerminalWindowPrivate *priv = window->priv; if (event->in) - priv->focus_time = time(NULL); + priv->focus_time = g_get_real_time () / G_USEC_PER_SEC; return FALSE; } @@ -2535,8 +2612,6 @@ sync_screen_icon_title (TerminalScreen *screen, return; gdk_window_set_icon_name (gtk_widget_get_window (GTK_WIDGET (window)), terminal_screen_get_icon_title (screen)); - - priv->icon_title_set = TRUE; } static void @@ -2549,10 +2624,6 @@ sync_screen_icon_title_set (TerminalScreen *screen, if (!gtk_widget_get_realized (GTK_WIDGET (window))) return; - /* No need to restore the title if we never set an icon title */ - if (!priv->icon_title_set) - return; - if (screen != priv->active_screen) return; @@ -2560,16 +2631,28 @@ sync_screen_icon_title_set (TerminalScreen *screen, return; /* Need to reset the icon name */ - /* FIXME: Once gtk+ bug 535557 is fixed, use that to unset the icon title. */ - - g_object_set_qdata (G_OBJECT (gtk_widget_get_window (GTK_WIDGET (window))), - g_quark_from_static_string ("gdk-icon-name-set"), - GUINT_TO_POINTER (FALSE)); - priv->icon_title_set = FALSE; + gdk_window_set_icon_name (gtk_widget_get_window (GTK_WIDGET (window)), NULL); /* Re-setting the right title will be done by the notify::title handler which comes after this one */ } +static void +screen_hyperlink_hover_uri_changed (TerminalScreen *screen, + const char *uri, + const GdkRectangle *bbox G_GNUC_UNUSED, + TerminalWindow *window G_GNUC_UNUSED) +{ + char *label = NULL; + + if (!gtk_widget_get_realized (GTK_WIDGET (screen))) + return; + + label = terminal_util_hyperlink_uri_label (uri); + + gtk_widget_set_tooltip_text (GTK_WIDGET (screen), label); + g_free(label); +} + /* Notebook callbacks */ static void @@ -2725,7 +2808,7 @@ terminal_window_set_menubar_visible (TerminalWindow *window, if (setting == priv->menubar_visible) return; - priv->menubar_visible = setting; + priv->menubar_visible = (setting != FALSE); G_GNUC_BEGIN_IGNORE_DEPRECATIONS; action = gtk_action_group_get_action (priv->action_group, "ViewMenubar"); @@ -2965,6 +3048,16 @@ notebook_button_press_cb (GtkWidget *widget, } } + /* If the event is a double click, display the set title dialog */ + if (event->type == GDK_DOUBLE_BUTTON_PRESS && + find_tab_num_at_pos (notebook, (int) event->x_root, (int) event->y_root) >= 0) + { + terminal_set_title_callback (NULL, window); + + /* handle ONLY the double-click event */ + return TRUE; + } + if (event->type != GDK_BUTTON_PRESS || event->button != 3 || (event->state & gtk_accelerator_get_default_mod_mask ()) != 0) @@ -3174,6 +3267,8 @@ notebook_page_added_callback (GtkWidget *notebook, G_CALLBACK (sync_screen_icon_title_set), window); g_signal_connect (screen, "selection-changed", G_CALLBACK (terminal_window_update_copy_sensitivity), window); + g_signal_connect (screen, "hyperlink-hover-uri-changed", + G_CALLBACK (screen_hyperlink_hover_uri_changed), window); g_signal_connect (screen, "show-popup-menu", G_CALLBACK (screen_show_popup_menu_callback), window); @@ -3254,6 +3349,10 @@ notebook_page_removed_callback (GtkWidget *notebook, G_CALLBACK (terminal_window_update_copy_sensitivity), window); + g_signal_handlers_disconnect_by_func (G_OBJECT (screen), + G_CALLBACK (screen_hyperlink_hover_uri_changed), + window); + g_signal_handlers_disconnect_by_func (screen, G_CALLBACK (screen_show_popup_menu_callback), window); @@ -3363,10 +3462,11 @@ terminal_window_update_geometry (TerminalWindow *window) GtkWidget *widget; GdkGeometry hints; GtkBorder padding; - GtkRequisition toplevel_request, vbox_request, widget_request; + GtkRequisition vbox_request; int grid_width, grid_height; int char_width, char_height; int chrome_width, chrome_height; + int csd_width = 0, csd_height = 0; if (priv->active_screen == NULL) return; @@ -3397,20 +3497,41 @@ terminal_window_update_geometry (TerminalWindow *window) _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "content area requests %dx%d px\n", vbox_request.width, vbox_request.height); - gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &toplevel_request); - _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "window requests %dx%d px\n", - toplevel_request.width, toplevel_request.height); - chrome_width = vbox_request.width - (char_width * grid_width); chrome_height = vbox_request.height - (char_height * grid_height); _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "chrome: %dx%d px\n", chrome_width, chrome_height); - gtk_widget_get_preferred_size (widget, NULL, &widget_request); - _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "terminal widget requests %dx%d px\n", - widget_request.width, widget_request.height); + if (gtk_widget_get_realized (GTK_WIDGET (window))) { + GtkAllocation toplevel_allocation, vbox_allocation; + + gtk_widget_get_allocation (priv->main_vbox, &vbox_allocation); + _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, + "terminal widget allocation %dx%d px\n", + vbox_allocation.width, vbox_allocation.height); + + gtk_widget_get_allocation (GTK_WIDGET (window), &toplevel_allocation); + _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "window allocation %dx%d px\n", + toplevel_allocation.width, toplevel_allocation.height); + + csd_width = toplevel_allocation.width - vbox_allocation.width; + csd_height = toplevel_allocation.height - vbox_allocation.height; + _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "CSDs: %dx%d px\n", + csd_width, csd_height); + } - if (char_width != priv->old_char_width || + if (!gtk_widget_get_realized (GTK_WIDGET (window))) + { + /* Don't actually set the geometry hints until we have been realized, + * because we don't know how large the client-side decorations are going + * to be. + * + * Similarly, the size request doesn't seem to include the padding + * until we've been redrawn at least once. Don't resize the window + * until we've done that. */ + _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "not realized yet\n"); + } + else if (char_width != priv->old_char_width || char_height != priv->old_char_height || padding.left + padding.right != priv->old_padding_width || padding.top + padding.bottom != priv->old_padding_height || @@ -3418,8 +3539,8 @@ terminal_window_update_geometry (TerminalWindow *window) chrome_height != priv->old_chrome_height || widget != GTK_WIDGET (priv->old_geometry_widget)) { - hints.base_width = chrome_width; - hints.base_height = chrome_height; + hints.base_width = chrome_width + csd_width; + hints.base_height = chrome_height + csd_height; #define MIN_WIDTH_CHARS 4 #define MIN_HEIGHT_CHARS 1 @@ -3563,14 +3684,11 @@ confirm_close_window_or_tab (TerminalWindow *window, GtkBuilder *builder; TerminalWindowPrivate *priv = window->priv; GtkWidget *dialog; - gboolean do_confirm; gboolean has_processes; int n_tabs; char *confirm_msg; - do_confirm = g_settings_get_boolean (settings_global, "confirm-window-close"); - - if (!do_confirm) + if (!g_settings_get_boolean (settings_global, "confirm-window-close")) return FALSE; if (screen) @@ -3582,8 +3700,6 @@ confirm_close_window_or_tab (TerminalWindow *window, { GList *tabs, *t; - do_confirm = FALSE; - tabs = terminal_window_list_screen_containers (window); n_tabs = g_list_length (tabs); @@ -3599,7 +3715,6 @@ confirm_close_window_or_tab (TerminalWindow *window, g_list_free (tabs); } - if (has_processes) { if (n_tabs > 1) @@ -3613,7 +3728,6 @@ confirm_close_window_or_tab (TerminalWindow *window, else return FALSE; - builder = gtk_builder_new_from_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/confirm-close-dialog.ui"); priv->confirm_close_dialog = dialog = GTK_WIDGET (gtk_builder_get_object (builder, "confirm_close_dialog")); if (n_tabs > 1) { @@ -3791,8 +3905,7 @@ clipboard_uris_received_cb (GtkClipboard *clipboard, } /* This potentially modifies the strings in |uris| but that's ok */ - if (data->uris_as_paths) - terminal_util_transform_uris_to_quoted_fuse_paths (uris); + terminal_util_transform_uris_to_quoted_fuse_paths (uris); text = terminal_util_concat_uris (uris, &len); vte_terminal_feed_child (VTE_TERMINAL (data->screen), text, len); @@ -3815,7 +3928,7 @@ clipboard_targets_received_cb (GtkClipboard *clipboard, return; } - if (gtk_targets_include_uri (targets, n_targets)) + if (data->uris_as_paths && gtk_targets_include_uri (targets, n_targets)) { gtk_clipboard_request_uris (clipboard, (GtkClipboardURIReceivedFunc) clipboard_uris_received_cb, @@ -4043,7 +4156,6 @@ view_zoom_normal_callback (GtkAction *action, terminal_window_update_zoom_sensitivity (window); } - static void search_find_response_callback (GtkWidget *dialog, int response, @@ -4212,6 +4324,7 @@ terminal_set_title_dialog_response_cb (GtkWidget *dialog, } gtk_widget_destroy (dialog); + gtk_widget_grab_focus (GTK_WIDGET (screen)); } static void @@ -4384,7 +4497,6 @@ help_about_callback (GtkAction *action, gsize data_len, n_authors = 0, n_contributors = 0, n_artists = 0, n_documenters = 0 , i; GPtrArray *array; - bytes = g_resources_lookup_data (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/terminal.about", G_RESOURCE_LOOKUP_FLAGS_NONE, &error); @@ -4534,7 +4646,6 @@ terminal_window_save_state (TerminalWindow *window, g_strfreev (tab_names); } - TerminalWindow * terminal_window_get_latest_focused (TerminalWindow *window1, TerminalWindow *window2) diff --git a/src/terminal-window.h b/src/terminal-window.h index 4b8f846..b96afab 100644 --- a/src/terminal-window.h +++ b/src/terminal-window.h @@ -1,5 +1,6 @@ /* * Copyright © 2001 Havoc Pennington + * Copyright (C) 2012-2021 MATE Developers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public diff --git a/src/terminal.c b/src/terminal.c index 2f65284..7909fdf 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -4,6 +4,7 @@ * Copyright © 2002 Sun Microsystems * Copyright © 2003 Mariano Suarez-Alvarez * Copyright © 2008, 2010 Christian Persch + * Copyright (C) 2012-2021 MATE Developers * * Mate-terminal is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +25,6 @@ #include <errno.h> #include <locale.h> #include <stdlib.h> -#include <time.h> #include <unistd.h> #include <glib.h> @@ -243,6 +243,7 @@ bus_acquired_cb (GDBusConnection *connection, method_call_cb, NULL, NULL, + { 0 } }; OwnData *data = (OwnData *) user_data; @@ -290,7 +291,6 @@ name_acquired_cb (GDBusConnection *connection, g_assert_not_reached (); } - if (!terminal_app_handle_options (terminal_app_get (), data->options, TRUE /* do resume */, &error)) { g_printerr ("Failed to handle options: %s\n", error->message); @@ -525,7 +525,8 @@ main (int argc, char **argv) if (options->startup_id == NULL) { - options->startup_id = g_strdup_printf ("_TIME%lu", g_get_monotonic_time () / 1000); + options->startup_id = g_strdup_printf ("_TIME%" G_GINT64_FORMAT, + g_get_monotonic_time () / 1000); } gdk_init (&argc, &argv); diff --git a/src/terminal.xml b/src/terminal.xml index 263dce4..281dc90 100644 --- a/src/terminal.xml +++ b/src/terminal.xml @@ -83,6 +83,9 @@ </menubar> <popup name="Popup" action="Popup"> + <menuitem action="PopupOpenHyperlink" /> + <menuitem action="PopupCopyHyperlinkAddress" /> + <separator /> <menuitem action="PopupSendEmail" /> <menuitem action="PopupCopyEmailAddress" /> <menuitem action="PopupCall" /> |