From: Kaj-Michael Lang Date: Fri, 19 Oct 2007 12:56:32 +0000 (+0300) Subject: Fixes X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf5c8b8463a5f5d49ec2b04d27312261469de5d4;p=mapper Fixes --- diff --git a/src/ui-common.c b/src/ui-common.c index f7b5308..ced30c0 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -699,19 +699,9 @@ info_banner.location=gtk_label_new(""); info_banner.speed=gtk_label_new(""); info_banner.distance=gtk_label_new(""); -#if 0 -gtk_label_set_max_width_chars(GTK_LABEL(info_banner.speed), 10); -gtk_label_set_width_chars(GTK_LABEL(info_banner.speed), 14); -gtk_label_set_max_width_chars(GTK_LABEL(info_banner.distance), 14); -gtk_label_set_width_chars(GTK_LABEL(info_banner.distance), 18); -gtk_label_set_width_chars(GTK_LABEL(info_banner.location), 35); -#endif - -#if 1 gtk_misc_set_alignment(GTK_MISC(info_banner.location), 0.f, 0.5f); gtk_misc_set_alignment(GTK_MISC(info_banner.speed), 1.f, 0.5f); gtk_misc_set_alignment(GTK_MISC(info_banner.distance), 1.f, 0.5f); -#endif gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.location, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(info_banner.container), info_banner.speed, FALSE, FALSE, 0); @@ -745,8 +735,6 @@ 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); #endif -gtk_widget_show_all(GTK_WIDGET(vbox_main)); - label = gtk_label_new("Map"); hbox = gtk_hpaned_new(); @@ -758,20 +746,46 @@ gtk_paned_add1(GTK_PANED(hbox), _gps_widget); mapvbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(mapvbox), hbox, TRUE, TRUE, 0); ui_notebook.map=gtk_notebook_append_page(notebook, mapvbox, label); -gtk_widget_show_all(GTK_WIDGET(mapvbox)); /* Map widget */ _map_widget = gtk_drawing_area_new(); gtk_paned_add2(GTK_PANED(hbox), _map_widget); gtk_widget_realize(_map_widget); +_scale_context = gtk_widget_get_pango_context(_map_widget); +_scale_layout = pango_layout_new(_scale_context); +_scale_font = pango_font_description_new(); +pango_font_description_set_size(_scale_font, 12 * PANGO_SCALE); +pango_layout_set_font_description(_scale_layout, _scale_font); + +/* Speed limit */ +_speed_limit_gc1 = gdk_gc_new(_map_widget->window); +color.red = 0xffff; +color.green = 0; +color.blue = 0; +gdk_gc_set_rgb_fg_color(_speed_limit_gc1, &color); +color.red = 0; +color.green = 0; +color.blue = 0; +_speed_limit_gc2 = gdk_gc_new(_map_widget->window); +gdk_gc_set_rgb_fg_color(_speed_limit_gc2, &color); +_speed_limit_context = gtk_widget_get_pango_context(_map_widget); +_speed_limit_layout = pango_layout_new(_speed_limit_context); +_speed_limit_fontdesc = pango_font_description_new(); +pango_font_description_set_size(_speed_limit_fontdesc, 64 * PANGO_SCALE); +pango_layout_set_font_description(_speed_limit_layout, _speed_limit_fontdesc); +pango_layout_set_alignment(_speed_limit_layout, PANGO_ALIGN_CENTER); + +map_poi_init(_map_widget); +/* -1: use bit depth of widget->window. */ +_map_pixmap = gdk_pixmap_new(_map_widget->window, BUF_WIDTH_PIXELS, BUF_HEIGHT_PIXELS, -1); + /* GPS Tab */ vbox = gtk_vbox_new(FALSE, 0); label = gtk_label_new("Gps"); _gps_sat_view = gtk_gps_new(GTK_GPS_MODE_SKY, &_gps); gtk_box_pack_start(GTK_BOX(vbox), _gps_sat_view, TRUE, TRUE, 0); ui_notebook.gps=gtk_notebook_append_page(notebook, vbox, label); -gtk_widget_show_all(GTK_WIDGET(vbox)); /* Heading Tab */ vbox = gtk_vbox_new(FALSE, 0); @@ -779,7 +793,6 @@ label = gtk_label_new("Heading"); _tab_compass = gtk_compass_new(&_gps); gtk_box_pack_start(GTK_BOX(vbox), _tab_compass, TRUE, TRUE, 0); ui_notebook.heading=gtk_notebook_append_page(notebook, vbox, label); -gtk_widget_show_all(GTK_WIDGET(vbox)); /* Route Tab */ vbox=gtk_vbox_new(FALSE, 0); @@ -807,58 +820,14 @@ column=gtk_tree_view_column_new_with_attributes(_("Waypoint"), renderer, "text", gtk_tree_view_append_column(GTK_TREE_VIEW(route_tree_view), column); ui_notebook.route=gtk_notebook_append_page(notebook, vbox, label); -gtk_widget_show_all(GTK_WIDGET(vbox)); - -gps_show_info(); -map_poi_init(_map_widget); menu_maps_add_repos(); - menu_init_cmenu(); -/* -1: use bit depth of widget->window. */ -_map_pixmap = gdk_pixmap_new(_map_widget->window, BUF_WIDTH_PIXELS, BUF_HEIGHT_PIXELS, -1); - -/* Connect signals. */ -g_signal_connect(G_OBJECT(_window), "destroy", G_CALLBACK(gtk_main_quit), NULL); -g_signal_connect(G_OBJECT(_window), "key_press_event", G_CALLBACK(window_cb_key_press), NULL); -g_signal_connect(G_OBJECT(_window), "key_release_event", G_CALLBACK(window_cb_key_release), NULL); - -g_signal_connect(G_OBJECT(_map_widget), "configure_event", G_CALLBACK(map_cb_configure), NULL); -g_signal_connect(G_OBJECT(_map_widget), "expose_event", G_CALLBACK(map_cb_expose), NULL); -g_signal_connect(G_OBJECT(_map_widget), "button_press_event", G_CALLBACK(map_cb_button_press), NULL); -g_signal_connect(G_OBJECT(_map_widget), "button_release_event",G_CALLBACK(map_cb_button_release), NULL); -g_signal_connect(G_OBJECT(_map_widget), "scroll_event", G_CALLBACK(map_cb_scroll_event), NULL); - -gtk_widget_add_events(_map_widget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); - -gtk_widget_show_all(hbox); - -/* Cache some pango and GCs for drawing. */ -_scale_context = gtk_widget_get_pango_context(_map_widget); -_scale_layout = pango_layout_new(_scale_context); -_scale_font = pango_font_description_new(); -pango_font_description_set_size(_scale_font, 12 * PANGO_SCALE); -pango_layout_set_font_description(_scale_layout, _scale_font); +/* Initialize our line styles. */ +update_gcs(); -/* Speed limit */ -_speed_limit_gc1 = gdk_gc_new(_map_widget->window); -color.red = 0xffff; -color.green = 0; -color.blue = 0; -gdk_gc_set_rgb_fg_color(_speed_limit_gc1, &color); -color.red = 0; -color.green = 0; -color.blue = 0; -_speed_limit_gc2 = gdk_gc_new(_map_widget->window); -gdk_gc_set_rgb_fg_color(_speed_limit_gc2, &color); -_speed_limit_context = gtk_widget_get_pango_context(_map_widget); -_speed_limit_layout = pango_layout_new(_speed_limit_context); -_speed_limit_fontdesc = pango_font_description_new(); -pango_font_description_set_size(_speed_limit_fontdesc, 64 * PANGO_SCALE); -pango_layout_set_font_description(_speed_limit_layout, _speed_limit_fontdesc); -pango_layout_set_alignment(_speed_limit_layout, PANGO_ALIGN_CENTER); +gps_show_info(); _last_spoken_phrase = g_strdup(""); memset(&_autoroute_data, 0, sizeof(_autoroute_data)); @@ -880,12 +849,26 @@ set_action_activate("view_poi", _show_poi); set_action_activate("view_track", _show_tracks & TRACKS_MASK); set_action_activate("view_route", _show_tracks & ROUTES_MASK); -/* Initialize our line styles. */ -update_gcs(); +/* Connect signals. */ +g_signal_connect(G_OBJECT(_window), "destroy", G_CALLBACK(gtk_main_quit), NULL); +g_signal_connect(G_OBJECT(_window), "key_press_event", G_CALLBACK(window_cb_key_press), NULL); +g_signal_connect(G_OBJECT(_window), "key_release_event", G_CALLBACK(window_cb_key_release), NULL); + +g_signal_connect(G_OBJECT(_map_widget), "configure_event", G_CALLBACK(map_cb_configure), NULL); +g_signal_connect(G_OBJECT(_map_widget), "expose_event", G_CALLBACK(map_cb_expose), NULL); +g_signal_connect(G_OBJECT(_map_widget), "button_press_event", G_CALLBACK(map_cb_button_press), NULL); +g_signal_connect(G_OBJECT(_map_widget), "button_release_event",G_CALLBACK(map_cb_button_release), NULL); +g_signal_connect(G_OBJECT(_map_widget), "scroll_event", G_CALLBACK(map_cb_scroll_event), NULL); + +gtk_widget_add_events(_map_widget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); /* If we have a route, calculate the next point. */ route_find_nearest_point(); +gtk_widget_show_all(GTK_WIDGET(vbox_main)); +gtk_widget_show_all(GTK_WIDGET(_window)); + gtk_idle_add((GSourceFunc)window_present, NULL); }