From: Alexandru C. <cs...@us...> - 2003-02-14 09:06:57
|
Update of /cvsroot/groundstation/grig/src In directory sc8-pr-cvs1:/tmp/cvs-serv20629 Modified Files: Makefile.am Added Files: gnome-hamlib-rot.c gnome-hamlib-rot.h Log Message: Added rotator widget. --- NEW FILE: gnome-hamlib-rot.c --- /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* gnome-hamlib-rot.c: Gtk+/Gnome widget that contains all implemented hamlib rotator controls. See the API documentation for details. Copyright (C) 2002-2003 Alexandru Csete. Authors: Alexandru Csete <cs...@us...> Comments, questions and bugreports should be submitted via http://sourceforge.net/projects/groundstation/ More details can be found at http://groundstation.sourceforge.net/ 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; either version 2 of the License, or (at your option) any later version. 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 */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <gnome.h> #include <math.h> #include "gnome-hamlib-rot.h" #include "defaults.h" static void gnome_hamlib_rot_class_init (GnomeHamlibRotClass *class); static void gnome_hamlib_rot_init (GnomeHamlibRot *ghr); static GtkVBoxClass *parent_class; guint gnome_hamlib_rot_get_type (void) { static guint hamlib_rot_type = 0; if (!hamlib_rot_type) { GtkTypeInfo hamlib_rot_info = { "GnomeHamlibRot", sizeof (GnomeHamlibRot), sizeof (GnomeHamlibRotClass), (GtkClassInitFunc) gnome_hamlib_rot_class_init, (GtkObjectInitFunc) gnome_hamlib_rot_init, (GtkArgSetFunc) NULL, (GtkArgGetFunc) NULL }; hamlib_rot_type = gtk_type_unique (gtk_vbox_get_type (), &hamlib_rot_info); } return hamlib_rot_type; } static void gnome_hamlib_rot_class_init (GnomeHamlibRotClass *class) { parent_class = gtk_type_class (gtk_hbox_get_type ()); } static void gnome_hamlib_rot_destroy(GnomeHamlibRot *ghr) { gint i; g_return_if_fail (ghr != NULL); g_return_if_fail (GNOME_IS_HAMLIB_ROT (ghr)); /* hamlib backend */ if (ghr->rot) { rot_close (ghr->rot); /* close port */ rot_cleanup (ghr->rot); /* if you care about memory */ } } static void gnome_hamlib_rot_init (GnomeHamlibRot *ghr) { gtk_box_set_spacing (GTK_BOX (ghr), 0); gtk_signal_connect(GTK_OBJECT(ghr),"destroy", GTK_SIGNAL_FUNC(gnome_hamlib_rot_destroy), NULL); /* Readback timers */ ghr->timer_id = 0; ghr->timer_val = 0; } /** * gnome_hamlib_rot_new: * @rotid: the hamlib ID of the radio (see 'rotctl --list') * @port: the port the radio is attached to * * Description: Creates a new radio control widget. * * Returns: A new GnomeHamlibRot widget. */ GtkWidget * gnome_hamlib_rot_new (guint rotid, const gchar *port) { GnomeHamlibRot *ghr; ghr = gtk_type_new (gnome_hamlib_rot_get_type ()); /* initialize rot backend */ ghr->rot = rot_init (rotid ? rotid : 1); g_return_val_if_fail (ghr->rot != NULL, NULL); /* set port and open */ strncpy (ghr->rot->state.rotport.pathname, port ? port : "/dev/ttyS0", FILPATHLEN ); retcode = rot_open (ghr->rot); if (retcode != ROT_OK) { rot_cleanup (ghr->rot); return NULL; } return GTK_WIDGET (ghr); } --- NEW FILE: gnome-hamlib-rot.h --- /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* gnome-hamlib-rot.h: Gtk+/Gnome widget that contains all implemented hamlib rotator controls. See the API documentation for details. Copyright (C) 2002-2003 Alexandru Csete. Authors: Alexandru Csete <cs...@us...> Comments, questions and bugreports should be submitted via http://sourceforge.net/projects/groundstation/ More details can be found at http://groundstation.sourceforge.net/ 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; either version 2 of the License, or (at your option) any later version. 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 */ #ifndef GNOME_HAMLIB_ROT_H #define GNOME_HAMLIB_ROT_H 1 #include <gtk/gtkwidget.h> #include <gtk/gtkvbox.h> #include <gdk/gdk.h> #include <libgnome/gnome-defs.h> #include <hamlib/rotator.h> BEGIN_GNOME_DECLS #define GNOME_TYPE_HAMLIB_ROT (gnome_hamlib_rot_get_type ()) #define GNOME_HAMLIB_ROT(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_HAMLIB_ROT, GnomeHamlibRot)) #define GNOME_HAMLIB_ROT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_HAMLIB_ROT, GnomeHamlibRotClass)) #define GNOME_IS_HAMLIB_ROT(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_HAMLIB_ROT)) #define GNOME_IS_HAMLIB_ROT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_HAMLIB_ROT)) typedef struct _GnomeHamlibRot GnomeHamlibRot; typedef struct _GnomeHamlibRotClass GnomeHamlibRotClass; struct _GnomeHamlibRot { GtkVBox vbox; GtkWidget *azcb000_01u,*azcb000_01d; /* Azimuth control button 0.01 up/down */ GtkWidget *azcb000_10u,*azcb000_10d; /* Azimuth control button 0.10 up/down */ GtkWidget *azcb001_00u,*azcb001_00d; /* Azimuth control button 1 up/down */ GtkWidget *azcb010_00u,*azcb010_00d; /* Azimuth control button 10 up/down */ GtkWidget *azcb100_00u,*azcb100_00d; /* Azimuth control button 100 up/down */ GtkWidget *azl100_00,*azl010_00,*azl001_00,*azl000_10,*azl000_01; /* Azimuth labels */ GtkWidget *ell100_00,*ell010_00,*ell001_00,*ell000_10,*ell000_01; /* Elevation labels */ GtkWidget *refbut; /* Reference button */ GtkWidget *reflab; /* Reference label */ GtkWidget *aqnlab; /* label to show acquired value */ ROT *rot; /* Hamlib ROT structure */ azimuth_t az; /* current azimuth setting */ elevation_t el; /* current elevation setting */ azimuth_t refaz; /* reference azimuth value */ elevation_t refel; /* reference elevation value */ guint timer_id; /* The ID of the readback timer */ guint32 timer_val; }; struct _GnomeHamlibRotClass { GtkVBoxClass parent_class; }; guint gnome_hamlib_rot_get_type (void); /* Standard API funtions */ GtkWidget *gnome_hamlib_rot_new (guint rotid, const gchar *port); /* Readback timers */ gint gnome_hamlib_rot_get_timeout (GnomeHamlibRot *ghr); gint gnome_hamlib_rot_set_timeout (GnomeHamlibRot *ghr, guint timeout); END_GNOME_DECLS #endif Index: Makefile.am =================================================================== RCS file: /cvsroot/groundstation/grig/src/Makefile.am,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Makefile.am 18 Aug 2002 21:44:39 -0000 1.24 --- Makefile.am 14 Feb 2003 09:06:53 -0000 1.25 *************** *** 24,28 **** riglist-util.c riglist-util.h \ rotlist-util.c rotlist-util.h \ ! gnome-hamlib-rig.c gnome-hamlib-rig.h grig_CFLAGS = $(EXTRA_GNOME_CFLAGS) $(GCONF_CFLAGS) --- 24,29 ---- riglist-util.c riglist-util.h \ rotlist-util.c rotlist-util.h \ ! gnome-hamlib-rig.c gnome-hamlib-rig.h \ ! gnome-hamlib-rot.c gnome-hamlib-rot.h grig_CFLAGS = $(EXTRA_GNOME_CFLAGS) $(GCONF_CFLAGS) |