problem with cleaning wors list after bookmarks closing fixed;
[mdictionary] / src / gui / src / ws_gui_callbacks.c
index 40d1e8f..5f417d8 100644 (file)
@@ -141,6 +141,7 @@ void ws_gui_signal_hander (GError *error, GArray *words, gpointer user_data)
                         ws_gui_app->ws_gui_w_list->ws_gui_model = 
                                 create_and_fill_model(tmp, ws_gui_app);
                         ws_gui_fill_html(" ", ws_gui_app);
+                       ws_gui_app->html_flag = FALSE;
 
                         gtk_widget_set_sensitive(
                              GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
@@ -176,23 +177,35 @@ void ws_gui_signal_hander (GError *error, GArray *words, gpointer user_data)
                        gtk_widget_set_sensitive(
                         GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
                         FALSE);
+                        gtk_widget_set_sensitive(
+                        GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks),
+                        FALSE);
+                      gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_w_list->ws_gui_view),
+                       FALSE);
 
                        break;
                 }
 
                 case WS_DBUS_INFO_CACHING_FINISHED:
                 {
-                        gtk_widget_destroy(
-                                 GTK_WIDGET(ws_gui_app->ws_gui_banner_caching));
-                        ws_gui_app->caching_flag = FALSE;
-                        gtk_widget_set_sensitive(
-                             GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
-                             TRUE);
-                        gtk_widget_set_sensitive(
-                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
-                       TRUE);
+                      gtk_widget_destroy(
+                      GTK_WIDGET(ws_gui_app->ws_gui_banner_caching));
+                      ws_gui_app->caching_flag = FALSE;
+                      gtk_widget_set_sensitive(
+                      GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                      TRUE);
+                      gtk_widget_set_sensitive(
+                      GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                      TRUE);
+                     gtk_widget_set_sensitive(
+                      GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks),
+                      TRUE);
+                     gtk_widget_set_sensitive(
+                      GTK_WIDGET(ws_gui_app->ws_gui_w_list->ws_gui_view),
+                      TRUE);
 
-                        break;
+                      break;
                 }
 
                 case WS_DBUS_ERROR_DICTIONARY_NOT_LOAD:
@@ -243,7 +256,7 @@ void ws_gui_signal_hander (GError *error, GArray *words, gpointer user_data)
                                         _("ws_ni_bookmark_not_added"));
                break;
                }
-        
+
                case WS_DBUS_BOOKMARKS_REMOVED_FAIL:
                {
                        gtk_infoprint(GTK_WINDOW(
@@ -251,8 +264,135 @@ void ws_gui_signal_hander (GError *error, GArray *words, gpointer user_data)
                                         _("ws_ni_bookmark_not_removed"));
                break;
                }
+
+               case WS_DBUS_LOAD_BOOKMARK_FAILED:
+               {
+                    gtk_widget_set_sensitive(
+                     GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_bookmarks),
+                     FALSE);
+                    ws_gui_app->bookmark_avail = FALSE;
+                               
+                       ws_gui_app->ws_message_dialog = 
+                        gtk_message_dialog_new(
+                                  GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_ERROR,
+                                   GTK_BUTTONS_OK,
+                                   _("ws_ni_bookmarks_unavailable"));
+
+                       if (gtk_dialog_run(
+                                GTK_DIALOG(ws_gui_app->ws_message_dialog)) 
+                                                            == GTK_RESPONSE_OK)
+                        {
+                                gtk_widget_destroy(
+                                                 ws_gui_app->ws_message_dialog);
+                        }
+
+                       
+                        break; 
+               }
+               case WS_DBUS_EXTRACT_FILE:
+                {
+                        ws_gui_app->ws_gui_banner_extracting =
+                               hildon_banner_show_animation(
+                                   GTK_WIDGET(ws_gui_app->ws_gui_hildon_window),
+                                   NULL,
+                                   _("ws_pb_extracting"));
+
+                       ws_gui_app->caching_flag = TRUE;
+                       
+                       gtk_widget_set_sensitive(
+                          GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                          FALSE);
+                       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                        FALSE);
+
+                       break;
+                }
+
+                case WS_DBUS_EXTRACT_FILE_FINISHED:
+                {
+                       gtk_widget_destroy(
+                       GTK_WIDGET(ws_gui_app->ws_gui_banner_extracting));
+                       
+                       ws_gui_app->caching_flag = FALSE;
+                       
+                       gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ni_dictionary_added"));
+                       
+                       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_hildon_find_toolbar),
+                       TRUE);
+                       gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                       TRUE);
+
+                        break;
+                }
+
+               case  WS_DBUS_WORDS_LIST_FULL:
+               {
+                       gtk_widget_show(GTK_WIDGET(ws_gui_app->ws_gui_list_hbox));
+               break;
+               }
+
+               case  WS_DBUS_WORDS_LIST_FILLED_NOT_FULL:
+               {
+                       gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_list_hbox));
+               break;
+               }
+
+               case  WS_DBUS_WORDS_LIST_FINISHED:
+               {
+                       gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+               break;
+               }
+
+               case  WS_DBUS_TRANSLATION_FINISHED:
+               {
+                       gtk_widget_hide(ws_gui_app->ws_gui_banner_translation_loading);
+               break;
+               }
+
+               case  WS_DBUS_WORDS_LIST_STARTED:
+               {
+                       gtk_widget_show(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+               break;
+               }
+
+               case  WS_DBUS_TRANSLATION_STARTED:
+               {
+                       gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               break;
+               }
+
         }
 }
