void InputContext::update_prop_list(const char *str) { char *buf; if (asprintf(&buf, "prop_list_update\ncharset=UTF-8\n%s", str) == -1) { free(buf); return; } uim_helper_send_message(lib_uim_fd, buf); free(buf); #if 1 // Show caret state indicator with this function instead of // InputContext::update_prop_label() to workaround the label // mismatch during IM switch caused from context-update-widgets. uim_bool show_caret_state = uim_scm_symbol_value_bool("bridge-show-input-state?"); char *show_caret_with = uim_scm_c_symbol(uim_scm_symbol_value("bridge-show-with?")); uim_bool show_caret_mode = (strcmp(show_caret_with, "mode") == 0); uim_bool show_caret_mode_on = uim_scm_symbol_value_bool("bridge-show-input-state-mode-on?"); if (show_caret_state == UIM_TRUE && !(show_caret_mode && !show_caret_mode_on)) { char *label; int timeout; Canddisp *disp = canddisp_singleton(); if (strcmp(show_caret_with, "time") == 0) timeout = static_cast<int>(uim_scm_symbol_value_int( "bridge-show-input-state-time-length")); else timeout = 0; label = get_caret_state_label_from_prop_list(str); disp->show_caret_state(label, timeout); free(label); mCaretStateShown = true; } else if (show_caret_mode && !show_caret_mode_on) { Canddisp *disp = canddisp_singleton(); disp->hide_caret_state(); } free(show_caret_with); #endif }
static void helper_toolbar_prop_list_update(GtkWidget *widget, gchar **lines) { GtkWidget *button = NULL; guint i; gchar **cols; gchar *charset; const gchar *indication_id, *iconic_label, *label, *tooltip_str; const gchar *action_id, *is_selected; GList *prop_buttons, *tool_buttons; GtkSizeGroup *sg; char *display_time; gboolean is_hidden; GtkWidget *toplevel; if (prop_menu_showing) return; charset = get_charset(lines[1]); prop_buttons = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_PROP_BUTTONS); tool_buttons = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_TOOL_BUTTONS); sg = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_SIZE_GROUP); if (prop_buttons) { g_list_foreach(prop_buttons, prop_button_destroy, NULL); g_list_free(prop_buttons); g_object_set_data(G_OBJECT(widget), OBJECT_DATA_PROP_BUTTONS, NULL); } if (tool_buttons) { g_list_foreach(tool_buttons, tool_button_destroy, NULL); g_list_free(tool_buttons); g_object_set_data(G_OBJECT(widget), OBJECT_DATA_TOOL_BUTTONS, NULL); } display_time = uim_scm_c_symbol( uim_scm_symbol_value( "toolbar-display-time" ) ); is_hidden = strcmp(display_time, "mode"); for (i = 0; lines[i] && strcmp("", lines[i]); i++) { gchar *utf8_str = convert_charset(charset, lines[i]); if (utf8_str != NULL) { cols = g_strsplit(utf8_str, "\t", 0); g_free(utf8_str); } else { cols = g_strsplit(lines[i], "\t", 0); } if (cols && cols[0]) { if (!strcmp("branch", cols[0]) && has_n_strs(cols, 4)) { indication_id = cols[1]; iconic_label = safe_gettext(cols[2]); tooltip_str = safe_gettext(cols[3]); button = prop_button_create(widget, indication_id, iconic_label, tooltip_str); append_prop_button(widget, button); if (!is_hidden && (!strcmp(indication_id, "direct") || g_str_has_suffix(indication_id, "_direct"))) { is_hidden = TRUE; } } else if (!strcmp("leaf", cols[0]) && has_n_strs(cols, 7)) { indication_id = cols[1]; iconic_label = safe_gettext(cols[2]); label = safe_gettext(cols[3]); tooltip_str = safe_gettext(cols[4]); action_id = cols[5]; is_selected = cols[6]; prop_button_append_menu(button, indication_id, label, tooltip_str, action_id, is_selected); } g_strfreev(cols); } } toplevel = gtk_widget_get_toplevel(widget); is_hidden = (is_hidden && strcmp(display_time, "always")); #if GTK_CHECK_VERSION(2, 18, 0) if (gtk_widget_get_visible(toplevel) == is_hidden) { #else if (GTK_WIDGET_VISIBLE(toplevel) == is_hidden) { #endif if (is_hidden) { gtk_widget_hide(toplevel); } else { gint x = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(toplevel), "position_x")); gint y = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(toplevel), "position_y")); gtk_window_move(GTK_WINDOW(toplevel), x, y); gtk_widget_show(toplevel); } } /* create tool buttons */ /* FIXME! command menu and buttons should be customizable. */ for (i = 0; i < command_entry_len; i++) { GtkWidget *tool_button; GtkWidget *img; if (!command_entry[i].show_button) continue; tool_button = gtk_button_new(); set_button_style(tool_button, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), OBJECT_DATA_TOOLBAR_TYPE))); g_object_set_data(G_OBJECT(tool_button), OBJECT_DATA_BUTTON_TYPE, GINT_TO_POINTER(BUTTON_TOOL)); g_object_set_data(G_OBJECT(tool_button), OBJECT_DATA_COMMAND, (gpointer)command_entry[i].command); if (command_entry[i].icon) img = gtk_image_new_from_stock(command_entry[i].icon, GTK_ICON_SIZE_MENU); else { img = gtk_label_new(""); gtk_label_set_markup(GTK_LABEL(img), command_entry[i].label); } if (img) gtk_container_add(GTK_CONTAINER(tool_button), img); gtk_button_set_relief(GTK_BUTTON(tool_button), GTK_RELIEF_NONE); gtk_size_group_add_widget(sg, tool_button); g_signal_connect(G_OBJECT(tool_button), "button-press-event", G_CALLBACK(button_pressed), widget); g_signal_connect(G_OBJECT(tool_button), "clicked", G_CALLBACK(tool_button_clicked_cb), widget); /* tooltip */ gtk_widget_set_tooltip_text(tool_button, _(command_entry[i].desc)); append_tool_button(widget, tool_button); } gtk_widget_show_all(widget); g_free(charset); } static void helper_toolbar_check_custom() { guint i; for (i = 0; i < command_entry_len; i++) command_entry[i].show_button = uim_scm_symbol_value_bool(command_entry[i].custom_button_show_symbol); with_dark_bg = uim_scm_symbol_value_bool("toolbar-icon-for-dark-background?"); }