UNIVERSITÀ DEGLI STUDI DI MILANO Facoltà di Scienze Matematiche, Fisiche e Naturali Dipartimento di Scienze della Terra ALLEGATI ALLA TESI DI LAUREA

Size: px
Start display at page:

Download "UNIVERSITÀ DEGLI STUDI DI MILANO Facoltà di Scienze Matematiche, Fisiche e Naturali Dipartimento di Scienze della Terra ALLEGATI ALLA TESI DI LAUREA"

Transcription

1 UNIVERSITÀ DEGLI STUDI DI MILANO Facoltà di Scienze Matematiche, Fisiche e Naturali Dipartimento di Scienze della Terra ALLEGATI ALLA TESI DI LAUREA CODICI Relatore: Prof. Alberto Luigi Marcellini Correlatore: Prof. Roberto Sabadini Tesi di Laurea di: Valerio Poggi Matr. n Anno Accademico 2005/2006

2 Indice Sezione 1 GSesame Codice Sorgente pag Gsesame.c pag Gsesame.h pag Globals.h pag Menu.c pag Menu.h pag Toolbar.c pag Toolbar.h pag List.c pag List.h pag Project.c pag Project.h pag Saf.c pag Saf.h pag Winselcfg.c pag Winselcfg.h pag Hvproccfg.c pag Hvproccfg.h pag Mainproc.c pag Mainproc.h pag Platdep.c (Linux version) pag Platdep.c (Windows version) pag Platdep.h pag Gsescfg.c pag Gsescfg.h pag Primitives.c pag Primitives.h pag Plotch.c pag Plotch.h pag Plothv.c pag Plothv.h pag

3 1.31 Warning.c pag Warning.h pag About.c pag About.h pag Thanks.c pag Thanks.h pag Icon.rc pag. 133 Sezione 2 GSesame Compilazione ed Installazione pag Makefile pag NSIS install script pag. 136 Sezione 3 ICmix - Codice Sorgente pag ICmix.c pag

4 SEZIONE 1 GSesame 1.0 Codice Sorgente 3

5 1.1 - Gsesame.c /* G-SESAME Version 1.0: */ /* a graphical front-end for SESAME modules written with GTK+ */ /* Copyright (c) 2005 Poggi Valerio */ /* valerio.poggi@idpa.cnr.it */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, */ /* MA USA */ # include <gtk/gtk.h> # include <string.h> # include <time.h> # include <locale.h> # include "globals.h" # include "gsesame.h" # include "platdep.h" # include "toolbar.h" # include "menu.h" # include "list.h" # include "winselcfg.h" # include "hvproccfg.h" # include "gsescfg.h" # include "mainproc.h" # include "about.h" # include "thanks.h" # include "warning.h" /* MAIN FUNCTION */ gint main (gint argc, gchar *argv[]) GtkWidget *h_separator; GtkWidget *status_bar; /* Disabling Gtk localization */ gtk_disable_setlocale(); setlocale (LC_ALL, ""); setlocale (LC_NUMERIC, "C"); /* Gtk initialization */ gtk_init (&argc, &argv); /* Set absolute and relative path */ 4

6 set_path (); /* Configuration windows */ create_ws_par_window (); create_hv_par_window (); create_gs_par_window (); /* Processing console */ create_console_window (); /* About & Thanks windows */ create_about_window (); create_thanks_window (); /* Main window */ main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (GTK_WIDGET(main_window), 550, 300); gtk_window_move (GTK_WINDOW (main_window), 50, 50); gtk_widget_show (main_window); /* Project's default parameters setup*/ set_default_project_name (); set_project_file (); set_project_title (); /* Quit event signal connection */ g_signal_connect (G_OBJECT(main_window), "delete_event", G_CALLBACK(warning_unsaved_work),NULL); g_signal_connect (G_OBJECT(main_window), "destroy", G_CALLBACK(warning_unsaved_work),NULL); /* Main vertical box */ vbox_main = gtk_vbox_new (FALSE,0); gtk_container_add (GTK_CONTAINER(main_window), vbox_main); gtk_widget_show (vbox_main); /* Menu bar */ create_menu (); /* Button toolbar */ create_toolbar (); /* File list widget */ /* NOTE: the first item of the saf structure MUST be initilized to NULL */ first_saf = NULL; create_gtk_list (vbox_main, argc, argv); /* Status bar (for future use) */ h_separator = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (vbox_main), h_separator, FALSE, TRUE, 0); gtk_widget_show (h_separator); 5

7 status_bar = gtk_statusbar_new (); gtk_box_pack_start (GTK_BOX (vbox_main), status_bar, FALSE, TRUE, 0); gtk_widget_show (status_bar); /* Main window should be the next window showed and actived (optional) */ gtk_widget_show_all (main_window); /* GTK main loop */ gtk_main (); /* End of main */ return 0; /* SET_DEFAULT_PROJECT_NAME: */ /* This function automatically generates a default project name using the */ /* actual creation date ("Project_day_month_year"). */ void set_default_project_name (void) time_t now; struct tm *time_ptr; time (&now); time_ptr = localtime (&now); strftime (project.name, 50, "Project_%d-%m-%Y", time_ptr); /* SET_PROJECT_FILE: */ /* This function only generates a default project file name from the */ /* current project name, but doesn't save that file. */ void set_project_file (void) sprintf (project.file, "%s.prj", project.name); /* SET_PROJECT_TITLE: */ /* This function sets the main window's title including in it the current */ /* project name. */ void set_project_title (void) sprintf (project.title_bar, "GSesame Version %s", project.name); gtk_window_set_title (GTK_WINDOW(main_window), project.title_bar); /* RESET_PROJECT_FILE: */ /* This is a callback function that simply modify the project file name. */ /* It's called when the user want to save the project with a different name */ /* or in a different place (see the "SAVE_PROJECT_AS" function). */ void reset_project_file (GtkWidget *widget, gpointer abstrptr) 6

8 const gchar *string; GtkWidget *file_selector = GTK_WIDGET (abstrptr); string = gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_selector)); strcpy (project.file, string); Gsesame.h /* Function prototypes. */ #ifndef GSESAME_H #define GSESAME_H # endif void set_default_project_name (void); void set_project_file (void); void set_project_title (void); void reset_project_file (GtkWidget *widget, gpointer abstrptr); Globals.h /* GLOBAL VARIABLES DECLARATION: */ #ifndef GLOBALS_H #define GLOBALS_H struct saf_file gchar *file; gchar sta_code [100]; gchar start_time [100]; gchar samp_freq [100]; gchar ndat [100]; gchar ch0_id [100]; gchar ch1_id [100]; gchar ch2_id [100]; gchar units [100]; struct saf_file *next_saf; ; struct prj_struct gchar name[50]; gchar file[100]; gchar title_bar[100]; project; struct confpar_struct 7

9 gdouble stalen_def; gdouble ltalen_def; gdouble minstalta_def; gdouble maxstalta_def; gdouble winlen_def; gdouble overlap_def; gdouble tolerance_def; gboolean saturation_def; gboolean noisywin_def; gdouble stalen; gdouble ltalen; gdouble minstalta; gdouble maxstalta; gdouble winlen; gdouble overlap; gdouble tolerance; gboolean saturation; gboolean noisywin; gint freqsp_type_def; gdouble freqsp_min_def; gdouble freqsp_max_def; gdouble freqsp_npnt_def; gint offrem_type_def; gdouble offrem_freq_def; gint tape_type_def; gdouble tape_perc_def; gint smth_type_def; gdouble smth_band_def; gint smth_wgh_def; gint merging_def; gboolean outsinwin_def; gint freqsp_type; gdouble freqsp_min; gdouble freqsp_max; gdouble freqsp_npnt; gint offrem_type; gdouble offrem_freq; gint tape_type; gdouble tape_perc; gint smth_type; gdouble smth_band; gint smth_wgh; gint merging; gboolean outsinwin; confpar; typedef struct saf_file SAF_LIST; typedef SAF_LIST *SAF_LIST_PTR; SAF_LIST_PTR first_saf; GtkWidget *main_window; GtkWidget *vbox_main; GtkWidget *view; gboolean plotfo; gboolean plotsdhv; gboolean plotsdfo; gboolean imgfmt; 8

10 #endif gboolean plotfo_def; gboolean plotsdhv_def; gboolean plotsdfo_def; gboolean imgfmt_def; gchar imgext[50]; Menu.c # include <gdk/gdkkeysyms.h> # include <gtk/gtk.h> # include "globals.h" # include "menu.h" # include "list.h" # include "project.h" # include "saf.h" # include "winselcfg.h" # include "hvproccfg.h" # include "gsescfg.h" # include "plotch.h" # include "plothv.h" # include "mainproc.h" # include "about.h" # include "warning.h" # include "icons/ch16x16.xpm" # include "icons/hv16x16.xpm" /* CREATE_MENU: */ /* This function create the the main menu bar with submenu. It's done in the */ /* "hard way" (more code but more control). */ void create_menu(void) GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; GtkWidget *menu_bar; GtkWidget *file_item; GtkWidget *file_menu; GtkWidget *new_prj_item; GtkWidget *new_prj_img; GtkWidget *open_prj_item; GtkWidget *open_prj_img; GtkWidget *save_prj_item; GtkWidget *save_prj_img; GtkWidget *save_prj_as_item; GtkWidget *save_prj_as_img; GtkWidget *file_sep1; GtkWidget *import_saf_item; GtkWidget *import_saf_img; GtkWidget *delete_saf_item; GtkWidget *delete_saf_img; 9

