static void serializer_visit_label (Serializer* self, GtkLabel* label) { char* label_text; g_return_if_fail (self != NULL); g_return_if_fail (label != NULL); label_text = g_strdup (gtk_label_get_label (label)); g_string_append (self->priv->label_sb, label_text); g_debug ("serializer.vala:143: append text = %s", label_text); if (GTK_IS_ACCEL_LABEL (label)) { GtkLabel* _tmp0_; GtkLabel* _tmp1_; char* accel_string; gboolean _tmp2_ = FALSE; gtk_accel_label_refetch ((_tmp0_ = label, GTK_IS_ACCEL_LABEL (_tmp0_) ? ((GtkAccelLabel*) _tmp0_) : NULL)); accel_string = string_strip ((_tmp1_ = label, GTK_IS_ACCEL_LABEL (_tmp1_) ? ((GtkAccelLabel*) _tmp1_) : NULL)->accel_string); if (string_get_length (accel_string) > 0) { _tmp2_ = _vala_strcmp0 (accel_string, "-/-") != 0; } else { _tmp2_ = FALSE; } if (_tmp2_) { char* _tmp3_; g_string_append (self->priv->sb, _tmp3_ = g_markup_printf_escaped (" accel=\"%s\"", accel_string)); _g_free0 (_tmp3_); } _g_free0 (accel_string); } _g_free0 (label_text); }
void wxMenuBar::SetMenuLabel( size_t pos, const wxString& label ) { wxMenuList::compatibility_iterator node = m_menus.Item( pos ); wxCHECK_RET( node, wxT("menu not found") ); wxMenu* menu = node->GetData(); const wxString str( wxReplaceUnderscore( label ) ); menu->SetTitle( str ); if (menu->m_owner) { GtkLabel *glabel = GTK_LABEL( GTK_BIN(menu->m_owner)->child ); /* set new text */ gtk_label_set( glabel, wxGTK_CONV( str ) ); /* reparse key accel */ (void)gtk_label_parse_uline (GTK_LABEL(glabel), wxGTK_CONV( str ) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(glabel) ); } }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setLabel (JNIEnv *env, jobject obj, jstring label) { void *ptr; const char *str; ptr = NSA_GET_PTR (env, obj); str = (*env)->GetStringUTFChars (env, label, NULL); gdk_threads_enter (); if (strcmp (str, "-") == 0) /* "-" signals that we need a separator */ gtk_container_remove (GTK_CONTAINER (ptr), GTK_BIN (ptr)->child); else { GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (GTK_BIN (ptr)->child); gtk_label_set_text (GTK_LABEL (accel_label), str); gtk_accel_label_refetch (accel_label); } gdk_threads_leave (); (*env)->ReleaseStringUTFChars (env, label, str); }
/* Recreates the string representing the accelerator keys. This should not be needed since the string is automatically updated whenever accelerators are added or removed from the associated widget. */ int clip_GTK_ACCELLABELREFETCH(ClipMachine * ClipMachineMemory) { C_widget *clbl = _fetch_cw_arg(ClipMachineMemory); CHECKCWID(clbl, GTK_IS_ACCEL_LABEL); _clip_retl(ClipMachineMemory, gtk_accel_label_refetch(GTK_ACCEL_LABEL(clbl->widget))); return 0; err: return 1; }
void wxMenuItem::SetItemLabel( const wxString& string ) { wxString str = string; if ( str.empty() && !IsSeparator() ) { wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?")); str = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR | wxSTOCK_WITH_MNEMONIC); } // Some optimization to avoid flicker wxString oldLabel = m_text; oldLabel = wxStripMenuCodes(oldLabel); oldLabel.Replace(wxT("_"), wxEmptyString); wxString label1 = wxStripMenuCodes(str); wxString oldhotkey = GetHotKey(); // Store the old hotkey in Ctrl-foo format wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) ); // and as <control>foo DoSetText(str); if (oldLabel == label1 && oldhotkey == GetHotKey()) // Make sure we can change a hotkey even if the label is unaltered return; if (m_menuItem) { GtkLabel *label; if (m_labelWidget) label = (GtkLabel*) m_labelWidget; else label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); // set new text gtk_label_set( label, wxGTK_CONV( m_text ) ); // reparse key accel (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); } guint accel_key; GdkModifierType accel_mods; gtk_accelerator_parse( (const char*) oldbuf, &accel_key, &accel_mods); if (accel_key != 0) { gtk_widget_remove_accelerator( GTK_WIDGET(m_menuItem), m_parentMenu->m_accel, accel_key, accel_mods ); } wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*this) ); gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods); if (accel_key != 0) { gtk_widget_add_accelerator( GTK_WIDGET(m_menuItem), "activate", m_parentMenu->m_accel, accel_key, accel_mods, GTK_ACCEL_VISIBLE); } }