示例#1
0
END_HANDLER

BUTTON_CLICKED(setDefaultExportOptions)
{
	nsoption_set_int(margin_top, DEFAULT_MARGIN_TOP_MM);
	nsoption_set_int(margin_bottom, DEFAULT_MARGIN_BOTTOM_MM);
	nsoption_set_int(margin_left, DEFAULT_MARGIN_LEFT_MM);
	nsoption_set_int(margin_right, DEFAULT_MARGIN_RIGHT_MM);
	nsoption_set_int(export_scale, DEFAULT_EXPORT_SCALE * 100);		
	nsoption_set_bool(suppress_images, false);
	nsoption_set_bool(remove_backgrounds, false);
	nsoption_set_bool(enable_loosening, true);
	nsoption_set_bool(enable_PDF_compression, true);
	nsoption_set_bool(enable_PDF_password, false);
			
	SET_SPIN(spinMarginTop, nsoption_int(margin_top));
	SET_SPIN(spinMarginBottom, nsoption_int(margin_bottom));
	SET_SPIN(spinMarginLeft, nsoption_int(margin_left));
	SET_SPIN(spinMarginRight, nsoption_int(margin_right));
	SET_SPIN(spinExportScale, nsoption_int(export_scale));
	SET_CHECK(checkSuppressImages, nsoption_bool(suppress_images));
	SET_CHECK(checkRemoveBackgrounds, nsoption_bool(remove_backgrounds));
	SET_CHECK(checkCompressPDF, nsoption_bool(enable_PDF_compression));
	SET_CHECK(checkPasswordPDF, nsoption_bool(enable_PDF_password));
	SET_CHECK(checkFitPage, nsoption_bool(enable_loosening));
}
示例#2
0
void Options::UpdateInterface(void)
{
	char buffer[2048];
	
#define SET_TEXT(name,data) 	gtk_entry_set_text(GTK_ENTRY(lookup_widget(OptionsWindow,name)),data)
#define SET_SPIN(name,data)		gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(OptionsWindow,name)),data)
#define SET_TOGGLE(name,data)	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(OptionsWindow,name)),data)
#define SET_NUM(name,data)		\
	sprintf(buffer,"%d",data);	\
	gtk_entry_set_text(GTK_ENTRY(lookup_widget(OptionsWindow,name)),buffer);
	
	//	Set all the options window interface	
	SET_TEXT("ScreamerName",ScreamerName.c_str());
	SET_NUM("ScreamerCPUNumbers",ScreamerCPUNumbers);
	SET_SPIN("NumberFrames",NumberFrames);	
	SET_TEXT("CommandDirectory",CommandDirectory.c_str());
	SET_TEXT("ScreamerExecutable",ScreamerExecutable.c_str());
	SET_TEXT("ScreamerConfigDir",ScreamerConfigDir.c_str());
	SET_SPIN("ScreamerPriority",ScreamerPriority);
	SET_SPIN("ScreamerInterval",FindScreamerInterval);
	SET_TEXT("WineCmd",WineCmd.c_str());
	
	//	Set all the main window interface
	gtk_label_set_text(GTK_LABEL(lookup_widget(MainWindow,"ScreamerName")),ScreamerName.c_str());
}
void download(GtkWidget *dialog,TDEINT_PARAM *param)
{
        SET_SPIN(spinbuttonmthreshL,mthreshL);
        SET_SPIN(spinbuttonmthreshC,mthreshC);
        SET_SPIN(spinbuttoncthresh,cthresh);
        SET_SPIN(spinbuttonMI,MI);
        SET_SPIN(spinbuttonAP,AP);

        SET_MENU(comboboxOrder,order);
        SET_MENU(comboboxInterpolate,field);
        SET_MENU(comboboxType,type);
        SET_MENU(comboboxMnt,mtnmode);
        SET_MENU(combobox5,link);
        SET_MENU(combobox6,APType);

        SET_CHECK(checkbuttonChroma,chroma);
        SET_CHECK(checkbuttonTryweave,tryWeave);
        SET_CHECK(checkbuttonDenoise,denoise);
        SET_CHECK(checkbuttonSharp,sharp);
        SET_CHECK(checkbuttonFull,full);
}
示例#4
0
void nsgtk_options_load(void) 
{
	GtkBox *box;
	const char *default_accept_language = "en";
	const char *default_homepage_url = "";
	const char *default_http_proxy_host = "";
	const char *default_http_proxy_auth_user = "";
	const char *default_http_proxy_auth_pass = "";
	int combo_row_count = 0;
	int active_language = 0;
	int proxytype = 0;
	FILE *fp;
	char buf[50];

	/* get widget text */
	if (nsoption_charp(accept_language) != NULL) {
		default_accept_language = nsoption_charp(accept_language);
	}

	if (nsoption_charp(homepage_url) != NULL) {
		default_homepage_url = nsoption_charp(homepage_url);
	}

	if (nsoption_charp(http_proxy_host) != NULL) {
		default_http_proxy_host = nsoption_charp(http_proxy_host);
	}

	if (nsoption_charp(http_proxy_auth_user) != NULL) {
		default_http_proxy_auth_user = nsoption_charp(http_proxy_auth_user);
	}

	if (nsoption_charp(http_proxy_auth_pass) != NULL) {
		default_http_proxy_auth_pass = nsoption_charp(http_proxy_auth_pass);
	}

	if (nsoption_bool(http_proxy) == true) {
		proxytype = nsoption_int(http_proxy_auth) + 1;
	}

	/* Create combobox */
	box = GTK_BOX(gtk_builder_get_object(gladeFile, "combolanguagevbox"));
	comboLanguage = nsgtk_combo_box_text_new();

	/* Populate combobox from languages file */
	if ((languages_file_location != NULL) && 
	    ((fp = fopen(languages_file_location, "r")) != NULL)) {
		LOG(("Used %s for languages", languages_file_location));
		while (fgets(buf, sizeof(buf), fp)) {
			/* Ignore blank lines */
			if (buf[0] == '\0')
				continue;

			/* Remove trailing \n */
			buf[strlen(buf) - 1] = '\0';

			nsgtk_combo_box_text_append_text(comboLanguage, buf);

			if (strcmp(buf, default_accept_language) == 0)
				active_language = combo_row_count;

			combo_row_count++;
		}

		fclose(fp);
	} else {
		LOG(("Failed opening languages file"));
		warn_user("FileError", languages_file_location);
		nsgtk_combo_box_text_append_text(comboLanguage, "en");
	}


	gtk_combo_box_set_active(GTK_COMBO_BOX(comboLanguage), active_language);
	/** \todo localisation */
	gtk_widget_set_tooltip_text(GTK_WIDGET(comboLanguage), 
			"set preferred language for web pages");
	gtk_box_pack_start(box, comboLanguage, FALSE, FALSE, 0);
	gtk_widget_show(comboLanguage);
	
	nsgtk_options_theme_combo();
	
	SET_ENTRY(entryHomePageURL, default_homepage_url);
	SET_BUTTON(setCurrentPage);
	SET_BUTTON(setDefaultPage);
	SET_CHECK(checkHideAdverts, nsoption_bool(block_ads));
	
	SET_CHECK(checkDisablePopups, nsoption_bool(disable_popups));
	SET_CHECK(checkDisablePlugins, nsoption_bool(disable_plugins));
	SET_SPIN(spinHistoryAge, nsoption_int(history_age));
	SET_CHECK(checkHoverURLs, nsoption_bool(hover_urls));
	
	SET_CHECK(checkDisplayRecentURLs, nsoption_bool(url_suggestion));
	SET_CHECK(checkSendReferer, nsoption_bool(send_referer));
        SET_CHECK(checkShowSingleTab, nsoption_bool(show_single_tab));
	
	SET_COMBO(comboProxyType, proxytype);
	SET_ENTRY(entryProxyHost, default_http_proxy_host);

	gtk_widget_set_sensitive(entryProxyHost, proxytype != 0);

	snprintf(buf, sizeof(buf), "%d", nsoption_int(http_proxy_port));	

	SET_ENTRY(entryProxyPort, buf);
	gtk_widget_set_sensitive(entryProxyPort, proxytype != 0);

	SET_ENTRY(entryProxyUser, default_http_proxy_auth_user);

	gtk_widget_set_sensitive(entryProxyUser, proxytype != 0);

	SET_ENTRY(entryProxyPassword, default_http_proxy_auth_pass);

	gtk_widget_set_sensitive(entryProxyPassword, proxytype != 0);

	SET_SPIN(spinMaxFetchers, nsoption_int(max_fetchers));
	SET_SPIN(spinFetchesPerHost, nsoption_int(max_fetchers_per_host));
	SET_SPIN(spinCachedConnections, nsoption_int(max_cached_fetch_handles));

	SET_CHECK(checkResampleImages, nsoption_bool(render_resample));
	SET_SPIN(spinAnimationSpeed, nsoption_int(minimum_gif_delay) / 100.0);
	SET_CHECK(checkDisableAnimations, !nsoption_bool(animate_images));

	SET_FONT(fontSansSerif, nsoption_charp(font_sans));
	SET_FONT(fontSerif, nsoption_charp(font_serif));
	SET_FONT(fontMonospace, nsoption_charp(font_mono));
	SET_FONT(fontCursive, nsoption_charp(font_cursive));
	SET_FONT(fontFantasy, nsoption_charp(font_fantasy));
	SET_COMBO(comboDefault, nsoption_int(font_default));
	SET_SPIN(spinDefaultSize, nsoption_int(font_size) / 10);
	SET_SPIN(spinMinimumSize, nsoption_bool(font_min_size) / 10);
	SET_BUTTON(fontPreview);
	
	SET_COMBO(comboButtonType, nsoption_int(button_type) -1);

	SET_COMBO(comboTabPosition, nsoption_int(position_tab));

	SET_SPIN(spinMemoryCacheSize, nsoption_int(memory_cache_size) >> 20);
	SET_SPIN(spinDiscCacheAge, nsoption_int(disc_cache_age));
	
	SET_CHECK(checkClearDownloads, nsoption_bool(downloads_clear));
	SET_CHECK(checkRequestOverwrite, nsoption_bool(request_overwrite));
	SET_FILE_CHOOSER(fileChooserDownloads, nsoption_charp(downloads_directory));
	
	SET_CHECK(checkFocusNew, nsoption_bool(focus_new));
	SET_CHECK(checkNewBlank, nsoption_bool(new_blank));
	SET_CHECK(checkUrlSearch, nsoption_bool(search_url_bar));
	SET_COMBO(comboSearch, nsoption_int(search_provider));
	
	SET_BUTTON(buttonaddtheme);
	SET_CHECK(sourceButtonTab, nsoption_bool(source_tab));
		
	SET_SPIN(spinMarginTop, nsoption_int(margin_top));
	SET_SPIN(spinMarginBottom, nsoption_int(margin_bottom));
	SET_SPIN(spinMarginLeft, nsoption_int(margin_left));
	SET_SPIN(spinMarginRight, nsoption_int(margin_right));
	SET_SPIN(spinExportScale, nsoption_int(export_scale));
	SET_CHECK(checkSuppressImages, nsoption_bool(suppress_images));
	SET_CHECK(checkRemoveBackgrounds, nsoption_bool(remove_backgrounds));
	SET_CHECK(checkFitPage, nsoption_bool(enable_loosening));
	SET_CHECK(checkCompressPDF, nsoption_bool(enable_PDF_compression));
	SET_CHECK(checkPasswordPDF, nsoption_bool(enable_PDF_password));
	SET_BUTTON(setDefaultExportOptions);
}
示例#5
0
void nsgtk_options_load(void) 
{
	GtkBox *box;
	char languagefile[strlen(res_dir_location) + SLEN("languages") + 1];
	const char *default_accept_language = 
			option_accept_language ? option_accept_language : "en";
	int combo_row_count = 0;
	int active_language = 0;
	int proxytype = 0;
	FILE *fp;
	char buf[50];

	/* Create combobox */
	box = GTK_BOX(glade_xml_get_widget(gladeFile, "combolanguagevbox"));
	comboLanguage = gtk_combo_box_new_text();

	sprintf(languagefile, "%slanguages", res_dir_location);

	/* Populate combobox from languages file */
	fp = fopen((const char *) languagefile, "r");
	if (fp == NULL) {
		LOG(("Failed opening languages file"));
		warn_user("FileError", (const char *) languagefile);
		return;
	}

	while (fgets(buf, sizeof(buf), fp)) {
		/* Ignore blank lines */
		if (buf[0] == '\0')
			continue;

		/* Remove trailing \n */
		buf[strlen(buf) - 1] = '\0';

		gtk_combo_box_append_text(GTK_COMBO_BOX(comboLanguage), buf);

		if (strcmp(buf, default_accept_language) == 0)
			active_language = combo_row_count;

		combo_row_count++;
	}

	fclose(fp);

	gtk_combo_box_set_active(GTK_COMBO_BOX(comboLanguage), active_language);
	/** \todo localisation */
	gtk_widget_set_tooltip_text(GTK_WIDGET(comboLanguage), 
			"set preferred language for web pages");
	gtk_box_pack_start(box, comboLanguage, FALSE, FALSE, 0);
	gtk_widget_show(comboLanguage);
	
	nsgtk_options_theme_combo();
	
	SET_ENTRY(entryHomePageURL,
			option_homepage_url ? option_homepage_url : "");
	SET_BUTTON(setCurrentPage);
	SET_BUTTON(setDefaultPage);
	SET_CHECK(checkHideAdverts, option_block_ads);
	
	SET_CHECK(checkDisablePopups, option_disable_popups);
	SET_CHECK(checkDisablePlugins, option_disable_plugins);
	SET_SPIN(spinHistoryAge, option_history_age);
	SET_CHECK(checkHoverURLs, option_hover_urls);
	
	SET_CHECK(checkDisplayRecentURLs, option_url_suggestion);
	SET_CHECK(checkSendReferer, option_send_referer);
        SET_CHECK(checkShowSingleTab, option_show_single_tab);
	
	if (option_http_proxy == false)
		proxytype = 0;
	else
		proxytype = option_http_proxy_auth + 1;

	SET_COMBO(comboProxyType, proxytype);
	SET_ENTRY(entryProxyHost,
			option_http_proxy_host ? option_http_proxy_host : "");
	gtk_widget_set_sensitive(entryProxyHost, proxytype != 0);

	snprintf(buf, sizeof(buf), "%d", option_http_proxy_port);	

	SET_ENTRY(entryProxyPort, buf);
	gtk_widget_set_sensitive(entryProxyPort, proxytype != 0);

	SET_ENTRY(entryProxyUser, option_http_proxy_auth_user ?
			option_http_proxy_auth_user : "");
	gtk_widget_set_sensitive(entryProxyUser, proxytype != 0);

	SET_ENTRY(entryProxyPassword, option_http_proxy_auth_pass ?
			option_http_proxy_auth_pass : "");
	gtk_widget_set_sensitive(entryProxyPassword, proxytype != 0);

	SET_SPIN(spinMaxFetchers, option_max_fetchers);
	SET_SPIN(spinFetchesPerHost, option_max_fetchers_per_host);
	SET_SPIN(spinCachedConnections, option_max_cached_fetch_handles);

	SET_CHECK(checkResampleImages, option_render_resample);
	SET_SPIN(spinAnimationSpeed, option_minimum_gif_delay / 100.0);
	SET_CHECK(checkDisableAnimations, !option_animate_images);

	SET_FONT(fontSansSerif, option_font_sans);
	SET_FONT(fontSerif, option_font_serif);
	SET_FONT(fontMonospace, option_font_mono);
	SET_FONT(fontCursive, option_font_cursive);
	SET_FONT(fontFantasy, option_font_fantasy);
	SET_COMBO(comboDefault, option_font_default);
	SET_SPIN(spinDefaultSize, option_font_size / 10);
	SET_SPIN(spinMinimumSize, option_font_min_size / 10);
	SET_BUTTON(fontPreview);
	
	SET_COMBO(comboButtonType, option_button_type -1);

	SET_SPIN(spinMemoryCacheSize, option_memory_cache_size >> 20);
	SET_SPIN(spinDiscCacheAge, option_disc_cache_age);
	
	SET_CHECK(checkClearDownloads, option_downloads_clear);
	SET_CHECK(checkRequestOverwrite, option_request_overwrite);
	SET_FILE_CHOOSER(fileChooserDownloads, option_downloads_directory);
	
	SET_CHECK(checkFocusNew, option_focus_new);
	SET_CHECK(checkNewBlank, option_new_blank);
	SET_CHECK(checkUrlSearch, option_search_url_bar);
	SET_COMBO(comboSearch, option_search_provider);
	
	SET_BUTTON(buttonaddtheme);
	SET_CHECK(sourceButtonTab, option_source_tab);
		
	SET_SPIN(spinMarginTop, option_margin_top);
	SET_SPIN(spinMarginBottom, option_margin_bottom);
	SET_SPIN(spinMarginLeft, option_margin_left);
	SET_SPIN(spinMarginRight, option_margin_right);
	SET_SPIN(spinExportScale, option_export_scale);
	SET_CHECK(checkSuppressImages, option_suppress_images);
	SET_CHECK(checkRemoveBackgrounds, option_remove_backgrounds);
	SET_CHECK(checkFitPage, option_enable_loosening);
	SET_CHECK(checkCompressPDF, option_enable_PDF_compression);
	SET_CHECK(checkPasswordPDF, option_enable_PDF_password);
	SET_BUTTON(setDefaultExportOptions);
}
void ConfigurationDialog::SetConfigurations(std::list<RouteMapConfiguration> configurations)
{
    m_bBlockUpdate = true;
    
    m_edited_controls.clear();

    SET_CHOICE(Start);


    bool ult = m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue();
#define STARTTIME (ult ? it->StartTime.FromUTC() : it->StartTime)

    SET_CONTROL_VALUE(STARTTIME.GetDateOnly(), m_dpStartDate, SetValue, wxDateTime, wxDateTime());
    SET_CONTROL_VALUE(STARTTIME, m_tpTime, SetValue, wxDateTime, wxDateTime());
    
    m_bCurrentTime->Enable(m_tpTime->IsEnabled() && m_dpStartDate->IsEnabled());
    m_bGribTime->Enable(m_tpTime->IsEnabled() && m_dpStartDate->IsEnabled());

    SET_SPIN_VALUE(TimeStepHours, (int)((*it).DeltaTime / 3600));
    SET_SPIN_VALUE(TimeStepMinutes, ((int)(*it).DeltaTime / 60) % 60);
    SET_SPIN_VALUE(TimeStepSeconds, (int)(*it).DeltaTime%60);
    
    SET_CONTROL(boatFileName, m_tBoat, SetValue, wxString, _T(""));
    long l = m_tBoat->GetValue().Length();
    m_tBoat->SetSelection(l, l);

    SET_CHOICE(End);

    // if there's a GUID it's an OpenCPN route, for now disable start and end
    // which would invalidate the it
    bool oRoute = false;
    for(auto it : configurations ) {
        if (!it.RouteGUID.IsEmpty()) {
            oRoute = true;
            break;
        }
    }
    m_cStart->Enable(!oRoute);
    m_cEnd->Enable(!oRoute);

    SET_SPIN(FromDegree);
    SET_SPIN(ToDegree);
    SET_CONTROL_VALUE(wxString::Format(_T("%f"), (*it).ByDegrees), m_tByDegrees, SetValue, wxString, _T(""));

    SET_CHOICE_VALUE(Integrator, ((*it).Integrator == RouteMapConfiguration::RUNGE_KUTTA ?
                                  _T("Runge Kutta") : _T("Newton")));

    SET_SPIN(MaxDivertedCourse);
    SET_SPIN(MaxCourseAngle);
    SET_SPIN(MaxSearchAngle);
    SET_SPIN(MaxTrueWindKnots);
    SET_SPIN(MaxApparentWindKnots);

    SET_SPIN(MaxSwellMeters);
    SET_SPIN(MaxLatitude);
    SET_SPIN(TackingTime);
    SET_SPIN(WindVSCurrent);

    SET_CHECKBOX(AvoidCycloneTracks);
    SET_SPIN(CycloneMonths);
    SET_SPIN(CycloneDays);
    SET_SPIN(SafetyMarginLand);

    SET_CHECKBOX(DetectLand);
    SET_CHECKBOX(DetectBoundary);
    SET_CHECKBOX(Currents);
    SET_CHECKBOX(OptimizeTacking);
    
    SET_CHECKBOX(InvertedRegions);
    SET_CHECKBOX(Anchoring);

    SET_CHECKBOX(UseGrib);
    SET_CONTROL(ClimatologyType, m_cClimatologyType, SetSelection, int, -1);
    SET_CHECKBOX(AllowDataDeficient);
    SET_SPIN_VALUE(WindStrength, (int)((*it).WindStrength * 100));

    m_bBlockUpdate = false;
}
void ConfigurationDialog::SetConfigurations(std::list<RouteMapConfiguration> configurations)
{
    m_bBlockUpdate = true;

    SET_CHOICE(Start);

    bool ult = m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue();
#define STARTTIME (ult ? it->StartTime.FromUTC() : it->StartTime)

    SET_CONTROL_VALUE(STARTTIME, m_dpStartDate, SetValue, wxDateTime, wxDateTime());
    SET_CONTROL_VALUE(wxString::Format(_T("%.2f"), STARTTIME.GetHour()
                                       + (double)STARTTIME.GetMinute()/60.0),
                m_tStartHour, SetValue, wxString, _T(""));

    SET_SPIN_VALUE(TimeStepHours, (int)((*it).dt / 3600));
    SET_SPIN_VALUE(TimeStepMinutes, ((int)(*it).dt / 60) % 60);
    SET_SPIN_VALUE(TimeStepSeconds, (int)(*it).dt%60);

    SET_CONTROL(boatFileName, m_tBoat, SetValue, wxString, _T(""));

    SET_CHOICE(End);

    SET_SPIN(FromDegree);
    SET_SPIN(ToDegree);
    SET_CONTROL_VALUE(wxString::Format(_T("%f"), (*it).ByDegrees), m_tByDegrees, SetValue, wxString, _T(""));

    SET_CONTROL_VALUE(((*it).Integrator == RouteMapConfiguration::RUNGE_KUTTA ?
                       _T("Runge Kutta") : _T("Newton")), m_cIntegrator, SetValue, wxString, _T(""));

    SET_SPIN(MaxDivertedCourse);
    SET_SPIN(MaxCourseAngle);
    SET_SPIN(MaxSearchAngle);
    SET_SPIN(MaxTrueWindKnots);
    SET_SPIN(MaxApparentWindKnots);

    SET_SPIN(MaxSwellMeters);
    SET_SPIN(MaxLatitude);
    SET_SPIN(TackingTime);
    SET_SPIN(WindVSCurrent);

    SET_CHECKBOX(AvoidCycloneTracks);
    SET_SPIN(CycloneMonths);
    SET_SPIN(CycloneDays);

    SET_CHECKBOX(DetectLand);
    SET_CHECKBOX(Currents);
    SET_CHECKBOX(InvertedRegions);
    SET_CHECKBOX(Anchoring);

    SET_CHECKBOX(UseGrib);
    SET_CONTROL(ClimatologyType, m_cClimatologyType, SetSelection, int, -1);
    SET_CHECKBOX(AllowDataDeficient);
    SET_SPIN_VALUE(WindStrength, (int)((*it).WindStrength * 100));

    m_bBlockUpdate = false;
}