* 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/>.
*/
/**
* 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
* <title>GtkRecentFilter as GtkBuildable</title>
* <para>
* The GtkRecentFilter implementation of the GtkBuildable interface
- * supports adding rules using the <mime-types>, <patterns> and
- * <applications> elements and listing the rules within. Specifying
- * a <mime-type>, <pattern> or <application> is the same
+ * supports adding rules using the <mime-types>, <patterns> and
+ * <applications> elements and listing the rules within. Specifying
+ * a <mime-type>, <pattern> or <application> is the same
* as calling gtk_recent_filter_add_mime_type(), gtk_recent_filter_add_pattern()
* or gtk_recent_filter_add_application().
*
* <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>
typedef struct {
GtkRecentFilter *filter;
ParserType type;
- gchar *string;
+ GString *string;
gboolean parsing;
} SubParserData;
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
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;
}
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);
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);
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);
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);
}
}
*
* 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);