~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to sumika/gtk2/anthyimportwordpane.c

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2005-12-04 13:10:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051204131042-ktzc8b17zi7a3cw8
Tags: 1:0.4.9.1-1
* New upstream release
* libuim0-nox, libuim-nox-dev, and libuim0-dbg-nox is now obsolete.
  Because libuim0 does not depends on X11. They now become dummy package,
  therefore you can safely remove them.
* Add --enable-debug in configure again.
* debian/patches/08_fix_privilage_escalation_CVE_2005_3149: disabled.
* Fix Error on purge because update-uim-config is not found.
  (closes: Bug#339345)
* uim-qt: New package for Qt utilities for uim. qt-immodule does not
  contained yet because of Debian's Qt3 does not support immodule and
  because uim does not recognize libqt4-dev's headers properly. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  $Id:$
3
 
 *  Copyright (c) 2003,2004 Masahito Omote <omote@utyuuzin.net>
4
 
 *
5
 
 *  All rights reserved.
6
 
 *
7
 
 *  Redistribution and use in source and binary forms, with or without
8
 
 *  modification, are permitted provided that the following conditions
9
 
 *  are met:
10
 
 *
11
 
 *  1. Redistributions of source code must retain the above copyright
12
 
 *     notice, this list of conditions and the following disclaimer.
13
 
 *  2. Redistributions in binary form must reproduce the above copyright
14
 
 *     notice, this list of conditions and the following disclaimer in the
15
 
 *     documentation and/or other materials provided with the distribution.
16
 
 *  3. Neither the name of authors nor the names of its contributors
17
 
 *     may be used to endorse or promote products derived from this software
18
 
 *     without specific prior written permission.
19
 
 *
20
 
 *  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21
 
 *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
 
 *  ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24
 
 *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
 
 *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
 
 *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
 
 *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
 
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
 
 *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
 
 *  SUCH DAMAGE.
31
 
 */
32
 
 
33
 
#include <gtk/gtk.h>
34
 
 
35
 
#include <stdio.h>
36
 
#include <stdlib.h>
37
 
 
38
 
#include "anthyimportwordpane.h"
39
 
 
40
 
#include "charset.h"
41
 
#include "word.h"
42
 
#include "anthy.h"
43
 
#include "cannadic.h"
44
 
#include "uim/config.h"
45
 
#include "uim/gettext.h"
46
 
 
47
 
 
48
 
static gchar *dictionary_type[] = {
49
 
        "DixChange",
50
 
        "cannadic",
51
 
/*      "ATOK",
52
 
        "MS-IME", */
53
 
};
54
 
 
55
 
/* dummy functions */
56
 
static void dixchange_import (const char* filename, int type) { g_print("dixchange_import called\n"); }
57
 
static void dixchange_export (const char* filename, int type) { g_print("dixchange_export called\n"); }
58
 
 
59
 
static void cb_browse_button_clicked(GtkButton *button, GtkEntry *entry) {
60
 
    GtkWidget *filebrowser;
61
 
    gint ret;
62
 
    const gchar *filename;
63
 
 
64
 
    filebrowser = gtk_file_selection_new(_("Select File"));
65
 
    gtk_window_set_position(GTK_WINDOW(filebrowser), GTK_WIN_POS_CENTER);
66
 
    ret = gtk_dialog_run(GTK_DIALOG(filebrowser));
67
 
 
68
 
    switch(ret) {
69
 
    case GTK_RESPONSE_OK:
70
 
        filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filebrowser));
71
 
        gtk_entry_set_text(entry, filename);
72
 
        gtk_widget_destroy(filebrowser);
73
 
        break;
74
 
    case GTK_RESPONSE_CANCEL:
75
 
        gtk_widget_destroy(filebrowser);
76
 
        break;
77
 
    }
78
 
}
79
 
 
80
 
static void cb_export_button_clicked(GtkButton *button, AnthyImportWordPane *pane)
81
 
