[gq-commit] gq/src search.c,1.45,1.46 search.h,1.11,1.12
Status: Beta
                
                Brought to you by:
                
                    sur5r
                    
                
            | 
     
      
      
      From: <sta...@us...> - 2003-10-11 22:37:13
      
     
   | 
Update of /cvsroot/gqclient/gq/src
In directory sc8-pr-cvs1:/tmp/cvs-serv22347
Modified Files:
	search.c search.h 
Log Message:
* Added persistency for per-tab search history
Index: search.c
===================================================================
RCS file: /cvsroot/gqclient/gq/src/search.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** search.c	11 Oct 2003 21:35:30 -0000	1.45
--- search.c	11 Oct 2003 22:37:09 -0000	1.46
***************
*** 46,49 ****
--- 46,50 ----
  #include "i18n.h"
  #include "browse.h"
+ #include "state.h"
  #include "utf8-compat.h" 
  
***************
*** 57,60 ****
--- 58,91 ----
  
  
+ static void search_save_snapshot(char *state_name, struct tab *tab)
+ {
+      GList *hist = SEARCHTAB(tab)->history;
+      if (hist) {
+ 	  state_value_set_list(state_name, "history", hist);
+      }
+ }
+ 
+ 
+ static void search_restore_snapshot(char *state_name, struct tab *tab)
+ {
+      if (config->restore_search_history) {
+ 	  const GList *hist = state_value_get_list(state_name, "history");
+ 	  if (hist) {
+ 	       const GList *I;
+ 	       for (I = hist ; I ; I = g_list_next(I)) {
+ 		    SEARCHTAB(tab)->history =
+ 			 g_list_append(SEARCHTAB(tab)->history,
+ 				       g_strdup(I->data));
+ 	       }
+ 	       gtk_combo_set_popdown_strings(GTK_COMBO(SEARCHTAB(tab)->search_combo),
+ 					     SEARCHTAB(tab)->history);
+ 	       
+ 	  }
+      }
+ }
+ 
+ static struct tab_vtab search_vtab = { search_save_snapshot, 
+ 				       search_restore_snapshot };
+ 
  struct tab *new_searchmode()
  {
***************
*** 67,70 ****
--- 98,102 ----
       struct tab *tab = g_malloc0(sizeof(struct tab));
       tab->type = SEARCH_MODE;
+      tab->vtab = &search_vtab;
  
       modeinfo = g_malloc0(sizeof(struct tab_search));
***************
*** 76,85 ****
       gtk_box_pack_start(GTK_BOX(searchmode_vbox), hbox1, FALSE, FALSE, 3);
  
!      /* FIXME for now, init this to an empty list -- modeinfo->history needs
! 	to be initialized from the session save facility when it's available */
       searchhist = modeinfo->history;
  
       /* searchterm combo box */
!      searchcombo = gtk_combo_new();
       gtk_combo_disable_activate(GTK_COMBO(searchcombo));
       if(searchhist)
--- 108,117 ----
       gtk_box_pack_start(GTK_BOX(searchmode_vbox), hbox1, FALSE, FALSE, 3);
  
!      /* Initially the list is empty. It might be changed to the data
! 	read from the persistant storage later on*/
       searchhist = modeinfo->history;
  
       /* searchterm combo box */
!      SEARCHTAB(tab)->search_combo = searchcombo = gtk_combo_new();
       gtk_combo_disable_activate(GTK_COMBO(searchcombo));
       if(searchhist)
***************
*** 997,1002 ****
  	  gtk_widget_destroy(main_clist);
       }
- 
-      /* FIXME save history into permanent session thingie */
  
       list = SEARCHTAB(tab)->history;
--- 1029,1032 ----
Index: search.h
===================================================================
RCS file: /cvsroot/gqclient/gq/src/search.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** search.h	11 Oct 2003 21:35:30 -0000	1.11
--- search.h	11 Oct 2003 22:37:09 -0000	1.12
***************
*** 31,34 ****
--- 31,35 ----
  #define SEARCHTAB(tab) (assert(tab->type == SEARCH_MODE), (struct tab_search *)tab->modeinfo)
  struct tab_search {
+      GtkWidget *search_combo;
       GtkWidget *serverlist_combo;
       GtkWidget *searchbase_combo;
 |