+
+
+/* added by Dariusz Wiechecki - HISA */
+void ws_gui_search_home_handler(GError *error, GArray *word, gpointer user_data)
+{
+        g_debug("->%s", __FUNCTION__);
+        WSGuiApp *data = (WSGuiApp*) user_data;
+        osso_rpc_t* osso_data = NULL;
+
+        //get the word passed by dbus 
+        osso_data = &g_array_index (word, osso_rpc_t, 0); 
+
+        //free memory used by last searched word
+        gchar* tmp = NULL;
+        tmp = g_strdup(osso_data->value.s + 11);
+       
+       g_object_set(G_OBJECT(data->ws_gui_hildon_find_toolbar),
+                    "prefix",
+                    tmp,
+                    NULL);
+       ws_gui_search(NULL, data);
+}
+
 /**  this function handles signals from dbus; it is called when progress bar
  status has been changed
  *
@@ -275,6 +415,31 @@ void ws_dbus_progress_bar(GError *error, GArray *words, gpointer user_data)
         }
 }
 
+/** this function clean GtkListStore row by row
+ *
+ * @param list - GtkListStore to be remoeved
+ * @return
+ */
+void ws_gui_clear_list (GtkListStore* list, gpointer user_data) 
+{
+       //WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       GtkTreeIter iter;
+       gboolean tmp;
+       
+       //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n\nws_gui_clear_list\n\n");   
+       tmp = gtk_tree_model_get_iter_first(
+                        GTK_TREE_MODEL(list),
+                        &iter);        
+
+       while (tmp == TRUE)
+       {
+       //      g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n\nws_gui_clear_list2\n\n");
+               tmp = gtk_list_store_remove(list, &iter);
+               
+       }
+}
+
+
 /** this function handles signal from dbus and transfer recived 
 (found in a dictionary) words to the words list
  *
@@ -290,6 +455,13 @@ void ws_gui_dbus_return_words (GError *error, GArray *words, gpointer user_data)
         osso_rpc_t data;
 
         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       ws_gui_app->no_words_found = FALSE;
+       
+       g_signal_handlers_block_by_func(G_OBJECT 
+                       (ws_gui_app->ws_gui_w_list->ws_gui_view),
+                        G_CALLBACK (ws_gui_view_cursor_changed), 
+                       ws_gui_app);    
+
 
         GArray *tmp;
         tmp = g_array_new(TRUE, TRUE, sizeof(gchar*));
@@ -298,32 +470,129 @@ void ws_gui_dbus_return_words (GError *error, GArray *words, gpointer user_data)
         for (i=0;i<words->len;++i)
         {
                 data = g_array_index (words, osso_rpc_t, i);
-                tmp_word = g_strconcat(data.value.s,NULL);
+                tmp_word = g_strdup(data.value.s);
                 g_array_append_val(tmp, tmp_word);
         }
        
-       g_assert(ws_gui_app->ws_gui_banner);
-        gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner));
-       ws_gui_app->ws_gui_banner_flag = FALSE;
-        gtk_widget_set_sensitive(
-                              GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_stop),
-                              FALSE);
-        gtk_widget_set_sensitive(
-                          GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_stop),
-                          FALSE);
-        gtk_list_store_clear(ws_gui_app->ws_gui_w_list->ws_gui_store);
+       //g_assert(ws_gui_app->ws_gui_banner_list_searching);
+        //gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+
+       ws_gui_app->loading = FALSE;
+       ws_gui_set_toolbar_avail(ws_gui_app);
+
+       //ws_gui_app->ws_gui_banner_flag = FALSE;
+
+       //ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store);
+
 
         ws_gui_app->ws_gui_w_list->ws_gui_model = 
-                                         create_and_fill_model(tmp, ws_gui_app);
+                                        create_and_fill_model(tmp, ws_gui_app);
+       
+       if (ws_gui_app->history_flag == TRUE)
+       {
+
+       GValue value = { 0, };
+       GtkTreeIter tmp_iter;
+       gchar *pattern;
+       gboolean keep_searching = TRUE;
+
+       if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(
+           ws_gui_app->ws_gui_w_list->ws_gui_model), &tmp_iter) == TRUE)
+       {
+
+               pattern = strdup(g_array_index(ws_gui_app->ws_gui_history,
+                                       gchar*, 
+                                       ws_gui_app->ws_gui_history_cur_pos));
+               
+               gtk_tree_model_get_value(GTK_TREE_MODEL(
+                               ws_gui_app->ws_gui_w_list->ws_gui_model), 
+                               &tmp_iter, 
+                               COL_WORD, 
+                               &value);
+
+               if ((g_value_get_string (&value) != NULL) &&
+                               (strcmp(((gchar *)g_value_get_string (&value)), 
+                                pattern) == 0))
+               {
+                       gtk_tree_selection_select_iter(
+                               ws_gui_app->ws_gui_w_list->ws_gui_selection,
+                               &tmp_iter);
 
-        if (tmp->len == 0)
+               }
+               else
+               {
+               while (gtk_tree_model_iter_next(GTK_TREE_MODEL
+                     (ws_gui_app->ws_gui_w_list->ws_gui_model), 
+                     &tmp_iter) == TRUE && keep_searching == TRUE)
+               {
+                       gtk_tree_model_get_value(GTK_TREE_MODEL(
+                               ws_gui_app->ws_gui_w_list->ws_gui_model), 
+                               &tmp_iter, 
+                               COL_WORD, 
+                               &value);
+
+                       if ((g_value_get_string (&value) != NULL) &&
+                               (strcmp(((gchar *)g_value_get_string (&value)), 
+                               pattern) == 0))
+                               {
+                               gtk_tree_model_get_iter_from_string (
+                               GTK_TREE_MODEL(
+                               ws_gui_app->ws_gui_w_list->ws_gui_model),
+                                &tmp_iter,
+                                g_array_index(
+                               ws_gui_app->ws_gui_history_iter,
+                               gchar*, 
+                               ws_gui_app->ws_gui_history_cur_pos));
+
+                               gtk_tree_selection_select_iter(
+                               ws_gui_app->ws_gui_w_list->ws_gui_selection,
+                               &tmp_iter);
+                                                               
+                               keep_searching = FALSE;
+                               }
+                       }
+               }
+       }
+       g_free(pattern);
+
+       ws_gui_app->history_flag = FALSE;
+       ws_dbus_client_find_translation(ws_gui_app->dbus_data, 
+                               g_array_index(ws_gui_app->ws_gui_history,
+                               gchar*, 
+                               ws_gui_app->ws_gui_history_cur_pos));
+       
+       ws_gui_app->html_flag = TRUE;
+       g_value_unset (&value);
+       }
+       
+       
+/*     g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Dlugosc tempa to: %d", tmp->len);
+       g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "w tempie mamy: %s", tmp_word);*/
+        //if (&& ws_gui_app->stop_clicked != TRUE )
+       
+       if ((tmp->len == 0 || tmp_word == NULL) && ws_gui_app->stop_clicked != TRUE )
         {
                 gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
                               _("ws_ni_no_words_found"));
+               
+               //ws_gui_fill_html(" ", ws_gui_app);
+               //ws_gui_app->html_flag = FALSE;
                g_free(ws_gui_app->last_word);
                ws_gui_app->last_word = NULL;
+               ws_gui_app->no_words_found = TRUE;
         }
+
+       g_signal_handlers_unblock_by_func(G_OBJECT(
+                                       ws_gui_app->ws_gui_w_list->ws_gui_view),
+                                        G_CALLBACK (ws_gui_view_cursor_changed), 
+                                       ws_gui_app);    
+       
+       for (i=0;i<tmp->len;++i)
+        {
+                g_free(g_array_index(tmp, gchar* , i));
+        }
+       g_array_free(tmp, TRUE);
+
         timer(TIMER_STOP, (gchar*)__FUNCTION__);
 }
 
