3 #include "my-atk-object.h"
4 #include "my-atk-streamable-content.h"
6 //*************************implementation***********************
7 //implementation of virtual functions
8 //*****************get_n_mime_types************
9 static gint my_atk_streamable_content_get_n_mime_types(
10 AtkStreamableContent *streamable)
12 g_return_val_if_fail(MY_IS_ATK_STREAMABLE_CONTENT(streamable), 0);
14 return sizeof(mime_types) / sizeof(mime_types[0]);
16 //*****************get_mime_type****************
17 static const gchar* my_atk_streamable_content_get_mime_type(
18 AtkStreamableContent *streamable,
21 g_return_val_if_fail(MY_IS_ATK_STREAMABLE_CONTENT(streamable), NULL);
23 if((i < 0) || (i >= sizeof(mime_types) / sizeof(mime_types[0])))
29 //**********************get_stream*******************
30 static GIOChannel* my_atk_streamable_content_get_stream(
31 AtkStreamableContent *streamable,
32 const gchar* mime_type)
35 g_return_val_if_fail(MY_IS_ATK_STREAMABLE_CONTENT(streamable), NULL);
37 for(i = 0; i < sizeof(mime_types) / sizeof(mime_types[0]); i++)
39 if(strcmp(mime_type, mime_types[i]) == 0)
42 gchar* full_filename = T2C_GET_DATA_PATH(file_names[i]);
43 GIOChannel* channel = g_io_channel_new_file(full_filename, "r", &error);
46 TRACE("Cannot open file '%s' for read: %s", full_filename,
50 g_free(full_filename);
57 static void my_atk_streamable_content_interface_init(gpointer g_iface, gpointer iface_data)
59 AtkStreamableContentIface *klass = (AtkStreamableContentIface*)g_iface;
61 klass->get_n_mime_types = my_atk_streamable_content_get_n_mime_types;
62 klass->get_mime_type = my_atk_streamable_content_get_mime_type;
63 klass->get_stream = my_atk_streamable_content_get_stream;
66 GType my_atk_streamable_content_get_type()
68 static GType type = 0;
71 static const GTypeInfo typeInfo =
73 sizeof(MyAtkStreamableContentClass),
77 NULL, //class_finalize
79 sizeof(MyAtkStreamableContent),
84 static const GInterfaceInfo iface_info =
86 my_atk_streamable_content_interface_init, /* interface_init*/
87 NULL, /* interface_finalize*/
88 NULL /* interface_data */
90 type = g_type_register_static(MY_TYPE_ATK_OBJECT, "MyAtkStreamableContent", &typeInfo, 0);
91 g_type_add_interface_static(type,
92 ATK_TYPE_STREAMABLE_CONTENT,