11 GtkWidget *clear_list_item; GtkWidget *clear_list_img; GtkWidget *file_sep2; GtkWidget *exit_item; GtkWidget *exit_img; GtkWidget *preferences_item; GtkWidget *preferences_menu; GtkWidget *ws_par_item; GtkWidget *ws_par_img; GtkWidget *hv_par_item; GtkWidget *hv_par_img; GtkWidget *preferences_sep1; GtkWidget *gen_opt_item; GtkWidget *gen_opt_img; GtkWidget *ch_plot_item; GtkWidget *ch_plot_menu; GtkWidget *ch_0_item; GtkWidget *ch_0_img; GtkWidget *ch_1_item; GtkWidget *ch_1_img; GtkWidget *ch_2_item; GtkWidget *ch_2_img; GtkWidget *processing_item; GtkWidget *processing_menu; GtkWidget *hv_sp_item; GtkWidget *hv_sp_img; GtkWidget *hv_sp_menu; GtkWidget *selected_hv_item; GtkWidget *all_hv_item; GtkWidget *average_hv_item; GtkWidget *as_plot_item; GtkWidget *as_plot_menu; GtkWidget *as_0_plot_item; GtkWidget *as_0_plot_img; GtkWidget *as_1_plot_item; GtkWidget *as_1_plot_img; GtkWidget *as_2_plot_item; GtkWidget *as_2_plot_img; GtkWidget *sp_plot_item; GtkWidget *sp_plot_menu; GtkWidget *av_sp_plot_item; GtkWidget *av_sp_plot_img; GtkWidget *c1_sp_plot_item; GtkWidget *c1_sp_plot_img; GtkWidget *c2_sp_plot_item; GtkWidget *c2_sp_plot_img; GtkWidget *help_item; GtkWidget *help_menu; GtkWidget *gs_man_item; GtkWidget *gs_man_img; GtkWidget *help_sep1; 10

12 GtkWidget *about_item; GtkWidget *about_img; GtkAccelGroup *accel_group; /* Make an accelerator group (shortcut keys) */ accel_group = gtk_accel_group_new (); /* Creating Menu bar */ menu_bar = gtk_menu_bar_new (); gtk_box_pack_start (GTK_BOX (vbox_main), menu_bar, FALSE, TRUE, 0); /* Widget style for creating pixmap */ style = gtk_widget_get_style(menu_bar); /* File Menu */ file_item = gtk_menu_item_new_with_mnemonic ("_File"); gtk_widget_show (file_item); gtk_container_add (GTK_CONTAINER (menu_bar), file_item); file_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_item), file_menu); /* New Project */ new_prj_item = gtk_image_menu_item_new_with_mnemonic ("_New Project"); gtk_widget_show (new_prj_item); gtk_container_add (GTK_CONTAINER (file_menu), new_prj_item); g_signal_connect (GTK_WIDGET(new_prj_item), "activate", G_CALLBACK (new_project), NULL); gtk_widget_add_accelerator (new_prj_item, "activate", accel_group, GDK_N, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); new_prj_img = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (new_prj_item), new_prj_img); gtk_widget_show (new_prj_img); /* Open Project */ open_prj_item = gtk_image_menu_item_new_with_mnemonic ("_Open Project"); gtk_widget_show (open_prj_item); gtk_container_add (GTK_CONTAINER (file_menu), open_prj_item); g_signal_connect (GTK_WIDGET(open_prj_item), "activate", G_CALLBACK (open_project), NULL); gtk_widget_add_accelerator (open_prj_item, "activate", accel_group, GDK_O, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); open_prj_img = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (open_prj_item), open_prj_img); gtk_widget_show (open_prj_img); 11

13 /* Save Project */ save_prj_item = gtk_image_menu_item_new_with_mnemonic ("_Save Project"); gtk_widget_show (save_prj_item); gtk_container_add (GTK_CONTAINER (file_menu), save_prj_item); g_signal_connect (GTK_WIDGET(save_prj_item), "activate", G_CALLBACK (save_project), NULL); gtk_widget_add_accelerator (save_prj_item, "activate", accel_group, GDK_S, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); save_prj_img = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_prj_item), save_prj_img); gtk_widget_show (save_prj_img); /* Save Project As */ save_prj_as_item = gtk_image_menu_item_new_with_mnemonic ("Save Project _As"); gtk_widget_show (save_prj_as_item); gtk_container_add (GTK_CONTAINER (file_menu), save_prj_as_item); g_signal_connect (GTK_WIDGET(save_prj_as_item), "activate", G_CALLBACK (save_project_as), NULL); gtk_widget_add_accelerator (save_prj_as_item, "activate", accel_group, GDK_A, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); save_prj_as_img = gtk_image_new_from_stock ("gtk-save-as", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_prj_as_item), save_prj_as_img); gtk_widget_show (save_prj_as_img); /* Separator */ file_sep1 = gtk_separator_menu_item_new (); gtk_widget_show (file_sep1); gtk_container_add (GTK_CONTAINER (file_menu), file_sep1); gtk_widget_set_sensitive (file_sep1, FALSE); /* Import Saf */ import_saf_item = gtk_image_menu_item_new_with_mnemonic ("Import Saf _File"); gtk_widget_show (import_saf_item); gtk_container_add (GTK_CONTAINER (file_menu), import_saf_item); g_signal_connect (GTK_WIDGET(import_saf_item), "activate", G_CALLBACK (saf_file_selection), NULL); gtk_widget_add_accelerator (import_saf_item, "activate", accel_group, GDK_F, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); import_saf_img = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (import_saf_item), import_saf_img); gtk_widget_show (import_saf_img); /* Delete Saf */ 12

14 delete_saf_item = gtk_image_menu_item_new_with_mnemonic ("_Delete Item"); gtk_widget_show (delete_saf_item); gtk_container_add (GTK_CONTAINER (file_menu), delete_saf_item); g_signal_connect (GTK_WIDGET(delete_saf_item), "activate", G_CALLBACK (del_from_list), NULL); gtk_widget_add_accelerator (delete_saf_item, "activate", accel_group, GDK_D, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); delete_saf_img = gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (delete_saf_item), delete_saf_img); gtk_widget_show (delete_saf_img); /* Clear List */ clear_list_item = gtk_image_menu_item_new_with_mnemonic ("_Clear List"); gtk_widget_show (clear_list_item); gtk_container_add (GTK_CONTAINER (file_menu), clear_list_item); g_signal_connect (GTK_WIDGET(clear_list_item), "activate", G_CALLBACK (clear_list), NULL); gtk_widget_add_accelerator (clear_list_item, "activate", accel_group, GDK_C, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); clear_list_img = gtk_image_new_from_stock ("gtk-clear", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (clear_list_item), clear_list_img); gtk_widget_show (clear_list_img); /* Separator */ file_sep2 = gtk_separator_menu_item_new (); gtk_widget_show (file_sep2); gtk_container_add (GTK_CONTAINER (file_menu), file_sep2); gtk_widget_set_sensitive (file_sep2, FALSE); /* Exit */ exit_item = gtk_image_menu_item_new_with_mnemonic ("_Exit"); gtk_widget_show (exit_item); gtk_container_add (GTK_CONTAINER (file_menu), exit_item); g_signal_connect (GTK_WIDGET(exit_item), "activate", G_CALLBACK (warning_unsaved_work), NULL); gtk_widget_add_accelerator (exit_item, "activate", accel_group, GDK_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); exit_img = gtk_image_new_from_stock ("gtk-quit", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (exit_item), exit_img); gtk_widget_show (exit_img); /* Preferences Menu */ 13

15 preferences_item = gtk_menu_item_new_with_mnemonic ("_Preferences"); gtk_widget_show (preferences_item); gtk_container_add (GTK_CONTAINER (menu_bar), preferences_item); preferences_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (preferences_item), preferences_menu); /* Window Selection Preferences */ ws_par_item = gtk_image_menu_item_new_with_mnemonic ("_Window Selection Parameters"); gtk_widget_show (ws_par_item); gtk_container_add (GTK_CONTAINER (preferences_menu), ws_par_item); g_signal_connect (GTK_WIDGET(ws_par_item), "activate", G_CALLBACK (ws_window_showhide), NULL); gtk_widget_add_accelerator (ws_par_item, "activate", accel_group, GDK_W, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); ws_par_img = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (ws_par_item), ws_par_img); gtk_widget_show (ws_par_img); /* HV Processing Preferences */ hv_par_item = gtk_image_menu_item_new_with_mnemonic ("_H/V Processing Parameters"); gtk_widget_show (hv_par_item); gtk_container_add (GTK_CONTAINER (preferences_menu), hv_par_item); g_signal_connect (GTK_WIDGET(hv_par_item), "activate", G_CALLBACK (hv_window_showhide), NULL); gtk_widget_add_accelerator (hv_par_item, "activate", accel_group, GDK_H, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); hv_par_img = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (hv_par_item), hv_par_img); gtk_widget_show (hv_par_img); /* Separator */ preferences_sep1 = gtk_separator_menu_item_new (); gtk_widget_show (preferences_sep1); gtk_container_add (GTK_CONTAINER (preferences_menu), preferences_sep1); gtk_widget_set_sensitive (preferences_sep1, FALSE); /* GSesame General Options */ gen_opt_item = gtk_image_menu_item_new_with_mnemonic ("_GSesame General Options"); gtk_widget_show (gen_opt_item); gtk_container_add (GTK_CONTAINER (preferences_menu), gen_opt_item); g_signal_connect (GTK_WIDGET(gen_opt_item), "activate", G_CALLBACK (gs_window_showhide), NULL); gtk_widget_add_accelerator (gen_opt_item, "activate", accel_group, GDK_G, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); 14