@@ -339,17 +608,54 @@ void ws_gui_dbus_return_translation (GError *error,
                                      GArray *words,
                                      gpointer user_data)
 {
-        timer(TIMER_START, (gchar*)__FUNCTION__);
         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
-
+       gchar *html_content = NULL;
         osso_rpc_t data;
 
         data = g_array_index (words, osso_rpc_t, 0);
-        gtk_html_zoom_reset(GTK_HTML(ws_gui_app->ws_gui_html));
-        ws_gui_fill_html(format_html(data.value.s, ws_gui_app), ws_gui_app);
+
+       html_content = format_html(data.value.s, ws_gui_app);
+       ws_gui_fill_html(html_content, ws_gui_app);
+       g_free(html_content);
+       ws_gui_app->html_flag = TRUE;
        
+       //gtk_widget_hide(ws_gui_app->ws_gui_banner_translation_loading);
+       ws_gui_app->loading = FALSE;
+       ws_gui_set_toolbar_avail(ws_gui_app);
 
-        timer(TIMER_STOP, (gchar*)__FUNCTION__);
+}
+
+/** this function handles signal from dbus and send recived data to 
+the translation area
+ *
+ * @param error - error message recived from DBUS
+ * @param words - array with recived data structure
+ * @param user_data - pointer to data structure
+ * @return
+ */
+void ws_dbus_server_return_extracted_bzip(GError *error,
+                                     GArray *words,
+                                     gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+        osso_rpc_t data;
+
+        data = g_array_index (words, osso_rpc_t, 0);
+
+       if (data.value.s[0] == '\0')
+       {
+               gtk_infoprint(GTK_WINDOW(
+                                ws_gui_app->ws_gui_hildon_window),
+                                _("ws_ni_dictionary_not_added"));
+       }
+       else
+       {
+       if (ws_gui_load_dict(data.value.s, ws_gui_app) == TRUE)
+       {
+               
+       }
+       }
 }
 
 /**
@@ -360,8 +666,32 @@ void ws_gui_dbus_return_translation (GError *error,
 void ws_gui_free_memory(gpointer user_data)
 {
         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       guint i = 0;
+       for (i = 0; i<ws_gui_app->ws_gui_history->len; ++i)
+       {
+               g_free(g_array_index(ws_gui_app->ws_gui_history, gchar *, i));
+       }
         g_array_free(ws_gui_app->ws_gui_history, TRUE);
+
+       for (i = 0; i<ws_gui_app->ws_gui_history_list->len; ++i)
+       {
+               g_free(g_array_index(ws_gui_app->ws_gui_history_list, gchar *, i));
+       }
+       g_array_free(ws_gui_app->ws_gui_history_list, TRUE);
+
+       for (i = 0; i<ws_gui_app->ws_gui_history_iter->len; ++i)
+       {
+               g_free(g_array_index(ws_gui_app->ws_gui_history_iter, gchar *, i));
+       }
+       g_array_free(ws_gui_app->ws_gui_history_iter, TRUE);
+
+
         pango_font_description_free(ws_gui_app->p);
+
+       g_free(ws_gui_app->welcome_note);
+       ws_gui_app->welcome_note = NULL;
+
+       g_string_free(ws_gui_app->raw_translation, TRUE);
         g_free(ws_gui_app->last_word);
        g_free(ws_gui_app->ws_gui_w_list);
         g_free(ws_gui_app->ws_gui_menu);
@@ -401,7 +731,8 @@ gboolean hildon_key_press_listener (GtkWidget * widget,
                                         GTK_ADJUSTMENT(ws_gui_app->ws_gui_vadj),
                                         ws_gui_app->v_new_value);
                       }
-                      break;
+                       
+                       break;
                 }
 
                 case HILDON_HARDKEY_DOWN: 
@@ -511,7 +842,7 @@ void ws_gui_words_list_hide_from_menu(GtkCheckMenuItem *checkmenuitem,
         if (gtk_check_menu_item_get_active(
            GTK_CHECK_MENU_ITEM(ws_gui_app->ws_gui_menu->ws_gui_menu_hide_list)))
         {
-                gtk_widget_hide(ws_gui_app->ws_gui_scrolledwindow_left);
+                gtk_widget_hide(ws_gui_app->ws_gui_list_vbox);
                 gtk_toggle_tool_button_set_active(
                   GTK_TOGGLE_TOOL_BUTTON(ws_gui_app->ws_gui_toobar_button_hide),
                   TRUE);
@@ -521,7 +852,7 @@ void ws_gui_words_list_hide_from_menu(GtkCheckMenuItem *checkmenuitem,
         }
         else 
         {
-                gtk_widget_show(ws_gui_app->ws_gui_scrolledwindow_left);
+                gtk_widget_show(ws_gui_app->ws_gui_list_vbox);
                 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(
                                          ws_gui_app->ws_gui_toobar_button_hide),
                                          FALSE);
@@ -545,7 +876,7 @@ void ws_gui_words_list_hide(GtkToggleButton *togglebutton, gpointer user_data)
         if (gtk_toggle_tool_button_get_active(
                  GTK_TOGGLE_TOOL_BUTTON(ws_gui_app->ws_gui_toobar_button_hide)))
         {
-                gtk_widget_hide(ws_gui_app->ws_gui_scrolledwindow_left);
+                gtk_widget_hide(ws_gui_app->ws_gui_list_vbox);
                 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(
                                          ws_gui_app->ws_gui_toobar_button_hide),
                                          TRUE);
@@ -555,7 +886,7 @@ void ws_gui_words_list_hide(GtkToggleButton *togglebutton, gpointer user_data)
         }
         else 
         {
-                gtk_widget_show(ws_gui_app->ws_gui_scrolledwindow_left);
+                gtk_widget_show(ws_gui_app->ws_gui_list_vbox);
                 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(
                                          ws_gui_app->ws_gui_toobar_button_hide),
                                          FALSE);
@@ -573,33 +904,96 @@ void ws_gui_words_list_hide(GtkToggleButton *togglebutton, gpointer user_data)
  */
 void ws_gui_history_add(char *new_word, gpointer user_data)
 {
-        guint i;
-        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
-        gchar *tmp_word;
-
-        i = ws_gui_app->ws_gui_history_cur_pos + 1;
-        gchar *tmp = g_array_index(ws_gui_app->ws_gui_history, gchar*, i);
-
-        while (tmp != NULL) 
-        {
-                g_array_remove_index(ws_gui_app->ws_gui_history, i);
-                tmp = g_array_index(ws_gui_app->ws_gui_history, gchar*, i);
-        }
+       WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
 
-        i = 0;
-        ws_gui_app->ws_gui_history_cur_pos ++;
-
-        tmp_word = g_strdup(new_word);
-        g_array_append_val(ws_gui_app->ws_gui_history, tmp_word);
+       if (ws_gui_app->history_flag != TRUE)
+       {
 
-        if(ws_gui_app->ws_gui_history->len > HISTORY_LEN)
-        {
-                g_array_remove_index(ws_gui_app->ws_gui_history, 0);
-                ws_gui_app->ws_gui_history_cur_pos--;
-        }
+               guint i;
+               gchar *tmp_word;
+               gchar *tmp_last_searched;
+               gchar *tmp_iter = NULL;
+               gchar *previous_word = " ";
+       
+               if (ws_gui_app->ws_gui_history_cur_pos > -1 &&
+                   g_array_index(ws_gui_app->ws_gui_history, 
+                                 gchar*, 
+                                 ws_gui_app->ws_gui_history_cur_pos) != NULL)
+               {
+                       previous_word = NULL;
+                       previous_word = g_array_index(
+                                       ws_gui_app->ws_gui_history, 
+                                       gchar*, 
+                                       ws_gui_app->ws_gui_history_cur_pos);
+               }
+       
+               i = ws_gui_app->ws_gui_history_cur_pos + 1;
+               gchar *tmp = g_array_index(ws_gui_app->ws_gui_history, 
+                                          gchar*, 
+                                          i);
+               //tmp_iter = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_model), &ws_gui_app->ws_gui_w_list->ws_gui_iter);
+       
+               if (previous_word != NULL && 
+                   strcmp(previous_word, new_word) != 0)
+               {
+                       while (tmp != NULL) 
+                       {
+                               g_array_remove_index(
+                               ws_gui_app->ws_gui_history_list, 
+                               i);
+                               g_array_remove_index(
+                               ws_gui_app->ws_gui_history_iter, 
+                               i);
+
+                               
+                               g_array_remove_index(
+                               ws_gui_app->ws_gui_history, 
+                               i);
+                               
+                               tmp = g_array_index(
+                                     ws_gui_app->ws_gui_history, 
+                                     gchar*, 
+                                     i);
+                       }
+       
+               i = 0;
+               ws_gui_app->ws_gui_history_cur_pos ++;
+       
+               if (ws_gui_app->bookmark_mode == FALSE)
+               {
+                       tmp_last_searched = g_strdup(ws_gui_app->last_searched);
+               }
+               else
+               {
+               tmp_last_searched = g_strdup(ws_gui_app->last_searched_in_book);
+               }
 
-        i = 0;
-        tmp = g_array_index(ws_gui_app->ws_gui_history, gchar*, i);
+               g_array_append_val(ws_gui_app->ws_gui_history_list, 
+                                  tmp_last_searched);
+                               
+               tmp_word = g_strdup(new_word);
+               
+               g_array_append_val(ws_gui_app->ws_gui_history, tmp_word);
+               g_array_append_val(ws_gui_app->ws_gui_history_iter, tmp_iter);
+               
+       
+               if(ws_gui_app->ws_gui_history->len > HISTORY_LEN)
+               {
+                       g_array_remove_index(ws_gui_app->ws_gui_history, 0);
+                       g_array_remove_index(ws_gui_app->ws_gui_history_list, 
+                                       0);
+                       g_array_remove_index(ws_gui_app->ws_gui_history_iter, 
+                                       0);
+                       
+                       ws_gui_app->ws_gui_history_cur_pos--;
+               }
+       
+               i = 0;
+               
+               tmp = g_array_index(ws_gui_app->ws_gui_history, gchar*, i);
+               }
+               
+       }
 
         ws_gui_check_history(ws_gui_app);
 }
