/** * Auto attempt to read the world file associated with the image used for the georef * Based on simple file name conventions * Only attempted if the preference is on. */ static gboolean maybe_read_world_file ( VikFileEntry *vfe, gpointer user_data ) { if ( a_preferences_get (VIKING_PREFERENCES_IO_NAMESPACE "georef_auto_read_world_file")->b ) { const gchar* filename = vik_file_entry_get_filename(VIK_FILE_ENTRY(vfe)); gdouble values[4]; if ( filename && user_data ) { changeable_widgets *cw = user_data; gboolean upper = g_ascii_isupper (filename[strlen(filename)-1]); gchar* filew = g_strconcat ( filename, (upper ? "W" : "w") , NULL ); if ( world_file_read_file ( filew, values ) == 0 ) { set_widget_values ( cw, values ); } else { if ( strlen(filename) > 3 ) { gchar* file0 = g_strndup ( filename, strlen(filename)-2 ); gchar* file1 = g_strdup_printf ( "%s%c%c", file0, filename[strlen(filename)-1], (upper ? 'W' : 'w') ); if ( world_file_read_file ( file1, values ) == 0 ) { set_widget_values ( cw, values ); } g_free ( file1 ); g_free ( file0 ); } } g_free ( filew ); } } return TRUE; }
static void calculate_mpp_from_coords ( GtkWidget *ww, VikGeorefLayer *vgl ) { const gchar* filename = vik_file_entry_get_filename(VIK_FILE_ENTRY(vgl->cw.imageentry)); if ( !filename ) { return; } GError *gx = NULL; GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file ( filename, &gx ); if ( gx ) { a_dialog_error_msg_extra ( VIK_GTK_WINDOW_FROM_WIDGET(ww), _("Couldn't open image file: %s"), gx->message ); g_error_free ( gx ); return; } guint width = gdk_pixbuf_get_width ( pixbuf ); guint height = gdk_pixbuf_get_height ( pixbuf ); if ( width == 0 || height == 0 ) { a_dialog_error_msg_extra ( VIK_GTK_WINDOW_FROM_WIDGET(ww), _("Invalid image size: %s"), filename); } else { align_coords ( vgl ); struct LatLon ll_tl = get_ll_tl (vgl); struct LatLon ll_br = get_ll_br (vgl); gdouble xmpp, ympp; georef_layer_mpp_from_coords ( VIK_COORD_LATLON, ll_tl, ll_br, width, height, &xmpp, &ympp ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(vgl->cw.x_spin), xmpp ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(vgl->cw.y_spin), ympp ); check_br_is_good_or_msg_user ( vgl ); } g_object_unref ( G_OBJECT(pixbuf) ); }
VikLayerParamData a_uibuilder_widget_get_value ( GtkWidget *widget, VikLayerParam *param ) { VikLayerParamData rv; switch ( param->widget_type ) { case VIK_LAYER_WIDGET_COLOR: gtk_color_button_get_color ( GTK_COLOR_BUTTON(widget), &(rv.c) ); break; case VIK_LAYER_WIDGET_CHECKBUTTON: rv.b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); break; case VIK_LAYER_WIDGET_COMBOBOX: if ( param->type == VIK_LAYER_PARAM_UINT ) { rv.i = gtk_combo_box_get_active ( GTK_COMBO_BOX(widget) ); if ( rv.i == -1 ) rv.i = 0; rv.u = rv.i; if ( param->extra_widget_data ) rv.u = ((guint *)param->extra_widget_data)[rv.u]; } if ( param->type == VIK_LAYER_PARAM_STRING) { if ( param->extra_widget_data ) { /* Combobox displays labels and we want values from extra */ int pos = gtk_combo_box_get_active ( GTK_COMBO_BOX(widget) ); rv.s = ((const char **)param->extra_widget_data)[pos]; } else { /* Return raw value */ #if GTK_CHECK_VERSION (2, 24, 0) rv.s = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget)))); #else rv.s = gtk_combo_box_get_active_text ( GTK_COMBO_BOX(widget) ); #endif } g_debug("%s: %s", __FUNCTION__, rv.s); } break; case VIK_LAYER_WIDGET_RADIOGROUP: case VIK_LAYER_WIDGET_RADIOGROUP_STATIC: rv.u = vik_radio_group_get_selected(VIK_RADIO_GROUP(widget)); if ( param->extra_widget_data ) rv.u = GPOINTER_TO_UINT ( g_list_nth_data(param->extra_widget_data, rv.u) ); break; case VIK_LAYER_WIDGET_SPINBUTTON: if ( param->type == VIK_LAYER_PARAM_UINT ) rv.u = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widget) ); else if ( param->type == VIK_LAYER_PARAM_INT ) rv.i = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widget) ); else rv.d = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(widget) ); break; case VIK_LAYER_WIDGET_ENTRY: case VIK_LAYER_WIDGET_PASSWORD: rv.s = gtk_entry_get_text ( GTK_ENTRY(widget) ); break; case VIK_LAYER_WIDGET_FILEENTRY: case VIK_LAYER_WIDGET_FOLDERENTRY: rv.s = vik_file_entry_get_filename ( VIK_FILE_ENTRY(widget) ); break; case VIK_LAYER_WIDGET_FILELIST: rv.sl = vik_file_list_get_files ( VIK_FILE_LIST(widget) ); break; case VIK_LAYER_WIDGET_HSCALE: if ( param->type == VIK_LAYER_PARAM_UINT ) rv.u = (guint32) gtk_range_get_value ( GTK_RANGE(widget) ); else if ( param->type == VIK_LAYER_PARAM_INT ) rv.i = (gint32) gtk_range_get_value ( GTK_RANGE(widget) ); else rv.d = gtk_range_get_value ( GTK_RANGE(widget) ); break; } // Perform conversion if necessary if ( param->convert_to_internal ) rv = param->convert_to_internal ( rv ); return rv; }
/* todo: less on this side, like add track */ gchar *a_dialog_waypoint ( GtkWindow *parent, gchar *default_name, VikTrwLayer *vtl, VikWaypoint *wp, VikCoordMode coord_mode, gboolean is_new, gboolean *updated ) { GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Waypoint Properties"), parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); struct LatLon ll; GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry=NULL; GtkWidget *commentlabel, *commententry, *descriptionlabel, *descriptionentry, *imagelabel, *imageentry, *symbollabel, *symbolentry; GtkWidget *sourcelabel = NULL, *sourceentry = NULL; GtkWidget *typelabel = NULL, *typeentry = NULL; GtkWidget *timelabel = NULL; GtkWidget *timevaluebutton = NULL; GtkWidget *hasGeotagCB = NULL; GtkWidget *consistentGeotagCB = NULL; GtkWidget *direction_sb = NULL; GtkWidget *direction_hb = NULL; GtkListStore *store; gchar *lat, *lon, *alt; vik_coord_to_latlon ( &(wp->coord), &ll ); lat = g_strdup_printf ( "%f", ll.lat ); lon = g_strdup_printf ( "%f", ll.lon ); vik_units_height_t height_units = a_vik_get_units_height (); switch (height_units) { case VIK_UNITS_HEIGHT_METRES: alt = g_strdup_printf ( "%f", wp->altitude ); break; case VIK_UNITS_HEIGHT_FEET: alt = g_strdup_printf ( "%f", VIK_METERS_TO_FEET(wp->altitude) ); break; default: alt = g_strdup_printf ( "%f", wp->altitude ); g_critical("Houston, we've had a problem. height=%d", height_units); } *updated = FALSE; namelabel = gtk_label_new (_("Name:")); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), namelabel, FALSE, FALSE, 0); // Name is now always changeable nameentry = gtk_entry_new (); if ( default_name ) gtk_entry_set_text( GTK_ENTRY(nameentry), default_name ); g_signal_connect_swapped ( nameentry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), nameentry, FALSE, FALSE, 0); latlabel = gtk_label_new (_("Latitude:")); latentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(latentry), lat ); g_free ( lat ); lonlabel = gtk_label_new (_("Longitude:")); lonentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(lonentry), lon ); g_free ( lon ); altlabel = gtk_label_new (_("Altitude:")); altentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(altentry), alt ); g_free ( alt ); if ( wp->comment && !strncmp(wp->comment, "http", 4) ) commentlabel = gtk_link_button_new_with_label (wp->comment, _("Comment:") ); else commentlabel = gtk_label_new (_("Comment:")); commententry = gtk_entry_new (); gchar *cmt = NULL; // Auto put in some kind of 'name' as a comment if one previously 'goto'ed this exact location cmt = a_vik_goto_get_search_string_for_this_place(VIK_WINDOW(parent)); if (cmt) gtk_entry_set_text(GTK_ENTRY(commententry), cmt); if ( wp->description && !strncmp(wp->description, "http", 4) ) descriptionlabel = gtk_link_button_new_with_label (wp->description, _("Description:") ); else descriptionlabel = gtk_label_new (_("Description:")); descriptionentry = gtk_entry_new (); sourcelabel = gtk_label_new (_("Source:")); if ( wp->source ) { sourceentry = gtk_entry_new (); gtk_entry_set_text(GTK_ENTRY(sourceentry), wp->source); } typelabel = gtk_label_new (_("Type:")); if ( wp->type ) { typeentry = gtk_entry_new (); gtk_entry_set_text(GTK_ENTRY(typeentry), wp->type); } imagelabel = gtk_label_new (_("Image:")); imageentry = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN, VF_FILTER_IMAGE, NULL, NULL); { GtkCellRenderer *r; symbollabel = gtk_label_new (_("Symbol:")); GtkTreeIter iter; store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING); symbolentry = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(symbolentry), 6); g_signal_connect(symbolentry, "changed", G_CALLBACK(symbol_entry_changed_cb), store); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, NULL, 1, NULL, 2, _("(none)"), -1); a_populate_sym_list(store); r = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "pixbuf", 1, NULL); r = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "text", 2, NULL); if ( !is_new && wp->symbol ) { gboolean ok; gchar *sym; for (ok = gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &iter ); ok; ok = gtk_tree_model_iter_next ( GTK_TREE_MODEL(store), &iter)) { gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); if (sym && !strcmp(sym, wp->symbol)) { g_free(sym); break; } else { g_free(sym); } } // Ensure is it a valid symbol in the given symbol set (large vs small) // Not all symbols are available in both // The check prevents a Gtk Critical message if ( iter.stamp ) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(symbolentry), &iter); } } if ( !is_new && wp->comment ) gtk_entry_set_text ( GTK_ENTRY(commententry), wp->comment ); if ( !is_new && wp->description ) gtk_entry_set_text ( GTK_ENTRY(descriptionentry), wp->description ); if ( !edit_wp ) edit_wp = vik_waypoint_new (); edit_wp = vik_waypoint_copy ( wp ); if ( !is_new && wp->image ) { vik_file_entry_set_filename ( VIK_FILE_ENTRY(imageentry), wp->image ); #ifdef VIK_CONFIG_GEOTAG // Geotag Info [readonly] hasGeotagCB = gtk_check_button_new_with_label ( _("Has Geotag") ); gtk_widget_set_sensitive ( hasGeotagCB, FALSE ); gboolean hasGeotag; gchar *ignore = a_geotag_get_exif_date_from_file ( wp->image, &hasGeotag ); g_free ( ignore ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(hasGeotagCB), hasGeotag ); consistentGeotagCB = gtk_check_button_new_with_label ( _("Consistent Position") ); gtk_widget_set_sensitive ( consistentGeotagCB, FALSE ); if ( hasGeotag ) { struct LatLon ll = a_geotag_get_position ( wp->image ); VikCoord coord; vik_coord_load_from_latlon ( &coord, coord_mode, &ll ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(consistentGeotagCB), vik_coord_equalish(&coord, &wp->coord) ); } // ATM the direction value box is always shown, even when there is no information. // It would be nice to be able to hide it until the 'Add' has been performed, // however I've not been able to achieve this. // Thus simply sensistizing it instead. GtkWidget *direction_label = gtk_label_new ( _("Image Direction:") ); direction_hb = gtk_hbox_new ( FALSE, 0 ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_label, FALSE, FALSE, 0); direction_sb = gtk_spin_button_new ( (GtkAdjustment*)gtk_adjustment_new (0, 0.0, 359.9, 5.0, 1, 0 ), 1, 1 ); if ( !is_new && !isnan(wp->image_direction) ) { GtkWidget *direction_ref = gtk_label_new ( NULL ); if ( wp->image_direction_ref == WP_IMAGE_DIRECTION_REF_MAGNETIC ) gtk_label_set_label ( GTK_LABEL(direction_ref), _("Magnetic") ); else gtk_label_set_label ( GTK_LABEL(direction_ref), _("True") ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_ref, TRUE, FALSE, 0); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(direction_sb), wp->image_direction ); } else { GtkWidget *direction_ref_button = gtk_button_new (); gtk_button_set_relief ( GTK_BUTTON(direction_ref_button), GTK_RELIEF_NONE ); GtkWidget *img = gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_MENU ); gtk_button_set_image ( GTK_BUTTON(direction_ref_button), img ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_ref_button, TRUE, FALSE, 0); gtk_widget_set_sensitive ( direction_sb, FALSE ); direction_signal_id = g_signal_connect ( G_OBJECT(direction_ref_button), "button-release-event", G_CALLBACK(direction_add_click), direction_sb ); } #endif } timelabel = gtk_label_new ( _("Time:") ); timevaluebutton = gtk_button_new(); gtk_button_set_relief ( GTK_BUTTON(timevaluebutton), GTK_RELIEF_NONE ); // TODO: Consider if there should be a remove time button... if ( !is_new && wp->has_timestamp ) { update_time ( timevaluebutton, wp ); } else { GtkWidget *img = gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_MENU ); gtk_button_set_image ( GTK_BUTTON(timevaluebutton), img ); // Initially use current time or otherwise whatever the last value used was if ( edit_wp->timestamp == 0 ) { time ( &edit_wp->timestamp ); } } g_signal_connect ( G_OBJECT(timevaluebutton), "button-release-event", G_CALLBACK(time_edit_click), edit_wp ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), latlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), latentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), timelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), timevaluebutton, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), altlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), altentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), commentlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), commententry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), descriptionlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), descriptionentry, FALSE, FALSE, 0); if ( wp->source ) { gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), sourcelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), sourceentry, FALSE, FALSE, 0); } if ( wp->type ) { gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), typelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), typeentry, FALSE, FALSE, 0); } gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), imagelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), imageentry, FALSE, FALSE, 0); if ( hasGeotagCB ) { GtkWidget *hbox = gtk_hbox_new ( FALSE, 0 ); gtk_box_pack_start (GTK_BOX(hbox), hasGeotagCB, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(hbox), consistentGeotagCB, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, FALSE, FALSE, 0); } if ( direction_hb ) gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), direction_hb, FALSE, FALSE, 0); if ( direction_sb ) gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), direction_sb, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), symbollabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), GTK_WIDGET(symbolentry), FALSE, FALSE, 0); gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); gtk_widget_show_all ( gtk_dialog_get_content_area(GTK_DIALOG(dialog)) ); if ( !is_new ) { // Shift left<->right to try not to obscure the waypoint. trw_layer_dialog_shift ( vtl, GTK_WINDOW(dialog), &(wp->coord), FALSE ); } while ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) { if ( strlen((gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) )) == 0 ) /* TODO: other checks (isalpha or whatever ) */ a_dialog_info_msg ( parent, _("Please enter a name for the waypoint.") ); else { // NB: No check for unique names - this allows generation of same named entries. gchar *entered_name = g_strdup ( (gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) ) ); /* Do It */ ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) ); ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) ); vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll ); // Always store in metres switch (height_units) { case VIK_UNITS_HEIGHT_METRES: wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); break; case VIK_UNITS_HEIGHT_FEET: wp->altitude = VIK_FEET_TO_METERS(atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) )); break; default: wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); g_critical("Houston, we've had a problem. height=%d", height_units); } if ( g_strcmp0 ( wp->comment, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ) ) vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ); if ( g_strcmp0 ( wp->description, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) ) ) vik_waypoint_set_description ( wp, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) ); if ( g_strcmp0 ( wp->image, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ) ) vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ); if ( sourceentry && g_strcmp0 ( wp->source, gtk_entry_get_text ( GTK_ENTRY(sourceentry) ) ) ) vik_waypoint_set_source ( wp, gtk_entry_get_text ( GTK_ENTRY(sourceentry) ) ); if ( typeentry && g_strcmp0 ( wp->type, gtk_entry_get_text ( GTK_ENTRY(typeentry) ) ) ) vik_waypoint_set_type ( wp, gtk_entry_get_text ( GTK_ENTRY(typeentry) ) ); if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) ) a_thumbnails_create ( wp->image ); if ( edit_wp->timestamp ) { wp->timestamp = edit_wp->timestamp; wp->has_timestamp = TRUE; } if ( direction_sb ) { if ( gtk_widget_get_sensitive (direction_sb) ) { wp->image_direction = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(direction_sb) ); if ( wp->image_direction != edit_wp->image_direction ) a_geotag_write_exif_gps ( wp->image, wp->coord, wp->altitude, wp->image_direction, wp->image_direction_ref, TRUE ); } } GtkTreeIter iter, first; gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first ); if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) { vik_waypoint_set_symbol ( wp, NULL ); } else { gchar *sym; gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); vik_waypoint_set_symbol ( wp, sym ); g_free(sym); } gtk_widget_destroy ( dialog ); if ( is_new ) return entered_name; else { *updated = TRUE; // See if name has been changed if ( g_strcmp0 (default_name, entered_name ) ) return entered_name; else return NULL; } } } gtk_widget_destroy ( dialog ); return NULL; }
/* returns TRUE if OK was pressed. */ static gboolean georef_layer_dialog ( VikGeorefLayer **vgl, gpointer vp, GtkWindow *w ) { GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Layer Properties"), w, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL ); /* Default to reject as user really needs to specify map file first */ gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_REJECT ); GtkWidget *response_w = NULL; #if GTK_CHECK_VERSION (2, 20, 0) response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_REJECT ); #endif GtkWidget *table, *wfp_hbox, *wfp_label, *wfp_button, *ce_label, *ce_spin, *cn_label, *cn_spin, *xlabel, *xspin, *ylabel, *yspin, *imagelabel, *imageentry; GtkWidget *pass_along[4]; table = gtk_table_new ( 6, 2, FALSE ); gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0 ); wfp_hbox = gtk_hbox_new ( FALSE, 0 ); wfp_label = gtk_label_new ( _("World File Parameters:") ); wfp_button = gtk_button_new_with_label ( _("Load From File...") ); gtk_box_pack_start ( GTK_BOX(wfp_hbox), wfp_label, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX(wfp_hbox), wfp_button, FALSE, FALSE, 3 ); ce_label = gtk_label_new ( _("Corner pixel easting:") ); ce_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, 0.0, 1500000.0, 1, 5, 0 ), 1, 4 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(ce_spin), _("the UTM \"easting\" value of the upper-left corner pixel of the map") ); cn_label = gtk_label_new ( _("Corner pixel northing:") ); cn_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, 0.0, 9000000.0, 1, 5, 0 ), 1, 4 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(cn_spin), _("the UTM \"northing\" value of the upper-left corner pixel of the map") ); xlabel = gtk_label_new ( _("X (easting) scale (mpp): ")); ylabel = gtk_label_new ( _("Y (northing) scale (mpp): ")); xspin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM, 1, 5, 0 ), 1, 8 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(xspin), _("the scale of the map in the X direction (meters per pixel)") ); yspin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM, 1, 5, 0 ), 1, 8 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(yspin), _("the scale of the map in the Y direction (meters per pixel)") ); imagelabel = gtk_label_new ( _("Map Image:") ); imageentry = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN); if (*vgl) { gtk_spin_button_set_value ( GTK_SPIN_BUTTON(ce_spin), (*vgl)->corner.easting ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cn_spin), (*vgl)->corner.northing ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(xspin), (*vgl)->mpp_easting ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(yspin), (*vgl)->mpp_northing ); if ( (*vgl)->image ) vik_file_entry_set_filename ( VIK_FILE_ENTRY(imageentry), (*vgl)->image ); } else { VikCoord corner_coord; struct UTM utm; vik_viewport_screen_to_coord ( VIK_VIEWPORT(vp), 0, 0, &corner_coord ); vik_coord_to_utm ( &corner_coord, &utm ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(ce_spin), utm.easting ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cn_spin), utm.northing ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(xspin), vik_viewport_get_xmpp ( VIK_VIEWPORT(vp) ) ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(yspin), vik_viewport_get_ympp ( VIK_VIEWPORT(vp) ) ); } gtk_table_attach_defaults ( GTK_TABLE(table), imagelabel, 0, 1, 0, 1 ); gtk_table_attach_defaults ( GTK_TABLE(table), imageentry, 1, 2, 0, 1 ); gtk_table_attach_defaults ( GTK_TABLE(table), wfp_hbox, 0, 2, 1, 2 ); gtk_table_attach_defaults ( GTK_TABLE(table), xlabel, 0, 1, 2, 3 ); gtk_table_attach_defaults ( GTK_TABLE(table), xspin, 1, 2, 2, 3 ); gtk_table_attach_defaults ( GTK_TABLE(table), ylabel, 0, 1, 3, 4 ); gtk_table_attach_defaults ( GTK_TABLE(table), yspin, 1, 2, 3, 4 ); gtk_table_attach_defaults ( GTK_TABLE(table), ce_label, 0, 1, 4, 5 ); gtk_table_attach_defaults ( GTK_TABLE(table), ce_spin, 1, 2, 4, 5 ); gtk_table_attach_defaults ( GTK_TABLE(table), cn_label, 0, 1, 5, 6 ); gtk_table_attach_defaults ( GTK_TABLE(table), cn_spin, 1, 2, 5, 6 ); pass_along[0] = xspin; pass_along[1] = yspin; pass_along[2] = ce_spin; pass_along[3] = cn_spin; g_signal_connect_swapped ( G_OBJECT(wfp_button), "clicked", G_CALLBACK(georef_layer_dialog_load), pass_along ); if ( response_w ) gtk_widget_grab_focus ( response_w ); gtk_widget_show_all ( table ); if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) { if (! *vgl) { *vgl = georef_layer_new ( VIK_VIEWPORT(vp) ); vik_layer_rename ( VIK_LAYER(*vgl), vik_georef_layer_interface.name ); } (*vgl)->corner.easting = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(ce_spin) ); (*vgl)->corner.northing = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(cn_spin) ); (*vgl)->mpp_easting = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(xspin) ); (*vgl)->mpp_northing = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(yspin) ); if ( (!(*vgl)->image) || strcmp( (*vgl)->image, vik_file_entry_get_filename(VIK_FILE_ENTRY(imageentry)) ) != 0 ) { georef_layer_set_image ( *vgl, vik_file_entry_get_filename(VIK_FILE_ENTRY(imageentry)) ); georef_layer_load_image ( *vgl, VIK_VIEWPORT(vp), FALSE ); } gtk_widget_destroy ( GTK_WIDGET(dialog) ); return TRUE; } gtk_widget_destroy ( GTK_WIDGET(dialog) ); return FALSE; }
/* returns TRUE if OK was pressed. */ static gboolean georef_layer_dialog ( VikGeorefLayer *vgl, gpointer vp, GtkWindow *w, gboolean have_apply_button ) { GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Layer Properties"), w, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL ); if ( have_apply_button ) gtk_dialog_add_button ( GTK_DIALOG(dialog), GTK_STOCK_APPLY, GTK_RESPONSE_APPLY ); gtk_dialog_add_button ( GTK_DIALOG(dialog), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT ); /* Default to reject as user really needs to specify map file first */ gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_REJECT ); GtkWidget *response_w = NULL; #if GTK_CHECK_VERSION (2, 20, 0) response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_REJECT ); #endif GtkWidget *table, *wfp_hbox, *wfp_label, *wfp_button, *ce_label, *cn_label, *xlabel, *ylabel, *imagelabel; changeable_widgets cw; GtkBox *dgbox = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))); table = gtk_table_new ( 4, 2, FALSE ); gtk_box_pack_start ( dgbox, table, TRUE, TRUE, 0 ); wfp_hbox = gtk_hbox_new ( FALSE, 0 ); wfp_label = gtk_label_new ( _("World File Parameters:") ); wfp_button = gtk_button_new_with_label ( _("Load From File...") ); gtk_box_pack_start ( GTK_BOX(wfp_hbox), wfp_label, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX(wfp_hbox), wfp_button, FALSE, FALSE, 3 ); ce_label = gtk_label_new ( _("Corner pixel easting:") ); cw.ce_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, -15000000.0, 1500000.0, 1, 5, 0 ), 1, 4 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(cw.ce_spin), _("the UTM \"easting\" value of the upper-left corner pixel of the map") ); cn_label = gtk_label_new ( _("Corner pixel northing:") ); cw.cn_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, -15000000.0, 15000000.0, 1, 5, 0 ), 1, 4 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(cw.cn_spin), _("the UTM \"northing\" value of the upper-left corner pixel of the map") ); xlabel = gtk_label_new ( _("X (easting) scale (mpp): ")); ylabel = gtk_label_new ( _("Y (northing) scale (mpp): ")); cw.x_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM, 1, 5, 0 ), 1, 8 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(cw.x_spin), _("the scale of the map in the X direction (meters per pixel)") ); cw.y_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM, 1, 5, 0 ), 1, 8 ); gtk_widget_set_tooltip_text ( GTK_WIDGET(cw.y_spin), _("the scale of the map in the Y direction (meters per pixel)") ); imagelabel = gtk_label_new ( _("Map Image:") ); cw.imageentry = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN, VF_FILTER_IMAGE, maybe_read_world_file, &cw); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cw.ce_spin), vgl->corner.easting ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cw.cn_spin), vgl->corner.northing ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cw.x_spin), vgl->mpp_easting ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cw.y_spin), vgl->mpp_northing ); if ( vgl->image ) vik_file_entry_set_filename ( VIK_FILE_ENTRY(cw.imageentry), vgl->image ); gtk_table_attach_defaults ( GTK_TABLE(table), imagelabel, 0, 1, 0, 1 ); gtk_table_attach_defaults ( GTK_TABLE(table), cw.imageentry, 1, 2, 0, 1 ); gtk_table_attach_defaults ( GTK_TABLE(table), wfp_hbox, 0, 2, 1, 2 ); gtk_table_attach_defaults ( GTK_TABLE(table), xlabel, 0, 1, 2, 3 ); gtk_table_attach_defaults ( GTK_TABLE(table), cw.x_spin, 1, 2, 2, 3 ); gtk_table_attach_defaults ( GTK_TABLE(table), ylabel, 0, 1, 3, 4 ); gtk_table_attach_defaults ( GTK_TABLE(table), cw.y_spin, 1, 2, 3, 4 ); cw.tabs = gtk_notebook_new(); GtkWidget *table_utm = gtk_table_new ( 3, 2, FALSE ); gtk_table_attach_defaults ( GTK_TABLE(table_utm), ce_label, 0, 1, 0, 1 ); gtk_table_attach_defaults ( GTK_TABLE(table_utm), cw.ce_spin, 1, 2, 0, 1 ); gtk_table_attach_defaults ( GTK_TABLE(table_utm), cn_label, 0, 1, 1, 2 ); gtk_table_attach_defaults ( GTK_TABLE(table_utm), cw.cn_spin, 1, 2, 1, 2 ); GtkWidget *utm_hbox = gtk_hbox_new ( FALSE, 0 ); cw.utm_zone_spin = gtk_spin_button_new ((GtkAdjustment*)gtk_adjustment_new( vgl->corner.zone, 1, 60, 1, 5, 0 ), 1, 0 ); gtk_box_pack_start ( GTK_BOX(utm_hbox), gtk_label_new(_("Zone:")), TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX(utm_hbox), cw.utm_zone_spin, TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX(utm_hbox), gtk_label_new(_("Letter:")), TRUE, TRUE, 0 ); cw.utm_letter_entry = gtk_entry_new (); gtk_entry_set_max_length ( GTK_ENTRY(cw.utm_letter_entry), 1 ); gtk_entry_set_width_chars ( GTK_ENTRY(cw.utm_letter_entry), 2 ); gchar tmp_letter[2]; tmp_letter[0] = vgl->corner.letter; tmp_letter[1] = '\0'; gtk_entry_set_text ( GTK_ENTRY(cw.utm_letter_entry), tmp_letter ); gtk_box_pack_start ( GTK_BOX(utm_hbox), cw.utm_letter_entry, TRUE, TRUE, 0 ); gtk_table_attach_defaults ( GTK_TABLE(table_utm), utm_hbox, 0, 2, 2, 3 ); // Lat/Lon GtkWidget *table_ll = gtk_table_new ( 5, 2, FALSE ); GtkWidget *lat_tl_label = gtk_label_new ( _("Upper left latitude:") ); cw.lat_tl_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new (0.0,-90,90.0,0.05,0.1,0), 0.1, 6 ); GtkWidget *lon_tl_label = gtk_label_new ( _("Upper left longitude:") ); cw.lon_tl_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new (0.0,-180,180.0,0.05,0.1,0), 0.1, 6 ); GtkWidget *lat_br_label = gtk_label_new ( _("Lower right latitude:") ); cw.lat_br_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new (0.0,-90,90.0,0.05,0.1,0), 0.1, 6 ); GtkWidget *lon_br_label = gtk_label_new ( _("Lower right longitude:") ); cw.lon_br_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new (0.0,-180.0,180.0,0.05,0.1,0), 0.1, 6 ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), lat_tl_label, 0, 1, 0, 1 ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), cw.lat_tl_spin, 1, 2, 0, 1 ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), lon_tl_label, 0, 1, 1, 2 ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), cw.lon_tl_spin, 1, 2, 1, 2 ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), lat_br_label, 0, 1, 2, 3 ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), cw.lat_br_spin, 1, 2, 2, 3 ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), lon_br_label, 0, 1, 3, 4 ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), cw.lon_br_spin, 1, 2, 3, 4 ); GtkWidget *calc_mpp_button = gtk_button_new_with_label ( _("Calculate MPP values from coordinates") ); gtk_widget_set_tooltip_text ( calc_mpp_button, _("Enter all corner coordinates before calculating the MPP values from the image size") ); gtk_table_attach_defaults ( GTK_TABLE(table_ll), calc_mpp_button, 0, 2, 4, 5 ); VikCoord vc; vik_coord_load_from_utm (&vc, VIK_COORD_LATLON, &(vgl->corner)); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cw.lat_tl_spin), vc.north_south ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cw.lon_tl_spin), vc.east_west ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cw.lat_br_spin), vgl->ll_br.lat ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(cw.lon_br_spin), vgl->ll_br.lon ); gtk_notebook_append_page(GTK_NOTEBOOK(cw.tabs), GTK_WIDGET(table_utm), gtk_label_new(_("UTM"))); gtk_notebook_append_page(GTK_NOTEBOOK(cw.tabs), GTK_WIDGET(table_ll), gtk_label_new(_("Latitude/Longitude"))); gtk_box_pack_start ( dgbox, cw.tabs, TRUE, TRUE, 0 ); GtkWidget *alpha_hbox = gtk_hbox_new ( FALSE, 0 ); // GTK3 => GtkWidget *alpha_scale = gtk_scale_new_with_range ( GTK_ORIENTATION_HORIZONTAL, 0, 255, 1 ); GtkWidget *alpha_scale = gtk_hscale_new_with_range ( 0, 255, 1 ); gtk_scale_set_digits ( GTK_SCALE(alpha_scale), 0 ); gtk_range_set_value ( GTK_RANGE(alpha_scale), vgl->alpha ); gtk_box_pack_start ( GTK_BOX(alpha_hbox), gtk_label_new(_("Alpha:")), TRUE, TRUE, 0 ); gtk_box_pack_start ( GTK_BOX(alpha_hbox), alpha_scale, TRUE, TRUE, 0 ); gtk_box_pack_start ( dgbox, alpha_hbox, TRUE, TRUE, 0 ); vgl->cw = cw; g_signal_connect ( G_OBJECT(vgl->cw.tabs), "switch-page", G_CALLBACK(switch_tab), vgl ); g_signal_connect ( G_OBJECT(calc_mpp_button), "clicked", G_CALLBACK(calculate_mpp_from_coords), vgl ); g_signal_connect_swapped ( G_OBJECT(wfp_button), "clicked", G_CALLBACK(georef_layer_dialog_load), &cw ); if ( response_w ) gtk_widget_grab_focus ( response_w ); gtk_widget_show_all ( dialog ); // Remember setting the notebook page must be done after the widget is visible. gint page_num = 0; if ( a_settings_get_integer ( VIK_SETTINGS_GEOREF_TAB, &page_num ) ) if ( page_num < 0 || page_num > 1 ) page_num = 0; gtk_notebook_set_current_page ( GTK_NOTEBOOK(cw.tabs), page_num ); gboolean answer = FALSE; gint resp = GTK_RESPONSE_APPLY; while ( resp == GTK_RESPONSE_APPLY ) { resp = gtk_dialog_run ( GTK_DIALOG(dialog) ); if ( resp == GTK_RESPONSE_ACCEPT || resp == GTK_RESPONSE_APPLY ) { align_coords ( vgl ); vgl->corner.easting = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(cw.ce_spin) ); vgl->corner.northing = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(cw.cn_spin) ); vgl->corner.zone = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(cw.utm_zone_spin) ); const gchar *letter = gtk_entry_get_text ( GTK_ENTRY(cw.utm_letter_entry) ); if (*letter) vgl->corner.letter = toupper(*letter); vgl->mpp_easting = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(cw.x_spin) ); vgl->mpp_northing = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(cw.y_spin) ); vgl->ll_br = get_ll_br (vgl); check_br_is_good_or_msg_user ( vgl ); // TODO check if image has changed otherwise no need to regenerate pixbuf if ( !vgl->pixbuf ) { if ( g_strcmp0 (vgl->image, vik_file_entry_get_filename(VIK_FILE_ENTRY(cw.imageentry)) ) != 0 ) { georef_layer_set_image ( vgl, vik_file_entry_get_filename(VIK_FILE_ENTRY(cw.imageentry)) ); georef_layer_load_image ( vgl, VIK_VIEWPORT(vp), FALSE ); } } vgl->alpha = (guint8) gtk_range_get_value ( GTK_RANGE(alpha_scale) ); if ( vgl->pixbuf && vgl->alpha <= 255 ) vgl->pixbuf = ui_pixbuf_set_alpha ( vgl->pixbuf, vgl->alpha ); if ( vgl->scaled && vgl->alpha <= 255 ) vgl->scaled = ui_pixbuf_set_alpha ( vgl->scaled, vgl->alpha ); a_settings_set_integer ( VIK_SETTINGS_GEOREF_TAB, gtk_notebook_get_current_page(GTK_NOTEBOOK(cw.tabs)) ); if ( resp == GTK_RESPONSE_APPLY ) { vik_layer_emit_update ( VIK_LAYER(vgl) ); answer = FALSE; } else answer = TRUE; } } gtk_widget_destroy ( GTK_WIDGET(dialog) ); return answer; }
VikLayerParamData a_uibuilder_widget_get_value ( GtkWidget *widget, VikLayerParam *param ) { VikLayerParamData rv; switch ( param->widget_type ) { case VIK_LAYER_WIDGET_COLOR: gtk_color_button_get_color ( GTK_COLOR_BUTTON(widget), &(rv.c) ); break; case VIK_LAYER_WIDGET_CHECKBUTTON: rv.b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); break; case VIK_LAYER_WIDGET_COMBOBOX: #ifndef GTK_2_2 if ( param->type == VIK_LAYER_PARAM_UINT ) { rv.i = gtk_combo_box_get_active ( GTK_COMBO_BOX(widget) ); if ( rv.i == -1 ) rv.i = 0; rv.u = rv.i; if ( param->extra_widget_data ) rv.u = ((guint *)param->extra_widget_data)[rv.u]; } if ( param->type == VIK_LAYER_PARAM_STRING) { rv.s = gtk_combo_box_get_active_text ( GTK_COMBO_BOX(widget) ); g_debug("%s: %s", __FUNCTION__, rv.s); } break; #endif case VIK_LAYER_WIDGET_RADIOGROUP: case VIK_LAYER_WIDGET_RADIOGROUP_STATIC: rv.u = vik_radio_group_get_selected(VIK_RADIO_GROUP(widget)); if ( param->extra_widget_data ) rv.u = GPOINTER_TO_UINT ( g_list_nth_data(param->extra_widget_data, rv.u) ); break; case VIK_LAYER_WIDGET_SPINBUTTON: if ( param->type == VIK_LAYER_PARAM_UINT ) rv.u = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widget) ); else if ( param->type == VIK_LAYER_PARAM_INT ) rv.i = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widget) ); else rv.d = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(widget) ); break; case VIK_LAYER_WIDGET_ENTRY: case VIK_LAYER_WIDGET_PASSWORD: rv.s = gtk_entry_get_text ( GTK_ENTRY(widget) ); break; case VIK_LAYER_WIDGET_FILEENTRY: case VIK_LAYER_WIDGET_FOLDERENTRY: rv.s = vik_file_entry_get_filename ( VIK_FILE_ENTRY(widget) ); break; case VIK_LAYER_WIDGET_FILELIST: rv.sl = vik_file_list_get_files ( VIK_FILE_LIST(widget) ); break; case VIK_LAYER_WIDGET_HSCALE: if ( param->type == VIK_LAYER_PARAM_UINT ) rv.u = (guint32) gtk_range_get_value ( GTK_RANGE(widget) ); else if ( param->type == VIK_LAYER_PARAM_INT ) rv.i = (gint32) gtk_range_get_value ( GTK_RANGE(widget) ); else rv.d = gtk_range_get_value ( GTK_RANGE(widget) ); break; } return rv; }