16 gen_opt_img = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (gen_opt_item), gen_opt_img); gtk_widget_show (gen_opt_img); /* Trace Plot Menu */ ch_plot_item = gtk_menu_item_new_with_mnemonic ("_Trace Plot"); gtk_widget_show (ch_plot_item); gtk_container_add (GTK_CONTAINER (menu_bar), ch_plot_item); ch_plot_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (ch_plot_item), ch_plot_menu); pixmap = gdk_pixmap_create_from_xpm_d (menu_bar->window, &mask, &style->bg[gtk_state_normal],(gchar **) ch16x16_xpm); /* Channel 0 Plot */ ch_0_item = gtk_image_menu_item_new_with_mnemonic ("Channel _0"); gtk_widget_show (ch_0_item); gtk_container_add (GTK_CONTAINER (ch_plot_menu), ch_0_item); g_signal_connect (GTK_WIDGET(ch_0_item), "activate", G_CALLBACK (plot_channel), "Channel 0"); gtk_widget_add_accelerator (ch_0_item, "activate", accel_group, GDK_0, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); ch_0_img = gtk_image_new_from_pixmap (pixmap, mask); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (ch_0_item), ch_0_img); gtk_widget_show (ch_0_img); /* Channel 1 Plot */ ch_1_item = gtk_image_menu_item_new_with_mnemonic ("Channel _1"); gtk_widget_show (ch_1_item); gtk_container_add (GTK_CONTAINER (ch_plot_menu), ch_1_item); g_signal_connect (GTK_WIDGET(ch_1_item), "activate", G_CALLBACK (plot_channel), "Channel 1"); gtk_widget_add_accelerator (ch_1_item, "activate", accel_group, GDK_1, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); ch_1_img = gtk_image_new_from_pixmap (pixmap, mask); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (ch_1_item), ch_1_img); gtk_widget_show (ch_1_img); /* Channel 2 Plot */ ch_2_item = gtk_image_menu_item_new_with_mnemonic ("Channel _2"); gtk_widget_show (ch_2_item); gtk_container_add (GTK_CONTAINER (ch_plot_menu), ch_2_item); g_signal_connect (GTK_WIDGET(ch_2_item), "activate", G_CALLBACK (plot_channel), "Channel 2"); gtk_widget_add_accelerator (ch_2_item, "activate", accel_group, 15

17 GDK_2, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); ch_2_img = gtk_image_new_from_pixmap (pixmap, mask); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (ch_2_item), ch_2_img); gtk_widget_show (ch_2_img); /* Processing Menu */ processing_item = gtk_menu_item_new_with_mnemonic ("_Processing"); gtk_widget_show (processing_item); gtk_container_add (GTK_CONTAINER (menu_bar), processing_item); processing_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (processing_item), processing_menu); /* HV Spectral Ratio Menu */ hv_sp_item = gtk_image_menu_item_new_with_mnemonic ("_H/V Spectral Ratio"); gtk_widget_show (hv_sp_item); gtk_container_add (GTK_CONTAINER (processing_menu), hv_sp_item); hv_sp_img = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (hv_sp_item), hv_sp_img); gtk_widget_show (hv_sp_img); hv_sp_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (hv_sp_item), hv_sp_menu); /* Processing Selected item */ selected_hv_item = gtk_menu_item_new_with_mnemonic ("_Selected Item"); g_signal_connect (GTK_WIDGET(selected_hv_item), "activate", G_CALLBACK (console_window_show), "single"); gtk_widget_show (selected_hv_item); gtk_container_add (GTK_CONTAINER (hv_sp_menu), selected_hv_item); /* Processing All items */ all_hv_item = gtk_menu_item_new_with_mnemonic ("_All Items"); g_signal_connect (GTK_WIDGET(all_hv_item), "activate", G_CALLBACK (console_window_show), "all"); gtk_widget_show (all_hv_item); gtk_container_add (GTK_CONTAINER (hv_sp_menu), all_hv_item); /* Processing Average */ average_hv_item = gtk_menu_item_new_with_mnemonic ("_List Average"); g_signal_connect (GTK_WIDGET(average_hv_item), "activate", G_CALLBACK (console_window_show), "average"); gtk_widget_show (average_hv_item); gtk_container_add (GTK_CONTAINER (hv_sp_menu), average_hv_item); 16

18 /* Absolute Spectra Plot Menu */ as_plot_item = gtk_menu_item_new_with_mnemonic ("_Spectrum Plot"); gtk_widget_show (as_plot_item); gtk_container_add (GTK_CONTAINER (menu_bar), as_plot_item); as_plot_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (as_plot_item), as_plot_menu); pixmap = gdk_pixmap_create_from_xpm_d (menu_bar->window, &mask, &style->bg[gtk_state_normal],(gchar **) hv16x16_xpm); /* Channel 0 Absolute Spectrum Plot */ as_0_plot_item = gtk_image_menu_item_new_with_mnemonic ("Channel 0"); gtk_widget_show (as_0_plot_item); gtk_container_add (GTK_CONTAINER (as_plot_menu), as_0_plot_item); g_signal_connect (GTK_WIDGET(as_0_plot_item), "activate", G_CALLBACK (plot_hvsp), "Ch 0 Spectrum"); gtk_widget_add_accelerator (as_0_plot_item, "activate", accel_group, GDK_0, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); as_0_plot_img = gtk_image_new_from_pixmap (pixmap, mask); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (as_0_plot_item), as_0_plot_img); gtk_widget_show (as_0_plot_img); /* Channel 1 Absolute Spectrum Plot */ as_1_plot_item = gtk_image_menu_item_new_with_mnemonic ("Channel 1"); gtk_widget_show (as_1_plot_item); gtk_container_add (GTK_CONTAINER (as_plot_menu), as_1_plot_item); g_signal_connect (GTK_WIDGET(as_1_plot_item), "activate", G_CALLBACK (plot_hvsp), "Ch 1 Spectrum"); gtk_widget_add_accelerator (as_1_plot_item, "activate", accel_group, GDK_1, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); as_1_plot_img = gtk_image_new_from_pixmap (pixmap, mask); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (as_1_plot_item), as_1_plot_img); gtk_widget_show (as_1_plot_img); /* Channel 2 Absolute Spectrum Plot */ as_2_plot_item = gtk_image_menu_item_new_with_mnemonic ("Channel 2"); gtk_widget_show (as_2_plot_item); gtk_container_add (GTK_CONTAINER (as_plot_menu), as_2_plot_item); g_signal_connect (GTK_WIDGET(as_2_plot_item), "activate", G_CALLBACK (plot_hvsp), "Ch 2 Spectrum"); gtk_widget_add_accelerator (as_2_plot_item, "activate", accel_group, GDK_2, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); as_2_plot_img = gtk_image_new_from_pixmap (pixmap, mask); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (as_2_plot_item), as_2_plot_img); 17

19 gtk_widget_show (as_2_plot_img); /* Spectral Ratio Plot Menu */ sp_plot_item = gtk_menu_item_new_with_mnemonic ("_Spectral Ratio"); gtk_widget_show (sp_plot_item); gtk_container_add (GTK_CONTAINER (menu_bar), sp_plot_item); sp_plot_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (sp_plot_item), sp_plot_menu); pixmap = gdk_pixmap_create_from_xpm_d (menu_bar->window, &mask, &style->bg[gtk_state_normal],(gchar **) hv16x16_xpm); /* Average Spectral Ratio Plot */ av_sp_plot_item = gtk_image_menu_item_new_with_mnemonic ("_Average"); gtk_widget_show (av_sp_plot_item); gtk_container_add (GTK_CONTAINER (sp_plot_menu), av_sp_plot_item); g_signal_connect (GTK_WIDGET(av_sp_plot_item), "activate", G_CALLBACK (plot_hvsp), "Average H/V"); gtk_widget_add_accelerator (av_sp_plot_item, "activate", accel_group, GDK_0, GDK_CONTROL_MASK GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); av_sp_plot_img = gtk_image_new_from_pixmap (pixmap, mask); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (av_sp_plot_item), av_sp_plot_img); gtk_widget_show (av_sp_plot_img); /* Channel 1 Spectral Ratio Plot */ c1_sp_plot_item = gtk_image_menu_item_new_with_mnemonic ("H(_1)/V"); gtk_widget_show (c1_sp_plot_item); gtk_container_add (GTK_CONTAINER (sp_plot_menu), c1_sp_plot_item); g_signal_connect (GTK_WIDGET(c1_sp_plot_item), "activate", G_CALLBACK (plot_hvsp), "H(1)/V"); gtk_widget_add_accelerator (c1_sp_plot_item, "activate", accel_group, GDK_1, GDK_CONTROL_MASK GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); c1_sp_plot_img = gtk_image_new_from_pixmap (pixmap, mask); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (c1_sp_plot_item), c1_sp_plot_img); gtk_widget_show (c1_sp_plot_img); /* Channel 2 Spectral Ratio Plot */ c2_sp_plot_item = gtk_image_menu_item_new_with_mnemonic ("H(_2)/V"); gtk_widget_show (c2_sp_plot_item); gtk_container_add (GTK_CONTAINER (sp_plot_menu), c2_sp_plot_item); g_signal_connect (GTK_WIDGET(c2_sp_plot_item), "activate", G_CALLBACK (plot_hvsp), "H(2)/V"); gtk_widget_add_accelerator (c2_sp_plot_item, "activate", accel_group, GDK_2, GDK_CONTROL_MASK GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); c2_sp_plot_img = gtk_image_new_from_pixmap (pixmap, mask); 18

20 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (c2_sp_plot_item), c2_sp_plot_img); gtk_widget_show (c2_sp_plot_img); /* Help Menu */ help_item = gtk_menu_item_new_with_mnemonic ("_Help"); gtk_widget_show (help_item); gtk_container_add (GTK_CONTAINER (menu_bar), help_item); help_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (help_item), help_menu); /* GSesame Manual */ gs_man_item = gtk_image_menu_item_new_with_mnemonic ("GSesame _Manual"); gtk_widget_show (gs_man_item); gtk_container_add (GTK_CONTAINER (help_menu), gs_man_item); gtk_widget_add_accelerator (gs_man_item, "activate", accel_group, GDK_F1, 0, GTK_ACCEL_VISIBLE); gs_man_img = gtk_image_new_from_stock ("gtk-help", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (gs_man_item), gs_man_img); gtk_widget_show (gs_man_img); /* Separator */ help_sep1 = gtk_separator_menu_item_new (); gtk_widget_show (help_sep1); gtk_container_add (GTK_CONTAINER (help_menu), help_sep1); gtk_widget_set_sensitive (help_sep1, FALSE); /* GSesame Manual */ about_item = gtk_image_menu_item_new_with_mnemonic ("_About"); gtk_widget_show (about_item); gtk_container_add (GTK_CONTAINER (help_menu), about_item); g_signal_connect (GTK_WIDGET(about_item), "activate", G_CALLBACK (about_window_showhide), NULL); gtk_widget_add_accelerator (about_item, "activate", accel_group, GDK_F2, 0, GTK_ACCEL_VISIBLE); about_img = gtk_image_new_from_stock ("gtk-about", GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (about_item), about_img); gtk_widget_show (about_img); /* End Menu */ /* Attach the new accelerator group to the window. */ gtk_window_add_accel_group (GTK_WINDOW (main_window), accel_group); gtk_widget_show_all (menu_bar); 19

21 1.5 - Menu.h /* Function prototypes. */ #ifndef MENU_H #define MENU_H # endif void create_menu (void); Toolbar.c # include <gtk/gtk.h> # include "globals.h" # include "toolbar.h" # include "project.h" # include "list.h" # include "saf.h" # include "mainproc.h" # include "plothv.h" # include "warning.h" # include "icons/hv24x24.xpm" /* CREATE_TOOLBAR: */ /* This function create a button toolbar for a fast functions recall. */ void create_toolbar (void) GtkWidget *toolbar_main; GtkWidget *toolbutton1; GtkWidget *toolbutton2; GtkWidget *toolbutton3; GtkWidget *toolbutton4; GtkWidget *toolbutton5; GtkWidget *toolbutton6; GtkWidget *toolbutton7; GtkWidget *toolbutton8; GtkWidget *toolbutton9; GtkWidget *separatortoolitem1; GtkWidget *separatortoolitem2; GtkWidget *separatortoolitem3; GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; GtkWidget *tmp_image; GtkIconSize tmp_toolbar_icon_size; /* Main Toolbar */ 20

