当前位置: 首页>>代码示例>>C++>>正文


C++ SPDocument::getResourceList方法代码示例

本文整理汇总了C++中SPDocument::getResourceList方法的典型用法代码示例。如果您正苦于以下问题:C++ SPDocument::getResourceList方法的具体用法?C++ SPDocument::getResourceList怎么用?C++ SPDocument::getResourceList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPDocument的用法示例。


在下文中一共展示了SPDocument::getResourceList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: gr_vector_list

gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection_empty, SPGradient *gr_selected, bool gr_multi)
{
    gboolean sensitive = FALSE;
    if (blocked) {
        return sensitive;
    }

    SPDocument *document = sp_desktop_document(desktop);

    GtkTreeIter iter;
    GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box));

    blocked = TRUE;

    /* Clear old list, if there is any */
    gtk_list_store_clear(store);

    GSList *gl = NULL;
    const GSList *gradients = document->getResourceList("gradient");
    for (const GSList *i = gradients; i != NULL; i = i->next) {
        SPGradient *grad = SP_GRADIENT(i->data);
        if ( grad->hasStops() && !grad->isSolid() ) {
            gl = g_slist_prepend(gl, i->data);
        }
    }
    gl = g_slist_reverse(gl);

    guint pos = 0;

    if (!gl) {
        // The document has no gradients
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1);
        sensitive = FALSE;

    } else if (selection_empty) {
        // Document has gradients, but nothing is currently selected.
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, 0, _("Nothing selected"), 1, NULL, 2, NULL, -1);
        sensitive = FALSE;

    } else {

        if (gr_selected == NULL) {
            gtk_list_store_append(store, &iter);
            gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1);
            sensitive = FALSE;
        }

        if (gr_multi) {
            gtk_list_store_append(store, &iter);
            gtk_list_store_set(store, &iter, 0, _("Multiple gradients"), 1, NULL, 2, NULL, -1);
            sensitive = FALSE;
        }

        guint idx = 0;
        while (gl) {
            SPGradient *gradient = SP_GRADIENT(gl->data);
            gl = g_slist_remove(gl, gradient);

            Glib::ustring label = gr_prepare_label(gradient);
            GdkPixbuf *pixb = sp_gradient_to_pixbuf(gradient, 64, 16);
            gtk_list_store_append(store, &iter);
            gtk_list_store_set(store, &iter, 0, label.c_str(), 1, pixb, 2, gradient, -1);

            if (gradient == gr_selected) {
                pos = idx;
            }
            idx ++;
        }
        sensitive = TRUE;

    }

    /* Select the current gradient, or the Multi/Nothing line */
    if (gr_multi || gr_selected == NULL) {
        gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , 0);
    }
    else {
        gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , pos);
    }

    blocked = FALSE;
    return sensitive;
}
开发者ID:tik0,项目名称:inkscapeGrid,代码行数:85,代码来源:gradient-toolbar.cpp


注:本文中的SPDocument::getResourceList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。