G_MODULE_EXPORT void on_menu_paste_activate (GtkWidget *widget, void* user) { GtkClipboard *clipboard; clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); gtk_text_buffer_paste_clipboard (g_e_buffer, clipboard, NULL, TRUE); }
void WAttTextGtk::activate_paste(GtkWidget* w, gpointer data) { WAttTextGtk* watttext = (WAttTextGtk*)data; GtkClipboard* clipboard = gtk_clipboard_get(GDK_NONE); gtk_text_buffer_paste_clipboard(watttext->textbuffer, clipboard, NULL, TRUE); }
void peacock_file_paste_selection (PeacockFile *file) { g_return_if_fail (file != NULL); g_return_if_fail (PEACOCK_IS_FILE (file)); gtk_text_buffer_paste_clipboard (GTK_TEXT_BUFFER (file), gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), NULL, !peacock_file_is_readonly (file)); }
/* paste -- insert the text from the clipboard into the text buffer */ static void paste_clicked( GtkButton *paste, GtkTextView *textview ) { GtkClipboard *clipboard = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD ); GtkTextBuffer *buffer = gtk_text_view_get_buffer( textview ); /* third parameter is an iterator -- position into which you specify to insert */ /* Null, insert into cursor. true -- rich text, false -- text only */ gtk_text_buffer_paste_clipboard( buffer, clipboard, NULL, TRUE ); }
static void paste_and_send(GtkWidget *menu_entry, PidginConversation *gtkconv) { g_return_if_fail(gtkconv != NULL); GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_text_buffer_paste_clipboard(gtkconv->entry_buffer, clipboard, NULL, TRUE); g_signal_emit_by_name(gtkconv->entry, "message_send"); }
/* Called when the user clicks the 'Paste' menu. */ void on_paste_menu_item_activate (GtkMenuItem *menuitem, TutorialTextEditor *editor) { GtkTextBuffer *buffer; GtkClipboard *clipboard; clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->text_view)); gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE); }
CAMLprim value ml_gtk_text_buffer_paste_clipboard (value arg1, value arg2, value arg3, value arg4) { gtk_text_buffer_paste_clipboard (GtkTextBuffer_val(arg1), GtkClipboard_val(arg2), Option_val(arg3,GtkTextIter_val,NULL), Bool_val(arg4) ); return(Val_unit); }
static void gglk_text_paste_clipboard_selection(GglkText *tb, GdkAtom selection, GtkTextIter *iter) { GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(tb), selection); if(!gtk_text_iter_can_insert(iter, FALSE)) gtk_text_buffer_get_iter_at_mark(tb->buffer, iter, tb->endedit); gtk_text_buffer_paste_clipboard(tb->buffer, clipboard, iter, FALSE); }
/* ghtml_paste */ void ghtml_paste(GtkWidget * widget) { GHtml * ghtml; GtkTextBuffer * buffer; GtkClipboard * clipboard; ghtml = g_object_get_data(G_OBJECT(widget), "ghtml"); clipboard = gtk_widget_get_clipboard(ghtml->view, GDK_SELECTION_CLIPBOARD); gtk_text_buffer_paste_clipboard(ghtml->tbuffer, clipboard, NULL, FALSE); }
void Gobby::EditCommands::on_paste() { g_assert(m_current_view != NULL); g_assert(m_current_view->get_active_user() != NULL); gtk_text_buffer_paste_clipboard( GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), NULL, TRUE); m_current_view->scroll_to_cursor_position(0.0); }
static void gmdb_sql_paste_cb(GtkWidget *w, GladeXML *xml) { GtkTextBuffer *txtbuffer; GtkClipboard *clipboard; GtkWidget *textview; textview = glade_xml_get_widget(xml, "sql_textview"); clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); txtbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); gtk_text_buffer_paste_clipboard(txtbuffer, clipboard, NULL, TRUE); }
static void window_paste (GSimpleAction *action, GVariant *parameter, gpointer user_data) { GtkWindow *window = GTK_WINDOW (user_data); GtkTextView *text = g_object_get_data ((GObject*)window, "plugman-text"); gtk_text_buffer_paste_clipboard (gtk_text_view_get_buffer (text), get_clipboard ((GtkWidget*) text), NULL, TRUE); }
void on________p_1_activate (GtkMenuItem *menuitem, AD data) // 貼上 { GtkTextBuffer *buffer; GtkClipboard *clipboard; clipboard = gtk_clipboard_get( GDK_NONE ); // 取得反白選取的部份 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (data->textview)); // 取得整個編輯緩衝區 gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE); // 將剪貼簿的內容貼到指定區域 }
void on_paste1_activate(GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window)); if (GTK_IS_EDITABLE(focusw)) gtk_editable_paste_clipboard(GTK_EDITABLE(focusw)); else if (IS_SCINTILLA(focusw)) sci_paste(SCINTILLA(focusw)); else if (GTK_IS_TEXT_VIEW(focusw)) { GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(focusw)); gtk_text_buffer_paste_clipboard(buffer, gtk_clipboard_get(GDK_NONE), NULL, TRUE); } }
/* compose_paste */ void compose_paste(Compose * compose) { GtkWidget * focus; GtkTextBuffer * buffer; GtkClipboard * clipboard; if((focus = gtk_window_get_focus(GTK_WINDOW(compose->window))) == compose->view) { buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(compose->view)); clipboard = gtk_widget_get_clipboard(compose->view, GDK_SELECTION_CLIPBOARD); gtk_text_buffer_paste_clipboard(buffer, clipboard, NULL, TRUE); } else if(focus == gtk_bin_get_child(GTK_BIN(compose->from)) || focus == compose->subject) gtk_editable_copy_clipboard(GTK_EDITABLE(focus)); /* FIXME also implement the headers */ }
/* * Get clipboard and 'Paste' */ void av_editor_paste_clipboard(const av_editor *editor) { GtkClipboard *clipboard = NULL; g_return_if_fail(editor != NULL && editor->textview != NULL && editor->textbuf != NULL); clipboard = gtk_widget_get_clipboard(GTK_WIDGET(editor->textview), GDK_SELECTION_CLIPBOARD); gtk_text_buffer_paste_clipboard(editor->textbuf, clipboard, NULL, editor->pref.editable); gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(editor->textview), gtk_text_buffer_get_insert(editor->textbuf), AV_EDITOR_VIEW_SCROLL_MARGIN, FALSE, AV_EDITOR_VIEW_SCROLL_XALIGN, AV_EDITOR_VIEW_SCROLL_YALIGN); }
/** * cucopa: * @callback_data: unused callback param * @callback_action: action to perform (GRG_CUT, GRG_COPY, GRG_PASTE) * * basic CUT/COPY/PASTE clipboard operation. */ void cucopa (gpointer callback_data, guint callback_action) { switch ((grg_clip_action) callback_action) { case GRG_CUT: gtk_text_buffer_cut_clipboard (entryBuf, clip, TRUE); return; case GRG_COPY: gtk_text_buffer_copy_clipboard (entryBuf, clip); return; case GRG_PASTE: gtk_text_buffer_paste_clipboard (entryBuf, clip, NULL, TRUE); return; default: #ifdef MAINTAINER_MODE g_assert_not_reached (); #endif break; } }
static void menu_paste (GtkMenuItem *menuitem, gpointer data) { // If null text is inserted at the current cursor position gtk_text_buffer_paste_clipboard(editor_buf, gtk_clipboard_get(sel_atom), NULL, TRUE); }
/********** 'set_chord_position' function ************************************/ gint set_chord_position(GtkWidget *t_view, GtkTextBuffer *buffer) { GtkTextTag *tag; GtkTextMark *end_chord, *start_chord; GtkTextIter ch, chord_S, chord_E, match_end, match_start, start_of_line; GtkClipboard *clipboard; gint line_num_1, line_num_2, line_count_V, line_offset_1, line_offset_2; line_count_V = gtk_text_buffer_get_line_count(buffer); clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_text_buffer_get_start_iter(buffer, &start_of_line); if(gtk_text_iter_forward_search(&start_of_line, "[", 1, &match_start, &match_end, NULL)) { gtk_text_buffer_create_mark(buffer, "start_chord", &match_start, FALSE); start_chord = gtk_text_buffer_get_mark(buffer, "start_chord"); } else { return -1; } if(gtk_text_iter_forward_search(&start_of_line, "]", 1, &match_start, &match_end, NULL)) { gtk_text_buffer_create_mark(buffer, "end_chord", &match_end, FALSE); end_chord = gtk_text_buffer_get_mark(buffer, "end_chord"); } else { return -1; } // Initializes iters at mark. gtk_text_buffer_get_iter_at_mark(buffer, &chord_S, start_chord); gtk_text_buffer_get_iter_at_mark(buffer, &chord_E, end_chord); // Get line and line offset of iter. If we just obtain the offset // within buffer then chord_S will not format as desired. line_num_1 = gtk_text_iter_get_line(&chord_S); line_offset_1 = gtk_text_iter_get_line_index(&chord_S); line_num_2 = gtk_text_iter_get_line(&chord_E); line_offset_2 = gtk_text_iter_get_line_index(&chord_E); // This returns with error if end bracket does not have a // matching start bracket. if(line_offset_1 > line_offset_2) { return -1; } //g_print("Lineoffset of start:end bracket:\n%d\n%d\n", line_offset_1, line_offset_2); // If chord found is found more than two lines down // refresh global values of 'line_count_C' and 'line_num_C'. if(line_num_1 > (line_num_C + 1)) { line_num_C = line_num_1; line_count_C = line_count_V; } // Copy, cut, and add tags to the section between the marks. gtk_text_buffer_select_range(buffer, &chord_S, &chord_E); tag = gtk_text_buffer_create_tag(buffer, NULL, "background", "gold", "weight", "500", "foreground-gdk", "black3", NULL); gtk_text_buffer_apply_tag(buffer, tag, &chord_S, &chord_E); gtk_text_buffer_cut_clipboard(buffer, clipboard, TRUE); // This finds first chord of line. if(line_count_V == line_count_C) { gtk_text_buffer_get_iter_at_line(buffer, &start_of_line, line_num_1); gtk_text_buffer_insert(buffer, &start_of_line, "\n", -1); } // This finds the rest of the chord_S on the same line as the first. if(line_num_1 == (line_num_C + 1)) { line_num_1 = line_num_1 - 1; line_num_2 = line_num_2 - 1; } gtk_text_buffer_get_iter_at_line(buffer, &ch, line_num_1); // Insert 110 blank spaces so we can insert chord_S at higher offsets than 0. // GtkTextBuffer does not allow us to insert past a newline character // so we move it with spaces to allow us to place chord_S at offsets // past a newline character. if(gtk_text_iter_get_char(&ch) == '\n') { gtk_text_buffer_insert(buffer, &ch, " ", -1); } // Place iter at the same offset one line above. gtk_text_buffer_get_iter_at_line_index(buffer, &ch, line_num_1, line_offset_1); //g_print("Position after cut: %d\n", line_offset_1); gtk_text_buffer_paste_clipboard(buffer, clipboard, &ch, TRUE); gtk_text_buffer_get_iter_at_line_offset(buffer, &ch, line_num_1, line_offset_2); // Deletes the end bracket. gtk_text_buffer_backspace(buffer, &ch, FALSE, TRUE); gtk_text_buffer_get_iter_at_line_offset(buffer, &ch, line_num_1, line_offset_1 +1); // Deletes the start bracket. gtk_text_buffer_backspace(buffer, &ch, FALSE, TRUE); gtk_text_buffer_delete_mark_by_name(buffer, "start_chord"); gtk_text_buffer_delete_mark_by_name(buffer, "end_chord"); return 0; }
static void menu_show(gpointer data, guint action, GtkWidget *widget) { GtkTextIter p; switch(action) { case MENU_NEW: if(save_if_modified()) /* call save if modified wen user opens a new file */ { /* get all the current tag table n put them in the new buffer */ buf = gtk_text_buffer_new(gtk_text_buffer_get_tag_table(buf)); gtk_text_view_set_buffer(GTK_TEXT_VIEW(view), buf); g_object_unref(G_OBJECT(buf)); /* needed for freeing memory by the buffer wen a new buffer is created */ } break; case MENU_OPEN: if(save_if_modified()) { /* call save if modified wen user opens a new file */ buf = gtk_text_buffer_new(gtk_text_buffer_get_tag_table(buf)); gtk_text_view_set_buffer(GTK_TEXT_VIEW(view), buf); /* needed for freeing memory by the buffer wen a new buffer is created */ g_object_unref(G_OBJECT(buf)); load_file(NULL); } break; case MENU_SAVE: save_file(filename); break; case MENU_SAVE_AS: save_file(NULL); break; case MENU_QUIT: if(save_if_modified()) /* call save if modified wen user opens a new file */ gtk_widget_destroy(window); break; case MENU_CUT: gtk_text_buffer_cut_clipboard(buf,gtk_clipboard_get(sel_atom), TRUE); break; case MENU_COPY: gtk_text_buffer_copy_clipboard(buf,gtk_clipboard_get(sel_atom)); break; case MENU_PASTE: /* if null text is inserted at the current cursor position */ gtk_text_buffer_paste_clipboard(buf,gtk_clipboard_get(sel_atom), NULL, TRUE); break; case MENU_FIND: textfind(); break; case MENU_REPLACE: text_find_replace(); break; case MENU_SELECT_ALL: gtk_text_buffer_get_start_iter(buf, &p); /* get the starting pt of the buffer */ gtk_text_buffer_place_cursor(buf, &p); /* ignore the selection made by the mouse */ gtk_text_buffer_get_end_iter(buf, &p); /* get the ending pt of the buffer */ gtk_text_buffer_move_mark_by_name(buf, "selection_bound", &p); break; case MENU_HELP: show_help(); break; case MENU_ABOUT: show_about(); break; default: /* error checking */ g_printerr("Menu action not defined : %u\n", action); break; } }
//クリップボードの内容を貼り付ける void paste_text(void) { GtkClipboard *clipboard = gtk_widget_get_clipboard(view, GDK_SELECTION_CLIPBOARD); gtk_text_buffer_paste_clipboard(GTK_TEXT_BUFFER(buffer), clipboard, NULL, TRUE); }