{
82
 
    GtkWidget *dialog;
83
 
    const gchar *filename;
84
 
    gint type, ret;
85
 
    int (*export_commands[])(const char*, int) = {
86
 
        dixchange_export,
87
 
        cannadic_export,
88
 
/*              atok_export,
89
 
                msime_export, */
90
 
    };
91
 
 
92
 
    filename = gtk_entry_get_text(GTK_ENTRY(pane->exportfilename));
93
 
    type = gtk_combo_box_get_active(GTK_COMBO_BOX(pane->combo_box_dic_export_type));
94
 
 
95
 
    if(filename != NULL && filename[0] != '\0')
96
 
        ret = export_commands[type](filename, 0);
97
 
 
98
 
    if(ret == -1) {
99
 
        dialog = gtk_message_dialog_new(NULL,
100
 
                                        GTK_DIALOG_MODAL,
101
 
                                        GTK_MESSAGE_ERROR,
102
 
                                        GTK_BUTTONS_CLOSE,
103
 
                                        _("Exportion failed."));
104
 
        gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
105
 
        gtk_dialog_run(GTK_DIALOG(dialog));
106
 
        gtk_widget_destroy(dialog);
107
 
    }
108
 
}
109
 
 
110
 
static void cb_import_button_clicked(GtkButton *button, AnthyImportWordPane *pane)
111
 
{
112
 
    const gchar *filename;
113
 
    gint type, ret;
114
 
    int (*import_commands[])(const char*, int) = {
115
 
        dixchange_import,
116
 
        cannadic_import,
117
 
/*              atok_import,
118
 
                msime_import, */
119
 
    };
120
 
 
121
 
    filename = gtk_entry_get_text(GTK_ENTRY(pane->importfilename));
122
 
    type = gtk_combo_box_get_active(GTK_COMBO_BOX(pane->combo_box_dic_import_type));
123
 
    if(filename != NULL && filename[0] != '\0')
124
 
        ret = import_commands[type](filename, 0);
125
 
}
126
 
 
127
 
