예제 #1
0
파일: console.c 프로젝트: aylusltd/gretl
static void update_console (ExecState *state, GtkWidget *cview)
{
    GtkTextBuffer *buf;
    GtkTextIter iter;

    console_record_sample(dataset);

    if (state == console_state) {
	real_console_exec(state);
	if (state->cmd->ci == QUIT) {
	    return;
	}
    }

    buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(cview));

    gtk_text_buffer_get_end_iter(buf, &iter);
    gtk_text_buffer_insert(buf, &iter, "\n", 1);

    if (!printing_is_redirected(state->prn)) {
	print_result_to_console(buf, &iter, state);
    }
    
    /* set up prompt for next command and scroll to it */
    console_insert_prompt(buf, &iter, console_prompt(state));
    console_scroll_to_end(cview, buf, &iter);

    /* update variable listing in main window if needed */
    if (check_dataset_is_changed()) {
	mark_dataset_as_modified();
	populate_varlist();
    }

    /* update sample info if needed */
    if (console_sample_changed(dataset)) {
	set_sample_label(dataset);
    }

#ifdef G_OS_WIN32
    gtk_window_present(GTK_WINDOW(gtk_widget_get_toplevel(cview)));
    gtk_widget_grab_focus(cview);
#endif
}
예제 #2
0
파일: menustate.c 프로젝트: maupatras/gretl
void set_sample_label (DATASET *dset)
{
    GtkWidget *dlabel;
    char tmp[256];
    int tsubset;

    if (mdata == NULL) {
	return;
    }

    /* set the sensitivity of various menu items */

    time_series_menu_state(dataset_is_time_series(dset));
    panel_menu_state(dataset_is_panel(dset));
    ts_or_panel_menu_state(dataset_is_time_series(dset) ||
			   dataset_is_panel(dset));
    flip(mdata->ui, "/menubar/Data/DataTranspose", !dataset_is_panel(dset));

    tsubset = dset->t1 > 0 || dset->t2 < dset->n - 1;

    /* construct label showing summary of dataset/sample info
       (this goes at the foot of the window) 
    */

    if (complex_subsampled() && !tsubset && dataset_is_cross_section(dset)) {
	sprintf(tmp, _("Undated: Full range n = %d; current sample"
		       " n = %d"), get_full_length_n(), dataset->n);
	gtk_label_set_text(GTK_LABEL(mdata->status), tmp);
    } else if (complex_subsampled() && dataset_is_panel(dset)) {
	char t1str[OBSLEN], t2str[OBSLEN];
	const char *pdstr = get_pd_string(dset);

	ntodate(t1str, dset->t1, dset);
	ntodate(t2str, dset->t2, dset);
	sprintf(tmp, _("%s; sample %s - %s"), _(pdstr), t1str, t2str);
	gtk_label_set_text(GTK_LABEL(mdata->status), tmp);
    } else {
	char t1str[OBSLEN], t2str[OBSLEN];
	const char *pdstr = get_pd_string(dset);

	if (tsubset && calendar_data(dset)) {
	    /* it's too verbose to print both full range and sample */
	    ntodate(t1str, dset->t1, dset);
	    ntodate(t2str, dset->t2, dset);
	    sprintf(tmp, _("%s; sample %s - %s"), _(pdstr), t1str, t2str);
	    gtk_label_set_text(GTK_LABEL(mdata->status), tmp);
	} else {
	    ntodate(t1str, 0, dset);
	    ntodate(t2str, dset->n - 1, dset);
	    sprintf(tmp, _("%s: Full range %s - %s"), _(pdstr), 
		    t1str, t2str);
	    if (tsubset) {
		gchar *fulltext;

		ntodate(t1str, dset->t1, dset);
		ntodate(t2str, dset->t2, dset);
		fulltext = g_strdup_printf(_("%s; sample %s - %s"), tmp, t1str, t2str);
		gtk_label_set_text(GTK_LABEL(mdata->status), fulltext);
		g_free(fulltext);
	    } else {
		gtk_label_set_text(GTK_LABEL(mdata->status), tmp);
	    }
	}
    }

    /* construct label with datafile name (this goes above the
       data series window) */

    dlabel = g_object_get_data(G_OBJECT(mdata->main), "dlabel");

    if (dlabel != NULL) {
	if (strlen(datafile) > 2) {
	    /* data file open already */
	    const char *p = strrchr(datafile, SLASH);
	    gchar *trfname;

	    if (p != NULL) {
		trfname = my_filename_to_utf8(p + 1);
	    } else {
		trfname = my_filename_to_utf8(datafile);
	    }

	    strcpy(tmp, " ");

	    if (data_status & SESSION_DATA) {
		sprintf(tmp + 1, "Imported %s", trfname);
	    } else if (data_status & MODIFIED_DATA) {
		sprintf(tmp + 1, "%s *", trfname);
	    } else {
		sprintf(tmp + 1, "%s", trfname);
	    }

	    gtk_label_set_text(GTK_LABEL(dlabel), tmp);
	    g_free(trfname);
	} else if (data_status & MODIFIED_DATA) {
	    strcpy(tmp, _(" Unsaved data "));
	    gtk_label_set_text(GTK_LABEL(dlabel), tmp);
	}
    }

    if (complex_subsampled() || dset->t1 > 0 || 
	dset->t2 < dset->n - 1) {
	restore_sample_state(TRUE);
    }

    console_record_sample(dataset);
}