diff options
| author | Keith Packard <keithp@keithp.com> | 2009-10-10 11:44:20 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2009-10-10 11:44:20 -0700 | 
| commit | 22856cf8bb0f5e1f37c9b774132d9ef6934526ed (patch) | |
| tree | ce6ffd540fb08f025c8d42fcde280717d2ffcf4b | |
| parent | 2f7603490a169df8f18b565db4fa967832ffc9bd (diff) | |
| parent | e29961fdb2a48874c895829880eadbf13e094c0c (diff) | |
Merge branch 'master' into skytraq
| -rw-r--r-- | ao-tools/ao-view/Makefile.am | 1 | ||||
| -rw-r--r-- | ao-tools/ao-view/aoview.glade | 101 | ||||
| -rw-r--r-- | ao-tools/ao-view/aoview.h | 11 | ||||
| -rw-r--r-- | ao-tools/ao-view/aoview_channel.c | 90 | ||||
| -rw-r--r-- | ao-tools/ao-view/aoview_main.c | 2 | ||||
| -rw-r--r-- | ao-tools/ao-view/aoview_monitor.c | 12 | 
6 files changed, 217 insertions, 0 deletions
| diff --git a/ao-tools/ao-view/Makefile.am b/ao-tools/ao-view/Makefile.am index 7b274a40..7a288417 100644 --- a/ao-tools/ao-view/Makefile.am +++ b/ao-tools/ao-view/Makefile.am @@ -25,6 +25,7 @@ ao_view_SOURCES = \  	aoview_replay.c \  	aoview_label.c \  	aoview_flite.c \ +	aoview_channel.c \  	aoview.h  BUILT_SOURCES = aoview_glade.h diff --git a/ao-tools/ao-view/aoview.glade b/ao-tools/ao-view/aoview.glade index 9a746110..c302ad0d 100644 --- a/ao-tools/ao-view/aoview.glade +++ b/ao-tools/ao-view/aoview.glade @@ -258,6 +258,107 @@                </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>                  <property name="label" translatable="yes">_Help</property> diff --git a/ao-tools/ao-view/aoview.h b/ao-tools/ao-view/aoview.h index 6a4753ac..c582159c 100644 --- a/ao-tools/ao-view/aoview.h +++ b/ao-tools/ao-view/aoview.h @@ -169,6 +169,9 @@ gboolean  aoview_monitor_parse(const char *line);  void +aoview_monitor_set_channel(int channel); + +void  aoview_monitor_reset(void);  struct aoview_serial * @@ -320,4 +323,12 @@ aoview_flite_stop(void);  extern char *aoview_tty; +/* aoview_channel.c */ + +int +aoview_channel_current(void); + +void +aoview_channel_init(GladeXML *xml); +  #endif /* _AOVIEW_H_ */ diff --git a/ao-tools/ao-view/aoview_channel.c b/ao-tools/ao-view/aoview_channel.c new file mode 100644 index 00000000..959173ca --- /dev/null +++ b/ao-tools/ao-view/aoview_channel.c @@ -0,0 +1,90 @@ +/* + * 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); +} diff --git a/ao-tools/ao-view/aoview_main.c b/ao-tools/ao-view/aoview_main.c index 64c1c027..714bee9a 100644 --- a/ao-tools/ao-view/aoview_main.c +++ b/ao-tools/ao-view/aoview_main.c @@ -86,6 +86,8 @@ int main(int argc, char **argv)  	aoview_voice_init(xml); +	aoview_channel_init(xml); +  	aoview_dev_dialog_init(xml);  	aoview_state_init(xml); diff --git a/ao-tools/ao-view/aoview_monitor.c b/ao-tools/ao-view/aoview_monitor.c index 8564014b..48e20320 100644 --- a/ao-tools/ao-view/aoview_monitor.c +++ b/ao-tools/ao-view/aoview_monitor.c @@ -82,6 +82,7 @@ aoview_monitor_parse(const char *input_line)  	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); @@ -214,15 +215,26 @@ aoview_monitor_callback(gpointer user_data,  	}  } +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; | 