22 toolbar_main = gtk_toolbar_new (); gtk_widget_show (toolbar_main); gtk_box_pack_start (GTK_BOX (vbox_main), toolbar_main, FALSE, TRUE, 0); gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_main), GTK_TOOLBAR_BOTH); tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar_main)); /* New Project */ tmp_image = gtk_image_new_from_stock ("gtk-new", tmp_toolbar_icon_size); gtk_widget_show (tmp_image); toolbutton1 = (GtkWidget*) gtk_tool_button_new (tmp_image, "New"); g_signal_connect (GTK_WIDGET(toolbutton1), "clicked", G_CALLBACK (new_project), NULL); gtk_widget_show (toolbutton1); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton1); /* Open Project */ tmp_image = gtk_image_new_from_stock ("gtk-open", tmp_toolbar_icon_size); gtk_widget_show (tmp_image); toolbutton2 = (GtkWidget*) gtk_tool_button_new (tmp_image, "Open"); g_signal_connect (GTK_WIDGET(toolbutton2), "clicked", G_CALLBACK (open_project), NULL); gtk_widget_show (toolbutton2); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton2); /* Save Project */ tmp_image = gtk_image_new_from_stock ("gtk-save", tmp_toolbar_icon_size); gtk_widget_show (tmp_image); toolbutton3 = (GtkWidget*) gtk_tool_button_new (tmp_image, "Save"); g_signal_connect (GTK_WIDGET(toolbutton3), "clicked", G_CALLBACK (save_project), NULL); gtk_widget_show (toolbutton3); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton3); /* Separator */ separatortoolitem1 = (GtkWidget*) gtk_separator_tool_item_new (); gtk_widget_show (separatortoolitem1); gtk_container_add (GTK_CONTAINER (toolbar_main), separatortoolitem1); /* Import SAF */ tmp_image = gtk_image_new_from_stock ("gtk-add", tmp_toolbar_icon_size); gtk_widget_show (tmp_image); toolbutton4 = (GtkWidget*) gtk_tool_button_new (tmp_image, "Add"); g_signal_connect (GTK_WIDGET(toolbutton4), "clicked", G_CALLBACK (saf_file_selection), NULL); gtk_widget_show (toolbutton4); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton4); 21

23 /* Delete SAF */ tmp_image = gtk_image_new_from_stock ("gtk-delete", tmp_toolbar_icon_size); gtk_widget_show (tmp_image); toolbutton5 = (GtkWidget*) gtk_tool_button_new (tmp_image, "Delete"); g_signal_connect (GTK_WIDGET(toolbutton5), "clicked", G_CALLBACK (del_from_list), NULL); gtk_widget_show (toolbutton5); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton5); /* Clear list */ tmp_image = gtk_image_new_from_stock ("gtk-clear", tmp_toolbar_icon_size); gtk_widget_show (tmp_image); toolbutton6 = (GtkWidget*) gtk_tool_button_new (tmp_image, "Clear"); g_signal_connect (GTK_WIDGET(toolbutton6), "clicked", G_CALLBACK (clear_list), NULL); gtk_widget_show (toolbutton6); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton6); /* Separator */ separatortoolitem2 = (GtkWidget*) gtk_separator_tool_item_new (); gtk_widget_show (separatortoolitem2); gtk_container_add (GTK_CONTAINER (toolbar_main), separatortoolitem2); /* Item process */ tmp_image = gtk_image_new_from_stock ("gtk-execute", tmp_toolbar_icon_size); gtk_widget_show (tmp_image); toolbutton7 = (GtkWidget*) gtk_tool_button_new (tmp_image, "H/V"); g_signal_connect (GTK_WIDGET(toolbutton7), "clicked", G_CALLBACK (console_window_show), "single"); gtk_widget_show (toolbutton7); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton7); /* Spectral ratio plot */ style = gtk_widget_get_style(toolbar_main); pixmap = gdk_pixmap_create_from_xpm_d (toolbar_main->window, &mask, &style->bg[gtk_state_normal], (gchar **) hv24x24_xpm); tmp_image = gtk_image_new_from_pixmap (pixmap, mask); gtk_widget_show (tmp_image); toolbutton8 = (GtkWidget*) gtk_tool_button_new (tmp_image, "Plot"); g_signal_connect (GTK_WIDGET(toolbutton8), "clicked", G_CALLBACK (plot_hvsp), "Average H/V"); gtk_widget_show (toolbutton8); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton8); /* Separator */ 22

24 separatortoolitem3 = (GtkWidget*) gtk_separator_tool_item_new (); gtk_widget_show (separatortoolitem3); gtk_container_add (GTK_CONTAINER (toolbar_main), separatortoolitem3); /* Main quit */ tmp_image = gtk_image_new_from_stock ("gtk-quit", tmp_toolbar_icon_size); gtk_widget_show (tmp_image); toolbutton9 = (GtkWidget*) gtk_tool_button_new (tmp_image, "Exit"); g_signal_connect (GTK_WIDGET(toolbutton9), "clicked", G_CALLBACK (warning_unsaved_work), NULL); gtk_widget_show (toolbutton9); gtk_container_add (GTK_CONTAINER (toolbar_main), toolbutton9); gtk_widget_show_all (toolbar_main); Toolbar.h /* Function prototypes. */ #ifndef TOOLBAR_H #define TOOLBAR_H # endif void create_toolbar (void); List.c # include <gtk/gtk.h> # include <stdio.h> # include <stdlib.h> # include <string.h> # include "globals.h" # include "list.h" # include "platdep.h" /* SAF FIle Header's parameters enumeration: */ /* This kind of association between strings and progressive */ /* numbers make easy the list's elements referentiation. */ /* The "SAF_POINTER" element refers to an invisible field */ /* and is only used to connect the GTK list's element with */ /* the associated saf file. */ enum COLUMN_FILE_NAME, COLUMN_STA_CODE, COLUMN_START_TIME, COLUMN_SAMP_FREQ, COLUMN_NDAT, COLUMN_CH0_ID, 23

25 ; COLUMN_CH1_ID, COLUMN_CH2_ID, COLUMN_UNITS, SAF_POINTER, COLUMNS /* CREATE_LIST: */ /* This function create a clean GTK list structure and make it visible. */ /* (No elements are still included) */ void create_gtk_list (GtkWidget *vbox_main,gint argc, gchar *argv[]) GtkWidget *scrolledwindow; GtkListStore *model; GtkTreeSelection *selection; GtkCellRenderer *renderer; /* Scrolled window container initialization */ scrolledwindow = gtk_scrolled_window_new (NULL, NULL); gtk_box_pack_start (GTK_BOX (vbox_main), scrolledwindow, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow), 5); gtk_scrolled_window_set_shadow_type(gtk_scrolled_window(scrolledwindow), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_show (scrolledwindow); /* List model initialization */ model = gtk_list_store_new (COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); /* Tree view initialization from previous model*/ view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(model)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(view), TRUE); /* Tree's visible columns definition */ renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "File", renderer, "text", COLUMN_FILE_NAME, 24

26 NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "Station Code", renderer, "text", COLUMN_STA_CODE, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "Start Time", renderer, "text", COLUMN_START_TIME, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "Sampling Freqency", renderer, "text", COLUMN_SAMP_FREQ, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "Samples Number", renderer, "text", COLUMN_NDAT, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "Channel 0", renderer, "text", COLUMN_CH0_ID, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "Channel 1", renderer, "text", COLUMN_CH1_ID, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "Channel 2", renderer, "text", COLUMN_CH2_ID, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(view),-1, "Units", renderer, "text", 25

27 COLUMN_UNITS, NULL); gtk_widget_show (view); g_object_unref (model); gtk_container_add (GTK_CONTAINER (scrolledwindow), view); /* Optional: function for alternate rows evidentiation */ gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE); /* ADD_TO_LIST: */ /* This function add an item to the GTK list, getting its values from the */ /* "saf_file" structure. */ void add_to_gtk_list (SAF_LIST_PTR new_saf) GtkTreeModel *model; GtkTreeIter iter; model = gtk_tree_view_get_model(gtk_tree_view(view)); gtk_list_store_append(gtk_list_store(model), &iter); gtk_list_store_set (GTK_LIST_STORE(model), &iter, COLUMN_FILE_NAME, saf_filename_extract(new_saf->file), COLUMN_STA_CODE, new_saf->sta_code, COLUMN_START_TIME, new_saf->start_time, COLUMN_SAMP_FREQ, new_saf->samp_freq, COLUMN_NDAT, new_saf->ndat, COLUMN_CH0_ID, new_saf->ch0_id, COLUMN_CH1_ID, new_saf->ch1_id, COLUMN_CH2_ID, new_saf->ch2_id, COLUMN_UNITS, new_saf->units, SAF_POINTER, new_saf, -1); /* DEL_FROM_LIST: */ /* This function delete an item from the GTK list. */ void del_from_list (void) GtkTreeModel *model; GtkTreeIter iter; GtkTreeSelection *selection; SAF_LIST_PTR ptr_del, ptr_list, ptr_tmp; model = gtk_tree_view_get_model(gtk_tree_view(view)); selection = gtk_tree_view_get_selection(gtk_tree_view(view)); if (gtk_tree_selection_get_selected(selection, NULL, &iter)) gtk_tree_model_get(model, &iter, SAF_POINTER, &ptr_del, -1); 26