int create_anthy_importwordpane(AnthyImportWordPane *pane) {
128
 
    GtkWidget *vbox1, *vbox2;
129
 
    GtkWidget *hbox1, *hbox2;
130
 
    GtkWidget *hbox3, *hbox4;
131
 
    GtkWidget *label1, *label2;
132
 
    GtkWidget *frame1, *frame2;
133
 
/*      GtkWidget *menu, *menuitem; */
134
 
    gint i, dictionary_type_num;
135
 
 
136
 
    dictionary_type_num = sizeof(dictionary_type) / sizeof(dictionary_type[0]);
137
 
 
138
 
    pane->pane = gtk_hbox_new(FALSE, 5);
139
 
    gtk_container_set_border_width(GTK_CONTAINER(pane->pane), 15);
140
 
 
141
 
    vbox1 = gtk_vbox_new(FALSE, 0);
142
 
    gtk_widget_show(vbox1);
143
 
    gtk_box_pack_start(GTK_BOX(pane->pane), vbox1, FALSE, FALSE, 0);
144
 
 
145
 
    /* Import */
146
 
    frame1 = gtk_frame_new(_("Import"));
147
 
    gtk_widget_show(frame1);
148
 
    gtk_box_pack_start(GTK_BOX(vbox1), frame1, FALSE, FALSE, 0);
149
 
 
150
 
    hbox2 = gtk_hbox_new(FALSE, 0);
151
 
    gtk_widget_show(hbox2);
152
 
    gtk_container_set_border_width(GTK_CONTAINER(hbox2), 10);
153
 
    gtk_container_add(GTK_CONTAINER(frame1), hbox2);
154
 
 
155
 
    label1 = gtk_label_new_with_mnemonic(_("Filename:"));
156
 
    gtk_widget_show(label1);
157
 
    gtk_box_pack_start(GTK_BOX(hbox2), label1, FALSE, FALSE, 0);
158
 
 
159
 
    pane->importfilename = gtk_entry_new();
160
 
    gtk_widget_show(pane->importfilename);
161
 
    gtk_box_pack_start(GTK_BOX(hbox2), pane->importfilename, FALSE, FALSE, 5);
162
 
 
163
 
    pane->button_import_getfilename = gtk_button_new_with_label(_("Browse..."));
164
 
    gtk_widget_show(pane->button_import_getfilename);
165
 
    gtk_box_pack_start(GTK_BOX(hbox2), pane->button_import_getfilename,
166
 
                       FALSE, FALSE, 10);
167
 
    g_signal_connect(G_OBJECT(pane->button_import_getfilename), "clicked",
168
 
                     G_CALLBACK(cb_browse_button_clicked),
169
 
                     GTK_ENTRY(pane->importfilename));
170
 
 
171
 
    pane->combo_box_dic_import_type = gtk_combo_box_new_text();
172
 
    gtk_widget_show(pane->combo_box_dic_import_type);
173
 
    for(i = 0; i < dictionary_type_num; i++) {
174
 
        gtk_combo_box_append_text(GTK_COMBO_BOX(pane->combo_box_dic_import_type),
175
 
                                  dictionary_type[i]);
176
 
    }
177
 
    gtk_box_pack_start(GTK_BOX(hbox2), pane->combo_box_dic_import_type,
178
 
                       FALSE, FALSE, 10);
179
 
 
180
 
    pane->button_doimport = gtk_button_new_with_label(_("Import"));
181
 
    gtk_box_pack_start(GTK_BOX(hbox2), pane->button_doimport,
182
 
                       FALSE, FALSE, 20);
183
 
    gtk_widget_show(pane->button_doimport);
184
 
    g_signal_connect(G_OBJECT(pane->button_doimport), "clicked",
185
 
                     G_CALLBACK(cb_import_button_clicked), pane);
186
 
 
187
 
 
188
 
    /* Export */
189
 
    frame2 = gtk_frame_new(_("Export"));
190
 
    gtk_widget_show(frame2);
191
 
    gtk_box_pack_start(GTK_BOX(vbox1), frame2, FALSE, FALSE, 10);
192
 
 
193
 
    hbox3 = gtk_hbox_new(FALSE, 0);
194
 
    gtk_widget_show(hbox3);
195
 
    gtk_container_set_border_width(GTK_CONTAINER(hbox3), 10);
196
 
    gtk_container_add(GTK_CONTAINER(frame2), hbox3);
197
 
 
198
 
    label2 = gtk_label_new_with_mnemonic(_("Filename:"));
199
 
    gtk_widget_show(label2);
200
 
    gtk_box_pack_start(GTK_BOX(hbox3), label2, FALSE, FALSE, 0);
201
 
 
202
 
    pane->exportfilename = gtk_entry_new();
203
 
    gtk_widget_show(pane->exportfilename);
204
 
    gtk_box_pack_start(GTK_BOX(hbox3), pane->exportfilename, FALSE, FALSE, 5);
205
 
 
206
 
    pane->button_export_getfilename = gtk_button_new_with_label(_("Browse..."));
207
 
    gtk_widget_show(pane->button_export_getfilename);
208
 
    gtk_box_pack_start(GTK_BOX(hbox3), pane->button_export_getfilename,
209
 
                       FALSE, FALSE, 10);
210
 
    g_signal_connect(G_OBJECT(pane->button_export_getfilename), "clicked",
211
 
                     G_CALLBACK(cb_browse_button_clicked),
212
 
                     GTK_ENTRY(pane->exportfilename));
213
 
    pane->combo_box_dic_export_type = gtk_combo_box_new_text();
214
 
    gtk_widget_show(pane->combo_box_dic_export_type);
215
 
    for(i = 0; i < dictionary_type_num; i++) {
216
 
        gtk_combo_box_append_text(GTK_COMBO_BOX(pane->combo_box_dic_export_type),
217
 
                                  dictionary_type[i]);
218
 
 
219
 
    }
220
 
    gtk_box_pack_start(GTK_BOX(hbox3), pane->combo_box_dic_export_type,
221
 
                       FALSE, FALSE, 10);
222
 
    pane->button_doexport = gtk_button_new_with_label(_("Export"));
223
 
    gtk_box_pack_start(GTK_BOX(hbox3), pane->button_doexport,
224
 
                       FALSE, FALSE, 20);
225
 
    gtk_widget_show(pane->button_doexport);
226
 
 
227
 
    g_signal_connect(G_OBJECT(pane->button_doexport), "clicked",
228
 
                     G_CALLBACK(cb_export_button_clicked), pane);
229
 
    return 0;
230
 
}
231
 
 
232
 
int show_anthy_importwordpane(AnthyImportWordPane *pane) {
233
 
    gtk_widget_show(pane->pane);
234
 
    return 0;
235
 
}