Пример #1
0
gboolean iofunctions_autosave_cb (void *user) {
    gint tabtotal, i;
    GtkWidget *focus;
    GuTabContext* tab;
    GuEditor *ec;
    gchar *text;

    GList *tabs = gummi_get_all_tabs();
    tabtotal = g_list_length(tabs);
    
    /* skip the autosave procedure when there are no tabs open */
    if (tabtotal == 0) return TRUE; 

    for (i=0; i < tabtotal; i++) {
        tab = g_list_nth_data (tabs, i);
        ec = tab->editor;
        
        if ((ec->filename) && editor_buffer_changed (ec)) {
            focus = gtk_window_get_focus (gummi_get_gui ()->mainwindow);
            text = editor_grab_buffer (ec);
            gtk_widget_grab_focus (focus);
            iofunctions_save_file (gummi->io, ec->filename, text);
            gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (ec->buffer), FALSE);
            slog (L_DEBUG, "Autosaving document: %s\n", ec->filename);
            gui_set_filename_display (tab, TRUE, TRUE);
       }
    }
    return TRUE;
}
Пример #2
0
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);
}
Пример #3
0
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);
    }
}