00001 #ifdef HAVE_CONFIG_H 00002 # include <config.h> 00003 #endif 00004 00005 #include <gtk/gtk.h> 00006 00007 #include "callbacks.h" 00008 #include "interface.h" 00009 #include "support.h" 00010 00011 00012 GtkWidget *fileDialog = NULL; 00013 gchar *filename = NULL; 00014 int loading = 0; 00015 int saving = 0; 00016 gint watch_timer_id=0; 00017 00018 #include "simctrlintf.h" 00019 00020 00021 void 00022 on_SetButton_clicked (GtkButton *button, 00023 gpointer user_data) 00024 { 00025 send_values_to_controller(); 00026 } 00027 00028 00029 gboolean 00030 on_SimCtrlWindow_destroy_event (GtkWidget *widget, 00031 GdkEvent *event, 00032 gpointer user_data) 00033 { 00034 gtk_exit(0); 00035 return FALSE; 00036 } 00037 00038 00039 gboolean 00040 on_SimCtrlWindow_delete_event (GtkWidget *widget, 00041 GdkEvent *event, 00042 gpointer user_data) 00043 { 00044 gtk_exit(0); 00045 return FALSE; 00046 } 00047 00048 00049 void 00050 on_SaveButton_clicked (GtkButton *button, 00051 gpointer user_data) 00052 { 00053 loading = 0; 00054 saving = 1; 00055 fileDialog = create_fileselection1(); 00056 gtk_widget_show(fileDialog); 00057 } 00058 00059 00060 void 00061 on_OpenButton_clicked (GtkButton *button, 00062 gpointer user_data) 00063 { 00064 loading = 1; 00065 saving = 0; 00066 fileDialog = create_fileselection1(); 00067 gtk_widget_show(fileDialog); 00068 } 00069 00070 00071 int last_axis = 0; 00072 00073 void 00074 on_AxisSpinbutton_changed (GtkEditable *editable, 00075 gpointer user_data) 00076 { 00077 int axis = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(editable)); 00078 store_control_values(last_axis); 00079 update_display(); 00080 last_axis = axis; 00081 } 00082 00083 00084 void 00085 on_ok_button1_clicked (GtkButton *button, 00086 gpointer user_data) 00087 { 00088 if(NULL != fileDialog) 00089 { 00090 filename = gtk_file_selection_get_filename( GTK_FILE_SELECTION (fileDialog)); 00091 if(loading) 00092 { 00093 loadSimulationIniFile(filename); 00094 } 00095 else if(saving) 00096 { 00097 saveSimulationIniFile(filename); 00098 } 00099 gtk_widget_destroy(fileDialog); 00100 fileDialog = NULL; 00101 } 00102 loading=0; 00103 saving=0; 00104 } 00105 00106 00107 void file_dialog_cancel() 00108 { 00109 filename = NULL; 00110 if(NULL != fileDialog) 00111 { 00112 gtk_widget_destroy(fileDialog); 00113 fileDialog = NULL; 00114 } 00115 loading=0; 00116 saving=0; 00117 } 00118 00119 00120 void 00121 on_cancel_button1_clicked (GtkButton *button, 00122 gpointer user_data) 00123 { 00124 file_dialog_cancel(); 00125 } 00126 00127 00128 gboolean 00129 on_fileselection1_delete_event (GtkWidget *widget, 00130 GdkEvent *event, 00131 gpointer user_data) 00132 { 00133 file_dialog_cancel(); 00134 return FALSE; 00135 } 00136 00137 00138 gboolean 00139 on_fileselection1_destroy_event (GtkWidget *widget, 00140 GdkEvent *event, 00141 gpointer user_data) 00142 { 00143 file_dialog_cancel(); 00144 return FALSE; 00145 } 00146 00147 00148 void 00149 on_EditRadiobutton_toggled (GtkToggleButton *togglebutton, 00150 gpointer user_data) 00151 { 00152 00153 } 00154 00155 00156 void 00157 on_WatchRadiobutton_toggled (GtkToggleButton *togglebutton, 00158 gpointer user_data) 00159 { 00160 gboolean is_active = gtk_toggle_button_get_active(togglebutton); 00161 if(is_active) 00162 { 00163 if(watch_timer_id < 1) 00164 { 00165 watch_timer_id = gtk_timeout_add(1000, 00166 ((GtkFunction) read_status_and_update_display), 00167 togglebutton); 00168 } 00169 } 00170 else 00171 { 00172 if(watch_timer_id > 0) 00173 { 00174 gtk_timeout_remove(watch_timer_id); 00175 watch_timer_id = 0; 00176 } 00177 } 00178 00179 } 00180 00181 00182 void 00183 on_TrippedCheckbutton_toggled (GtkToggleButton *togglebutton, 00184 gpointer user_data) 00185 { 00186 00187 }