core dupmed when selecting dictionaries; I fixed it.
authorgadomska_anna <gadomska.anna@gmail.com>
Mon, 12 Feb 2007 13:05:26 +0000 (13:05 +0000)
committergadomska_anna <gadomska.anna@gmail.com>
Mon, 12 Feb 2007 13:05:26 +0000 (13:05 +0000)
git-svn-id: file:///svnroot/mdictionary/trunk@76 5bde0345-f819-0410-ac75-e5045f9217cc

src/gui/include/ws_gui.h
src/gui/src/ws_gui_callbacks.c
src/gui/src/ws_gui_layout.c

index bfe84d0..95a2313 100644 (file)
@@ -220,6 +220,7 @@ struct WSGuiAppData {
        GArray *ws_gui_history; ///< words history
        GArray *ws_gui_history_list;
        GArray *ws_gui_history_iter;
+       GArray *ws_gui_history_bookmarks;
        gboolean history_flag;
        gint ws_gui_history_cur_pos; ///< current position in words history array 
        guint history_mode;
@@ -255,6 +256,7 @@ struct WSGuiAppData {
        gchar *last_word; ///< stores last choosen word on the words list (necessary for bookmarks)
        GString *raw_translation; ///< stores current translation, if user wants to add it to bookmarks
        gchar *last_searched;
+       gchar *last_searched_in_book;
        gdouble zoom;
        gboolean html_flag;
 
index fc90055..baa6973 100644 (file)
@@ -669,6 +669,7 @@ void ws_gui_history_add(char *new_word, gpointer user_data)
                {
                        while (tmp != NULL) 
                        {
+                               //if (ws_gui_app->bookmark_mode =
                                g_array_remove_index(
                                ws_gui_app->ws_gui_history, 
                                i);
@@ -688,12 +689,23 @@ void ws_gui_history_add(char *new_word, gpointer user_data)
                i = 0;
                ws_gui_app->ws_gui_history_cur_pos ++;
        
-               tmp_word = g_strdup(new_word);
-               tmp_last_searched = g_strdup(ws_gui_app->last_searched);
                
-               g_array_append_val(ws_gui_app->ws_gui_history, tmp_word);
+               
+               if (ws_gui_app->history_flag == FALSE)
+               {
+               tmp_last_searched = g_strdup(ws_gui_app->last_searched);
                g_array_append_val(ws_gui_app->ws_gui_history_list, 
                                   tmp_last_searched);
+               }
+               else
+               {
+               tmp_last_searched = g_strdup(ws_gui_app->last_searched_in_book);
+               g_array_append_val(ws_gui_app->ws_gui_history_bookmarks, 
+                                  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);
                
        
@@ -1206,6 +1218,12 @@ void ws_gui_search(GtkWidget * widget, gpointer user_data)
                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) 
index 06ffb4b..f01669b 100644 (file)
@@ -43,6 +43,7 @@ void ws_gui_create_window(gpointer user_data)
         GArray *array_tmp = g_array_new (TRUE, TRUE, sizeof(gchar*));
        ws_gui_app->raw_translation = g_string_new(" ");
        ws_gui_app->last_searched = NULL;
+       ws_gui_app->last_searched_in_book = NULL;
 
         ws_gui_app->ws_gui_banner_flag = FALSE;
         ws_gui_app->ws_gui_full_screen_flag = FALSE;
@@ -61,6 +62,7 @@ void ws_gui_create_window(gpointer user_data)
         ws_gui_app->ws_gui_history = g_array_new(TRUE, TRUE, sizeof(gchar*));
        ws_gui_app->ws_gui_history_list = g_array_new(TRUE, TRUE, sizeof(gchar*));
        ws_gui_app->ws_gui_history_iter = g_array_new(TRUE, TRUE, sizeof(gchar*));
+       ws_gui_app->ws_gui_history_bookmarks = g_array_new(TRUE, TRUE, sizeof(gchar*));
        ws_gui_app->history_flag = FALSE;
         ws_gui_app->ws_gui_history_cur_pos = -1;
        ws_gui_app->history_mode = 0;
@@ -923,10 +925,13 @@ void ws_gui_dictionary_chooser(GtkMenuItem *menuitem, gpointer user_data)
                ws_dbus_notify(ws_gui_app->dbus_data, 
                                WS_DBUS_INFO_CONFIG_CHANGED);
 
+               if(ws_gui_app->ws_gui_history->len > 0)
+               {
                ws_gui_app->ws_gui_history = g_array_remove_range (ws_gui_app->ws_gui_history, 0, ws_gui_app->ws_gui_history->len);
                ws_gui_app->ws_gui_history_list = g_array_remove_range (ws_gui_app->ws_gui_history_list, 0, ws_gui_app->ws_gui_history_list->len);
                ws_gui_app->ws_gui_history_iter = g_array_remove_range (ws_gui_app->ws_gui_history_iter, 0, ws_gui_app->ws_gui_history_iter->len);
                ws_gui_app->ws_gui_history_cur_pos = -1;
+               }
                ws_gui_check_history(ws_gui_app);
        
                gtk_widget_destroy (dialog1);