Example #1
0
gint _check_for_distribution_license(gchar *mod_name)
{
	gchar *distributionlicense;
	gchar *conf_file;

	conf_file = g_strdup_printf("%s/" DOTSWORD "/mods.d/%s.conf",
				    settings.homedir,
				    g_utf8_strdown(mod_name, -1));

	if (g_file_test(conf_file, G_FILE_TEST_EXISTS))
		distributionlicense = get_conf_file_item(conf_file,
							 mod_name,
							 "DistributionLicense");
	else
		distributionlicense = main_get_mod_config_entry(mod_name,
								"DistributionLicense");
	g_free(conf_file);
	XI_message(("DistributionLicense: %s", distributionlicense));

	if (!distributionlicense || (distributionlicense &&
				     g_strstr_len(distributionlicense,
						  strlen(distributionlicense),
						  "Copyright"))) {
		if (main_get_one_option(mod_name, OP_NAME) == 0) {
			gui_generic_warning(_("Please check copyright before exporting!"));
			main_save_module_options(mod_name, OP_NAME, 1);
		}

		return 1;
	}

	return 0;
}
Example #2
0
G_MODULE_EXPORT void on_rename_perscomm_activate(GtkMenuItem *menuitem,
						 gpointer user_data)
{
	if (is_dialog)
		return;

#if defined(WIN32)
	gui_generic_warning(_("Renaming is not available in Windows.\n\n"
			      "Xiphos is limited by Windows' filesystem,\n"
			      "because it disallows the renaming of filename\n"
			      "components of currently-open files,\n"
			      "such as the contents of this commentary.\n"
			      "Therefore, personal commentary renaming is\n"
			      "not available in the Windows environment."));
#else
	GS_DIALOG *info;
	GString *workstr;
	char *s;
	char *datapath_old, *datapath_new;
	const char *conf_old;
	char *conf_new;
	char *sworddir, *modsdir;
	FILE *result;

	// get a new name for the module.
	info = gui_new_dialog();
	info->title = _("Rename Commentary");
	workstr = g_string_new("");
	g_string_printf(workstr, "<span weight=\"bold\">%s</span>",
			_("Choose Commentary Name"));
	info->label_top = workstr->str;
	info->text1 = g_strdup(_("New Name"));
	info->label1 = N_("Name: ");
	info->ok = TRUE;
	info->cancel = TRUE;

	if (gui_gs_dialog(info) != GS_OK)
		goto out1;

	for (s = info->text1; *s; ++s) {
		if (!isalnum(*s) && (*s != '_')) {
			gui_generic_warning_modal(_("Module names must contain [A-Za-z0-9_] only."));
			goto out1;
		}
	}

	if (main_is_module(info->text1)) {
		gui_generic_warning_modal(_("Xiphos already knows a module by that name."));
		goto out1;
	}

	sworddir = g_strdup_printf("%s/" DOTSWORD, settings.homedir);
	modsdir = g_strdup_printf("%s/mods.d", sworddir);

	conf_old =
	    main_get_mod_config_file(settings.CommWindowModule, sworddir);

	conf_new = g_strdup(info->text1); // dirname is lowercase.
	for (s = conf_new; *s; ++s)
		if (isupper(*s))
			*s = tolower(*s);

	datapath_old =
	    main_get_mod_config_entry(settings.CommWindowModule,
				      "DataPath");
	datapath_new = g_strdup(datapath_old);
	if ((s = strstr(datapath_new, "rawfiles/")) == NULL) {
		gui_generic_warning_modal("Malformed datapath in old configuration!");
		goto out2;
	}

	*(s + 9) = '\0'; // skip past "rawfiles/".
	s = g_strdup_printf("%s%s", datapath_new, conf_new);
	g_free(datapath_new); // out with the old...
	datapath_new = s;     // ..and in with the new.

	// move old data directory to new.
	if ((g_chdir(sworddir) != 0) ||
	    (rename(datapath_old, datapath_new) != 0)) {
		gui_generic_warning_modal("Failed to rename directory.");
		goto out2;
	}
	// manufacture new .conf from old.
	g_string_printf(workstr,
			"( cd \"%s\" && sed -e '/^\\[/s|^.*$|[%s]|' -e '/^DataPath=/s|rawfiles/.*$|rawfiles/%s/|' < \"%s\" > \"%s.conf\" ) 2>&1",
			modsdir, info->text1, conf_new, conf_old,
			conf_new);
	if ((result = popen(workstr->str, "r")) == NULL) {
		g_string_printf(workstr,
				_("Failed to create new configuration:\n%s"),
				strerror(errno));
		gui_generic_warning_modal(workstr->str);
		goto out2;
	} else {
		gchar output[258];
		if (fgets(output, 256, result) != NULL) {
			g_string_truncate(workstr, 0);
			g_string_append(workstr,
					_("Configuration build error:\n\n"));
			g_string_append(workstr, output);
			gui_generic_warning_modal(workstr->str);
			goto out2; // necessary?  advisable?
		}
		pclose(result);
	}

	// unlink old conf.
	g_string_printf(workstr, "%s/%s", modsdir, conf_old);
	if (unlink(workstr->str) != 0) {
		g_string_printf(workstr,
				"Unlink of old configuration failed:\n%s",
				strerror(errno));
		gui_generic_warning_modal(workstr->str);
		goto out2;
	}
	main_update_module_lists();
	settings.CommWindowModule = g_strdup(info->text1);
	main_display_commentary(info->text1, settings.currentverse);

out2:
	g_free(conf_new);
	g_free((char *)conf_old);
	g_free(datapath_old);
	g_free(datapath_new);
	g_free(modsdir);
	g_free(sworddir);
out1:
	g_free(info->text1);
	g_free(info);
	g_string_free(workstr, TRUE);
#endif /* !WIN32 */
}
Example #3
0
void gui_display_about_module_dialog(gchar *modname)
{
	const gchar *desc;
	gchar *about;
	const gchar *version, *language, *abbreviation,
	    *size, *promo, *dist, *langtoken, *companion,
	    *category, *feature;
	int feature_count = 0;
	GString *info = g_string_new("");

	desc = main_get_mod_config_entry(modname, "Description");
	about = main_get_mod_config_entry(modname, "About");
	version = main_get_mod_config_entry(modname, "Version");
	size = main_get_mod_config_entry(modname, "InstallSize");
	promo = main_get_mod_config_entry(modname, "ShortPromo");
	dist = main_get_mod_config_entry(modname, "DistributionLicense");
	companion = main_get_mod_config_entry(modname, "Companion");
	category = main_get_mod_config_entry(modname, "Category");
	feature = main_get_mod_config_entry(modname, "Feature");
	langtoken = main_get_mod_config_entry(modname, "Lang");
	language = main_get_module_language(modname);
	abbreviation = main_get_abbreviation(modname);

	info = g_string_append(info,
			       "<center><table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">");
	info = g_string_append(info, "<tr><td valign=\"top\">");

	info = g_string_append(info, _("<b>Module name:</b> "));
	info = g_string_append(info, modname);
	info = g_string_append(info, "<br/>");

	if (abbreviation && *abbreviation) {
		info =
		    g_string_append(info,
				    _("<b>Module abbreviation:</b> "));
		info = g_string_append(info, abbreviation);
		info = g_string_append(info, "<br/>");
	}

	info = g_string_append(info, _("<b>Version:</b> "));
	info = g_string_append(info, ((version && *version)
					  ? version
					  : _("No version stamp found")));
	info = g_string_append(info, "<br/>");

	info = g_string_append(info, _("<b>Type:</b> "));
	if (feature && !strcmp(feature, "DailyDevotion"))
		info = g_string_append(info, _("Daily Devotion"));
	else if (category && !strcmp(category, "Maps"))
		info = g_string_append(info, _("Maps"));
	else if (category && !strcmp(category, "Images"))
		info = g_string_append(info, _("Images"));
	else if (category && !strcmp(category, "Glossaries"))
		info = g_string_append(info, _("Glossary"));
	else if (category &&
		 !strcmp(category,
			 "Cults / Unorthodox / Questionable Material"))
		info = g_string_append(info, _("Cult"));
	else {
		switch (main_get_mod_type(modname)) {
		case TEXT_TYPE:
			info = g_string_append(info, _("Bible"));
			break;
		case COMMENTARY_TYPE:
			info = g_string_append(info, _("Commentary"));
			break;
		case DICTIONARY_TYPE:
			info = g_string_append(info, _("Dictionary"));
			break;
		case BOOK_TYPE:
			info = g_string_append(info, _("General Book"));
			break;
		case PERCOM_TYPE:
			info =
			    g_string_append(info,
					    _("Personal Commentary"));
			break;
		case PRAYERLIST_TYPE:
			info = g_string_append(info, _("Journal"));
			break;
		default:
			info = g_string_append(info, _("Unknown type"));
			break;
		}
	}
	info = g_string_append(info, "<br/>");

	info = g_string_append(info, _("<b>Language:</b> "));
	info = g_string_append(info, ((language && *language)
					  ? language
					  : _("Not specified")));
	info = g_string_append(info, "&nbsp;(");
	info = g_string_append(info, ((langtoken && *langtoken)
					  ? langtoken
					  : "?"));
	info = g_string_append(info, ")");
	info = g_string_append(info, "<br/>");

	if (size && *size) {
		info = g_string_append(info, _("<b>Installed size:</b> "));
		info = g_string_append(info, size);
		info = g_string_append(info, "<br/>");
	}

	if (companion && *companion) {
		info =
		    g_string_append(info,
				    _("<b>Companion module(s):</b></br>"));
		info = g_string_append(info, companion);
		info = g_string_append(info, "<br/>");
	}

	info = g_string_append(info,
			       "</td>"
			       "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>"
			       "<td valign=\"top\">");

	info = g_string_append(info, _("<b>Features:</b>"));
	info = g_string_append(info, "<br/>");
	if (main_check_for_global_option((gchar *)modname, "ThMLHeadings") || main_check_for_global_option((gchar *)modname,
													   "OSISHeadings")) {
		info = g_string_append(info, _("*&nbsp;Headings"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "GBFFootnotes") || main_check_for_global_option((gchar *)modname,
													   "ThMLFootnotes") ||
	    main_check_for_global_option((gchar *)modname,
					 "OSISFootnotes")) {
		info = g_string_append(info, _("*&nbsp;Footnotes"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "ThMLScripref") || main_check_for_global_option((gchar *)modname,
													   "OSISScripref")) {
		info = g_string_append(info, _("*&nbsp;Cross references"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if ((main_check_for_global_option((gchar *)modname, "GBFStrongs")) ||
	    (main_check_for_global_option((gchar *)modname, "ThMLStrongs")) ||
	    (main_check_for_global_option((gchar *)modname, "OSISStrongs"))) {
		info = g_string_append(info, _("*&nbsp;Strong's numbers"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "GBFMorph") ||
	    main_check_for_global_option((gchar *)modname, "ThMLMorph") ||
	    main_check_for_global_option((gchar *)modname, "OSISMorph")) {
		info =
		    g_string_append(info, _("*&nbsp;Morphological tags"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "ThMLLemma") ||
	    main_check_for_global_option((gchar *)modname, "OSISLemma")) {
		info = g_string_append(info, _("*&nbsp;Lemmas"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if ((main_check_for_global_option((gchar *)modname, "GBFRedLetterWords")) ||
	    (main_check_for_global_option((gchar *)modname, "OSISRedLetterWords"))) {
		info =
		    g_string_append(info,
				    _("*&nbsp;Words of Christ in red"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "UTF8GreekAccents")) {
		info = g_string_append(info, _("*&nbsp;Greek accents"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "UTF8HebrewPoints")) {
		info =
		    g_string_append(info, _("*&nbsp;Hebrew Vowel Points"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "UTF8Cantillation")) {
		info =
		    g_string_append(info, _("*&nbsp;Hebrew Cantillation"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "ThMLVariants") || main_check_for_global_option((gchar *)modname,
													   "OSISVariants")) {
		info = g_string_append(info, _("*&nbsp;Variant readings"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "OSISXlit")) {
		info =
		    g_string_append(info,
				    _("*&nbsp;Transliteration forms"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "OSISEnum")) {
		info = g_string_append(info, _("*&nbsp;Enumerations"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "OSISGlosses") || main_check_for_global_option((gchar *)modname, "OSISRuby")) {
		info = g_string_append(info, _("*&nbsp;Glosses"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (main_check_for_global_option((gchar *)modname, "OSISMorphSegmentation")) {
		info =
		    g_string_append(info,
				    _("*&nbsp;Morpheme Segmentation"));
		info = g_string_append(info, "<br/>");
		feature_count++;
	}
	if (feature_count == 0) {
		info =
		    g_string_append(info,
				    _("*&nbsp;<i>No features found</i>"));
		info = g_string_append(info, "<br/>");
	}

	info = g_string_append(info, "</td></tr></table></center>");

	if (dist && *dist) {
		info = g_string_append(info, "<br/><center>");
		info =
		    g_string_append(info,
				    _("<b>Distribution license:</b>"));
		info = g_string_append(info, "<br/>");
		info = g_string_append(info, dist);
		info = g_string_append(info, "</a></center>");
	}

	if (promo) {
		/* if promo looks like just an undecorated url, hotlink it. */
		gboolean just_url = (((strncmp(promo, "http", 4) == 0) ||
				      (strncmp(promo, "www.", 4) == 0)) &&
				     (strchr(promo, ' ') == 0));

		info = g_string_append(info, "<br/><center>");
		info = g_string_append(info, _("<b>Promotional:</b> "));
		info = g_string_append(info, "<br/>");
		if (just_url) {
			g_string_append(info, "<a href=\"");
			if (*promo == 'w')
				info = g_string_append(info, "http://");
			info = g_string_append(info, promo);
			g_string_append(info, "\">");
		}
		info = g_string_append(info, promo);
		if (just_url)
			g_string_append(info, "</a>");
		info = g_string_append(info, "</center>");
	}

	info = g_string_append(info, "<br/><hr width=\"80%%\"/><br/>");
	info = g_string_append(info, about);

	gui_core_display_about_dialog(desc, info->str, modname);
}