Added option to copy selection to clipboard

master-1.22
spuhpointer 2014-09-10 10:04:27 +02:00 committed by Stefano Karapetsas
parent 0442355666
commit a6a5774c68
8 changed files with 62 additions and 2 deletions

View File

@ -128,6 +128,11 @@
<summary>Whether to silence terminal bell</summary> <summary>Whether to silence terminal bell</summary>
<description>If true, don't make a noise when applications send the escape sequence for the terminal bell.</description> <description>If true, don't make a noise when applications send the escape sequence for the terminal bell.</description>
</key> </key>
<key name="copy-selection" type="b">
<default>false</default>
<summary>Copy selection to clipboard</summary>
<description>If true, selection is automatically copied to cliboard buffer.</description>
</key>
<key name="word-chars" type="s"> <key name="word-chars" type="s">
<default>'-A-Za-z0-9,./?%&amp;#:_=+@~'</default> <default>'-A-Za-z0-9,./?%&amp;#:_=+@~'</default>
<summary>Characters that are considered "part of a word"</summary> <summary>Characters that are considered "part of a word"</summary>

View File

@ -242,6 +242,10 @@ profile_notify_sensitivity_cb (TerminalProfile *profile,
SET_SENSITIVE ("bell-checkbutton", SET_SENSITIVE ("bell-checkbutton",
!terminal_profile_property_locked (profile, TERMINAL_PROFILE_SILENT_BELL)); !terminal_profile_property_locked (profile, TERMINAL_PROFILE_SILENT_BELL));
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_COPY_SELECTION))
SET_SENSITIVE ("copy-checkbutton",
!terminal_profile_property_locked (profile, TERMINAL_PROFILE_COPY_SELECTION));
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));
@ -941,6 +945,8 @@ terminal_profile_edit (TerminalProfile *profile,
CONNECT ("use-theme-colors-checkbutton", TERMINAL_PROFILE_USE_THEME_COLORS); CONNECT ("use-theme-colors-checkbutton", TERMINAL_PROFILE_USE_THEME_COLORS);
CONNECT ("word-chars-entry", TERMINAL_PROFILE_WORD_CHARS); CONNECT ("word-chars-entry", TERMINAL_PROFILE_WORD_CHARS);
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 ("copy-checkbutton", TERMINAL_PROFILE_COPY_SELECTION);
#undef CONNECT #undef CONNECT
#undef CONNECT_WITH_FLAGS #undef CONNECT_WITH_FLAGS

View File

@ -457,6 +457,24 @@
<property name="fill">False</property> <property name="fill">False</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="copy-checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Copy selected text into _clipboard</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child> <child>
<object class="GtkHBox" id="hbox147"> <object class="GtkHBox" id="hbox147">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -84,6 +84,7 @@ enum
PROP_USE_THEME_COLORS, PROP_USE_THEME_COLORS,
PROP_VISIBLE_NAME, PROP_VISIBLE_NAME,
PROP_WORD_CHARS, PROP_WORD_CHARS,
PROP_COPY_SELECTION,
LAST_PROP LAST_PROP
}; };
@ -114,6 +115,7 @@ enum
#define KEY_SCROLL_ON_KEYSTROKE "scroll-on-keystroke" #define KEY_SCROLL_ON_KEYSTROKE "scroll-on-keystroke"
#define KEY_SCROLL_ON_OUTPUT "scroll-on-output" #define KEY_SCROLL_ON_OUTPUT "scroll-on-output"
#define KEY_SILENT_BELL "silent-bell" #define KEY_SILENT_BELL "silent-bell"
#define KEY_COPY_SELECTION "copy-selection"
#define KEY_TITLE_MODE "title-mode" #define KEY_TITLE_MODE "title-mode"
#define KEY_TITLE "title" #define KEY_TITLE "title"
#define KEY_UPDATE_RECORDS "update-records" #define KEY_UPDATE_RECORDS "update-records"
@ -154,6 +156,7 @@ enum
#define DEFAULT_SCROLL_ON_KEYSTROKE (TRUE) #define DEFAULT_SCROLL_ON_KEYSTROKE (TRUE)
#define DEFAULT_SCROLL_ON_OUTPUT (FALSE) #define DEFAULT_SCROLL_ON_OUTPUT (FALSE)
#define DEFAULT_SILENT_BELL (FALSE) #define DEFAULT_SILENT_BELL (FALSE)
#define DEFAULT_COPY_SELECTION (FALSE)
#define DEFAULT_TITLE_MODE (TERMINAL_TITLE_REPLACE) #define DEFAULT_TITLE_MODE (TERMINAL_TITLE_REPLACE)
#define DEFAULT_TITLE (N_("Terminal")) #define DEFAULT_TITLE (N_("Terminal"))
#define DEFAULT_UPDATE_RECORDS (TRUE) #define DEFAULT_UPDATE_RECORDS (TRUE)
@ -1251,6 +1254,7 @@ terminal_profile_class_init (TerminalProfileClass *klass)
TERMINAL_PROFILE_PROPERTY_BOOLEAN (SCROLL_ON_KEYSTROKE, DEFAULT_SCROLL_ON_KEYSTROKE, KEY_SCROLL_ON_KEYSTROKE); TERMINAL_PROFILE_PROPERTY_BOOLEAN (SCROLL_ON_KEYSTROKE, DEFAULT_SCROLL_ON_KEYSTROKE, KEY_SCROLL_ON_KEYSTROKE);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (SCROLL_ON_OUTPUT, DEFAULT_SCROLL_ON_OUTPUT, KEY_SCROLL_ON_OUTPUT); TERMINAL_PROFILE_PROPERTY_BOOLEAN (SCROLL_ON_OUTPUT, DEFAULT_SCROLL_ON_OUTPUT, KEY_SCROLL_ON_OUTPUT);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (SILENT_BELL, DEFAULT_SILENT_BELL, KEY_SILENT_BELL); TERMINAL_PROFILE_PROPERTY_BOOLEAN (SILENT_BELL, DEFAULT_SILENT_BELL, KEY_SILENT_BELL);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (COPY_SELECTION, DEFAULT_COPY_SELECTION, KEY_COPY_SELECTION);
TERMINAL_PROFILE_PROPERTY_BOOLEAN (UPDATE_RECORDS, DEFAULT_UPDATE_RECORDS, KEY_UPDATE_RECORDS); TERMINAL_PROFILE_PROPERTY_BOOLEAN (UPDATE_RECORDS, DEFAULT_UPDATE_RECORDS, KEY_UPDATE_RECORDS);
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);

