| 103 |
103 |
| 104 g_input_stream_close(istream, NULL, NULL); |
104 g_input_stream_close(istream, NULL, NULL); |
| 105 } |
105 } |
| 106 |
106 |
| 107 static void |
107 static void |
| 108 _pidgin_about_dialog_load_developers(PidginAboutDialog *about) { |
108 _pidgin_about_dialog_load_json(GtkTreeStore *store, const gchar *json_section) { |
| 109 GInputStream *istream = NULL; |
109 GInputStream *istream = NULL; |
| 110 GList *l = NULL, *sections = NULL; |
110 GList *l = NULL, *sections = NULL; |
| 111 GError *error = NULL; |
111 GError *error = NULL; |
| 112 JsonParser *parser = NULL; |
112 JsonParser *parser = NULL; |
| 113 JsonNode *root_node = NULL; |
113 JsonNode *root_node = NULL; |
| 114 JsonObject *root_object = NULL; |
114 JsonObject *root_object = NULL; |
| 115 JsonArray *developers = NULL; |
115 JsonArray *sections_array = NULL; |
| 116 |
116 |
| 117 /* get a stream to the developers resource */ |
117 /* get a stream to the credits resource */ |
| 118 istream = g_resource_open_stream( |
118 istream = g_resource_open_stream( |
| 119 pidgin_get_resource(), |
119 pidgin_get_resource(), |
| 120 "/im/pidgin/Pidgin/About/credits.json", |
120 "/im/pidgin/Pidgin/About/credits.json", |
| 121 G_RESOURCE_LOOKUP_FLAGS_NONE, |
121 G_RESOURCE_LOOKUP_FLAGS_NONE, |
| 122 NULL |
122 NULL |
| 130 } |
130 } |
| 131 |
131 |
| 132 root_node = json_parser_get_root(parser); |
132 root_node = json_parser_get_root(parser); |
| 133 root_object = json_node_get_object(root_node); |
133 root_object = json_node_get_object(root_node); |
| 134 |
134 |
| 135 developers = json_object_get_array_member(root_object, "developers"); |
135 sections_array = json_object_get_array_member(root_object, json_section); |
| 136 sections = json_array_get_elements(developers); |
136 sections = json_array_get_elements(sections_array); |
| 137 |
137 |
| 138 for(l = sections; l; l = l->next) { |
138 for(l = sections; l; l = l->next) { |
| 139 GtkTreeIter section_iter; |
139 GtkTreeIter section_iter; |
| 140 JsonObject *section = json_node_get_object(l->data); |
140 JsonObject *section = json_node_get_object(l->data); |
| 141 JsonArray *people = NULL; |
141 JsonArray *people = NULL; |
| 162 n_people = json_array_get_length(people); |
162 n_people = json_array_get_length(people); |
| 163 |
163 |
| 164 for(idx = 0; idx < n_people; idx++) { |
164 for(idx = 0; idx < n_people; idx++) { |
| 165 GtkTreeIter person_iter; |
165 GtkTreeIter person_iter; |
| 166 |
166 |
| 167 gtk_tree_store_append(about->priv->developers_store, &person_iter, §ion_iter); |
167 gtk_tree_store_append(store, &person_iter, §ion_iter); |
| 168 gtk_tree_store_set( |
168 gtk_tree_store_set( |
| 169 about->priv->developers_store, |
169 store, |
| 170 &person_iter, |
170 &person_iter, |
| 171 0, json_array_get_string_element(people, idx), |
171 0, json_array_get_string_element(people, idx), |
| 172 1, 0.5f, |
172 1, 0.5f, |
| 173 -1 |
173 -1 |
| 174 ); |
174 ); |
| 182 |
182 |
| 183 g_input_stream_close(istream, NULL, NULL); |
183 g_input_stream_close(istream, NULL, NULL); |
| 184 } |
184 } |
| 185 |
185 |
| 186 static void |
186 static void |
| |
187 _pidgin_about_dialog_load_developers(PidginAboutDialog *about) { |
| |
188 _pidgin_about_dialog_load_json(about->priv->developers_store, "developers"); |
| |
189 } |
| |
190 |
| |
191 static void |
| 187 _pidgin_about_dialog_load_translators(PidginAboutDialog *about) { |
192 _pidgin_about_dialog_load_translators(PidginAboutDialog *about) { |
| 188 GInputStream *istream = NULL; |
193 _pidgin_about_dialog_load_json(about->priv->translators_store, "languages"); |
| 189 GList *l = NULL, *sections = NULL; |
|
| 190 GError *error = NULL; |
|
| 191 JsonParser *parser = NULL; |
|
| 192 JsonNode *root_node = NULL; |
|
| 193 JsonObject *root_object = NULL; |
|
| 194 JsonArray *languages = NULL; |
|
| 195 |
|
| 196 /* get a stream to the translators resource */ |
|
| 197 istream = g_resource_open_stream( |
|
| 198 pidgin_get_resource(), |
|
| 199 "/im/pidgin/Pidgin/About/credits.json", |
|
| 200 G_RESOURCE_LOOKUP_FLAGS_NONE, |
|
| 201 NULL |
|
| 202 ); |
|
| 203 |
|
| 204 /* create our parser */ |
|
| 205 parser = json_parser_new(); |
|
| 206 |
|
| 207 if(!json_parser_load_from_stream(parser, istream, NULL, &error)) { |
|
| 208 g_critical("%s", error->message); |
|
| 209 } |
|
| 210 |
|
| 211 root_node = json_parser_get_root(parser); |
|
| 212 root_object = json_node_get_object(root_node); |
|
| 213 |
|
| 214 languages = json_object_get_array_member(root_object, "languages"); |
|
| 215 sections = json_array_get_elements(languages); |
|
| 216 |
|
| 217 for(l = sections; l; l = l->next) { |
|
| 218 GtkTreeIter section_iter; |
|
| 219 JsonObject *section = json_node_get_object(l->data); |
|
| 220 JsonArray *people = NULL; |
|
| 221 gchar *markup = NULL; |
|
| 222 guint idx = 0, n_people = 0; |
|
| 223 |
|
| 224 markup = g_strdup_printf( |
|
| 225 "<span font_weight=\"bold\" font_size=\"large\">%s</span>", |
|
| 226 json_object_get_string_member(section, "title") |
|
| 227 ); |
|
| 228 |
|
| 229 gtk_tree_store_append(about->priv->translators_store, §ion_iter, NULL); |
|
| 230 gtk_tree_store_set( |
|
| 231 about->priv->translators_store, |
|
| 232 §ion_iter, |
|
| 233 0, markup, |
|
| 234 1, 0.5f, |
|
| 235 -1 |
|
| 236 ); |
|
| 237 |
|
| 238 g_free(markup); |
|
| 239 |
|
| 240 people = json_object_get_array_member(section, "people"); |
|
| 241 n_people = json_array_get_length(people); |
|
| 242 |
|
| 243 for(idx = 0; idx < n_people; idx++) { |
|
| 244 GtkTreeIter person_iter; |
|
| 245 |
|
| 246 gtk_tree_store_append(about->priv->translators_store, &person_iter, §ion_iter); |
|
| 247 gtk_tree_store_set( |
|
| 248 about->priv->translators_store, |
|
| 249 &person_iter, |
|
| 250 0, json_array_get_string_element(people, idx), |
|
| 251 1, 0.5f, |
|
| 252 -1 |
|
| 253 ); |
|
| 254 } |
|
| 255 } |
|
| 256 |
|
| 257 g_list_free(sections); |
|
| 258 |
|
| 259 /* clean up */ |
|
| 260 g_object_unref(G_OBJECT(parser)); |
|
| 261 |
|
| 262 g_input_stream_close(istream, NULL, NULL); |
|
| 263 } |
194 } |
| 264 |
195 |
| 265 static void |
196 static void |
| 266 _pidgin_about_dialog_add_build_args( |
197 _pidgin_about_dialog_add_build_args( |
| 267 PidginAboutDialog *about, |
198 PidginAboutDialog *about, |