Back to index

im-sdk  12.3.91
option_aux.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2003 Sun Microsystems Inc.
00003  *
00004  * This is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  *
00019  * Authors: Karl Park <karl.park@sun.com>
00020  */
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025 
00026 #include <string.h>
00027 #include <stdlib.h>
00028 #include <gtk/gtk.h>
00029 
00030 #define _(String) String
00031 
00032 typedef struct _option_info option_info;
00033 
00034 
00035 struct _option_info {
00036     GtkWidget *option_aux;
00037     GtkWidget *option_keyboard;
00038     GtkWidget *option_charset;
00039     GtkWidget *option_autocommit;
00040 };
00041 
00042 static option_info *create_ui (GtkWidget *parent);
00043 static GtkWidget *create_keyboard_option (GtkWidget *frame);
00044 static GtkWidget *create_charset_option (GtkWidget *frame);
00045 static GtkWidget *create_hanja_conversion_option (GtkWidget *frame);
00046 static GtkWidget *create_autocommit_option (GtkWidget *frame);
00047 
00048 int
00049 main (int argc, char *argv[])
00050 {
00051     GtkWidget *main_window;
00052     option_info *oi;
00053 
00054     gtk_init (&argc, &argv);
00055     main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
00056 
00057     oi = create_ui (main_window);
00058     
00059     gtk_widget_show (oi->option_aux);
00060     /*
00061     gtk_widget_show (main_window);
00062     */
00063     
00064     gtk_main ();
00065     
00066     return 0;
00067 
00068 }
00069 
00070 static option_info *
00071 create_ui (GtkWidget *parent)
00072 {
00073     option_info *poi;
00074     GtkWidget *vbox;
00075     GtkWidget *keyboard_option;
00076     GtkWidget *charset_option;
00077     GtkWidget *autocommit_option;
00078     
00079     GtkWidget *frame_keyboard;
00080     GtkWidget *frame_charset_reduction;
00081     GtkWidget *frame_hanja_conversion;
00082     GtkWidget *frame_autocommit;
00083 
00084     static gchar *p_str_charsetreduction = _("Character set reduction mode");
00085     static gchar *p_str_autocommit = _("Character Basis auto-commit");
00086     
00087     poi = (option_info *) calloc (1, sizeof (option_info));
00088 
00089     /*
00090       Vertical box for packing stuffs
00091      */
00092     vbox = gtk_vbox_new (FALSE, 20);
00093     gtk_container_add (GTK_CONTAINER (parent), vbox);
00094     gtk_widget_show (vbox);
00095 
00096     poi->option_aux = vbox;
00097     
00098     /* Keyboard Layout selection frame */
00099     frame_keyboard = gtk_frame_new (_("Default Keyboard Layout Selction"));
00100     
00101      keyboard_option = create_keyboard_option (frame_keyboard);
00102     /*gtk_widget_show (keyboard_option);*/
00103     
00104     gtk_box_pack_start (GTK_BOX (vbox), frame_keyboard, TRUE, TRUE, 200);
00105     gtk_widget_show (frame_keyboard);
00106     
00107     poi->option_keyboard = keyboard_option;
00108     /* Chracter set reduction mode */
00109 
00110     frame_charset_reduction = gtk_frame_new (p_str_charsetreduction);
00111     charset_option = create_charset_option (frame_charset_reduction);
00112     gtk_box_pack_start (GTK_BOX (vbox), frame_charset_reduction,
00113                      FALSE, TRUE, 10);
00114     gtk_widget_show (frame_charset_reduction);
00115     poi->option_charset = charset_option;
00116     /* Hanja conversion format */
00117     frame_hanja_conversion =
00118        gtk_frame_new (_("Hanja conversion format"));
00119     
00120     (void) create_hanja_conversion_option (frame_hanja_conversion);
00121     gtk_box_pack_start (GTK_BOX (vbox), frame_hanja_conversion,
00122                      TRUE, FALSE, 0);
00123     gtk_widget_show (frame_hanja_conversion);
00124     /* Automatic commit on a character basis */
00125     frame_autocommit = gtk_frame_new (p_str_autocommit);
00126     autocommit_option = create_autocommit_option (frame_autocommit);
00127     gtk_box_pack_start (GTK_BOX (vbox), frame_autocommit,
00128                      TRUE, FALSE, 10);
00129     poi->option_autocommit = autocommit_option;
00130     gtk_widget_show (frame_autocommit);
00131     
00132     return poi;
00133 }
00134 
00135 static GtkWidget *
00136 create_keyboard_option (GtkWidget *frame)
00137 {
00138     static gchar *keyboard_list[] = {
00139        _("2 pair"),
00140        _("3 pair 390"),
00141        _("3 pair final"),
00142     };
00143     static gchar *p_label =
00144        _("This enables you to choose default keyboard layout");
00145     
00146     GtkWidget *combo_keyboard;
00147     GList *list_keyboard = NULL;
00148     GtkWidget *vbox;
00149     GtkWidget *label_keyboard;
00150     int i;
00151 
00152     g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
00153     
00154     for (i = 0; i < sizeof (keyboard_list) / sizeof (keyboard_list[0]);i++){
00155        list_keyboard = g_list_append (list_keyboard, keyboard_list [i]);
00156     }
00157 
00158     vbox = gtk_vbox_new (FALSE, 10);
00159     gtk_container_add (GTK_CONTAINER (frame), vbox);
00160     gtk_widget_show (vbox);
00161     label_keyboard = gtk_label_new (p_label);
00162     gtk_box_pack_start (GTK_BOX (vbox), label_keyboard,
00163                      FALSE, FALSE, 5);
00164     gtk_widget_show (label_keyboard);
00165     
00166     /* combo box creationg and population */
00167     combo_keyboard = gtk_combo_new ();
00168     gtk_combo_set_popdown_strings (GTK_COMBO (combo_keyboard), list_keyboard);
00169     g_list_free (list_keyboard); /* I can free GList here */
00170     gtk_box_pack_start (GTK_BOX (vbox),combo_keyboard,
00171                      FALSE, FALSE, 5);
00172     gtk_widget_show (combo_keyboard);
00173 
00174     return combo_keyboard;
00175 
00176 }
00177 
00178 static GtkWidget *
00179 create_charset_option (GtkWidget *frame)
00180 {
00181     GtkWidget *vbox;
00182     GtkWidget *check_charset;
00183     static const gchar *p_label = _("Use Character set reduction mode");
00184     
00185     g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
00186     
00187     vbox = gtk_vbox_new (FALSE, 10);
00188     gtk_container_add (GTK_CONTAINER (frame), vbox);
00189 
00190     check_charset = gtk_check_button_new_with_label (p_label);
00191     gtk_box_pack_start (GTK_BOX (vbox), check_charset,
00192                      FALSE, FALSE, 5);
00193     gtk_widget_show (check_charset);
00194     gtk_widget_show (vbox);
00195     
00196     return check_charset;
00197 }
00198 
00199 
00200 static GtkWidget *
00201 create_hanja_conversion_option (GtkWidget *frame)
00202 {
00203     GtkWidget *vbox;
00204     GSList *group = NULL;
00205     GtkWidget *radio_button;
00206     int i;
00207     static const gchar *p_str[] = {
00208        _("hanja"),
00209        _("hanja(hangul)"),
00210        _("hangul(hanja)")
00211     };
00212 
00213     g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
00214     
00215 
00216     vbox = gtk_vbox_new (FALSE, 10);
00217     gtk_container_add (GTK_CONTAINER (frame), vbox);
00218 
00219     
00220     for (i = 0, group = NULL ; i < 3; i++){
00221        
00222        radio_button =
00223            gtk_radio_button_new_with_label (group, p_str[i]);
00224        group =
00225            gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button));
00226        gtk_box_pack_start (GTK_BOX (vbox),radio_button, TRUE, TRUE, 0);
00227        gtk_widget_show (radio_button);
00228     }
00229     gtk_widget_show (vbox);
00230     return vbox;
00231 }
00232 
00233 static GtkWidget *
00234 create_autocommit_option (GtkWidget *frame)
00235 {
00236     GtkWidget *vbox;
00237     GtkWidget *check_commitoption;
00238     static const gchar *p_label =
00239        _("Automatically commit on a character basis");
00240     
00241     g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
00242     
00243     vbox = gtk_vbox_new (FALSE, 10);
00244     gtk_container_add (GTK_CONTAINER (frame), vbox);
00245 
00246     check_commitoption = gtk_check_button_new_with_label (p_label);
00247     gtk_box_pack_start (GTK_BOX (vbox), check_commitoption,
00248                      FALSE, FALSE, 5);
00249     gtk_widget_show (check_commitoption);
00250     gtk_widget_show (vbox);
00251     
00252     return check_commitoption;
00253 }