@@ -613,31 +1007,40 @@ void ws_gui_history_add(char *new_word, gpointer user_data)
  */
 void ws_gui_history_back(GtkButton *button, gpointer user_data) 
 {
-        WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+       WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+       
+       ws_gui_app->history_flag = TRUE;
 
-        if (ws_gui_app->ws_gui_history_cur_pos > 0) 
+        if (ws_gui_app->ws_gui_history_cur_pos > -1) 
        {
-                ws_gui_app->ws_gui_history_cur_pos = 
+               ws_gui_app->ws_gui_history_cur_pos = 
                                        ws_gui_app->ws_gui_history_cur_pos - 1;
 
-               ws_dbus_client_search_in_history(
-                        ws_gui_app->dbus_data,
-                        (g_array_index(ws_gui_app->ws_gui_history,
-                                       gchar*, 
-                                       ws_gui_app->ws_gui_history_cur_pos)));
+               
+               g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                            "prefix",
+                            (g_array_index(ws_gui_app->ws_gui_history_list,
+                             gchar*, 
+                             ws_gui_app->ws_gui_history_cur_pos)),
+                            NULL);
+       
+               ws_dbus_client_find_word (ws_gui_app->dbus_data, 
+                                       g_strstrip(g_array_index(ws_gui_app->ws_gui_history_list,
+                                               gchar*, 
+                                       ws_gui_app->ws_gui_history_cur_pos))
+                                       );
+               //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               ws_gui_app->loading = TRUE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
         }
         else 
         {
-                gtk_widget_set_sensitive (
-                              GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_back),
-                              FALSE);
-                gtk_widget_set_sensitive(
-                     GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_prev),
-                     FALSE);
+               ws_gui_app->loading = FALSE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
         }
 
         ws_gui_check_history(ws_gui_app);
