</child>
</widget>
</child>
+ <child>
+ <widget class="GtkMenuItem" id="channel_menu_item">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Channel</property>
+ <property name="use_underline">True</property>
+ <child>
+ <widget class="GtkMenu" id="menu7">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_0">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 0 (434.550MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 1 (434.650MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 2 (434.750MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 3 (434.850MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 4 (434.950MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 5 (435.050MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 6 (435.150MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 7 (435.250MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 8 (435.350MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioMenuItem" id="channel_9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Channel 9 (435.450MHz)</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">channel_0</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
<child>
<widget class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
--- /dev/null
+/*
+ * Copyright © 2009 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "aoview.h"
+
+
+#define NUM_CHANNEL 10
+
+static GtkRadioMenuItem *channel_item[NUM_CHANNEL];
+
+int
+aoview_channel_current(void)
+{
+ int c;
+
+ for (c = 0; c < NUM_CHANNEL; c++)
+ if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(channel_item[c])))
+ return c;
+ return -1;
+}
+
+static void
+aoview_channel_notify(int channel)
+{
+ if (0 <= channel && channel < NUM_CHANNEL)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(channel_item[channel]), TRUE);
+}
+
+#define ALTOS_CHANNEL_PATH "/apps/aoview/channel"
+
+static void
+aoview_channel_change(GtkWidget *widget, gpointer data)
+{
+ gboolean enabled = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
+ int c = (int) data;
+ GConfClient *gconf_client;
+ GError *error;
+
+ if (enabled) {
+ aoview_monitor_set_channel(c);
+ gconf_client = gconf_client_get_default();
+ gconf_client_set_int(gconf_client, ALTOS_CHANNEL_PATH, c, &error);
+ }
+}
+
+void
+aoview_channel_init(GladeXML *xml)
+{
+ int c;
+ GConfClient *gconf_client;
+
+ for (c = 0; c < NUM_CHANNEL; c++) {
+ char name[32];
+
+ sprintf(name, "channel_%d", c);
+ channel_item[c] = GTK_RADIO_MENU_ITEM(glade_xml_get_widget(xml, name));
+ assert(channel_item[c]);
+ g_signal_connect(G_OBJECT(channel_item[c]), "toggled",
+ G_CALLBACK(aoview_channel_change),
+ (gpointer) c);
+ }
+ gconf_client = gconf_client_get_default();
+ c = 0;
+ if (gconf_client)
+ {
+ GError *error;
+
+ error = NULL;
+ c = gconf_client_get_int(gconf_client,
+ ALTOS_CHANNEL_PATH,
+ &error);
+ if (error)
+ c = 0;
+ }
+ aoview_channel_notify(c);
+}
char line_buf[8192], *line;
struct aodata data;
int tracking_pos;
+ int channel;
/* avoid smashing our input parameter */
strncpy (line_buf, input_line, sizeof (line_buf)-1);
}
}
+void
+aoview_monitor_set_channel(int channel)
+{
+ if (monitor_serial)
+ aoview_serial_printf(monitor_serial, "c r %d\n", channel);
+}
+
gboolean
aoview_monitor_connect(char *tty)
{
+ int channel;
aoview_monitor_disconnect();
monitor_serial = aoview_serial_open(tty);
if (!monitor_serial)
return FALSE;
aoview_table_clear();
aoview_state_reset();
+ channel = aoview_channel_current();
+ if (channel >= 0)
+ aoview_monitor_set_channel(channel);
aoview_serial_set_callback(monitor_serial,
aoview_monitor_callback);
return TRUE;