示例#1
0
static void
render_symbol(G_GNUC_UNUSED GtkTreeViewColumn *column,
              GtkCellRenderer *renderer,
              GtkTreeModel *model,
              GtkTreeIter *iter,
              gpointer user_data)
{
    GtkTreeView *treeview = (GtkTreeView*)user_data;
    GwyGrainValue *gvalue;
    GdkColor color;

    gtk_tree_model_get(model, iter,
                       GWY_GRAIN_VALUE_STORE_COLUMN_ITEM, &gvalue,
                       -1);

    if (gvalue) {
        text_color(treeview, gvalue, &color);
        g_object_set(renderer,
                     "text", gwy_grain_value_get_symbol(gvalue),
                     "foreground-gdk", &color,
                     NULL);
        g_object_unref(gvalue);
    }
    else
        g_object_set(renderer, "text", "", NULL);
}
示例#2
0
int
main(void)
{
    gwy_type_init();

    printf(file_prologue, generated, id, id, title, title);

    const gchar* const *names = gwy_grain_value_list_builtins();
    guint nvalues = g_strv_length((gchar**)names);
    GwyGrainValue **grainvalues = g_new(GwyGrainValue*, nvalues);
    for (guint i = 0; i < nvalues; i++) {
        grainvalues[i] = gwy_grain_value_new(names[i]);
        g_assert(GWY_IS_GRAIN_VALUE(grainvalues[i]));
    }
    qsort(grainvalues, nvalues, sizeof(GwyGrainValue*), compare);

    GString *str = g_string_new(NULL);
    const gchar *processing_group = "NONE";
    for (guint i = 0; i < nvalues; i++) {
        GwyGrainValue *grainvalue = grainvalues[i];
        const gchar *name = gwy_grain_value_get_name(grainvalue);
        const gchar *group = gwy_grain_value_get_group(grainvalue);
        if (!gwy_strequal(group, processing_group)) {
            if (!gwy_strequal(processing_group, "NONE"))
                printf(group_epilogue);
            g_string_assign(str, group);
            make_id(str);
            printf(group_prologue, id, str->str, group, group);
            processing_group = group;
        }
        g_string_assign(str, name);
        make_id(str);
        printf(value_prologue, id, str->str, name);
        g_string_assign(str, gwy_grain_value_get_symbol(grainvalue));
        convert_pango_to_docbook(str);
        make_math(str);
        printf("<entry>%s</entry>\n", str->str);
        printf("<entry><code>%s</code></entry>",
               gwy_grain_value_get_ident(grainvalue));
        g_string_assign(str, "");
        if (gwy_grain_value_needs_same_units(grainvalue))
            append_separated(str, "needs same lateral and value units");
        if (gwy_grain_value_is_angle(grainvalue))
            append_separated(str, "represents angle in radians");
        printf("<entry>%s</entry>\n", str->str);
        printf(value_epilogue);
        g_object_unref(grainvalue);
    }
    if (!gwy_strequal(processing_group, "NONE"))
        printf(group_epilogue);

    printf(file_epilogue);

    return 0;
}