From 97a2a332d14a72044327522eb1dfd42518ed3699 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Sat, 2 Feb 2008 11:58:39 +0200 Subject: [PATCH] Hide and show widgets depending on selected GPS type in settings dialog. --- src/gps.c | 16 +- src/gps.h | 7 +- src/settings-gui.c | 359 ++++++++++++++++++++++++++------------------- 3 files changed, 219 insertions(+), 163 deletions(-) diff --git a/src/gps.c b/src/gps.c index bdfa799..0523be5 100644 --- a/src/gps.c +++ b/src/gps.c @@ -69,21 +69,21 @@ static gboolean gps_connect_file(Gps *gps, gchar *file); const GpsTypes gps_types[] = { #ifdef WITH_BLUEZ - { GPS_IO_RFCOMM, "Bluetooth connection (old)", TRUE, TRUE}, + { GPS_IO_RFCOMM, "Bluetooth connection (old)", TRUE, TRUE, FALSE}, #endif #ifdef WITH_HILDON_DBUS_BT - { GPS_IO_HILDON_DBUS, "Bluetooth connection (btconn)", TRUE, TRUE }, + { GPS_IO_HILDON_DBUS, "Bluetooth connection (btconn)", TRUE, TRUE, FALSE }, #endif #ifdef WITH_BLUEZ_DBUS_BT - { GPS_IO_BLUEZ_DBUS, "Bluetooth connection (new)", TRUE, TRUE}, + { GPS_IO_BLUEZ_DBUS, "Bluetooth connection (new)", TRUE, TRUE, FALSE}, #endif - { GPS_IO_GPSD, "GPSD Connection", FALSE, TRUE}, - { GPS_IO_FILE, "File or device", FALSE, TRUE}, - { GPS_IO_TCP, "TCP Connection", FALSE, TRUE}, + { GPS_IO_GPSD, "GPSD Connection", FALSE, TRUE, TRUE, GPSD_PORT }, + { GPS_IO_FILE, "File or device", FALSE, TRUE, FALSE}, + { GPS_IO_TCP, "TCP Connection", FALSE, TRUE, TRUE, 1024 }, #ifdef WITH_GYPSY - { GPS_IO_GYPSY, "Gypsy", FALSE, TRUE}, + { GPS_IO_GYPSY, "Gypsy", FALSE, TRUE, FALSE}, #endif - { GPS_IO_SIMULATION, "Simulation (random)", FALSE, FALSE}, + { GPS_IO_SIMULATION, "Simulation (random)", FALSE, FALSE, FALSE}, { 0 } }; diff --git a/src/gps.h b/src/gps.h index 8b21bef..498d3e6 100644 --- a/src/gps.h +++ b/src/gps.h @@ -55,8 +55,11 @@ typedef struct _GpsTypes GpsTypes; struct _GpsTypes { GpsIOSourceType type; const gchar *name; - gboolean scan; - gboolean address; + gboolean scan; /* Can scan for device */ + gboolean address; /* Needs address */ + gboolean port; /* Needs port */ + guint port_def; /* Default port */ + }; /** This enumerated type defines the possible connection states. */ diff --git a/src/settings-gui.c b/src/settings-gui.c index 7e98c4c..b278ca1 100644 --- a/src/settings-gui.c +++ b/src/settings-gui.c @@ -44,6 +44,18 @@ struct _ColorsDialogInfo { GtkWidget *col[COLORABLE_ENUM_COUNT]; }; +typedef struct _GpsDialogInfo GpsDialogInfo; +struct _GpsDialogInfo { + GtkWidget *cmb_gps_type; + GtkWidget *txt_rcvr_mac; + GtkWidget *spn_rcvr_port; + GtkWidget *btn_scan; + GtkTreeIter active; + GtkListStore *store; + GtkTreeIter iter; +}; + + #define UPDATE_GC(gc) gdk_gc_set_line_attributes(gc, _draw_width, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND); void @@ -51,11 +63,11 @@ update_gcs(void) { gint i; -for (i = 0; i < COLORABLE_ENUM_COUNT; i++) { +for (i=0; i < COLORABLE_ENUM_COUNT; i++) { gdk_color_alloc(gtk_widget_get_colormap(_map_widget),&_color[i]); if (_gc[i]) g_object_unref(_gc[i]); - _gc[i] = gdk_gc_new(_map_pixmap); + _gc[i]=gdk_gc_new(_map_pixmap); gdk_gc_set_foreground(_gc[i], &_color[i]); gdk_gc_set_line_attributes(_gc[i], _draw_width, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND); } @@ -68,14 +80,14 @@ settings_dialog_browse_forfile(GtkWidget * widget, BrowseInfo * browse_info) GtkWidget *dialog; gint res; -dialog = GTK_WIDGET(hildon_file_chooser_dialog_new(GTK_WINDOW(browse_info->dialog),GTK_FILE_CHOOSER_ACTION_OPEN)); +dialog=GTK_WIDGET(hildon_file_chooser_dialog_new(GTK_WINDOW(browse_info->dialog),GTK_FILE_CHOOSER_ACTION_OPEN)); gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), gtk_entry_get_text(GTK_ENTRY(browse_info->txt))); res=gtk_dialog_run(GTK_DIALOG(dialog)); if (res==GTK_RESPONSE_OK || res==GTK_RESPONSE_ACCEPT) { - gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + gchar *filename=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); gtk_entry_set_text(GTK_ENTRY(browse_info->txt), filename); g_free(filename); } @@ -90,11 +102,11 @@ settings_dialog_hardkeys_reset(GtkWidget *widget, KeysDialogInfo *cdi) { GtkWidget *confirm; -confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Reset all hardware keys to their original defaults?")); +confirm=hildon_note_new_confirmation(GTK_WINDOW(_window), _("Reset all hardware keys to their original defaults?")); if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) { gint i; - for (i = 0; i < CUSTOM_KEY_ENUM_COUNT; i++) + for (i=0; i < CUSTOM_KEY_ENUM_COUNT; i++) gtk_combo_box_set_active(GTK_COMBO_BOX(cdi->cmb[i]), CUSTOM_KEY_DEFAULT[i]); } gtk_widget_destroy(confirm); @@ -111,23 +123,23 @@ GtkWidget *label; KeysDialogInfo bdi; GtkWidget *btn_defaults; -dialog = gtk_dialog_new_with_buttons(_("Hardware Keys"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); +dialog=gtk_dialog_new_with_buttons(_("Hardware Keys"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); -gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_defaults = gtk_button_new_with_label(_("Reset..."))); +gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_defaults=gtk_button_new_with_label(_("Reset..."))); g_signal_connect(G_OBJECT(btn_defaults), "clicked", G_CALLBACK(settings_dialog_hardkeys_reset), &bdi); gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); -gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table = gtk_table_new(2, 9, FALSE), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table=gtk_table_new(2, 9, FALSE), TRUE, TRUE, 0); -for (i = 0; i < CUSTOM_KEY_ENUM_COUNT; i++) { +for (i=0; i < CUSTOM_KEY_ENUM_COUNT; i++) { gint j; - gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(""), 0, 1, i, i + 1, GTK_FILL, 0, 2, 1); + gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(""), 0, 1, i, i + 1, GTK_FILL, 0, 2, 1); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); #ifdef WITH_HILDON gtk_label_set_markup(GTK_LABEL(label), CUSTOM_KEY_ICON[i]); #endif - gtk_table_attach(GTK_TABLE(table), bdi.cmb[i] = gtk_combo_box_new_text(), 1, 2, i, i + 1, GTK_FILL, 0, 2, 1); - for (j = 0; j < CUSTOM_ACTION_ENUM_COUNT; j++) + gtk_table_attach(GTK_TABLE(table), bdi.cmb[i]=gtk_combo_box_new_text(), 1, 2, i, i + 1, GTK_FILL, 0, 2, 1); + for (j=0; j < CUSTOM_ACTION_ENUM_COUNT; j++) gtk_combo_box_append_text(GTK_COMBO_BOX(bdi.cmb[i]), CUSTOM_ACTION_TEXT[j]); gtk_combo_box_set_active(GTK_COMBO_BOX(bdi.cmb[i]), _action[i]); } @@ -137,14 +149,14 @@ gtk_widget_show_all(dialog); OUTER_WHILE: while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { /* Check for duplicates. */ - for (i = 0; i < CUSTOM_KEY_ENUM_COUNT; i++) { + for (i=0; i < CUSTOM_KEY_ENUM_COUNT; i++) { gint j; - for (j = i + 1; j < CUSTOM_KEY_ENUM_COUNT; j++) { + for (j=i + 1; j < CUSTOM_KEY_ENUM_COUNT; j++) { if (gtk_combo_box_get_active(GTK_COMBO_BOX(bdi.cmb[i])) == gtk_combo_box_get_active(GTK_COMBO_BOX(bdi.cmb[j]))) { GtkWidget *confirm; - gchar *buffer = g_strdup_printf("%s:\n %s\n%s", _("The following action is mapped to multiple keys"), + gchar *buffer=g_strdup_printf("%s:\n %s\n%s", _("The following action is mapped to multiple keys"), CUSTOM_ACTION_TEXT[gtk_combo_box_get_active(GTK_COMBO_BOX(bdi.cmb[i]))], _("Continue?")); - confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer); + confirm=hildon_note_new_confirmation(GTK_WINDOW(_window), buffer); if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) { @@ -155,8 +167,8 @@ while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { } } } - for (i = 0; i < CUSTOM_KEY_ENUM_COUNT; i++) - _action[i] = gtk_combo_box_get_active(GTK_COMBO_BOX(bdi.cmb[i])); + for (i=0; i < CUSTOM_KEY_ENUM_COUNT; i++) + _action[i]=gtk_combo_box_get_active(GTK_COMBO_BOX(bdi.cmb[i])); break; } @@ -170,11 +182,11 @@ settings_dialog_colors_reset(GtkWidget *widget, ColorsDialogInfo *cdi) { GtkWidget *confirm; -confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Reset all colors to their original defaults?")); +confirm=hildon_note_new_confirmation(GTK_WINDOW(_window), _("Reset all colors to their original defaults?")); if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) { gint i; - for (i = 0; i < COLORABLE_ENUM_COUNT; i++) { + for (i=0; i < COLORABLE_ENUM_COUNT; i++) { gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi->col[i]), &COLORABLE_DEFAULT[i]); } } @@ -192,48 +204,48 @@ GtkWidget *label; GtkWidget *btn_defaults; ColorsDialogInfo cdi; -dialog = gtk_dialog_new_with_buttons(_("Colors"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); +dialog=gtk_dialog_new_with_buttons(_("Colors"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); -gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_defaults = gtk_button_new_with_label(_("Reset..."))); +gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_defaults=gtk_button_new_with_label(_("Reset..."))); g_signal_connect(G_OBJECT(btn_defaults), "clicked", G_CALLBACK(settings_dialog_colors_reset), &cdi); gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); -gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table = gtk_table_new(4, 3, TRUE), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table=gtk_table_new(4, 3, TRUE), TRUE, TRUE, 0); /* GPS. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("GPS")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("GPS")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_MARK] = gtk_color_button_new(), 1, 2, 0, 1, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_MARK]=gtk_color_button_new(), 1, 2, 0, 1, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_MARK]), &_color[COLORABLE_MARK]); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_MARK_VELOCITY] = gtk_color_button_new(), 2, 3, 0, 1, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_MARK_VELOCITY]=gtk_color_button_new(), 2, 3, 0, 1, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_MARK_VELOCITY]), &_color[COLORABLE_MARK_VELOCITY]); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_MARK_OLD] = gtk_color_button_new(), 3, 4, 0, 1, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_MARK_OLD]=gtk_color_button_new(), 3, 4, 0, 1, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_MARK_OLD]), &_color[COLORABLE_MARK_OLD]); /* Track. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Track")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Track")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_TRACK] = gtk_color_button_new(), 1, 2, 1, 2, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_TRACK]=gtk_color_button_new(), 1, 2, 1, 2, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_TRACK]), &_color[COLORABLE_TRACK]); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_TRACK_MARK] = gtk_color_button_new(), 2, 3, 1, 2, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_TRACK_MARK]=gtk_color_button_new(), 2, 3, 1, 2, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_TRACK_MARK]), &_color[COLORABLE_TRACK_MARK]); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_TRACK_BREAK] = gtk_color_button_new(), 3, 4, 1, 2, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_TRACK_BREAK]=gtk_color_button_new(), 3, 4, 1, 2, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_TRACK_BREAK]), &_color[COLORABLE_TRACK_BREAK]); /* Route. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Route")), 0, 1, 2, 3, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Route")), 0, 1, 2, 3, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_ROUTE] = gtk_color_button_new(), 1, 2, 2, 3, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_ROUTE]=gtk_color_button_new(), 1, 2, 2, 3, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_ROUTE]), &_color[COLORABLE_ROUTE]); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_ROUTE_WAY] = gtk_color_button_new(), 2, 3, 2, 3, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_ROUTE_WAY]=gtk_color_button_new(), 2, 3, 2, 3, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_ROUTE_WAY]), &_color[COLORABLE_ROUTE_WAY]); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_ROUTE_BREAK] = gtk_color_button_new(), 3, 4, 2, 3, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_ROUTE_BREAK]=gtk_color_button_new(), 3, 4, 2, 3, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_ROUTE_BREAK]), &_color[COLORABLE_ROUTE_BREAK]); /* POI. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("POI")), 0, 1, 3, 4, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("POI")), 0, 1, 3, 4, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_POI] = gtk_color_button_new(), 1, 2, 3, 4, 0, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), cdi.col[COLORABLE_POI]=gtk_color_button_new(), 1, 2, 3, 4, 0, 0, 2, 4); gtk_color_button_set_color(GTK_COLOR_BUTTON(cdi.col[COLORABLE_POI]), &_color[COLORABLE_POI]); gtk_widget_show_all(dialog); @@ -256,24 +268,50 @@ gtk_widget_destroy(dialog); return TRUE; } +static void +gtk_widget_hideshow(GtkWidget *widget, gboolean show) +{ +g_assert(widget); +if (show==TRUE) + gtk_widget_show(widget); +else + gtk_widget_hide(widget); +} + +static gboolean +gps_type_changed_cb(GtkWidget *widget, gpointer data) +{ +GpsDialogInfo *gdi=(GpsDialogInfo *)data; +gboolean scan, port, address; +GpsIOSourceType type; +guint dport; + +if (gtk_combo_box_get_active_iter(gdi->cmb_gps_type, &gdi->iter)==FALSE) + return TRUE; + +gtk_tree_model_get(GTK_TREE_MODEL(gdi->store), &gdi->iter, 0, &type, 2, &scan, 3, &address, 4, &port, 5, &dport, -1); +g_debug("GPS: %d", type); + +gtk_widget_hideshow(gdi->btn_scan, scan); +gtk_widget_hideshow(gdi->txt_rcvr_mac, address); +gtk_widget_hideshow(gdi->spn_rcvr_port, port); +if (port && dport!=0 && (guint)gtk_spin_button_get_value(gdi->spn_rcvr_port)==0) + gtk_spin_button_set_value(gdi->spn_rcvr_port, (guint)dport); + +return TRUE; +} + gboolean settings_dialog_gps(Gps *gps) { GtkWidget *dialog; GtkWidget *notebook; -GtkWidget *table; -GtkWidget *hbox; GtkWidget *vbox; +GtkWidget *hbox; GtkWidget *label; -GtkWidget *cmb_gps_type; -GtkWidget *txt_rcvr_mac; -GtkWidget *spn_rcvr_port; -GtkWidget *btn_scan; GtkCellRenderer *renderer; -GtkTreeIter active; -GtkListStore *store; -GtkTreeIter iter; -ScanInfo scan_info = { 0 }; +GpsDialogInfo gdi; +ScanInfo scan_info={ 0 }; gboolean rcvr_changed=TRUE, settype=FALSE; GpsTypes *gpstypes; gint i=0; @@ -284,77 +322,92 @@ if (gps->io.conn!=RCVR_OFF) { return FALSE; } -dialog = gtk_dialog_new_with_buttons(_("GPS Settings"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, +dialog=gtk_dialog_new_with_buttons(_("GPS Settings"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); help_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_SETTINGS_GPS); -gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook = gtk_notebook_new(), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook=gtk_notebook_new(), TRUE, TRUE, 0); /* Receiver page. */ -gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox = gtk_vbox_new(FALSE, 4), label = gtk_label_new(_("GPS"))); +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox=gtk_vbox_new(FALSE, 4), label=gtk_label_new(_("GPS"))); /* Type */ -hbox = gtk_hbox_new(FALSE, 3); -gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("GPS Type")), TRUE, TRUE, 0); +hbox=gtk_hbox_new(FALSE, 3); +gtk_box_pack_start(GTK_BOX(hbox), label=gtk_label_new(_("GPS Type")), TRUE, TRUE, 0); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_box_pack_start(GTK_BOX(hbox), cmb_gps_type = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING))), TRUE, FALSE, 0); + +gdi.cmb_gps_type=gtk_combo_box_new_with_model( + GTK_TREE_MODEL(gtk_list_store_new(6, G_TYPE_INT, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_INT))); + +gtk_box_pack_start(GTK_BOX(hbox), gdi.cmb_gps_type, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); /* Add GPS types */ -/* Set up the view for the combo box. */ -renderer = gtk_cell_renderer_text_new(); -gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cmb_gps_type), renderer, TRUE); -gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cmb_gps_type), renderer, "text", 1, NULL); +renderer=gtk_cell_renderer_text_new(); +gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gdi.cmb_gps_type), renderer, TRUE); +gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gdi.cmb_gps_type), renderer, "text", 1, NULL); -store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(cmb_gps_type))); -gtk_list_store_clear(store); +/* Receiver MAC/File/IP Address. */ +hbox=gtk_hbox_new(FALSE, 3); +gtk_box_pack_start(GTK_BOX(hbox), label=gtk_label_new(_("Address: (MAC/IP/Device)")), TRUE, TRUE, 0); +gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); +gtk_box_pack_start(GTK_BOX(hbox), gdi.txt_rcvr_mac=gtk_entry_new(), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(hbox), gdi.spn_rcvr_port=gtk_spin_button_new_with_range(0, 65535, 1), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(hbox), gdi.btn_scan=gtk_button_new_with_label(_("Scan...")), FALSE, FALSE, 0); +gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); +/* Set up the view for the combo box. */ +gdi.store=GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(gdi.cmb_gps_type))); +gtk_list_store_clear(gdi.store); gpstypes=gps_get_supported_types(); while (gpstypes->type!=0) { - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, gpstypes->type, 1, gpstypes->name, -1); + gtk_list_store_append(gdi.store, &gdi.iter); + gtk_list_store_set(gdi.store, &gdi.iter, + 0, gpstypes->type, + 1, gpstypes->name, + 2, gpstypes->scan, + 3, gpstypes->address, + 4, gpstypes->port, + 5, gpstypes->port_def, + -1); if (gps->io.type==gpstypes->type) { - active=iter; + gdi.active=gdi.iter; + settype=TRUE; + } else if (settype==FALSE && gps->io.type==GPS_IO_SIMULATION) { + gdi.active=gdi.iter; settype=TRUE; } gpstypes++; } -if (settype==FALSE) - gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &active); - -gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cmb_gps_type), &active); +/* Connect signals. */ +scan_info.settings_dialog=dialog; +scan_info.txt_rcvr_mac=gdi.txt_rcvr_mac; -/* Receiver MAC Address. */ -hbox = gtk_hbox_new(FALSE, 3); -gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Address")), TRUE, TRUE, 0); -gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_box_pack_start(GTK_BOX(hbox), txt_rcvr_mac = gtk_entry_new(), TRUE, TRUE, 0); -gtk_box_pack_start(GTK_BOX(hbox), spn_rcvr_port = gtk_spin_button_new_with_range(0, 65535, 1), TRUE, TRUE, 0); -gtk_box_pack_start(GTK_BOX(hbox), btn_scan = gtk_button_new_with_label(_("Scan...")), FALSE, FALSE, 0); -gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); +g_signal_connect(G_OBJECT(gdi.btn_scan), "clicked", G_CALLBACK(scan_bluetooth), &scan_info); +g_signal_connect(G_OBJECT(gdi.cmb_gps_type), "changed", G_CALLBACK(gps_type_changed_cb), &gdi); -/* Connect signals. */ -scan_info.settings_dialog = dialog; -scan_info.txt_rcvr_mac = txt_rcvr_mac; -g_signal_connect(G_OBJECT(btn_scan), "clicked", G_CALLBACK(scan_bluetooth), &scan_info); -gtk_entry_set_text(GTK_ENTRY(txt_rcvr_mac), gps->io.address ? gps->io.address : ""); -gtk_spin_button_set_value(spn_rcvr_port, gps->io.port); +gtk_entry_set_text(GTK_ENTRY(gdi.txt_rcvr_mac), gps->io.address ? gps->io.address : ""); +gtk_spin_button_set_value(gdi.spn_rcvr_port, gps->io.port); gtk_window_set_default_size(GTK_WINDOW(dialog), 500, -1); gtk_widget_show_all(dialog); +if (settype==FALSE) + gtk_tree_model_get_iter_first(GTK_TREE_MODEL(gdi.store), &gdi.active); +gtk_combo_box_set_active_iter(GTK_COMBO_BOX(gdi.cmb_gps_type), &gdi.active); + while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { /* Set _rcvr_mac if necessary. */ - if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(cmb_gps_type), &iter)==TRUE) { - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &(gps->io.type), -1); + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(gdi.cmb_gps_type), &gdi.iter)==TRUE) { + gtk_tree_model_get(GTK_TREE_MODEL(gdi.store), &gdi.iter, 0, &(gps->io.type), -1); g_debug("GPS: %d", gps->io.type); } else { popup_error(_window, "Please select GPS type"); continue; } - if (!*gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac))) { + if (!*gtk_entry_get_text(GTK_ENTRY(gdi.txt_rcvr_mac))) { /* User specified no rcvr mac - set _rcvr_mac to NULL. */ if (gps->io.address) { g_free(gps->io.address); @@ -369,11 +422,11 @@ while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { rcvr_changed=TRUE; set_action_sensitive("gps_details", FALSE); } - } else if (!gps->io.address || strcmp(gps->io.address, gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac)))) { + } else if (!gps->io.address || strcmp(gps->io.address, gtk_entry_get_text(GTK_ENTRY(gdi.txt_rcvr_mac)))) { /* User specified a new rcvr mac. */ g_free(gps->io.address); - gps->io.address=g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac))); - gps->io.port=(guint)gtk_spin_button_get_value(spn_rcvr_port); + gps->io.address=g_strdup(gtk_entry_get_text(GTK_ENTRY(gdi.txt_rcvr_mac))); + gps->io.port=(guint)gtk_spin_button_get_value(gdi.spn_rcvr_port); rcvr_changed=TRUE; } @@ -394,28 +447,28 @@ GtkWidget *hbox; GtkWidget *label; GtkWidget *txt_mapper_db; GtkWidget *btn_browsedb; -BrowseInfo browse_info = { 0, 0 }; +BrowseInfo browse_info={ 0, 0 }; -dialog = gtk_dialog_new_with_buttons(_("OSM Settings"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, +dialog=gtk_dialog_new_with_buttons(_("OSM Settings"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); help_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_SETTINGS_OSM); -gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook = gtk_notebook_new(), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook=gtk_notebook_new(), TRUE, TRUE, 0); /* Database page */ -gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("Database"))); +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table=gtk_table_new(2, 3, FALSE), label=gtk_label_new(_("Database"))); /* Database. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Database")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Database")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); -gtk_box_pack_start(GTK_BOX(hbox), txt_mapper_db = gtk_entry_new(), TRUE, TRUE, 0); -gtk_box_pack_start(GTK_BOX(hbox), btn_browsedb = gtk_button_new_with_label(_("Browse...")), FALSE, FALSE, 0); +gtk_table_attach(GTK_TABLE(table), hbox=gtk_hbox_new(FALSE, 4), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_box_pack_start(GTK_BOX(hbox), txt_mapper_db=gtk_entry_new(), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(hbox), btn_browsedb=gtk_button_new_with_label(_("Browse...")), FALSE, FALSE, 0); gtk_entry_set_text(GTK_ENTRY(txt_mapper_db), _mapper_db ? _mapper_db : ""); -browse_info.dialog = dialog; -browse_info.txt = txt_mapper_db; +browse_info.dialog=dialog; +browse_info.txt=txt_mapper_db; g_signal_connect(G_OBJECT(btn_browsedb), "clicked", G_CALLBACK(settings_dialog_browse_forfile), &browse_info); gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300); @@ -481,104 +534,104 @@ GtkWidget *num_speed; GtkWidget *cmb_info_font_size; guint i; -dialog = gtk_dialog_new_with_buttons(_("Settings"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, +dialog=gtk_dialog_new_with_buttons(_("Settings"), GTK_WINDOW(_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); help_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_SETTINGS); -gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook = gtk_notebook_new(), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook=gtk_notebook_new(), TRUE, TRUE, 0); /* Auto-Center page. */ -gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 2, FALSE), label = gtk_label_new(_("Auto-Center"))); +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table=gtk_table_new(2, 2, FALSE), label=gtk_label_new(_("Auto-Center"))); /* Auto-Center Sensitivity. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Sensitivity")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Sensitivity")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), num_center_ratio = hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), num_center_ratio=hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); hildon_controlbar_set_range(HILDON_CONTROLBAR(num_center_ratio), 1, 10); force_min_visible_bars(HILDON_CONTROLBAR(num_center_ratio), 1); /* Lead Amount. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Lead Amount")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Lead Amount")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), num_lead_ratio = hildon_controlbar_new(), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), num_lead_ratio=hildon_controlbar_new(), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); hildon_controlbar_set_range(HILDON_CONTROLBAR(num_lead_ratio), 1, 10); force_min_visible_bars(HILDON_CONTROLBAR(num_lead_ratio), 1); /* Announcement page */ -gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("Announce"))); +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table=gtk_table_new(2, 3, FALSE), label=gtk_label_new(_("Announce"))); /* Announcement Advance Notice. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Advance Notice")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Advance Notice")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), num_announce_notice = hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), num_announce_notice=hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); hildon_controlbar_set_range(HILDON_CONTROLBAR(num_announce_notice), 1, 20); force_min_visible_bars(HILDON_CONTROLBAR(num_announce_notice), 1); /* Enable Voice. */ -gtk_table_attach(GTK_TABLE(table), chk_enable_voice = gtk_check_button_new_with_label(_("Enable Voice Synthesis")), 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), chk_enable_voice=gtk_check_button_new_with_label(_("Enable Voice Synthesis")), 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_enable_voice), _enable_voice); /* Voice Speed and Pitch. */ -gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 12), 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 6); -gtk_box_pack_start(GTK_BOX(hbox), hbox2 = gtk_hbox_new(FALSE, 4), TRUE, TRUE, 4); -gtk_box_pack_start(GTK_BOX(hbox2), lbl_voice_speed = gtk_label_new(_("Speed (words/minute)")), TRUE, TRUE, 0); -gtk_box_pack_start(GTK_BOX(hbox2), num_voice_speed = hildon_number_editor_new(80, 370), TRUE, TRUE, 0); -gtk_box_pack_start(GTK_BOX(hbox), hbox2 = gtk_hbox_new(FALSE, 4), TRUE, TRUE, 4); -gtk_box_pack_start(GTK_BOX(hbox2), lbl_voice_pitch = gtk_label_new(_("Pitch")), TRUE, TRUE, 0); -gtk_box_pack_start(GTK_BOX(hbox2), num_voice_pitch = hildon_number_editor_new(1, 99), TRUE, TRUE, 0); +gtk_table_attach(GTK_TABLE(table), hbox=gtk_hbox_new(FALSE, 12), 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 6); +gtk_box_pack_start(GTK_BOX(hbox), hbox2=gtk_hbox_new(FALSE, 4), TRUE, TRUE, 4); +gtk_box_pack_start(GTK_BOX(hbox2), lbl_voice_speed=gtk_label_new(_("Speed (words/minute)")), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(hbox2), num_voice_speed=hildon_number_editor_new(80, 370), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(hbox), hbox2=gtk_hbox_new(FALSE, 4), TRUE, TRUE, 4); +gtk_box_pack_start(GTK_BOX(hbox2), lbl_voice_pitch=gtk_label_new(_("Pitch")), TRUE, TRUE, 0); +gtk_box_pack_start(GTK_BOX(hbox2), num_voice_pitch=hildon_number_editor_new(1, 99), TRUE, TRUE, 0); /* Display settings page. */ -gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("Display"))); +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table=gtk_table_new(2, 3, FALSE), label=gtk_label_new(_("Display"))); /* Line Width. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Line Width")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Line Width")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), num_draw_width = hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), num_draw_width=hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4); hildon_controlbar_set_range(HILDON_CONTROLBAR(num_draw_width), 1, 20); force_min_visible_bars(HILDON_CONTROLBAR(num_draw_width), 1); /* Keep Display On Only When Fullscreen. */ -gtk_table_attach(GTK_TABLE(table), chk_always_keep_on = gtk_check_button_new_with_label(_("Keep Display On Only in Fullscreen Mode")), 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), chk_always_keep_on=gtk_check_button_new_with_label(_("Keep Display On Only in Fullscreen Mode")), 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4); /* Information Font Size. */ -gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 0, 2, 2, 3, GTK_FILL, 0, 2, 4); -gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Information Font Size")), FALSE, FALSE, 0); -gtk_box_pack_start(GTK_BOX(hbox), cmb_info_font_size = gtk_combo_box_new_text(), FALSE, FALSE, 0); -for (i = 0; i < INFO_FONT_ENUM_COUNT; i++) +gtk_table_attach(GTK_TABLE(table), hbox=gtk_hbox_new(FALSE, 4), 0, 2, 2, 3, GTK_FILL, 0, 2, 4); +gtk_box_pack_start(GTK_BOX(hbox), label=gtk_label_new(_("Information Font Size")), FALSE, FALSE, 0); +gtk_box_pack_start(GTK_BOX(hbox), cmb_info_font_size=gtk_combo_box_new_text(), FALSE, FALSE, 0); +for (i=0; i < INFO_FONT_ENUM_COUNT; i++) gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_info_font_size), INFO_FONT_TEXT[i]); /* Units page. */ -gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("Units"))); +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table=gtk_table_new(2, 3, FALSE), label=gtk_label_new(_("Units"))); /* Units. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Units")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Units")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), cmb_units = gtk_combo_box_new_text(), 1, 2, 0, 1, GTK_FILL, 0, 2, 4); -for (i = 0; i < UNITS_ENUM_COUNT; i++) +gtk_table_attach(GTK_TABLE(table), cmb_units=gtk_combo_box_new_text(), 1, 2, 0, 1, GTK_FILL, 0, 2, 4); +for (i=0; i < UNITS_ENUM_COUNT; i++) gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_units), UNITS_TEXT[i]); /* Degrees format */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Degrees Format")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Degrees Format")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), 1, 2, 1, 2, GTK_FILL, 0, 2, 4); -gtk_container_add(GTK_CONTAINER(label), cmb_degformat = gtk_combo_box_new_text()); -for (i = 0; i < DEG_FORMAT_ENUM_COUNT; i++) +gtk_table_attach(GTK_TABLE(table), label=gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), 1, 2, 1, 2, GTK_FILL, 0, 2, 4); +gtk_container_add(GTK_CONTAINER(label), cmb_degformat=gtk_combo_box_new_text()); +for (i=0; i < DEG_FORMAT_ENUM_COUNT; i++) gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_degformat), DEG_FORMAT_TEXT[i]); gtk_table_attach(GTK_TABLE(table), gtk_label_new(""), 2, 3, 0, 2, GTK_FILL | GTK_EXPAND, 0, 2, 4); /* Speed warner. */ -gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 0, 3, 2, 3, GTK_FILL, 0, 2, 4); -gtk_box_pack_start(GTK_BOX(hbox), chk_speed_on = gtk_check_button_new_with_label(_("Display Speed")), FALSE, FALSE, 0); -gtk_box_pack_start(GTK_BOX(hbox), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE, 0); -gtk_container_add(GTK_CONTAINER(label), num_speed = hildon_number_editor_new(0, 999)); +gtk_table_attach(GTK_TABLE(table), hbox=gtk_hbox_new(FALSE, 4), 0, 3, 2, 3, GTK_FILL, 0, 2, 4); +gtk_box_pack_start(GTK_BOX(hbox), chk_speed_on=gtk_check_button_new_with_label(_("Display Speed")), FALSE, FALSE, 0); +gtk_box_pack_start(GTK_BOX(hbox), label=gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE, 0); +gtk_container_add(GTK_CONTAINER(label), num_speed=hildon_number_editor_new(0, 999)); -gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("POIs"))); +gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table=gtk_table_new(2, 3, FALSE), label=gtk_label_new(_("POIs"))); /* Show POI below zoom. */ -gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Show POI below zoom")), 0, 1, 2, 3, GTK_FILL, 0, 2, 4); +gtk_table_attach(GTK_TABLE(table), label=gtk_label_new(_("Show POI below zoom")), 0, 1, 2, 3, GTK_FILL, 0, 2, 4); gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); -gtk_table_attach(GTK_TABLE(table), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4); -gtk_container_add(GTK_CONTAINER(label), num_poi_zoom = hildon_number_editor_new(0, MAX_ZOOM)); +gtk_table_attach(GTK_TABLE(table), label=gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4); +gtk_container_add(GTK_CONTAINER(label), num_poi_zoom=hildon_number_editor_new(0, MAX_ZOOM)); /* Initialize fields. */ hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_poi_zoom), _poi_zoom); @@ -600,20 +653,20 @@ gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300); gtk_widget_show_all(dialog); if (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { - _center_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_center_ratio)); - _lead_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_lead_ratio)); - _draw_width = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_draw_width)); - _always_keep_on = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_always_keep_on)); - _units = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_units)); - _degformat = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_degformat)); - _speed_on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_speed_on)); - _speed_limit = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_speed)); - _info_font_size = gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_info_font_size)); - _announce_notice_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_announce_notice)); - _voice_speed = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_voice_speed)); - _voice_pitch = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_voice_pitch)); - _enable_voice = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_enable_voice)); - _poi_zoom = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_poi_zoom)); + _center_ratio=hildon_controlbar_get_value(HILDON_CONTROLBAR(num_center_ratio)); + _lead_ratio=hildon_controlbar_get_value(HILDON_CONTROLBAR(num_lead_ratio)); + _draw_width=hildon_controlbar_get_value(HILDON_CONTROLBAR(num_draw_width)); + _always_keep_on=!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_always_keep_on)); + _units=gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_units)); + _degformat=gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_degformat)); + _speed_on=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_speed_on)); + _speed_limit=hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_speed)); + _info_font_size=gtk_combo_box_get_active(GTK_COMBO_BOX(cmb_info_font_size)); + _announce_notice_ratio=hildon_controlbar_get_value(HILDON_CONTROLBAR(num_announce_notice)); + _voice_speed=hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_voice_speed)); + _voice_pitch=hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_voice_pitch)); + _enable_voice=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_enable_voice)); + _poi_zoom=hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_poi_zoom)); speak_set_parameters(_voice_speed, _voice_pitch); update_gcs(); -- 2.39.5