G_MODULE_EXPORT void toggle_textwrapping(GtkWidget* widget, void* user) { gboolean newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); GList* tab = gummi->tabmanager->tabs; config_set_value("textwrapping", newval ? "True" : "False"); if (newval) { while (tab) { gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW (GU_TAB_CONTEXT(tab->data)->editor->view), GTK_WRAP_CHAR); tab = g_list_next(tab); } gtk_widget_set_sensitive(GTK_WIDGET(gui->prefsgui->wordwrap_button), TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (gui->prefsgui->wordwrap_button), FALSE); /* NOTE: gtk_text_vew_set_wrap_mode () must be placed after * gtk_toggle_button_set_active () since gtk_toggle_button_set_active () * will trigger the 'activate' event of the corresponding button and * cause wrapmode to be changed after we set it */ while (tab) { gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW (GU_TAB_CONTEXT(tab->data)->editor->view), GTK_WRAP_NONE); tab = g_list_next(tab); } gtk_widget_set_sensitive (GTK_WIDGET(gui->prefsgui->wordwrap_button), FALSE); } }
gboolean project_close(void) { GList *tabs = NULL; int i = 0; tabs = g_list_copy(gummi_get_all_tabs()); // XXX: needs refactor /* Disable compile thread to prevent it from compiling nonexisting editor */ motion_stop_compile_thread(gummi->motion); tabmanager_set_active_tab(-1); for (i = 0; i < g_list_length(tabs); i++) { GuTabContext* tab = GU_TAB_CONTEXT(g_list_nth_data(tabs, i)); if (tab->editor->projfile != NULL) on_menu_close_activate(NULL, tab); } g_list_free(tabs); /* Resume compile by selecting an active tag */ if (gummi_get_all_tabs() != NULL) tabmanager_set_active_tab(0); motion_start_compile_thread(gummi->motion); return TRUE; }
G_MODULE_EXPORT void toggle_wordwrapping(GtkWidget* widget, void* user) { gboolean newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); GList* tab = gummi->tabmanager->tabs; config_set_value("wordwrapping", newval ? "True" : "False"); while (tab) { if (newval) gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW (GU_TAB_CONTEXT(tab->data)->editor->view), GTK_WRAP_WORD); else gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW (GU_TAB_CONTEXT(tab->data)->editor->view), GTK_WRAP_CHAR); tab = g_list_next(tab); } }
G_MODULE_EXPORT void on_combo_language_changed(GtkComboBoxText* widget, void* user) { #ifdef USE_GTKSPELL gchar* selected = gtk_combo_box_text_get_active_text((widget)); GList* tab = gummi->tabmanager->tabs; config_set_value("spell_language", selected); if (config_get_value("spelling")) { while (tab) { editor_activate_spellchecking(GU_TAB_CONTEXT(tab->data)->editor, FALSE); editor_activate_spellchecking(GU_TAB_CONTEXT(tab->data)->editor, TRUE); tab = g_list_next(tab); } } #endif }
G_MODULE_EXPORT gboolean on_menu_quit_activate(void) { gint wx = 0, wy = 0, width = 0, height = 0; gchar buf[16]; int i = 0; gint length = g_list_length(gummi->tabmanager->tabs); motion_pause_compile_thread(gummi->motion); for (i = 0; i < length; i++) { gtk_notebook_set_current_page(gui->tabmanagergui->notebook, i); tabmanager_set_active_tab(i); gint ret = check_for_save(g_active_editor); if (GTK_RESPONSE_YES == ret) { gui_save_file(g_active_tab, FALSE); } else if (GTK_RESPONSE_CANCEL == ret || GTK_RESPONSE_DELETE_EVENT == ret) { motion_resume_compile_thread(gummi->motion); return TRUE; } } /* Stop compile thread */ if (length > 0) motion_stop_compile_thread(gummi->motion); gboolean is_maximized; g_object_get(gui->mainwindow, "is-maximized", &is_maximized, NULL); if (!is_maximized) { gtk_window_get_size(gui->mainwindow, &width, &height); gtk_window_get_position(gui->mainwindow, &wx, &wy); config_begin(); config_set_value("mainwindow_x", g_ascii_dtostr(buf, 16, (double)wx)); config_set_value("mainwindow_y", g_ascii_dtostr(buf, 16, (double)wy)); config_set_value("mainwindow_w", g_ascii_dtostr(buf, 16, (double)width)); config_set_value("mainwindow_h", g_ascii_dtostr(buf, 16, (double)height)); config_commit(); } gtk_main_quit(); for (i = 0; i < length; i++) editor_destroy(GU_TAB_CONTEXT(g_list_nth_data (gummi->tabmanager->tabs, i))->editor); printf(" ___ \n" " {o,o} Thanks for using Gummi!\n" " |)__) I welcome your feedback at:\n" " -\"-\"- http://gummi.midnightcoding.org\n\n"); return FALSE; }
G_MODULE_EXPORT void toggle_autoindentation(GtkWidget* widget, void* user) { gboolean newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); GList* tab = gummi->tabmanager->tabs; config_set_value("autoindentation", newval ? "True" : "False"); while (tab) { gtk_source_view_set_auto_indent (GU_TAB_CONTEXT(tab->data)->editor->view, newval); tab = g_list_next(tab); } }
G_MODULE_EXPORT void toggle_linenumbers(GtkWidget* widget, void* user) { gboolean newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); GList* tab = gummi->tabmanager->tabs; config_set_value("line_numbers", newval ? "True" : "False"); while (tab) { gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW (GU_TAB_CONTEXT(tab->data)->editor->view), newval); tab = g_list_next(tab); } }
GList* gummi_get_all_editors (void) { int tabtotal, i; GuEditor* ec; GList* editors = NULL; GList *tabs = gummi_get_all_tabs(); tabtotal = g_list_length(tabs); for (i = 0; i < tabtotal; ++i) { ec = GU_TAB_CONTEXT (g_list_nth_data (tabs, i))->editor; editors = g_list_append (editors, ec); } return editors; }
G_MODULE_EXPORT void on_tabwidth_value_changed(GtkWidget* widget, void* user) { gint newval = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)); gchar buf[16]; GList* tab = gummi->tabmanager->tabs; config_set_value("tabwidth", g_ascii_dtostr(buf, 16, (double)newval)); while (tab) { gtk_source_view_set_tab_width(GU_TAB_CONTEXT(tab->data)->editor->view, newval); tab = g_list_next(tab); } }
G_MODULE_EXPORT void on_editor_font_set(GtkWidget* widget, void* user) { const gchar* font = gtk_font_button_get_font_name(GTK_FONT_BUTTON(widget)); PangoFontDescription* font_desc = pango_font_description_from_string(font); GList* tab = gummi->tabmanager->tabs; slog(L_INFO, "setting font to %s\n", font); config_set_value("font", font); while (tab) { editor_set_font(GU_TAB_CONTEXT(tab->data)->editor, font); tab = g_list_next(tab); } pango_font_description_free(font_desc); }
G_MODULE_EXPORT void on_styleschemes_treeview_cursor_changed(GtkTreeView* treeview, void* user) { gchar* id = NULL; gchar* name = NULL; GList* tab = gummi->tabmanager->tabs; GtkTreeIter iter; GtkTreeModel* model = GTK_TREE_MODEL(gtk_tree_view_get_model(treeview)); GtkTreeSelection* selection = gtk_tree_view_get_selection(treeview); gtk_tree_selection_get_selected(selection, &model, &iter); gtk_tree_model_get(model, &iter, 0, &name, 1, &id, -1); tab = gummi->tabmanager->tabs; while (tab) { editor_set_style_scheme_by_id(GU_TAB_CONTEXT(tab->data)->editor, id); tab = g_list_next(tab); } config_set_value("style_scheme", id); }
G_MODULE_EXPORT void on_menu_close_activate (GtkWidget *widget, void* user) { GuTabContext* tab = NULL; tab = (user)? GU_TAB_CONTEXT (user): g_active_tab; gint ret = check_for_save (tab->editor); if (GTK_RESPONSE_YES == ret) gui_save_file (tab, FALSE); else if (GTK_RESPONSE_CANCEL == ret || GTK_RESPONSE_DELETE_EVENT == ret) return; /* Kill typesetter command */ motion_kill_typesetter(gummi->motion); if (!tabmanager_remove_tab (tab)) { motion_start_errormode (gummi->motion, ""); gui_set_hastabs_sensitive (FALSE); } else { gui_set_filename_display (g_active_tab, TRUE, FALSE); } }
void prefsgui_apply_style_scheme(GuPrefsGui* prefs) { const gchar* scheme = config_get_value("style_scheme"); GList* schemes = editor_list_style_scheme_sorted(); GList* schemes_iter = schemes; GList* tab = gummi->tabmanager->tabs; gint column = 0; GtkTreePath* treepath; while (schemes_iter) { if (STR_EQU(gtk_source_style_scheme_get_id(schemes_iter->data), scheme)) { gchar* path = g_strdup_printf("%d", column); treepath = gtk_tree_path_new_from_string(path); gtk_tree_view_set_cursor(prefs->styleschemes_treeview, treepath, NULL, FALSE); gtk_tree_path_free(treepath); g_free(path); break; } ++column; schemes_iter = g_list_next(schemes_iter); } g_list_free(schemes); if (schemes && !schemes_iter) { treepath = gtk_tree_path_new_from_string("0"); gtk_tree_view_set_cursor(prefs->styleschemes_treeview, treepath, NULL, FALSE); gtk_tree_path_free(treepath); while (tab) { editor_set_style_scheme_by_id(GU_TAB_CONTEXT(tab->data)->editor, "classic"); tab = g_list_next(tab); } } }