]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkrecentfilter.c
GtkBubbleWindow: Use style border color to stroke the bubble shape
[~andy/gtk] / gtk / gtkrecentfilter.c
index 93845eab74d79e39fe160172b20b84389f6224c8..d2963344988d5727ae2455b54b7a63bce71230df 100644 (file)
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser 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/>.
  */
 
 /**
@@ -34,7 +32,7 @@
  * types; e.g. a filter for text/plain also matches a file with mime
  * type application/rtf, since application/rtf is a subclass of text/plain.
  * Note that #GtkRecentFilter allows wildcards for the subtype of a
- * mime type, so you can e.g. filter for image/*.
+ * mime type, so you can e.g. filter for image/<!-- -->*.
  *
  * Normally, filters are used by adding them to a #GtkRecentChooser,
  * see gtk_recent_chooser_add_filter(), but it is also possible to
@@ -46,9 +44,9 @@
  * <title>GtkRecentFilter as GtkBuildable</title>
  * <para>
  * The GtkRecentFilter implementation of the GtkBuildable interface
- * supports adding rules using the &lt;mime-types&gt, &lt;patterns&gt and
- * &lt;applications&gt elements and listing the rules within. Specifying
- * a &lt;mime-type&gt, &lt;pattern&gt or &lt;application&gt is the same
+ * supports adding rules using the &lt;mime-types&gt;, &lt;patterns&gt; and
+ * &lt;applications&gt; elements and listing the rules within. Specifying
+ * a &lt;mime-type&gt;, &lt;pattern&gt; or &lt;application&gt; is the same
  * as calling gtk_recent_filter_add_mime_type(), gtk_recent_filter_add_pattern()
  * or gtk_recent_filter_add_application().
  *
@@ -58,7 +56,7 @@
  * <object class="GtkRecentFilter">
  *   <mime-types>
  *     <mime-type>text/plain</mime-type>
- *     <mime-type>image/*</mime-type>
+ *     <mime-type>image/png</mime-type>
  *   </mime-types>
  *   <patterns>
  *     <pattern>*.txt</pattern>
@@ -244,7 +242,7 @@ typedef enum {
 typedef struct {
   GtkRecentFilter *filter;
   ParserType       type;
-  gchar           *string;
+  GString         *string;
   gboolean         parsing;
 } SubParserData;
 
@@ -293,7 +291,7 @@ parser_text_element (GMarkupParseContext *context,
   SubParserData *parser_data = (SubParserData*)user_data;
 
   if (parser_data->parsing)
-    parser_data->string = g_strndup (text, text_len);
+    g_string_append_len (parser_data->string, text, text_len);
 }
 
 static void
@@ -309,21 +307,20 @@ parser_end_element (GMarkupParseContext *context,
       switch (parser_data->type)
        {
        case PARSE_MIME_TYPES:
-         gtk_recent_filter_add_mime_type (parser_data->filter, parser_data->string);
+         gtk_recent_filter_add_mime_type (parser_data->filter, parser_data->string->str);
          break;
        case PARSE_PATTERNS:
-         gtk_recent_filter_add_pattern (parser_data->filter, parser_data->string);
+         gtk_recent_filter_add_pattern (parser_data->filter, parser_data->string->str);
          break;
        case PARSE_APPLICATIONS:
-         gtk_recent_filter_add_application (parser_data->filter, parser_data->string);
+         gtk_recent_filter_add_application (parser_data->filter, parser_data->string->str);
          break;
        default:
          break;
        }
-      g_free (parser_data->string);
     }
 
-  parser_data->string = NULL;
+  g_string_set_size (parser_data->string, 0);
   parser_data->parsing = FALSE;
 }
 
@@ -347,6 +344,7 @@ gtk_recent_filter_buildable_custom_tag_start (GtkBuildable  *buildable,
   if (strcmp (tagname, "mime-types") == 0)
     {
       parser_data         = g_slice_new0 (SubParserData);
+      parser_data->string = g_string_new ("");
       parser_data->type   = PARSE_MIME_TYPES;
       parser_data->filter = GTK_RECENT_FILTER (buildable);
 
@@ -356,6 +354,7 @@ gtk_recent_filter_buildable_custom_tag_start (GtkBuildable  *buildable,
   else if (strcmp (tagname, "patterns") == 0)
     {
       parser_data         = g_slice_new0 (SubParserData);
+      parser_data->string = g_string_new ("");
       parser_data->type   = PARSE_PATTERNS;
       parser_data->filter = GTK_RECENT_FILTER (buildable);
 
@@ -365,6 +364,7 @@ gtk_recent_filter_buildable_custom_tag_start (GtkBuildable  *buildable,
   else if (strcmp (tagname, "applications") == 0)
     {
       parser_data         = g_slice_new0 (SubParserData);
+      parser_data->string = g_string_new ("");
       parser_data->type   = PARSE_APPLICATIONS;
       parser_data->filter = GTK_RECENT_FILTER (buildable);
 
@@ -386,7 +386,10 @@ gtk_recent_filter_buildable_custom_tag_end (GtkBuildable *buildable,
       strcmp (tagname, "patterns") == 0 ||
       strcmp (tagname, "applications") == 0)
     {
-      g_slice_free (SubParserData, (gpointer)data);
+      SubParserData *parser_data = (SubParserData*)data;
+
+      g_string_free (parser_data->string, TRUE);
+      g_slice_free (SubParserData, parser_data);
     }
 }
 
@@ -453,7 +456,7 @@ gtk_recent_filter_set_name (GtkRecentFilter *filter,
  *
  * Since: 2.10
  */
-G_CONST_RETURN gchar *
+const gchar *
 gtk_recent_filter_get_name (GtkRecentFilter *filter)
 {
   g_return_val_if_fail (GTK_IS_RECENT_FILTER (filter), NULL);