[Xfce4-commits] CVS: xfce4/xfdesktop/menueditor add_dialog.c, 1.25, 1.26 add_menu_dialog.c, 1.14, 1.15 dnd.c, 1.17, 1.18 edit_dialog.c, 1.34, 1.35 menueditor.c, 1.59, 1.60 menueditor.h, 1.20, 1.21 move.c, 1.13, 1.14

Brian J. Tarricone bjt23 at cornell.edu
Thu Dec 16 22:06:07 CET 2004


On 12/16/04 21:26, Jean-Fran?ois Wauthy wrote:
> Le jeudi 16 d?cembre 2004 ? 12:19 -0800, Brian J. Tarricone a ?crit :
> > On 12/16/04 20:11, Jean-Fran?ois Wauthy wrote:
> > > Can you confirm me that this patch is working on GLib 2.2 systems
> > > otherwise i'll revert it.
> > 
> > http://developer.gnome.org/doc/API/2.0/glib/glib-Simple-XML-Subset-Parser.html#g-markup-printf-escaped
> > 
> > it says g_markup_printf_escaped() is glib 2.4 and above only.  the API docs
> > are good for you ^_^.
> i know that... that's why i added it to menueditor.c between a #if !
> GLIB_CHECK_VERSION (2, 4, 0) and a #endif, i want to know if it's
> working with that

am i looking at something wrong then? xfdesktop/menueditor/add_dialog.c:338
uses g_markup_printf_escaped(), but i don't see a GLIB_CHECK_VERSION()
anywhere.

	-brian


