]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkbuilderparser.c
GtkEntry: Sanity check the end_pos value in _get_display_text()
[~andy/gtk] / gtk / gtkbuilderparser.c
index 6d36140dc1a4a7a856efa06c5c8cb0cd729a7817..634425890528f2f76147756c681f7874c04c0545 100644 (file)
@@ -13,9 +13,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
@@ -643,9 +641,9 @@ _free_signal_info (SignalInfo *info,
   g_slice_free (SignalInfo, info);
 }
 
-void
-_free_requires_info (RequiresInfo *info,
-                    gpointer user_data)
+static void
+free_requires_info (RequiresInfo *info,
+                    gpointer user_data)
 {
   g_free (info->library);
   g_slice_free (RequiresInfo, info);
@@ -832,34 +830,6 @@ parse_custom (GMarkupParseContext *context,
   return TRUE;
 }
 
-static gboolean
-parse_menu (GMarkupParseContext  *context,
-            const gchar          *element_name,
-            const gchar         **names,
-            const gchar         **values,
-            gpointer              user_data,
-            GError              **error)
-{
-  gchar *id;
-  ParserData *data = user_data;
-  MenuInfo *menu_info;
-
-  if (!g_markup_collect_attributes (element_name, names, values, error,
-                                    G_MARKUP_COLLECT_STRING, "id", &id,
-                                    G_MARKUP_COLLECT_INVALID))
-    return FALSE;
-
-  menu_info = g_slice_new0 (MenuInfo);
-  menu_info->tag.name = element_name;
-  menu_info->id = g_strdup (id);
-  menu_info->objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-  state_push (data, menu_info);
-
-  g_menu_markup_parser_start_menu (context, data->domain, menu_info->objects);
-
-  return TRUE;
-}
-
 static void
 start_element (GMarkupParseContext *context,
                const gchar         *element_name,
@@ -921,7 +891,7 @@ start_element (GMarkupParseContext *context,
   else if (strcmp (element_name, "interface") == 0)
     parse_interface (data, element_name, names, values, error);
   else if (strcmp (element_name, "menu") == 0)
-    parse_menu (context, element_name, names, values, data, error);
+    _gtk_builder_menu_start (data, element_name, names, values, error);
   else if (strcmp (element_name, "placeholder") == 0)
     {
       /* placeholder has no special treatmeant, but it needs an
@@ -988,36 +958,20 @@ end_element (GMarkupParseContext *context,
                         req_info->major, req_info->minor,
                         GTK_MAJOR_VERSION, GTK_MINOR_VERSION);
        }
-      _free_requires_info (req_info, NULL);
+      free_requires_info (req_info, NULL);
     }
   else if (strcmp (element_name, "interface") == 0)
     {
     }
-  else if (strcmp (element_name, "menu") == 0)
-    {
-      MenuInfo *menu_info;
-      GObject *menu;
-      GHashTableIter iter;
-      const gchar *id;
-
-      menu_info = state_pop_info (data, MenuInfo);
-      menu = (GObject*)g_menu_markup_parser_end_menu (context);
-      _gtk_builder_add_object (data->builder, menu_info->id, menu);
-      g_object_unref (menu);
-
-      g_hash_table_iter_init (&iter, menu_info->objects);
-      while (g_hash_table_iter_next (&iter, (gpointer*)&id, (gpointer*)&menu))
-        {
-          _gtk_builder_add_object (data->builder, id, menu);
-        }
-
-      free_menu_info (menu_info);
-    }
   else if (data->requested_objects && !data->inside_requested_object)
     {
       /* If outside a requested object, simply ignore this tag */
       return;
     }
+  else if (strcmp (element_name, "menu") == 0)
+    {
+      _gtk_builder_menu_end (data);
+    }
   else if (strcmp (element_name, "object") == 0)
     {
       ObjectInfo *object_info = state_pop_info (data, ObjectInfo);
@@ -1156,7 +1110,7 @@ free_info (CommonInfo *info)
   else if (strcmp (info->tag.name, "signal") == 0)
     _free_signal_info ((SignalInfo *)info, NULL);
   else if (strcmp (info->tag.name, "requires") == 0)
-    _free_requires_info ((RequiresInfo *)info, NULL);
+    free_requires_info ((RequiresInfo *)info, NULL);
   else if (strcmp (info->tag.name, "menu") == 0)
     free_menu_info ((MenuInfo *)info);
   else