/* Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA #include <gdk-pixbuf/gdk-pixbuf.h> #include <json-glib/json-glib.h> #include "package_revision.h" #include "pidginresources.h" #include "meson-config.h" struct _PidginAboutDialog { GtkWidget *application_name; GtkWidget *main_scrolled_window; GtkTextBuffer *main_buffer; GtkWidget *developers_page; GtkWidget *developers_treeview; GtkTreeStore *developers_store; GtkWidget *translators_page; GtkWidget *translators_treeview; GtkTreeStore *translators_store; GtkWidget *build_info_page; GtkWidget *build_info_treeview; GtkTreeStore *build_info_store; /****************************************************************************** *****************************************************************************/ _pidgin_about_dialog_load_application_name(PidginAboutDialog *about) { gchar *label = g_strdup_printf( gtk_label_set_text(GTK_LABEL(about->application_name), label); _pidgin_about_dialog_load_main_page(PidginAboutDialog *about) { GInputStream *istream = NULL; gssize read = 0, size = 0; istream = g_resource_open_stream( "/im/pidgin/Pidgin/About/about.md", G_RESOURCE_LOOKUP_FLAGS_NONE, while((read = g_input_stream_read(istream, buffer, sizeof(buffer), NULL, NULL)) > 0) { g_string_append_len(str, (gchar *)buffer, read); gtk_text_buffer_get_start_iter(about->main_buffer, &start); talkatu_markdown_buffer_insert_markdown( TALKATU_MARKDOWN_BUFFER(about->main_buffer), g_string_free(str, TRUE); g_input_stream_close(istream, NULL, NULL); _pidgin_about_dialog_load_json(GtkTreeStore *store, const gchar *json_section) { GInputStream *istream = NULL; GList *l = NULL, *sections = NULL; JsonParser *parser = NULL; JsonNode *root_node = NULL; JsonObject *root_object = NULL; JsonArray *sections_array = NULL; /* get a stream to the credits resource */ istream = g_resource_open_stream( "/im/pidgin/Pidgin/About/credits.json", G_RESOURCE_LOOKUP_FLAGS_NONE, parser = json_parser_new(); if(!json_parser_load_from_stream(parser, istream, NULL, &error)) { g_critical("%s", error->message); root_node = json_parser_get_root(parser); root_object = json_node_get_object(root_node); sections_array = json_object_get_array_member(root_object, json_section); sections = json_array_get_elements(sections_array); for(l = sections; l; l = l->next) { GtkTreeIter section_iter; JsonObject *section = json_node_get_object(l->data); JsonArray *people = NULL; guint idx = 0, n_people = 0; markup = g_strdup_printf( "<span font_weight=\"bold\" font_size=\"large\">%s</span>", json_object_get_string_member(section, "title") gtk_tree_store_append(store, §ion_iter, NULL); people = json_object_get_array_member(section, "people"); n_people = json_array_get_length(people); for(idx = 0; idx < n_people; idx++) { gtk_tree_store_append(store, &person_iter, §ion_iter); 0, json_array_get_string_element(people, idx), g_object_unref(G_OBJECT(parser)); g_input_stream_close(istream, NULL, NULL); _pidgin_about_dialog_load_developers(PidginAboutDialog *about) { _pidgin_about_dialog_load_json(about->developers_store, "developers"); _pidgin_about_dialog_load_translators(PidginAboutDialog *about) { _pidgin_about_dialog_load_json(about->translators_store, "languages"); _pidgin_about_dialog_add_build_args( PidginAboutDialog *about, GtkTreeIter section, value; markup = g_strdup_printf("<span font-weight=\"bold\">%s</span>", title); gtk_tree_store_append(about->build_info_store, §ion, NULL); /* now walk through the arguments and add them */ splits = g_strsplit(build_args, " ", -1); for(idx = 0; splits[idx]; idx++) { gchar **value_split = g_strsplit(splits[idx], "=", 2); if(value_split[0] == NULL || value_split[0][0] == '\0') { gtk_tree_store_append(about->build_info_store, &value, §ion); gtk_tree_store_set(about->build_info_store, &value, 0, value_split[0], 1, value_split[1] ? value_split[1] : "", -1); _pidgin_about_dialog_build_info_add_version( gchar *version = g_strdup_printf("%u.%u.%u", major, minor, micro); gtk_tree_store_append(store, &item, section); _pidgin_about_dialog_load_build_info(PidginAboutDialog *about) { GtkTreeIter section, item; markup = g_strdup_printf( "<span font-weight=\"bold\">%s</span>", gtk_tree_store_append(about->build_info_store, §ion, NULL); /* add the commit hash */ gtk_tree_store_append(about->build_info_store, &item, §ion); /* add the purple version */ _pidgin_about_dialog_build_info_add_version( /* add the glib version */ _pidgin_about_dialog_build_info_add_version( /* add the gtk version */ _pidgin_about_dialog_build_info_add_version( _pidgin_about_dialog_load_runtime_info(PidginAboutDialog *about) { markup = g_strdup_printf( "<span font-weight=\"bold\">%s</span>", gtk_tree_store_append(about->build_info_store, §ion, NULL); /* add the purple version */ _pidgin_about_dialog_build_info_add_version( /* add the glib version */ _pidgin_about_dialog_build_info_add_version( /* add the gtk version */ _pidgin_about_dialog_build_info_add_version( _pidgin_about_dialog_load_build_configuration(PidginAboutDialog *about) { _pidgin_about_dialog_add_build_args(about, "Meson Arguments", MESON_ARGS); _pidgin_about_dialog_load_build_info(about); _pidgin_about_dialog_load_runtime_info(about); /****************************************************************************** *****************************************************************************/ _pidgin_about_dialog_close(GtkWidget *b, gpointer data) { gtk_widget_destroy(GTK_WIDGET(data)); /****************************************************************************** *****************************************************************************/ G_DEFINE_TYPE(PidginAboutDialog, pidgin_about_dialog, GTK_TYPE_DIALOG); pidgin_about_dialog_class_init(PidginAboutDialogClass *klass) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); gtk_widget_class_set_template_from_resource( "/im/pidgin/Pidgin/About/about.ui" gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, close_button); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, application_name); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, stack); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, main_scrolled_window); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, main_buffer); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, developers_page); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, developers_store); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, developers_treeview); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, translators_page); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, translators_store); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, translators_treeview); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, build_info_page); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, build_info_store); gtk_widget_class_bind_template_child(widget_class, PidginAboutDialog, build_info_treeview); pidgin_about_dialog_init(PidginAboutDialog *about) { gtk_widget_init_template(GTK_WIDGET(about)); /* wire up the close button */ G_CALLBACK(_pidgin_about_dialog_close), /* setup the application name label */ _pidgin_about_dialog_load_application_name(about); /* setup the main page */ _pidgin_about_dialog_load_main_page(about); /* setup the developers stuff */ _pidgin_about_dialog_load_developers(about); gtk_tree_view_expand_all(GTK_TREE_VIEW(about->developers_treeview)); /* setup the translators stuff */ _pidgin_about_dialog_load_translators(about); gtk_tree_view_expand_all(GTK_TREE_VIEW(about->translators_treeview)); /* setup the build info page */ _pidgin_about_dialog_load_build_configuration(about); gtk_tree_view_expand_all(GTK_TREE_VIEW(about->build_info_treeview)); pidgin_about_dialog_new(void) { PIDGIN_TYPE_ABOUT_DIALOG,