[uim-commit] r520 - in trunk: helper po
makeinu at freedesktop.org
makeinu at freedesktop.org
Fri Feb 4 17:01:42 PST 2005
Author: makeinu
Date: 2005-02-04 17:01:37 -0800 (Fri, 04 Feb 2005)
New Revision: 520
Modified:
trunk/helper/pref-gtk-custom-widgets.c
trunk/helper/pref-gtk-custom-widgets.h
trunk/helper/pref-gtk.c
trunk/po/ja.po
Log:
* helper/pref-gtk.c, helper/pref-gtk-custom-widgets.[ch]:
- (uim_pref_gtk_set_default_value):
New function to add "Set to default" feature.
- (set_to_default_cb): Ditto.
- (defaults_button_clicked): Ditto.
- (create_setting_button_box): Added default button.
- (custom_spin_button_value_changed):
Rename from custom_adjustment_value_changed to connect signal to
spin button instead of adjustment.
- (sync_value_int): Connect signal to spin button instead of adjustment.
- (update_custom_type_int_cb): Ditto.
- (add_custom_type_integer): Ditto.
Modified: trunk/helper/pref-gtk-custom-widgets.c
===================================================================
--- trunk/helper/pref-gtk-custom-widgets.c 2005-02-04 12:10:44 UTC (rev 519)
+++ trunk/helper/pref-gtk-custom-widgets.c 2005-02-05 01:01:37 UTC (rev 520)
@@ -159,19 +159,19 @@
static void
-custom_adjustment_value_changed(GtkAdjustment *adj, gpointer user_data)
+custom_spin_button_value_changed(GtkSpinButton *spin, gpointer user_data)
{
const char *custom_sym;
struct uim_custom *custom;
uim_bool rv;
- custom_sym = g_object_get_data(G_OBJECT(adj), OBJECT_DATA_UIM_CUSTOM_SYM);
+ custom_sym = g_object_get_data(G_OBJECT(spin), OBJECT_DATA_UIM_CUSTOM_SYM);
g_return_if_fail(custom_sym);
custom = uim_custom_get(custom_sym);
g_return_if_fail(custom && custom->type == UCustom_Int);
- custom->value->as_int = adj->value;
+ custom->value->as_int = gtk_spin_button_get_value(spin);
rv = uim_custom_set(custom);
if (rv) {
@@ -185,39 +185,43 @@
}
static void
-sync_value_int(GtkAdjustment *adj)
+sync_value_int(GtkSpinButton *spin)
{
const char *custom_sym;
struct uim_custom *custom;
+ GtkAdjustment *adj;
- g_signal_handlers_block_by_func(G_OBJECT(adj),
- (gpointer) custom_adjustment_value_changed,
+ g_signal_handlers_block_by_func(G_OBJECT(spin),
+ (gpointer) custom_spin_button_value_changed,
NULL);
- custom_sym = g_object_get_data(G_OBJECT(adj), OBJECT_DATA_UIM_CUSTOM_SYM);
+ adj = gtk_spin_button_get_adjustment(spin);
+
+ custom_sym = g_object_get_data(G_OBJECT(spin), OBJECT_DATA_UIM_CUSTOM_SYM);
g_return_if_fail(custom_sym);
custom = uim_custom_get(custom_sym);
g_return_if_fail(custom && custom->type == UCustom_Int);
- /* gtk_widget_set_sensitive(GTK_WIDGET(widget), custom->is_active); */
+ gtk_widget_set_sensitive(GTK_WIDGET(spin), custom->is_active);
+ if (custom->range->as_int.min != (int) adj->lower &&
+ custom->range->as_int.max != (int) adj->upper)
+ gtk_spin_button_set_range(spin, custom->range->as_int.min, custom->range->as_int.max);
+ if (custom->value->as_int != (int) gtk_spin_button_get_value(spin)) {
+ gtk_spin_button_set_value(spin, custom->value->as_int);
+ }
- adj->value = custom->value->as_int;
- adj->lower = custom->range->as_int.min;
- adj->upper = custom->range->as_int.max;
- gtk_adjustment_changed(adj);
-
uim_custom_free(custom);
- g_signal_handlers_unblock_by_func(G_OBJECT(adj),
- (gpointer) custom_adjustment_value_changed,
+ g_signal_handlers_unblock_by_func(G_OBJECT(spin),
+ (gpointer) custom_spin_button_value_changed,
NULL);
}
static void
update_custom_type_int_cb(void *ptr, const char *custom_sym)
{
- sync_value_int(GTK_ADJUSTMENT(ptr));
+ sync_value_int(GTK_SPIN_BUTTON(ptr));
}
static void
@@ -251,12 +255,15 @@
g_object_set_data_full(G_OBJECT(adjustment),
OBJECT_DATA_UIM_CUSTOM_SYM, g_strdup(custom->symbol),
(GDestroyNotify) g_free);
+ g_object_set_data_full(G_OBJECT(spin),
+ OBJECT_DATA_UIM_CUSTOM_SYM, g_strdup(custom->symbol),
+ (GDestroyNotify) g_free);
- sync_value_int(adjustment);
+ sync_value_int(GTK_SPIN_BUTTON(spin));
- g_signal_connect(G_OBJECT(adjustment), "value-changed",
- G_CALLBACK(custom_adjustment_value_changed), NULL);
- uim_custom_cb_add(custom->symbol, adjustment, update_custom_type_int_cb);
+ g_signal_connect(G_OBJECT(spin), "value-changed",
+ G_CALLBACK(custom_spin_button_value_changed), NULL);
+ uim_custom_cb_add(custom->symbol, spin, update_custom_type_int_cb);
}
@@ -1657,7 +1664,7 @@
static void
choose_key_clicked_cb(GtkWidget *widget, GtkEntry *key_entry)
{
- GtkWidget *dialog, *scrwin, *view, *hbox, *vbox, *button, *entry;
+ GtkWidget *dialog, *scrwin, *view, *hbox, *vbox, *label, *button, *entry;
GtkTreeSelection *selection;
GtkListStore *store;
GtkCellRenderer *renderer;
@@ -1757,6 +1764,10 @@
gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
gtk_widget_show(hbox);
+ label = gtk_label_new(_("Key:"));
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4);
+ gtk_widget_show(label);
+
entry = gtk_entry_new();
/* XXX hack alert! This modifies private part of gtk_entry */
@@ -1775,7 +1786,7 @@
gtk_widget_show(entry);
button = gtk_button_new_with_label(_("..."));
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 4);
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 4);
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(choose_key_button_clicked_cb), key_entry);
gtk_widget_show(button);
@@ -1888,3 +1899,121 @@
uim_custom_free(custom);
}
+
+void
+uim_pref_gtk_set_default_value(GtkWidget *widget)
+{
+ const char *custom_sym;
+ struct uim_custom *custom;
+ union uim_custom_value *value, *defval;
+ uim_bool rv;
+ gint i, num;
+
+ custom_sym = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_UIM_CUSTOM_SYM);
+ if (!custom_sym) return;
+
+ custom = uim_custom_get(custom_sym);
+ g_return_if_fail(custom);
+
+ value = custom->value;
+ defval = custom->default_value;
+
+ switch (custom->type) {
+ case UCustom_Bool:
+ value->as_bool = defval->as_bool;
+ break;
+ case UCustom_Int:
+ value->as_int = defval->as_int;
+ break;
+ case UCustom_Str:
+ g_free(value->as_str);
+ value->as_str = strdup(defval->as_str);
+ break;
+ case UCustom_Pathname:
+ g_free(value->as_pathname);
+ value->as_pathname = strdup(defval->as_pathname);
+ break;
+ case UCustom_Choice:
+ g_free(value->as_choice->symbol);
+ g_free(value->as_choice->label);
+ g_free(value->as_choice->desc);
+ value->as_choice->symbol = strdup(defval->as_choice->symbol);
+ value->as_choice->label = strdup(defval->as_choice->label);
+ value->as_choice->desc = strdup(defval->as_choice->desc);
+ break;
+ case UCustom_OrderedList:
+ for (num = 0; defval->as_olist[num]; num++);
+ for (i = 0; value->as_olist[i]; i++) {
+ free(value->as_olist[i]->symbol);
+ free(value->as_olist[i]->label);
+ free(value->as_olist[i]->desc);
+ free(value->as_olist[i]);
+ }
+ value->as_olist = realloc(value->as_olist,
+ sizeof(struct uim_custom_choice) * (num + 1));
+ for (i = 0; i < num; i++) {
+ value->as_olist[i] = malloc(sizeof(struct uim_custom_choice));
+ value->as_olist[i]->symbol = strdup(defval->as_olist[i]->symbol);
+ value->as_olist[i]->label = strdup(defval->as_olist[i]->label);
+ value->as_olist[i]->desc = strdup(defval->as_olist[i]->desc);
+ }
+ value->as_olist[num] = NULL;
+ break;
+ case UCustom_Key:
+ for (num = 0; defval->as_key[num]; num++);
+ for (i = 0; value->as_key[i]; i++) {
+ free(value->as_key[i]->literal);
+ free(value->as_key[i]->label);
+ free(value->as_key[i]->desc);
+ free(value->as_key[i]);
+ }
+ value->as_key = realloc(value->as_key,
+ sizeof(struct uim_custom_key) * (num + 1));
+ for (i = 0; i < num; i++) {
+ value->as_key[i] = malloc(sizeof(struct uim_custom_key));
+ value->as_key[i] = defval->as_key[i];
+ value->as_key[i]->literal = strdup(defval->as_key[i]->literal);
+ value->as_key[i]->label = strdup(defval->as_key[i]->label);
+ value->as_key[i]->desc = strdup(defval->as_key[i]->desc);
+ }
+ value->as_key[num] = NULL;
+ break;
+ default:
+ uim_custom_free(custom);
+ return;
+ }
+
+ rv = uim_custom_set(custom);
+
+ if (rv == UIM_FALSE) {
+ g_printerr("Faild to set value for \"%s\".\n", custom->symbol);
+ uim_custom_free(custom);
+ return;
+ }
+
+ switch (custom->type) {
+ case UCustom_Bool:
+ sync_value_bool(GTK_CHECK_BUTTON(widget));
+ break;
+ case UCustom_Int:
+ sync_value_int(GTK_SPIN_BUTTON(widget));
+ break;
+ case UCustom_Str:
+ sync_value_string(GTK_ENTRY(widget));
+ break;
+ case UCustom_Pathname:
+ sync_value_string(GTK_ENTRY(widget));
+ break;
+ case UCustom_Choice:
+ sync_value_choice(GTK_COMBO_BOX(widget));
+ break;
+ case UCustom_OrderedList:
+ olist_pref_entry_set_value(GTK_ENTRY(widget));
+ break;
+ case UCustom_Key:
+ key_pref_entry_set_value(GTK_ENTRY(widget));
+ break;
+ default:
+ return;
+ }
+}
Modified: trunk/helper/pref-gtk-custom-widgets.h
===================================================================
--- trunk/helper/pref-gtk-custom-widgets.h 2005-02-04 12:10:44 UTC (rev 519)
+++ trunk/helper/pref-gtk-custom-widgets.h 2005-02-05 01:01:37 UTC (rev 520)
@@ -35,3 +35,4 @@
#include <gtk/gtk.h>
void uim_pref_gtk_add_custom(GtkWidget *vbox, const char *custom_sym);
+void uim_pref_gtk_set_default_value(GtkWidget *widget);
Modified: trunk/helper/pref-gtk.c
===================================================================
--- trunk/helper/pref-gtk.c 2005-02-04 12:10:44 UTC (rev 519)
+++ trunk/helper/pref-gtk.c 2005-02-05 01:01:37 UTC (rev 520)
@@ -267,6 +267,23 @@
}
}
+static void
+set_to_default_cb(GtkWidget *widget, gpointer data)
+{
+ uim_pref_gtk_set_default_value(widget);
+
+ if (GTK_IS_CONTAINER(widget))
+ gtk_container_foreach(GTK_CONTAINER(widget),
+ (GtkCallback) (set_to_default_cb), NULL);
+}
+
+static void
+defaults_button_clicked(GtkButton *button, gpointer user_data)
+{
+ gtk_container_foreach(GTK_CONTAINER(current_group_widget),
+ (GtkCallback) (set_to_default_cb), NULL);
+}
+
static GtkWidget *
create_setting_button_box(const char *group_name)
{
@@ -277,6 +294,12 @@
gtk_button_box_set_layout(GTK_BUTTON_BOX(setting_button_box), GTK_BUTTONBOX_END);
gtk_box_set_spacing(GTK_BOX(setting_button_box), 8);
+ /* Defaults button */
+ button = gtk_button_new_with_mnemonic(_("_Defaults"));
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(defaults_button_clicked), (gpointer) group_name);
+ gtk_box_pack_start(GTK_BOX(setting_button_box), button, TRUE, TRUE, 8);
+
/* Apply button */
button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
g_signal_connect(G_OBJECT(button), "clicked",
Modified: trunk/po/ja.po
===================================================================
--- trunk/po/ja.po 2005-02-04 12:10:44 UTC (rev 519)
+++ trunk/po/ja.po 2005-02-05 01:01:37 UTC (rev 520)
@@ -7,8 +7,8 @@
msgstr ""
"Project-Id-Version: uim 0.4.6-alpha1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-02-04 17:06+0900\n"
-"PO-Revision-Date: 2005-02-04 08:17+0900\n"
+"POT-Creation-Date: 2005-02-05 09:48+0900\n"
+"PO-Revision-Date: 2005-02-05 09:48+0900\n"
"Last-Translator: YamaKen <yamaken at bp.iij4u.or.jp>\n"
"Language-Team: Japanese <LL at li.org>\n"
"MIME-Version: 1.0\n"
@@ -332,7 +332,7 @@
msgid "Example"
msgstr "Îã"
-#: helper/pref-gtk.c:127
+#: helper/pref-gtk.c:100
msgid ""
"Some value(s) have been changed.\n"
"Save?"
@@ -340,7 +340,7 @@
"ÀßÄ꤬Êѹ¹¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\n"
"¥»¡¼¥Ö¤·¤Þ¤¹¤«?"
-#: helper/pref-gtk.c:196
+#: helper/pref-gtk.c:169
msgid ""
"Some value(s) have been changed.\n"
"Do you realy quit this program?"
@@ -348,59 +348,56 @@
"ÀßÄ꤬Êѹ¹¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\n"
"ËÜÅö¤Ë½ªÎ»¤·¤Þ¤¹¤«?"
-#: helper/pref-gtk.c:235 qt/pref-qt.cpp:103
+#: helper/pref-gtk.c:208 qt/pref-qt.cpp:103
msgid "Group"
msgstr "¥°¥ë¡¼¥×"
-#: helper/pref-gtk.c:560
+#. Defaults button
+#: helper/pref-gtk.c:298
+msgid "_Defaults"
+msgstr "¥Ç¥Õ¥©¥ë¥È(_D)"
+
+#: helper/pref-gtk-custom-widgets.c:383
msgid "Specify file"
msgstr "¥Õ¥¡¥¤¥ë¤Î»ØÄê"
-#: helper/pref-gtk.c:597 qt/pref-customwidgets.cpp:168
+#: helper/pref-gtk-custom-widgets.c:420 qt/pref-customwidgets.cpp:168
msgid "File"
msgstr "»²¾È"
-#: helper/pref-gtk.c:1271
+#: helper/pref-gtk-custom-widgets.c:1099
msgid "Enabled"
msgstr "͸ú"
-#: helper/pref-gtk.c:1297
+#: helper/pref-gtk-custom-widgets.c:1125
msgid "Enabled items"
msgstr "͸ú¤Ê¹àÌÜ"
-#: helper/pref-gtk.c:1375
+#: helper/pref-gtk-custom-widgets.c:1203
msgid "Disabled"
msgstr "̵¸ú"
-#: helper/pref-gtk.c:1401
+#: helper/pref-gtk-custom-widgets.c:1229
msgid "Disabled items"
msgstr "̵¸ú¤Ê¹àÌÜ"
-#: helper/pref-gtk.c:1433 helper/pref-gtk.c:2029
+#: helper/pref-gtk-custom-widgets.c:1261 helper/pref-gtk-custom-widgets.c:1851
msgid "Choose..."
msgstr "ÁªÂò..."
-#: helper/pref-gtk.c:1634
+#: helper/pref-gtk-custom-widgets.c:1465
msgid "Press any key to grab..."
msgstr "¼èÆÀ¤¹¤ë¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤..."
-#: helper/pref-gtk.c:1894
+#: helper/pref-gtk-custom-widgets.c:1721
msgid "Key preference"
msgstr "¥¡¼ÀßÄê"
-#: helper/pref-gtk.c:1940
-msgid "_Shift"
-msgstr "_Shift"
+#: helper/pref-gtk-custom-widgets.c:1767
+msgid "Key:"
+msgstr ""
-#: helper/pref-gtk.c:1945
-msgid "_Control"
-msgstr "_Control"
-
-#: helper/pref-gtk.c:1950
-msgid "_Alt"
-msgstr "_Alt"
-
-#: helper/pref-gtk.c:1966
+#: helper/pref-gtk-custom-widgets.c:1788
msgid "..."
msgstr "..."
@@ -2246,6 +2243,15 @@
msgid "Zulu"
msgstr "¥º¡¼¥ë¡¼¸ì"
+#~ msgid "_Shift"
+#~ msgstr "_Shift"
+
+#~ msgid "_Control"
+#~ msgstr "_Control"
+
+#~ msgid "_Alt"
+#~ msgstr "_Alt"
+
#~ msgid "Japanese Kana Kanji Conversion Engine, Anthy"
#~ msgstr "ÆüËܸ줫¤Ê´Á»úÊÑ´¹¥¨¥ó¥¸¥óAnthy"
More information about the Uim-commit
mailing list