-
 }
 
 /** display choosen word, next in the history array (if avaible), 
@@ -650,8 +1053,10 @@ sets current position in the history array
 void ws_gui_history_next(GtkButton *button, gpointer user_data) 
 {
         WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
+       
+       ws_gui_app->history_flag = TRUE;
 
-                gchar *tmp = g_array_index(ws_gui_app->ws_gui_history,
+        gchar *tmp = g_array_index(ws_gui_app->ws_gui_history,
                                    gchar*,
                                    ws_gui_app->ws_gui_history_cur_pos+1);
 
@@ -660,11 +1065,26 @@ void ws_gui_history_next(GtkButton *button, gpointer user_data)
         {
                 ws_gui_app->ws_gui_history_cur_pos =
                          ws_gui_app->ws_gui_history_cur_pos + 1;
-                ws_dbus_client_search_in_history(ws_gui_app->dbus_data,
-                                (g_array_index(ws_gui_app->ws_gui_history,
-                                          gchar*,
-                                          ws_gui_app->ws_gui_history_cur_pos)));
 
+
+               g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                              "prefix",
+                              (g_array_index(ws_gui_app->ws_gui_history_list,
+                               gchar*, 
+                               ws_gui_app->ws_gui_history_cur_pos)),
+                              NULL);
+       
+               
+               ws_dbus_client_find_word(ws_gui_app->dbus_data, 
+                                       g_strstrip(g_array_index(ws_gui_app->ws_gui_history_list,
+                                       gchar*, 
+                                               ws_gui_app->ws_gui_history_cur_pos))
+                                       );
+               
+               //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               ws_gui_app->loading = TRUE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
         }
         else 
         {
@@ -746,9 +1166,20 @@ void ws_gui_check_history(gpointer user_data)
 GtkTreeModel * create_and_fill_model (GArray *words_list, gpointer user_data)
 {
         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       g_signal_handlers_block_by_func(G_OBJECT (ws_gui_app->ws_gui_w_list->ws_gui_view),
+                                        G_CALLBACK (ws_gui_view_cursor_changed), 
+                                       ws_gui_app);    
+
         guint i = 0;
         gchar *tmp = g_strdup(g_array_index(words_list, gchar*, i));
-        gboolean valid;
+
+       if (tmp != NULL)
+       {
+               ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store, ws_gui_app);
+       }
+
+       gboolean valid;
         valid = gtk_tree_model_get_iter_first(
                         GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_store),
                         &ws_gui_app->ws_gui_w_list->ws_gui_iter);
@@ -758,26 +1189,42 @@ GtkTreeModel * create_and_fill_model (GArray *words_list, gpointer user_data)
         {
                 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,
+                              &ws_gui_app->ws_gui_w_list->ws_gui_iter, 
+                             COL_WORD, tmp,
                               -1);
                 i=i+1;
+               g_free(tmp);
+               tmp = NULL;
                 tmp = g_strdup(g_array_index(words_list, gchar*, i));
         };
 
-        tmp = g_strdup(g_array_index(words_list, gchar*, 0));
+       g_free(tmp);
+       tmp = NULL;
+       tmp = g_strdup(g_array_index(words_list, gchar*, 0));
+
+               
+       if (ws_gui_app->history_flag == FALSE && tmp != NULL)
+       {
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               ws_dbus_client_find_translation(ws_gui_app->dbus_data, tmp);
+               ws_gui_history_add(tmp, ws_gui_app);
 
-       if (tmp != NULL)
-        {
-                ws_dbus_client_find_translation(ws_gui_app->dbus_data, tmp);
-                ws_gui_history_add(tmp, ws_gui_app);
                g_free(ws_gui_app->last_word);
-               ws_gui_app->last_word=NULL;
+               ws_gui_app->last_word = NULL;
                ws_gui_app->last_word = g_strdup (tmp);
-        }
+               ws_gui_app->history_flag = FALSE;
+       }
+
+       g_signal_handlers_unblock_by_func(G_OBJECT(
+                                       ws_gui_app->ws_gui_w_list->ws_gui_view),
+                                        G_CALLBACK (ws_gui_view_cursor_changed), 
+                                       ws_gui_app);
 
+       g_free(tmp);
         return GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_store);
+       
 }
 
 /** create TreeView and TreeModel using create_and_fill_model() function;
@@ -809,48 +1256,11 @@ GtkWidget * create_view_and_model (GArray *words_list, gpointer user_data)
         gtk_tree_view_set_model(
                          GTK_TREE_VIEW (ws_gui_app->ws_gui_w_list->ws_gui_view),
                          ws_gui_app->ws_gui_w_list->ws_gui_model);
-
-        g_object_unref (ws_gui_app->ws_gui_w_list->ws_gui_model);
+       g_object_unref (ws_gui_app->ws_gui_w_list->ws_gui_model);
+       
         return ws_gui_app->ws_gui_w_list->ws_gui_view;
 }
 
-/** handle signal from words list, get selected word and calls 
-'find translation' function
- *
- * @param selection - the object which received the signal
- * @param user_data - user data set when the signal handler was connected
- * @return 
- */
-void ws_gui_tree_selection_changed(GtkTreeSelection *selection,
-                                   gpointer user_data)
-{
-        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
-        gchar *string;
-
-        if (gtk_tree_selection_get_selected(selection,
-                                       &ws_gui_app->ws_gui_w_list->ws_gui_model,
-                                       &ws_gui_app->ws_gui_w_list->ws_gui_iter))
-        {
-                gtk_tree_model_get(ws_gui_app->ws_gui_w_list->ws_gui_model,
-                                   &ws_gui_app->ws_gui_w_list->ws_gui_iter,
-                                   COL_WORD,
-                                   &string,
-                                   -1);
-
-               ws_dbus_client_find_translation(ws_gui_app->dbus_data, string);
-               
-               g_free(ws_gui_app->last_word);
-               ws_gui_app->last_word = NULL;
-               ws_gui_app->last_word = g_strdup (string);
-               
-               if (string != NULL)
-               {
-                       ws_gui_history_add(string, ws_gui_app);
-               }
-                g_free (string);
-        }
-}
-
 /** switch application between fun screen and normal mode
  *
  * @param menuitem - object which recived the signal
@@ -869,6 +1279,8 @@ void ws_gui_full_screen(GtkMenuItem *menuitem, gpointer user_data)
                               ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen),
                               TRUE);
                 ws_gui_app->ws_gui_full_screen_flag = TRUE;
+               gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                 _("ws_ib_fullscreen_on"));
         }
         else 
         {
@@ -878,6 +1290,8 @@ void ws_gui_full_screen(GtkMenuItem *menuitem, gpointer user_data)
                               ws_gui_app->ws_gui_menu->ws_gui_menu_full_screen),
                               FALSE);
                 ws_gui_app->ws_gui_full_screen_flag = FALSE;
+               gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                 _("ws_ib_fullscreen_off"));
         }
 }
 
@@ -897,6 +1311,7 @@ void ws_gui_popup_search(GtkMenuItem *menuitem, gpointer user_data)
         temp = gtk_clipboard_wait_for_text(
                                          ws_gui_app->ws_gui_clipboard_primary);
 
+       g_strstrip(temp);
         if (temp != NULL || strcmp(temp, " "))
         {
                 g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
@@ -904,7 +1319,8 @@ void ws_gui_popup_search(GtkMenuItem *menuitem, gpointer user_data)
                                       temp,
                                       NULL);
                 ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
-        }
+               //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+       }
         else
         {
                 hildon_banner_show_information(
@@ -935,7 +1351,9 @@ void ws_gui_html_select_all(GtkMenuItem *menuitem, gpointer user_data)
 void ws_gui_html_copy(GtkMenuItem *menuitem, gpointer user_data) 
 {
         WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
-        gtk_html_copy(GTK_HTML(ws_gui_app->ws_gui_html));
+       gtk_html_copy(GTK_HTML(ws_gui_app->ws_gui_html));
+       gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                 _("ws_ib_copied"));
 }
 
 /** paste copied text into toolbar entry
@@ -961,6 +1379,8 @@ void ws_gui_html_paste(GtkMenuItem *menuitem, gpointer user_data)
                      "prefix",
                      temp,
                      NULL);
+       gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                                 _("ws_ib_pasted"));
 }
 
 /** zoom in text in translation (html) area
@@ -972,7 +1392,32 @@ void ws_gui_html_paste(GtkMenuItem *menuitem, gpointer user_data)
 void ws_gui_html_zoom_in(GtkMenuItem *menuitem, gpointer user_data)
 {
         WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
-        gtk_html_zoom_in(GTK_HTML(ws_gui_app->ws_gui_html));
+       ws_gui_app->zoom = ws_gui_app->zoom + ZOOM_STEP;
+       if (ws_gui_app->zoom > ZOOM_MAX)
+       {
+               ws_gui_app->zoom = ws_gui_app->zoom - ZOOM_STEP;
+               gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ib_max_zoom"));
+       }
+       else
+       {
+               gtk_html_set_magnification(GTK_HTML(ws_gui_app->ws_gui_html), 
+                                               ws_gui_app->zoom);
+
+               if ((WS_GUI_ABS(ws_gui_app->zoom - ZOOM_DEFAULT)) < 0.000001)
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                       _("ws_ib_zoom_default"));
+               }
+               else
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                       _("ws_ib_zoom_in"));
+               }
+       }
 }
 
 /** zoom out text in translation (html) area
@@ -983,8 +1428,33 @@ void ws_gui_html_zoom_in(GtkMenuItem *menuitem, gpointer user_data)
  */
 void ws_gui_html_zoom_out(GtkMenuItem *menuitem, gpointer user_data)
 {
-        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
-        gtk_html_zoom_out(GTK_HTML(ws_gui_app->ws_gui_html));
+       WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+        ws_gui_app->zoom = ws_gui_app->zoom - ZOOM_STEP;
+       if (ws_gui_app->zoom < ZOOM_MIN)
+       {
+               ws_gui_app->zoom = ws_gui_app->zoom + ZOOM_STEP;
+               gtk_infoprint(GTK_WINDOW(
+                                      ws_gui_app->ws_gui_hildon_window),
+                                      _("ws_ib_min_zoom"));
+       }
+       else
+       {
+               gtk_html_set_magnification(GTK_HTML(ws_gui_app->ws_gui_html), 
+                                               ws_gui_app->zoom);
+               
+               if ((WS_GUI_ABS(ws_gui_app->zoom - ZOOM_DEFAULT)) < 0.000001)
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                       _("ws_ib_zoom_default"));
+               }
+               else
+               {
+                       gtk_infoprint(GTK_WINDOW(
+                                       ws_gui_app->ws_gui_hildon_window),
+                                       _("ws_ib_zoom_out"));
+               }
+       }
 }
 
 /** start searching, send typed word to DBUS and query for words
@@ -996,38 +1466,51 @@ void ws_gui_html_zoom_out(GtkMenuItem *menuitem, gpointer user_data)
 void ws_gui_search(GtkWidget * widget, gpointer user_data) 
 {
         WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
-        gchar* ws_gui_text = NULL;
-
-        if (ws_gui_app->ws_gui_banner_flag == TRUE) {
-                ws_gui_app->ws_gui_banner_flag = FALSE;
-        }
+       
+       ws_gui_app->stop_clicked = FALSE;
 
+       // if (ws_gui_app->ws_gui_banner_flag == FALSE) 
+       //{
+       gchar* ws_gui_text = NULL;
         g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
                      "prefix",
                      &ws_gui_text,
                      NULL);
 
-       if (strlen(ws_gui_text) != 0) 
-       {
-                /*ws_gui_app->ws_gui_banner = 
-                        hildon_banner_show_animation(
-                                   GTK_WIDGET(ws_gui_app->ws_gui_hildon_window),
-                                   NULL,
-                                   _("ws_ab_searching"));
-               */
-               gtk_widget_show(ws_gui_app->ws_gui_banner);
+       if (ws_gui_app->bookmark_mode == FALSE) 
+       {
+               if (ws_gui_app->first_run == TRUE)
+               {
+                       ws_gui_app->first_run = FALSE;
+               }
 
-                gtk_widget_set_sensitive(
-                              GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_stop),
-                              TRUE);
-                gtk_widget_set_sensitive(
-                          GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_stop),
-                          TRUE);
+               g_free(ws_gui_app->last_searched);
+               ws_gui_app->last_searched = NULL;
+               ws_gui_app->last_searched = g_strdup(ws_gui_text);
+       }
+       else
+       {
+               g_free(ws_gui_app->last_searched_in_book);
+               ws_gui_app->last_searched_in_book = NULL;
+               ws_gui_app->last_searched_in_book = g_strdup(ws_gui_text);
+       }
+       
+       g_strstrip(ws_gui_text);
+               if (strlen(ws_gui_text) != 0) 
+               {
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_list_searching);
+               
+                ws_gui_app->loading = TRUE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
 
