From 63f6795dada6d0d1544afb0828bb6bbfa6b82202 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 10 Apr 2008 17:22:13 +0300 Subject: [PATCH] Grey out Route menu entries if we have no route. --- src/cb.c | 64 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/src/cb.c b/src/cb.c index 64b5ffd..cde5bc1 100644 --- a/src/cb.c +++ b/src/cb.c @@ -65,33 +65,46 @@ #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) { -- 2.39.5