28 ptr_list = first_saf; if(ptr_list == ptr_del) first_saf = first_saf->next_saf; list_item_mem_free(ptr_list); else while(ptr_list!= ptr_del) ptr_tmp = ptr_list; ptr_list = ptr_list->next_saf; ptr_tmp->next_saf = ptr_list->next_saf; list_item_mem_free(ptr_list); gtk_list_store_remove(gtk_list_store(model), &iter); /* LIST_ITEM_MEM_FREE: */ /* This function frees memory of the headre's variables used in a list item; */ /* NOTE: it doesn't frees data sample's memory. */ void list_item_mem_free (SAF_LIST_PTR ptr_list) if (ptr_list->file!= NULL) free(ptr_list->file); if (ptr_list!= NULL) free(ptr_list); /* CLEAR_LIST: */ /* This function clear each list's element freeing memory. */ void clear_list (void) GtkTreeModel *model; SAF_LIST_PTR ptr_list, ptr_tmp; model = gtk_tree_view_get_model(gtk_tree_view(view)); gtk_list_store_clear(gtk_list_store(model)); ptr_list = first_saf; while(ptr_list!= NULL) ptr_tmp = ptr_list->next_saf; list_item_mem_free(ptr_list); ptr_list = ptr_tmp; 27

29 //if(ptr_list!= NULL) //list_item_mem_free(ptr_tmp); first_saf = NULL; CONTROLLARE BENE!!! List.h /* Function prototypes. */ #ifndef LIST_H #define LIST_H void create_gtk_list void add_to_gtk_list void del_from_list void list_item_mem_free void clear_list (GtkWidget *vbox_main, int argc, char *argv[]); (SAF_LIST_PTR new_saf); (void); (SAF_LIST_PTR ptr_list); (void); # endif Project.c # include <gtk/gtk.h> # include <stdio.h> # include <stdlib.h> # include <string.h> # include "globals.h" # include "gsesame.h" # include "list.h" # include "project.h" # include "saf.h" # include "winselcfg.h" # include "hvproccfg.h" # include "platdep.h" /* NEW_PROJECT: */ /* This function generates a dialog window that lets users to define/change */ /* the project name. Note that any possible change is unsaved, so you have */ /* to save it manually after. */ void new_project (void) GtkWidget *prj_new_dlg; GtkWidget *hbox; 28

30 GtkWidget *stock_image; GtkWidget *label; GtkWidget *entry; const gchar *string; gint response; /* Dialog window */ prj_new_dlg = gtk_dialog_new_with_buttons ("New Project", NULL, GTK_DIALOG_MODAL GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); /* Horizontal box */ hbox = gtk_hbox_new (FALSE,10); gtk_container_set_border_width (GTK_CONTAINER(hbox),10); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(prj_new_dlg)->vbox), hbox, FALSE, FALSE, 0); /* Dialog question stock image and label */ stock_image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX(hbox),stock_image,FALSE,FALSE,0); label = gtk_label_new_with_mnemonic ("Enter Project Name:"); gtk_box_pack_start (GTK_BOX(hbox),label,FALSE,FALSE,0); /* Entry widget */ entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY(entry), project.name); gtk_box_pack_start (GTK_BOX(hbox),entry,FALSE,FALSE,0); gtk_widget_show_all (prj_new_dlg); /* Action evaluation control: */ /* if the OK button is pressed, the project name is redifined. */ response = gtk_dialog_run (GTK_DIALOG(prj_new_dlg)); if (response == GTK_RESPONSE_ACCEPT) string = gtk_entry_get_text (GTK_ENTRY(entry)); strcpy (project.name,string); set_project_title (); set_project_file (); gtk_widget_destroy (prj_new_dlg); 29

31 /* SAVE_PROJECT: */ /* This function save the project by writing a file in which are stored all */ /* the project parameters. */ /* It uses the "project file name" global variable as target: */ /* if the file exists it is overwritten, otherwise is created by calling the */ /* SAVE_PROJECT_AS function. */ void save_project (void) FILE *fp; if((fp = fopen (project.file, "r"))!= NULL) fclose (fp); write_project_file (); else save_project_as (); /* SAVE_PROJECT_AS: */ /* This function save the project by writing a file in which are stored all */ /* the project parameters. */ /* It uses the "project file name" global variable, but allows user to change */ /* the target with a simple dialog window; if the file exists than the window */ /* ask for owerwrite. */ void save_project_as (void) GtkWidget *prj_selection; gchar fileseldef[200]; /* File selection dialog window */ prj_selection = gtk_file_selection_new ("Save Project"); /* Set the default filename */ sprintf(fileseldef, "%s%s", prj_path, project.file); gtk_file_selection_set_filename (GTK_FILE_SELECTION(prj_selection), fileseldef); /* OK button signal connection */ g_signal_connect (GTK_FILE_SELECTION(prj_selection)->ok_button, "clicked", G_CALLBACK(reset_project_file), prj_selection); g_signal_connect (GTK_FILE_SELECTION(prj_selection)->ok_button, "clicked", G_CALLBACK(ask_for_overwrite_project), prj_selection); 30

32 /* Cancel button signal connection */ g_signal_connect_swapped (GTK_FILE_SELECTION(prj_selection)->cancel_button, "clicked", G_CALLBACK(gtk_widget_destroy), prj_selection); gtk_widget_show (prj_selection); /* ASK_FOR_OVERWRITE_PROJECT: */ /* This function open a small dialog window that ask user for overwrite */ /* (or not) the current project file, if exists. */ /* If not, write the project in the selected file. */ void ask_for_overwrite_project(gtkwidget *widget, gpointer abstrptr) GtkWidget *file_selector = GTK_WIDGET(abstrptr); GtkWidget *overwrite; GtkWidget *hbox; GtkWidget *stock_image; GtkWidget *label; gint response; FILE *fp; /* File exists */ if ((fp = fopen(project.file, "r"))!= NULL) /* Dialog window */ overwrite = gtk_dialog_new_with_buttons ("Warning!", NULL, GTK_DIALOG_MODAL GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); /* Horizontal box */ hbox = gtk_hbox_new (FALSE,10); gtk_container_set_border_width (GTK_CONTAINER(hbox),10); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(overwrite)->vbox), hbox,false,false,0); /* Dialog question stock image and label */ stock_image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX(hbox),stock_image,FALSE,FALSE,0); label = gtk_label_new_with_mnemonic ("File exists: overwrite?"); gtk_box_pack_start (GTK_BOX(hbox),label,FALSE,FALSE,0); gtk_widget_show_all (overwrite); /* Response evaluation */ response = gtk_dialog_run (GTK_DIALOG(overwrite)); 31

33 if (response == GTK_RESPONSE_ACCEPT) write_project_file (); gtk_widget_destroy (GTK_WIDGET(file_selector)); gtk_widget_destroy (overwrite); fclose (fp); /* File doesn't exist */ else write_project_file (); gtk_widget_destroy (GTK_WIDGET(file_selector)); /* OPEN_PROJECT: */ /* This function open a fileselection dialog window to open an existing */ /* project file. */ void open_project (void) GtkWidget *prj_selection; /* File selection dialog window */ prj_selection = gtk_file_selection_new ( "Open Project"); /* Set the default target */ gtk_file_selection_set_filename (GTK_FILE_SELECTION(prj_selection), prj_path); /* Signal connection */ g_signal_connect (GTK_FILE_SELECTION (prj_selection)->ok_button, "clicked", G_CALLBACK(read_project_file), prj_selection); g_signal_connect_swapped (GTK_FILE_SELECTION(prj_selection)->cancel_button, "clicked", G_CALLBACK(gtk_widget_destroy), prj_selection); gtk_widget_show (prj_selection); /* WRITE_PROJECT_FILE: */ /* This function save the project informations (name and saf file list) in a */ /* ASCII project file. */ void write_project_file (void) FILE *fp; 32

34 SAF_LIST_PTR ptr_list; gchar *string[300]; gint count = 0; gint i; /* Open project file */ if ((fp = fopen(project.file, "w+"))!= NULL); /* File header */ fprintf(fp,"gsesame PROJECT FILE\n"); /* Project name */ fprintf(fp,"name = "); fprintf(fp,"%s\n",project.name); /* Winselection parameters */ fprintf(fp,"wspar = "); fprintf(fp,"%.2f ",confpar.stalen); fprintf(fp,"%.2f ",confpar.ltalen); fprintf(fp,"%.2f ",confpar.minstalta); fprintf(fp,"%.2f ",confpar.maxstalta); fprintf(fp,"%.2f ",confpar.winlen); fprintf(fp,"%.2f ",confpar.overlap); fprintf(fp,"%.2f ",confpar.tolerance); fprintf(fp,"%d ",confpar.saturation); fprintf(fp,"%d\n",confpar.noisywin); /* HVProcessing parameters */ fprintf(fp,"hvpar = "); fprintf(fp,"%d ",confpar.freqsp_type); fprintf(fp,"%.2f ",confpar.freqsp_min); fprintf(fp,"%.2f ",confpar.freqsp_max); fprintf(fp,"%.2f ",confpar.freqsp_npnt); fprintf(fp,"%d ",confpar.offrem_type); fprintf(fp,"%.2f ",confpar.offrem_freq); fprintf(fp,"%d ",confpar.tape_type); fprintf(fp,"%.2f ",confpar.tape_perc); fprintf(fp,"%d ",confpar.smth_type); fprintf(fp,"%.2f ",confpar.smth_band); fprintf(fp,"%d ",confpar.smth_wgh); fprintf(fp,"%d ",confpar.merging); fprintf(fp,"%d\n",confpar.outsinwin); /* SAF file list: */ /* the list structure is reorganized to */ /* be saved in the correct order. */ if (first_saf!= NULL) ptr_list = first_saf; while (ptr_list!= NULL) string[count] = ptr_list->file; ptr_list = ptr_list->next_saf; count++; for (i=1;i<=count;i++) fprintf(fp,"saf = "); fprintf(fp,"%s\n",string[count - i]); 33