-                ws_gui_app->ws_gui_banner_flag = TRUE;
-                ws_gui_fill_html(" ", ws_gui_app);
+               //ws_gui_app->ws_gui_banner_flag = TRUE;
+                //ws_gui_fill_html(" ", ws_gui_app);
+               //ws_gui_app->html_flag = FALSE;
                 ws_dbus_client_find_word (ws_gui_app->dbus_data, ws_gui_text);
-       }
+               //gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_list_hbox));
+               
+               g_free(ws_gui_text);
+               }
                else 
                {
                 gtk_infoprint(
@@ -1036,6 +1519,7 @@ void ws_gui_search(GtkWidget * widget, gpointer user_data)
         }
        g_free(ws_gui_app->last_word);
        ws_gui_app->last_word=NULL;
+       //}
 }
 
 /** stop search process
@@ -1047,13 +1531,19 @@ void ws_gui_search(GtkWidget * widget, gpointer user_data)
 void ws_gui_search_stop(GtkButton *button, gpointer user_data) 
 {
         WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
-        if (ws_gui_app->ws_gui_banner_flag == TRUE) 
+       ws_gui_app->stop_clicked = TRUE;
+       // if (ws_gui_app->ws_gui_banner_flag == TRUE || ws_gui_app->loading == TRUE) 
+       if (ws_gui_app->loading == TRUE) 
         {
-                gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner));
-                ws_gui_app->ws_gui_banner_flag = FALSE;
+                //gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
+
+               ws_gui_app->loading = FALSE;
+               ws_gui_set_toolbar_avail(ws_gui_app);           
+
+               //ws_gui_app->ws_gui_banner_flag = FALSE;
+               
                 ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_STOP_SEARCH);
-                gtk_infoprint(
-                              GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
+                gtk_infoprint(GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
                               _("ws_ni_search_aborted"));
         }
 }
@@ -1069,7 +1559,7 @@ it sends signal to DBUS and destroys it;
 void ws_gui_on_exit (GtkWidget *widget, GdkEvent *event, gpointer user_data) 
 {
         WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
-       //ws_gui_app->bookmark_mode = FALSE;
+       ws_gui_app->bookmark_mode = FALSE;
        ws_gui_set_bookmarks_sensitivity(ws_gui_app);
        g_timer_destroy(ws_gui_app->timer);
         ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_TERMINATE);
@@ -1089,7 +1579,7 @@ from application menu; it sends signal to DBUS and destroys it;
 void ws_gui_menu_quit(GtkMenuItem *menuitem, gpointer user_data)
 {
         WSGuiApp* ws_gui_app = (WSGuiApp *)user_data;
-       //ws_gui_app->bookmark_mode = FALSE;
+       ws_gui_app->bookmark_mode = FALSE;
        ws_gui_set_bookmarks_sensitivity(ws_gui_app);
         g_timer_destroy(ws_gui_app->timer);
         ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_TERMINATE);
@@ -1107,12 +1597,25 @@ void ws_gui_menu_quit(GtkMenuItem *menuitem, gpointer user_data)
  */
 void ws_gui_fill_html(char *html_context, gpointer user_data) 
 {
-        WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
-        gtk_html_set_editable (GTK_HTML(ws_gui_app->ws_gui_html), FALSE);
-
+       WSGuiApp* ws_gui_app = (WSGuiApp*)user_data;
+       
+       gtk_html_set_editable (GTK_HTML(ws_gui_app->ws_gui_html), FALSE);
+       if (ws_gui_app->first_run == TRUE && ws_gui_app->bookmark_mode==FALSE)
+       {
+       gtk_html_load_from_string(GTK_HTML(ws_gui_app->ws_gui_html),
+                                  ws_gui_app->welcome_note,
+                                  -1);
+       g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                     "prefix",
+                                      "",
+                                      NULL);
+       }
+       else
+       {
         gtk_html_load_from_string(GTK_HTML(ws_gui_app->ws_gui_html),
                                   html_context,
                                   -1);
+       }
 }
 
 /** read adjustment of left scrollwindow, which is necessary to navigate with 
@@ -1125,7 +1628,7 @@ void ws_gui_read_adjustment(gpointer user_data)
 {
         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
 
-        ws_gui_app->ws_gui_hadj = 
+       ws_gui_app->ws_gui_hadj = 
                 gtk_scrolled_window_get_hadjustment(
                 GTK_SCROLLED_WINDOW(
                ws_gui_app->ws_gui_scrolledwindow_left));
@@ -1198,7 +1701,7 @@ gboolean ws_gui_button_press(GtkWidget *widget,
                              GdkEventButton *event,
                              gpointer user_data)
 {
-        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
         if (ws_gui_app->ws_gui_sel_flag == FALSE)
         {
                 if (event->type == GDK_2BUTTON_PRESS) 
@@ -1267,7 +1770,7 @@ guint ws_gui_show_popup (gpointer user_data)
 {
         WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
         gdouble tmp = g_timer_elapsed(ws_gui_app->timer, NULL);
-        if (tmp > PRESS_TIME)
+       if (tmp > PRESS_TIME)
         {
                 ws_gui_create_popup_menu(ws_gui_app);
         }
@@ -1296,6 +1799,35 @@ void ws_gui_check_clipboard (GtkWidget *widget, gpointer user_data)
                          GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_paste),
                          FALSE);
         }
+
+       struct _GtkHTML *tmp = (struct _GtkHTML *)(ws_gui_app->ws_gui_html);
+
+       if (html_engine_is_selection_active(tmp->engine) == TRUE)
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_menu_copy),
+                               TRUE);
+       }
+       else 
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                               (ws_gui_app->ws_gui_menu->ws_gui_menu_copy),
+                               FALSE);
+       }
+
+       if (ws_gui_app->html_flag == FALSE)
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_menu_select_all),
+                       FALSE);
+       }
+       else
+       {
+               gtk_widget_set_sensitive(GTK_WIDGET
+                       (ws_gui_app->ws_gui_menu->ws_gui_menu_select_all),
+                       TRUE);
+       }       
+
 }
 
 /** gets received string (with translation), formats it and sends it to be 
@@ -1314,6 +1846,7 @@ gchar * format_html (gchar * received_string, gpointer user_data)
        str_tmp = g_string_new(received_string);
         gchar * tmp;
        gchar * tmp2;
+       gchar * returned_value;
        
        ws_gui_app->raw_translation=g_string_erase(ws_gui_app->raw_translation, 
                                                   0, 
@@ -1322,23 +1855,25 @@ gchar * format_html (gchar * received_string, gpointer user_data)
         while (strstr(str_final->str, "<PATTERN_OPEN>") != NULL)
         {
                 tmp = strstr(str_final->str, "<PATTERN_OPEN>");
-               
                 str_final =  g_string_erase(str_final,
                                            (long)(tmp - str_final->str),
                                            14);
                 str_final =  g_string_insert(str_final,
                  (long)(tmp - str_final->str),
-                 "<html><head></head><body><center><table width=\"400px\"><tr>"
+                 "<html><head></head><body><center><table width=\"95%\"><tr>"
                 "<td><table border=1 width=100%><tr>"
                 "<th background=\"file:/usr/share/pixmaps/ws_top.png\">"
                 "<img align=left src=\"file:/usr/share/pixmaps/"
                 "engine_xdxf_icon.png\"><font color=\"#eeeeee\">");
-
+               
                tmp2 = strstr(str_tmp->str, "<PATTERN_OPEN>");
-               str_tmp =  g_string_erase(str_tmp,
+               if (ws_gui_app->last_word != NULL)
+               {
+                       str_tmp =  g_string_erase(str_tmp,
                                            (long)(tmp2 - str_tmp->str),
-                                           14);
-        }
+                                           14 + strlen(ws_gui_app->last_word));
+               }
+       }
 
         while (strstr(str_final->str, "<PATTERN_CLOSED>") != NULL)
         {
@@ -1352,8 +1887,8 @@ gchar * format_html (gchar * received_string, gpointer user_data)
 
                tmp2 = strstr(str_tmp->str, "<PATTERN_CLOSED>");
                str_tmp =  g_string_erase(str_tmp,
-                                           (long)(tmp2 - str_tmp->str),
-                                           16);
+                                          (long)(tmp2 - str_tmp->str),
+                                          16);
         }
 
         while (strstr(str_final->str, "<TRANSLATION_OPEN>") != NULL)
@@ -1371,11 +1906,7 @@ gchar * format_html (gchar * received_string, gpointer user_data)
                str_tmp =  g_string_erase(str_tmp,
                                            (long)(tmp2 - str_tmp->str),
                                            18);
-               /*str_tmp =  g_string_insert(str_tmp,
-                                             (long)(tmp2 - str_tmp->str),
-                                             "<p/>");
-               */
-        }
+       }
 
         while (strstr(str_final->str, "<TRANSLATION_CLOSED>") != NULL)
         {
@@ -1385,31 +1916,26 @@ gchar * format_html (gchar * received_string, gpointer user_data)
                                             20);
                 str_final =  g_string_insert(str_final,
                                              (long)(tmp - str_final->str),
-                                             "</td></tr></table></center><br>");
+                                             "</td></tr></table></center>");
 
                tmp2 = strstr(str_tmp->str, "<TRANSLATION_CLOSED>");
                str_tmp =  g_string_erase(str_tmp,
                                           (long)(tmp2 - str_tmp->str),
                                          20);
