]> err.no Git - mapper/commitdiff
Add menu entry to show/hide toolbar for larger map view
authorKaj-Michael Lang <milang@tal.org>
Thu, 10 Apr 2008 15:19:57 +0000 (18:19 +0300)
committerKaj-Michael Lang <milang@tal.org>
Thu, 10 Apr 2008 15:19:57 +0000 (18:19 +0300)
src/cb.c
src/cb.h
src/ui-common.c
src/ui-common.h

index cde5bc104b337af5be2242813c3abd3394bc1758..7677474a89e79d656b4386562869aef4c092163b 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -458,6 +458,17 @@ gtk_idle_add((GSourceFunc) window_present, NULL);
 return TRUE;
 }
 
+gboolean
+menu_cb_view_toolbar(GtkAction *action)
+{
+if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
+       gtk_widget_show(_toolbar);
+else
+       gtk_widget_hide(_toolbar);
+
+return TRUE;
+}
+
 gboolean 
 menu_cb_enable_gps(GtkAction * action)
 {
index 01cc1d672cc6982261375ec133c12c828bf7508f..0787751447e2f41e09bf9ab47a7c1afcfa6dfe5f 100644 (file)
--- a/src/cb.h
+++ b/src/cb.h
@@ -43,6 +43,7 @@ gboolean cb_zoomin(GtkAction * action);
 gboolean cb_zoomout(GtkAction * action);
 gboolean cb_fullscreen(GtkAction * action);
 gboolean cb_fullscreen_click(GtkAction * action);
+gboolean menu_cb_view_toolbar(GtkAction *action);
 gboolean menu_cb_show_scale(GtkAction * action);
 gboolean menu_cb_show_routes(GtkAction * action);
 gboolean menu_cb_show_tracks(GtkAction * action);
index f065fc90bda057218fed5bea32bcf50e2a621742..594087c8cb9549d18851ad73cefcc7f58ca3a8e6 100644 (file)
@@ -50,7 +50,6 @@
 #define WINDOW_SIZE_Y 480
 
 static GtkWidget *menu_bar;
-static GtkWidget *toolbar;
 GtkWidget *_fix_banner=NULL;
 
 static GtkActionGroup *actions;
@@ -160,6 +159,8 @@ static const gchar *mapper_ui =
 "      <separator/>"
 "      <menuitem action='view_fullscreen'/>"
 "      <separator/>"
+"      <menuitem action='view_toolbar'/>"
+"      <separator/>"
 "      <menu action='view_items'>"
 "       <menuitem action='view_scale'/>"
 "       <menuitem action='view_route'/>"
@@ -301,6 +302,7 @@ static GtkToggleActionEntry ui_toggle_entries[] = {
 #else
        {"view_fullscreen", NULL, N_("Fullscreen"), "F11", NULL, G_CALLBACK(cb_fullscreen), FALSE},
 #endif
+       {"view_toolbar", NULL, N_("Toolbar"), NULL, NULL, G_CALLBACK(menu_cb_view_toolbar), FALSE},
        {"view_scale", NULL, N_("Scale"), NULL, NULL, G_CALLBACK(menu_cb_show_scale), TRUE},
        {"view_route", NULL, N_("Route"), NULL, NULL, G_CALLBACK(menu_cb_show_routes), TRUE},
        {"view_track", NULL, N_("Track"), NULL, NULL, G_CALLBACK(menu_cb_show_tracks), TRUE},
@@ -629,8 +631,8 @@ if (!gtk_ui_manager_add_ui_from_string (ui, mapper_ui, -1, &error)) {
 menu_bar = gtk_ui_manager_get_widget (ui, "/MenuBar");
 g_assert(menu_bar);
 
-toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar");
-g_assert(toolbar);
+_toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar");
+g_assert(_toolbar);
 
 /* Toolbar progress item */
 item=gtk_tool_item_new();
@@ -639,7 +641,7 @@ gtk_tool_item_set_expand(item, TRUE);
 gtk_progress_bar_set_ellipsize(_progress_item, PANGO_ELLIPSIZE_END);
 gtk_progress_bar_set_pulse_step(_progress_item, 0.2);
 gtk_container_add(item, _progress_item);
-gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
+gtk_toolbar_insert(GTK_TOOLBAR(_toolbar), item, -1);
 
 /* Notebook with different views */
 notebook = gtk_notebook_new();
@@ -672,12 +674,12 @@ gtk_box_pack_start(GTK_BOX(vbox_main), GTK_WIDGET(info_banner.container), FALSE,
        gtk_container_foreach(GTK_CONTAINER(menu_bar), (GtkCallback)gtk_widget_reparent, hmenu);
        hildon_window_set_menu(HILDON_WINDOW(_window), hmenu);
 }
-hildon_window_add_toolbar(_window, GTK_TOOLBAR(toolbar));
-gtk_widget_show_all(GTK_WIDGET(toolbar));
+hildon_window_add_toolbar(_window, GTK_TOOLBAR(_toolbar));
+gtk_widget_show_all(GTK_WIDGET(_toolbar));
 #else
 _status_bar = gtk_statusbar_new();
 gtk_box_pack_start(GTK_BOX(vbox_main), menu_bar, FALSE, FALSE, 0);
-gtk_box_pack_start(GTK_BOX(vbox_main), toolbar, FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(vbox_main), _toolbar, FALSE, FALSE, 0);
 gtk_box_pack_start(GTK_BOX(vbox_main), notebook, TRUE, TRUE, 0);
 gtk_box_pack_start(GTK_BOX(vbox_main), info_banner.container, FALSE, FALSE, 0);
 gtk_box_pack_start(GTK_BOX(vbox_main), _status_bar, FALSE, FALSE, 0);
@@ -774,6 +776,8 @@ set_action_sensitive("autocenter_lead", _enable_gps);
 
 set_action_activate("gps_information", _gps_info);
 
+set_action_activate("view_toolbar", TRUE);
+
 set_action_activate("view_scale", _show_scale);
 set_action_activate("view_vector", _show_velvec);
 set_action_activate("view_poi", _show_poi);
index 88e3b080a1adfd6db6ded592683ef3edb79da5ed..6a3cc32a075f39a61ea066670e23252900375bbf 100644 (file)
@@ -27,6 +27,8 @@
 GtkWidget *_window;
 GtkWidget *_gps_widget;
 
+GtkWidget *_toolbar;
+
 /* GPS Tab widget */
 GtkWidget *_gps_sat_view;