X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fsettings.c;h=655626d58534fa33696e6745a37a5f6fd08d78bf;hb=23b507a8dbe1b12e1e8a60540ddb057cdc3da555;hp=225d0b70e6b127c7dbc06f2527f7cb1325117676;hpb=a3a887840a34d9ff22b4a5fd09b6405258b8b453;p=tunertool diff --git a/src/settings.c b/src/settings.c index 225d0b7..655626d 100644 --- a/src/settings.c +++ b/src/settings.c @@ -22,6 +22,13 @@ #include "config.h" #endif +#include +#if HILDON == 1 +#include +#include +#include +#endif + #include "settings.h" static GConfClient * client = NULL; @@ -59,7 +66,7 @@ settings_get_display_keepalive (gboolean default_value) } gboolean -settings_set_disp_keepalive (gboolean val) +settings_set_display_keepalive (gboolean val) { return gconf_client_set_bool (get_client (), GCONF_KEY_DISPLAY_KEEPALIVE, val, NULL); } @@ -123,3 +130,98 @@ settings_init (GConfClientNotifyFunc func, gpointer user_data) return TRUE; } + +#if HILDON == 1 +static void +fix_hildon_number_editor (GtkWidget * widget, gpointer data) +{ + if (GTK_IS_EDITABLE (widget)) { + gtk_editable_set_editable (GTK_EDITABLE (widget), FALSE); + g_object_set (G_OBJECT (widget), "can-focus", FALSE, NULL); + } +} + +GtkWidget * +calibration_editor_new (gint min, gint max) +{ + GtkWidget *control; + + control = hildon_number_editor_new (min, max); + /* we don't want that ugly cursor there */ + gtk_container_forall (GTK_CONTAINER (control), + (GtkCallback) fix_hildon_number_editor, NULL); + + return control; +} + +void +settings_dialog_show (GtkWindow * parent) +{ + GtkWidget *dialog; + GtkWidget *vbox; + GtkWidget *caption; + GtkSizeGroup *group; + GtkWidget *editor = NULL; + GtkWidget *control; + GtkComboBox *combo; + gint res; + + dialog = gtk_dialog_new_with_buttons("Settings", + parent, + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT | + GTK_DIALOG_NO_SEPARATOR, + "OK", GTK_RESPONSE_OK, + "Cancel", + GTK_RESPONSE_CANCEL, + NULL, NULL); + + g_signal_connect (G_OBJECT (dialog), "delete_event", G_CALLBACK (gtk_widget_destroy), NULL); + + vbox = gtk_vbox_new (FALSE, HILDON_MARGIN_DEFAULT); + gtk_container_set_border_width (GTK_CONTAINER (vbox), HILDON_MARGIN_DEFAULT); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); + + group = GTK_SIZE_GROUP (gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL)); + + combo = GTK_COMBO_BOX (gtk_combo_box_new_text ()); + gtk_combo_box_append_text (combo, "Simple FFT"); + gtk_combo_box_append_text (combo, "Harmonic Product Spectrum"); + gtk_combo_box_set_active (combo, settings_get_algorithm (DEFAULT_ALGORITHM)); + caption = hildon_caption_new (group, "Pitch detection algorithm:", + GTK_WIDGET (combo), NULL, HILDON_CAPTION_OPTIONAL); + gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0); +#if 0 + editor = calibration_editor_new (CALIB_MIN, CALIB_MAX); + hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (editor), CALIB_DEFAULT); + caption = hildon_caption_new (group, "Calibration:", + editor, NULL, HILDON_CAPTION_OPTIONAL); + gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0); +#endif + + control = gtk_check_button_new (); + caption = hildon_caption_new (group, "Keep display on:", + control, NULL, HILDON_CAPTION_OPTIONAL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (control), + settings_get_display_keepalive (DEFAULT_DISPLAY_KEEPALIVE)); + gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0); + + gtk_widget_show_all (dialog); + res = gtk_dialog_run (GTK_DIALOG (dialog)); + + if (res == GTK_RESPONSE_OK) { + /* save settings */ + g_debug ("algorithm: %d", gtk_combo_box_get_active (combo)); + settings_set_algorithm (gtk_combo_box_get_active (combo)); + if (editor) { + g_debug ("calib: %d", hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (editor))); + settings_set_calibration (hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (editor))); + } + g_debug ("keepalive: %d", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (control))); + settings_set_display_keepalive (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (control))); + } + + gtk_widget_destroy (dialog); +} +#endif +