Back to index

im-sdk  12.3.91
palette_menu.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <gdk/gdkx.h>
00003 #include <gtk/gtk.h>
00004 #include <signal.h>
00005 #include <wait.h>
00006 
00007 #include "palette_messages.h"
00008 #include "palette_aux.h"
00009 #include "vkb_aux.h"
00010 
00011 extern palette_window_t *palette_window;
00012 
00013 void palette_window_set_menuitem_label(GtkWidget *menu_item, gchar *label);
00014 void palette_window_signal_child_handler(int sig, siginfo_t * info,
00015                               void *ucontext);
00016 
00017 void palette_window_change_current_ime(ime_module_t *ime_module,
00018                                    gboolean bNeedNotifyLE)
00019 {
00020     if (ime_module == NULL)
00021        return;
00022 
00023     if (bNeedNotifyLE) {
00024        palette_aux_Switch_LE_Engine_Request((char *)ime_module->uuid);
00025        return;
00026     }
00027 
00028     palette_window->current_ime = ime_module;
00029     palette_window_update_layout(palette_window);
00030 }
00031 
00032 static void
00033 palette_window_ime_menuitem_cb(GtkWidget *menuitem,
00034                             gpointer data)
00035 {
00036     ime_module_t *ime_module = (ime_module_t *)data;
00037 
00038     if (ime_module == NULL)
00039        return;
00040 
00041     ime_module_print(ime_module);
00042 
00043     palette_window_change_current_ime(ime_module, TRUE);
00044     return;
00045 }
00046 
00047 static gboolean
00048 palette_window_menu_button_release_cb(GtkWidget *menu,
00049                                   GdkEventButton *event,
00050                                   gpointer data)
00051 {
00052     palette_window_t *palette_window = (palette_window_t *)data;
00053     int x, y;
00054 
00055     DEBUG_printf("palette_window_ime_menu_button_release_cb ====\n");
00056 
00057     if (palette_window == NULL)
00058        return FALSE;
00059 
00060     gdk_window_get_pointer (palette_window->window->window, &x, &y, NULL);
00061     palette_window->focused_button = (palette_button_t *)
00062                                  palette_window_get_button_from_pos(palette_window, x, y);
00063 
00064     palette_window->pressed_button = NULL;
00065     palette_window_draw_layout(palette_window);
00066 
00067     palette_window->menu_popuped = 0;
00068 
00069     return FALSE;
00070 }
00071 
00072 GtkWidget *palette_window_create_ime_list_menu(palette_window_t *palette_window,
00073                                           property_data_t *property_data)
00074 {
00075     GtkWidget *menu; 
00076     GtkWidget *menu_item;
00077 
00078     char buf[256];
00079     gint width, height;
00080 
00081     int i;
00082 
00083     if (property_data == NULL)
00084        return NULL;
00085 
00086 /*
00087     property_data_print(property_data);
00088 */
00089 
00090     gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
00091     DEBUG_printf("icon: width: %d, height: %d\n", width, height);
00092 
00093     /* create icon for each ime entry */
00094     for (i = 0; i < property_data->num_ime_modules; i++) {
00095        char icon_path[256];
00096        ime_module_t *ime_module = property_data->ime_modules[i];
00097 
00098        if (ime_module == NULL)
00099            continue;
00100 
00101        if (ime_module->icon_pixbuf == NULL && ime_module->icon_file != NULL) {
00102            if (ime_module->icon_file[0] == '/')
00103               snprintf(icon_path, 256, "%s", ime_module->icon_file);
00104            else
00105               snprintf(icon_path, 256, "%s/icons/%s",
00106                       LE_IME_MODULES_DIR, ime_module->icon_file);
00107 
00108             ime_module->icon_pixbuf = (GdkPixbuf *)palette_window_new_pixbuf_from_xpm(
00109                                                              icon_path,
00110                                                              NULL,
00111                                                              width,
00112                                                              height,
00113                                                              FALSE);
00114        }
00115        if (ime_module->icon_pixbuf == NULL && palette_window->pixbufs[PIXMAP_ID_DEFAULT_IME])
00116            ime_module->icon_pixbuf = gdk_pixbuf_copy(
00117                             palette_window->pixbufs[PIXMAP_ID_DEFAULT_IME]);
00118     }
00119 
00120     menu = gtk_menu_new();
00121     for (i = 0; i < property_data->num_ime_modules; i++) {
00122        GtkWidget *icon_widget;
00123        ime_module_t *ime_module = property_data->ime_modules[i];
00124 
00125        if (ime_module == NULL)
00126            continue;
00127 
00128        if (ime_module->enabled == 0)
00129            continue;
00130 
00131         snprintf(buf, 256, "%s", (char *)ime_module->name);
00132 
00133         menu_item = gtk_image_menu_item_new_with_label(buf);
00134        if (ime_module->icon_pixbuf) {
00135            icon_widget = gtk_image_new_from_pixbuf(ime_module->icon_pixbuf);
00136            if (icon_widget != NULL)
00137               gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
00138                                          icon_widget);
00139        }
00140         gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00141         g_signal_connect(G_OBJECT(menu_item),
00142                       "activate",
00143                          G_CALLBACK(palette_window_ime_menuitem_cb),
00144                       (gpointer) ime_module);
00145         gtk_widget_show(menu_item);
00146     }
00147 
00148     gtk_widget_show(menu);
00149 
00150     g_signal_connect(G_OBJECT (menu),
00151                      "button_release_event",
00152                      G_CALLBACK (palette_window_menu_button_release_cb),
00153                      (gpointer)palette_window);
00154 
00155     g_object_set_data(G_OBJECT(menu),
00156                     DATA_PALETTE_AUX_WINDOW_INFO,
00157                     (gpointer)palette_window);
00158 
00159     return menu;
00160 }
00161 
00162 void palette_window_update_ime_list_menu(palette_window_t *palette_window,
00163                                     property_data_t *property_data)
00164 {
00165     if (palette_window == NULL || property_data == NULL)
00166         return;
00167 
00168     if (palette_window->ime_list_menu)
00169         gtk_widget_destroy(palette_window->ime_list_menu);
00170 
00171     palette_window->ime_list_menu = (GtkWidget *)palette_window_create_ime_list_menu(palette_window, property_data);
00172 
00173     return;
00174 }
00175 
00176 static void palette_window_vkb_menu_item_cb(gpointer data)
00177 {
00178     vkb_layout_t *vkb_layout = (vkb_layout_t *)data;
00179 
00180     palette_window->current_vkb_layout = vkb_layout;
00181     palette_window_show_vkb_window_with_layout(palette_window, vkb_layout);
00182     return;
00183 }
00184 
00185 static void palette_window_ime_vkb_menu_item_cb(gpointer data)
00186 {
00187     vkb_layout_t *ime_vkb_layout;
00188 
00189     palette_window->current_vkb_layout = NULL;
00190 
00191     ime_vkb_layout = (vkb_layout_t *)palette_window_get_current_ime_vkb_layout(palette_window);
00192     if (ime_vkb_layout == NULL)
00193         ime_vkb_layout = palette_window->vkb_layout_pc_keyboard;
00194 
00195     palette_window_show_vkb_window_with_layout(palette_window, ime_vkb_layout);
00196     return;
00197 }
00198 
00199 GtkWidget *palette_window_create_vkb_list_menu(palette_window_t *palette_window)
00200 {
00201     GtkWidget *menu; 
00202     GtkWidget *menu_item;
00203     GSList    *group = NULL;
00204 
00205     gboolean tearoff = FALSE;
00206 
00207     char buf[256];
00208     vkb_layout_t **p, **vkb_layout_list, *ime_vkb_layout;
00209 
00210     vkb_layout_list = (vkb_layout_t **)palette_window_get_vkb_layout_list(palette_window);
00211     if (vkb_layout_list == NULL)
00212        return NULL;
00213 
00214     menu = gtk_menu_new();
00215 
00216     if (tearoff) {
00217         menu_item = gtk_tearoff_menu_item_new ();
00218         gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
00219         gtk_widget_show (menu_item);
00220     }
00221 
00222     for (p = vkb_layout_list; *p; p++) {
00223        vkb_layout_t *vkb_layout = *p;
00224         snprintf(buf, 256, " %s ", (char *)vkb_layout->name_utf8);
00225 
00226         menu_item = gtk_radio_menu_item_new_with_label(group, buf);
00227        group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
00228         gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00229         g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
00230                                  G_CALLBACK(palette_window_vkb_menu_item_cb), (gpointer) vkb_layout);
00231         gtk_widget_show(menu_item);
00232         GTK_CHECK_MENU_ITEM(menu_item)->active = 0;
00233     }
00234 
00235     menu_item = gtk_separator_menu_item_new();
00236     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00237     gtk_widget_show(menu_item);
00238 
00239     ime_vkb_layout = (vkb_layout_t *)palette_window_get_current_ime_vkb_layout(palette_window);
00240 
00241     if (ime_vkb_layout && palette_window->current_ime) {
00242         snprintf(buf, 127, " %s%s", palette_window->current_ime->name, MENU_ITEM_LABEL_KEYBOARD);
00243     } else {
00244         snprintf(buf, 127, " PC %s", MENU_ITEM_LABEL_KEYBOARD);
00245     }
00246 
00247     menu_item = gtk_radio_menu_item_new_with_label(group, buf);
00248     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00249     g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
00250                              G_CALLBACK(palette_window_ime_vkb_menu_item_cb), (gpointer) ime_vkb_layout);
00251     gtk_widget_show(menu_item);
00252 
00253     if (palette_window->current_vkb_layout == NULL)
00254         GTK_CHECK_MENU_ITEM(menu_item)->active = 1;
00255 
00256     gtk_widget_show(menu);
00257 
00258     g_signal_connect(G_OBJECT (menu),
00259                      "button_release_event",
00260                      G_CALLBACK (palette_window_menu_button_release_cb),
00261                      (gpointer)palette_window);
00262 
00263     g_object_set_data(G_OBJECT(menu),
00264                     DATA_PALETTE_AUX_WINDOW_INFO,
00265                     (gpointer)palette_window);
00266 
00267     return menu;
00268 }
00269 
00270 GtkWidget *palette_window_update_vkb_list_menu(palette_window_t *palette_window)
00271 {
00272     GtkWidget *menu; 
00273     GList *list = NULL;
00274 
00275     char buf[128];
00276     vkb_layout_t *ime_vkb_layout;
00277 
00278     menu = palette_window->vkb_list_menu;
00279     if (menu == NULL)
00280        return NULL;
00281 
00282     /* remove the last menu item "IME Keyboard..." */
00283     list = g_list_last(GTK_MENU_SHELL(menu)->children);
00284 
00285     /* add new menu item for the current IME */
00286     ime_vkb_layout = (vkb_layout_t *)palette_window_get_current_ime_vkb_layout(palette_window);
00287     if (ime_vkb_layout && palette_window->current_ime) {
00288         snprintf(buf, 127, " %s%s", palette_window->current_ime->name, MENU_ITEM_LABEL_KEYBOARD);
00289     } else {
00290         snprintf(buf, 127, " PC %s", MENU_ITEM_LABEL_KEYBOARD);
00291     }
00292 
00293     palette_window_set_menuitem_label(GTK_WIDGET (list->data), (gchar *)buf);
00294 
00295     return menu;
00296 }
00297 
00298 void palette_window_register_signal_child_handler()
00299 {
00300     struct sigaction act;
00301 
00302     act.sa_handler = NULL;
00303     act.sa_sigaction = palette_window_signal_child_handler;
00304     sigfillset(&act.sa_mask);
00305     act.sa_flags = SA_SIGINFO;
00306 
00307     sigaction(SIGCHLD, &act, NULL);
00308 }
00309 
00310 void
00311 palette_window_signal_child_handler(int sig, siginfo_t * info, void *ucontext)
00312 {
00313     pid_t pid;
00314     int status;
00315 
00316     while ((pid = waitpid(info->si_pid, &status, WNOHANG | WUNTRACED)) > 0) {
00317        printf("pid %d: die\n", pid);
00318     }
00319 }
00320 
00321 static void palette_window_start_command(char *command_str)
00322 {
00323     int pid;
00324 
00325     if (command_str == NULL)
00326        return;
00327 
00328     palette_window_register_signal_child_handler();
00329 
00330     pid = fork();
00331     if (pid < 0) {
00332        return;
00333     } else if (pid == 0) {
00334        /* in child process */
00335        execl("/bin/sh", "sh", "-c", command_str, (char *) 0);
00336 
00337        /* Exec failed. */
00338        fprintf(stderr, "Error: Could not exec %s!\n", command_str);
00339        _exit(1);
00340     }
00341     return;
00342 }
00343 
00344 static void
00345 palette_window_start_uni_charmap_app(GtkWidget   *menuitem,
00346                                  palette_window_t *palette_window)
00347 {
00348     palette_window_start_command("/usr/bin/gucharmap");
00349 }
00350 
00351 static void
00352 palette_window_toggled_show_style_cb(GtkWidget   *menuitem,
00353                                 palette_window_t *palette_window)
00354 {
00355     if (palette_window->show_style == SHOW_STYLE_HORIZONTAL) {
00356         palette_window_set_show_style(palette_window, SHOW_STYLE_VERTICAL);
00357     } else {
00358         palette_window_set_show_style(palette_window, SHOW_STYLE_HORIZONTAL);
00359     }
00360     if (palette_window->property_window != NULL)
00361         palette_window->property_window->modified_status = TRUE;
00362 }
00363 
00364 static void
00365 palette_window_start_ime_properties_app(GtkWidget   *menuitem,
00366                                     palette_window_t *palette_window)
00367 {
00368     if (palette_window == NULL)
00369        return;
00370 
00371     if (palette_window->property_window == NULL) {
00372        palette_window->property_window = (property_window_t *)property_window_new_with_property_data(palette_window->property_data);
00373     }
00374 
00375     if (palette_window->property_window != NULL) {
00376        property_window_restore(palette_window->property_window);
00377         property_window_show(palette_window->property_window);
00378     }
00379 }
00380 
00381 static void
00382 palette_window_start_ime_help_app(GtkWidget   *menuitem,
00383                               palette_window_t *palette_window)
00384 {
00385 #ifndef STANDALONE_DEBUG
00386     char command_str[256];
00387 
00388     snprintf(command_str, 256, "/usr/bin/mozilla %s/index.html", LE_DOCS_DIR);
00389     palette_window_start_command(command_str);
00390 #else
00391     g_signal_emit_by_name(palette_window->window, "destroy");
00392     exit (0);
00393 #endif
00394 }
00395 
00396 static void
00397 palette_window_destroy_ime_about_dialog(GtkDialog *dialog, int response_id, gpointer data)
00398 {
00399     palette_window_t *platte_window = (palette_window_t *)data;
00400 
00401     gtk_widget_destroy ((GtkWidget *)dialog);
00402     if (palette_window)
00403         palette_window->about_dialog = NULL;
00404 }
00405 
00406 static void
00407 palette_window_start_ime_about_dialog(GtkWidget   *menuitem,
00408                                   palette_window_t *palette_window)
00409 {
00410     GtkWidget *dialog;
00411     GtkWidget *hbox;
00412     GtkWidget *vbox;
00413     GtkWidget *stock;
00414     GtkWidget *label;
00415     GtkWidget *hbox1;
00416     GtkWidget *vbox_author;
00417     GtkWidget *vbox_copyright;
00418     char message[1024];
00419     char title[256];
00420 
00421 #define ABOUT_IME_INDENT_SPACE   "    "
00422 
00423     if (palette_window->current_ime == NULL)
00424        return;
00425 
00426     DEBUG_printf ("about_dialog: %p\n", palette_window->about_dialog);
00427     if (palette_window->about_dialog != NULL)
00428        gtk_widget_destroy(palette_window->about_dialog);
00429 
00430     snprintf(title, 256, "%s%s%s", ABOUT_IME_TITLE, 
00431                           palette_window->current_ime->name,
00432                           ABOUT_IME_SUFFIX);
00433 
00434     dialog = gtk_dialog_new_with_buttons (title,
00435                                      NULL,
00436                                      GTK_DIALOG_DESTROY_WITH_PARENT,
00437                                      GTK_STOCK_OK,
00438                                      GTK_RESPONSE_NONE,
00439                                      NULL);
00440     gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
00441     gtk_widget_show(dialog);
00442 
00443     hbox = gtk_hbox_new (FALSE, 8);
00444     gtk_widget_show(hbox);
00445     gtk_container_set_border_width (GTK_CONTAINER (hbox), 16);
00446     gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
00447   
00448     stock = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
00449     gtk_widget_show(stock);
00450     gtk_box_pack_start (GTK_BOX (hbox), stock, FALSE, FALSE, 2);
00451   
00452     vbox = gtk_vbox_new (FALSE, 20);
00453     gtk_widget_show(vbox);
00454     gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
00455 
00456     snprintf(message, 1024, "%s%s    %s%d.%02d", 
00457                     palette_window->current_ime->name,
00458                     ABOUT_IME_SUFFIX,
00459                     ABOUT_IME_VERSION,
00460                     palette_window->current_ime->version/100,
00461                     palette_window->current_ime->version%100);
00462 
00463     label = gtk_label_new (message);
00464     gtk_widget_show(label);
00465     gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
00466     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
00467 
00468     vbox_author = gtk_vbox_new (FALSE, 3);
00469     gtk_widget_show(vbox_author);
00470     gtk_box_pack_start (GTK_BOX (vbox), vbox_author, FALSE, FALSE, 0);
00471 
00472     label = gtk_label_new (ABOUT_IME_AUTHOR);
00473     gtk_widget_show(label);
00474     gtk_box_pack_start (GTK_BOX (vbox_author), label, FALSE, FALSE, 0);
00475     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
00476 
00477     hbox1 = gtk_hbox_new (FALSE, 0);
00478     gtk_widget_show (hbox1);
00479     gtk_box_pack_start (GTK_BOX (vbox_author), hbox1, FALSE, FALSE, 0);
00480 
00481     label = gtk_label_new (ABOUT_IME_INDENT_SPACE);
00482     gtk_widget_show (label);
00483     gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
00484     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
00485 
00486     label = gtk_label_new (palette_window->current_ime->author);
00487     gtk_widget_show(label);
00488     gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
00489     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
00490 
00491     vbox_copyright = gtk_vbox_new (FALSE, 3);
00492     gtk_widget_show(vbox_copyright);
00493     gtk_box_pack_start (GTK_BOX (vbox), vbox_copyright, FALSE, FALSE, 0);
00494 
00495     label = gtk_label_new (ABOUT_IME_COPYRIGHT);
00496     gtk_widget_show(label);
00497     gtk_box_pack_start (GTK_BOX (vbox_copyright), label, FALSE, FALSE, 0);
00498     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
00499 
00500     hbox1 = gtk_hbox_new (FALSE, 0);
00501     gtk_widget_show (hbox1);
00502     gtk_box_pack_start (GTK_BOX (vbox_copyright), hbox1, FALSE, FALSE, 0);
00503     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
00504 
00505     label = gtk_label_new (ABOUT_IME_INDENT_SPACE);
00506     gtk_widget_show (label);
00507     gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
00508     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
00509 
00510     label = gtk_label_new (palette_window->current_ime->copyright);
00511     gtk_widget_show(label);
00512     gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
00513     gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
00514 
00515     g_signal_connect(dialog,
00516                    "response",
00517                    G_CALLBACK(palette_window_destroy_ime_about_dialog),
00518                    palette_window);
00519 
00520     gtk_widget_show (dialog);
00521 
00522     palette_window->about_dialog = dialog;
00523 }
00524 
00525 GtkWidget *palette_window_create_utility_list_menu(palette_window_t *palette_window)
00526 {
00527     GtkWidget *menu; 
00528     GtkWidget *menu_item;
00529 
00530     GtkWidget *icon_widget;
00531     GdkPixbuf *icon_pixbuf;
00532 
00533     char buf[128];
00534 
00535     gboolean tearoff = FALSE;
00536 
00537     menu = gtk_menu_new();
00538 
00539     if (tearoff) {
00540         menu_item = gtk_tearoff_menu_item_new ();
00541         gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
00542         gtk_widget_show (menu_item);
00543     }
00544 
00545     menu_item = gtk_image_menu_item_new_with_mnemonic(MENU_ITEM_LABEL_VKB);
00546     icon_pixbuf = palette_window->pixbufs[PIXMAP_ID_VKB];
00547     icon_widget = gtk_image_new_from_pixbuf(icon_pixbuf);
00548     gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
00549                               icon_widget);
00550     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00551     gtk_widget_show(menu_item);
00552 
00553     if (palette_window->vkb_list_menu == NULL) {
00554         palette_window->vkb_list_menu = (GtkWidget *)palette_window_create_vkb_list_menu(palette_window);
00555     } else {
00556         palette_window->vkb_list_menu = (GtkWidget *)palette_window_update_vkb_list_menu(palette_window);
00557     }
00558 
00559     if (palette_window->vkb_list_menu != NULL) {
00560        gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), palette_window->vkb_list_menu);
00561     }
00562 
00563     menu_item = gtk_image_menu_item_new_with_mnemonic(MENU_ITEM_LABEL_CHARMAP);
00564     gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
00565                               gtk_image_new_from_stock(GTK_STOCK_BOLD, GTK_ICON_SIZE_MENU));
00566     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00567     g_signal_connect(G_OBJECT(menu_item), "activate",
00568                    G_CALLBACK(palette_window_start_uni_charmap_app),
00569                    (gpointer)palette_window);
00570     gtk_widget_show(menu_item);
00571 
00572     menu_item = gtk_separator_menu_item_new();
00573     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00574     gtk_widget_show(menu_item);
00575 
00576     menu_item = gtk_check_menu_item_new_with_mnemonic(MENU_ITEM_LABEL_VERTICAL_STYLE);
00577     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00578     g_signal_connect(G_OBJECT(menu_item), "toggled",
00579                    G_CALLBACK(palette_window_toggled_show_style_cb),
00580                    (gpointer)palette_window);
00581     if (palette_window->show_style == SHOW_STYLE_HORIZONTAL) {
00582         GTK_CHECK_MENU_ITEM(menu_item)->active = 0;
00583     } else {
00584         GTK_CHECK_MENU_ITEM(menu_item)->active = 1;
00585     }
00586     gtk_widget_show(menu_item);
00587     palette_window->utility_menuitem_show_vertical = menu_item;
00588 
00589     menu_item = gtk_separator_menu_item_new();
00590     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00591     gtk_widget_show(menu_item);
00592 
00593     menu_item = gtk_image_menu_item_new_with_mnemonic(MENU_ITEM_LABEL_TOOLBAR_PERFERENCES);
00594     gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
00595                               gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU));
00596     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00597     g_signal_connect(G_OBJECT(menu_item), "activate",
00598                    G_CALLBACK(palette_window_start_ime_properties_app),
00599                    (gpointer)palette_window);
00600     gtk_widget_show(menu_item);
00601 
00602     menu_item = gtk_image_menu_item_new_with_mnemonic(MENU_ITEM_LABEL_HELP);
00603     gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
00604                               gtk_image_new_from_stock(GTK_STOCK_HELP, GTK_ICON_SIZE_MENU));
00605     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00606     g_signal_connect(G_OBJECT(menu_item), "activate",
00607                    G_CALLBACK(palette_window_start_ime_help_app),
00608                    (gpointer)palette_window);
00609     gtk_widget_show(menu_item);
00610 
00611     menu_item = gtk_separator_menu_item_new();
00612     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00613     gtk_widget_show(menu_item);
00614 
00615     if (palette_window->current_ime == NULL)
00616         snprintf(buf, 127, "%s...", MENU_ITEM_LABEL_ABOUT);
00617     else
00618         snprintf(buf, 127, "%s%s...", MENU_ITEM_LABEL_ABOUT, palette_window->current_ime->name);
00619     menu_item = gtk_image_menu_item_new_with_mnemonic(buf);
00620     gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
00621                               gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU));
00622     gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
00623     g_signal_connect(G_OBJECT(menu_item), "activate",
00624                    G_CALLBACK(palette_window_start_ime_about_dialog),
00625                    (gpointer)palette_window);
00626     gtk_widget_show(menu_item);
00627 
00628     gtk_widget_show(menu);
00629 
00630     g_signal_connect(G_OBJECT (menu),
00631                      "button_release_event",
00632                      G_CALLBACK (palette_window_menu_button_release_cb),
00633                      (gpointer)palette_window);
00634 
00635     g_object_set_data(G_OBJECT(menu),
00636                     DATA_PALETTE_AUX_WINDOW_INFO,
00637                     (gpointer)palette_window);
00638 
00639     return menu;
00640 }
00641 
00642 GtkWidget *palette_window_update_utility_list_menu(palette_window_t *palette_window)
00643 {
00644     GtkWidget *menu; 
00645     GList *list = NULL;
00646 
00647     char buf[128];
00648 
00649     menu = palette_window->utility_list_menu;
00650     if (menu == NULL)
00651        return NULL;
00652 
00653     if (palette_window->show_style == SHOW_STYLE_HORIZONTAL) {
00654         GTK_CHECK_MENU_ITEM(palette_window->utility_menuitem_show_vertical)->active = 0;
00655     } else {
00656         GTK_CHECK_MENU_ITEM(palette_window->utility_menuitem_show_vertical)->active = 1;
00657     }
00658 
00659     palette_window->vkb_list_menu = (GtkWidget *)palette_window_update_vkb_list_menu(palette_window);
00660 
00661     /* remove the last menu item "About IME..." */
00662     list = g_list_last(GTK_MENU_SHELL(menu)->children);
00663 
00664     /* update the label of menu item for the current IME */
00665     if (palette_window->current_ime == NULL)
00666         snprintf(buf, 127, "%s...", MENU_ITEM_LABEL_ABOUT);
00667     else
00668         snprintf(buf, 127, "%s%s...", MENU_ITEM_LABEL_ABOUT, palette_window->current_ime->name);
00669 
00670     palette_window_set_menuitem_label(GTK_WIDGET(list->data), (gchar *)buf);
00671 
00672     return menu;
00673 }
00674 
00675 void palette_window_set_menuitem_label_foreach (GtkWidget *widget,
00676                                                 gpointer data)
00677 {
00678     if (GTK_IS_LABEL (widget)) {
00679         gchar *label_new = (gchar *)data;
00680       gtk_label_set_text (GTK_LABEL (widget), label_new);
00681     } else if (GTK_IS_CONTAINER (widget)) {
00682         gtk_container_foreach (GTK_CONTAINER (widget),
00683                                palette_window_set_menuitem_label_foreach,
00684                                data);
00685     }
00686 }
00687 
00688 void palette_window_set_menuitem_label(GtkWidget *menu_item, gchar *label)
00689 {
00690     gtk_container_foreach (GTK_CONTAINER (menu_item),
00691                            palette_window_set_menuitem_label_foreach,
00692                            (gpointer) label);
00693 
00694     return;
00695 }