-               
-        }
+       }
 
         str_final = g_string_append(str_final,
                                     "</td></tr></table></body></html>");
 
-       //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. Zawartosc stringa to: \"%s\"", str_tmp->str);
-       
        ws_gui_app->raw_translation = g_string_insert(
                                                ws_gui_app->raw_translation,
                                                0,
                                                str_tmp->str);
        
-       //ws_gui_app->raw_translation = g_string_append(str_final, "<br>");
-
-
-       //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, ".::GUI::. Zawartosc RAW to: \"%s\"", ws_gui_app->raw_translation->str);
-
-        return str_final->str;
+       returned_value = g_strdup(str_final->str);
+       g_string_free(str_final, TRUE);
+       g_string_free(str_tmp, TRUE);
+       return returned_value;
 }
 
 /** open bookmarks database 
@@ -1424,15 +1950,33 @@ void ws_gui_dictionary_open_bookmark(GtkMenuItem *menuitem, gpointer user_data)
 
        ws_gui_read_active_dictionaries(ws_gui_app);
        
+       /*list has to be cleared if we're gonna use a completely different dict*/
+       ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store, ws_gui_app);
        g_free(ws_gui_app->last_word);
        ws_gui_app->last_word = NULL;
 
        ws_gui_app->bookmark_mode = TRUE;
        ws_gui_set_bookmarks_sensitivity(ws_gui_app);
-       ws_gui_fill_html(" ", ws_gui_app);
-       ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_CONFIG_CHANGED);
+       g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                     "prefix",
+                                      "*",
+                                      NULL);
+       ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_BOOKMARK_MODE_ON);
        
+       if(ws_gui_app->ws_gui_history->len >= 0)
+       {
+       ws_gui_clear_array(ws_gui_app->ws_gui_history);
+       ws_gui_clear_array(ws_gui_app->ws_gui_history_list);
+       ws_gui_clear_array(ws_gui_app->ws_gui_history_iter);
+       ws_gui_app->ws_gui_history_cur_pos = -1;
+       }
+       ws_gui_check_history(ws_gui_app);
+       ws_gui_fill_html(" ", ws_gui_app);
+       ws_gui_app->html_flag = FALSE;
+       ws_dbus_client_find_word(ws_gui_app->dbus_data, "*");
+       gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
        
+       ws_gui_search(NULL, ws_gui_app);
 }
 
 /** closes bookmarks database 
@@ -1451,16 +1995,50 @@ void ws_gui_dictionary_close_bookmark(GtkMenuItem *menuitem, gpointer user_data)
        ws_gui_app->last_word = NULL;
 
         ws_gui_app->bookmark_mode = FALSE;
-       ws_gui_set_bookmarks_sensitivity(ws_gui_app);
-       ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_INFO_CONFIG_CHANGED);
-       
-       /*gchar *temp;
+       ws_gui_set_bookmarks_sensitivity(ws_gui_app);   
+       ws_dbus_notify(ws_gui_app->dbus_data, WS_DBUS_BOOKMARK_MODE_OFF);
+
+       if(ws_gui_app->ws_gui_history->len >= 0)
+       {
+       ws_gui_clear_array(ws_gui_app->ws_gui_history);
+       ws_gui_clear_array(ws_gui_app->ws_gui_history_list);
+       ws_gui_clear_array(ws_gui_app->ws_gui_history_iter);
+       ws_gui_app->ws_gui_history_cur_pos = -1;
+       }
+       ws_gui_check_history(ws_gui_app);
+
+       ws_gui_fill_html(" ", ws_gui_app);
+       ws_gui_app->html_flag = TRUE;
+       //g_strstrip(ws_gui_app->last_searched);
+       if (g_strstrip(ws_gui_app->last_searched) != NULL && ws_gui_app->first_run == FALSE) 
+       {
        g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
-                                      "prefix",
-                                      temp,
+                                     "prefix",
+                                      ws_gui_app->last_searched,
+                                      NULL);
+       //ws_dbus_client_find_word(ws_gui_app->dbus_data, ws_gui_app->last_searched);
+       ws_gui_search(NULL, ws_gui_app);
+       }
+       else
+       {
+               gtk_list_store_clear(ws_gui_app->ws_gui_w_list->ws_gui_store);
+       }
+/*     else if (ws_gui_app->first_run == FALSE) 
+       {
+               g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                                    "prefix",
+                                      "\0",
                                       NULL);
-        ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
-       */
+               GArray *tmp;
+                tmp = g_array_new(TRUE, TRUE, sizeof(gchar*));
+                gtk_list_store_clear(ws_gui_app->ws_gui_w_list->ws_gui_store);
+                ws_gui_app->ws_gui_w_list->ws_gui_model = 
+                                       create_and_fill_model(tmp, ws_gui_app);
+               
+               ws_dbus_client_find_word(ws_gui_app->dbus_data, ws_gui_app->last_searched);
+               gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+               ws_gui_search(NULL, ws_gui_app);        
+       }*/
 }
 
 /** adds bookmark to bookmarks database 
@@ -1472,25 +2050,17 @@ void ws_gui_dictionary_close_bookmark(GtkMenuItem *menuitem, gpointer user_data)
 void ws_gui_dictionary_add_bookmark(GtkMenuItem *menuitem, gpointer user_data)
 {
        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
-       
-       /*g_log(G_LOG_DOMAIN, 
-              G_LOG_LEVEL_INFO, 
-              ".::GUI::. LAST_WORD: \"%s\"", 
-             ws_gui_app->last_word);*/
 
        if (ws_gui_app->last_word != NULL)
        {
-               //ws_gui_set_bookmarks_sensitivity(ws_gui_app);
                ws_gui_add_bookmark_dialog(ws_gui_app);
-       }
+       } 
        else
        {
                gtk_infoprint(
                               GTK_WINDOW(ws_gui_app->ws_gui_hildon_window),
                               _("ws_ni_select_word_to_add"));
        }
