[Gpredict-svn] SF.net SVN: gpredict:[109] trunk/src/gtk-rot-ctrl.c
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <cs...@us...> - 2008-09-15 23:26:00
|
Revision: 109 http://gpredict.svn.sourceforge.net/gpredict/?rev=109&view=rev Author: csete Date: 2008-09-15 23:26:11 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Implemented loading of rotator configuration. Modified Paths: -------------- trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2008-09-15 23:19:31 UTC (rev 108) +++ trunk/src/gtk-rot-ctrl.c 2008-09-15 23:26:11 UTC (rev 109) @@ -495,7 +495,7 @@ gtk_combo_box_set_active (GTK_COMBO_BOX (ctrl->DevSel), 0); g_signal_connect (ctrl->DevSel, "changed", G_CALLBACK (rot_selected_cb), ctrl); gtk_table_attach_defaults (GTK_TABLE (table), ctrl->DevSel, 1, 2, 0, 1); - + /* Engage button */ lock = gtk_toggle_button_new_with_label (_("Engage")); gtk_widget_set_tooltip_text (lock, _("Engage the selcted rotor device")); @@ -543,6 +543,8 @@ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 2, 3); + /* load initial rotator configuration */ + rot_selected_cb (ctrl->DevSel, ctrl); frame = gtk_frame_new (_("Settings")); gtk_container_add (GTK_CONTAINER (frame), table); @@ -688,9 +690,39 @@ { GtkRotCtrl *ctrl = GTK_ROT_CTRL (data); - /* TODO: update device */ + /* free previous configuration */ + if (ctrl->conf != NULL) { + g_free (ctrl->conf->name); + g_free (ctrl->conf->host); + g_free (ctrl->conf); + } - /* TODO: update ranges */ + ctrl->conf = g_try_new (rotor_conf_t, 1); + if (ctrl->conf == NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Failed to allocate memory for rotator config"), + __FILE__, __LINE__); + return; + } + + /* load new configuration */ + ctrl->conf->name = gtk_combo_box_get_active_text (box); + if (rotor_conf_read (ctrl->conf)) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("Loaded new rotator configuration %s"), + ctrl->conf->name); + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Failed to load rotator configuration %s"), + __FILE__, __LINE__, ctrl->conf->name); + + g_free (ctrl->conf->name); + if (ctrl->conf->host) + g_free (ctrl->conf->host); + g_free (ctrl->conf); + ctrl->conf = NULL; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |