From 49a01851771d9edc0b10c4f6ab49edfd18e96d81 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 13 Sep 2007 15:21:53 +0300 Subject: [PATCH] Add asserts. Hopefully fix hildon menu to work with ui manager. --- src/ui-common.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/ui-common.c b/src/ui-common.c index 6dcd263..fb9fb25 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -338,6 +338,7 @@ if (map_repos_action_group) { } map_repos_action_group=gtk_action_group_new("map_repos_actions"); +g_assert(map_repos_action_group); gtk_ui_manager_insert_action_group(ui, map_repos_action_group, 0); gtk_ui_manager_ensure_update(ui); @@ -527,7 +528,7 @@ GtkToolItem *item; item=gtk_tool_item_new(); _progress_item=gtk_progress_bar_new(); gtk_container_add(item, _progress_item); -gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); +gtk_toolbar_insert(GTK_TOOLBAR (toolbar), item, -1); } void @@ -649,7 +650,10 @@ gtk_window_set_resizable(GTK_WINDOW(_window), TRUE); gtk_container_set_border_width (GTK_CONTAINER (_window), 0); actions = gtk_action_group_new ("Actions"); +g_assert(actions); + ui = gtk_ui_manager_new (); +g_assert(ui); gtk_action_group_add_actions (actions, ui_entries, n_ui_entries, NULL); gtk_action_group_add_toggle_actions (actions, ui_toggle_entries, n_ui_toggle_entries, NULL); @@ -665,12 +669,16 @@ gtk_window_add_accel_group (GTK_WINDOW(_window), gtk_ui_manager_get_accel_group if (!gtk_ui_manager_add_ui_from_string (ui, mapper_ui, -1, &error)) { g_message ("building menus failed: %s", error->message); - g_error_free (error); + g_error_free(error); + g_assert(FALSE); } /* Menu and Toolbar */ 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_progress_init(); /* Notebook with different views */ @@ -681,9 +689,17 @@ gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE); /* Create and add widgets and supporting data. */ gtk_container_add(GTK_CONTAINER(_window), notebook); hildon_program_set_common_toolbar(_program, toolbar); +{ + GtkMenu *hmenu; + hmenu = GTK_MENU(gtk_menu_new()); -gtk_widget_show_all(notebook); -gtk_widget_show_all(toolbar); + gtk_container_foreach(GTK_CONTAINER(menu_bar), + (GtkCallback) gtk_widget_reparent, hmenu); + + hildon_window_set_menu(HILDON_WINDOW(_window), menu); +} +gtk_widget_show_all(GTK_WIDGET(notebook)); +gtk_widget_show_all(GTK_WIDGET(toolbar)); #else vbox_main = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(_window), vbox_main); @@ -694,7 +710,7 @@ gtk_box_pack_start(GTK_BOX(vbox_main), notebook, TRUE, TRUE, 0); _status_bar = gtk_statusbar_new(); gtk_box_pack_start(GTK_BOX(vbox_main), _status_bar, FALSE, FALSE, 0); -gtk_widget_show_all(vbox_main); +gtk_widget_show_all(GTK_WIDGET(vbox_main)); #endif label = gtk_label_new("Map"); @@ -710,20 +726,20 @@ gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.speed, FALSE, FAL gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.location, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.distance, FALSE, FALSE, 0); -gtk_widget_hide(_progress_item); +gtk_widget_hide(GTK_WIDGET(_progress_item)); mapvbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(mapvbox), info_banner.container, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(mapvbox), hbox, TRUE, TRUE, 0); gtk_notebook_append_page(GTK_WIDGET(notebook), mapvbox, label); -gtk_widget_show_all(mapvbox); +gtk_widget_show_all(GTK_WIDGET(mapvbox)); _gps_widget = gps_info_panel(); gtk_widget_set_size_request(GTK_WIDGET(_gps_widget), 180, 0); -gtk_paned_add1(GTK_BOX(hbox), _gps_widget); +gtk_paned_add1(GTK_PANED(hbox), _gps_widget); _map_widget = gtk_drawing_area_new(); -gtk_paned_add2(GTK_BOX(hbox), _map_widget); +gtk_paned_add2(GTK_PANED(hbox), _map_widget); gps_show_info(); map_poi_init(_map_widget); -- 2.39.5