1 /*
2 Gpredict: Real-time satellite tracking and orbit prediction program
3
4 Copyright (C) 2001-2017 Alexandru Csete, OZ9AEC.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, visit http://www.fsf.org/
18 */
19 #ifdef HAVE_CONFIG_H
20 #include <build-config.h>
21 #endif
22 #include <glib/gi18n.h>
23 #include <gtk/gtk.h>
24
25 #include "compat.h"
26 #include "config-keys.h"
27 #include "orbit-tools.h"
28 #include "pass-popup-menu.h"
29 #include "sat-cfg.h"
30 #include "sat-log.h"
31 #include "sat-pass-dialogs.h"
32 #include "sgpsdp/sgp4sdp4.h"
33
34 extern GtkWidget *app;
35
36
37 /**
38 * Show pass details.
39 *
40 * @param menuitem The seelcted menuitem.
41 * @param data Pointer to the toplevel window.
42 *
43 * This function is called when the user selects the "Show details" menu item
44 * in the upcoming passes popup menu.
45 */
show_pass_details(GtkWidget * menuitem,gpointer data)46 static void show_pass_details(GtkWidget * menuitem, gpointer data)
47 {
48 pass_t *pass;
49 qth_t *qth;
50
51 pass = PASS(g_object_get_data(G_OBJECT(menuitem), "pass"));
52 qth = (qth_t *) g_object_get_data(G_OBJECT(menuitem), "qth");
53
54 show_pass(pass->satname, qth, pass, data);
55 }
56
57 /* data = toplevel window */
polar_plot_pass_details(GtkWidget * menuitem,gpointer data)58 static void polar_plot_pass_details(GtkWidget * menuitem, gpointer data)
59 {
60 (void)menuitem;
61 (void)data;
62
63 g_print("FIXME: %s:%s not implemented!\n", __FILE__, __func__);
64 }
65
66 /* data = toplevel window */
azel_plot_pass_details(GtkWidget * menuitem,gpointer data)67 static void azel_plot_pass_details(GtkWidget * menuitem, gpointer data)
68 {
69 (void)menuitem;
70 (void)data;
71
72 g_print("FIXME: %s:%s not implemented!\n", __FILE__, __func__);
73 }
74
pass_popup_menu_exec(qth_t * qth,pass_t * pass,GdkEventButton * event,GtkWidget * toplevel)75 void pass_popup_menu_exec(qth_t * qth, pass_t * pass, GdkEventButton * event,
76 GtkWidget * toplevel)
77 {
78 GtkWidget *menu;
79 GtkWidget *menuitem;
80
81 menu = gtk_menu_new();
82
83 /* pass details */
84 menuitem = gtk_menu_item_new_with_label(_("Show details"));
85 g_object_set_data(G_OBJECT(menuitem), "pass", pass);
86 g_object_set_data(G_OBJECT(menuitem), "qth", qth);
87 g_signal_connect(menuitem, "activate",
88 G_CALLBACK(show_pass_details), toplevel);
89 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
90
91 /* separator */
92 menuitem = gtk_separator_menu_item_new();
93 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
94
95 /* Polar plot pass */
96 menuitem = gtk_menu_item_new_with_label(_("Polar plot"));
97 g_object_set_data(G_OBJECT(menuitem), "pass", pass);
98 g_object_set_data(G_OBJECT(menuitem), "qth", qth);
99 g_signal_connect(menuitem, "activate",
100 G_CALLBACK(polar_plot_pass_details), toplevel);
101 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
102 gtk_widget_set_sensitive(menuitem, FALSE);
103
104 /* Az/El plot pass */
105 menuitem = gtk_menu_item_new_with_label(_("Az/El plot"));
106 g_object_set_data(G_OBJECT(menuitem), "pass", pass);
107 g_object_set_data(G_OBJECT(menuitem), "qth", qth);
108 g_signal_connect(menuitem, "activate",
109 G_CALLBACK(azel_plot_pass_details), toplevel);
110 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
111 gtk_widget_set_sensitive(menuitem, FALSE);
112
113 gtk_widget_show_all(menu);
114
115 /* Note: event can be NULL here when called from view_onPopupMenu;
116 * gdk_event_get_time() accepts a NULL argument */
117 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
118 (event != NULL) ? event->button : 0,
119 gdk_event_get_time((GdkEvent *) event));
120 }
121