]> err.no Git - mapper/commitdiff
Grey out Route menu entries if we have no route.
authorKaj-Michael Lang <milang@tal.org>
Thu, 10 Apr 2008 14:22:13 +0000 (17:22 +0300)
committerKaj-Michael Lang <milang@tal.org>
Thu, 10 Apr 2008 14:22:13 +0000 (17:22 +0300)
src/cb.c

index 64b5ffd759baa8861050dd638d2dc1d3daf8c2e1..cde5bc104b337af5be2242813c3abd3394bc1758 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
 #include "map-repo.h"
 #include "config-gconf.h"
 
-static void
+static gboolean
 path_tree_view_update_store(GtkWidget *tree_view, Path *path)
 {
 GtkListStore *store;
 
+g_assert(tree_view);
+g_assert(path);
+
 store=path_generate_store(path);
-if (store!=NULL) {
-       gtk_tree_view_set_model(tree_view, store);
-       g_object_unref(G_OBJECT(store));
-}
+if (!store)
+       return FALSE;
+
+gtk_tree_view_set_model(tree_view, store);
+g_object_unref(G_OBJECT(store));
+return TRUE;
 }
 
+/***********************
+  Route menu callbacks 
+ ***********************/
 gboolean 
 menu_cb_route_download(GtkAction * action)
 {
 route_download(NULL);
-path_tree_view_update_store(route_tree_view, _route);
+route_menu_set_sensitive(path_tree_view_update_store(route_tree_view, _route));
 return TRUE;
 }
 
 gboolean 
-menu_cb_route_open(GtkAction * action)
+menu_cb_route_open(GtkAction *action)
 {
-GtkListStore *store;
-
 route_open_file();
-path_tree_view_update_store(route_tree_view, _route);
+route_menu_set_sensitive(path_tree_view_update_store(route_tree_view, _route));
+return TRUE;
+}
+
+gboolean 
+menu_cb_route_save(GtkAction * action)
+{
+route_save();
 return TRUE;
 }
 
@@ -123,9 +136,13 @@ menu_cb_route_clear(GtkAction * action)
 {
 route_clear();
 gtk_tree_view_set_model(route_tree_view, NULL);
+route_menu_set_sensitive(FALSE);
 return TRUE;
 }
 
+/***********************
+  Track menu callbacks 
+ ***********************/
 gboolean 
 menu_cb_track_open(GtkAction * action)
 {
@@ -175,13 +192,6 @@ track_show_distance_from_first();
 return TRUE;
 }
 
-gboolean 
-menu_cb_route_save(GtkAction * action)
-{
-route_save();
-return TRUE;
-}
-
 gboolean 
 menu_cb_track_clear(GtkAction * action)
 {
@@ -197,6 +207,9 @@ filter_dialog(_window);
 return TRUE;
 }
 
+/***********************
+  Other menu callbacks 
+ ***********************/
 gboolean 
 menu_cb_show_tracks(GtkAction *action)
 {
@@ -453,7 +466,7 @@ if ((_enable_gps = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) {
                gps_conn_set_state(_gps, RCVR_DOWN);
                gps_connect_now(_gps);
        } else {
-               popup_error(_window, _("Cannot enable GPS until a GPS Receiver has been configured in the GPS Settings dialog."));
+               MACRO_BANNER_SHOW_INFO(_window, _("Cannot enable GPS until a GPS Receiver has been configured in the GPS Settings dialog."));
                set_action_activate("gps_enabled", FALSE);
        }
 } else {
@@ -494,10 +507,11 @@ return TRUE;
 gboolean 
 menu_cb_settings(GtkAction * action)
 {
-settings_dialog();
-MACRO_RECALC_FOCUS_BASE(_center_ratio);
-MACRO_RECALC_FOCUS_SIZE(_center_ratio);
-map_force_redraw();
+if (settings_dialog()) {
+       MACRO_RECALC_FOCUS_BASE(_center_ratio);
+       MACRO_RECALC_FOCUS_SIZE(_center_ratio);
+       map_force_redraw();
+}
 return TRUE;
 }
 
@@ -512,11 +526,6 @@ if (settings_dialog_gps(_gps)) {
                gps_connect_now(_gps);
        }
 }
-#if 0
-MACRO_RECALC_FOCUS_BASE(_center_ratio);
-MACRO_RECALC_FOCUS_SIZE(_center_ratio);
-map_force_redraw();
-#endif
 
 return TRUE;
 }
@@ -550,7 +559,6 @@ osm_import_dialog(_window);
 return TRUE;
 }
 
-
 gboolean 
 menu_cb_help(GtkAction * action)
 {