static void create_sub_group_widgets(GtkWidget *parent_widget, const char *parent_group) { char **sgrp_syms = uim_custom_group_subgroups(parent_group); char **sgrp_sym; for (sgrp_sym = sgrp_syms; *sgrp_sym; sgrp_sym++) { struct uim_custom_group *sgrp = uim_custom_group_get(*sgrp_sym); char **custom_syms, **custom_sym; GString *sgrp_str; GtkWidget *frame; GtkWidget *vbox; if (!sgrp) continue; /* XXX quick hack to use AND expression of groups */ sgrp_str = g_string_new(""); g_string_printf(sgrp_str, "%s '%s", parent_group, *sgrp_sym); custom_syms = uim_custom_collect_by_group(sgrp_str->str); g_string_free(sgrp_str, TRUE); if (!custom_syms) continue; if (!*custom_syms) { uim_custom_symbol_list_free(custom_syms); continue; } #if GTK_CHECK_VERSION(3, 2, 0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8); #else vbox = gtk_vbox_new(FALSE, 8); #endif if (strcmp(*sgrp_sym, "main")) { frame = gtk_frame_new(sgrp->label); gtk_frame_set_label_align(GTK_FRAME(frame), 0.02, 0.5); gtk_box_pack_start(GTK_BOX(parent_widget), frame, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); } else { /* * Removing frame for 'main' subgroup. If you feel it * strange, Replace it as you favor. -- YamaKen 2005-02-06 */ gtk_box_pack_start(GTK_BOX(parent_widget), vbox, FALSE, FALSE, 0); } gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); for (custom_sym = custom_syms; *custom_sym; custom_sym++) { uim_pref_gtk_add_custom(vbox, *custom_sym); } uim_custom_symbol_list_free(custom_syms); uim_custom_group_free(sgrp); } uim_custom_symbol_list_free(sgrp_syms); }
void GroupPageWidget::setupWidgets() { if ( m_widget_created ) return; QVBoxLayout *vLayout = new QVBoxLayout( this ); vLayout->setMargin( 6 ); vLayout->setSpacing( 3 ); struct uim_custom_group *group = uim_custom_group_get( m_group_sym.toLatin1().constData() ); if( group == 0 ) return; QLabel *groupLabel = new QLabel( _FU8(group->label), this ); groupLabel->setAlignment( Qt::AlignLeft ); vLayout->addWidget( groupLabel ); QFrame *separator = new QFrame( this ); separator->setFrameShape( QFrame::HLine ); separator->setFrameShadow( QFrame::Sunken ); vLayout->addWidget( separator ); /* default QVGroupBox */ QGroupBox *defaultGroupVBox = new QGroupBox( this ); vLayout->addWidget( defaultGroupVBox ); defaultGroupVBox->hide(); #if 0 SubgroupData *sd = new SubgroupData( this, group_name ); /* add various widgets to the vbox */ char **custom_syms = uim_custom_collect_by_group( group_name ); if( custom_syms ) { for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ ) { QGroupBox *vbox = sd->searchGroupVBoxByCustomSym( *custom_sym ); if( vbox == 0 ) { vbox = defaultGroupVBox; vbox->show(); } UimCustomItemIface *iface = addCustom( vbox, *custom_sym ); if( iface ) m_customIfaceList.append( iface ); } uim_custom_symbol_list_free( custom_syms ); } #else char **sub_groups = uim_custom_group_subgroups( m_group_sym.toLatin1().constData() ); char **sgrp; for( sgrp = sub_groups; *sgrp; sgrp++ ) { struct uim_custom_group *sgroup_custom = uim_custom_group_get( *sgrp ); QGroupBox *vbox; if( QString::compare( *sgrp, "main" ) == 0 ) { vbox = defaultGroupVBox; vbox->show(); } else { vbox = new QGroupBox( _FU8(sgroup_custom->label), this ); vLayout->addWidget( vbox ); } QVBoxLayout *layout = new QVBoxLayout; vbox->setLayout( layout ); /* XXX quick hack to use AND expression of groups */ QString groups( m_group_sym ); groups += " '"; groups += *sgrp; char **custom_syms = uim_custom_collect_by_group( groups.toLatin1().constData() ); if( !custom_syms ) continue; for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ ) { UimCustomItemIface *iface = addCustom( vbox, *custom_sym ); if( iface ) m_customIfaceList.append( iface ); } uim_custom_symbol_list_free( custom_syms ); uim_custom_group_free( sgroup_custom ); } uim_custom_symbol_list_free( sub_groups ); #endif /* free */ //delete sd; uim_custom_group_free( group ); /* bottom up */ vLayout->addStretch(); setLayout( vLayout ); m_widget_created = true; }