Welcome picture has been added:-)
authorgadomska_anna <gadomska.anna@gmail.com>
Tue, 29 Aug 2006 06:13:57 +0000 (06:13 +0000)
committergadomska_anna <gadomska.anna@gmail.com>
Tue, 29 Aug 2006 06:13:57 +0000 (06:13 +0000)
git-svn-id: file:///svnroot/mdictionary/trunk@5 5bde0345-f819-0410-ac75-e5045f9217cc

gui/src/ws_gui_callbacks.c
gui/src/ws_gui_layout.c
include/ws_gui.h
include/ws_gui_callbacks.h
stork.png [new file with mode: 0644]

index a3dd430..30f216a 100644 (file)
@@ -486,7 +486,7 @@ GtkTreeModel * create_and_fill_model (GArray *words_list, gpointer user_data)
         /* Append a row and fill in some data */
        while (tmp != NULL)
        {
-       tmp2 = g_utf8_normalize(tmp, strlen(tmp), G_NORMALIZE_ALL);
+       //tmp2 = g_utf8_normalize(tmp, strlen(tmp), G_NORMALIZE_ALL);
        gtk_list_store_append (ws_gui_app->ws_gui_w_list->ws_gui_store, &ws_gui_app->ws_gui_w_list->ws_gui_iter);
        gtk_list_store_set (ws_gui_app->ws_gui_w_list->ws_gui_store,                                                               &ws_gui_app->ws_gui_w_list->ws_gui_iter,                                                                COL_WORD,                                                                                               tmp,                                                                                                    -1);
        i=i+1;
@@ -497,6 +497,7 @@ GtkTreeModel * create_and_fill_model (GArray *words_list, gpointer user_data)
        if (tmp != NULL)
        {
                ws_dbus_client_find_translation(ws_gui_app->dbus_data, tmp);
+               ws_gui_history_add(tmp, ws_gui_app);
        }
        
        return GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_store);
@@ -747,3 +748,32 @@ void ws_gui_read_adjustment(gpointer user_data)
        
 }
 
+void ws_gui_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *stream)
+{
+       int fd;
+
+       if (url && !strncmp (url, "file:", 5)) {
+               url += 5;
+               fd = open (url, O_RDONLY);
+
+               if (fd != -1) {
+                       gchar *buf;
+                       size_t size;
+
+                       buf = alloca (8192);
+                       while ((size = read (fd, buf, 8192)) > 0) {
+                               gtk_html_stream_write (stream, buf, size);
+                       }
+                       gtk_html_stream_close (stream,
+                                              size == -1
+                                              ? GTK_HTML_STREAM_ERROR
+                                              : GTK_HTML_STREAM_OK);
+                       close (fd);
+
+                       return;
+               }
+       }
+
+       gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
+}
+
index 10f978b..db96496 100644 (file)
@@ -17,7 +17,7 @@ void ws_gui_create_window(gpointer user_data)
 {
        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
        
-       ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string = "<font size=+2><center>Welcome to<br><b>WhiteStork</b><br>Dictionary.</font></center>";
+       ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string = "<font size=+2><center><br>Welcome to<br><b>WhiteStork</b><br>Dictionary.</font><br><IMG SRC=file:stork.png></center>";
 
        GArray *array_tmp = g_array_new (TRUE, TRUE, sizeof(gchar*));
 
@@ -52,7 +52,12 @@ void ws_gui_create_window(gpointer user_data)
        
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(ws_gui_app->ws_gui_scrolledwindow_left), ws_gui_app->ws_gui_w_list->ws_gui_view);
 
-       ws_gui_app->ws_gui_html = gtk_html_new_from_string(ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string, strlen(ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string));
+       ws_gui_app->ws_gui_html = gtk_html_new();
+       //ws_gui_app->ws_gui_html = gtk_html_new_from_string(ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string, strlen(ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string));
+       
+       g_signal_connect(GTK_OBJECT (ws_gui_app->ws_gui_html), "url_requested", G_CALLBACK(ws_gui_url_requested), ws_gui_app);
+       
+       gtk_html_load_from_string(GTK_HTML(ws_gui_app->ws_gui_html), ws_gui_app->ws_gui_w_list->ws_gui_list_item_data_string, -1);
 
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(ws_gui_app->ws_gui_scrolledwindow_right), ws_gui_app->ws_gui_html);
        gtk_paned_add1(GTK_PANED(ws_gui_app->ws_gui_hpane), ws_gui_app->ws_gui_scrolledwindow_left);
index b3701ef..04676fd 100644 (file)
@@ -28,6 +28,12 @@ extern "C" {
 
 #include "ws_dbus.h"
 
+//============================
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+//============================
+
 #define HISTORY_LEN 5
 #define SCROLL_STEP_H 50
 #define SCROLL_STEP_V 20
index 623c588..cc668c7 100644 (file)
@@ -145,6 +145,9 @@ void ws_gui_read_adjustment(gpointer user_data);
  *
  */
 
+
+void ws_gui_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *stream);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/stork.png b/stork.png
new file mode 100644 (file)
index 0000000..8b49df2
Binary files /dev/null and b/stork.png differ