Addressing gtk+ 2 deprecations.
[terminatorX.git] / src / tX_dialog.cc
index 87d8dd7baba785692b62dc2b885922d6fc3d8e92..128a39b2dcff532cb953d6eafbffd002e87347e2 100644 (file)
@@ -81,18 +81,18 @@ void apply_options(GtkWidget *dialog) {
        globals.use_realtime=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "use_realtime")));
        
        /* Audio: OSS */
-       strcpy(globals.oss_device, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_audio_device"))->entry)));
+       strcpy(globals.oss_device, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "oss_audio_device"))));
        globals.oss_buff_no=(int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "oss_buffers")));
        globals.oss_buff_size=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "oss_buffersize")));
-       globals.oss_samplerate=atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_samplerate"))->entry)));
+       globals.oss_samplerate=atoi(gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "oss_samplerate"))));
        
        /* Audio: ALSA */
-       strcpy(globals.alsa_device_id, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_audio_device"))->entry)));
+       strcpy(globals.alsa_device_id, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "alsa_audio_device"))));
        globals.alsa_buffer_time=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "alsa_buffer_time")));
        globals.alsa_buffer_time*=1000;
        globals.alsa_period_time=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "alsa_period_time")));
        globals.alsa_period_time*=1000;
-       globals.alsa_samplerate=atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate"))->entry)));        
+       globals.alsa_samplerate=atoi(gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "alsa_samplerate")))); 
        globals.alsa_free_hwstats=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "alsa_free_hwstats")));
        
        /* TODO: JACK
@@ -100,7 +100,7 @@ void apply_options(GtkWidget *dialog) {
        
        /* Input */
        globals.xinput_enable=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "xinput_enable")))==TRUE);
-       strcpy(globals.xinput_device, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "xinput_device"))->entry)));
+       strcpy(globals.xinput_device, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "xinput_device"))));
        globals.mouse_speed=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "mouse_speed")));
        globals.sense_cycles=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "stop_sense_cycles")));
        globals.vtt_inertia=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "vtt_inertia")));
@@ -109,8 +109,9 @@ void apply_options(GtkWidget *dialog) {
        globals.show_nag=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "startup_nagbox")))==TRUE);
        globals.tooltips=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "mainwin_tooltips")))==TRUE);
        globals.filename_length=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(dialog, "filename_length")));
-       if (globals.tooltips) gtk_tooltips_enable(gui_tooltips);
-       else gtk_tooltips_disable(gui_tooltips);
+//     if (globals.tooltips) gtk_tooltips_enable(gui_tooltips);
+//     else gtk_tooltips_disable(gui_tooltips);
+//     TODO: Disable Tooltips no longer possible?
 
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_only")))) {
                globals.button_type=BUTTON_TYPE_TEXT;
