]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkbuilderparser.c
Drop the Motif DND protocol
[~andy/gtk] / gtk / gtkbuilderparser.c
index f6f12a5bf6c0d9aca98f212dfa272c5c00eee385..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"
 #include <string.h>
 #include <gmodule.h>
 
-#include "gtktypeutils.h"
+#include <gio/gio.h>
 #include "gtkbuilderprivate.h"
 #include "gtkbuilder.h"
 #include "gtkbuildable.h"
 #include "gtkdebug.h"
 #include "gtkversion.h"
-#include "gtktypeutils.h"
+#include "gtktypebuiltins.h"
 #include "gtkintl.h"
-#include "gtkalias.h"
+
 
 static void free_property_info (PropertyInfo *info);
 static void free_object_info (ObjectInfo *info);
@@ -380,7 +378,12 @@ parse_object (GMarkupParseContext  *context,
           data->inside_requested_object = TRUE;
         }
       else
-        return;
+        {
+          g_free (object_class);
+          g_free (object_id);
+          g_free (constructor);
+          return;
+        }
     }
 
   object_info = g_slice_new0 (ObjectInfo);
@@ -399,12 +402,13 @@ parse_object (GMarkupParseContext  *context,
     {
       g_set_error (error, GTK_BUILDER_ERROR,
                    GTK_BUILDER_ERROR_DUPLICATE_ID,
-                   _("Duplicate object id '%s' on line %d (previously on line %d)"),
+                   _("Duplicate object ID '%s' on line %d (previously on line %d)"),
                    object_id, line, line2);
       return;
     }
 
-  g_hash_table_insert (data->object_ids, object_id, GINT_TO_POINTER (line));
+
+  g_hash_table_insert (data->object_ids, g_strdup (object_id), GINT_TO_POINTER (line));
 }
 
 static void
@@ -421,6 +425,14 @@ free_object_info (ObjectInfo *info)
   g_slice_free (ObjectInfo, info);
 }
 
+static void
+free_menu_info (MenuInfo *info)
+{
+  g_free (info->id);
+  g_hash_table_unref (info->objects);
+  g_slice_free (MenuInfo, info);
+}
+
 static void
 parse_child (ParserData   *data,
              const gchar  *element_name,
@@ -629,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);
@@ -829,7 +841,7 @@ start_element (GMarkupParseContext *context,
   ParserData *data = (ParserData*)user_data;
 
 #ifdef GTK_ENABLE_DEBUG
-  if (gtk_debug_flags & GTK_DEBUG_BUILDER)
+  if (gtk_get_debug_flags () & GTK_DEBUG_BUILDER)
     {
       GString *tags = g_string_new ("");
       int i;
@@ -878,6 +890,8 @@ start_element (GMarkupParseContext *context,
     parse_signal (data, element_name, names, values, error);
   else if (strcmp (element_name, "interface") == 0)
     parse_interface (data, element_name, names, values, error);
+  else if (strcmp (element_name, "menu") == 0)
+    _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
@@ -944,7 +958,7 @@ 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)
     {
@@ -954,6 +968,10 @@ end_element (GMarkupParseContext *context,
       /* 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);
@@ -1083,17 +1101,19 @@ text (GMarkupParseContext *context,
 static void
 free_info (CommonInfo *info)
 {
-  if (strcmp (info->tag.name, "object") == 0) 
+  if (strcmp (info->tag.name, "object") == 0)
     free_object_info ((ObjectInfo *)info);
-  else if (strcmp (info->tag.name, "child") == 0) 
+  else if (strcmp (info->tag.name, "child") == 0)
     free_child_info ((ChildInfo *)info);
-  else if (strcmp (info->tag.name, "property") == 0) 
+  else if (strcmp (info->tag.name, "property") == 0)
     free_property_info ((PropertyInfo *)info);
-  else if (strcmp (info->tag.name, "signal") == 0) 
+  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);
-  else 
+  else if (strcmp (info->tag.name, "requires") == 0)
+    free_requires_info ((RequiresInfo *)info, NULL);
+  else if (strcmp (info->tag.name, "menu") == 0)
+    free_menu_info ((MenuInfo *)info);
+  else
     g_assert_not_reached ();
 }
 
@@ -1102,7 +1122,6 @@ static const GMarkupParser parser = {
   end_element,
   text,
   NULL,
-  NULL
 };
 
 void
@@ -1128,7 +1147,8 @@ _gtk_builder_parser_parse_buffer (GtkBuilder   *builder,
   data->builder = builder;
   data->filename = filename;
   data->domain = g_strdup (domain);
-  data->object_ids = g_hash_table_new (g_str_hash, g_str_equal);
+  data->object_ids = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                           (GDestroyNotify)g_free, NULL);
 
   data->requested_objects = NULL;
   if (requested_objs)