static uim_bool
dump_group(const char *group_sym)
{
  struct uim_custom_group *group;
  char **custom_syms, **custom_sym;

  group = uim_custom_group_get(group_sym);
  if (!group)
    return UIM_FALSE;

  /* print group header */
  printf(";;;\n;;; %s\n;;;\n", group->label);

  custom_syms = uim_custom_collect_by_group(group_sym);
  if (custom_syms) {
    for (custom_sym = custom_syms; *custom_sym; custom_sym++) {
      dump_custom(*custom_sym);
    }
    uim_custom_symbol_list_free(custom_syms);
  }

  printf("\n\n");

  return UIM_TRUE;
}
Exemple #2
0
Fichier : qt4.cpp Projet : m8a/uim
void UimPrefDialog::createGroupWidgets()
{
    char **primary_groups = uim_custom_primary_groups();
    char **grp = 0;
    for( grp = primary_groups; *grp; grp++ )
    {
        struct uim_custom_group *group = uim_custom_group_get( *grp );
        if( group == 0 )
            continue;

        /* insert item in uim's order */
        m_groupListView->addTopLevelItem(
            new QTreeWidgetItem( QStringList() << _FU8(group->label) ) );

        GroupPageWidget *w = new GroupPageWidget( m_groupWidgetStack, *grp );
        if ( grp == primary_groups )
            w->setupWidgets();

        connect( w, SIGNAL(customValueChanged()),
                          this, SLOT(slotCustomValueChanged()) );

        m_groupWidgetsDict.insert( _FU8(group->label), w );
        m_groupWidgetStack->addWidget( w );

        uim_custom_group_free( group );
    }
    uim_custom_symbol_list_free( primary_groups );

    m_rightSideWidget->setWidget( m_groupWidgetStack );
}
Exemple #3
0
Fichier : gtk.c Projet : NgoHuy/uim
static GtkWidget *
create_group_widget(const char *group_name)
{
  GtkWidget *scrolled_win;
  GtkWidget *vbox;
  GtkWidget *group_label;
  struct uim_custom_group *group;
  char *label_text;

  scrolled_win = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_win),
				 GTK_POLICY_NEVER,
				 GTK_POLICY_AUTOMATIC);
#if GTK_CHECK_VERSION(3, 2, 0)
  vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
#else
  vbox = gtk_vbox_new(FALSE, 8);
#endif
#if GTK_CHECK_VERSION(3, 8, 0)
  gtk_container_add(GTK_CONTAINER(scrolled_win), vbox);
#else
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_win),
					vbox);
#endif

  gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);

  group = uim_custom_group_get(group_name);

  if (group == NULL)
    return NULL;

  group_label = gtk_label_new("");
  label_text  = g_markup_printf_escaped("<span size=\"xx-large\">%s</span>",
					group->label);
  gtk_label_set_markup(GTK_LABEL(group_label), label_text);
  g_free(label_text);

  gtk_box_pack_start (GTK_BOX(vbox), group_label, FALSE, TRUE, 8);

  create_sub_group_widgets(vbox, group_name);

  uim_custom_group_free(group);

  return scrolled_win;
}
Exemple #4
0
Fichier : gtk.c Projet : NgoHuy/uim
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);
}
Exemple #5
0
Fichier : gtk.c Projet : NgoHuy/uim
static GtkWidget *
create_pref_treeview(void)
{
  GtkTreeStore *tree_store;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  GtkTreeIter iter;
  char **primary_groups, **grp;
  GtkTreeSelection *selection;
  GtkTreePath *first_path;
  tree_store = gtk_tree_store_new (NUM_COLUMNS,
				   G_TYPE_STRING,
				   GTK_TYPE_WIDGET,
				   G_TYPE_STRING);

  pref_tree_view = gtk_tree_view_new();

  renderer = gtk_cell_renderer_text_new();
  column = gtk_tree_view_column_new_with_attributes(_("Group"),
						    renderer,
						    "text", GROUP_COLUMN,
						    (const gchar *)NULL);
  gtk_tree_view_column_set_sort_column_id(column, 0);
  gtk_tree_view_append_column(GTK_TREE_VIEW(pref_tree_view), column);

  primary_groups = uim_custom_primary_groups();
  for (grp = primary_groups; *grp; grp++) {
    struct uim_custom_group *group = uim_custom_group_get(*grp);
    gtk_tree_store_append (tree_store, &iter, NULL/* parent iter */);
    /* only set the widget of the first row for now */
    if (grp == primary_groups) {
      gtk_tree_store_set (tree_store, &iter,
			  GROUP_COLUMN, group->label,
			  GROUP_WIDGET, create_group_widget(*grp),
			  GROUP_SYM, *grp,
			  -1);
    } else {
      gtk_tree_store_set (tree_store, &iter,
			  GROUP_COLUMN, group->label,
			  GROUP_WIDGET, NULL,
			  GROUP_SYM, *grp,
			  -1);
    }
    uim_custom_group_free(group);
  }
  uim_custom_symbol_list_free( primary_groups );

  gtk_tree_view_set_model (GTK_TREE_VIEW(pref_tree_view),
			   GTK_TREE_MODEL(tree_store));
  g_object_unref (tree_store);
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(pref_tree_view), TRUE);
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pref_tree_view));
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
  g_signal_connect (G_OBJECT(selection), "changed",
		    G_CALLBACK(pref_tree_selection_changed), NULL);

  first_path = gtk_tree_path_new_from_indices (0, -1);

  gtk_tree_view_set_cursor(GTK_TREE_VIEW(pref_tree_view),
			   first_path, NULL, FALSE);

  return pref_tree_view;
}
Exemple #6
0
Fichier : qt4.cpp Projet : m8a/uim
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;
}