make "highlighting things under mouse pointer" configurable

osch 2019-05-21 19:35:30 +02:00 committed by raveit65
parent 803878a775
commit 045cda7ac4
6 changed files with 113 additions and 20 deletions

View File

@ -278,6 +278,11 @@
<summary>Highlight S/Key challenges</summary> <summary>Highlight S/Key challenges</summary>
<description>Popup a dialog when an S/Key challenge response query is detected and clicked on. Typing a password into the dialog will send it to the terminal.</description> <description>Popup a dialog when an S/Key challenge response query is detected and clicked on. Typing a password into the dialog will send it to the terminal.</description>
</key> </key>
<key name="use-urls" type="b">
<default>true</default>
<summary>Highlight URLs under mouse pointer</summary>
<description>If true, URLs under mouse pointer are highlighted and can be opened by mouse click together with control key or used in context menu.</description>
</key>
</schema> </schema>
<schema id="org.mate.terminal.keybindings" path="/org/mate/terminal/keybindings/"> <schema id="org.mate.terminal.keybindings" path="/org/mate/terminal/keybindings/">
<key name="new-tab" type="s"> <key name="new-tab" type="s">

View File

@ -253,6 +253,15 @@ profile_notify_sensitivity_cb (TerminalProfile *profile,
SET_SENSITIVE ("copy-checkbutton", SET_SENSITIVE ("copy-checkbutton",
!terminal_profile_property_locked (profile, TERMINAL_PROFILE_COPY_SELECTION)); !terminal_profile_property_locked (profile, TERMINAL_PROFILE_COPY_SELECTION));
#ifdef ENABLE_SKEY
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_USE_SKEY))
SET_SENSITIVE ("use-skey-checkbutton",
!terminal_profile_property_locked (profile, TERMINAL_PROFILE_USE_SKEY));
#endif
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_USE_URLS))
SET_SENSITIVE ("use-urls-checkbutton",
!terminal_profile_property_locked (profile, TERMINAL_PROFILE_USE_URLS));
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_WORD_CHARS)) if (!prop_name || prop_name == I_(TERMINAL_PROFILE_WORD_CHARS))
SET_SENSITIVE ("word-chars-entry", SET_SENSITIVE ("word-chars-entry",
!terminal_profile_property_locked (profile, TERMINAL_PROFILE_WORD_CHARS)); !terminal_profile_property_locked (profile, TERMINAL_PROFILE_WORD_CHARS));
@ -683,7 +692,9 @@ terminal_profile_edit (TerminalProfile *profile,
editor = (GtkWidget *) gtk_builder_get_object (builder, "profile-editor-dialog"); editor = (GtkWidget *) gtk_builder_get_object (builder, "profile-editor-dialog");
g_object_set_data_full (G_OBJECT (editor), "builder", g_object_set_data_full (G_OBJECT (editor), "builder",
builder, (GDestroyNotify) g_object_unref); builder, (GDestroyNotify) g_object_unref);
#ifndef ENABLE_SKEY
gtk_widget_hide (profile_editor_get_widget (editor, "use-skey-checkbutton"));
#endif
/* Store the dialogue on the profile, so we can acccess it above to check if /* Store the dialogue on the profile, so we can acccess it above to check if
* there's already a profile editor for this profile. * there's already a profile editor for this profile.
*/ */
@ -818,6 +829,10 @@ terminal_profile_edit (TerminalProfile *profile,
CONNECT_WITH_FLAGS ("bell-checkbutton", TERMINAL_PROFILE_SILENT_BELL, FLAG_INVERT_BOOL); CONNECT_WITH_FLAGS ("bell-checkbutton", TERMINAL_PROFILE_SILENT_BELL, FLAG_INVERT_BOOL);
/* CONNECT_WITH_FLAGS ("copy-checkbutton", TERMINAL_PROFILE_COPY_SELECTION, FLAG_INVERT_BOOL); */ /* CONNECT_WITH_FLAGS ("copy-checkbutton", TERMINAL_PROFILE_COPY_SELECTION, FLAG_INVERT_BOOL); */
CONNECT ("copy-checkbutton", TERMINAL_PROFILE_COPY_SELECTION); CONNECT ("copy-checkbutton", TERMINAL_PROFILE_COPY_SELECTION);
#ifdef ENABLE_SKEY
CONNECT ("use-skey-checkbutton", TERMINAL_PROFILE_USE_SKEY);
#endif
CONNECT ("use-urls-checkbutton", TERMINAL_PROFILE_USE_URLS);
#undef CONNECT #undef CONNECT
#undef CONNECT_WITH_FLAGS #undef CONNECT_WITH_FLAGS

View File

@ -469,6 +469,38 @@ Author: Wolfgang Ulbrich
<property name="position">6</property> <property name="position">6</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="use-skey-checkbutton">
<property name="label" translatable="yes">Highlight _S/Key challenges under mouse pointer</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="use-urls-checkbutton">
<property name="label" translatable="yes">Highlight _URLs under mouse pointer</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">8</property>
</packing>
</child>
<child> <child>
<object class="GtkBox" id="hbox147"> <object class="GtkBox" id="hbox147">
<property name="visible">True</property> <property name="visible">True</property>
@ -513,7 +545,7 @@ Author: Wolfgang Ulbrich
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">7</property> <property name="position">9</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -560,7 +592,7 @@ Author: Wolfgang Ulbrich
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">8</property> <property name="position">10</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -600,7 +632,7 @@ Author: Wolfgang Ulbrich
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">9</property> <property name="position">11</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -616,7 +648,7 @@ Author: Wolfgang Ulbrich
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">10</property> <property name="position">12</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -727,7 +759,7 @@ Author: Wolfgang Ulbrich
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">11</property> <property name="position">13</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

@ -79,6 +79,7 @@ enum
PROP_USE_CUSTOM_COMMAND, PROP_USE_CUSTOM_COMMAND,
PROP_USE_CUSTOM_DEFAULT_SIZE, PROP_USE_CUSTOM_DEFAULT_SIZE,
PROP_USE_SKEY, PROP_USE_SKEY,
PROP_USE_URLS,
PROP_USE_SYSTEM_FONT, PROP_USE_SYSTEM_FONT,
PROP_USE_THEME_COLORS, PROP_USE_THEME_COLORS,
PROP_VISIBLE_NAME, PROP_VISIBLE_NAME,
@ -120,6 +121,7 @@ enum
#define KEY_USE_CUSTOM_COMMAND "use-custom-command" #define KEY_USE_CUSTOM_COMMAND "use-custom-command"
#define KEY_USE_CUSTOM_DEFAULT_SIZE "use-custom-default-size" #define KEY_USE_CUSTOM_DEFAULT_SIZE "use-custom-default-size"
#define KEY_USE_SKEY "use-skey" #define KEY_USE_SKEY "use-skey"
#define KEY_USE_URLS "use-urls"
#define KEY_USE_SYSTEM_FONT "use-system-font" #define KEY_USE_SYSTEM_FONT "use-system-font"
#define KEY_USE_THEME_COLORS "use-theme-colors" #define KEY_USE_THEME_COLORS "use-theme-colors"
#define KEY_VISIBLE_NAME "visible-name" #define KEY_VISIBLE_NAME "visible-name"
@ -160,6 +162,7 @@ enum
#define DEFAULT_USE_CUSTOM_COMMAND (FALSE) #define DEFAULT_USE_CUSTOM_COMMAND (FALSE)
#define DEFAULT_USE_CUSTOM_DEFAULT_SIZE (FALSE) #define DEFAULT_USE_CUSTOM_DEFAULT_SIZE (FALSE)
#define DEFAULT_USE_SKEY (TRUE) #define DEFAULT_USE_SKEY (TRUE)
#define DEFAULT_USE_URLS (TRUE)
#define DEFAULT_USE_SYSTEM_FONT (TRUE) #define DEFAULT_USE_SYSTEM_FONT (TRUE)
#define DEFAULT_USE_THEME_COLORS (TRUE) #define DEFAULT_USE_THEME_COLORS (TRUE)
#define DEFAULT_VISIBLE_NAME (N_("Unnamed")) #define DEFAULT_VISIBLE_NAME (N_("Unnamed"))
@ -1298,6 +1301,7 @@ terminal_profile_class_init (TerminalProfileClass *klass)
TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_CUSTOM_COMMAND, DEFAULT_USE_CUSTOM_COMMAND, KEY_USE_CUSTOM_COMMAND); TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_CUSTOM_COMMAND, DEFAULT_USE_CUSTOM_COMMAND, KEY_USE_CUSTOM_COMMAND);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_CUSTOM_DEFAULT_SIZE, DEFAULT_USE_CUSTOM_DEFAULT_SIZE, KEY_USE_CUSTOM_DEFAULT_SIZE); TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_CUSTOM_DEFAULT_SIZE, DEFAULT_USE_CUSTOM_DEFAULT_SIZE, KEY_USE_CUSTOM_DEFAULT_SIZE);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_SKEY, DEFAULT_USE_SKEY, KEY_USE_SKEY); TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_SKEY, DEFAULT_USE_SKEY, KEY_USE_SKEY);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_URLS, DEFAULT_USE_URLS, KEY_USE_URLS);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_SYSTEM_FONT, DEFAULT_USE_SYSTEM_FONT, KEY_USE_SYSTEM_FONT); TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_SYSTEM_FONT, DEFAULT_USE_SYSTEM_FONT, KEY_USE_SYSTEM_FONT);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_THEME_COLORS, DEFAULT_USE_THEME_COLORS, KEY_USE_THEME_COLORS); TERMINAL_PROFILE_PROPERTY_BOOLEAN (USE_THEME_COLORS, DEFAULT_USE_THEME_COLORS, KEY_USE_THEME_COLORS);

