Ejemplo n.º 1
0
void WAttTextGtk::activate_cut(GtkWidget* w, gpointer data)
{
  WAttTextGtk* watttext = (WAttTextGtk*)data;

  GtkClipboard* clipboard = gtk_clipboard_get(GDK_NONE);
  gtk_text_buffer_cut_clipboard(watttext->textbuffer, clipboard, TRUE);
}
Ejemplo n.º 2
0
G_MODULE_EXPORT
void on_menu_cut_activate (GtkWidget *widget, void* user) {
    GtkClipboard     *clipboard;

    clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
    gtk_text_buffer_cut_clipboard (g_e_buffer, clipboard, TRUE);
}
Ejemplo n.º 3
0
void
peacock_file_cut_selection (PeacockFile *file)
{
	g_return_if_fail (file != NULL);
	g_return_if_fail (PEACOCK_IS_FILE (file));

	gtk_text_buffer_cut_clipboard (GTK_TEXT_BUFFER (file), gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), !peacock_file_is_readonly (file));
}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: 4179e1/misc
/*
Called when the user clicks the 'Cut' menu. 
*/
void on_cut_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_cut_clipboard (buffer, clipboard, TRUE);
}
Ejemplo n.º 5
0
/*
 * copy the selected text to the clipboard and remove it from the buffer
 * That is called cut.
 */
static void cut_clicked( GtkButton *cut, GtkTextView *textview ) {
  GtkClipboard *clipboard = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD );
  GtkTextBuffer *buffer = gtk_text_view_get_buffer( textview );

  /* real implementors */
  /* true -- cut the embedded object like image as well */
  /* false -- count out of objects like image */
  gtk_text_buffer_cut_clipboard( buffer, clipboard, TRUE );
}
Ejemplo n.º 6
0
/* ghtml_cut */
void ghtml_cut(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_cut_clipboard(ghtml->tbuffer, clipboard, FALSE);
}
Ejemplo n.º 7
0
static void
gmdb_sql_cut_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_cut_clipboard(txtbuffer, clipboard, TRUE);
}
Ejemplo n.º 8
0
void Gobby::EditCommands::on_cut()
{
	g_assert(m_current_view != NULL);
	g_assert(m_current_view->get_active_user() != NULL);

	gtk_text_buffer_cut_clipboard(
		GTK_TEXT_BUFFER(m_current_view->get_text_buffer()),
		gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
		TRUE);

	m_current_view->scroll_to_cursor_position(0.0);
}
Ejemplo n.º 9
0
void on_cut1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));

	if (GTK_IS_EDITABLE(focusw))
		gtk_editable_cut_clipboard(GTK_EDITABLE(focusw));
	else if (IS_SCINTILLA(focusw))
		sci_cut(SCINTILLA(focusw));
	else if (GTK_IS_TEXT_VIEW(focusw))
	{
		GtkTextBuffer *buffer = gtk_text_view_get_buffer(
			GTK_TEXT_VIEW(focusw));
		gtk_text_buffer_cut_clipboard(buffer, gtk_clipboard_get(GDK_NONE), TRUE);
	}
}
Ejemplo n.º 10
0
void
on________t_1_activate                 (GtkMenuItem     *menuitem,
                                        AD         data)
// 剪下 
{
  GtkTextBuffer *buffer;
  GtkClipboard *clipboard; 
  
  // 若GDK_NONE不行就換GDK_SELECTION_PRIMARY 
  clipboard = gtk_clipboard_get( GDK_NONE ); // 取得反白選取的部份 
  
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (data->textview)); // 取得整個編輯緩衝區 
  
  gtk_text_buffer_cut_clipboard (buffer, clipboard, TRUE); // 將反白選取的部份剪下到剪貼簿 

}
Ejemplo n.º 11
0
/* compose_cut */
void compose_cut(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_cut_clipboard(buffer, clipboard, TRUE);
	}
	else if(focus == gtk_bin_get_child(GTK_BIN(compose->from))
			|| focus == compose->subject)
		gtk_editable_cut_clipboard(GTK_EDITABLE(focus));
	/* FIXME also implement the headers */
}
Ejemplo n.º 12
0
/*
 * Get clipboard and 'Cut'
 */
void av_editor_cut_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_cut_clipboard(editor->textbuf,
                                clipboard,
                                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;
	}
}
Ejemplo n.º 14
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;
      }
} 
Ejemplo n.º 15
0
void gTextArea::cut()
{
	gtk_text_buffer_cut_clipboard(_buffer, gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), true);
}
Ejemplo n.º 16
0
/********** '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;
}
Ejemplo n.º 17
0
static void menu_cut (GtkMenuItem *menuitem, gpointer data) {
  gtk_text_buffer_cut_clipboard(editor_buf, gtk_clipboard_get(sel_atom), TRUE);
}