void series_view_refresh (GtkWidget *w, windata_t *vwin) { series_view *sview = (series_view *) vwin->data; if (sview != NULL && sview->varnum > 0 && sview->varnum < dataset->v) { int list[2] = {1, sview->varnum}; PRN *prn = NULL; int err; if (bufopen(&prn)) { return; } err = printdata(list, NULL, dataset, OPT_O, prn); if (err) { gui_errmsg(err); gretl_print_destroy(prn); } else { /* replace text buffer in sview using prn */ const char *buf = gretl_print_get_trimmed_buffer(prn); textview_set_text(vwin->text, buf); gretl_print_destroy(prn); } } }
static void multi_series_view_print (windata_t *vwin) { series_view *sview = (series_view *) vwin->data; PRN *prn; int err = 0; if (bufopen(&prn)) { return; } if (sview->view == VIEW_STANDARD) { err = printdata(sview->list, NULL, dataset, OPT_O, prn); } else { err = print_series_with_format(sview->list, dataset, sview->format, sview->digits, prn); } if (err) { gui_errmsg(err); } else { textview_set_text(vwin->text, gretl_print_get_trimmed_buffer(prn)); } gretl_print_destroy(prn); }
static void multi_series_view_print_sorted (windata_t *vwin) { series_view *sview = (series_view *) vwin->data; int *obsvec = make_obsvec(sview); PRN *prn; int err = 0; if (obsvec == NULL) { return; } if (bufopen(&prn)) { free(obsvec); return; } err = print_data_in_columns(sview->list, obsvec, dataset, OPT_NONE, prn); if (err) { gui_errmsg(err); } else { const char *buf = gretl_print_get_trimmed_buffer(prn); textview_set_text(vwin->text, buf); } free(obsvec); gretl_print_destroy(prn); }
static void single_series_view_print (windata_t *vwin) { series_view *sview = (series_view *) vwin->data; char num_format[32]; double x; PRN *prn; int i, t, obslen; int err = 0; if (bufopen(&prn)) { return; } if (sview->view == VIEW_STANDARD) { int list[2] = { 1, sview->varnum }; /* regular printout: unsort if need be */ if (sview->sorted) { series_view_unsort(sview); } err = printdata(list, NULL, dataset, OPT_O, prn); if (err) { gui_errmsg(err); } goto finalize; } obslen = max_obs_marker_length(dataset); if (sview->format == 'g') { sprintf(num_format, "%%#13.%dg\n", sview->digits); } else { sprintf(num_format, "%%13.%df\n", sview->digits); } pprintf(prn, "\n%*s ", obslen, " "); pprintf(prn, "%13s\n\n", dataset->varname[sview->varnum]); for (i=0; i<sview->npoints; i++) { t = sview->points[i].obsnum; x = sview->points[i].val; print_obs_marker(t, dataset, obslen, prn); if (na(x)) { pputc(prn, '\n'); } else { pprintf(prn, num_format, x); } } finalize: if (!err) { textview_set_text(vwin->text, gretl_print_get_buffer(prn)); } gretl_print_destroy(prn); }
static void display_full_info_cb(GtkWidget *widget, gpointer user_data) { MimeView *mimeview = (MimeView *) user_data; gchar *siginfo; siginfo = privacy_mimeinfo_sig_info_full(mimeview->siginfo); textview_set_text(mimeview->textview, siginfo); g_free(siginfo); noticeview_set_button_text(mimeview->siginfoview, NULL); }
static int dlg_text_set_previous (dialog_t *d) { if (d->ci == edit_save_code && edit_save_buf != NULL) { textview_set_text(d->edit, edit_save_buf); return 1; } else { return 0; } }
static void dlg_text_set_from_sys (equation_system *sys, dialog_t *d) { const char *buf; PRN *prn; if (bufopen(&prn)) { return; } print_equation_system_info(sys, dataset, OPT_NONE, prn); buf = gretl_print_get_buffer(prn); textview_set_text(d->edit, buf); gretl_print_destroy(prn); }
static int dlg_text_set_gmm_skel (dialog_t *d) { const char *skel = "# initializations go here\n\n\n" "gmm\n" " orthog\n" " weights\n" " params\n" "end gmm\n"; if (d->ci == GMM && edit_save_buf == NULL) { textview_set_text(d->edit, skel); textview_set_cursor_at_line(d->edit, 1); return 1; } else { return 0; } }
static void summary_print_formatted (windata_t *vwin, series_view *sview) { Summary *summ = vwin->data; int digits = 0, places = 0; PRN *prn; if (bufopen(&prn)) { return; } if (sview->view != VIEW_STANDARD && sview->digits > 0) { if (sview->format == 'g') { digits = sview->digits; } else { places = sview->digits; } } print_summary_single(summ, digits, places, dataset, prn); textview_set_text(vwin->text, gretl_print_get_trimmed_buffer(prn)); gretl_print_destroy(prn); }
void blocking_edit_dialog (int ci, const char *title, const char *info, const char *deflt, void (*okfunc)(), void *okptr, Varclick click, GtkWidget *parent, int *canceled) { dialog_t *d; GtkWidget *w; MODEL *pmod = NULL; int helpcode; int clear = 0; if (open_edit_dialog != NULL && ci != MINIBUF) { gtk_window_present(GTK_WINDOW(open_edit_dialog)); return; } helpcode = edit_dialog_help_code(ci, okptr); d = edit_dialog_new(ci, title, okfunc, okptr, helpcode, parent, canceled); if (d == NULL) return; open_edit_dialog = d->dialog; set_dialog_border_widths(d->vbox, d->bbox); gretl_dialog_set_resizeable(d->dialog, FALSE); gtk_button_box_set_layout(GTK_BUTTON_BOX(d->bbox), GTK_BUTTONBOX_END); if (ci == ESTIMATE) { /* estimating saved equation system */ dlg_display_sys(d); } else if (ci == SYSTEM && d->data != NULL) { /* respecifying equation system */ edit_dialog_add_note(info, d->vbox); dlg_display_sys(d); clear = 1; } else if (ci == NLS || ci == MLE || ci == GMM || ci == SYSTEM || ci == RESTRICT) { int hsize = 62; edit_dialog_add_note(info, d->vbox); d->edit = dlg_text_edit_new(&hsize, TRUE); dialog_table_setup(d, hsize); gretl_dialog_set_resizeable(d->dialog, TRUE); if (ci != RESTRICT && deflt != NULL) { /* re-specifying a nonlinear model */ textview_set_text(d->edit, deflt); if (ci == NLS || ci == MLE || ci == GMM) { pmod = okptr; } } else if (dlg_text_set_previous(d) || dlg_text_set_gmm_skel(d)) { /* insert previous text, if any and if the command is the same as previously -- or insert skeleton of command */ clear = 1; } if (ci != RESTRICT && ci != GMM) { g_signal_connect(G_OBJECT(d->edit), "button-press-event", G_CALLBACK(edit_dialog_popup_handler), d); } } else { if (info != NULL) { w = gtk_label_new(info); gtk_label_set_justify(GTK_LABEL(w), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(d->vbox), w, TRUE, TRUE, 5); gtk_widget_show(w); } d->edit = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(d->vbox), d->edit, TRUE, TRUE, 5); /* make the Enter key do the business */ if (okfunc != NULL) { gtk_entry_set_activates_default(GTK_ENTRY(d->edit), TRUE); } if (deflt != NULL && *deflt != '\0') { gtk_entry_set_text(GTK_ENTRY(d->edit), deflt); gtk_editable_select_region(GTK_EDITABLE(d->edit), 0, strlen(deflt)); } g_signal_connect(G_OBJECT(GTK_EDITABLE(d->edit)), "changed", G_CALLBACK(raise_and_focus_dialog), d->dialog); } if (ci == SYSTEM || ci == ESTIMATE) { GtkWidget *bt, *bv; bt = dialog_option_switch(d->vbox, d, OPT_T, NULL); bv = dialog_option_switch(d->vbox, d, OPT_V, NULL); system_estimator_list(d->vbox, d, bt, bv); } else if (ci == NLS || ci == MLE) { dialog_option_switch(d->vbox, d, OPT_V, pmod); dialog_option_switch(d->vbox, d, OPT_R, pmod); if (ci == MLE) { iter_control_button(d->vbox, d, pmod); } } else if (ci == GMM) { dialog_option_switch(d->vbox, d, OPT_V, pmod); build_gmm_combo(d->vbox, d, pmod); } else if (ci == RESTRICT && ols_model_window(okptr)) { dialog_option_switch(d->vbox, d, OPT_B, NULL); } else if (ci == RESTRICT && vecm_model_window(okptr)) { dialog_option_switch(d->vbox, d, OPT_F, NULL); } else if (ci == GR_BOX) { dialog_option_switch(d->vbox, d, OPT_O, NULL); } if (click == VARCLICK_INSERT_ID) { active_edit_id = d->edit; } else if (click == VARCLICK_INSERT_NAME) { active_edit_name = d->edit; } else if (click == VARCLICK_INSERT_TEXT) { active_edit_text = d->edit; } if (click != VARCLICK_NONE || helpcode > 0) { gtk_window_set_keep_above(GTK_WINDOW(d->dialog), FALSE); } else { gtk_window_set_keep_above(GTK_WINDOW(d->dialog), TRUE); } gtk_widget_grab_focus(d->edit); /* "Clear" button? */ if (clear) { w = gtk_button_new_from_stock(GTK_STOCK_CLEAR); gtk_container_add(GTK_CONTAINER(d->bbox), w); g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(clear_dlg_previous), d); } /* "Cancel" button */ cancel_delete_button(d->bbox, d->dialog); /* "OK" button */ if (canceled != NULL) { w = ok_validate_button(d->bbox, canceled, NULL); } else { w = ok_button(d->bbox); } g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(edit_dialog_ok), d); gtk_widget_grab_default(w); /* "Help" button, if wanted */ if (helpcode > 0) { context_help_button(d->bbox, helpcode); } if (ci == GENR) { gtk_widget_set_size_request(GTK_WIDGET(d->dialog), 400, -1); } gtk_widget_show_all(d->dialog); }
static void clear_dlg_previous (GtkWidget *w, dialog_t *d) { edit_save_buf_clear(); textview_set_text(d->edit, NULL); }