@@ -209,16 +210,9 @@ void apply_options(GtkWidget *dialog) {
        add_widget_dyn(label);
 
 #ifdef USE_ALSA
-static GList *alsa_devices=NULL;
-
-GList *get_alsa_device_list() {
-       if (alsa_devices) {
-               return alsa_devices;
-       }
-       
+void append_alsa_device_list(GtkComboBoxText *combo) {
        FILE *file;
        char buffer[PATH_MAX+1];
-       alsa_devices=NULL;
        
        if ((file = fopen("/proc/asound/pcm", "r"))) {
                while(fgets(buffer, PATH_MAX, file)) {
@@ -234,49 +228,36 @@ GList *get_alsa_device_list() {
                                sscanf(buffer, "%i-%i: %1024c", &card, &device, foo);
                                sprintf(tmp, "hw:%i,%i# %s", card, device, foo);
                                
-                               alsa_devices=g_list_append (alsa_devices, strdup(tmp));
+                               gtk_combo_box_text_append_text(combo, strdup(tmp));
                        }
                }
                fclose(file);
        }
-       
-       return alsa_devices;
 }
 #else
-GList *get_alsa_device_list() {
-       return NULL;
+void append_alsa_device_list(GtkComboBoxText *combo) {
 }
 #endif
 
 
 #ifdef USE_OSS
-static GList *oss_devices=NULL;
-
 int oss_select_dsp_only(const struct dirent *entry){
        return (strstr(entry->d_name, "dsp")!=0);
 }
 
-GList *get_oss_device_list() {
-       if (oss_devices) {
-               return oss_devices;
-       }
-               
+void append_oss_device_list(GtkComboBoxText *combo) {
     struct dirent **namelist;
     int n,i;
     n = scandir("/dev", &namelist, oss_select_dsp_only, alphasort);
     
-       oss_devices=NULL;
-       
     if (n>0) {
        for (i=0; i<n; i++) {
                        char buffer[256];
             sprintf(buffer, "/dev/%s", namelist[i]->d_name);
             free(namelist[i]);
-                       oss_devices=g_list_append (oss_devices, strdup(buffer));
+            gtk_combo_box_text_append_text(combo, strdup(buffer));
                }
        }
-       
-       return oss_devices;
 }
 #endif
 
@@ -328,8 +309,6 @@ char *colors[MAX_COLORS]={ NULL };
 
 
 void init_tx_options(GtkWidget *dialog) {
-       GtkTooltips *tooltips=GTK_TOOLTIPS(lookup_widget(dialog, "tooltips"));
-       
        if (colors[0]==NULL) {
                for (int i=0; i<MAX_COLORS; i++) {
                        colors[i]=new char[8];
@@ -376,57 +355,52 @@ void init_tx_options(GtkWidget *dialog) {
 #endif 
        
        /* Audio: OSS */
-       GList *oss_list=get_oss_device_list();
-       if (oss_list) {
-               gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "oss_audio_device")), oss_list);
-       }
-       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_audio_device"))->entry), globals.oss_device);
+       append_oss_device_list(GTK_COMBO_BOX_TEXT(lookup_widget(dialog, "oss_audio_device")));
+       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO_BOX(lookup_widget(dialog, "oss_audio_device"))->entry), globals.oss_device);
 
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "oss_buffers")), globals.oss_buff_no);
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "oss_buffersize")), globals.oss_buff_size);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "oss_buffersize"), "Set the size of the kernel level audio buffers. On slower systems you might have to increase this value (if you hear \"clicks\" or drop-outs). Lower values mean lower latency though.", NULL);        
-       gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "oss_samplerate")), get_sampling_rates_list());
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "oss_buffersize"), "Set the size of the kernel level audio buffers. On slower systems you might have to increase this value (if you hear \"clicks\" or drop-outs). Lower values mean lower latency though."); 
+       gtk_combo_set_popdown_strings(GTK_COMBO_BOX(lookup_widget(dialog, "oss_samplerate")), get_sampling_rates_list());
        char tmp[64];
        sprintf(tmp, "%i", globals.oss_samplerate);
-       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_samplerate"))->entry), tmp);
+       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO_BOX(lookup_widget(dialog, "oss_samplerate"))->entry), tmp);
        
        
        /* Audio: ALSA */
-       GtkCombo *combo=GTK_COMBO(lookup_widget(dialog, "alsa_audio_device"));
+       GtkCombo *combo=GTK_COMBO_BOX(lookup_widget(dialog, "alsa_audio_device"));
        GList *alsa_list=get_alsa_device_list();
        last_alsa_device_widget=NULL;
        alsa_device_entry=combo->entry;
        
-       if (alsa_list) {
-               gtk_combo_set_popdown_strings(combo, get_alsa_device_list());
-       }
+       append_alsa_device_list(GTK_COMBOBOX_TEXT(combo));
        gtk_entry_set_text(GTK_ENTRY(combo->entry), globals.alsa_device_id);
 
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "alsa_buffer_time")), globals.alsa_buffer_time/1000);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "alsa_buffer_time"), "Sets the size of the ALSA ring buffer. On slower systems you might have to increase this value (if you hear \"clicks\" or drop-outs). Lower values mean lower latency though.", NULL);       
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "alsa_buffer_time"), "Sets the size of the ALSA ring buffer. On slower systems you might have to increase this value (if you hear \"clicks\" or drop-outs). Lower values mean lower latency though.");        
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "alsa_period_time")), globals.alsa_period_time/1000);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "alsa_period_time"), "The ALSA period time determines how much audio data will be written to the device at once. It is recommended to set this value to a half or a third of the ALSA buffer time.", NULL);        
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "alsa_period_time"), "The ALSA period time determines how much audio data will be written to the device at once. It is recommended to set this value to a half or a third of the ALSA buffer time."); 
 
