Exemple #1
0
static void
settings_ok_cb(gpointer data)
{
   SettingsDialog_t *param = (SettingsDialog_t*) data;
   MapInfo_t *info = get_map_info();
   gchar *description;
   GtkTextIter start, end;

   g_strreplace(&info->image_name, gtk_entry_get_text(
      GTK_ENTRY(param->imagename->file)));
   g_strreplace(&info->title, gtk_entry_get_text(GTK_ENTRY(param->title)));
   g_strreplace(&info->author, gtk_entry_get_text(GTK_ENTRY(param->author)));
   g_strreplace(&info->default_url,
		gtk_entry_get_text(GTK_ENTRY(param->default_url)));
   gtk_text_buffer_get_bounds(param->description, &start, &end);
   description = gtk_text_buffer_get_text(param->description, &start, &end,
					  FALSE);
   g_strreplace(&info->description, description);
   g_free(description);

   info->map_format = _map_format;
}
static JSValueRef
txt2html_cb(JSContextRef context,
			JSObjectRef function,
			JSObjectRef thisObject,
			size_t argumentCount,
			const JSValueRef arguments[],
			JSValueRef *exception) {
	gchar *txt;
	JSValueRef result;

	if (argumentCount != 1) {
		return mkexception(context, exception, ARGNOTSUPPLIED);
	}

	txt = arg_to_string(context, arguments[0], exception);
	if (!txt) {
		return JSValueMakeNull(context);
	}

	/* Replace & with & */
	txt = g_strreplace (txt, "&", "&");

	/* Replace " with " */
	txt = g_strreplace (txt, "\"", """);

	/* Replace < with &lt; */
	txt = g_strreplace (txt, "<", "&lt;");

	/* Replace > with &gt; */
	txt = g_strreplace (txt, ">", "&gt;");

	/* Replace newlines with <br> */
	txt = g_strreplace (txt, "\n", "<br>");

	result = string_or_null (context, txt);
	g_free (txt);

	return result;
}
/*
 * Escapes single quote characters in a string.
 *
 * Simple escape function to make sure strings have any/all single
 * quote characters escaped.
 */
static char *
escape(const gchar *text) {
	gchar *escaped;
	gchar *result;

	/* Make sure all newlines, tabs, etc. are escaped. */
	escaped = g_strescape (text, NULL);

	/* Replace ' with \\' */
	result = g_strreplace (escaped, "'", "\\'");

	return result;
}
Exemple #4
0
void
taglist_set(TagList_t *tlist, const gchar *name, const gchar *value)
{
   GList *p;
   Tag_t *tag;

   for (p = tlist->list; p; p = p->next) {
      tag = (Tag_t*) p->data;
      if (!g_ascii_strcasecmp(tag->name, name)) {
         g_strreplace(&tag->value, value);
         return;
      }
   }
   /* Tag not found, add a new tag */
   tlist->list = g_list_append(tlist->list, tag_create(name, value));
}