#include "gps-panels.h"
#include "gps-conn.h"
#include "filter.h"
+#include "dialogs.h"
#include "settings-gui.h"
/* Callbacks */
#define GTK_STOCK_INFO GTK_STOCK_PROPERTIES
#endif
+static gboolean mapper_cb_quit(GtkWidget *widget, GdkEvent *event, gpointer data);
+
/**
* Action groups and UI
*/
{"file_settings_colors", NULL, N_("_Colors..."), NULL, NULL, G_CALLBACK(menu_cb_settings_colors) },
{"file_settings_gps", NULL, N_("_Gps..."), NULL, NULL, G_CALLBACK(menu_cb_settings_gps) },
{"file_settings_osm", NULL, N_("_Map info..."), NULL, NULL, G_CALLBACK(menu_cb_settings_osm) },
- {"file_quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", NULL, G_CALLBACK(gtk_main_quit) },
+ {"file_quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", NULL, G_CALLBACK(mapper_cb_quit) },
{"help", NULL, N_("_Help"), NULL, NULL, NULL },
{"help_help", GTK_STOCK_HELP, N_("_Help"), NULL, NULL, G_CALLBACK(menu_cb_help) },
}
#endif
-/**
- * Pop up a modal dialog box with simple error information in it.
- */
-void
-popup_error(GtkWidget * window, const gchar * error)
+static gboolean
+mapper_cb_quit(GtkWidget *widget, GdkEvent *event, gpointer data)
{
-GtkWidget *dialog;
-
-#ifdef WITH_HILDON
-dialog = hildon_note_new_information(GTK_WINDOW(window), error);
-#else
-dialog = gtk_message_dialog_new (GTK_WINDOW(window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO, GTK_BUTTONS_OK, error);
-#endif
-gtk_dialog_run(GTK_DIALOG(dialog));
-gtk_widget_destroy(dialog);
+if (dialog_confirm(_window, _("Are sure you'd like to quit ?"))==TRUE) {
+ gtk_main_quit();
+ return FALSE;
+}
+return TRUE;
}
void
}
/**
- * Call gtk_window_present() on Mapper. This also checks the
- * configuration and brings up the Settings dialog if the GPS Receiver is
- * not set up, the first time it is called.
+ * Call gtk_window_present() on Mapper.
*/
gboolean
window_present()
{
-static gint been_here = 0;
-static gint done_here = 0;
-
-if (!been_here++) {
- /* Set connection state first, to avoid going into this if twice. */
- if (!_gps->io.address && _enable_gps) {
- GtkWidget *confirm;
-
- gtk_window_present(GTK_WINDOW(_window));
- popup_error(_window, _("It looks like this is your first time running Mapper. Press OK to continue."));
-
- if (settings_dialog()) {
- popup_error(_window,
- _("OpenStreetMap.org provides public, free-to-use maps. "
- "You can also download a sample set of repositories from "
- " the internet by using the \"Download...\" button."));
- repoman_dialog();
- if (_curr_repo->type != REPOTYPE_NONE) {
- confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
- _("You will now see a blank screen. You can download"
- " maps using the \"Manage Maps\" menu item in the"
- " \"Maps\" menu. Or, press OK to enable"
- " Auto-Download."));
- if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
- set_action_activate("map_auto_download", FALSE);
- }
- gtk_widget_destroy(confirm);
- }
- } else {
- gtk_main_quit();
- }
- }
-
- done_here++; /* Don't ask... */
-}
-if (done_here) {
- gtk_window_present(GTK_WINDOW(_window));
-
- /* Re-enable any banners that might have been up. */
- {
- GpsConnState old_state = _gps->io.conn;
- gps_conn_set_state(_gps, RCVR_OFF);
- gps_conn_set_state(_gps, old_state);
- }
-}
-
+gtk_window_present(GTK_WINDOW(_window));
return FALSE;
}
#endif
}
+static GtkWidget *
+mapper_window_new(void)
+{
+GtkWidget *window;
+
+#ifdef WITH_HILDON
+_program=HILDON_PROGRAM(hildon_program_get_instance());
+window=GTK_WIDGET(hildon_window_new());
+hildon_program_add_window(_program, HILDON_WINDOW(window));
+#else
+window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+gtk_window_set_title(GTK_WINDOW(window), "Mapper");
+gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
+gtk_widget_set_size_request(GTK_WIDGET(window), WINDOW_SIZE_X, WINDOW_SIZE_Y);
+gtk_window_resize(GTK_WINDOW(window), WINDOW_SIZE_X, WINDOW_SIZE_Y);
+#endif
+
+return window;
+}
+
+/**
+ * Create a tree view inside given container
+ */
+static GtkWidget *
+mapper_tree_view_new(GtkWidget *container)
+{
+GtkWidget *tree_view, *sw;
+tree_view=gtk_tree_view_new();
+sw=gtk_scrolled_window_new(NULL, NULL);
+gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+gtk_container_add(GTK_CONTAINER(sw), tree_view);
+gtk_box_pack_start(container, sw, TRUE, TRUE, 0);
+gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)), GTK_SELECTION_SINGLE);
+gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), TRUE);
+return tree_view;
+}
/**
* Initialize everything required in preparation for calling gtk_main().
GError *error = NULL;
GtkWidget *hbox, *mapvbox, *label, *vbox_main;
GtkWidget *vbox;
-GtkWidget *sw;
GtkNotebook *notebook;
GtkToolItem *item;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
-#ifdef WITH_HILDON
-_program = HILDON_PROGRAM(hildon_program_get_instance());
-_window = GTK_WIDGET(hildon_window_new());
-hildon_program_add_window(_program, HILDON_WINDOW(_window));
-#else
-_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-gtk_window_set_title(GTK_WINDOW(_window), "Mapper");
-gtk_widget_set_size_request(GTK_WIDGET(_window), WINDOW_SIZE_X, WINDOW_SIZE_Y);
-gtk_window_resize(GTK_WINDOW(_window), WINDOW_SIZE_X, WINDOW_SIZE_Y);
-gtk_window_set_resizable(GTK_WINDOW(_window), TRUE);
-#endif
-
+_window=mapper_window_new();
gtk_container_set_border_width (GTK_CONTAINER (_window), 0);
actions = gtk_action_group_new ("Actions");
gtk_ui_manager_insert_action_group (ui, actions, 0);
g_object_unref (actions);
-/* N810 has keyboard so set this up */
+/* N810 has keyboard so set this up on hildon too */
gtk_window_add_accel_group (GTK_WINDOW(_window), gtk_ui_manager_get_accel_group (ui));
if (!gtk_ui_manager_add_ui_from_string (ui, mapper_ui, -1, &error)) {
toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar");
g_assert(toolbar);
+/* Toolbar progress item */
item=gtk_tool_item_new();
_progress_item=gtk_progress_bar_new();
gtk_tool_item_set_expand(item, TRUE);
GtkMenu *hmenu;
hmenu = GTK_MENU(gtk_menu_new());
- gtk_container_foreach(GTK_CONTAINER(menu_bar),
- (GtkCallback) gtk_widget_reparent, hmenu);
-
+ gtk_container_foreach(GTK_CONTAINER(menu_bar), (GtkCallback)gtk_widget_reparent, hmenu);
hildon_window_set_menu(HILDON_WINDOW(_window), hmenu);
}
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), notebook, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), _tab_compass, TRUE, TRUE, 0);
ui_notebook.heading=gtk_notebook_append_page(notebook, vbox, label);
+/* Track Tab */
+vbox=gtk_vbox_new(FALSE, 0);
+label=gtk_label_new("Track");
+track_tree_view=mapper_tree_view_new(vbox);
+#if 0
+g_signal_connect(G_OBJECT(track_tree_view), "row-activated", G_CALLBACK(track_waypoint_activated_cb), NULL);
+#endif
+ui_notebook.track=gtk_notebook_append_page(notebook, vbox, label);
+
/* Route Tab */
vbox=gtk_vbox_new(FALSE, 0);
label=gtk_label_new("Route");
-
-route_tree_view=gtk_tree_view_new();
-sw=gtk_scrolled_window_new(NULL, NULL);
-gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-gtk_box_pack_start(vbox, sw, TRUE, TRUE, 0);
-gtk_container_add(GTK_CONTAINER(sw), route_tree_view);
-
-gtk_tree_selection_set_mode(gtk_tree_view_get_selection (GTK_TREE_VIEW(route_tree_view)), GTK_SELECTION_SINGLE);
-gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(route_tree_view), TRUE);
+route_tree_view=mapper_tree_view_new(vbox);
renderer=gtk_cell_renderer_text_new();
column=gtk_tree_view_column_new_with_attributes(_("Location"), renderer, "text", ROUTE_LATLON, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(route_tree_view), column);
#if 0
-g_signal_connect(G_OBJECT(route_tree), "row-activated", G_CALLBACK(route_waypoint_activated_cb), NULL);
+g_signal_connect(G_OBJECT(route_tree_view), "row-activated", G_CALLBACK(route_waypoint_activated_cb), NULL);
#endif
ui_notebook.route=gtk_notebook_append_page(notebook, vbox, label);
-/* Track Tab */
-#if 0
-vbox=gtk_vbox_new(FALSE, 0);
-label=gtk_label_new("Track");
-
-ui_notebook.track=gtk_notebook_append_page(notebook, vbox, label);
-#endif
-
menu_maps_add_repos();
menu_init_cmenu();
_last_spoken_phrase = g_strdup("");
memset(&_autoroute_data, 0, sizeof(_autoroute_data));
+g_signal_connect(G_OBJECT(_window), "delete_event", G_CALLBACK(mapper_cb_quit), NULL);
g_signal_connect(G_OBJECT(_window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(GTK_WIDGET(vbox_main));
gtk_idle_add((GSourceFunc)window_present, NULL);
}
-GtkWidget *
-progress_dialog(const gchar *title, GtkWidget *progress)
-{
-GtkWidget *dialog;
-
-dialog = gtk_dialog_new();
-gtk_window_set_title(GTK_WINDOW(dialog), title);
-gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(_window));
-gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
-#ifndef WITH_HILDON
-gtk_window_set_deletable(GTK_WINDOW(dialog), FALSE);
-#endif
-/* gtk_window_set_decorated(GTK_WINDOW(dialog), FALSE); */
-gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(title), TRUE, TRUE, 0);
-gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), progress, TRUE, TRUE, 0);
-gtk_widget_show_all(dialog);
-return dialog;
-}
-
-void
-progress_dialog_remove(GtkWidget *dialog)
-{
-if (dialog)
- gtk_widget_destroy(dialog);
-}
-
gboolean
gps_info_update(Gps *gps)
{