2 * MStarDict - International dictionary for Maemo.
3 * Copyright (C) 2010 Roman Moravcik
5 * base on code of stardict:
6 * Copyright (C) 2003-2007 Hu Zheng <huzheng_001@163.com>
8 * based on code of sdcv:
9 * Copyright (C) 2005-2006 Evgeniy <dushistov@mail.ru>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include <glib/gi18n.h>
39 #include <hildon/hildon.h>
41 #include "libwrapper.hpp"
42 #include "mstardict.hpp"
43 #include "transwin.hpp"
45 TransWin::TransWin(MStarDict *mStarDict)
47 oStarDict = mStarDict;
56 TransWin::CreateTransWidget(SearchResult *result)
58 GtkWidget *vbox, *hbox, *label;
59 char *bookname = NULL, *def = NULL, *exp = NULL;
61 bookname = g_markup_printf_escaped("<span color=\"dimgray\" size=\"x-small\">%s</span>",
63 def = g_markup_printf_escaped("<span color=\"darkred\" weight=\"heavy\" size=\"large\">%s</span>",
65 exp = g_strdup(result->exp);
67 vbox = gtk_vbox_new(FALSE, 0);
69 hbox = gtk_hbox_new(FALSE, 0);
70 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
72 label = gtk_label_new("Definition");
73 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
74 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
76 gtk_label_set_markup(GTK_LABEL(label), def);
80 label = gtk_label_new("Bookname");
81 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
82 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
84 gtk_label_set_markup(GTK_LABEL(label), bookname);
88 label = gtk_label_new("Expresion");
89 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
90 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
91 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
93 gtk_label_set_markup(GTK_LABEL(label), exp);
101 TransWin::CreateTransWindow(GList *results)
103 GtkWidget *window, *alignment, *pannable, *vbox, *trans, *separator;
104 GList *result = NULL;
106 window = hildon_stackable_window_new();
107 gtk_window_set_title(GTK_WINDOW(window), _("Translation"));
109 alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
110 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
111 HILDON_MARGIN_DEFAULT,
112 HILDON_MARGIN_DEFAULT, HILDON_MARGIN_DOUBLE, HILDON_MARGIN_DEFAULT);
113 gtk_container_add(GTK_CONTAINER(window), alignment);
115 pannable = hildon_pannable_area_new();
116 gtk_container_add(GTK_CONTAINER(alignment), pannable);
118 vbox = gtk_vbox_new(FALSE, 16);
119 hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable), vbox);
121 for (result = results; result != NULL; result = result->next) {
122 trans = CreateTransWidget((SearchResult *) result->data);
123 gtk_box_pack_start(GTK_BOX(vbox), trans, FALSE, FALSE, 0);
125 separator = gtk_hseparator_new();
126 gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
129 gtk_widget_show_all(window);