static void update_module_info_cb(GtkWidget *tree, GtkWidget *parent) { GtkWidget *failed_widget, *module_widget; GtkLabel *label; GtkTreeModel *store; GtkTreeSelection *selection; const GwyModuleInfo *mod_info; const _GwyModuleFailureInfo *fail_info; const gchar *name; gboolean failed; GtkTreeIter iter; GSList *l; gchar *s; gsize n; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); g_return_if_fail(selection); if (!gtk_tree_selection_get_selected(selection, &store, &iter)) return; gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, MODEL_NAME, &name, /* We do not actually access the other one */ MODEL_INFO, &mod_info, MODEL_INFO, &fail_info, MODEL_FAILED, &failed, -1); module_widget = g_object_get_data(G_OBJECT(parent), "mod-info"); failed_widget = g_object_get_data(G_OBJECT(parent), "fail-info"); if (failed) { gtk_widget_hide(module_widget); gtk_widget_show(failed_widget); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "fail-name")); gtk_label_set_text(label, name); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "fail-file")); gtk_label_set_text(label, fail_info->filename); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "failure")); gtk_label_set_text(label, fail_info->message); return; } gtk_widget_hide(failed_widget); gtk_widget_show(module_widget); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "name-version")); s = g_strconcat(name, "-", mod_info->version, NULL); gtk_label_set_text(label, s); g_free(s); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "file")); gtk_label_set_text(label, gwy_module_get_filename(name)); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "author")); gtk_label_set_text(label, mod_info->author); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "copy")); gtk_label_set_text(label, mod_info->copyright); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "date")); gtk_label_set_text(label, mod_info->date); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "desc")); gtk_label_set_text(label, _(mod_info->blurb)); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "funcs")); n = 0; for (l = gwy_module_get_functions(name); l; l = g_slist_next(l)) n += strlen((gchar*)l->data) + 1; if (!n) gtk_label_set_text(label, ""); else { gchar *p; p = s = g_new(gchar, n); for (l = gwy_module_get_functions(name); l; l = g_slist_next(l)) { p = g_stpcpy(p, (gchar*)l->data); *(p++) = '\n'; } *(--p) = '\0'; gtk_label_set_text(label, s); g_free(s); } }
static void update_module_info_cb(GtkWidget *tree, GtkWidget *parent) { GtkLabel *label; GtkTreeModel *store; GtkTreeSelection *selection; const GwyModuleInfo *mod_info; GtkTreeIter iter; GSList *l; gchar *s, *name; gsize n; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); g_return_if_fail(selection); if (!gtk_tree_selection_get_selected(selection, &store, &iter)) return; gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, MODULE_NAME, &name, -1); mod_info = gwy_module_lookup(name); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "name-version")); s = g_strconcat(mod_info->name, "-", mod_info->version, NULL); gtk_label_set_text(label, s); g_free(s); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "file")); gtk_label_set_text(label, gwy_module_get_filename(name)); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "author")); gtk_label_set_text(label, mod_info->author); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "copy")); gtk_label_set_text(label, mod_info->copyright); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "date")); gtk_label_set_text(label, mod_info->date); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "desc")); gtk_label_set_text(label, _(mod_info->blurb)); label = GTK_LABEL(g_object_get_data(G_OBJECT(parent), "funcs")); n = 0; for (l = gwy_module_get_functions(name); l; l = g_slist_next(l)) n += strlen((gchar*)l->data) + 1; if (!n) gtk_label_set_text(label, ""); else { gchar *p; p = s = g_new(gchar, n); for (l = gwy_module_get_functions(name); l; l = g_slist_next(l)) { p = g_stpcpy(p, (gchar*)l->data); *(p++) = '\n'; } *(--p) = '\0'; gtk_label_set_text(label, s); g_free(s); } g_free(name); }