static void peacock_file_load_async_close_cb (GnomeVFSAsyncHandle *handle, GnomeVFSResult result, gpointer user_data) { gboolean success = TRUE; PeacockFile *file = PEACOCK_FILE (user_data); #ifdef PEACOCK_FILE_DEBUG g_warning ("peacock_file_load_async_close_cb (): Closed GnomeVFS handle - %s\n", gnome_vfs_result_to_string (result)); #endif /* * File read ok. Emit the PeacockFile::loaded signal. * The handler should load it up in the MDI (besides other things it * might want to do). Else destroy the PeacockFile object. */ if (result == GNOME_VFS_OK) { gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (file), FALSE); gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (file)); } else { g_object_unref (file); success = FALSE; } g_signal_emit (G_OBJECT (file), peacock_file_signals[LOADED], 0, success); }
static void gb_view_source_set_file (GbViewSource *source, GFile *file) { GbViewSourcePrivate *priv; gchar *contents = NULL; gsize size; g_return_if_fail(GB_IS_VIEW_SOURCE(source)); g_return_if_fail(G_IS_FILE(file)); priv = source->priv; /* * TODO: Do this all aysnc. */ priv->file = g_object_ref(file); gb_view_source_set_file_attribs(source, file); if (g_file_get_contents(g_file_get_path(file), &contents, &size, NULL)) { gtk_source_buffer_begin_not_undoable_action(priv->buffer); gtk_text_buffer_set_text(GTK_TEXT_BUFFER(priv->buffer), contents, size); gtk_source_buffer_end_not_undoable_action(priv->buffer); gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(priv->buffer), FALSE); gb_view_source_goto_start(GTK_TEXT_BUFFER(priv->buffer)); g_free(contents); } }
void set_buffer(){ gtk_source_buffer_begin_not_undoable_action(GTK_SOURCE_BUFFER(mBuff)); gtk_text_buffer_set_text(GTK_TEXT_BUFFER(mBuff),content,-1); g_free(content); gtk_source_buffer_end_not_undoable_action(GTK_SOURCE_BUFFER(mBuff)); gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(mBuff),FALSE); GtkTextIter iter; gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(mBuff),&iter); gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(mBuff),&iter); }
static void end_append_text_to_document (GeditDocumentOutputStream *stream) { if (stream->priv->ensure_trailing_newline) { remove_ending_newline (stream); } gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (stream->priv->doc), FALSE); gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (stream->priv->doc)); }
void new_file(){ //unsigned int u_id //GtkSourceBuffer *tBuff=(GtkSourceBuffer *)tpad_buff_get_buff(u_id); if(save_modified()) { gtk_source_buffer_begin_not_undoable_action(GTK_SOURCE_BUFFER(mBuff)); gtk_text_buffer_set_text(GTK_TEXT_BUFFER(mBuff),"",-1); gtk_source_buffer_end_not_undoable_action(GTK_SOURCE_BUFFER(mBuff)); gtk_text_buffer_set_modified(GTK_TEXT_BUFFER(mBuff),FALSE); gtk_window_set_title(GTK_WINDOW(window),_FALLBACK_SAVE_FILE_NAME); save_locked=FALSE; } }
static void insert_text_in_document(SourceviewIO* sio, const gchar* text, gsize len) { GtkSourceBuffer* document = GTK_SOURCE_BUFFER (sio->sv->priv->document); gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER (sio->sv->priv->document)); /* Insert text in the buffer */ gtk_text_buffer_set_text (GTK_TEXT_BUFFER (document), text, len); gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (document), FALSE); gtk_source_buffer_end_not_undoable_action (document); }
static void gedit_document_output_stream_constructed (GObject *object) { GeditDocumentOutputStream *stream = GEDIT_DOCUMENT_OUTPUT_STREAM (object); if (!stream->priv->doc) { g_critical ("This should never happen, a problem happened constructing the Document Output Stream!"); return; } /* Init the undoable action */ gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER (stream->priv->doc)); /* clear the buffer */ gtk_text_buffer_set_text (GTK_TEXT_BUFFER (stream->priv->doc), "", 0); gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (stream->priv->doc), FALSE); gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (stream->priv->doc)); G_OBJECT_CLASS (gedit_document_output_stream_parent_class)->constructed (object); }
void GUI::add_program_file(gchar * filepath){ if (this->is_empty_notebook){ this->is_empty_notebook = false; gtk_notebook_remove_page(GTK_NOTEBOOK(this->programs_notebook), this->empty_notebook_index); } GuiNotebookItem notebook_item; notebook_item.vmachine = NULL; notebook_item.filepath = filepath; // netobook label notebook_item.notebook_label_text = this->extract_file_name(notebook_item.filepath); notebook_item.notebook_label = gtk_label_new (notebook_item.notebook_label_text); // create inner notebook vbox notebook_item.notebook_vbox = gtk_vbox_new(FALSE, 0); // create scrolled_window notebook_item.notebook_scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (notebook_item.notebook_scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (notebook_item.notebook_vbox), notebook_item.notebook_scrolled_window, TRUE, // vbox gives widget all remaining space TRUE, // widget expands to fill given space 0); // pixel of padding around the widget // create notebook_source_view notebook_item.source_buffer = gtk_source_buffer_new (NULL); notebook_item.source_view = gtk_source_view_new_with_buffer(notebook_item.source_buffer); gtk_container_add (GTK_CONTAINER (notebook_item.notebook_scrolled_window), notebook_item.source_view); gtk_source_view_set_auto_indent ( GTK_SOURCE_VIEW (notebook_item.source_view), TRUE); // make a tab be two spaces gtk_source_view_set_indent_width (GTK_SOURCE_VIEW (notebook_item.source_view), 2); gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (notebook_item.source_view), TRUE); gtk_source_view_set_show_line_numbers ( GTK_SOURCE_VIEW (notebook_item.source_view), TRUE); gtk_source_view_set_right_margin_position ( GTK_SOURCE_VIEW (notebook_item.source_view), 80); // default is 70 chars gtk_source_view_set_show_right_margin ( GTK_SOURCE_VIEW (notebook_item.source_view), TRUE); gtk_text_view_set_wrap_mode ( GTK_TEXT_VIEW (notebook_item.source_view), GTK_WRAP_WORD_CHAR); gtk_text_view_set_editable ( GTK_TEXT_VIEW (notebook_item.source_view), FALSE); gtk_text_view_set_cursor_visible ( GTK_TEXT_VIEW (notebook_item.source_view), FALSE); /* setup view */ PangoFontDescription * font_desc = NULL; font_desc = pango_font_description_from_string ("monospace"); if (font_desc != NULL){ gtk_widget_modify_font (notebook_item.source_view, font_desc); pango_font_description_free (font_desc); } // get file content gchar * buffer; GError * error_here = NULL; if (g_file_get_contents (notebook_item.filepath, &buffer, NULL, &error_here)){ gtk_source_buffer_begin_not_undoable_action (notebook_item.source_buffer); gtk_source_buffer_begin_not_undoable_action (notebook_item.source_buffer); gtk_text_buffer_set_text (GTK_TEXT_BUFFER (notebook_item.source_buffer), buffer, -1); gtk_source_buffer_end_not_undoable_action (notebook_item.source_buffer); gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (notebook_item.source_buffer), FALSE); /* move cursor to the beginning */ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (notebook_item.source_buffer), ¬ebook_item.iter); gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (notebook_item.source_buffer), ¬ebook_item.iter); { GtkTextIter start, end; char *text; gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (notebook_item.source_buffer), &start, &end); text = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (notebook_item.source_buffer), &start, &end, TRUE); g_assert (!strcmp (text, buffer)); g_free (text); } g_free (buffer); GtkWidget * vm_frame; vm_frame = gtk_frame_new ("VM operations"); // create buttons notebook_item.notebook_button_hbox = gtk_hbox_new (FALSE, 0); notebook_item.run_step_button = gtk_button_new_with_label ("Run Step"); notebook_item.run_button = gtk_button_new_with_label ("Run"); notebook_item.view_vm_mem = gtk_button_new_with_label ("View Vm memory"); // create time out input notebook_item.timeout_field = gtk_entry_new_with_max_length(10); GtkWidget * timeout_label; timeout_label = gtk_label_new("Timeout:"); g_signal_connect (notebook_item.run_step_button, "clicked", G_CALLBACK (GUI::run_step_button_clicked), gpointer(this)); g_signal_connect (notebook_item.run_button, "clicked", G_CALLBACK (GUI::run_button_clicked), gpointer(this)); g_signal_connect (notebook_item.view_vm_mem, "clicked", G_CALLBACK (GUI::view_vm_mem_clicked), gpointer(this)); gtk_box_pack_start (GTK_BOX (notebook_item.notebook_button_hbox), notebook_item.view_vm_mem, FALSE, // vbox gives widget all remaining space FALSE, // widget expands to fill given space 5); // pixel of padding around the widget gtk_box_pack_start (GTK_BOX (notebook_item.notebook_button_hbox), notebook_item.run_step_button, FALSE, // vbox gives widget all remaining space FALSE, // widget expands to fill given space 5); // pixel of padding around the widget gtk_box_pack_start (GTK_BOX (notebook_item.notebook_button_hbox), timeout_label, FALSE, // vbox gives widget all remaining space FALSE, // widget expands to fill given space 5); // pixel of padding around the widget gtk_box_pack_start (GTK_BOX (notebook_item.notebook_button_hbox), notebook_item.timeout_field, FALSE, // vbox gives widget all remaining space FALSE, // widget expands to fill given space 5); // pixel of padding around the widget gtk_box_pack_start (GTK_BOX (notebook_item.notebook_button_hbox), notebook_item.run_button, FALSE, // vbox gives widget all remaining space FALSE, // widget expands to fill given space 5); // pixel of padding around the widget gtk_container_add(GTK_CONTAINER (vm_frame), notebook_item.notebook_button_hbox); gtk_box_pack_start (GTK_BOX (notebook_item.notebook_vbox), vm_frame, FALSE, // vbox gives widget all remaining space FALSE, // widget expands to fill given space 5); gtk_notebook_append_page( GTK_NOTEBOOK(this->programs_notebook), notebook_item.notebook_vbox, notebook_item.notebook_label); this->gui_notebook_item_list.push_back(notebook_item); gtk_widget_show_all(this->programs_notebook); } else { g_print("WRONG \n"); } }