35 /* Close file */ fclose(fp); /* READ_PROJECT_FILE: */ /* this function read an existing project file and import its informations. */ void read_project_file (GtkWidget *widget, gpointer abstrptr) gchar *header = "SESAME ASCII data format (saf) v. 1"; GtkWidget *file_selector = GTK_WIDGET(abstrptr); const gchar *selected_filename; gchar *extract = NULL; gchar saf_string[50]; gchar string[200]; FILE *fp, *saf_fp; /* Clear each previous list item */ clear_list(); /* Open project file */ selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION(file_selector)); if((fp = fopen(selected_filename, "r"))!= NULL) /* Check if the file is a project file; if so */ /* close the file selection. */ fgets(string,200,fp); if(strstr(string,"gsesame PROJECT FILE") == string) gtk_widget_destroy(gtk_widget(file_selector)); /* Redefine the project.name variable */ strcpy(project.file,selected_filename); while (!feof(fp)) fgets(string,200,fp); extract = string_extract(fp, string); /* Redefine the project.name variable */ /* and the project title */ if (strstr(string,"name") == string) strcpy(project.name,extract); set_project_title(); /* Winselection parameters */ if (strstr(string,"wspar") == string) sscanf(extract, "%lf%lf%lf%lf%lf%lf%lf%d%d", &confpar.stalen, &confpar.ltalen, &confpar.minstalta, &confpar.maxstalta, 34

36 &confpar.winlen, &confpar.overlap, &confpar.tolerance, &confpar.saturation, &confpar.noisywin); ws_undo_value (NULL, NULL); /* HVProcessing parameters */ if (strstr(string,"hvpar") == string) sscanf(string,"%d%lf%lf%lf%d%lf%d%lf%d%lf%d%d%d", &confpar.freqsp_type, &confpar.freqsp_min, &confpar.freqsp_max, &confpar.freqsp_npnt, &confpar.offrem_type, &confpar.offrem_freq, &confpar.tape_type, &confpar.tape_perc, &confpar.smth_type, &confpar.smth_band, &confpar.smth_wgh, &confpar.merging, &confpar.outsinwin); hv_undo_value (NULL, NULL); /* Get the saf file item */ if (strstr(string,"saf") == string) /* Check if the file exist. */ if((saf_fp = fopen(extract, "r"))!= NULL) fgets(saf_string,50,saf_fp); fclose(saf_fp); /* Check if the file is a SAF file. */ if (strstr(saf_string,header) == saf_string) add_to_c_list ((const gchar *)extract); add_to_gtk_list (first_saf); /* Clear the string for the next cicle */ strcpy(string,"*****"); extract = string; fclose(fp); gchar *string_extract (FILE *fp, gchar *string) gchar *newline_ptr; gchar *extract = NULL; 35

37 /* Control for a line terminator character: */ /* if present, it's substituted whit a */ /* string terminator character. */ newline_ptr = strchr (string,'\n'); if (newline_ptr!= NULL) newline_ptr[0] = '\0'; newline_ptr = strchr (string,'\r'); if (newline_ptr!= NULL) newline_ptr[0] = '\0'; /* Getting string information whitout identifier: */ /* any eventual white space at the begin is omitted */ extract = strchr(string, '='); if (extract!= NULL) extract = extract + sizeof(char); while ((extract[0] == ' ') (extract[0] == '\0')) extract = extract + sizeof(char); else extract = string; return extract; Project.h /* Function prototypes. */ #ifndef PROJECT_H #define PROJECT_H void new_project (void); void save_project (void); void save_project_as (void); void ask_for_overwrite_project (GtkWidget *widget, gpointer abstrptr); void open_project (void); void write_project_file (void); 36

Lecture 3. GUI Programming part 1: GTK

Lecture 3. GUI Programming part 1: GTK INTRODUCTION TO DESIGN AUTOMATION Lecture 3. GUI Programming part 1: GTK Guoyong Shi, PhD shiguoyong@ic.sjtu.edu.cn School of Microelectronics Shanghai Jiao Tong University Fall 2010 2010-9-15 Slide 1

More information

COMP 2400 UNIX Tools

COMP 2400 UNIX Tools COMP 2400 UNIX Tools Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 GTK+ GTK+ = Gimp Tool Kit, Manipulation Program GIMP = GNU Image Basis for Gnome Written in C, bindings for

More information

Maemo Diablo Reference Manual for maemo 4.1. Application Development

Maemo Diablo Reference Manual for maemo 4.1. Application Development Maemo Diablo Reference Manual for maemo 4.1 Application Development December 22, 2008 Contents 1 Application Development 3 1.1 Introduction.............................. 3 1.2 Typical Maemo GUI Application..................

More information

Lesson 2: GTK+ Basics

Lesson 2: GTK+ Basics 1 A First GTK+ Program We will begin with a very simple GTK+ program in order to demonstrate some of the key tasks that every GTK+ main program must perform. The program, hello_world.c, is found in many

More information

OO for GUI Design (contd.) Questions:

OO for GUI Design (contd.) Questions: OO for GUI Design (contd.) Questions: 1 1. What is a window manager and what are its responsibilities? 2 2. How would you define an event in the context of GUI programming? 3 3. What is the first thing

More information

Programming with Clutter. Murray Cumming

Programming with Clutter. Murray Cumming Programming with Clutter Murray Cumming Programming with Clutter by Murray Cumming Copyright 2007, 2008 Openismus GmbH We very much appreciate any reports of inaccuracies or other errors in this document.

More information

What's new in GTK+ 2.6

What's new in GTK+ 2.6 What's new in GTK+ 2.6 Matthias Clasen mclasen@redhat.com GUADEC 2005 Stuttgart, Germany May 29 May 1, 2005 What's new in GTK+ 2.6 New or improved widgets New cell renderers Clipboard improvements Ellipsization

More information

The FFI Reference Manual

The FFI Reference Manual The FFI Reference Manual a Foreign Function Interface (version 0.2) for MIT/GNU Scheme version 9.0.1 2011-09-19 by Matt Birkholz This manual documents FFI 0.2. Copyright c 1986, 1987, 1988, 1989, 1990,

More information

C Libraries. Using GLib. Ph. D. Eng. Lucjan Miękina upel.agh.edu.pl/wimir/login/ Department of Robotics and Mechatronics 1/31

C Libraries. Using GLib. Ph. D. Eng. Lucjan Miękina upel.agh.edu.pl/wimir/login/ Department of Robotics and Mechatronics 1/31 1/31 C Libraries Using GLib Ph. D. Eng. Lucjan Miękina upel.agh.edu.pl/wimir/login/ Department of Robotics and Mechatronics January 10, 2017 2/31 Programming in C External libraries - GLib If you re writing

More information

The GTK+ Tree View. 1 Overview. 2 A Bit of Terminology. Prof. Stewart Weiss. CSci Graphical User Interface Programming The GTK+ Tree View

The GTK+ Tree View. 1 Overview. 2 A Bit of Terminology. Prof. Stewart Weiss. CSci Graphical User Interface Programming The GTK+ Tree View 1 Overview The GTK+ TreeView widget, called GtkTreeView in the C language binding, is based on a Model/View/- Controller (MVC) design paradigm. In this paradigm, the visual display of information is separate

More information

t GTK+ Object # widget, [ W< z< sl. y Widget E / Xlib E 8 Csq ;, #,., $ Gtk widget object GWuS vv q. A o. # widget x C widget # X L. B #, D #( *), " #

t GTK+ Object # widget, [ W< z< sl. y Widget E / Xlib E 8 Csq ;, #,., $ Gtk widget object GWuS vv q. A o. # widget x C widget # X L. B #, D #( *),  # GTK Tutorial Ian Main imain@gtk.org, Tony Gale gale@gtk.org 1998[ 5 24 ts liberta@cau.ac.kr, hanjiho@penta.co.kr 1998[ 5 25 C 1 < & 2 S B GTK Tutorial. GTK+ W W http://www.gtk. org/.? Z (3/??), Tutorial

More information

Container Widgets and Packing

Container Widgets and Packing Container Widgets and Packing As mentioned in Chapter 2, there are two kinds of containers, those that can hold no more than one child widget, and those that can hold more than one. Containers that can

More information

Creating GNOME Applications with Glade. Part I: Introduction

Creating GNOME Applications with Glade. Part I: Introduction Creating GNOME Applications with Glade Part I: Introduction Glade 3 Glade 3 is a tool to enable quick and easy development of Uis for the GTK+ toolkit and GNOME desktop environment. User interfaces designed

More information

Open source MySQL Browser for Open Innovation

Open source MySQL Browser for Open Innovation Open source MySQL Browser for Open Innovation Lecturer Radu Bucea-Manea-Tonis, PhD 1 1 mysqlbrowser.codeplex.com Abstract. Our purpose is to cross-compile MySQL driver source code for Linux on Windows

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

THE UNIVERSITY OF WESTERN ONTARIO. COMPUTER SCIENCE 211a FINAL EXAMINATION 17 DECEMBER HOURS

THE UNIVERSITY OF WESTERN ONTARIO. COMPUTER SCIENCE 211a FINAL EXAMINATION 17 DECEMBER HOURS Computer Science 211a Final Examination 17 December 2002 Page 1 of 17 THE UNIVERSITY OF WESTERN ONTARIO LONDON CANADA COMPUTER SCIENCE 211a FINAL EXAMINATION 17 DECEMBER 2002 3 HOURS NAME: STUDENT NUMBER:

More information

EE495K Slides by Avi Kak: OO for GUI Design (contd.)

EE495K Slides by Avi Kak: OO for GUI Design (contd.) EE495K Slides by Avi Kak: OO for GUI Design (contd.) 1 Date: Tue, 18 Feb 2003 09:42:33 CST To: kak@ecn.purdue.edu From: Newton Matthew-W18732 Subject: RE: Visit to Purdue! Return-Path:

More information

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

C SCI The X Window System Stewart Weiss

C SCI The X Window System Stewart Weiss The X Window System The X Window System is a networking and display protocol which provides windowing on bitmapped displays. X provides the basic framework for building GUI environments, such as drawing

More information

Cake: a tool for adaptation of object code

Cake: a tool for adaptation of object code Cake: a tool for adaptation of object code Stephen Kell Stephen.Kell@cl.cam.ac.uk Computer Laboratory University of Cambridge Cake... p.1/32 Some familiar problems Software is expensive to develop expensive

More information

CSCI 2132 Final Exam Solutions

CSCI 2132 Final Exam Solutions Faculty of Computer Science 1 CSCI 2132 Final Exam Solutions Term: Fall 2018 (Sep4-Dec4) 1. (12 points) True-false questions. 2 points each. No justification necessary, but it may be helpful if the question

More information

HomeScope : an open microscope with an XY stage

HomeScope : an open microscope with an XY stage 2018 年 1 月 5 日 1 HomeScope : an open microscope with an XY stage A hacker guide for the DIY biologist 2 The HomeScope is a homemade RaspiCam-based microscope system capable of recording video and/or image

More information

Gjs/GTK+ 3 Tutorial Documentation

Gjs/GTK+ 3 Tutorial Documentation Gjs/GTK+ 3 Tutorial Documentation Release 0 Christian Bjartli Aug 28, 2017 Contents: 1 Installation 3 2 Getting Started 5 2.1 Simple Example............................................. 5 2.2 Extended

More information

Darshan Institute of Engineering & Technology for Diploma Studies Unit 6

