Back to index

im-sdk  12.3.91
property_window.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <gdk/gdkx.h>
00003 #include <gtk/gtk.h>
00004 
00005 #include "property_messages.h"
00006 #include "property_data.h"
00007 #include "property_window.h"
00008 #include "palette_aux.h"
00009 
00010 enum {
00011     CATEGORY_LIST_LABEL = 0,
00012     CATEGORY_LIST_WIDGET,
00013     CATEGORY_LIST_NUM_COLUMNS
00014 };
00015 
00016 enum {
00017     IME_LIST_ENABLE = 0,
00018     IME_LIST_NAME,
00019     IME_LIST_MODULE_POINTER,
00020     IME_LIST_INCONSISTENT,
00021     IME_LIST_NUM_COLUMNS
00022 };
00023 
00024 #define _(s)  (s)
00025 
00026 gboolean property_window_delete_callback (GtkWidget *widget, GdkEvent *event, gpointer user_data);
00027 void property_window_click_restore_button_callback (GtkButton *button, gpointer user_data);
00028 void property_window_click_apply_button_callback (GtkButton *button, gpointer user_data);
00029 void property_window_click_ok_button_callback (GtkButton *button, gpointer user_data);
00030 void property_window_click_cancel_button_callback (GtkButton *button, gpointer user_data);
00031 
00032 GtkTreeModel *property_window_create_category_list_model(property_window_t *property_window,
00033                                                   property_data_t *property_data);
00034 GtkListStore *property_window_create_ime_list_model(property_window_t *property_window,
00035                                               property_data_t *property_data);
00036 GtkWidget *property_window_create_category_list_view();
00037 
00038 extern palette_window_t *palette_window;
00039 
00040 property_window_t *property_window_new()
00041 {
00042     property_window_t *property_window;
00043 
00044     GtkWidget *main_window;
00045     GtkWidget *work_area;
00046     GtkWidget *apply_button;
00047     GtkWidget *restore_button;
00048     GtkWidget *ok_button;
00049     GtkWidget *cancel_button;
00050 
00051     GtkWidget *hpaned1;
00052     GtkWidget *scrolledwindow;
00053     GtkWidget *vbox1;
00054     GtkWidget *vbox2;
00055     GtkWidget *frame1;
00056     GtkWidget *hbox1;
00057 
00058     GtkWidget *category_list_view;
00059 
00060     property_window = (property_window_t *)calloc(1, sizeof(property_window_t));
00061     if (property_window == NULL)
00062         return NULL;
00063 
00064     // Create main window.
00065     main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
00066     gtk_window_set_title (GTK_WINDOW (main_window), PROPERTY_WINDOW_TITLE);
00067     gtk_window_set_position (GTK_WINDOW (main_window), GTK_WIN_POS_CENTER);
00068     gtk_window_set_modal (GTK_WINDOW (main_window), FALSE);
00069     gtk_window_set_destroy_with_parent (GTK_WINDOW (main_window), TRUE);
00070     gtk_window_set_resizable (GTK_WINDOW (main_window), TRUE);
00071 
00072     vbox1 = gtk_vbox_new (FALSE, 0);
00073     gtk_widget_show (vbox1);
00074     gtk_container_add (GTK_CONTAINER (main_window), vbox1);
00075 
00076     // Create paned window.
00077     hpaned1 = gtk_hpaned_new ();
00078     gtk_widget_show (hpaned1);
00079     gtk_box_pack_start (GTK_BOX (vbox1), hpaned1, TRUE, TRUE, 0);
00080     gtk_container_set_border_width (GTK_CONTAINER (hpaned1), 4);
00081 
00082     // Create hbox for button area.
00083     hbox1 = gtk_hbox_new (FALSE, 0);
00084     gtk_widget_show (hbox1);
00085     gtk_box_pack_start(GTK_BOX (vbox1), hbox1, FALSE, FALSE, 8);
00086 
00087     ok_button = gtk_button_new_from_stock ("gtk-ok");
00088     gtk_widget_show (ok_button);
00089     gtk_box_pack_end (GTK_BOX (hbox1), ok_button, FALSE, FALSE, 4);
00090 
00091     cancel_button = gtk_button_new_from_stock ("gtk-cancel");
00092     gtk_widget_show (cancel_button);
00093     gtk_box_pack_end (GTK_BOX (hbox1), cancel_button, FALSE, FALSE, 4);
00094 
00095     apply_button = gtk_button_new_from_stock ("gtk-apply");
00096     gtk_widget_show (apply_button);
00097     gtk_box_pack_end (GTK_BOX (hbox1), apply_button, FALSE, FALSE, 4);
00098     GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT);
00099 
00100     restore_button = gtk_button_new_from_stock ("gtk-revert-to-saved");
00101     gtk_widget_show (restore_button);
00102     gtk_box_pack_end (GTK_BOX (hbox1), restore_button, FALSE, FALSE, 4);
00103 
00104     // Create scrollwindow for module list.
00105     scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
00106     gtk_widget_show (scrolledwindow);
00107     gtk_paned_pack1 (GTK_PANED (hpaned1), scrolledwindow, FALSE, FALSE);
00108     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
00109                                     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
00110     gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow), 
00111                                          GTK_SHADOW_ETCHED_IN);
00112     gtk_widget_set_size_request(scrolledwindow, 150, 280);
00113 
00114     category_list_view = (GtkWidget *)property_window_create_category_list_view();
00115     gtk_container_add (GTK_CONTAINER (scrolledwindow), category_list_view);
00116 
00117     // Create vbox for work area and button area.
00118     vbox2 = gtk_vbox_new (FALSE, 0);
00119     gtk_widget_show (vbox2);
00120     gtk_paned_pack2 (GTK_PANED (hpaned1), vbox2, TRUE, FALSE);
00121 
00122     // Create frame for work area.
00123     frame1 = gtk_frame_new (NULL);
00124     gtk_widget_show (frame1);
00125     gtk_widget_set_size_request(frame1, 470, 420);
00126     gtk_box_pack_start (GTK_BOX (vbox2), frame1, TRUE, TRUE, 0);
00127 
00128     work_area = gtk_vbox_new (FALSE, 0);
00129     gtk_widget_show (work_area);
00130     gtk_container_add (GTK_CONTAINER (frame1), work_area);
00131 
00132     property_window->main_window = main_window;
00133     property_window->category_list_view = category_list_view;
00134     property_window->work_area = work_area;
00135     property_window->apply_button = apply_button;
00136     property_window->restore_button = restore_button;
00137     
00138     g_signal_connect ((gpointer) ok_button, "clicked",
00139                       G_CALLBACK (property_window_click_ok_button_callback),
00140                       property_window);
00141     g_signal_connect ((gpointer) cancel_button, "clicked",
00142                       G_CALLBACK (property_window_click_cancel_button_callback),
00143                       property_window);
00144     g_signal_connect ((gpointer) apply_button, "clicked",
00145                       G_CALLBACK (property_window_click_apply_button_callback),
00146                       property_window);
00147     g_signal_connect ((gpointer) restore_button, "clicked",
00148                       G_CALLBACK (property_window_click_restore_button_callback),
00149                       property_window);
00150     g_signal_connect (G_OBJECT (main_window), "delete_event",
00151                       G_CALLBACK (property_window_delete_callback),
00152                       property_window);
00153 
00154     gtk_widget_grab_default (apply_button);
00155 
00156     gtk_widget_realize(main_window);
00157 
00158     return property_window;
00159 }
00160 
00161 void property_window_destroy(property_window_t *property_window)
00162 {
00163     int i, j;
00164 
00165     if (!property_window)
00166         return;
00167 
00168     if (property_window->main_window)
00169         gtk_widget_destroy(property_window->main_window);
00170 
00171     if (property_window->ime_module_widgets) {
00172        for (i = 0; i < property_window->num_ime_modules; i++) {
00173            ime_module_widget_t *ime_module_widget;
00174 
00175            ime_module_widget = property_window->ime_module_widgets[i];
00176            if (ime_module_widget == NULL)
00177               continue;
00178 
00179            if (ime_module_widget->ime_property_widgets) {
00180               for (j = 0; j < ime_module_widget->num_ime_properties; j++) {
00181                   ime_property_widget_t *ime_property_widget;
00182                   ime_property_widget = ime_module_widget->ime_property_widgets[j];
00183                   if (ime_property_widget != NULL)
00184                       free ((char *) ime_property_widget);
00185               }
00186               free ((char *)ime_module_widget->ime_property_widgets);
00187            }
00188            free ((char *) ime_module_widget);
00189        }
00190        free ((char *)property_window->ime_module_widgets);
00191     }
00192 
00193     free ((char *)property_window);
00194 
00195     return;
00196 }
00197 
00198 void property_window_show(property_window_t *property_window)
00199 {
00200     if (!property_window)
00201         return;
00202 
00203     gtk_widget_show(property_window->main_window);
00204     gdk_window_raise (property_window->main_window->window);
00205 
00206     return;
00207 }
00208 
00209 void property_window_hide(property_window_t *property_window)
00210 {
00211     if (!property_window)
00212         return;
00213 
00214     gtk_widget_hide(property_window->main_window);
00215     return;
00216 }
00217 
00218 void property_window_set_modified_status(property_window_t *property_window,
00219                                     int modified)
00220 {
00221     if (property_window == NULL ||
00222        property_window->modified_status == modified)
00223        return;
00224 
00225     property_window->modified_status = modified;
00226 
00227     if (modified) {
00228        gtk_widget_set_sensitive (property_window->apply_button, TRUE);
00229        gtk_widget_set_sensitive (property_window->restore_button, TRUE);
00230     } else {
00231        gtk_widget_set_sensitive (property_window->apply_button, FALSE);
00232        gtk_widget_set_sensitive (property_window->restore_button, FALSE);
00233     }
00234 
00235     return;
00236 }
00237 
00238 property_window_t *property_window_new_with_property_data(property_data_t *property_data)
00239 {
00240     property_window_t *property_window;
00241     GtkTreeModel *category_list_model;
00242 
00243     if (property_data == NULL)
00244        return NULL;
00245 
00246     property_window = property_window_new();
00247     if (property_window == NULL)
00248        return NULL;
00249     
00250     category_list_model = (GtkTreeModel *)property_window_create_category_list_model(property_window,
00251                                                                            property_data);
00252 
00253     property_window->category_list_model = (GtkTreeStore *) category_list_model;
00254 
00255     gtk_tree_view_set_model(GTK_TREE_VIEW (property_window->category_list_view), 
00256                          GTK_TREE_MODEL (category_list_model));
00257 
00258     gtk_tree_view_expand_all (GTK_TREE_VIEW (property_window->category_list_view));
00259 
00260     property_window->modified_status == TRUE;
00261 
00262     g_object_set_data(G_OBJECT (property_window->main_window),
00263                     DATA_PROPERTY_DATA_INFO,
00264                     (gpointer) property_data);
00265 
00266     return property_window;
00267 }
00268 
00269 void property_window_restore(property_window_t *property_window)
00270 {
00271     int i, j;
00272     property_data_t *property_data;
00273     int fkey_vkb_id;
00274 
00275     if (property_window == NULL || property_window->modified_status == FALSE)
00276        return;
00277 
00278     property_data = (property_data_t *) g_object_get_data(G_OBJECT (property_window->main_window),
00279                                                    DATA_PROPERTY_DATA_INFO);
00280 
00281     if (property_data == NULL)
00282        return;
00283 
00284     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_show_ime_icon),
00285                              property_data->show_ime_button);
00286     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_show_qjbj_icon),
00287                              property_data->show_qjbj_button);
00288     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_show_punct_icon),
00289                              property_data->show_punct_button);
00290     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_show_vkb_icon),
00291                              property_data->show_vkb_button);
00292     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_show_utility_icon),
00293                              property_data->show_utility_button);
00294 
00295     if (property_data->show_with_vertical) {
00296        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_direction_vertical), TRUE);
00297     } else {
00298        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_direction_horizontal), TRUE);
00299     }
00300 
00301     if (property_data->beep_enabled) {
00302        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_beep_enabled), TRUE);
00303     } else {
00304        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (property_window->widget_beep_disabled), TRUE);
00305     }
00306 
00307     fkey_vkb_id = property_data->fkey_vkb - 'A';
00308     if (fkey_vkb_id < 0 || fkey_vkb_id >= 26)
00309        fkey_vkb_id = 'K' -'A';
00310     gtk_option_menu_set_history (GTK_OPTION_MENU (property_window->widget_fkey_vkb_list), fkey_vkb_id);
00311 
00312     if (property_window->ime_module_widgets) {
00313        for (i = 0; i < property_window->num_ime_modules; i++) {
00314            ime_module_widget_t *ime_module_widget;
00315 
00316            ime_module_widget = property_window->ime_module_widgets[i];
00317            if (ime_module_widget == NULL)
00318               continue;
00319 
00320            if (ime_module_widget->ime_property_widgets) {
00321               for (j = 0; j < ime_module_widget->num_ime_properties; j++) {
00322                   ime_property_widget_t *ime_property_widget;
00323                   ime_property_widget = ime_module_widget->ime_property_widgets[j];
00324                   if (ime_property_widget == NULL ||
00325                      ime_property_widget->ime_property == NULL ||
00326                      ime_property_widget->widget == NULL) 
00327                      continue;
00328 
00329                   if (ime_property_widget->ime_property->type == ImeProperty_Toggle) {
00330                      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (ime_property_widget->widget),
00331                                                ime_property_widget->ime_property->value.int_value);
00332                   } else if (ime_property_widget->ime_property->type == ImeProperty_Selection) {
00333                      gtk_option_menu_set_history (GTK_OPTION_MENU (ime_property_widget->widget),
00334                                                ime_property_widget->ime_property->value.int_value);
00335                   } else if (ime_property_widget->ime_property->type == ImeProperty_Int) {
00336                      gtk_spin_button_set_value (GTK_SPIN_BUTTON (ime_property_widget->widget),
00337                                              ime_property_widget->ime_property->value.int_value);
00338                   }
00339               }
00340            }
00341        }
00342     }
00343 
00344     if (property_window->ime_list_model) {
00345        g_object_unref (property_window->ime_list_model);
00346     }
00347 
00348     property_window->ime_list_model = property_window_create_ime_list_model(property_window,
00349                                                                    property_data);
00350     gtk_tree_view_set_model (GTK_TREE_VIEW (property_window->ime_list_view),
00351                           GTK_TREE_MODEL (property_window->ime_list_model));
00352 
00353     property_window_set_modified_status(property_window, FALSE);
00354 
00355     return;
00356 }
00357 
00358 void property_window_apply(property_window_t *property_window)
00359 {
00360     int i, j;
00361     int fkey_vkb_id;
00362     property_data_t *property_data;
00363     GtkTreeModel *ime_list_model;
00364     gboolean have_iter;
00365     GtkTreeIter iter;
00366     gboolean enabled;
00367 
00368     gboolean ime_all_disabled = TRUE;
00369 
00370     if (property_window == NULL || property_window->modified_status == FALSE)
00371        return;
00372 
00373     property_data = (property_data_t *) g_object_get_data(G_OBJECT (property_window->main_window),
00374                                                    DATA_PROPERTY_DATA_INFO);
00375 
00376     if (property_data == NULL)
00377        return;
00378 
00379     ime_list_model = (GtkTreeModel *)property_window->ime_list_model;
00380     if (ime_list_model) {
00381        have_iter = gtk_tree_model_get_iter_first(ime_list_model, &iter);
00382        while (have_iter) {
00383            gtk_tree_model_get (ime_list_model, &iter,
00384                             IME_LIST_ENABLE, &enabled,
00385                             -1);
00386            if (enabled) {
00387               ime_all_disabled = FALSE;
00388               break;
00389            }
00390 
00391            have_iter = gtk_tree_model_iter_next(ime_list_model, &iter);
00392        }
00393 
00394        if (ime_all_disabled) {
00395            GtkWidget *dialog;
00396 
00397            dialog = gtk_message_dialog_new (GTK_WINDOW (property_window->main_window),
00398                                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
00399                                GTK_MESSAGE_WARNING,
00400                                GTK_BUTTONS_OK,
00401                                PROPERTY_WARNING_DIALOG_IME_DISABLED_STR);
00402            gtk_dialog_run (GTK_DIALOG (dialog));
00403            gtk_widget_destroy (dialog);
00404            return;
00405        }
00406     }
00407 
00408     /* Apply for statusbar settings */
00409     property_data->show_ime_button =
00410        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (property_window->widget_show_ime_icon));
00411     property_data->show_qjbj_button =
00412        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (property_window->widget_show_qjbj_icon));
00413     property_data->show_punct_button =
00414        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (property_window->widget_show_punct_icon));
00415     property_data->show_vkb_button =
00416        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (property_window->widget_show_vkb_icon));
00417     property_data->show_utility_button =
00418        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (property_window->widget_show_utility_icon));
00419 
00420     property_data->show_with_vertical =
00421        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (property_window->widget_direction_vertical));
00422 
00423     property_data->beep_enabled =
00424        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (property_window->widget_beep_enabled));
00425 
00426     /* Apply for fkey settings */
00427     fkey_vkb_id = gtk_option_menu_get_history (GTK_OPTION_MENU (property_window->widget_fkey_vkb_list));
00428     property_data->fkey_vkb = fkey_vkb_id + 'A';
00429 
00430     /* Apply for ime property settings */
00431     if (property_window->ime_module_widgets) {
00432        for (i = 0; i < property_window->num_ime_modules; i++) {
00433            ime_module_widget_t *ime_module_widget;
00434 
00435            ime_module_widget = property_window->ime_module_widgets[i];
00436            if (ime_module_widget == NULL)
00437               continue;
00438 
00439            if (ime_module_widget->ime_property_widgets) {
00440               for (j = 0; j < ime_module_widget->num_ime_properties; j++) {
00441                   ime_property_widget_t *ime_property_widget;
00442                   ime_property_widget = ime_module_widget->ime_property_widgets[j];
00443                   if (ime_property_widget == NULL ||
00444                      ime_property_widget->ime_property == NULL ||
00445                      ime_property_widget->widget == NULL) 
00446                      continue;
00447 
00448                   if (ime_property_widget->ime_property->type == ImeProperty_Toggle) {
00449                      ime_property_widget->ime_property->value.int_value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (ime_property_widget->widget));
00450                   } else if (ime_property_widget->ime_property->type == ImeProperty_Selection) {
00451                      ime_property_widget->ime_property->value.int_value = gtk_option_menu_get_history (GTK_OPTION_MENU (ime_property_widget->widget));
00452                   } else if (ime_property_widget->ime_property->type == ImeProperty_Int) {
00453                      ime_property_widget->ime_property->value.int_value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ime_property_widget->widget));
00454                   }
00455               }
00456            }
00457        }
00458     }
00459 
00460     /* Apply for ime enable and sequence settings */
00461     if (ime_list_model) {
00462        int current_ime_module_id = 0;
00463 
00464        have_iter = gtk_tree_model_get_iter_first(ime_list_model, &iter);
00465        while (have_iter) {
00466            gpointer ime_module_ptr;
00467            gtk_tree_model_get (ime_list_model, &iter,
00468                             IME_LIST_ENABLE, &enabled,
00469                             IME_LIST_MODULE_POINTER, &ime_module_ptr,
00470                             -1);
00471 
00472            if (ime_module_ptr != NULL) {
00473               
00474               DEBUG_printf("uuid: %s, enabled: %d\n", ((ime_module_t *)ime_module_ptr)->uuid, enabled);
00475 
00476               for (i = current_ime_module_id; i < property_data->num_ime_modules; i++) {
00477                   ime_module_t *ime_module = property_data->ime_modules[i];
00478                   if (ime_module == NULL)
00479                      continue;
00480 
00481                   if (ime_module == ime_module_ptr) {
00482                      for (j = i; j > current_ime_module_id; j--)
00483                          property_data->ime_modules[j] = property_data->ime_modules[j - 1];
00484                      property_data->ime_modules[current_ime_module_id] = ime_module;
00485                      current_ime_module_id ++;
00486                      ime_module->enabled = enabled;
00487                      break;
00488                   }
00489               }
00490            }
00491 
00492            have_iter = gtk_tree_model_iter_next(ime_list_model, &iter);
00493        }
00494     }
00495 
00496     palette_aux_Update_LE_Properties_Request();
00497     property_window_set_modified_status(property_window, FALSE);
00498 
00499     property_data_save_to_profile(property_data, PROPERTY_DATA_FOR_ALL);
00500 
00501     palette_window_sync_from_property_data(palette_window);
00502     palette_window_update_ime_list_menu(palette_window, property_data);
00503 
00504     return;
00505 }
00506 
00507 /*************************************************************/
00508 /*       restore/applly/cancel/ok buttons' callbacks         */
00509 /*************************************************************/
00510 void
00511 property_window_set_modified_status_callback (GtkWidget *widget, gpointer user_data)
00512 {
00513     property_window_t *property_window = (property_window_t *) user_data;
00514 
00515     DEBUG_printf("property_window_set_modified_status_callback =======\n");
00516     property_window_set_modified_status(property_window, TRUE);
00517 
00518     return;
00519 }
00520 
00521 void
00522 property_window_click_restore_button_callback (GtkButton *button, gpointer user_data)
00523 {
00524     property_window_t *property_window = (property_window_t *) user_data;
00525 
00526     property_window_restore(property_window);
00527 }
00528 
00529 void
00530 property_window_click_apply_button_callback (GtkButton *button, gpointer user_data)
00531 {
00532     property_window_t *property_window = (property_window_t *) user_data;
00533 
00534     property_window_apply(property_window);
00535 }
00536 
00537 void
00538 property_window_click_ok_button_callback (GtkButton *button, gpointer user_data)
00539 {
00540     property_window_t *property_window = (property_window_t *)user_data;
00541 
00542     property_window_apply(property_window);
00543     property_window_hide(property_window);
00544 
00545     return;
00546 }
00547 
00548 void
00549 property_window_click_cancel_button_callback (GtkButton *button, gpointer user_data)
00550 {
00551     property_window_t *property_window = (property_window_t *)user_data;
00552 
00553     property_window_hide(property_window);
00554     return;
00555 }
00556 
00557 gboolean
00558 property_window_delete_callback (GtkWidget *widget, GdkEvent *event, gpointer user_data)
00559 {
00560     property_window_t *property_window = (property_window_t *)user_data;
00561 
00562     property_window_hide(property_window);
00563     return TRUE;
00564 }
00565 
00566 /*************************************************************/
00567 /*       property categories widget                          */
00568 /*************************************************************/
00569 static GtkWidget *
00570 property_window_create_category_header(const char *category)
00571 {
00572     GtkWidget *vbox;
00573     GtkWidget *label;
00574     GtkWidget *sep;
00575 
00576     char buf[128];
00577     
00578     vbox = gtk_vbox_new (FALSE, 0);
00579     gtk_widget_show(vbox);
00580     gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
00581 
00582     snprintf(buf, 127, "<span weight=\"bold\" size=\"large\">%s</span>", category);
00583 
00584     label = gtk_label_new(NULL);
00585     gtk_label_set_markup(GTK_LABEL(label), buf);
00586     gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
00587     gtk_widget_show(label);
00588     gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
00589 
00590     sep = gtk_hseparator_new();
00591     gtk_widget_show(sep);
00592     gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, TRUE, 4);
00593 
00594     return vbox;
00595 }
00596 
00597 static GtkWidget *
00598 property_window_create_setting_cover(const char *category)
00599 {
00600     GtkWidget *cover;
00601     char buf[128];
00602 
00603     snprintf(buf, 127, PROPERTY_SETTING_COVER_STR, category);
00604 
00605     cover = gtk_label_new(NULL);
00606 
00607     gtk_label_set_markup(GTK_LABEL(cover), buf);
00608     gtk_label_set_justify(GTK_LABEL(cover), GTK_JUSTIFY_CENTER);
00609 
00610     gtk_widget_hide(cover);
00611 
00612     return cover;
00613 }
00614 
00615 static GtkWidget *
00616 property_window_create_candidate_style_view(property_window_t *property_window,
00617                                        property_data_t *property_data)
00618 {
00619     GtkWidget *vbox;
00620     GtkWidget *header;
00621     GtkWidget *frame;
00622     GtkWidget *table;
00623     GtkWidget *hbox;
00624     GtkWidget *widget_application_style;
00625     GtkWidget *widget_traditional_style;
00626     GtkWidget *widget_modern_style;
00627     GSList    *group;
00628     
00629     vbox = gtk_vbox_new (FALSE, 6);
00630     gtk_widget_show(vbox);
00631     gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
00632 
00633     header = property_window_create_category_header(CATEGORY_CANDIDATE_SETTING_STR);
00634     gtk_box_pack_start(GTK_BOX(vbox), header, FALSE, FALSE, 4);
00635 
00636     // Create the ToolBar setup block.
00637     frame = gtk_frame_new (_("Candidate Style"));
00638     gtk_widget_show (frame);
00639     gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
00640     gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
00641 
00642     table = gtk_table_new (2, 2, FALSE);
00643     gtk_widget_show (table);
00644     gtk_container_add (GTK_CONTAINER (frame), table);
00645     gtk_table_set_row_spacings (GTK_TABLE (table), 4);
00646     gtk_table_set_col_spacings (GTK_TABLE (table), 8);
00647 
00648 /*
00649     hbox = gtk_hbox_new(FALSE, 20);
00650     gtk_widget_show(hbox);
00651     gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
00652     gtk_container_add(GTK_CONTAINER (frame), hbox);
00653 */
00654     widget_traditional_style = gtk_radio_button_new_with_mnemonic (NULL, _("_Traditional mode"));
00655     gtk_widget_show (widget_traditional_style);
00656 /*
00657     gtk_box_pack_start(GTK_BOX (hbox), widget_traditional_style, FALSE, FALSE, 5);
00658 */
00659     gtk_table_attach (GTK_TABLE (table), widget_traditional_style, 0, 1, 0, 1,
00660                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
00661                           (GtkAttachOptions) (GTK_EXPAND), 4, 0);
00662 
00663     group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (widget_traditional_style));
00664     widget_modern_style = gtk_radio_button_new_with_mnemonic (group, _("_Modern mode"));
00665     gtk_widget_show (widget_modern_style);
00666 /*
00667     gtk_box_pack_start(GTK_BOX (hbox), widget_modern_style, FALSE, FALSE, 5);
00668 */
00669     gtk_table_attach (GTK_TABLE (table), widget_modern_style, 1, 2, 0, 1,
00670                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
00671                           (GtkAttachOptions) (GTK_EXPAND), 4, 0);
00672 
00673 
00674     group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (widget_modern_style));
00675     widget_application_style = gtk_radio_button_new_with_mnemonic (group, _("_Application mode"));
00676     gtk_widget_show (widget_application_style);
00677 /*
00678     gtk_box_pack_start(GTK_BOX (hbox), widget_application_style, FALSE, FALSE, 5);
00679 */
00680     gtk_table_attach (GTK_TABLE (table), widget_application_style, 0, 2, 1, 2,
00681                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
00682                           (GtkAttachOptions) (GTK_EXPAND), 4, 0);
00683 
00684     gtk_widget_hide(vbox);
00685 
00686     return vbox;
00687 }
00688 
00689 /*************************************************************/
00690 /*           properties for toolbar                          */
00691 /*************************************************************/
00692 static void
00693 statusbar_show_ime_button_toggled_cb(GtkWidget *button,
00694                                  property_window_t *property_window)
00695 {
00696 /*
00697     int show_ime_button = 0;
00698 
00699     if (property_data == NULL)
00700        return;
00701 
00702     if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
00703        show_ime_button = 1;
00704     }
00705 
00706     property_data->show_ime_button = show_ime_button;
00707 */
00708 
00709     property_window_set_modified_status(property_window, TRUE);
00710     return;
00711 }
00712 
00713 static GtkWidget *
00714 property_window_create_statusbar_setting_view(property_window_t *property_window,
00715                                          property_data_t *property_data)
00716 {
00717     GtkWidget *vbox;
00718     GtkWidget *header;
00719     GtkWidget *widget_show_ime_icon;
00720     GtkWidget *widget_show_qjbj_icon;
00721     GtkWidget *widget_show_punct_icon;
00722     GtkWidget *widget_show_vkb_icon;
00723     GtkWidget *widget_show_utility_icon;
00724     GtkWidget *frame;
00725     GtkWidget *table;
00726     GtkWidget *hbox;
00727     GtkWidget *widget_direction_vertical;
00728     GtkWidget *widget_direction_horizontal;
00729     GSList    *group;
00730     
00731     vbox = gtk_vbox_new (FALSE, 6);
00732     gtk_widget_show(vbox);
00733     gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
00734 
00735     header = property_window_create_category_header(CATEGORY_STATUSBAR_SETTING_STR);
00736     gtk_box_pack_start(GTK_BOX(vbox), header, FALSE, FALSE, 4);
00737 
00738     // Create the ToolBar setup block.
00739     frame = gtk_frame_new (STATUSBAR_SHOW_HIDE_FRAME);
00740     gtk_widget_show (frame);
00741     gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
00742     gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
00743 
00744     table = gtk_table_new (3, 2, FALSE);
00745     gtk_widget_show (table);
00746     gtk_container_add (GTK_CONTAINER (frame), table);
00747     gtk_table_set_row_spacings (GTK_TABLE (table), 4);
00748     gtk_table_set_col_spacings (GTK_TABLE (table), 8);
00749 
00750     widget_show_ime_icon = gtk_check_button_new_with_mnemonic (STATUSBAR_SHOW_IME_BUTTON);
00751     gtk_widget_show (widget_show_ime_icon);
00752     property_window->widget_show_ime_icon = widget_show_ime_icon;
00753     gtk_table_attach (GTK_TABLE (table), widget_show_ime_icon, 0, 1, 0, 1,
00754                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
00755                           (GtkAttachOptions) (GTK_EXPAND), 4, 0);
00756     g_signal_connect (G_OBJECT (widget_show_ime_icon), "toggled",
00757                       G_CALLBACK (property_window_set_modified_status_callback),
00758                       property_window);
00759 
00760     widget_show_qjbj_icon = gtk_check_button_new_with_mnemonic (STATUSBAR_SHOW_QJBJ_BUTTON);
00761     gtk_widget_show (widget_show_qjbj_icon);
00762     property_window->widget_show_qjbj_icon = widget_show_qjbj_icon;
00763     gtk_table_attach (GTK_TABLE (table), widget_show_qjbj_icon, 0, 1, 1, 2,
00764                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
00765                           (GtkAttachOptions) (GTK_EXPAND), 4, 0);
00766     g_signal_connect (G_OBJECT (widget_show_qjbj_icon), "toggled",
00767                       G_CALLBACK (property_window_set_modified_status_callback),
00768                       property_window);
00769 
00770     widget_show_punct_icon = gtk_check_button_new_with_mnemonic (STATUSBAR_SHOW_PUNCT_BUTTON);
00771     gtk_widget_show (widget_show_punct_icon);
00772     property_window->widget_show_punct_icon = widget_show_punct_icon;
00773     gtk_table_attach (GTK_TABLE (table), widget_show_punct_icon, 0, 2, 2, 3,
00774                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
00775                           (GtkAttachOptions) (GTK_EXPAND), 4, 0);
00776     g_signal_connect (G_OBJECT (widget_show_punct_icon), "toggled",
00777                       G_CALLBACK (property_window_set_modified_status_callback),
00778                       property_window);
00779 
00780     widget_show_vkb_icon = gtk_check_button_new_with_mnemonic (STATUSBAR_SHOW_VKB_BUTTON);
00781     gtk_widget_show (widget_show_vkb_icon);
00782     property_window->widget_show_vkb_icon = widget_show_vkb_icon;
00783     gtk_table_attach (GTK_TABLE (table), widget_show_vkb_icon, 1, 2, 0, 1,
00784                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
00785                           (GtkAttachOptions) (GTK_EXPAND), 4, 0);
00786     g_signal_connect (G_OBJECT (widget_show_vkb_icon), "toggled",
00787                       G_CALLBACK (property_window_set_modified_status_callback),
00788                       property_window);
00789 
00790     widget_show_utility_icon = gtk_check_button_new_with_mnemonic (STATUSBAR_SHOW_UTILITY_BUTTON);
00791     gtk_widget_show (widget_show_utility_icon);
00792     property_window->widget_show_utility_icon = widget_show_utility_icon;
00793     gtk_table_attach (GTK_TABLE (table), widget_show_utility_icon, 1, 2, 1, 2,
00794                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
00795                           (GtkAttachOptions) (GTK_EXPAND), 4, 0);
00796     g_signal_connect (G_OBJECT (widget_show_utility_icon), "toggled",
00797                       G_CALLBACK (property_window_set_modified_status_callback),
00798                       property_window);
00799 
00800     // Create the ToolBar setup block.
00801     frame = gtk_frame_new (STATUSBAR_DIRECTION_FRAME);
00802     gtk_widget_show (frame);
00803     gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
00804     gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
00805 
00806     hbox = gtk_hbox_new(FALSE, 20);
00807     gtk_widget_show(hbox);
00808     gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
00809     gtk_container_add(GTK_CONTAINER (frame), hbox);
00810 
00811     widget_direction_vertical = gtk_radio_button_new_with_mnemonic (NULL, STATUSBAR_VERTICAL_STYLE);
00812     gtk_widget_show (widget_direction_vertical);
00813     property_window->widget_direction_vertical = widget_direction_vertical;
00814     gtk_box_pack_start(GTK_BOX (hbox), widget_direction_vertical, FALSE, FALSE, 5);
00815     g_signal_connect (G_OBJECT (widget_direction_vertical), "toggled",
00816                       G_CALLBACK (property_window_set_modified_status_callback),
00817                       property_window);
00818 
00819     group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (widget_direction_vertical));
00820     widget_direction_horizontal = gtk_radio_button_new_with_mnemonic (group, STATUSBAR_HORIZONTAL_STYLE);
00821     gtk_widget_show (widget_direction_horizontal);
00822     property_window->widget_direction_horizontal = widget_direction_horizontal;
00823     gtk_box_pack_start(GTK_BOX (hbox), widget_direction_horizontal, FALSE, FALSE, 5);
00824     g_signal_connect (G_OBJECT (widget_direction_horizontal), "toggled",
00825                       G_CALLBACK (property_window_set_modified_status_callback),
00826                       property_window);
00827 
00828     gtk_widget_hide(vbox);
00829 
00830     return vbox;
00831 }
00832 
00833 /*************************************************************/
00834 /*           properties for shortcut keys                    */
00835 /*************************************************************/
00836 static GtkWidget *
00837 property_window_create_fkey_setting_view(property_window_t *property_window,
00838                                     property_data_t *property_data)
00839 {
00840     GtkWidget *vbox;
00841     GtkWidget *label;
00842     GtkWidget *header;
00843     GtkWidget *frame;
00844     GtkWidget *table;
00845     GtkWidget *hbox;
00846 /*
00847     GtkWidget *toggle_ctrl;
00848     GtkWidget *toggle_alt;
00849     GtkWidget *toggle_shift;
00850 */
00851 
00852     GtkWidget *option_menu, *menu, *menu_item;
00853     int i;
00854     char buf[4];
00855 
00856     vbox = gtk_vbox_new (FALSE, 6);
00857     gtk_widget_show(vbox);
00858     gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
00859 
00860     header = property_window_create_category_header(CATEGORY_FKEY_SETTING_STR);
00861     gtk_box_pack_start(GTK_BOX(vbox), header, FALSE, FALSE, 4);
00862 
00863     // Create the ToolBar setup block.
00864     frame = gtk_frame_new (FKEY_SETTING_VKB_FRAME);
00865     gtk_widget_show (frame);
00866     gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
00867 
00868     table = gtk_table_new (1, 2, FALSE);
00869     gtk_widget_show (table);
00870     gtk_container_set_border_width (GTK_CONTAINER (table), 8);
00871     gtk_container_add (GTK_CONTAINER (frame), table);
00872     gtk_table_set_row_spacings (GTK_TABLE (table), 4);
00873     gtk_table_set_col_spacings (GTK_TABLE (table), 8);
00874 
00875     label = gtk_label_new (FKEY_VKB_LABEL);
00876     gtk_widget_show (label);
00877     gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
00878                           (GtkAttachOptions) (GTK_FILL),
00879                           (GtkAttachOptions) (0), 4, 0);
00880     gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
00881 
00882     hbox = gtk_hbox_new (FALSE, 0);
00883     gtk_widget_show (hbox);
00884     gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 0, 1,
00885                       (GtkAttachOptions) (GTK_FILL),
00886                       (GtkAttachOptions) (0), 4, 4);
00887 
00888 #if 0
00889     toggle_ctrl = gtk_check_button_new_with_mnemonic (_("_Ctrl"));
00890     gtk_widget_show (toggle_ctrl);
00891     gtk_box_pack_start (GTK_BOX (hbox), toggle_ctrl, TRUE, TRUE, 2);
00892 
00893     toggle_alt = gtk_check_button_new_with_mnemonic (_("A_lt"));
00894     gtk_widget_show (toggle_alt);
00895     gtk_box_pack_start (GTK_BOX (hbox), toggle_alt, TRUE, TRUE, 2);
00896 
00897     toggle_shift = gtk_check_button_new_with_mnemonic (_("_Shift"));
00898     gtk_widget_show (toggle_shift);
00899     gtk_box_pack_start (GTK_BOX (hbox), toggle_shift, TRUE, TRUE, 2);
00900 #endif
00901 
00902     option_menu = gtk_option_menu_new();
00903     gtk_widget_show (option_menu);
00904     g_signal_connect (G_OBJECT (option_menu), "changed",
00905                     G_CALLBACK (property_window_set_modified_status_callback),
00906                     property_window);
00907 
00908     menu = gtk_menu_new();
00909     gtk_widget_show (menu);
00910     buf[0] = ' ';
00911     buf[2] = ' ';
00912     buf[3] = '\0';
00913     for (i = 0; i < 26; i++) {
00914         buf[1] = 'A'+ i;
00915        menu_item = gtk_menu_item_new_with_label (buf);
00916        gtk_widget_show (menu_item);
00917        gtk_menu_shell_append (GTK_MENU_SHELL (menu),
00918                             menu_item);
00919     }
00920     gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
00921     property_window->widget_fkey_vkb_list = option_menu;
00922 
00923     gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 2);
00924     gtk_widget_hide(vbox);
00925 
00926     return vbox;
00927 }
00928 
00929 static GtkWidget *
00930 property_window_create_beep_setting_view(property_window_t *property_window,
00931                                     property_data_t *property_data)
00932 {
00933     GtkWidget *vbox;
00934     GtkWidget *header;
00935     GtkWidget *frame;
00936     GtkWidget *hbox;
00937     GtkWidget *widget_beep_enabled;
00938     GtkWidget *widget_beep_disabled;
00939     GSList    *group;
00940     
00941     vbox = gtk_vbox_new (FALSE, 6);
00942     gtk_widget_show(vbox);
00943     gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
00944 
00945     header = property_window_create_category_header(CATEGORY_BEEP_SETTING_STR);
00946     gtk_box_pack_start(GTK_BOX(vbox), header, FALSE, FALSE, 4);
00947 
00948     // Create the ToolBar setup block.
00949     frame = gtk_frame_new (BEEP_SETTING_FRAME);
00950     gtk_widget_show (frame);
00951     gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
00952     gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
00953 
00954     hbox = gtk_hbox_new(FALSE, 20);
00955     gtk_widget_show(hbox);
00956     gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
00957     gtk_container_add(GTK_CONTAINER (frame), hbox);
00958 
00959     widget_beep_enabled = gtk_radio_button_new_with_mnemonic (NULL, BEEP_ENABLE_STYLE);
00960     gtk_widget_show (widget_beep_enabled);
00961     property_window->widget_beep_enabled = widget_beep_enabled;
00962     gtk_box_pack_start(GTK_BOX (hbox), widget_beep_enabled, FALSE, FALSE, 5);
00963     g_signal_connect (G_OBJECT (widget_beep_enabled), "toggled",
00964                       G_CALLBACK (property_window_set_modified_status_callback),
00965                       property_window);
00966 
00967     group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (widget_beep_enabled));
00968     widget_beep_disabled = gtk_radio_button_new_with_mnemonic (group, BEEP_DISABLE_STYLE);
00969     gtk_widget_show (widget_beep_disabled);
00970     property_window->widget_beep_disabled = widget_beep_disabled;
00971     gtk_box_pack_start(GTK_BOX (hbox), widget_beep_disabled, FALSE, FALSE, 5);
00972     g_signal_connect (G_OBJECT (widget_beep_disabled), "toggled",
00973                       G_CALLBACK (property_window_set_modified_status_callback),
00974                       property_window);
00975 
00976     gtk_widget_hide(vbox);
00977 
00978     return vbox;
00979 }
00980 
00981 /*************************************************************/
00982 /*           properties for IMEs' status                     */
00983 /*************************************************************/
00984 GtkListStore *property_window_create_ime_list_model(property_window_t *property_window,
00985                                               property_data_t *property_data)
00986 {
00987     int i;
00988     GtkListStore *model;
00989     GtkTreeIter iter;
00990 
00991     model = gtk_list_store_new(IME_LIST_NUM_COLUMNS,
00992                             G_TYPE_BOOLEAN,
00993                             G_TYPE_STRING,
00994                             G_TYPE_POINTER,
00995                             G_TYPE_BOOLEAN);
00996 
00997     if (property_data == NULL)
00998         return model;
00999 
01000     for (i = 0; i < property_data->num_ime_modules; i++) {
01001         ime_module_t *ime_module = property_data->ime_modules[i];
01002 
01003         if (ime_module == NULL || 
01004            ime_module->name == NULL)
01005             continue;
01006 
01007        gtk_list_store_append(model, &iter);
01008        gtk_list_store_set(model, &iter,
01009                         IME_LIST_ENABLE, ime_module->enabled,
01010                         IME_LIST_NAME, ime_module->name,
01011                         IME_LIST_MODULE_POINTER, ime_module,
01012                         IME_LIST_INCONSISTENT, FALSE,
01013                         -1);
01014     }
01015 
01016     return model;
01017 }
01018 
01019 
01020 void property_window_ime_set_as_default_cb(GtkWidget *widget, gpointer user_data)
01021 {
01022     GtkWidget *ime_list_view;
01023     GtkTreeSelection *selection;
01024     GtkTreeModel *model;
01025     GtkTreeIter iter;
01026 
01027     property_window_t *property_window = (property_window_t *) user_data;
01028 
01029     if (property_window == NULL)
01030        return;
01031 
01032     ime_list_view = property_window->ime_list_view;
01033     if (ime_list_view == NULL)
01034        return;
01035 
01036     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ime_list_view));
01037 
01038     if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
01039         GtkTreePath* first_path = gtk_tree_path_new_first();
01040         GtkTreePath* now_path = gtk_tree_model_get_path(model, &iter);
01041        if (gtk_tree_path_compare(first_path, now_path)!=0) {
01042            gtk_list_store_move_after(GTK_LIST_STORE(model), &iter, NULL);
01043            gtk_tree_selection_select_path(selection, first_path);
01044            gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (ime_list_view), first_path, NULL, FALSE, 0, 0);
01045         }
01046         gtk_tree_path_free(first_path);
01047         gtk_tree_path_free(now_path);
01048     }
01049 
01050     property_window_set_modified_status(property_window, TRUE);
01051 }
01052 
01053 void property_window_ime_move_up_cb(GtkWidget *widget, gpointer user_data)
01054 {
01055     GtkWidget *ime_list_view;
01056     GtkTreeSelection *selection;
01057     GtkTreeModel *model;
01058     GtkTreeIter iter;
01059 
01060     property_window_t *property_window = (property_window_t *) user_data;
01061 
01062     if (property_window == NULL)
01063        return;
01064 
01065     ime_list_view = property_window->ime_list_view;
01066     if (ime_list_view == NULL)
01067        return;
01068 
01069     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ime_list_view));
01070 
01071     if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
01072         GtkTreePath* path = gtk_tree_model_get_path(model, &iter);
01073         if (gtk_tree_path_prev(path)) {
01074            GtkTreeIter prev;
01075 
01076            gtk_tree_model_get_iter(model, &prev, path);
01077            gtk_list_store_swap(GTK_LIST_STORE(model), &iter, &prev);
01078            gtk_tree_selection_select_path(selection, path);
01079 
01080            gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (ime_list_view), path, NULL, FALSE, 0, 0);
01081         }
01082         gtk_tree_path_free(path);
01083     }
01084 
01085     property_window_set_modified_status(property_window, TRUE);
01086 }
01087 
01088 void property_window_ime_move_down_cb(GtkWidget *widget, gpointer user_data)
01089 {
01090     GtkWidget *ime_list_view;
01091     GtkTreeSelection *selection;
01092     GtkTreeModel *model;
01093     GtkTreeIter iter;
01094 
01095     property_window_t *property_window = (property_window_t *) user_data;
01096 
01097     if (property_window == NULL)
01098        return;
01099 
01100     ime_list_view = property_window->ime_list_view;
01101     if (ime_list_view == NULL)
01102        return;
01103 
01104     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ime_list_view));
01105 
01106     if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
01107         GtkTreeIter next;
01108         GtkTreePath* path = gtk_tree_model_get_path(model, &iter);
01109         gtk_tree_path_next(path);
01110         if (gtk_tree_model_get_iter(model, &next, path)) {
01111            gtk_list_store_swap(GTK_LIST_STORE(model), &iter, &next);
01112            gtk_tree_selection_select_path(selection, path);
01113            gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (ime_list_view), path, NULL, FALSE, 0, 0);
01114         }
01115         gtk_tree_path_free(path);
01116     }
01117 
01118     property_window_set_modified_status(property_window, TRUE);
01119 }
01120 
01121 void property_window_ime_enable_toggled_cb (GtkCellRendererToggle *cell,
01122                                        gchar *path_str,
01123                                        gpointer user_data)
01124 {
01125     GtkTreeModel *ime_list_model;
01126     GtkTreeIter  iter;
01127     GtkTreePath  *path = gtk_tree_path_new_from_string (path_str);
01128     gboolean enabled;
01129 
01130     property_window_t *property_window = (property_window_t *) user_data;
01131 
01132     if (property_window == NULL)
01133        return;
01134 
01135     ime_list_model = (GtkTreeModel *)property_window->ime_list_model;
01136     if (ime_list_model == NULL)
01137        return;
01138 
01139     gtk_tree_model_get_iter (ime_list_model, &iter, path);
01140     gtk_tree_model_get (ime_list_model, &iter, IME_LIST_ENABLE, &enabled, -1);
01141 
01142     enabled = !enabled;
01143 
01144     DEBUG_printf("enabled: %d\n", enabled);
01145     gtk_list_store_set (GTK_LIST_STORE (ime_list_model), &iter, IME_LIST_ENABLE, enabled, -1);
01146 
01147     gtk_tree_path_free (path);
01148 
01149     property_window_set_modified_status(property_window, TRUE);
01150 }
01151 
01152 GtkWidget *property_window_create_ime_list_view(property_window_t *property_window)
01153 {
01154     GtkWidget *vbox;
01155     GtkWidget *scrolledwindow;
01156     GtkWidget *header;
01157     GtkWidget *frame;
01158     GtkWidget *hbox1, *vbox1;
01159     GtkWidget *up_button, *down_button;
01160     GtkWidget *default_button;
01161 
01162     GtkWidget *ime_list_view;
01163     GtkTreeModel *model;
01164     GtkCellRenderer *renderer;
01165     GtkTreeViewColumn *column;
01166     GtkTreeSelection *selection;
01167 
01168     vbox = gtk_vbox_new(FALSE, 4);
01169     gtk_widget_show(vbox);
01170     gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
01171 
01172     header = property_window_create_category_header(CATEGORY_IMESTATUS_SETTING_STR);
01173     gtk_box_pack_start(GTK_BOX(vbox), header, FALSE, FALSE, 4);
01174 
01175     hbox1 = gtk_hbox_new(FALSE, 4);
01176     gtk_widget_show(hbox1);
01177     gtk_box_pack_start(GTK_BOX(vbox), hbox1, TRUE, TRUE, 4);
01178 
01179     scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
01180     gtk_widget_show(scrolledwindow);
01181     gtk_box_pack_start(GTK_BOX(hbox1), scrolledwindow, TRUE, TRUE, 4);
01182     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolledwindow),
01183                                GTK_POLICY_AUTOMATIC,
01184                                GTK_POLICY_AUTOMATIC);
01185     gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolledwindow),
01186                                    GTK_SHADOW_NONE);
01187 
01188     ime_list_view = gtk_tree_view_new ();
01189     gtk_widget_show(ime_list_view);
01190     property_window->ime_list_view = ime_list_view;
01191     gtk_container_add(GTK_CONTAINER (scrolledwindow), ime_list_view);
01192     gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (ime_list_view), TRUE);
01193     gtk_tree_view_set_rules_hint(GTK_TREE_VIEW (ime_list_view), TRUE);
01194 
01195     // Enable column
01196     column = gtk_tree_view_column_new();
01197     gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
01198     gtk_tree_view_column_set_resizable(column, FALSE);
01199     gtk_tree_view_column_set_title(column, IME_COLUMN_ENABLE_STR);
01200 
01201     renderer = gtk_cell_renderer_toggle_new();
01202     gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE (renderer), FALSE);
01203     gtk_tree_view_column_pack_start(column, renderer, FALSE);
01204     gtk_tree_view_column_set_attributes(column, renderer,
01205                                    "active", IME_LIST_ENABLE,
01206                                    "inconsistent", IME_LIST_INCONSISTENT,
01207                                    NULL);
01208     g_signal_connect (G_OBJECT (renderer), "toggled",
01209                       G_CALLBACK (property_window_ime_enable_toggled_cb),
01210                       property_window);
01211 
01212     gtk_tree_view_append_column(GTK_TREE_VIEW (ime_list_view), column);
01213 
01214     // Name column
01215     column = gtk_tree_view_column_new();
01216     gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
01217     gtk_tree_view_column_set_resizable(column, FALSE);
01218 
01219     gtk_tree_view_column_set_title(column, IME_COLUMN_NAME_STR);
01220 
01221     renderer = gtk_cell_renderer_text_new();
01222     gtk_tree_view_column_pack_start(column, renderer, TRUE);
01223     gtk_tree_view_column_set_attributes(column, renderer,
01224                                    "text", IME_LIST_NAME, NULL);
01225 
01226     gtk_tree_view_append_column(GTK_TREE_VIEW (ime_list_view), column);
01227 
01228     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW (ime_list_view));
01229     gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
01230 
01231     vbox1 = gtk_vbox_new(FALSE, 4);
01232     gtk_widget_show(vbox1);
01233     gtk_box_pack_start(GTK_BOX (hbox1), vbox1, FALSE, FALSE, 4);
01234 
01235     default_button = gtk_button_new_from_stock(GTK_STOCK_GOTO_TOP);
01236     gtk_widget_show(default_button);
01237     gtk_box_pack_start(GTK_BOX (vbox1), default_button, FALSE, FALSE, 4);
01238     g_signal_connect(G_OBJECT (default_button),"clicked", 
01239                    G_CALLBACK (property_window_ime_set_as_default_cb),
01240                    property_window);
01241 
01242     up_button = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
01243     gtk_widget_show(up_button);
01244     gtk_box_pack_start(GTK_BOX (vbox1), up_button, FALSE, FALSE, 4);
01245     g_signal_connect(G_OBJECT (up_button),"clicked", 
01246                    G_CALLBACK (property_window_ime_move_up_cb),
01247                    property_window);
01248 
01249     down_button = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
01250     gtk_widget_show(down_button);
01251     gtk_box_pack_start(GTK_BOX (vbox1), down_button, FALSE, FALSE, 4);
01252     g_signal_connect(G_OBJECT (down_button),"clicked", 
01253                    G_CALLBACK (property_window_ime_move_down_cb),
01254                    property_window);
01255 
01256     gtk_widget_hide(vbox);
01257 
01258     return vbox;
01259 }
01260 
01261 /*************************************************************/
01262 /*           properties for IMEs                             */
01263 /*************************************************************/
01264 GtkWidget *property_window_create_ime_property_view(property_window_t *property_window,
01265                                               ime_module_t *ime_module,
01266                                               ime_module_widget_t *ime_module_widget)
01267 {
01268     GtkWidget *vbox;
01269     GtkWidget *header;
01270     GtkWidget *scrolledwindow;
01271     GtkWidget *vbox1;
01272     GtkWidget *check;
01273     GtkWidget *table;
01274     GtkWidget *label;
01275     GtkWidget *combo;
01276     char buf[128];
01277     int i;
01278 
01279     ImePropertyListRec *property_list;
01280 
01281     if (ime_module == NULL ||
01282        ime_module->property_list == NULL ||
01283        ime_module_widget == NULL)
01284        return NULL;
01285 
01286     property_list = ime_module->property_list;
01287 
01288     vbox = gtk_vbox_new(FALSE, 4);
01289     gtk_widget_show(vbox);
01290     gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
01291 
01292     snprintf(buf, 127, "%s - %s", CATEGORY_IME_SETTING_STR, ime_module->name);
01293     header = property_window_create_category_header(buf);
01294     gtk_box_pack_start(GTK_BOX(vbox), header, FALSE, FALSE, 4);
01295 
01296 /*
01297     scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
01298     gtk_widget_show(scrolledwindow);
01299     gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 4);
01300     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
01301                                GTK_POLICY_AUTOMATIC,
01302                                GTK_POLICY_AUTOMATIC);
01303     gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolledwindow),
01304                                         GTK_SHADOW_NONE);
01305 */
01306 
01307     table= gtk_table_new(0, 2, FALSE);
01308     gtk_widget_show(table);
01309     gtk_table_set_row_spacings (GTK_TABLE (table), 2);
01310     gtk_table_set_col_spacings (GTK_TABLE (table), 12);
01311     gtk_container_set_border_width (GTK_CONTAINER (table), 2);
01312 /*
01313     gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (scrolledwindow),
01314                                      GTK_WIDGET(table));
01315 */
01316     gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
01317 
01318     ime_module_widget->num_ime_properties = property_list->count;
01319     ime_module_widget->ime_property_widgets = (ime_property_widget_t **)calloc(property_list->count,
01320                                                                sizeof(ime_property_widget_t *));
01321 
01322     if (ime_module_widget->ime_property_widgets == NULL)
01323        return vbox;
01324 
01325     for (i = 0; i < property_list->count; i ++) {
01326        ImePropertyRec *ime_property = &(property_list->properties[i]);
01327 
01328        ime_module_widget->ime_property_widgets[i] = (ime_property_widget_t *)calloc(1,
01329                                                         sizeof (ime_property_widget_t));
01330        if (ime_module_widget->ime_property_widgets[i] == NULL)
01331            continue;
01332 
01333        ime_module_widget->ime_property_widgets[i]->ime_property = ime_property;
01334 
01335        if (ime_property->type == ImeProperty_Toggle) {
01336            gtk_table_resize(GTK_TABLE(table), i+1, 2);
01337            check = gtk_check_button_new_with_label(ime_property->name);
01338            gtk_widget_show(check);
01339            g_signal_connect (G_OBJECT (check), "toggled",
01340                            G_CALLBACK (property_window_set_modified_status_callback),
01341                            property_window);
01342 
01343            gtk_table_attach (GTK_TABLE (table), check, 0, 1, i, i + 1,
01344                           (GtkAttachOptions) (GTK_FILL),
01345                           (GtkAttachOptions) (0), 0, 0);
01346 
01347            ime_module_widget->ime_property_widgets[i]->widget = check;
01348 
01349        } else if (ime_property->type == ImeProperty_Selection) {
01350            int j;
01351            char **value_ptr;
01352            GtkWidget *alignment;
01353            GtkWidget *option_menu, *menu, *menu_item;
01354 
01355            gtk_table_resize(GTK_TABLE(table), i+1, 2);
01356            label = gtk_label_new(ime_property->name);
01357            gtk_widget_show(label);
01358 
01359            gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i + 1,
01360                           (GtkAttachOptions) (GTK_FILL),
01361                           (GtkAttachOptions) (0), 0, 0);
01362            gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
01363 
01364            alignment = gtk_alignment_new (0, 0.5, 0, 1);
01365            gtk_widget_show (alignment);
01366            gtk_table_attach (GTK_TABLE (table), alignment, 1, 2, i, i + 1,
01367                            (GtkAttachOptions) (GTK_FILL),
01368                            (GtkAttachOptions) (0), 0, 0);
01369 
01370            option_menu = gtk_option_menu_new();
01371            gtk_widget_show (option_menu);
01372            g_signal_connect (G_OBJECT (option_menu), "changed",
01373                            G_CALLBACK (property_window_set_modified_status_callback),
01374                            property_window);
01375 
01376            menu = gtk_menu_new();
01377            gtk_widget_show (menu);
01378            value_ptr = ime_property->range.multiString_range;
01379            if (value_ptr != NULL) {
01380                for (j = 0; value_ptr[j]; j++) {
01381                    menu_item = gtk_menu_item_new_with_label (value_ptr[j]);
01382                    gtk_widget_show (menu_item);
01383                    gtk_menu_shell_append (GTK_MENU_SHELL (menu),
01384                                        menu_item);
01385                }
01386            }
01387            gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
01388 
01389            gtk_container_add (GTK_CONTAINER (alignment), option_menu);
01390 
01391            ime_module_widget->ime_property_widgets[i]->widget = option_menu;
01392 
01393        } else if (ime_property->type == ImeProperty_Int) {
01394            GtkWidget *alignment;
01395            GtkWidget *spin_button;
01396            int value_min, value_max;
01397 
01398            gtk_table_resize(GTK_TABLE(table), i+1, 2);
01399            label = gtk_label_new(ime_property->name);
01400            gtk_widget_show(label);
01401 
01402            gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i + 1,
01403                           (GtkAttachOptions) (GTK_FILL),
01404                           (GtkAttachOptions) (0), 0, 0);
01405            gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
01406 
01407            alignment = gtk_alignment_new (0, 0.5, 0, 1);
01408            gtk_widget_show (alignment);
01409            gtk_table_attach (GTK_TABLE (table), alignment, 1, 2, i, i + 1,
01410                            (GtkAttachOptions) (GTK_FILL),
01411                            (GtkAttachOptions) (0), 0, 0);
01412 
01413            value_min = ime_property->range.int_range.min;
01414            value_max = ime_property->range.int_range.max;
01415            spin_button = gtk_spin_button_new_with_range (value_min, value_max, value_min);
01416            gtk_widget_show (spin_button);
01417            gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), 1);
01418            g_signal_connect (G_OBJECT (spin_button), "value_changed",
01419                            G_CALLBACK (property_window_set_modified_status_callback),
01420                            property_window);
01421 
01422            gtk_container_add (GTK_CONTAINER (alignment), spin_button);
01423 
01424            ime_module_widget->ime_property_widgets[i]->widget = spin_button;
01425        }
01426     }
01427 
01428     gtk_widget_hide(vbox);
01429 
01430     return vbox;
01431 }
01432 
01433 /*************************************************************/
01434 /*           Version/Copyright Info                          */
01435 /*************************************************************/
01436 /* create copyright view */
01437 static GtkWidget *
01438 property_window_create_copyright_view()
01439 {
01440     GtkWidget *vbox;
01441     GtkWidget *header;
01442     GtkWidget *hbox1;
01443     GtkWidget *label_title;
01444     GtkWidget *label_space;
01445     GtkWidget *label_info;
01446     GtkWidget *vbox_category;
01447     GtkWidget *vbox_info;
01448 
01449     vbox = gtk_vbox_new(FALSE, 10);
01450     gtk_widget_show(vbox);
01451     gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
01452 
01453     header = property_window_create_category_header(CATEGORY_COPYRIGHT_STR);
01454     gtk_box_pack_start(GTK_BOX(vbox), header, FALSE, FALSE, 4);
01455 
01456     /* for copyright category */
01457     vbox_category = gtk_vbox_new (FALSE, 6);
01458     gtk_widget_show (vbox_category);
01459     gtk_box_pack_start (GTK_BOX (vbox), vbox_category, FALSE, FALSE, 0);
01460 
01461     label_title = gtk_label_new (INFO_COPYRIGHT_STR);
01462     gtk_widget_show (label_title);
01463     gtk_box_pack_start (GTK_BOX (vbox_category), label_title, FALSE, FALSE, 0);
01464     gtk_label_set_use_markup (GTK_LABEL (label_title), TRUE);
01465     gtk_misc_set_alignment (GTK_MISC (label_title), 0, 0.5);
01466 
01467     hbox1 = gtk_hbox_new (FALSE, 0);
01468     gtk_widget_show (hbox1);
01469     gtk_box_pack_start (GTK_BOX (vbox_category), hbox1, FALSE, FALSE, 0);
01470 
01471     label_space = gtk_label_new (INFO_INDENT_STR);
01472     gtk_widget_show (label_space);
01473     gtk_box_pack_start (GTK_BOX (hbox1), label_space, FALSE, FALSE, 0);
01474 
01475     vbox_info = gtk_vbox_new (FALSE, 6);
01476     gtk_widget_show (vbox_info);
01477     gtk_box_pack_start (GTK_BOX (hbox1), vbox_info, FALSE, FALSE, 0);
01478 
01479     label_info = gtk_label_new (INFO_LANGUAGE_ENGINE_STR);
01480     gtk_widget_show (label_info);
01481     gtk_box_pack_start (GTK_BOX (vbox_info), label_info, FALSE, FALSE, 0);
01482     gtk_label_set_use_markup (GTK_LABEL (label_info), TRUE);
01483     gtk_misc_set_alignment (GTK_MISC (label_info), 0, 0.5);
01484 
01485     /* for Internet category */
01486     vbox_category = gtk_vbox_new (FALSE, 6);
01487     gtk_widget_show (vbox_category);
01488     gtk_box_pack_start (GTK_BOX (vbox), vbox_category, FALSE, FALSE, 0);
01489 
01490     label_title = gtk_label_new (INFO_INTERNET_STR);
01491     gtk_widget_show (label_title);
01492     gtk_box_pack_start (GTK_BOX (vbox_category), label_title, FALSE, FALSE, 0);
01493     gtk_label_set_use_markup (GTK_LABEL (label_title), TRUE);
01494     gtk_misc_set_alignment (GTK_MISC (label_title), 0, 0.5);
01495 
01496     hbox1 = gtk_hbox_new (FALSE, 0);
01497     gtk_widget_show (hbox1);
01498     gtk_box_pack_start (GTK_BOX (vbox_category), hbox1, FALSE, FALSE, 0);
01499 
01500     label_space = gtk_label_new (INFO_INDENT_STR);
01501     gtk_widget_show (label_space);
01502     gtk_box_pack_start (GTK_BOX (hbox1), label_space, FALSE, FALSE, 0);
01503   
01504     label_info = gtk_label_new (_("http://www.openi18n.org"));
01505     gtk_widget_show (label_info);
01506     gtk_box_pack_start (GTK_BOX (hbox1), label_info, FALSE, FALSE, 0);
01507     gtk_label_set_use_markup (GTK_LABEL (label_info), TRUE);
01508     gtk_misc_set_alignment (GTK_MISC (label_info), 0, 0.5);
01509 
01510     /* for Developers category */
01511     vbox_category = gtk_vbox_new (FALSE, 6);
01512     gtk_widget_show (vbox_category);
01513     gtk_box_pack_start (GTK_BOX (vbox), vbox_category, FALSE, FALSE, 0);
01514 
01515     label_title = gtk_label_new (INFO_DEVELOPERS_STR);
01516     gtk_widget_show (label_title);
01517     gtk_box_pack_start (GTK_BOX (vbox_category), label_title, FALSE, FALSE, 0);
01518     gtk_label_set_use_markup (GTK_LABEL (label_title), TRUE);
01519     gtk_misc_set_alignment (GTK_MISC (label_title), 0, 0.5);
01520 
01521     hbox1 = gtk_hbox_new (FALSE, 0);
01522     gtk_widget_show (hbox1);
01523     gtk_box_pack_start (GTK_BOX (vbox_category), hbox1, TRUE, TRUE, 0);
01524 
01525     label_space = gtk_label_new (INFO_INDENT_STR);
01526     gtk_widget_show (label_space);
01527     gtk_box_pack_start (GTK_BOX (hbox1), label_space, FALSE, FALSE, 0);
01528 
01529     vbox_info = gtk_vbox_new (FALSE, 6);
01530     gtk_widget_show (vbox_info);
01531     gtk_box_pack_start (GTK_BOX (hbox1), vbox_info, FALSE, FALSE, 0);
01532 
01533     label_info = gtk_label_new (INFO_DEVELOPER_NAMES_STR);
01534     gtk_widget_show (label_info);
01535     gtk_box_pack_start (GTK_BOX (vbox_info), label_info, FALSE, FALSE, 0);
01536     gtk_label_set_use_markup (GTK_LABEL (label_info), TRUE);
01537     gtk_misc_set_alignment (GTK_MISC (label_info), 0, 0.5);
01538 
01539     /* for Acknowledgement category */
01540     vbox_category = gtk_vbox_new (FALSE, 6);
01541     gtk_widget_show (vbox_category);
01542     gtk_box_pack_start (GTK_BOX (vbox), vbox_category, FALSE, FALSE, 0);
01543 
01544     label_title = gtk_label_new (INFO_THANKS_STR);
01545     gtk_widget_show (label_title);
01546     gtk_box_pack_start (GTK_BOX (vbox_category), label_title, FALSE, FALSE, 0);
01547     gtk_label_set_use_markup (GTK_LABEL (label_title), TRUE);
01548     gtk_misc_set_alignment (GTK_MISC (label_title), 0, 0.5);
01549 
01550     hbox1 = gtk_hbox_new (FALSE, 0);
01551     gtk_widget_show (hbox1);
01552     gtk_box_pack_start (GTK_BOX (vbox_category), hbox1, TRUE, TRUE, 0);
01553 
01554     label_space = gtk_label_new (INFO_INDENT_STR);
01555     gtk_widget_show (label_space);
01556     gtk_box_pack_start (GTK_BOX (hbox1), label_space, FALSE, FALSE, 0);
01557 
01558     vbox_info = gtk_vbox_new (FALSE, 6);
01559     gtk_widget_show (vbox_info);
01560     gtk_box_pack_start (GTK_BOX (hbox1), vbox_info, FALSE, FALSE, 0);
01561 
01562     label_info = gtk_label_new (INFO_THANK_NAMES_STR);
01563     gtk_widget_show (label_info);
01564     gtk_box_pack_start (GTK_BOX (vbox_info), label_info, FALSE, FALSE, 0);
01565     gtk_label_set_use_markup (GTK_LABEL (label_info), TRUE);
01566     gtk_misc_set_alignment (GTK_MISC (label_info), 0, 0.5);
01567 
01568     gtk_widget_hide(vbox);
01569 
01570     return vbox;
01571 }
01572 
01573 /*************************************************************/
01574 /*           Categories List Treeview                        */
01575 /*************************************************************/
01576 GtkTreeModel *
01577 property_window_create_category_list_model(property_window_t *property_window,
01578                                       property_data_t *property_data)
01579 {
01580     GtkTreeStore *category_list_model;
01581     GtkTreeIter iter, parent;
01582     GtkWidget *widget;
01583 
01584     int i, num_ime_modules;
01585 
01586     category_list_model = gtk_tree_store_new(CATEGORY_LIST_NUM_COLUMNS,
01587                                         G_TYPE_STRING,
01588                                         GTK_TYPE_WIDGET);
01589 
01590     /* Add system_setting catogory */
01591     widget = property_window_create_setting_cover(CATEGORY_SYSTEM_SETTING_STR);
01592     gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01593                      TRUE, 0);
01594 
01595     gtk_tree_store_append(category_list_model, &parent, NULL);
01596     gtk_tree_store_set(category_list_model, &parent,
01597                      CATEGORY_LIST_LABEL, CATEGORY_SYSTEM_SETTING_STR,
01598                      CATEGORY_LIST_WIDGET, widget,
01599                      -1);
01600                
01601     /* Add system_setting/imestatus_setting */
01602     widget = property_window_create_ime_list_view(property_window);
01603     gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01604                      TRUE, 0);
01605 
01606     gtk_tree_store_append(category_list_model, &iter, &parent);
01607     gtk_tree_store_set(category_list_model, &iter,
01608                      CATEGORY_LIST_LABEL, CATEGORY_IMESTATUS_SETTING_STR,
01609                      CATEGORY_LIST_WIDGET, widget,
01610                      -1);
01611 
01612     /* Add system_setting/fkey_setting */
01613     widget = property_window_create_fkey_setting_view(property_window, property_data);
01614     gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01615                      TRUE, 0);
01616 
01617     gtk_tree_store_append(category_list_model, &iter, &parent);
01618     gtk_tree_store_set(category_list_model, &iter,
01619                      CATEGORY_LIST_LABEL, CATEGORY_FKEY_SETTING_STR,
01620                      CATEGORY_LIST_WIDGET, widget,
01621                      -1);
01622 
01623 #if 0
01624     /* Add system_setting/candidate_setting */
01625     widget = property_window_create_candidate_style_view(property_window, property_data);
01626     gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01627                      TRUE, 0);
01628 
01629     gtk_tree_store_append(category_list_model, &iter, &parent);
01630     gtk_tree_store_set(category_list_model, &iter,
01631                      CATEGORY_LIST_LABEL, CATEGORY_CANDIDATE_SETTING_STR,
01632                      CATEGORY_LIST_WIDGET, widget,
01633                      -1);
01634 #endif
01635 
01636     /* Add system_setting/statusbar_setting */
01637     widget = property_window_create_statusbar_setting_view(property_window, property_data);
01638     gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01639                      TRUE, 0);
01640 
01641     gtk_tree_store_append(category_list_model, &iter, &parent);
01642     gtk_tree_store_set(category_list_model, &iter,
01643                      CATEGORY_LIST_LABEL, CATEGORY_STATUSBAR_SETTING_STR,
01644                      CATEGORY_LIST_WIDGET, widget,
01645                      -1);
01646 
01647     /* Add system_setting/beep_setting */
01648     widget = property_window_create_beep_setting_view(property_window, property_data);
01649     gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01650                      TRUE, 0);
01651 
01652     gtk_tree_store_append(category_list_model, &iter, &parent);
01653     gtk_tree_store_set(category_list_model, &iter,
01654                      CATEGORY_LIST_LABEL, CATEGORY_BEEP_SETTING_STR,
01655                      CATEGORY_LIST_WIDGET, widget,
01656                      -1);
01657 
01658     /* Add IME properties setting catogory */
01659     widget = property_window_create_setting_cover(CATEGORY_IME_SETTING_STR);
01660     gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01661                      TRUE, 0);
01662 
01663     gtk_tree_store_append(category_list_model, &parent, NULL);
01664     gtk_tree_store_set(category_list_model, &parent,
01665                      CATEGORY_LIST_LABEL, CATEGORY_IME_SETTING_STR,
01666                      CATEGORY_LIST_WIDGET, widget,
01667                      -1);
01668 
01669     /* Add IME_Setting/property_setting */
01670     num_ime_modules = property_data->num_ime_modules;
01671     property_window->num_ime_modules = num_ime_modules;
01672     property_window->ime_module_widgets = (ime_module_widget_t **) calloc (num_ime_modules,
01673                                                                   sizeof (ime_module_widget_t *));
01674     if (property_window->ime_module_widgets == NULL)
01675        return GTK_TREE_MODEL(category_list_model);
01676 
01677     for (i = 0; i < num_ime_modules; i++) {
01678        ime_module_t *ime_module = property_data->ime_modules[i];
01679        ime_module_widget_t *ime_module_widget;
01680 
01681         if (ime_module == NULL || 
01682            ime_module->property_list == NULL)
01683             continue;
01684 
01685        ime_module_widget = (ime_module_widget_t *) calloc(1, sizeof (ime_module_widget_t));
01686        if (ime_module_widget == NULL)
01687            continue;
01688 
01689        ime_module_widget->num_ime_properties = 0;
01690        ime_module_widget->ime_property_widgets = NULL;
01691 
01692        property_window->ime_module_widgets[i] = ime_module_widget;
01693 
01694        widget = property_window_create_ime_property_view(property_window, ime_module, ime_module_widget);
01695        gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01696                          TRUE, 0);
01697 
01698        gtk_tree_store_append(category_list_model, &iter, &parent);
01699        gtk_tree_store_set(category_list_model, &iter,
01700                          CATEGORY_LIST_LABEL, ime_module->name,
01701                          CATEGORY_LIST_WIDGET, widget,
01702                          -1);
01703     }
01704 
01705     /* Add Copyright catogory */
01706     widget = property_window_create_copyright_view();
01707     gtk_box_pack_start(GTK_BOX(property_window->work_area), widget, TRUE,
01708                      TRUE, 0);
01709 
01710     gtk_tree_store_append(category_list_model, &parent, NULL);
01711     gtk_tree_store_set(category_list_model, &parent,
01712                      CATEGORY_LIST_LABEL, CATEGORY_COPYRIGHT_STR,
01713                      CATEGORY_LIST_WIDGET, widget,
01714                      -1);
01715 
01716     return GTK_TREE_MODEL(category_list_model);
01717 }
01718 
01719 void property_window_realize_tree(GtkWidget * widget, gpointer * data)
01720 {
01721     gtk_tree_view_expand_all(GTK_TREE_VIEW(widget));
01722 }
01723 
01724 gboolean
01725 property_window_hide_widget_iter_func(GtkTreeModel * model,
01726                                    GtkTreePath * path,
01727                                    GtkTreeIter * iter, gpointer data)
01728 {
01729     GtkWidget *widget;
01730     gtk_tree_model_get(model, iter, CATEGORY_LIST_WIDGET, &widget, -1);
01731 
01732     if (widget) {
01733        gtk_widget_hide(widget);
01734        g_object_unref(widget);
01735     }
01736 
01737     return FALSE;
01738 }
01739 
01740 void
01741 property_window_selection_changed_cb(GtkTreeSelection * selection,
01742                                    gpointer user_data)
01743 {
01744     GtkTreeModel *model;
01745     GtkTreeIter iter;
01746     GtkWidget *widget;
01747     gchar *label;
01748 
01749     DEBUG_printf("property_window_selection_changed_cb \n");
01750     if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
01751        gtk_tree_model_get(model, &iter,
01752                         CATEGORY_LIST_LABEL, &label,
01753                         CATEGORY_LIST_WIDGET, &widget, -1);
01754 
01755        if (widget != NULL) {
01756            gtk_tree_model_foreach(model,
01757                                property_window_hide_widget_iter_func,
01758                                NULL);
01759            gtk_widget_show(widget);
01760            g_object_unref(widget);
01761        }
01762 
01763        if (label) {
01764            DEBUG_printf("label: %s\n", label);
01765            g_free(label);
01766        }
01767     }
01768 }
01769 
01770 GtkWidget *property_window_create_category_list_view()
01771 {
01772     GtkWidget *treeview;
01773     GtkCellRenderer *renderer;
01774     GtkTreeSelection *selection;
01775     GtkTreeViewColumn *column;
01776     gint col_offset;
01777 
01778     treeview = gtk_tree_view_new();
01779     gtk_widget_show(treeview);
01780     gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
01781     gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
01782     gtk_tree_view_set_enable_search(GTK_TREE_VIEW(treeview), FALSE);
01783 
01784     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
01785     gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
01786 
01787     /* add column for category */
01788     renderer = gtk_cell_renderer_text_new ();
01789     column = gtk_tree_view_column_new_with_attributes (NULL, renderer,
01790                                                  "text", CATEGORY_LIST_LABEL, NULL);
01791 
01792     gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
01793     gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(column), FALSE);
01794 
01795     g_signal_connect(selection, "changed",
01796                    G_CALLBACK(property_window_selection_changed_cb),
01797                    selection);
01798 
01799     g_signal_connect(G_OBJECT(treeview), "realize",
01800                    G_CALLBACK(property_window_realize_tree), treeview);
01801 
01802     return treeview;
01803 }