-       gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate")), get_sampling_rates_list());
+       gtk_combo_set_popdown_strings(GTK_COMBO_BOX(lookup_widget(dialog, "alsa_samplerate")), get_sampling_rates_list());
        sprintf(tmp, "%i", globals.alsa_samplerate);
-       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate"))->entry), tmp);
+       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO_BOX(lookup_widget(dialog, "alsa_samplerate"))->entry), tmp);
        
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "alsa_free_hwstats")), globals.alsa_free_hwstats);
        
        /* Input */
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "xinput_enable")), globals.xinput_enable);
        
-       gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "xinput_device")), get_xinput_devices_list());
-       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "xinput_device"))->entry), globals.xinput_device);
+       gtk_combo_set_popdown_strings(GTK_COMBO_BOX(lookup_widget(dialog, "xinput_device")), get_xinput_devices_list());
+       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO_BOX(lookup_widget(dialog, "xinput_device"))->entry), globals.xinput_device);
 
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "mouse_speed")), globals.mouse_speed);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "mouse_speed"), "The speed of your mouse in scratch mode. Use negative values to invert motion.", NULL);
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "mouse_speed"), "The speed of your mouse in scratch mode. Use negative values to invert motion.");
        
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "stop_sense_cycles")), globals.sense_cycles);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "stop_sense_cycles"),"If there is no \"motion-event\" for x cycles, where x is the number of cycles you select here, terminatorX assumes mouse motion has stopped. For smaller buffer sizes (=> shorter cycle times) you might have to increase this value", NULL);        
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "stop_sense_cycles"),"If there is no \"motion-event\" for x cycles, where x is the number of cycles you select here, terminatorX assumes mouse motion has stopped. For smaller buffer sizes (=> shorter cycle times) you might have to increase this value"); 
 
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "vtt_inertia")), globals.vtt_inertia);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "vtt_inertia"),"This value defines how fast the turntables will adapt to the speed input - the higher this value, the longer it will take the turntable to actually reach the target speed.", NULL);       
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "vtt_inertia"),"This value defines how fast the turntables will adapt to the speed input - the higher this value, the longer it will take the turntable to actually reach the target speed.");        
 
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "filename_length")), globals.filename_length);
 
@@ -449,11 +423,11 @@ void init_tx_options(GtkWidget *dialog) {
        }
        
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "update_delay")), globals.update_delay);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "update_delay"), "How often to update the slow widgets.", NULL);   
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "update_delay"), "How often to update the slow widgets.");    
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "update_idle")), globals.update_idle);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "update_idle"), "The update thread will idle for the selcted amount of milliseconds. If you want to have a more responsive display update reduce this value - if you have performance problems increase this value.", NULL);       
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "update_idle"), "The update thread will idle for the selcted amount of milliseconds. If you want to have a more responsive display update reduce this value - if you have performance problems increase this value.");        
        gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "vumeter_decay")), globals.flash_response);
-       gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "vumeter_decay"), "Defines how fast the maximum values of the VU meters should be decayed.", NULL);        
+       gtk_widget_set_tooltip_text(lookup_widget(dialog, "vumeter_decay"), "Defines how fast the maximum values of the VU meters should be decayed."); 
 
        /* Audio Colors */
        int ctr=0;
@@ -777,8 +751,8 @@ void show_about(int nag)
                gtk_container_add(GTK_CONTAINER(window), box);
                gtk_widget_show(box);
                
-               g_signal_connect(G_OBJECT(btn), "clicked", (GtkSignalFunc) destroy_about, NULL);                
-               g_signal_connect(G_OBJECT(window), "delete-event", (GtkSignalFunc) destroy_about, NULL);                
+               g_signal_connect(G_OBJECT(btn), "clicked", (GCallback) destroy_about, NULL);            
+               g_signal_connect(G_OBJECT(window), "delete-event", (GCallback) destroy_about, NULL);            
        }
        gtk_widget_show(window);        
        tX_set_icon(window);