3 #include "my-atk-streamable-content.h"
5 //*************************implementation***********************
6 //implementation of virtual functions
7 //*****************get_n_mime_types************
8 static gint my_atk_streamable_content_get_n_mime_types(
9 AtkStreamableContent *streamable)
11 g_return_val_if_fail(MY_IS_ATK_STREAMABLE_CONTENT(streamable), 0);
13 return sizeof(mime_types) / sizeof(mime_types[0]);
15 //*****************get_mime_type****************
16 static const gchar* my_atk_streamable_content_get_mime_type(
17 AtkStreamableContent *streamable,
20 g_return_val_if_fail(MY_IS_ATK_STREAMABLE_CONTENT(streamable), NULL);
22 if((i < 0) || (i >= sizeof(mime_types) / sizeof(mime_types[0])))
28 //**********************get_stream*******************
29 static GIOChannel* my_atk_streamable_content_get_stream(
30 AtkStreamableContent *streamable,
31 const gchar* mime_type)
34 g_return_val_if_fail(MY_IS_ATK_STREAMABLE_CONTENT(streamable), NULL);
36 for(i = 0; i < sizeof(mime_types) / sizeof(mime_types[0]); i++)
38 if(strcmp(mime_type, mime_types[i]) == 0)
41 gchar* full_filename = T2C_GET_DATA_PATH(file_names[i]);
42 GIOChannel* channel = g_io_channel_new_file(full_filename, "r", &error);
45 TRACE("Cannot open file '%s' for read: %s", full_filename,
49 g_free(full_filename);
56 static void my_atk_streamable_content_interface_init(gpointer g_iface, gpointer iface_data)
58 AtkStreamableContentIface *klass = (AtkStreamableContentIface*)g_iface;
60 klass->get_n_mime_types = my_atk_streamable_content_get_n_mime_types;
61 klass->get_mime_type = my_atk_streamable_content_get_mime_type;
62 klass->get_stream = my_atk_streamable_content_get_stream;
65 GType my_atk_streamable_content_get_type()
67 static GType type = 0;
70 static const GTypeInfo typeInfo =
72 sizeof(MyAtkStreamableContentClass),
76 NULL, //class_finalize
78 sizeof(MyAtkStreamableContent),
83 static const GInterfaceInfo iface_info =
85 my_atk_streamable_content_interface_init, /* interface_init*/
86 NULL, /* interface_finalize*/
87 NULL /* interface_data */
89 type = g_type_register_static(G_TYPE_OBJECT, "MyAtkStreamableContent", &typeInfo, 0);
90 g_type_add_interface_static(type,
91 ATK_TYPE_STREAMABLE_CONTENT,