-       
-       
 }
 
 /** removes bookmark from bookmarks database 
@@ -1503,23 +2073,19 @@ void ws_gui_dictionary_remove_bookmark(GtkMenuItem *menuitem,
                                       gpointer user_data)
 {
        WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
-       
-       g_log(G_LOG_DOMAIN, 
-             G_LOG_LEVEL_INFO, 
-             ".::GUI::. LAST_WORD: \"%s\"", 
-             ws_gui_app->last_word);
 
                if (ws_gui_app->last_word != NULL)
        {
-               //ws_gui_set_bookmarks_sensitivity(ws_gui_app);
                ws_gui_remove_bookmark_dialog(ws_gui_app);
 
+               ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store, ws_gui_app);
                gchar *temp;
                g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
                                       "prefix",
                                       &temp,
                                       NULL);
                ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
+               //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
                
        }
        else
@@ -1592,7 +2158,6 @@ void ws_gui_set_bookmarks_sensitivity(gpointer user_data)
        int i;
        gchar *string;
        gchar *name;
-       //static gchar *bookmarks_path = g_strconcat(GCONF_PATH, "/bookmarks/active", NULL);
 
        if (ws_gui_app->bookmark_mode == TRUE)
        {
@@ -1605,10 +2170,7 @@ void ws_gui_set_bookmarks_sensitivity(gpointer user_data)
                ws_gui_app->directories = gconf_client_all_dirs(
                                                        ws_gui_app->client, 
                                                        GCONF_PATH, NULL);
-       
-               //ws_gui_app->directories_last = 
-               //                        g_slist_copy(ws_gui_app->directories);
-       
+               
        for (i=0; i<g_slist_length(ws_gui_app->directories); i++)
         {
                string = (gchar*)g_slist_nth_data(ws_gui_app->directories, i);
@@ -1617,7 +2179,9 @@ void ws_gui_set_bookmarks_sensitivity(gpointer user_data)
                
                if (gconf_client_get_bool(ws_gui_app->client, string, NULL) == TRUE) 
                {
-                       ws_gui_app->directories_last = g_slist_append(ws_gui_app->directories_last, string);
+                       ws_gui_app->directories_last = 
+                               g_slist_append(ws_gui_app->directories_last, 
+                                              string);
                }
 
                if (strcmp(name, "bookmarks") == 0)
@@ -1665,13 +2229,14 @@ void ws_gui_set_bookmarks_sensitivity(gpointer user_data)
         {
                string = (gchar*)g_slist_nth_data(ws_gui_app->directories_last, 
                                                  i);
-
-               //string = g_strconcat(string, "/active", NULL);
-
+               
+               if (string != NULL)
+               {
                gconf_client_set_bool(ws_gui_app->client, 
                                string, 
                                TRUE, 
                                NULL);
+               }
        }
 
        //setting sensitivity of components
@@ -1690,7 +2255,10 @@ void ws_gui_set_bookmarks_sensitivity(gpointer user_data)
        gtk_widget_set_sensitive(
                GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_dictionaries),
                 TRUE);
+
+       g_free(bookmarks_path);
        }
+
 }
 
 /** sets sensitivity of menu items due to user selection made
@@ -1714,7 +2282,9 @@ void ws_gui_set_bookmark_menu_items(GtkMenuItem *menuitem, gpointer user_data)
                FALSE);
        }
 
-       if (ws_gui_app->last_word == NULL || ws_gui_app->bookmark_mode == TRUE)
+       if (ws_gui_app->last_word == NULL || 
+           (ws_gui_app->last_word[0] == '\0') ||
+           ws_gui_app->bookmark_mode == TRUE)
        {
               gtk_widget_set_sensitive(
               GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_add_bookmark),
@@ -1742,3 +2312,96 @@ void ws_gui_read_active_dictionaries(gpointer user_data)
                                              GCONF_PATH,
                                              NULL);
 }
+
+void ws_gui_clear_array(GArray *history)
+{
+       if(history->len >= 0)
+       {
+               history = g_array_remove_range(history, 0, history->len);
+       }
+}
+
+void ws_gui_view_cursor_changed(GtkTreeView *treeview, gpointer user_data)
+{
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       gchar *string;
+       if (gtk_tree_selection_get_selected(ws_gui_app->ws_gui_w_list->ws_gui_selection,
+                                       &ws_gui_app->ws_gui_w_list->ws_gui_model,
+                                       &ws_gui_app->ws_gui_w_list->ws_gui_iter))
+       {
+       gtk_tree_model_get(ws_gui_app->ws_gui_w_list->ws_gui_model,
+                                   &ws_gui_app->ws_gui_w_list->ws_gui_iter,
+                                   COL_WORD,
+                                   &string,
+                                  -1);
+       if (string != NULL)
+               {
+               //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
+               ws_gui_app->loading = TRUE;
+               ws_gui_set_toolbar_avail(ws_gui_app);
+
+               ws_dbus_client_find_translation(ws_gui_app->dbus_data, string);
+               
+               
+               g_free(ws_gui_app->last_word);
+               ws_gui_app->last_word = NULL;
+               ws_gui_app->last_word = g_strdup (string);
+
+               if (ws_gui_app->history_flag == FALSE)
+               {
+                      ws_gui_history_add(string, ws_gui_app);
+               
+               }
+                g_free (string);
+               }
+               
+       }
+       
+       
+}
+
+void ws_gui_set_toolbar_avail(gpointer user_data) {
+       
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+       
+       if (ws_gui_app->loading == TRUE)
+       {
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_stop),
+                       TRUE);
+       
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                       FALSE);
+
+       }
+       else 
+       {
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_stop),
+                       FALSE);
+       
+               gtk_widget_set_sensitive(
+                       GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_search),
+                       TRUE);
+       }
+}
+
+void ws_refresh_search_results(gpointer user_data) {
+       
+       WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
+
+       //refreshing the words list and translation pane
+       gchar *temp;
+       g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
+                               "prefix",
+                               &temp,
+                               NULL);
+       
+       if (ws_gui_app->first_run == FALSE)
+       {
+               ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
+       }
+       //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
+       //-----------------------------------------------
+}