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 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 on_tab_notebook_switch_page(GtkNotebook *notebook, GtkWidget *nbpage, int pagenr, void *data) { slog (L_DEBUG, "Switched to environment at page %d\n", pagenr); /* Kill typesetter command */ motion_kill_typesetter(gummi->motion); /* set the active tab/editor pointers */ tabmanager_set_active_tab (pagenr); /* update the title of the mainwindow */ gui_set_filename_display (g_active_tab, TRUE, FALSE); /* clear the build log output window */ gui_buildlog_set_text (""); previewgui_reset (gui->previewgui); }