[uim-commit] r414 - trunk/helper
tkng at freedesktop.org
tkng at freedesktop.org
Sun Jan 30 22:12:16 PST 2005
Author: tkng
Date: 2005-01-30 22:12:13 -0800 (Sun, 30 Jan 2005)
New Revision: 414
Modified:
trunk/helper/pref-gtk.c
Log:
* helper/pref-gtk.c:
-(update_custom_type_bool_cb, update_custom_type_string_cb,
update_custom_type_choice_cb, update_custom_type_key_cb):
Get new custom item from second argument.
Modified: trunk/helper/pref-gtk.c
===================================================================
--- trunk/helper/pref-gtk.c 2005-01-31 05:12:15 UTC (rev 413)
+++ trunk/helper/pref-gtk.c 2005-01-31 06:12:13 UTC (rev 414)
@@ -307,18 +307,20 @@
static void
update_custom_type_bool_cb(void *ptr, const char *custom_sym)
{
- struct uim_custom *custom;
+ struct uim_custom *custom = uim_custom_get(custom_sym);
GtkWidget *check_button = GTK_WIDGET(ptr);
- custom = g_object_get_data(G_OBJECT(check_button), OBJECT_DATA_UIM_CUSTOM);
if (!custom || custom->type != UCustom_Bool)
return;
+ g_object_set_data_full(G_OBJECT(check_button),
+ OBJECT_DATA_UIM_CUSTOM, custom,
+ (GDestroyNotify) uim_custom_free);
+
gtk_widget_set_sensitive(check_button, custom->is_active);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button),
custom->value->as_bool);
-
}
static void
@@ -448,16 +450,16 @@
static void
update_custom_type_string_cb(void *ptr, const char *custom_sym)
{
- struct uim_custom *custom;
- GtkWidget *entry = GTK_WIDGET(ptr);
- custom = g_object_get_data(G_OBJECT(entry), OBJECT_DATA_UIM_CUSTOM);
-
+ struct uim_custom *custom = uim_custom_get(custom_sym);
+ GtkWidget *entry = GTK_WIDGET(ptr);
+
if (!custom || custom->type != UCustom_Str)
return;
-
+
gtk_widget_set_sensitive(entry, custom->is_active);
+ gtk_entry_set_text(GTK_ENTRY(entry), custom->value->as_str);
- gtk_entry_set_text(GTK_ENTRY(entry), custom->value->as_str);
+ uim_custom_free(custom);
}
static void
@@ -554,7 +556,7 @@
custom = g_object_get_data(G_OBJECT(combo_box), OBJECT_DATA_UIM_CUSTOM);
g_return_if_fail(custom);
- if (custom->type == UCustom_Choice) {
+ if (custom->type != UCustom_Choice) {
gint i, num = gtk_combo_box_get_active(combo_box);
struct uim_custom_choice *choice = NULL;
@@ -596,16 +598,41 @@
static void
update_custom_type_choice_cb(void *ptr, const char *custom_sym)
{
- struct uim_custom *custom;
- GtkWidget *combobox = GTK_WIDGET(ptr);
- custom = g_object_get_data(G_OBJECT(combobox), OBJECT_DATA_UIM_CUSTOM);
+ struct uim_custom *custom = uim_custom_get(custom_sym);
+ GtkWidget *combobox = GTK_WIDGET(ptr);
+ struct uim_custom_choice **item;
+ gint i = 0, default_index = 0;
+ gchar *default_symbol;
- g_print("update_custom_type_choice_cb called\n");
-
if (!custom || custom->type != UCustom_Choice)
return;
+ g_object_set_data_full(G_OBJECT(combobox),
+ OBJECT_DATA_UIM_CUSTOM, custom,
+ (GDestroyNotify) uim_custom_free);
gtk_widget_set_sensitive(combobox, custom->is_active);
+
+ item = custom->range->as_choice.valid_items;
+
+ if(item == NULL || *item == NULL)
+ return;
+
+ g_signal_handlers_disconnect_by_func(G_OBJECT(combobox), (gpointer)custom_combo_box_changed, NULL);
+
+ gtk_cell_layout_clear(GTK_CELL_LAYOUT(combobox));
+
+ default_symbol = custom->value->as_choice->symbol;
+
+ while(*item) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), (*item)->label);
+ if(!strcmp(default_symbol, (*item)->symbol))
+ default_index = i;
+ i++;
+ item++;
+ }
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), default_index);
+ g_signal_connect(G_OBJECT(combobox), "changed",
+ G_CALLBACK(custom_combo_box_changed), NULL);
}
static void
@@ -1803,18 +1830,18 @@
static void
update_custom_type_key_cb(void *ptr, const char *custom_sym)
{
- struct uim_custom *custom;
+ struct uim_custom *custom = uim_custom_get(custom_sym);
GtkWidget *entry = GTK_WIDGET(ptr);
- custom = g_object_get_data(G_OBJECT(entry), OBJECT_DATA_UIM_CUSTOM);
-
if (!custom || custom->type != UCustom_Key)
return;
+ g_object_set_data_full(G_OBJECT(entry),
+ OBJECT_DATA_UIM_CUSTOM, custom,
+ (GDestroyNotify) uim_custom_free);
gtk_widget_set_sensitive(entry, custom->is_active);
}
-
static void
add_custom_type_key(GtkWidget *vbox, struct uim_custom *custom)
{
More information about the Uim-commit
mailing list