本文整理汇总了C++中SPObject::defaultLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ SPObject::defaultLabel方法的具体用法?C++ SPObject::defaultLabel怎么用?C++ SPObject::defaultLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPObject
的用法示例。
在下文中一共展示了SPObject::defaultLabel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static void
sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw )
{
if (gtk_object_get_data (GTK_OBJECT (spw), "blocked"))
return;
SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
g_return_if_fail (item != NULL);
gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE));
/* Retrieve the label widget for the object's id */
GtkWidget *id_entry = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id"));
gchar *id = (gchar *) gtk_entry_get_text (GTK_ENTRY (id_entry));
g_strcanon (id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_');
GtkWidget *id_label = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
if (!strcmp (id, item->getId())) {
gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_Id"));
} else if (!*id || !isalnum (*id)) {
gtk_label_set_text (GTK_LABEL (id_label), _("Id invalid! "));
} else if (SP_ACTIVE_DOCUMENT->getObjectById(id) != NULL) {
gtk_label_set_text (GTK_LABEL (id_label), _("Id exists! "));
} else {
SPException ex;
gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_Id"));
SP_EXCEPTION_INIT (&ex);
sp_object_setAttribute (SP_OBJECT (item), "id", id, &ex);
sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM,
_("Set object ID"));
}
/* Retrieve the label widget for the object's label */
GtkWidget *label_entry = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label"));
gchar *label = (gchar *)gtk_entry_get_text (GTK_ENTRY (label_entry));
g_assert(label != NULL);
/* Give feedback on success of setting the drawing object's label
* using the widget's label text
*/
SPObject *obj = (SPObject*)item;
if (strcmp (label, obj->defaultLabel())) {
obj->setLabel(label);
sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM,
_("Set object label"));
}
/* Retrieve the title */
GtkWidget *w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "title"));
gchar *title = (gchar *)gtk_entry_get_text(GTK_ENTRY (w));
if (obj->setTitle(title))
sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM,
_("Set object title"));
/* Retrieve the description */
GtkTextView *tv = GTK_TEXT_VIEW(gtk_object_get_data(GTK_OBJECT(spw), "desc"));
GtkTextBuffer *buf = gtk_text_view_get_buffer(tv);
GtkTextIter start, end;
gtk_text_buffer_get_bounds(buf, &start, &end);
gchar *desc = gtk_text_buffer_get_text(buf, &start, &end, TRUE);
if (obj->setDesc(desc))
sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM,
_("Set object description"));
g_free(desc);
gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE));
} // end of sp_item_widget_label_changed()
示例2: _updateMessageFromSelection
void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) {
GSList const *items = selection->itemList();
if (!items) { // no items
_context.set(Inkscape::NORMAL_MESSAGE, _when_nothing);
} else {
SPItem *item = SP_ITEM(items->data);
SPObject *layer = selection->desktop()->layerForObject(item);
SPObject *root = selection->desktop()->currentRoot();
// Layer name
gchar *layer_name;
if (layer == root) {
layer_name = g_strdup(_("root"));
} else {
char const *layer_label;
bool is_label = false;
if (layer->label()) {
layer_label = layer->label();
is_label = true;
} else {
layer_label = layer->defaultLabel();
}
char *quoted_layer_label = xml_quote_strdup(layer_label);
if (is_label) {
layer_name = g_strdup_printf(_("layer <b>%s</b>"), quoted_layer_label);
} else {
layer_name = g_strdup_printf(_("layer <b><i>%s</i></b>"), quoted_layer_label);
}
g_free(quoted_layer_label);
}
// Parent name
SPObject *parent = item->parent;
gchar const *parent_label = parent->getId();
char *quoted_parent_label = xml_quote_strdup(parent_label);
gchar *parent_name = g_strdup_printf(_("<i>%s</i>"), quoted_parent_label);
g_free(quoted_parent_label);
gchar *in_phrase;
guint num_layers = selection->numberOfLayers();
guint num_parents = selection->numberOfParents();
if (num_layers == 1) {
if (num_parents == 1) {
if (layer == parent)
in_phrase = g_strdup_printf(_(" in %s"), layer_name);
else
in_phrase = g_strdup_printf(_(" in group %s (%s)"), parent_name, layer_name);
} else {
in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> parents (%s)", " in <b>%i</b> parents (%s)", num_parents), num_parents, layer_name);
}
} else {
in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> layers", " in <b>%i</b> layers", num_layers), num_layers);
}
g_free (layer_name);
g_free (parent_name);
if (!items->next) { // one item
char *item_desc = item->description();
if (SP_IS_USE(item) && SP_IS_SYMBOL(item->firstChild())) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Convert symbol to group to edit"), _when_selected);
} else if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Use <b>Shift+D</b> to look up original"), _when_selected);
} else if (SP_IS_TEXT_TEXTPATH(item)) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Use <b>Shift+D</b> to look up path"), _when_selected);
} else if (SP_IS_FLOWTEXT(item) && !SP_FLOWTEXT(item)->has_internal_frame()) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Use <b>Shift+D</b> to look up frame"), _when_selected);
} else {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s.",
item_desc, in_phrase, _when_selected);
}
g_free(item_desc);
} else { // multiple items
int object_count = g_slist_length((GSList *)items);
gchar *objects_str = NULL;
GSList *terms = collect_terms ((GSList *)items);
int n_terms = g_slist_length(terms);
if (n_terms == 0) {
objects_str = g_strdup_printf (
// this is only used with 2 or more objects
ngettext("<b>%i</b> object selected", "<b>%i</b> objects selected", object_count),
object_count);
} else if (n_terms == 1) {
objects_str = g_strdup_printf (
// this is only used with 2 or more objects
ngettext("<b>%i</b> object of type <b>%s</b>", "<b>%i</b> objects of type <b>%s</b>", object_count),
object_count, (gchar *) terms->data);
} else if (n_terms == 2) {
objects_str = g_strdup_printf (
// this is only used with 2 or more objects
ngettext("<b>%i</b> object of types <b>%s</b>, <b>%s</b>", "<b>%i</b> objects of types <b>%s</b>, <b>%s</b>", object_count),
//.........这里部分代码省略.........
示例3: gtk_entry_set_text
/**
* \param selection Selection to use; should not be NULL.
*/
static void
sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection )
{
g_assert (selection != NULL);
if (gtk_object_get_data (GTK_OBJECT (spw), "blocked"))
return;
if (!selection->singleItem()) {
gtk_widget_set_sensitive (GTK_WIDGET (spw), FALSE);
return;
} else {
gtk_widget_set_sensitive (GTK_WIDGET (spw), TRUE);
}
gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE));
SPItem *item = selection->singleItem();
/* Sensitive */
GtkWidget *w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "sensitive"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), item->isLocked());
/* Hidden */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "hidden"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), item->isExplicitlyHidden());
if (SP_OBJECT_IS_CLONED (item)) {
/* ID */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id"));
gtk_entry_set_text (GTK_ENTRY (w), "");
gtk_widget_set_sensitive (w, FALSE);
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
gtk_label_set_text (GTK_LABEL (w), _("Ref"));
/* Label */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label"));
gtk_entry_set_text (GTK_ENTRY (w), "");
gtk_widget_set_sensitive (w, FALSE);
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label_label"));
gtk_label_set_text (GTK_LABEL (w), _("Ref"));
} else {
SPObject *obj = (SPObject*)item;
/* ID */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id"));
gtk_entry_set_text (GTK_ENTRY (w), obj->getId());
gtk_widget_set_sensitive (w, TRUE);
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
gtk_label_set_markup_with_mnemonic (GTK_LABEL (w), _("_Id"));
/* Label */
w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label"));
gtk_entry_set_text (GTK_ENTRY (w), obj->defaultLabel());
gtk_widget_set_sensitive (w, TRUE);
/* Title */
w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "title"));
gchar *title = obj->title();
if (title) {
gtk_entry_set_text(GTK_ENTRY(w), title);
g_free(title);
}
else gtk_entry_set_text(GTK_ENTRY(w), "");
gtk_widget_set_sensitive(w, TRUE);
/* Description */
w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc"));
GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w));
gchar *desc = obj->desc();
if (desc) {
gtk_text_buffer_set_text(buf, desc, -1);
g_free(desc);
} else {
gtk_text_buffer_set_text(buf, "", 0);
}
w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc_frame"));
gtk_widget_set_sensitive(w, TRUE);
w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "interactivity"));
GtkWidget* int_table = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "interactivity_table"));
if (int_table){
gtk_container_remove(GTK_CONTAINER(w), int_table);
}
const gchar* int_labels[10] = {"onclick", "onmouseover", "onmouseout", "onmousedown", "onmouseup", "onmousemove","onfocusin", "onfocusout", "onactivate", "onload"};
int_table = sp_attribute_table_new (obj, 10, int_labels, int_labels);
gtk_widget_show_all (int_table);
gtk_object_set_data(GTK_OBJECT(spw), "interactivity_table", int_table);
gtk_container_add (GTK_CONTAINER (w), int_table);
}
//.........这里部分代码省略.........