history still need some improovements.
authorgadomska_anna <gadomska.anna@gmail.com>
Mon, 12 Feb 2007 14:48:54 +0000 (14:48 +0000)
committergadomska_anna <gadomska.anna@gmail.com>
Mon, 12 Feb 2007 14:48:54 +0000 (14:48 +0000)
git-svn-id: file:///svnroot/mdictionary/trunk@78 5bde0345-f819-0410-ac75-e5045f9217cc

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

index 1579f9a..a0ee18d 100644 (file)
@@ -241,6 +241,8 @@ void ws_gui_set_bookmark_menu_items(GtkMenuItem *menuitem, gpointer user_data);
  *
  */
 void ws_gui_read_active_dictionaries(gpointer user_data);
+
+void ws_gui_clear_array(GArray *history);
 #ifdef __cplusplus
 }
 #endif
index 2ccb695..aab0de5 100644 (file)
@@ -348,21 +348,28 @@ void ws_gui_dbus_return_words (GError *error, GArray *words, gpointer user_data)
        
        if (ws_gui_app->history_flag == TRUE)
        {
-       gtk_tree_model_get_iter_from_string
-                                            (GTK_TREE_MODEL(
-                         ws_gui_app->ws_gui_w_list->ws_gui_model),
-                                            &ws_gui_app->ws_gui_w_list->ws_gui_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(
+       if (gtk_tree_model_get_iter_from_string
+                                  (GTK_TREE_MODEL(
+                                 ws_gui_app->ws_gui_w_list->ws_gui_model),
+                                  &ws_gui_app->ws_gui_w_list->ws_gui_iter,
+                                  g_array_index(ws_gui_app->ws_gui_history_iter,
+                                 gchar*, 
+                                 ws_gui_app->ws_gui_history_cur_pos)) == TRUE);
+       {
+       
+       g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n\nString from iter: %s", 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));
+       g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "GUI-TrePath: %s\n\n", gtk_tree_path_to_string(ws_gui_app->ws_gui_w_list->path));
+
+               gtk_tree_selection_select_iter(
                                ws_gui_app->ws_gui_w_list->ws_gui_selection,
                                 &ws_gui_app->ws_gui_w_list->ws_gui_iter);
        
-       ws_gui_app->history_flag = FALSE;
-       ws_gui_fill_html(format_html(data.value.s, ws_gui_app), ws_gui_app);
-       ws_gui_app->html_flag = TRUE;
+               ws_gui_app->history_flag = FALSE;
+               ws_gui_fill_html(format_html(data.value.s, ws_gui_app), 
+                                            ws_gui_app);
+               ws_gui_app->html_flag = TRUE;
+       }
        }
        
         if (tmp->len == 0)
@@ -699,6 +706,7 @@ void ws_gui_history_add(char *new_word, gpointer user_data)
                {
                tmp_last_searched = g_strdup(ws_gui_app->last_searched_in_book);
                }
+
                g_array_append_val(ws_gui_app->ws_gui_history_list, 
                                   tmp_last_searched);
                                
@@ -724,6 +732,8 @@ void ws_gui_history_add(char *new_word, gpointer user_data)
                }
                
        }
+               
+       ws_gui_app->ws_gui_w_list->path = gtk_tree_model_get_path(GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_model), &ws_gui_app->ws_gui_w_list->ws_gui_iter);
         ws_gui_check_history(ws_gui_app);
 }
 
@@ -1672,22 +1682,11 @@ void ws_gui_dictionary_open_bookmark(GtkMenuItem *menuitem, gpointer user_data)
        
        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_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);
@@ -1718,17 +1717,9 @@ void ws_gui_dictionary_close_bookmark(GtkMenuItem *menuitem, gpointer user_data)
 
        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_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);
@@ -2027,3 +2018,11 @@ 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);
+       }
+}
index f01669b..ff33791 100644 (file)
@@ -925,11 +925,11 @@ 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)
+               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_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);
@@ -1244,6 +1244,15 @@ void ws_gui_dictionary_loader(GtkMenuItem *menuitem, gpointer user_data)
                         }
                         gtk_widget_destroy (dialog2);
 
+                       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_dbus_notify(ws_gui_app->dbus_data,
                                        WS_DBUS_INFO_CONFIG_CHANGED);
                         gtk_infoprint(GTK_WINDOW(
@@ -1386,6 +1395,15 @@ void ws_gui_dictionary_remover(GtkMenuItem *menuitem, gpointer user_data)
                         } 
                  }
 
+               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_dbus_notify(ws_gui_app->dbus_data, 
                               WS_DBUS_INFO_CONFIG_CHANGED);
                gtk_infoprint(GTK_WINDOW(