Darshan Institute of Engineering & Technology for Diploma Studies Unit 6 1. What is File management? In real life, we want to store data permanently so that later on we can retrieve it and reuse it. A file is a collection of bytes stored on a secondary storage device like hard

More information

Kurt Schmidt. October 30, 2018

Kurt Schmidt. October 30, 2018 to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed

More information

ECE264 Spring 2014 Exam 2, March 11, 2014

ECE264 Spring 2014 Exam 2, March 11, 2014 ECE264 Spring 2014 Exam 2, March 11, 2014 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

Fundamentals of Programming. Lecture 10 Hamed Rasifard

Fundamentals of Programming. Lecture 10 Hamed Rasifard Fundamentals of Programming Lecture 10 Hamed Rasifard 1 Outline File Input/Output 2 Streams and Files The C I/O system supplies a consistent interface to the programmer independent of the actual device

More information

Unit 6 Files. putchar(ch); ch = getc (fp); //Reads single character from file and advances position to next character

Unit 6 Files. putchar(ch); ch = getc (fp); //Reads single character from file and advances position to next character 1. What is File management? In real life, we want to store data permanently so that later on we can retrieve it and reuse it. A file is a collection of bytes stored on a secondary storage device like hard

More information

ECE264 Fall 2013 Exam 2, October 24, 2013

ECE264 Fall 2013 Exam 2, October 24, 2013 ECE Fall 0 Exam, October, 0 If this is an on-line exam, you have 0 minutes to finish the exam. When the time limit is reached, the system will automatically close. If this is a paper exam, you have 0 minutes.

More information

Automatically generated type-safe GTK+ binding for Dylan

Automatically generated type-safe GTK+ binding for Dylan Automatically generated type-safe GTK+ binding for Dylan Hannes Mehnert hannes@mehnert.org Dylan Hackers ABSTRACT We present an automated way to get language bindings for GTK+ for Dylan [2], an object-oriented

More information

beginslide Chapter 2 Abstract Data Types Copyright C. Gotsman & Y.M. Kimchi, Computer Science Dept. Technion

beginslide Chapter 2 Abstract Data Types Copyright C. Gotsman & Y.M. Kimchi, Computer Science Dept. Technion 1 Chapter 2 Abstract Data Types Modularity 2 module modules - functions. - function calls. Program elements that are tightly coupled should be organized as modules. Their connection to the outside world

More information

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto Adapted from the slides Revisões sobre Programação em C, Sérgio Crisóstomo Compilation #include int main()

More information

MRO Delay Line. Coding and Documentation Guidelines for Prototype Delay Line Software. John Young. rev June 2007

MRO Delay Line. Coding and Documentation Guidelines for Prototype Delay Line Software. John Young. rev June 2007 MRO Delay Line Coding and Documentation Guidelines for Prototype Delay Line Software John Young rev 0.5 21 June 2007 Cavendish Laboratory Madingley Road Cambridge CB3 0HE UK Objective To propose a set

More information

Rick Duley Perth, Western Australia 2009

Rick Duley Perth, Western Australia 2009 Rick Duley Perth, Western Australia 2009 Table of Contents 1 Preamble... 1 2 Introduction... 1 2.1 Why Verbose Code?... 1 2.2 On Being Methodical... 2 3 Getting GtkAda... 2 3.1 Glade... 2 3.2 GtkAda Documentation...

More information

File I/O. Arash Rafiey. November 7, 2017

File I/O. Arash Rafiey. November 7, 2017 November 7, 2017 Files File is a place on disk where a group of related data is stored. Files File is a place on disk where a group of related data is stored. C provides various functions to handle files

More information

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems Programs CSCI 4061 Introduction to Operating Systems C Program Structure Libraries and header files Compiling and building programs Executing and debugging Instructor: Abhishek Chandra Assume familiarity

More information

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems Deep C Multifile projects Getting it running Data types Typecasting Memory management Pointers Fabián E. Bustamante, Fall 2004 Multifile Projects Give your project a structure Modularized design Reuse

More information

Linked List using a Sentinel

Linked List using a Sentinel Linked List using a Sentinel Linked List.h / Linked List.h Using a sentinel for search Created by Enoch Hwang on 2/1/10. Copyright 2010 La Sierra University. All rights reserved. / #include

More information

How to use MPLABX to program and debug PICsimLab

How to use MPLABX to program and debug PICsimLab How to use MPLABX to program and debug PICsimLab Luis Claudio Gambôa Lopes http://sourceforge.net/projects/picsim/ November 2, 2015 Contents 1 Installing the Necessary Tools 2 1.1

More information

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; }

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; } Modifiers unsigned. For example unsigned int would have a range of [0..2 32 1] on a 32-bit int machine. const Constant or read-only. Same as final in Java. static Similar to static in Java but not the

More information

Lab 4: Tracery Recursion in C with Linked Lists

Lab 4: Tracery Recursion in C with Linked Lists Lab 4: Tracery Recursion in C with Linked Lists For this lab we will be building on our previous lab at the end of the previous lab you should have had: #include #include char * make_string_from

More information

Student Number: Computer Science 211b Final Examination. 28 April hours

Student Number: Computer Science 211b Final Examination. 28 April hours Computer Science 211b Final Examination 28 April 2006 3 hours Student Number: Surname: Given name: Instructions/Notes: The examination has 40 questions on 15 pages, and a total of 150 marks. Put all answers

More information

High Performance Programming Programming in C part 1

High Performance Programming Programming in C part 1 High Performance Programming Programming in C part 1 Anastasia Kruchinina Uppsala University, Sweden April 18, 2017 HPP 1 / 53 C is designed on a way to provide a full control of the computer. C is the

More information

Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE. Advanced Operating Systems A.A Exam date: 28 June 2016

Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE. Advanced Operating Systems A.A Exam date: 28 June 2016 Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE Advanced Operating Systems A.A. 2015-2016 Exam date: 28 June 2016 Prof. William FORNACIARI Surname (readable)... Matr... Name (readable)...

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

1 The CTIE processor INTRODUCTION 1

1 The CTIE processor INTRODUCTION 1 1 The CTIE processor INTRODUCTION 1 1. Introduction. Whenever a programmer wants to change a given WEB or CWEB program (referred to as a WEB program throughout this program) because of system dependencies,

More information

Lecture 7: Files. opening/closing files reading/writing strings reading/writing numbers (conversion to ASCII) command line arguments

Lecture 7: Files. opening/closing files reading/writing strings reading/writing numbers (conversion to ASCII) command line arguments Lecture 7: Files opening/closing files reading/writing strings reading/writing numbers (conversion to ASCII) command line arguments Lecture 5: Files, I/O 0IGXYVI*MPIW 0 opening/closing files reading/writing

More information

C Programming Helper. Prof Bill - Mar This is a little helper document for quickly plunging into the C Programming Language.

C Programming Helper. Prof Bill - Mar This is a little helper document for quickly plunging into the C Programming Language. C Programming Helper Prof Bill - Mar 2018 This is a little helper document for quickly plunging into the C Programming Language. The sections are: A. Introduction B. The Command Line C. C Coding D. My

More information

M.CS201 Programming language

M.CS201 Programming language Power Engineering School M.CS201 Programming language Lecture 16 Lecturer: Prof. Dr. T.Uranchimeg Agenda Opening a File Errors with open files Writing and Reading File Data Formatted File Input Direct

More information

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Announcements Exam 1 (20%): Feb. 27 (Tuesday) Tentative Proposal Deadline:

More information

Exercise Session 2 Systems Programming and Computer Architecture

Exercise Session 2 Systems Programming and Computer Architecture Systems Group Department of Computer Science ETH Zürich Exercise Session 2 Systems Programming and Computer Architecture Herbstsemester 216 Agenda Linux vs. Windows Working with SVN Exercise 1: bitcount()

More information

A Smart Fuzzer for x86 Executables

A Smart Fuzzer for x86 Executables Università degli Studi di Milano Facoltà di Scienze Matematiche, Fisiche e Naturali A Smart Fuzzer for x86 Executables Andrea Lanzi, Lorenzo Martignoni, Mattia Monga, Roberto Paleari May 19, 2007 Lanzi,

More information

PROGRAMMAZIONE I A.A. 2017/2018

PROGRAMMAZIONE I A.A. 2017/2018 PROGRAMMAZIONE I A.A. 2017/2018 INPUT/OUTPUT INPUT AND OUTPUT Programs must be able to write data to files or to physical output devices such as displays or printers, and to read in data from files or

More information

Maemo Diablo Source code for the LibOSSO RPC examples Training Material

Maemo Diablo Source code for the LibOSSO RPC examples Training Material Maemo Diablo Source code for the LibOSSO RPC examples Training Material February 9, 2009 Contents 1 Source code for the LibOSSO RPC examples 2 1.1 libosso-example-sync/libosso-rpc-sync.c..............

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

More information

Functions in C C Programming and Software Tools. N.C. State Department of Computer Science

Functions in C C Programming and Software Tools. N.C. State Department of Computer Science Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the

More information

Computer Programming Unit v

Computer Programming Unit v READING AND WRITING CHARACTERS We can read and write a character on screen using printf() and scanf() function but this is not applicable in all situations. In C programming language some function are

More information

CSE 333 Midterm Exam 7/22/12

CSE 333 Midterm Exam 7/22/12 Name There are 6 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed

More information

File Access. FILE * fopen(const char *name, const char * mode);

File Access. FILE * fopen(const char *name, const char * mode); File Access, K&R 7.5 Dealing with named files is surprisingly similar to dealing with stdin and stdout. Start by declaring a "file pointer": FILE *fp; /* See Appendix B1.1, pg. 242 */ header

More information

WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolution. Juan J. Sánchez LinuxCon Japan 2014, Tokyo

WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolution. Juan J. Sánchez LinuxCon Japan 2014, Tokyo : Bridging the Gap Between the Kernel and the HTML5 Revolution LinuxCon Japan 2014, Tokyo Myself, Igalia and WebKit Co-founder, member of the WebKit/Blink/Browsers team Igalia is an open source consultancy

More information

CS242: Object-Oriented Design and Programming

CS242: Object-Oriented Design and Programming CS242: Object-Oriented Design and Programming Program Assignment 5 Part 1 (Linked List Timer Queue) Due Tuesday, March 18 th ; 1997 Part 2 (Heap Timer Queue) Due Tuesday, April 1 st ; 1997) A Timer Queue

