Merge pull request #3 from Tetralet/master

Whoa, very thanks to Tetralet!
This commit is contained in:
caleb- 2014-01-06 18:04:21 -08:00
commit 8a42b383c4
2 changed files with 16 additions and 0 deletions

View File

@ -117,6 +117,7 @@ void save_config_file(void)
}
gint jump_linenum = 0;
GtkClipboard *selection_primary = NULL;
static void parse_args(gint argc, gchar **argv, FileInfo *fi)
{
@ -210,6 +211,8 @@ gint main(gint argc, gchar **argv)
gtk_init(&argc, &argv);
g_set_application_name(PACKAGE_NAME);
selection_primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
pub->mw = create_main_window();
conf = g_malloc(sizeof(Conf));

View File

@ -24,6 +24,9 @@
static gint keyval;
static gboolean view_scroll_flag = FALSE;
extern GtkClipboard *selection_primary;
gchar *selection_primary_str = NULL;
gint get_current_keyval(void)
{
return keyval;
@ -216,6 +219,16 @@ static gboolean cb_button_press_event(GtkWidget *view, GdkEventButton *event)
gtk_text_buffer_place_cursor(buffer, &iter);
}
// backup and restore the clipboard
gchar *current_clipboard_str = gtk_clipboard_wait_for_text(selection_primary);
if ((current_clipboard_str == NULL) || (current_clipboard_str[0]=='\0')) {
gtk_clipboard_set_text(selection_primary, selection_primary_str, -1);
}
else {
g_free(selection_primary_str);
selection_primary_str = g_strdup(current_clipboard_str);
}
return FALSE;
}