[Gpredict-svn] SF.net SVN: gpredict:[763] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <aa...@us...> - 2011-02-15 02:02:49
|
Revision: 763
http://gpredict.svn.sourceforge.net/gpredict/?rev=763&view=rev
Author: aa1vs
Date: 2011-02-15 02:02:42 +0000 (Tue, 15 Feb 2011)
Log Message:
-----------
List a satellite under the available column or the selected column but not both.
Modified Paths:
--------------
trunk/ChangeLog
trunk/NEWS
trunk/src/gtk-sat-selector.c
trunk/src/gtk-sat-selector.h
trunk/src/mod-cfg.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-02-13 14:50:46 UTC (rev 762)
+++ trunk/ChangeLog 2011-02-15 02:02:42 UTC (rev 763)
@@ -1,3 +1,10 @@
+2011-02-14 Charles Suprin <hamaa1vs at gmail.com>
+
+ * src/gtk-sat-selector.c
+ * src/gtk-sat-selector.h
+ * src/mod-cfg.c
+ List a satellite under the available column or the selected column but not both.
+
2011-02-08 Charles Suprin <hamaa1vs at gmail.com>
* src/gtk-sat-selector.c
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2011-02-13 14:50:46 UTC (rev 762)
+++ trunk/NEWS 2011-02-15 02:02:42 UTC (rev 763)
@@ -4,6 +4,7 @@
- Feature Request 3022617: Malaysia's location.
- Automatically refresh the Sky at a glance view every minute.
- Added more checks with hamlib communications.
+- List satellite as available or selected when configuring module.
- Fixed bug 2116691: Leave network connection open.
- Fixed bug 3099314: Rotator Thrashing.
- Fixed bug 2167508: problems in rotator controller.
Modified: trunk/src/gtk-sat-selector.c
===================================================================
--- trunk/src/gtk-sat-selector.c 2011-02-13 14:50:46 UTC (rev 762)
+++ trunk/src/gtk-sat-selector.c 2011-02-15 02:02:42 UTC (rev 763)
@@ -29,7 +29,10 @@
/** \brief Satellite selector.
*
*/
-#include "string.h"
+
+/*needed _gnu_source to have strcasestr defined*/
+#define _GNU_SOURCE
+#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#ifdef HAVE_CONFIG_H
@@ -73,6 +76,7 @@
gpointer column);
static gint cat_file_compare (const gchar *a, const gchar *b);
+static void gtk_sat_selector_mark_engine(GtkSatSelector *selector, gint catnr,gboolean val);
static GtkVBoxClass *parent_class = NULL;
@@ -444,6 +448,7 @@
GTK_SAT_SELECTOR_COL_NAME, sat.nickname,
GTK_SAT_SELECTOR_COL_CATNUM, catnum,
GTK_SAT_SELECTOR_COL_EPOCH, sat.jul_epoch,
+ GTK_SAT_SELECTOR_COL_SELECTED, FALSE,
-1);
g_free (sat.name);
@@ -559,6 +564,7 @@
GTK_SAT_SELECTOR_COL_NAME, sat.nickname,
GTK_SAT_SELECTOR_COL_CATNUM, catnum,
GTK_SAT_SELECTOR_COL_EPOCH, sat.jul_epoch,
+ GTK_SAT_SELECTOR_COL_SELECTED, FALSE,
-1);
g_free (sat.name);
g_free (sat.nickname);
@@ -915,7 +921,7 @@
return( FALSE );
}
-/** \brief Selects satellites whose name contains the substring in entry.
+/** \brief Selects unselected satellites whose name contains the substring in entry.
**/
static gboolean sat_filter_func( GtkTreeModel *model,
GtkTreeIter *iter,
@@ -931,9 +937,55 @@
/*if it is already selected then remove it from the available list*/
if (selected)
return( FALSE);
- if( strcasestr( satname, searchstring ) != NULL )
+ if( strcasestr( satname, searchstring ) != (char *)NULL )
return( TRUE );
else
return( FALSE );
}
+/** \brief Searches through all the models for the given satellite and sets its selected value.
+ \param *selector is the selector that contains the models
+ \param catnr is the catalog numer of satellite.
+ \param val is true or false depending on whether that satellite is selected or not.
+ **/
+static void gtk_sat_selector_mark_engine(GtkSatSelector *selector, gint catnr,gboolean val){
+ gint n, k;
+ gint nummodels, numiters;
+ gint catnumscratch;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ nummodels = g_slist_length(selector->models);
+
+ for (n = 0; n<nummodels; n++) {
+ model = GTK_TREE_MODEL(g_slist_nth_data (selector->models,n));
+ numiters = gtk_tree_model_iter_n_children(model,NULL);
+ for (k = 0; k<numiters; k++){
+ if (G_LIKELY(gtk_tree_model_iter_nth_child(model, &iter,NULL,k))){
+ gtk_tree_model_get (model, &iter, GTK_SAT_SELECTOR_COL_CATNUM, &catnumscratch,-1);
+ if (catnumscratch == catnr) {
+ gtk_list_store_set(GTK_LIST_STORE(model),&iter,GTK_SAT_SELECTOR_COL_SELECTED,val,-1);
+ }
+ }
+
+ }
+
+ }
+}
+
+
+/** \brief Searches the models for the satellite and sets SELECTED to TRUE.
+ \param *selector is the selector that contains the models
+ \param catnr is the catalog numer of satellite.
+**/
+void gtk_sat_selector_mark_selected(GtkSatSelector *selector, gint catnr){
+ gtk_sat_selector_mark_engine ( selector, catnr, TRUE);
+}
+
+/** \brief Searches the models for the satellite and sets SELECTED to FALSE.
+ \param *selector is the selector that contains the models
+ \param catnr is the catalog numer of satellite.
+**/
+void gtk_sat_selector_mark_unselected(GtkSatSelector *selector, gint catnr){
+ gtk_sat_selector_mark_engine ( selector, catnr, FALSE);
+}
Modified: trunk/src/gtk-sat-selector.h
===================================================================
--- trunk/src/gtk-sat-selector.h 2011-02-13 14:50:46 UTC (rev 762)
+++ trunk/src/gtk-sat-selector.h 2011-02-15 02:02:42 UTC (rev 763)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -85,8 +85,6 @@
GtkWidget *tree; /*!< The tree. */
GtkWidget *swin; /*!< Scrolled window. */
guint flags; /*!< Column visibility flags. */
- GSList *selection; /*!< List of selected satellites. FIXME: remove */
- gulong handler_id; /*!< Toggle signale handler ID (FIXME): remove. */
GtkWidget *groups; /*!< Combo box for selecting satellite group. */
GtkWidget *search; /*!< Text entry for searching. */
@@ -106,6 +104,8 @@
guint32 gtk_sat_selector_get_flags (GtkSatSelector *selector);
void gtk_sat_selector_get_selected (GtkSatSelector *selector, gint *catnum, gchar **satname, gdouble *epoch);
gdouble gtk_sat_selector_get_latest_epoch (GtkSatSelector *selector);
+void gtk_sat_selector_mark_selected (GtkSatSelector *selector, gint catnum);
+void gtk_sat_selector_mark_unselected (GtkSatSelector *selector, gint catnum);
#ifdef __cplusplus
}
Modified: trunk/src/mod-cfg.c
===================================================================
--- trunk/src/mod-cfg.c 2011-02-13 14:50:46 UTC (rev 762)
+++ trunk/src/mod-cfg.c 2011-02-15 02:02:42 UTC (rev 763)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2010 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -64,7 +64,7 @@
static void edit_advanced_settings (GtkDialog *parent, GKeyFile *cfgdata);
-static GtkWidget *create_selected_sats_list (GKeyFile *cfgdata, gboolean new);
+static GtkWidget *create_selected_sats_list (GKeyFile *cfgdata, gboolean new, GtkSatSelector *selector);
static void add_selected_sat (GtkListStore *store, gint catnum);
static void sat_activated_cb (GtkSatSelector *selector, gint catnr, gpointer data);
@@ -555,7 +555,7 @@
G_CALLBACK (sat_activated_cb), NULL);
/* list of selected satellites */
- satlist = create_selected_sats_list (cfgdata, new);
+ satlist = create_selected_sats_list (cfgdata, new, GTK_SAT_SELECTOR(selector));
swin = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (swin), satlist);
@@ -566,7 +566,7 @@
g_signal_connect (addbut, "clicked", G_CALLBACK (addbut_clicked_cb), selector);
delbut = gpredict_hstock_button (GTK_STOCK_GO_BACK, NULL,
_("Remove satellite from the list of selected satellites."));
- g_signal_connect (delbut, "clicked", G_CALLBACK (delbut_clicked_cb), NULL);
+ g_signal_connect (delbut, "clicked", G_CALLBACK (delbut_clicked_cb), selector);
/* quick sat selecotr tutorial label */
label = gtk_label_new (NULL);
@@ -599,7 +599,7 @@
* \returns A newly created GtkTreeView widget.
*
*/
-static GtkWidget *create_selected_sats_list (GKeyFile *cfgdata, gboolean new)
+static GtkWidget *create_selected_sats_list (GKeyFile *cfgdata, gboolean new, GtkSatSelector *selector)
{
GtkWidget *satlist;
GtkCellRenderer *renderer;
@@ -637,7 +637,7 @@
/* "row-activated" signal is used to catch double click events, which means
a satellite has been selected. This will cause the satellite to be deleted */
g_signal_connect (GTK_TREE_VIEW (satlist), "row-activated",
- G_CALLBACK(row_activated_cb), NULL);
+ G_CALLBACK(row_activated_cb), selector);
/* create the model */
store = gtk_list_store_new (GTK_SAT_SELECTOR_COL_NUM,
@@ -686,6 +686,7 @@
else {
for (i = 0; i < length; i++) {
add_selected_sat (store, sats[i]);
+ gtk_sat_selector_mark_selected(selector, sats[i]);
}
g_free (sats);
}
@@ -1136,7 +1137,8 @@
/* Add satellite to selected list */
store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (satlist)));
add_selected_sat (store, catnr);
-
+ /*tell the sat_selector it can hide that satellite */
+ gtk_sat_selector_mark_selected (selector, catnr);
}
@@ -1187,13 +1189,17 @@
GtkTreeModel *model;
GtkTreeIter iter;
gboolean haveselection = FALSE; /* this flag is set to TRUE if there is a selection */
+ gint catnr;
+ GtkSatSelector *selector = GTK_SAT_SELECTOR(data);
-
/* get the selected row in the treeview */
selection = gtk_tree_view_get_selection (view);
haveselection = gtk_tree_selection_get_selected (selection, &model, &iter);
if (haveselection) {
+ gtk_tree_model_get (model, &iter, GTK_SAT_SELECTOR_COL_CATNUM, &catnr, -1);
+ /*tell the sat_selector it can show that satellite again*/
+ gtk_sat_selector_mark_unselected ( selector, catnr);
gtk_list_store_remove (GTK_LIST_STORE(model), &iter);
}
}
@@ -1218,6 +1224,8 @@
/* Add satellite to selected list */
store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (satlist)));
add_selected_sat (store, catnum);
+ /*tell the sat_selector to hide that satellite */
+ gtk_sat_selector_mark_selected (selector,catnum);
}
}
@@ -1233,6 +1241,7 @@
GtkTreeModel *model;
GtkTreeIter iter;
gboolean haveselection = FALSE; /* this flag is set to TRUE if there is a selection */
+ gint catnr;
/* get the selected row in the treeview */
@@ -1240,6 +1249,9 @@
haveselection = gtk_tree_selection_get_selected (selection, &model, &iter);
if (haveselection) {
+ gtk_tree_model_get (model, &iter, GTK_SAT_SELECTOR_COL_CATNUM, &catnr, -1);
+ /*tell the sat_selector it can show that satellite again*/
+ gtk_sat_selector_mark_unselected ( selector, catnr);
gtk_list_store_remove (GTK_LIST_STORE(model), &iter);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|