*** empty log message ***
authorterminatorX <>
Sat, 16 Sep 2000 01:16:23 +0000 (01:16 +0000)
committerterminatorX <>
Sat, 16 Sep 2000 01:16:23 +0000 (01:16 +0000)
src/tX_global.c
src/tX_global.h
src/tX_mastergui.cc

index e86584b6ca3e7e286eabba060af9bbeef8ea2035..1075f9e50a72f537960bc271d4ace1d5c587a6b5 100644 (file)
@@ -38,14 +38,20 @@ tx_global globals;
 void get_rc_name(char *buffer)
 {
        strcpy(buffer,"");
-       
-       if (getenv("HOME"))
+       if (globals.alternate_rc)
+       {
+               strcpy(buffer, globals.alternate_rc);
+       }
+       else 
        {
-               strcpy(buffer, getenv("HOME"));
-               if (buffer[strlen(buffer)-1]!='/')
-               strcat(buffer, "/");
+               if (getenv("HOME"))
+               {
+                       strcpy(buffer, getenv("HOME"));
+                       if (buffer[strlen(buffer)-1]!='/')
+                       strcat(buffer, "/");
+               }
+               strcat(buffer, ".terminatorX3rc.bin");
        }
-       strcat(buffer, ".terminatorX3rc.bin");
 }
 
 void load_globals()
@@ -53,54 +59,63 @@ void load_globals()
        char rc_name[PATH_MAX]="";
        FILE *rc;
 
-       strcpy(globals.audio_device, "/dev/dsp");
+       get_rc_name(rc_name);
        
-       strcpy(globals.xinput_device, "");
-       globals.xinput_enable=0;
+       rc=fopen(rc_name, "r");
+       if (rc)
+       {
+               fread(&globals, sizeof(tx_global), 1, rc);
+               fclose(rc);
+       }
+       else
+       {
+               fprintf(stderr, "tX: Alternate rc file doesn't exist, reverting to defaults");
+
+               globals.startup_set = 0;
+               globals.store_globals = 1;
+               globals.no_gui = 0;
+               globals.alternate_rc = 0;
        
-       globals.update_idle=18;
-       globals.update_delay=1;
+               strcpy(globals.audio_device, "/dev/dsp");
        
-       globals.buff_no=2;
-       globals.buff_size=8;
-               
-       globals.sense_cycles=12;
+               strcpy(globals.xinput_device, "");
+               globals.xinput_enable=0;
        
-       globals.mouse_speed=0.8;
+               globals.update_idle=18;
+               globals.update_delay=1;
        
-       globals.width=800;
-       globals.height=440;     
+               globals.buff_no=2;
+               globals.buff_size=8;
+               
+               globals.sense_cycles=12;
        
-       globals.tooltips=1;
+               globals.mouse_speed=0.8;
        
-       globals.use_stdout=0;
+               globals.width=800;
+               globals.height=440;     
        
-       globals.show_nag=1;
-       globals.prelis=1;
+               globals.tooltips=1;
        
-       strcpy(globals.last_fn,"");
+               globals.use_stdout=0;
        
-       globals.pitch=1.0;
-       globals.volume=1.0;
-       globals.gui_wrap=3;
+               globals.show_nag=1;
+               globals.prelis=1;
        
-       globals.flash_response=0.95;
+               strcpy(globals.last_fn,"");
        
-       globals.button_type=BUTTON_TYPE_BOTH;
+               globals.pitch=1.0;
+               globals.volume=1.0;
+               globals.gui_wrap=3;
        
-       globals.true_block_size=0;
+               globals.flash_response=0.95;
        
-       strcpy(globals.tables_filename, "");
-       strcpy(globals.record_filename, "tX_record.wav");
-       strcpy(globals.file_editor, "");
+               globals.button_type=BUTTON_TYPE_BOTH;
+               
+               globals.true_block_size=0;
        
-       get_rc_name(rc_name);
-
-       rc=fopen(rc_name, "r");
-       if (rc)
-       {
-               fread(&globals, sizeof(tx_global), 1, rc);
-               fclose(rc);
+               strcpy(globals.tables_filename, "");
+               strcpy(globals.record_filename, "tX_record.wav");
+               strcpy(globals.file_editor, "");
        }
 
        /* i'll have to keep these as they're in the code
@@ -117,12 +132,16 @@ void store_globals()
        char rc_name[PATH_MAX]="";
        FILE *rc;
        
-       get_rc_name(rc_name);
-
-       rc=fopen(rc_name, "w");
-       if (rc)
+       if (globals.store_globals)
        {
-               fwrite(&globals, sizeof(tx_global), 1, rc);
-               fclose(rc);
+
+               get_rc_name(rc_name);
+
+               rc=fopen(rc_name, "w");
+               if (rc)
+               {
+                       fwrite(&globals, sizeof(tx_global), 1, rc);
+                       fclose(rc);
+               }
        }       
 }
index 3acf18bfcb54719cf664da4720b6c9b88c7da19e..f2351aed166d6bcdbb5f0af27ba146eacd39eef1 100644 (file)
@@ -52,6 +52,10 @@ typedef struct {
        char    xinput_device[256]; // If your device's name is longer than that
                                    // you are insane and you simply don't deserve
                                    // running terminatorX ;) (said the guy who invented 8+3)                                                               
+       int     store_globals;          // if it should store the globals vals on exit
+       char    *startup_set;   
+       char    *alternate_rc;          // a diferent set of stored globals to load
+       int     no_gui;                 // run without any gui
        
        int     update_idle;
        
index 5885894a99f87318e366a4550279a0e51bf2aa94..dcf550ae44792f7a811eb61663f1e1ae0c84d694 100644 (file)
@@ -314,7 +314,10 @@ void load_tt_part(char * buffer)
        }
        else
        {
-               tx_note("Failed to access file.");
+               strcpy(idbuff, "Failed to access file: \"");    // I'm stealing the unrelated sting for a temp :)
+               strcat(idbuff, globals.tables_filename);
+               strcat(idbuff, "\"");
+               tx_note(idbuff);
        }
 }
 
@@ -1152,12 +1155,15 @@ void tx_note(const char *message)
        
        btn = gtk_button_new_with_label("Ok");
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mbox)->action_area), btn, TRUE, TRUE, 0);
-       gtk_widget_show(btn);
        
        gtk_signal_connect(GTK_OBJECT(btn), "clicked", GtkSignalFunc(note_destroy), mbox);
 
        gtk_window_set_default_size(win, 200, 100);
        gtk_window_set_position(win, GTK_WIN_POS_CENTER_ALWAYS);        
+
+       GTK_WIDGET_SET_FLAGS (btn, GTK_CAN_DEFAULT);
+       gtk_widget_grab_default(btn);
+       gtk_widget_show(btn);
        gtk_widget_show(mbox);
 
 //     gtk_widget_unrealize(main_window);