>  
> > 
> > 	-brian
> > 
> > > 
> > > Thanks in advance
> > > 
> > > Le jeudi 16 d?cembre 2004 ? 19:04 +0000, Jean-Fran?ois Wauthy a ?crit :
> > > > Update of /var/cvs/xfce/xfce4/xfdesktop/menueditor
> > > > In directory espresso.foo-projects.org:/tmp/cvs-serv12889
> > > > 
> > > > Modified Files:
> > > > 	add_dialog.c add_menu_dialog.c dnd.c edit_dialog.c 
> > > > 	menueditor.c menueditor.h move.c 
> > > > Log Message:
> > > > fix #598 using a glib 2.4 func, i added a copy in the menueditor code conditionnaly compiled but it needs testing
> > > > 
> > > > Index: add_dialog.c
> > > > ===================================================================
> > > > RCS file: /var/cvs/xfce/xfce4/xfdesktop/menueditor/add_dialog.c,v
> > > > retrieving revision 1.25
> > > > retrieving revision 1.26
> > > > diff -u -d -r1.25 -r1.26
> > > > --- add_dialog.c	23 Oct 2004 10:32:23 -0000	1.25
> > > > +++ add_dialog.c	16 Dec 2004 19:04:06 -0000	1.26
> > > > @@ -335,8 +335,8 @@
> > > >          xmlSetProp (node, "name", gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > >          xmlSetProp (node, "cmd", gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > >  
> > > > -        name = g_strdup_printf (NAME_FORMAT, gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > > -        command = g_strdup_printf (COMMAND_FORMAT, gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > > +        name = g_markup_printf_escaped (NAME_FORMAT, gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > > +        command = g_markup_printf_escaped (COMMAND_FORMAT, gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > >          break;
> > > >        case SUBMENU:
> > > >          /* Set node name */
> > > > @@ -346,14 +346,14 @@
> > > >          xmlSetProp (node, "visible", "yes");
> > > >  
> > > > 
> > > > -        name = g_strdup_printf (MENU_FORMAT, gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > > +        name = g_markup_printf_escaped (MENU_FORMAT, gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > >          command = g_strdup ("");
> > > >          break;
> > > >        case SEPARATOR:
> > > >          /* Set node name */
> > > >          xmlNodeSetName (node, "separator");
> > > >  
> > > > -        name = g_strdup_printf (SEPARATOR_FORMAT, _("--- separator ---"));
> > > > +        name = g_markup_printf_escaped (SEPARATOR_FORMAT, _("--- separator ---"));
> > > >          command = g_strdup ("");
> > > >          break;
> > > >        case TITLE:
> > > > @@ -364,7 +364,7 @@
> > > >          xmlSetProp (node, "visible", "yes");
> > > >  
> > > > 
> > > > -        name = g_strdup_printf (TITLE_FORMAT, gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > > +        name = g_markup_printf_escaped (TITLE_FORMAT, gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > >          command = g_strdup ("");
> > > >          break;
> > > >        case INCLUDE:
> > > > @@ -377,8 +377,8 @@
> > > >          xmlSetProp (node, "visible", "yes");
> > > >          xmlSetProp (node, "cmd", "quit");
> > > >  
> > > > -        name = g_strdup_printf (BUILTIN_FORMAT, gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > > -        command = g_strdup_printf (COMMAND_FORMAT, _("quit"));
> > > > +        name = g_markup_printf_escaped (BUILTIN_FORMAT, gtk_entry_get_text (GTK_ENTRY (entry_name)));
> > > > +        command = g_markup_printf_escaped (COMMAND_FORMAT, _("quit"));
> > > >        }
> > > >  
> > > >        /* Append entry in the tree */
> > > > 
> > > > Index: add_menu_dialog.c
> > > > ===================================================================
> > > > RCS file: /var/cvs/xfce/xfce4/xfdesktop/menueditor/add_menu_dialog.c,v
> > > > retrieving revision 1.14
> > > > retrieving revision 1.15
> > > > diff -u -d -r1.14 -r1.15
> > > > --- add_menu_dialog.c	23 Oct 2004 10:32:23 -0000	1.14
> > > > +++ add_menu_dialog.c	16 Dec 2004 19:04:06 -0000	1.15
> > > > @@ -215,8 +215,8 @@
> > > >          xmlSetProp (node, "type", "file");
> > > >          xmlSetProp (node, "src", gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > >  
> > > > -        name = g_strdup_printf (INCLUDE_FORMAT, _("--- include ---"));
> > > > -        source = g_strdup_printf (INCLUDE_PATH_FORMAT, gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > > +        name = g_markup_printf_escaped (INCLUDE_FORMAT, _("--- include ---"));
> > > > +        source = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > >        }
> > > >  
> > > >        if (controls.menu_type == SYSTEM) {
> > > > @@ -231,8 +231,8 @@
> > > >          if (gtk_option_menu_get_history (GTK_OPTION_MENU (controls.optionmenu_style)) != 0)
> > > >            xmlSetProp (node, "style", "multilevel");
> > > >  
> > > > -        name = g_strdup_printf (INCLUDE_FORMAT, _("--- include ---"));
> > > > -        source = g_strdup_printf (INCLUDE_PATH_FORMAT, _("system"));
> > > > +        name = g_markup_printf_escaped (INCLUDE_FORMAT, _("--- include ---"));
> > > > +        source = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, _("system"));
> > > >        }
> > > >  
> > > >        /* Append entry in the tree */
> > > > 
> > > > Index: dnd.c
> > > > ===================================================================
> > > > RCS file: /var/cvs/xfce/xfce4/xfdesktop/menueditor/dnd.c,v
> > > > retrieving revision 1.17
> > > > retrieving revision 1.18
> > > > diff -u -d -r1.17 -r1.18
> > > > --- dnd.c	23 Oct 2004 10:32:23 -0000	1.17
> > > > +++ dnd.c	16 Dec 2004 19:04:06 -0000	1.18
> > > > @@ -132,11 +132,11 @@
> > > >          hidden = TRUE;
> > > >  
> > > >        if (!xmlStrcmp (node_to_insert->name, "title")) {
> > > > -        str_name = g_strdup_printf (TITLE_FORMAT, prop_name);
> > > > +        str_name = g_markup_printf_escaped (TITLE_FORMAT, prop_name);
> > > >        }
> > > >        else if (!xmlStrcmp (node_to_insert->name, "app")) {
> > > > -        str_name = g_strdup_printf (NAME_FORMAT, prop_name);
> > > > -        str_command = g_strdup_printf (COMMAND_FORMAT, prop_cmd);
> > > > +        str_name = g_markup_printf_escaped (NAME_FORMAT, prop_name);
> > > > +        str_command = g_markup_printf_escaped (COMMAND_FORMAT, prop_cmd);
> > > >        }
> > > >        else if (!xmlStrcmp (node_to_insert->name, "menu")) {
> > > >          if (gtk_tree_path_is_descendant (path, path_to_insert)) {
> > > > @@ -147,22 +147,22 @@
> > > >            return;
> > > >          }
> > > >  
> > > > -        str_name = g_strdup_printf (MENU_FORMAT, prop_name);
> > > > +        str_name = g_markup_printf_escaped (MENU_FORMAT, prop_name);
> > > >        }
> > > >        else if (!xmlStrcmp (node_to_insert->name, "separator")) {
> > > > -        str_name = g_strdup_printf (SEPARATOR_FORMAT, _("--- separator ---"));
> > > > +        str_name = g_markup_printf_escaped (SEPARATOR_FORMAT, _("--- separator ---"));
> > > >        }
> > > >        else if (!xmlStrcmp (node_to_insert->name, "include")) {
> > > > -        str_name = g_strdup_printf (INCLUDE_FORMAT, _("--- include ---"));
> > > > +        str_name = g_markup_printf_escaped (INCLUDE_FORMAT, _("--- include ---"));
> > > >  
> > > >          if (xmlHasProp (node_to_insert, "src"))
> > > > -          str_command = g_strdup_printf (INCLUDE_PATH_FORMAT, prop_src);
> > > > +          str_command = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, prop_src);
> > > >          else
> > > > -          str_command = g_strdup_printf (INCLUDE_PATH_FORMAT, _("system"));
> > > > +          str_command = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, _("system"));
> > > >        }
> > > >        else if (!xmlStrcmp (node_to_insert->name, "builtin")) {
> > > > -        str_name = g_strdup_printf (NAME_FORMAT, prop_name);
> > > > -        str_command = g_strdup_printf (COMMAND_FORMAT, prop_cmd);
> > > > +        str_name = g_markup_printf_escaped (NAME_FORMAT, prop_name);
> > > > +        str_command = g_markup_printf_escaped (COMMAND_FORMAT, prop_cmd);
> > > >        }
> > > >  
> > > >        /* move in the gtk and xml tree */
> > > > @@ -284,8 +284,8 @@
> > > >  
> > > >        gtk_tree_store_insert_before (me->treestore, &iter, NULL, &iter_target);
> > > >  
> > > > -      name = g_strdup_printf (NAME_FORMAT, value_name);
> > > > -      command = g_strdup_printf (COMMAND_FORMAT, value_command);
> > > > +      name = g_markup_printf_escaped (NAME_FORMAT, value_name);
> > > > +      command = g_markup_printf_escaped (COMMAND_FORMAT, value_command);
> > > >  
> > > >        gtk_tree_store_set (me->treestore, &iter,
> > > >                            ICON_COLUMN, icon, NAME_COLUMN, name, COMMAND_COLUMN, command, POINTER_COLUMN, node, -1);
> > > > @@ -358,8 +358,8 @@
> > > >  
> > > >        gtk_tree_store_insert_before (me->treestore, &iter, NULL, &iter_target);
> > > >  
> > > > -      name = g_strdup_printf (NAME_FORMAT, value_name);
> > > > -      command = g_strdup_printf (COMMAND_FORMAT, value_command);
> > > > +      name = g_markup_printf_escaped (NAME_FORMAT, value_name);
> > > > +      command = g_markup_printf_escaped (COMMAND_FORMAT, value_command);
> > > >  
> > > >        gtk_tree_store_set (me->treestore, &iter,
> > > >                            ICON_COLUMN, icon, NAME_COLUMN, name, COMMAND_COLUMN, command, POINTER_COLUMN, node, -1);
> > > > 
> > > > Index: edit_dialog.c
> > > > ===================================================================
> > > > RCS file: /var/cvs/xfce/xfce4/xfdesktop/menueditor/edit_dialog.c,v
> > > > retrieving revision 1.34
> > > > retrieving revision 1.35
> > > > diff -u -d -r1.34 -r1.35
> > > > --- edit_dialog.c	23 Oct 2004 10:32:23 -0000	1.34
> > > > +++ edit_dialog.c	16 Dec 2004 19:04:06 -0000	1.35
> > > > @@ -491,23 +491,23 @@
> > > >            xmlRemoveProp (term_prop);
> > > >          }
> > > >  
> > > > -        name = g_strdup_printf (NAME_FORMAT, gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > > -        command = g_strdup_printf (COMMAND_FORMAT, gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > > +        name = g_markup_printf_escaped (NAME_FORMAT, gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > > +        command = g_markup_printf_escaped (COMMAND_FORMAT, gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > >        }
> > > >        else if (!xmlStrcmp (node->name, (xmlChar *) "menu")) {
> > > > -        name = g_strdup_printf (MENU_FORMAT, gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > > +        name = g_markup_printf_escaped (MENU_FORMAT, gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > >          command = g_strdup ("");
> > > >  
> > > >          xmlSetProp (node, "name", gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > >        }
> > > >        else if (!xmlStrcmp (node->name, (xmlChar *) "builtin")) {
> > > > -        name = g_strdup_printf (BUILTIN_FORMAT, gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > > -        command = g_strdup_printf (COMMAND_FORMAT, _("quit"));
> > > > +        name = g_markup_printf_escaped (BUILTIN_FORMAT, gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > > +        command = g_markup_printf_escaped (COMMAND_FORMAT, _("quit"));
> > > >  
> > > >          xmlSetProp (node, "name", gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > >        }
> > > >        else if (!xmlStrcmp (node->name, (xmlChar *) "title")) {
> > > > -        name = g_strdup_printf (TITLE_FORMAT, gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > > +        name = g_markup_printf_escaped (TITLE_FORMAT, gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > >          command = g_strdup ("");
> > > >  
> > > >          xmlSetProp (node, "name", gtk_entry_get_text (GTK_ENTRY (name_entry)));
> > > > @@ -518,8 +518,8 @@
> > > >  
> > > >          switch (controls.menu_type) {
> > > >          case MENUFILE:
> > > > -          name = g_strdup_printf (INCLUDE_FORMAT, _("--- include ---"));
> > > > -          command = g_strdup_printf (INCLUDE_PATH_FORMAT, gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > > +          name = g_markup_printf_escaped (INCLUDE_FORMAT, _("--- include ---"));
> > > > +          command = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > >  
> > > >            xmlSetProp (node, "type", "file");
> > > >            xmlSetProp (node, "src", gtk_entry_get_text (GTK_ENTRY (me->entry_command)));
> > > > @@ -531,8 +531,8 @@
> > > >            xmlRemoveProp (style_prop);
> > > >            break;
> > > >          case SYSTEM:
> > > > -          name = g_strdup_printf (INCLUDE_FORMAT, _("--- include ---"));
> > > > -          command = g_strdup_printf (INCLUDE_PATH_FORMAT, _("system"));
> > > > +          name = g_markup_printf_escaped (INCLUDE_FORMAT, _("--- include ---"));
> > > > +          command = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, _("system"));
> > > >  
> > > >            xmlSetProp (node, "type", "system");
> > > >  
> > > > @@ -559,6 +559,7 @@
> > > >        g_free (name);
> > > >        g_free (command);
> > > >  
> > > > +
> > > >        me->menu_modified = TRUE;
> > > >        gtk_widget_set_sensitive (me->file_menu_save, TRUE);
> > > >        gtk_widget_set_sensitive (me->toolbar_save, TRUE);
> > > > 
> > > > Index: menueditor.c
> > > > ===================================================================
> > > > RCS file: /var/cvs/xfce/xfce4/xfdesktop/menueditor/menueditor.c,v
> > > > retrieving revision 1.59
> > > > retrieving revision 1.60
> > > > diff -u -d -r1.59 -r1.60
> > > > --- menueditor.c	23 Oct 2004 10:32:23 -0000	1.59
> > > > +++ menueditor.c	16 Dec 2004 19:04:06 -0000	1.60
> > > > @@ -69,7 +69,227 @@
> > > >  /* Main window */
> > > >  static void create_main_window (MenuEditor * me);
> > > >  
> > > > +#if !GLIB_CHECK_VERSION (2, 4, 0)
> > > > +/*******************************************************/
> > > > +/* Copy of g_markup_printf_escaped from the glib 2.4.8 */
> > > > +/*******************************************************/
> > > > +static const char *
> > > > +find_conversion (const char *format, const char **after)
> > > > +{
> > > > +  const char *start = format;
> > > > +  const char *cp;
> > > > +
> > > > +  while (*start != '\0' && *start != '%')
> > > > +    start++;
> > > > +
> > > > +  if (*start == '\0') {
> > > > +    *after = start;
> > > > +    return NULL;
> > > > +  }
> > > > +
> > > > +  cp = start + 1;
> > > > +
> > > > +  if (*cp == '\0') {
> > > > +    *after = cp;
> > > > +    return NULL;
> > > > +  }
> > > > +
> > > > +  /* Test for positional argument.  */
> > > > +  if (*cp >= '0' && *cp <= '9') {
> > > > +    const char *np;
> > > > +
> > > > +    for (np = cp; *np >= '0' && *np <= '9'; np++);
> > > > +    if (*np == '$')
> > > > +      cp = np + 1;
> > > > +  }
> > > > +
> > > > +  /* Skip the flags.  */
> > > > +  for (;;) {
> > > > +    if (*cp == '\'' || *cp == '-' || *cp == '+' || *cp == ' ' || *cp == '#' || *cp == '0')
> > > > +      cp++;
> > > > +    else
> > > > +      break;
> > > > +  }
> > > > +
> > > > +  /* Skip the field width.  */
> > > > +  if (*cp == '*') {
> > > > +    cp++;
> > > >  
> > > > +    /* Test for positional argument.  */
> > > > +    if (*cp >= '0' && *cp <= '9') {
> > > > +      const char *np;
> > > > +
> > > > +      for (np = cp; *np >= '0' && *np <= '9'; np++);
> > > > +      if (*np == '$')
> > > > +        cp = np + 1;
> > > > +    }
> > > > +  }
> > > > +  else {
> > > > +    for (; *cp >= '0' && *cp <= '9'; cp++);
> > > > +  }
> > > > +
> > > > +  /* Skip the precision.  */
> > > > +  if (*cp == '.') {
> > > > +    cp++;
> > > > +    if (*cp == '*') {
> > > > +      /* Test for positional argument.  */
> > > > +      if (*cp >= '0' && *cp <= '9') {
> > > > +        const char *np;
> > > > +
> > > > +        for (np = cp; *np >= '0' && *np <= '9'; np++);
> > > > +        if (*np == '$')
> > > > +          cp = np + 1;
> > > > +      }
> > > > +    }
> > > > +    else {
> > > > +      for (; *cp >= '0' && *cp <= '9'; cp++);
> > > > +    }
> > > > +  }
> > > > +
> > > > +  /* Skip argument type/size specifiers.  */
> > > > +  while (*cp == 'h' || *cp == 'L' || *cp == 'l' || *cp == 'j' || *cp == 'z' || *cp == 'Z' || *cp == 't')
> > > > +    cp++;
> > > > +
> > > > +  /* Skip the conversion character.  */
> > > > +  cp++;
> > > > +
> > > > +  *after = cp;
> > > > +  return start;
> > > > +}
> > > > +
> > > > +static char *
> > > > +g_markup_vprintf_escaped (const char *format, va_list args)
> > > > +{
> > > > +  GString *format1;
> > > > +  GString *format2;
> > > > +  GString *result = NULL;
> > > > +  gchar *output1 = NULL;
> > > > +  gchar *output2 = NULL;
> > > > +  const char *p, *op1, *op2;
> > > > +  va_list args2;
> > > > +
> > > > +  /* The technique here, is that we make two format strings that
> > > > +   * have the identical conversions in the identical order to the
> > > > +   * original strings, but differ in the text in-between. We
> > > > +   * then use the normal g_strdup_vprintf() to format the arguments
> > > > +   * with the two new format strings. By comparing the results,
> > > > +   * we can figure out what segments of the output come from
> > > > +   * the the original format string, and what from the arguments,
> > > > +   * and thus know what portions of the string to escape.
> > > > +   *
> > > > +   * For instance, for:
> > > > +   *
> > > > +   *  g_markup_printf_escaped ("%s ate %d apples", "Susan & Fred", 5);
> > > > +   *
> > > > +   * We form the two format strings "%sX%dX" and %sY%sY". The results
> > > > +   * of formatting with those two strings are
> > > > +   *
> > > > +   * "%sX%dX" => "Susan & FredX5X"
> > > > +   * "%sY%dY" => "Susan & FredY5Y"
> > > > +   *
> > > > +   * To find the span of the first argument, we find the first position
> > > > +   * where the two arguments differ, which tells us that the first
> > > > +   * argument formatted to "Susan & Fred". We then escape that
> > > > +   * to "Susan & Fred" and join up with the intermediate portions
> > > > +   * of the format string and the second argument to get
> > > > +   * "Susan & Fred ate 5 apples".
> > > > +   */
> > > > +
> > > > +  /* Create the two modified format strings
> > > > +   */
> > > > +  format1 = g_string_new (NULL);
> > > > +  format2 = g_string_new (NULL);
> > > > +  p = format;
> > > > +  while (TRUE) {
> > > > +    const char *after;
> > > > +    const char *conv = find_conversion (p, &after);
> > > > +    if (!conv)
> > > > +      break;
> > > > +
> > > > +    g_string_append_len (format1, conv, after - conv);
> > > > +    g_string_append_c (format1, 'X');
> > > > +    g_string_append_len (format2, conv, after - conv);
> > > > +    g_string_append_c (format2, 'Y');
> > > > +
> > > > +    p = after;
> > > > +  }
> > > > +
> > > > +  /* Use them to format the arguments
> > > > +   */
> > > > +  G_VA_COPY (args2, args);
> > > > +
> > > > +  output1 = g_strdup_vprintf (format1->str, args);
> > > > +  va_end (args);
> > > > +  if (!output1)
> > > > +    goto cleanup;
> > > > +
> > > > +  output2 = g_strdup_vprintf (format2->str, args2);
> > > > +  va_end (args2);
> > > > +  if (!output2)
> > > > +    goto cleanup;
> > > > +
> > > > +  result = g_string_new (NULL);
> > > > +
> > > > +  /* Iterate through the original format string again,
> > > > +   * copying the non-conversion portions and the escaped
> > > > +   * converted arguments to the output string.
> > > > +   */
> > > > +  op1 = output1;
> > > > +  op2 = output2;
> > > > +  p = format;
> > > > +  while (TRUE) {
> > > > +    const char *after;
> > > > +    const char *output_start;
> > > > +    const char *conv = find_conversion (p, &after);
> > > > +    char *escaped;
> > > > +
> > > > +    if (!conv) {                /* The end, after points to the trailing \0 */
> > > > +      g_string_append_len (result, p, after - p);
> > > > +      break;
> > > > +    }
> > > > +
> > > > +    g_string_append_len (result, p, conv - p);
> > > > +    output_start = op1;
> > > > +    while (*op1 == *op2) {
> > > > +      op1++;
> > > > +      op2++;
> > > > +    }
> > > > +
> > > > +    escaped = g_markup_escape_text (output_start, op1 - output_start);
> > > > +    g_string_append (result, escaped);
> > > > +    g_free (escaped);
> > > > +
> > > > +    p = after;
> > > > +    op1++;
> > > > +    op2++;
> > > > +  }
> > > > +
> > > > +cleanup:
> > > > +  g_string_free (format1, TRUE);
> > > > +  g_string_free (format2, TRUE);
> > > > +  g_free (output1);
> > > > +  g_free (output2);
> > > > +
> > > > +  if (result)
> > > > +    return g_string_free (result, FALSE);
> > > > +  else
> > > > +    return NULL;
> > > > +}
> > > > +
> > > > +char *
> > > > +g_markup_printf_escaped (const char *format, ...)
> > > > +{
> > > > +  char *result;
> > > > +  va_list args;
> > > > +
> > > > +  DBG ("using the embedded version of g_markup_printf_escaped ()");
> > > > +  va_start (args, format);
> > > > +  result = g_markup_vprintf_escaped (format, args);
> > > > +  va_end (args);
> > > > +
> > > > +  return result;
> > > > +}
> > > > +#endif
> > > >  /*****************************/
> > > >  /* Manage icon theme changes */
> > > >  /*****************************/
> > > > @@ -358,7 +578,7 @@
> > > >  
> > > >      /* separator */
> > > >      if (!xmlStrcmp (menu->name, (xmlChar *) "separator")) {
> > > > -      name = g_strdup_printf (SEPARATOR_FORMAT, _("--- separator ---"));
> > > > +      name = g_markup_printf_escaped (SEPARATOR_FORMAT, _("--- separator ---"));
> > > >  
> > > >        gtk_tree_store_append (me->treestore, &c, p);
> > > >        gtk_tree_store_set (me->treestore, &c,
> > > > @@ -370,8 +590,8 @@
> > > >        prop_name = xmlGetProp (menu, "name");
> > > >        prop_cmd = xmlGetProp (menu, "cmd");
> > > >  
> > > > -      name = g_strdup_printf (NAME_FORMAT, prop_name);
> > > > -      cmd = g_strdup_printf (COMMAND_FORMAT, prop_cmd);
> > > > +      name = g_markup_printf_escaped (NAME_FORMAT, prop_name);
> > > > +      cmd = g_markup_printf_escaped (COMMAND_FORMAT, prop_cmd);
> > > >  
> > > >        gtk_tree_store_append (me->treestore, &c, p);
> > > >        gtk_tree_store_set (me->treestore, &c,
> > > > @@ -383,7 +603,7 @@
> > > >      if (!xmlStrcmp (menu->name, (xmlChar *) "menu")) {
> > > >        prop_name = xmlGetProp (menu, "name");
> > > >  
> > > > -      name = g_strdup_printf (MENU_FORMAT, prop_name);
> > > > +      name = g_markup_printf_escaped (MENU_FORMAT, prop_name);
> > > >  
> > > >        gtk_tree_store_append (me->treestore, &c, p);
> > > >        gtk_tree_store_set (me->treestore, &c,
> > > > @@ -397,12 +617,12 @@
> > > >        prop_type = xmlGetProp (menu, "type");
> > > >        prop_src = xmlGetProp (menu, "src");
> > > >  
> > > > -      name = g_strdup_printf (INCLUDE_FORMAT, _("--- include ---"));
> > > > +      name = g_markup_printf_escaped (INCLUDE_FORMAT, _("--- include ---"));
> > > >  
> > > >        if (!xmlStrcmp (prop_type, (xmlChar *) "system"))
> > > > -        src = g_strdup_printf (INCLUDE_PATH_FORMAT, _("system"));
> > > > +        src = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, _("system"));
> > > >        else
> > > > -        src = g_strdup_printf (INCLUDE_PATH_FORMAT, prop_src);
> > > > +        src = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, prop_src);
> > > >  
> > > >        gtk_tree_store_append (me->treestore, &c, p);
> > > >        gtk_tree_store_set (me->treestore, &c,
> > > > @@ -415,8 +635,8 @@
> > > >        prop_name = xmlGetProp (menu, "name");
> > > >        prop_cmd = xmlGetProp (menu, "cmd");
> > > >  
> > > > -      name = g_strdup_printf (NAME_FORMAT, prop_name);
> > > > -      cmd = g_strdup_printf (COMMAND_FORMAT, prop_cmd);
> > > > +      name = g_markup_printf_escaped (NAME_FORMAT, prop_name);
> > > > +      cmd = g_markup_printf_escaped (COMMAND_FORMAT, prop_cmd);
> > > >  
> > > >        gtk_tree_store_append (me->treestore, &c, p);
> > > >        gtk_tree_store_set (me->treestore, &c,
> > > > @@ -427,7 +647,7 @@
> > > >      if (!xmlStrcmp (menu->name, (xmlChar *) "title")) {
> > > >        prop_name = xmlGetProp (menu, "name");
> > > >  
> > > > -      title = g_strdup_printf (TITLE_FORMAT, prop_name);
> > > > +      title = g_markup_printf_escaped (TITLE_FORMAT, prop_name);
> > > >  
> > > >        gtk_tree_store_append (me->treestore, &c, p);
> > > >        gtk_tree_store_set (me->treestore, &c,
> > > > @@ -967,8 +1187,9 @@
> > > >  
> > > >    /* DND */
> > > >    GtkTargetEntry gte[] = { {"XFCE_MENU_ENTRY", GTK_TARGET_SAME_WIDGET, 0},
> > > > -			   {"text/plain", 0, 1},
> > > > -			   {"application/x-desktop", 0, 2} };
> > > > +  {"text/plain", 0, 1},
> > > > +  {"application/x-desktop", 0, 2}
> > > > +  };
> > > >  
> > > >    me->accel_group = gtk_accel_group_new ();
> > > >    me->icon_theme = xfce_icon_theme_get_for_screen (NULL);
> > > > 
> > > > Index: menueditor.h
> > > > ===================================================================
> > > > RCS file: /var/cvs/xfce/xfce4/xfdesktop/menueditor/menueditor.h,v
> > > > retrieving revision 1.20
> > > > retrieving revision 1.21
> > > > diff -u -d -r1.20 -r1.21
> > > > --- menueditor.h	23 Oct 2004 10:32:23 -0000	1.20
> > > > +++ menueditor.h	16 Dec 2004 19:04:06 -0000	1.21
> > > > @@ -51,6 +51,10 @@
> > > >  /***********/
> > > >  /* Globals */
> > > >  /***********/
> > > > +#if !GLIB_CHECK_VERSION (2, 4, 0)
> > > > +char *g_markup_printf_escaped (const char *format, ...);
> > > > +#endif
> > > > +
> > > >  void browse_command_cb (GtkWidget * widget, gpointer data);
> > > >  void browse_icon_cb (GtkWidget * widget, gpointer data);
> > > >  gboolean command_exists (const gchar * command);
> > > > 
> > > > Index: move.c
> > > > ===================================================================
> > > > RCS file: /var/cvs/xfce/xfce4/xfdesktop/menueditor/move.c,v
> > > > retrieving revision 1.13
> > > > retrieving revision 1.14
> > > > diff -u -d -r1.13 -r1.14
> > > > --- move.c	23 Oct 2004 10:32:23 -0000	1.13
> > > > +++ move.c	16 Dec 2004 19:04:06 -0000	1.14
> > > > @@ -74,8 +74,8 @@
> > > >      prop_name = xmlGetProp (node, "name");
> > > >      prop_cmd = xmlGetProp (node, "cmd");
> > > >  
> > > > -    name = g_strdup_printf (NAME_FORMAT, prop_name);
> > > > -    cmd = g_strdup_printf (COMMAND_FORMAT, prop_cmd);
> > > > +    name = g_markup_printf_escaped (NAME_FORMAT, prop_name);
> > > > +    cmd = g_markup_printf_escaped (COMMAND_FORMAT, prop_cmd);
> > > >  
> > > >      gtk_tree_store_insert_after (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -84,7 +84,7 @@
> > > >    }
> > > >    /* separator */
> > > >    else if (!xmlStrcmp (node->name, (xmlChar *) "separator")) {
> > > > -    name = g_strdup_printf (SEPARATOR_FORMAT, _("--- separator ---"));
> > > > +    name = g_markup_printf_escaped (SEPARATOR_FORMAT, _("--- separator ---"));
> > > >  
> > > >      gtk_tree_store_insert_after (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -95,7 +95,7 @@
> > > >    else if (!xmlStrcmp (node->name, (xmlChar *) "menu")) {
> > > >      prop_name = xmlGetProp (node, "name");
> > > >  
> > > > -    name = g_strdup_printf (MENU_FORMAT, prop_name);
> > > > +    name = g_markup_printf_escaped (MENU_FORMAT, prop_name);
> > > >  
> > > >      gtk_tree_store_insert_after (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -108,12 +108,12 @@
> > > >      prop_type = xmlGetProp (node, "type");
> > > >      prop_src = xmlGetProp (node, "src");
> > > >  
> > > > -    name = g_strdup_printf (INCLUDE_FORMAT, _("--- include ---"));
> > > > +    name = g_markup_printf_escaped (INCLUDE_FORMAT, _("--- include ---"));
> > > >  
> > > >      if (!xmlStrcmp (prop_type, (xmlChar *) "system"))
> > > > -      src = g_strdup_printf (INCLUDE_PATH_FORMAT, _("system"));
> > > > +      src = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, _("system"));
> > > >      else
> > > > -      src = g_strdup_printf (INCLUDE_PATH_FORMAT, prop_src);
> > > > +      src = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, prop_src);
> > > >  
> > > >      gtk_tree_store_insert_after (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -125,8 +125,8 @@
> > > >      prop_name = xmlGetProp (node, "name");
> > > >      prop_cmd = xmlGetProp (node, "cmd");
> > > >  
> > > > -    name = g_strdup_printf (NAME_FORMAT, prop_name);
> > > > -    cmd = g_strdup_printf (COMMAND_FORMAT, prop_cmd);
> > > > +    name = g_markup_printf_escaped (NAME_FORMAT, prop_name);
> > > > +    cmd = g_markup_printf_escaped (COMMAND_FORMAT, prop_cmd);
> > > >  
> > > >      gtk_tree_store_insert_after (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -137,7 +137,7 @@
> > > >    else if (!xmlStrcmp (node->name, (xmlChar *) "title")) {
> > > >      prop_name = xmlGetProp (node, "name");
> > > >  
> > > > -    title = g_strdup_printf (TITLE_FORMAT, prop_name);
> > > > +    title = g_markup_printf_escaped (TITLE_FORMAT, prop_name);
> > > >  
> > > >      gtk_tree_store_insert_after (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -212,8 +212,8 @@
> > > >      prop_name = xmlGetProp (node, "name");
> > > >      prop_cmd = xmlGetProp (node, "cmd");
> > > >  
> > > > -    name = g_strdup_printf (NAME_FORMAT, prop_name);
> > > > -    cmd = g_strdup_printf (COMMAND_FORMAT, prop_cmd);
> > > > +    name = g_markup_printf_escaped (NAME_FORMAT, prop_name);
> > > > +    cmd = g_markup_printf_escaped (COMMAND_FORMAT, prop_cmd);
> > > >  
> > > >      gtk_tree_store_insert_before (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -222,7 +222,7 @@
> > > >    }
> > > >    /* separator */
> > > >    else if (!xmlStrcmp (node->name, (xmlChar *) "separator")) {
> > > > -    name = g_strdup_printf (SEPARATOR_FORMAT, _("--- separator ---"));
> > > > +    name = g_markup_printf_escaped (SEPARATOR_FORMAT, _("--- separator ---"));
> > > >  
> > > >      gtk_tree_store_insert_before (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -233,7 +233,7 @@
> > > >    else if (!xmlStrcmp (node->name, (xmlChar *) "menu")) {
> > > >      prop_name = xmlGetProp (node, "name");
> > > >  
> > > > -    name = g_strdup_printf (MENU_FORMAT, prop_name);
> > > > +    name = g_markup_printf_escaped (MENU_FORMAT, prop_name);
> > > >  
> > > >      gtk_tree_store_insert_before (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -246,12 +246,12 @@
> > > >      prop_type = xmlGetProp (node, "type");
> > > >      prop_src = xmlGetProp (node, "src");
> > > >  
> > > > -    name = g_strdup_printf (INCLUDE_FORMAT, _("--- include ---"));
> > > > +    name = g_markup_printf_escaped (INCLUDE_FORMAT, _("--- include ---"));
> > > >  
> > > >      if (!xmlStrcmp (prop_type, (xmlChar *) "system"))
> > > > -      src = g_strdup_printf (INCLUDE_PATH_FORMAT, _("system"));
> > > > +      src = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, _("system"));
> > > >      else
> > > > -      src = g_strdup_printf (INCLUDE_PATH_FORMAT, prop_src);
> > > > +      src = g_markup_printf_escaped (INCLUDE_PATH_FORMAT, prop_src);
> > > >  
> > > >      gtk_tree_store_insert_before (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -263,8 +263,8 @@
> > > >      prop_name = xmlGetProp (node, "name");
> > > >      prop_cmd = xmlGetProp (node, "cmd");
> > > >  
> > > > -    name = g_strdup_printf (NAME_FORMAT, prop_name);
> > > > -    cmd = g_strdup_printf (COMMAND_FORMAT, prop_cmd);
> > > > +    name = g_markup_printf_escaped (NAME_FORMAT, prop_name);
> > > > +    cmd = g_markup_printf_escaped (COMMAND_FORMAT, prop_cmd);
> > > >  
> > > >      gtk_tree_store_insert_before (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > @@ -275,7 +275,7 @@
> > > >    else if (!xmlStrcmp (node->name, (xmlChar *) "title")) {
> > > >      prop_name = xmlGetProp (node, "name");
> > > >  
> > > > -    title = g_strdup_printf (TITLE_FORMAT, prop_name);
> > > > +    title = g_markup_printf_escaped (TITLE_FORMAT, prop_name);
> > > >  
> > > >      gtk_tree_store_insert_before (tree_store, &iter_new, NULL, b);
> > > >      gtk_tree_store_set (tree_store, &iter_new,
> > > > 
> > > > _______________________________________________
> > > > Xfce4-commits mailing list
> > > > Xfce4-commits at xfce.org
> > > > http://lunar-linux.org/mailman/listinfo/xfce4-commits
> > > -- 
> > > Jean-Fran?ois Wauthy <pollux at xfce.org>
> > 
> > 
> > 
> > > _______________________________________________
> > > Xfce4-dev mailing list
> > > Xfce4-dev at xfce.org
> > > http://lunar-linux.org/mailman/listinfo/xfce4-dev
> > _______________________________________________
> > Xfce4-dev mailing list
> > Xfce4-dev at xfce.org
> > http://lunar-linux.org/mailman/listinfo/xfce4-dev
> -- 
> Jean-Fran?ois Wauthy <pollux at xfce.org>



> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
> http://lunar-linux.org/mailman/listinfo/xfce4-dev



More information about the Xfce4-dev mailing list