View File

@ -94,6 +94,7 @@ typedef enum
#define TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE "scroll-on-keystroke" #define TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE "scroll-on-keystroke"
#define TERMINAL_PROFILE_SCROLL_ON_OUTPUT "scroll-on-output" #define TERMINAL_PROFILE_SCROLL_ON_OUTPUT "scroll-on-output"
#define TERMINAL_PROFILE_SILENT_BELL "silent-bell" #define TERMINAL_PROFILE_SILENT_BELL "silent-bell"
#define TERMINAL_PROFILE_COPY_SELECTION "copy-selection"
#define TERMINAL_PROFILE_TITLE_MODE "title-mode" #define TERMINAL_PROFILE_TITLE_MODE "title-mode"
#define TERMINAL_PROFILE_TITLE "title" #define TERMINAL_PROFILE_TITLE "title"
#define TERMINAL_PROFILE_UPDATE_RECORDS "update-records" #define TERMINAL_PROFILE_UPDATE_RECORDS "update-records"

View File

@ -943,6 +943,11 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
* update_on_realize * update_on_realize
*/ */
terminal_window_update_geometry (window); terminal_window_update_geometry (window);
/* madars.vitolins@gmail.com 24/07/2014 -
* update terminal window config
* with the flag of copy selection to cliboard or not. */
terminal_window_update_copy_selection(screen, window);
} }
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_SCROLLBAR_POSITION)) if (!prop_name || prop_name == I_(TERMINAL_PROFILE_SCROLLBAR_POSITION))

View File

@ -100,6 +100,9 @@ struct _TerminalWindowPrivate
/* Workaround until gtk+ bug #535557 is fixed */ /* Workaround until gtk+ bug #535557 is fixed */
guint icon_title_set : 1; guint icon_title_set : 1;
time_t focus_time; time_t focus_time;
/* should we copy selection to clibpoard */
int copy_selection;
}; };
#define PROFILE_DATA_KEY "GT::Profile" #define PROFILE_DATA_KEY "GT::Profile"
@ -978,6 +981,10 @@ terminal_window_update_copy_sensitivity (TerminalScreen *screen,
action = gtk_action_group_get_action (priv->action_group, "EditCopy"); action = gtk_action_group_get_action (priv->action_group, "EditCopy");
gtk_action_set_sensitive (action, can_copy); gtk_action_set_sensitive (action, can_copy);
/* 24/07/2014 madars.vitolins@gmail.com, sync to clibboard */
if (priv->copy_selection)
vte_terminal_copy_clipboard(VTE_TERMINAL(screen));
} }
static void static void
@ -2402,16 +2409,17 @@ terminal_window_show (GtkWidget *widget)
gtk_widget_get_allocation (widget, &widget_allocation); gtk_widget_get_allocation (widget, &widget_allocation);
#if 0
TerminalWindowPrivate *priv = window->priv; TerminalWindowPrivate *priv = window->priv;
if (priv->active_screen != NULL) if (priv->active_screen != NULL)
{ {
terminal_window_update_copy_selection (priv->active_screen, window);
#if 0
/* At this point, we have our GdkScreen, and hence the right /* At this point, we have our GdkScreen, and hence the right
* font size, so we can go ahead and size the window. */ * font size, so we can go ahead and size the window. */
terminal_window_set_size (window, priv->active_screen, FALSE); terminal_window_set_size (window, priv->active_screen, FALSE);
}
#endif #endif
}
terminal_window_update_geometry (window); terminal_window_update_geometry (window);
@ -3098,6 +3106,16 @@ notebook_page_removed_callback (GtkWidget *notebook,
} }
} }
void
terminal_window_update_copy_selection (TerminalScreen *screen,
TerminalWindow *window)
{
TerminalWindowPrivate *priv = window->priv;
priv->copy_selection =
terminal_profile_get_property_boolean (terminal_screen_get_profile (screen),
TERMINAL_PROFILE_COPY_SELECTION);
}
void void
terminal_window_update_geometry (TerminalWindow *window) terminal_window_update_geometry (TerminalWindow *window)
{ {

View File

@ -100,6 +100,9 @@ gboolean terminal_window_uses_argb_visual (TerminalWindow *window);
void terminal_window_save_state (TerminalWindow *window, void terminal_window_save_state (TerminalWindow *window,
GKeyFile *key_file, GKeyFile *key_file,
const char *group); const char *group);
void
terminal_window_update_copy_selection (TerminalScreen *screen,
TerminalWindow *window);
TerminalWindow *terminal_window_get_latest_focused (TerminalWindow *window1, TerminalWindow *terminal_window_get_latest_focused (TerminalWindow *window1,
TerminalWindow *window2); TerminalWindow *window2);