//行のハイライトの設定を変える void set_highlight_line(void) { if (state & highlight_mask) { gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW(view), FALSE); } else { gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW(view), TRUE); } state ^= highlight_mask; }
static void pluma_prefs_manager_hl_current_line_changed (GSettings *settings, gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); if (strcmp (key, GPM_HIGHLIGHT_CURRENT_LINE) == 0) { gboolean hl; GList *views; GList *l; hl = g_settings_get_boolean (settings, key); views = pluma_app_get_views (pluma_app_get_default ()); l = views; while (l != NULL) { gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (l->data), hl); l = l->next; } g_list_free (views); } }
void mape_edit_view_apply_preferences(MapeEditView* edit_view, MapePreferences* preferences) { GtkSourceView* view; GtkSourceBuffer* buffer; GtkWrapMode wrap_mode; view = GTK_SOURCE_VIEW(edit_view->view); buffer = GTK_SOURCE_BUFFER( gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)) ); gtk_source_view_set_tab_width( view, preferences->tab_width ); gtk_source_view_set_insert_spaces_instead_of_tabs( view, preferences->tab_to_spaces ); gtk_source_view_set_auto_indent( view, preferences->auto_indentation ); wrap_mode = GTK_WRAP_CHAR; if(preferences->text_wrapping == FALSE) wrap_mode = GTK_WRAP_NONE; gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW(view), wrap_mode ); gtk_source_view_set_show_line_numbers( view, preferences->line_numbers ); gtk_source_view_set_highlight_current_line( view, preferences->highlight_line ); gtk_source_buffer_set_highlight_matching_brackets( buffer, preferences->bracket_matching ); edit_view->fixed_seed = preferences->fixed_seed; edit_view->random_seed = preferences->random_seed; edit_view->map_width = preferences->map_width; edit_view->map_height = preferences->map_height; edit_view->map_zoom = preferences->map_zoom; /* Rerender with new random settings */ mape_edit_view_reload(edit_view); }
void init_editor(GtkWidget *box) { //エディタ部分の外観の設定 GtkWidget *notebook = gtk_notebook_new(); scroll_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); buffer = gtk_source_buffer_new(NULL); view = gtk_source_view_new_with_buffer(buffer); set_file_name(""); name_label = gtk_label_new("編集中のファイル"); gtk_container_add(GTK_CONTAINER(scroll_window), view); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scroll_window, name_label); gtk_widget_set_has_tooltip(view, TRUE); gtk_widget_grab_focus(view); set_style(); gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0); //エディタ部分の動作の初期設定 gtk_source_buffer_set_highlight_matching_brackets(buffer, FALSE); gtk_widget_modify_font(view, pango_font_description_from_string(font_name)); gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(view), state & width_mask); if (state & wrap_mask) { gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_CHAR); } else { gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_NONE); } if (state & line_mask) { gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(view), TRUE); } else { gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(view), FALSE); } if (state & highlight_mask) { gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW(view), TRUE); } else { gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW(view), FALSE); } if (state & space_mask) { gtk_source_view_set_insert_spaces_instead_of_tabs(GTK_SOURCE_VIEW(view), TRUE); } else { gtk_source_view_set_insert_spaces_instead_of_tabs(GTK_SOURCE_VIEW(view), FALSE); } }
G_MODULE_EXPORT void toggle_highlighting(GtkWidget* widget, void* user) { gboolean newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); GList* tab = gummi->tabmanager->tabs; config_set_value("highlighting", newval ? "True" : "False"); while (tab) { gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW (GU_TAB_CONTEXT(tab->data)->editor->view), newval); tab = g_list_next(tab); } }
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"); } }
void apply_changed_option (char *option_name) { if (!g_strcmp0 (option_name, "font_name")) { PangoFontDescription *font_desc; font_desc = pango_font_description_from_string (options.font_name); int i; for (i = 0; i < code_widget_array_size; i++) gtk_widget_modify_font (code_widget_array[i]->sourceview, font_desc); pango_font_description_free (font_desc); } else if (!g_strcmp0 (option_name, "font_size")) { } else if(!g_strcmp0 (option_name, "word_wrap")) { int i; GtkWrapMode wrap_mode; if (options.word_wrap) wrap_mode = GTK_WRAP_WORD; else wrap_mode = GTK_WRAP_NONE; for (i = 0; i < code_widget_array_size; i++) gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (code_widget_array[i]->sourceview), wrap_mode); } else if(!g_strcmp0 (option_name, "highlight_curr_line")) { int i; for (i = 0; i < code_widget_array_size; i++) gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (code_widget_array [i]->sourceview), options.highlight_curr_line); } else if(!g_strcmp0 (option_name, "matching_brace")) { } else if(!g_strcmp0 (option_name, "indentation")) { } else if(!g_strcmp0 (option_name, "indent_width")) { } else if(!g_strcmp0 (option_name, "inc_indent_syms")) { } else if(!g_strcmp0 (option_name, "dec_indent_syms")) { } else if(!g_strcmp0 (option_name, "tab_width")) { } else if(!g_strcmp0 (option_name, "code_folding")) { } else if(!g_strcmp0 (option_name, "fold_comments")) { } else if(!g_strcmp0 (option_name, "fold_classes")) { } else if(!g_strcmp0 (option_name, "fold_functions")) { } else if(!g_strcmp0 (option_name, "code_completion")) { } else if(!g_strcmp0 (option_name, "variable_scoping")) { } else if(!g_strcmp0 (option_name, "line_numbers")) { } else if(!g_strcmp0 (option_name, "line_numbers_font_size")) { } else if(!g_strcmp0 (option_name, "syntax_highlighting")) { } }