summaryrefslogtreecommitdiff
path: root/dictwin.c
diff options
context:
space:
mode:
authorb0ric <b0risov.alexandr@rambler.ru>2009-08-08 20:18:38 +0300
committerb0ric <b0risov.alexandr@rambler.ru>2009-08-08 20:18:38 +0300
commit343357ed1e7907cf4b488058053df280ae63c7bb (patch)
tree201915ed25612180af3745131be66ce19edf1a0b /dictwin.c
parent88db5cdceabf042f5e5d5695bf984900f8396225 (diff)
Now words are shown in alphabetical order
Diffstat (limited to 'dictwin.c')
-rw-r--r--dictwin.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/dictwin.c b/dictwin.c
new file mode 100644
index 0000000..9569a35
--- /dev/null
+++ b/dictwin.c
@@ -0,0 +1,107 @@
+/* This file is a part of WordExtract project
+ *
+ * Copyright (C) 2009 Borisov Alexandr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+#include "dictwin.h"
+#include "mainwin.h"
+#include "dict.h"
+
+static void fill_dict(GtkTextBuffer *, Word *);
+
+void create_dict_win()
+{
+ GtkWidget *dict_win;
+
+ dict_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_widget_set_size_request(dict_win, 500, 375);
+ gtk_container_set_border_width(GTK_CONTAINER(dict_win), 0);
+ gtk_window_set_title(GTK_WINDOW(dict_win), "My Dictionary");
+ gtk_window_set_transient_for(GTK_WINDOW(dict_win), GTK_WINDOW(main_window));
+ gtk_window_set_position(GTK_WINDOW(dict_win), GTK_WIN_POS_CENTER_ON_PARENT);
+ gtk_window_set_modal(GTK_WINDOW(dict_win), TRUE);
+ gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dict_win), TRUE);
+
+ GtkWidget *vbox;
+ vbox = gtk_vbox_new(FALSE, 2);
+ gtk_container_add(GTK_CONTAINER(dict_win), vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
+ gtk_widget_show(vbox);
+
+ GtkWidget *dict_sc;
+ dict_sc = gtk_scrolled_window_new(NULL, NULL);
+ gtk_box_pack_start(GTK_BOX(vbox), dict_sc, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(dict_sc), GTK_SHADOW_IN);
+ gtk_widget_show(dict_sc);
+
+ GtkWidget *dict_text;
+ GtkTextBuffer *buffer;
+ dict_text = gtk_text_view_new();
+ gtk_container_add(GTK_CONTAINER(dict_sc), dict_text);
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(dict_text));
+ fill_dict(buffer, dict);
+ gtk_widget_show(dict_text);
+
+ GtkWidget *hbox;
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show(hbox);
+
+ GtkWidget *btn_hbox;
+ btn_hbox = gtk_hbox_new(TRUE, 2);
+ gtk_box_pack_end(GTK_BOX(hbox), btn_hbox, FALSE, FALSE, 0);
+ gtk_widget_show(btn_hbox);
+
+ GtkWidget *cancel_btn;
+ cancel_btn = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+ gtk_box_pack_end(GTK_BOX(btn_hbox), cancel_btn, TRUE, TRUE, 0);
+ gtk_widget_show(cancel_btn);
+
+ GtkWidget *save_btn;
+ save_btn = gtk_button_new_from_stock(GTK_STOCK_SAVE);
+ gtk_box_pack_end(GTK_BOX(btn_hbox), save_btn, TRUE, TRUE, 0);
+ gtk_widget_show(save_btn);
+
+ gtk_widget_show(dict_win);
+}
+
+static void fill_dict(GtkTextBuffer *buffer, Word *dict)
+{
+ GtkTextIter iter;
+
+ if (dict != NULL) {
+ if (dict->lsibl != NULL)
+ fill_dict(buffer, dict->lsibl);
+ if (dict->rsibl != NULL)
+ fill_dict(buffer, dict->rsibl);
+ gtk_text_buffer_get_end_iter(buffer, &iter);
+ gtk_text_buffer_insert(buffer, &iter, (gchar*) dict->word, -1);
+ gtk_text_buffer_insert(buffer, &iter, "\n", -1);
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+