More information

are all acceptable. With the right compiler flags, Java/C++ style comments are also acceptable.

are all acceptable. With the right compiler flags, Java/C++ style comments are also acceptable. CMPS 12M Introduction to Data Structures Lab Lab Assignment 3 The purpose of this lab assignment is to introduce the C programming language, including standard input-output functions, command line arguments,

More information

Lesson 5: Functions and Libraries. EE3490E: Programming S1 2018/2019 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology

Lesson 5: Functions and Libraries. EE3490E: Programming S1 2018/2019 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology Lesson 5: Functions and Libraries 1 Functions 2 Overview Function is a block of statements which performs a specific task, and can be called by others Each function has a name (not identical to any other),

More information

WATER CLASSES AND USES

WATER CLASSES AND USES APPENDIX WATER CLASSES AND USES 46 INTERIM NATIONAL WATER QUALITY STANDARDS FOR MALAYSIA 47 C SCRIPT FOR HEA TRAINING Variable Declaration and Main Programme Copyright 2007 University of Adelaide, AUSTRALIA

More information

CS1003: Intro to CS, Summer 2008

CS1003: Intro to CS, Summer 2008 CS1003: Intro to CS, Summer 2008 Lab #07 Instructor: Arezu Moghadam arezu@cs.columbia.edu 6/25/2008 Recap Pointers Structures 1 Pointer Arithmetic (exercise) What do the following return? given > char

More information

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types

More information

Course organization. Part I: Introduction to C programming language (Week 1-12) Chapter 1: Overall Introduction (Week 1-4)

Course organization. Part I: Introduction to C programming language (Week 1-12) Chapter 1: Overall Introduction (Week 1-4) Course organization 1 Course introduction ( Week 1) Code editor: Emacs Part I: Introduction to C programming language (Week 1-12) Chapter 1: Overall Introduction (Week 1-4) C Unix/Linux Chapter 2: Types,

More information

Topic 8: I/O. Reading: Chapter 7 in Kernighan & Ritchie more details in Appendix B (optional) even more details in GNU C Library manual (optional)

Topic 8: I/O. Reading: Chapter 7 in Kernighan & Ritchie more details in Appendix B (optional) even more details in GNU C Library manual (optional) Topic 8: I/O Reading: Chapter 7 in Kernighan & Ritchie more details in Appendix B (optional) even more details in GNU C Library manual (optional) No C language primitives for I/O; all done via function

More information

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready.

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready. Name: CSE 303, Winter 2007, Final Examination 15 March 2007 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for two 8.5x11in pieces of paper (both

More information

Computational Methods of Scientific Programming Fall 2007

Computational Methods of Scientific Programming Fall 2007 MIT OpenCourseWare http://ocw.mit.edu 12.010 Computational Methods of Scientific Programming Fall 2007 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

More information

CSE au Midterm Exam Nov. 2, 2018 Sample Solution

CSE au Midterm Exam Nov. 2, 2018 Sample Solution Question 1. (16 points) Build tools and make. We re building a C++ software back-end prototype for a new food web site. So far, we ve got the following source files with the code for two main programs

More information

Procedural Programming

Procedural Programming Exercise 5 (SS 2016) 28.06.2016 What will I learn in the 5. exercise Strings (and a little bit about pointer) String functions in strings.h Files Exercise(s) 1 Home exercise 4 (3 points) Write a program

More information

SOFTWARE Ph.D. Qualifying Exam Spring Consider the following C program, which includes three function definitions, including the main function.

SOFTWARE Ph.D. Qualifying Exam Spring Consider the following C program, which includes three function definitions, including the main function. (i) (6 pts.) SOFTWARE Ph.D. Qualifying Exam Spring 2017 Consider the following C program, which includes three function definitions, including the main function. #include #include

More information

EE495K Slides by Avi Kak: OO for GUI Design (contd.) Questions:

EE495K Slides by Avi Kak: OO for GUI Design (contd.) Questions: EE495K Slides by Avi Kak: OO for GUI Design (contd.) Questions: 1 1. What are the two features of every GUI program in Qt? 2 2. How are the parent-child connections established in the containment hierarchy

More information

C programming basics T3-1 -

C programming basics T3-1 - C programming basics T3-1 - Outline 1. Introduction 2. Basic concepts 3. Functions 4. Data types 5. Control structures 6. Arrays and pointers 7. File management T3-2 - 3.1: Introduction T3-3 - Review of

More information

AStyle C/C++ Source Code Formatter Plugin

AStyle C/C++ Source Code Formatter Plugin AStyle C/C++ Source Code Formatter Plugin This plugin allows for formatting and pretty-printing of C/C++ source code in an easy and convenient way. It is based on the Artistic Style code formatter utility.

More information

ECE264 Fall 2013 Exam 3, November 20, 2013

ECE264 Fall 2013 Exam 3, November 20, 2013 ECE264 Fall 2013 Exam 3, November 20, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

A Crash Course in C. Steven Reeves

A Crash Course in C. Steven Reeves A Crash Course in C Steven Reeves This class will rely heavily on C and C++. As a result this section will help students who are not familiar with C or who need a refresher. By the end of this section

More information

CMPE-013/L. File I/O. File Processing. Gabriel Hugh Elkaim Winter File Processing. Files and Streams. Outline.

CMPE-013/L. File I/O. File Processing. Gabriel Hugh Elkaim Winter File Processing. Files and Streams. Outline. CMPE-013/L Outline File Processing File I/O Gabriel Hugh Elkaim Winter 2014 Files and Streams Open and Close Files Read and Write Sequential Files Read and Write Random Access Files Read and Write Random

More information

Computer Programming

Computer Programming Computer Programming Make everything as simple as possible, but not simpler. Albert Einstein T.U. Cluj-Napoca - Computer Programming - lecture 4 - M. Joldoş 1 Outline Functions Structure of a function

More information

Pointers, Dynamic Data, and Reference Types

Pointers, Dynamic Data, and Reference Types Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple

More information

CSE 124 Discussion (10/3) C/C++ Basics

CSE 124 Discussion (10/3) C/C++ Basics CSE 124 Discussion (10/3) C/C++ Basics Topics - main() function - Compiling with gcc/makefile - Primitives - Structs/Enums - Function calls/loops - C++ Classes/stdtl - Pointers/Arrays - Memory allocation/freeing

More information

Final Intro to C Review

Final Intro to C Review Final Exam Content: Final Intro to C Review - Pass by reference Functions - General Syntax - Structures - Recursion(maybe?) - Programming by nature is cumulative so any past material is up for grabs as

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

COMP26120: Algorithms and Imperative Programming. Lecture 5: Program structuring, Java vs. C, and common mistakes

COMP26120: Algorithms and Imperative Programming. Lecture 5: Program structuring, Java vs. C, and common mistakes COMP26120: Algorithms and Imperative Programming Lecture 5: Program structuring, Java vs. C, and common mistakes Lecture outline Program structuring Functions (defining a functions, passing arguments and

More information

Main differences with Java

Main differences with Java Signals, Instruments, and Systems W2 C Programming (continued) C Main differences with Java C is NOT object oriented. (C++ is OO) C code is directly translated into binary that can be directly executed

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

CSE 333 Midterm Exam July 24, Name UW ID#

CSE 333 Midterm Exam July 24, Name UW ID# Name UW ID# There are 6 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,

More information

Beginner s Guide to scintilla: Syntax Highlighting & Code Folding for var aq. Andreas Tscharner

Beginner s Guide to scintilla: Syntax Highlighting & Code Folding for var aq. Andreas Tscharner Beginner s Guide to scintilla: Syntax Highlighting & Code Folding for var aq Andreas Tscharner April 18, 2014 Abstract Syntax Highlighting and Code Folding in Scintilla explained by the Klingon scripting

More information

Exercise(s) Solution(s) to the exercise(s)

Exercise(s) Solution(s) to the exercise(s) Exercise(s) Problem 1. Counting configurations Consider two different types of atoms, say A and B (represented by red and blue, respectively in the figures). Let A atoms and B atoms be distributed on N

More information

CSCI-243 Exam 2 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI-243 Exam 2 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-43 Exam Review February, 01 Presented by the RIT Computer Science Community http://csc.cs.rit.edu C Preprocessor 1. Consider the following program: 1 # include 3 # ifdef WINDOWS 4 # include

More information

ECE264 Spring 2013 Exam 1, February 14, 2013

ECE264 Spring 2013 Exam 1, February 14, 2013 ECE264 Spring 2013 Exam 1, February 14, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

Discussion 3 Richard Guo Advanced C 01/28/09

Discussion 3 Richard Guo Advanced C 01/28/09 Discussion 3 Richard Guo Advanced C 01/28/09 1. Answers to Last Time's Problems 1. #include int increment (int ptr); int ptr; // will not actually get used b/c masked by local variables with

More information

Here's how you declare a function that returns a pointer to a character:

Here's how you declare a function that returns a pointer to a character: 23 of 40 3/28/2013 10:35 PM Violets are blue Roses are red C has been around, But it is new to you! ANALYSIS: Lines 32 and 33 in main() prompt the user for the desired sort order. The value entered is

More information

CS 0449 Sample Midterm

CS 0449 Sample Midterm Name: CS 0449 Sample Midterm Multiple Choice 1.) Given char *a = Hello ; char *b = World;, which of the following would result in an error? A) strlen(a) B) strcpy(a, b) C) strcmp(a, b) D) strstr(a, b)

More information

Review: Constants. Modules and Interfaces. Modules. Clients, Interfaces, Implementations. Client. Interface. Implementation

Review: Constants. Modules and Interfaces. Modules. Clients, Interfaces, Implementations. Client. Interface. Implementation Review: Constants Modules and s CS 217 C has several ways to define a constant Use #define #define MAX_VALUE 10000 Substitution by preprocessing (will talk about this later) Use const const double x =

More information

Approximately a Test II CPSC 206

Approximately a Test II CPSC 206 Approximately a Test II CPSC 206 Sometime in history based on Kelly and Pohl Last name, First Name Last 5 digits of ID Write your section number(s): All parts of this exam are required unless plainly and

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

CS 580 FINAL EXAM. Fall April 29, 2014

CS 580 FINAL EXAM. Fall April 29, 2014 CS 580 FINAL EXAM Fall 201 April 29, 2014 You are to build a range tree for your final exam. A range tree is a tree where each node contains a minimum and a maximum value as well as a linked list to store

More information