View File

@ -101,6 +101,7 @@ typedef enum
#define TERMINAL_PROFILE_USE_CUSTOM_COMMAND "use-custom-command" #define TERMINAL_PROFILE_USE_CUSTOM_COMMAND "use-custom-command"
#define TERMINAL_PROFILE_USE_CUSTOM_DEFAULT_SIZE "use-custom-default-size" #define TERMINAL_PROFILE_USE_CUSTOM_DEFAULT_SIZE "use-custom-default-size"
#define TERMINAL_PROFILE_USE_SKEY "use-skey" #define TERMINAL_PROFILE_USE_SKEY "use-skey"
#define TERMINAL_PROFILE_USE_URLS "use-urls"
#define TERMINAL_PROFILE_USE_SYSTEM_FONT "use-system-font" #define TERMINAL_PROFILE_USE_SYSTEM_FONT "use-system-font"
#define TERMINAL_PROFILE_USE_THEME_COLORS "use-theme-colors" #define TERMINAL_PROFILE_USE_THEME_COLORS "use-theme-colors"
#define TERMINAL_PROFILE_VISIBLE_NAME "visible-name" #define TERMINAL_PROFILE_VISIBLE_NAME "visible-name"

View File

@ -174,6 +174,9 @@ static GRegex **url_regexes;
static TerminalURLFlavour *url_regex_flavors; static TerminalURLFlavour *url_regex_flavors;
static guint n_url_regexes; static guint n_url_regexes;
static void terminal_screen_url_match_remove (TerminalScreen *screen);
#ifdef ENABLE_SKEY #ifdef ENABLE_SKEY
static const TerminalRegexPattern skey_regex_patterns[] = static const TerminalRegexPattern skey_regex_patterns[] =
{ {
@ -333,12 +336,10 @@ terminal_screen_init (TerminalScreen *screen)
{ "text/x-moz-url", 0, TARGET_MOZ_URL }, { "text/x-moz-url", 0, TARGET_MOZ_URL },
{ "_NETSCAPE_URL", 0, TARGET_NETSCAPE_URL } { "_NETSCAPE_URL", 0, TARGET_NETSCAPE_URL }
}; };
VteTerminal *terminal = VTE_TERMINAL (screen);
TerminalScreenPrivate *priv; TerminalScreenPrivate *priv;
GtkTargetList *target_list; GtkTargetList *target_list;
GtkTargetEntry *targets; GtkTargetEntry *targets;
int n_targets; int n_targets;
guint i;
priv = screen->priv = G_TYPE_INSTANCE_GET_PRIVATE (screen, TERMINAL_TYPE_SCREEN, TerminalScreenPrivate); priv = screen->priv = G_TYPE_INSTANCE_GET_PRIVATE (screen, TERMINAL_TYPE_SCREEN, TerminalScreenPrivate);
@ -351,18 +352,6 @@ terminal_screen_init (TerminalScreen *screen)
priv->font_scale = PANGO_SCALE_MEDIUM; priv->font_scale = PANGO_SCALE_MEDIUM;
for (i = 0; i < n_url_regexes; ++i)
{
TagData *tag_data;
tag_data = g_slice_new (TagData);
tag_data->flavor = url_regex_flavors[i];
tag_data->tag = vte_terminal_match_add_gregex (terminal, url_regexes[i], 0);
vte_terminal_match_set_cursor_type (terminal, tag_data->tag, URL_MATCH_CURSOR);
priv->match_tags = g_slist_prepend (priv->match_tags, tag_data);
}
/* Setup DND */ /* Setup DND */
target_list = gtk_target_list_new (NULL, 0); target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_uri_targets (target_list, 0); gtk_target_list_add_uri_targets (target_list, 0);
@ -1060,6 +1049,29 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
vte_terminal_set_cursor_shape (vte_terminal, vte_terminal_set_cursor_shape (vte_terminal,
terminal_profile_get_property_enum (priv->profile, TERMINAL_PROFILE_CURSOR_SHAPE)); terminal_profile_get_property_enum (priv->profile, TERMINAL_PROFILE_CURSOR_SHAPE));
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_USE_URLS))
{
if (terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_URLS))
{
guint i;
for (i = 0; i < n_url_regexes; ++i)
{
TagData *tag_data;
tag_data = g_slice_new (TagData);
tag_data->flavor = url_regex_flavors[i];
tag_data->tag = vte_terminal_match_add_gregex (vte_terminal, url_regexes[i], 0);
vte_terminal_match_set_cursor_type (vte_terminal, tag_data->tag, URL_MATCH_CURSOR);
priv->match_tags = g_slist_prepend (priv->match_tags, tag_data);
}
}
else
{
terminal_screen_url_match_remove (screen);
}
}
g_object_thaw_notify (object); g_object_thaw_notify (object);
} }
@ -2312,6 +2324,30 @@ terminal_screen_skey_match_remove (TerminalScreen *screen)
} }
#endif /* ENABLE_SKEY */ #endif /* ENABLE_SKEY */
static void
terminal_screen_url_match_remove (TerminalScreen *screen)
{
TerminalScreenPrivate *priv = screen->priv;
GSList *l, *next;
l = priv->match_tags;
while (l != NULL)
{
TagData *tag_data = (TagData *) l->data;
next = l->next;
#ifdef ENABLE_SKEY
if (tag_data->flavor != FLAVOR_SKEY)
#endif
{
vte_terminal_match_remove (VTE_TERMINAL (screen), tag_data->tag);
priv->match_tags = g_slist_delete_link (priv->match_tags, l);
}
l = next;
}
}
static char* static char*
terminal_screen_check_match (TerminalScreen *screen, terminal_screen_check_match (TerminalScreen *screen,
GdkEvent *event, GdkEvent *event,