GList *get_working_dir_list (void) { GList *list = NULL; gchar *fname; int i; for (i=0; i<MAXRECENT && wdirp[i][0]; i++) { fname = my_filename_to_utf8(wdirp[i]); if (fname != NULL) { list = g_list_append(list, fname); } } return list; }
void set_main_window_title (const char *name, gboolean modified) { #ifdef GRETL_PID_FILE int seqno = gretl_sequence_number(); #else int seqno = 0; #endif gchar *title = NULL; if (seqno <= 1 && name == NULL) { gtk_window_set_title(GTK_WINDOW(mdata->main), "gretl"); } else if (name == NULL) { title = g_strdup_printf("gretl (%d)", seqno); } else { gchar *prog; if (seqno > 1) { prog = g_strdup_printf("gretl (%d)", seqno); } else { prog = g_strdup("gretl"); } if (!g_utf8_validate(name, -1, NULL)) { gchar *trname = my_filename_to_utf8(name); if (modified) { title = g_strdup_printf("%s: %s *", prog, trname); } else { title = g_strdup_printf("%s: %s", prog, trname); } g_free(trname); } else { if (modified) { title = g_strdup_printf("%s: %s *", prog, name); } else { title = g_strdup_printf("%s: %s", prog, name); } } g_free(prog); } if (title != NULL) { gtk_window_set_title(GTK_WINDOW(mdata->main), title); g_free(title); } }
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); }
static void real_add_files_to_menus (int ftype) { char tmp[MAXSTR]; const char *fword; guint *id; GtkActionEntry entry; const gchar *mpath[] = { "/menubar/File/OpenDataMenu/RecentData", "/menubar/File/SessionFiles/RecentSessions", "/menubar/File/ScriptFiles/RecentScripts", "/menubar/Tools/FunctionFiles/RecentGfns" }; gchar *aname, *alabel; int jmin = 0, jmax = NFILELISTS - 1; GtkWidget *w; int i, j, k; if (mdata == NULL || mdata->ui == NULL) { return; } if (ftype < NFILELISTS - 1) { jmin = ftype; jmax = jmin + 1; } action_entry_init(&entry); entry.callback = G_CALLBACK(open_file_from_filelist); for (j=jmin; j<jmax; j++) { char **filep = NULL; if (j == FILE_LIST_DATA) { filep = datap; id = data_id; fword = "Data"; } else if (j == FILE_LIST_SESSION) { filep = sessionp; id = session_id; fword = "Session"; } else if (j == FILE_LIST_SCRIPT) { filep = scriptp; id = script_id; fword = "Script"; } else if (j == FILE_LIST_GFN) { filep = gfnp; id = gfn_id; fword = "Gfn"; } /* See if there are any files to add */ if (filep == NULL || *filep[0] == '\0') { continue; } /* put the files under the menu separator: ensure valid UTF-8 for display purposes */ k = 0; for (i=0; i<MAXRECENT && filep[i][0]; i++) { gchar *fname, *apath; /* note: if the filename is already valid UTF-8, this just gives us a copy of filep[i] */ fname = my_filename_to_utf8(filep[i]); if (fname == NULL) { /* We got a rubbish 'filename'. It would be nice to know how that happened, but we'll try to recover by blanking out the rubbish and continuing. */ fprintf(stderr, "%s %d: got corrupted filename\n", mpath[j], i); filep[i][0] = '\0'; continue; } else { aname = g_strdup_printf("%s %d", fword, k); alabel = g_strdup_printf("%d. %s", k+1, gretl_basename(tmp, fname, 1)); entry.name = aname; entry.label = alabel; id[i] = vwin_menu_add_item_unique(mdata, aname, mpath[j], &entry); apath = g_strdup_printf("%s/%s", mpath[j], aname); w = gtk_ui_manager_get_widget(mdata->ui, apath); if (w != NULL) { gretl_tooltips_add(w, fname); } g_free(fname); g_free(aname); g_free(alabel); g_free(apath); k++; } } } }