Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv14625/src

Modified Files:
        prefs.c prefs.h prefs_window.c 
Log Message:

Moved sort_ign_fields to new prefs. Also got rid of sortcfg.


Index: prefs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.c,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -d -r1.245 -r1.246
--- prefs.c     14 Jun 2006 23:26:31 -0000      1.245
+++ prefs.c     15 Jun 2006 03:07:30 -0000      1.246
@@ -2286,14 +2286,6 @@
     }
 }
 
-void sortcfg_free(struct sortcfg *c)
-{
-    g_return_if_fail (c);
-    g_list_free (c->tmp_sort_ign_fields);
-    g_free (c);
-}
-
-
 void prefs_set_offline(gboolean active)
 {
   if (cfg->offline != active)   space_data_update ();
@@ -2386,19 +2378,6 @@
     return(result);
 }
 
-struct sortcfg *clone_sortprefs(void)
-{
-    struct sortcfg *result = NULL;
-
-    if(cfg)
-    {
-       result = g_memdup (&cfg->sortcfg, sizeof (struct sortcfg));
-    }
-    /* GLists are not copied */
-    result->tmp_sort_ign_fields = NULL;
-    return(result);
-}
-
 /* Returns "$HOME/.gtkpod" and tries to create it if it does not
    exist. */
 gchar *prefs_get_cfgdir (void)

Index: prefs.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.h,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -d -r1.173 -r1.174
--- prefs.h     14 Jun 2006 23:26:31 -0000      1.173
+++ prefs.h     15 Jun 2006 03:07:30 -0000      1.174
@@ -66,12 +66,8 @@
   gboolean md5tracks;      /* don't allow track duplication on your ipod */
   gboolean block_display;   /* block display during change of selection? */
   
-  struct sortcfg
-  {         /* sort type: SORT_ASCENDING, SORT_DESCENDING, SORT_NONE */
-    GList *tmp_sort_ign_fields; /* used in prefs_window.c only     */
-  } sortcfg;
+  
   gboolean offline;       /* are we working offline, i.e. without iPod? */
-
   gboolean display_toolbar;     /* should toolbar be displayed */
   GtkToolbarStyle toolbar_style;/* style of toolbar */
   gboolean display_tooltips_main; /* should tooltips be displayed (main) */
@@ -83,7 +79,7 @@
 };
 
 
-/* types for sortcfg.xx_sort */
+/* types for sort */
 enum
 {
     SORT_ASCENDING = GTK_SORT_ASCENDING,
@@ -219,11 +215,9 @@
 gchar *prefs_get_cfgdir (void);
 void prefs_print(void);
 void cfg_free(struct cfg *c);
-void sortcfg_free(struct sortcfg *c);
 void write_prefs (void);
 void discard_prefs (void);
 struct cfg* clone_prefs(void);
-struct sortcfg* clone_sortprefs(void);
 gboolean read_prefs_old (GtkWidget *gtkpod, int argc, char *argv[]);
 
 void prefs_set_offline(gboolean active);

Index: prefs_window.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs_window.c,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -d -r1.167 -r1.168
--- prefs_window.c      14 Jun 2006 23:26:32 -0000      1.167
+++ prefs_window.c      15 Jun 2006 03:07:30 -0000      1.168
@@ -48,8 +48,6 @@
 static GtkWidget *sort_window = NULL;
 static struct cfg *tmpcfg = NULL;
 static struct cfg *origcfg = NULL;
-static struct sortcfg *tmpsortcfg = NULL;
-static struct sortcfg *origsortcfg = NULL;
 
 /* New prefs temp handling */
 static TempPrefs *temp_prefs;
@@ -1424,7 +1422,7 @@
 
 
 /* Copy the current ignore fields and ignore strings into scfg */
-static void sort_window_read_sort_ign (struct sortcfg *scfg)
+static void sort_window_read_sort_ign ()
 {
     gint i;
     GtkTextView *tv;
@@ -1433,11 +1431,6 @@
     GList *current;
     gchar *buf;
 
-    g_return_if_fail (scfg);
-
-    /* remove old list */
-    g_list_free (scfg->tmp_sort_ign_fields);
-    scfg->tmp_sort_ign_fields = NULL;
 
     /* read sort field states */
     for (i=0; sort_ign_fields[i] != -1; ++i)
@@ -1446,10 +1439,9 @@
                                      sort_ign_fields[i]);
        GtkWidget *w = gtkpod_xml_get_widget (sort_window_xml, buf);
        g_return_if_fail (w);
-       scfg->tmp_sort_ign_fields = g_list_append (
-           scfg->tmp_sort_ign_fields,
-           GUINT_TO_POINTER( gtk_toggle_button_get_active (
-               GTK_TOGGLE_BUTTON (w))));
+       prefs_set_int( buf,
+            gtk_toggle_button_get_active (
+               GTK_TOGGLE_BUTTON (w)));
        g_free (buf);
     }
     
@@ -1504,16 +1496,6 @@
        GtkTextIter ti;
        gchar *str;
 
-       if(!tmpsortcfg && !origsortcfg)
-       {
-           origsortcfg = clone_sortprefs();
-       }
-       else
-       {
-           g_warning ("Programming error: tmpsortcfg is not NULL!!\n");
-           g_return_if_reached ();
-       }
-  
        sort_temp_prefs = temp_prefs_create();
        sort_temp_lists = temp_lists_create();
 
@@ -1574,9 +1556,7 @@
        
        prefs_free_list(sort_ign_strings);
 
-       /* update the origsortcfg with the original settings (ignore
-        * fields and ignore strings) */
-       sort_window_read_sort_ign (origsortcfg);
+       sort_window_read_sort_ign ();
 
        /* Set Sort-Column-Combo */
        /* create the list in the order of the columns displayed */
@@ -1624,11 +1604,6 @@
        gchar *str;
        GtkWidget *w = NULL;
 
-       /* update or create tmpsortcfg */
-       if (tmpsortcfg)
-           sortcfg_free (tmpsortcfg);
-       tmpsortcfg = clone_sortprefs();
-
        switch (prefs_get_int("pm_sort"))
        {
        case SORT_ASCENDING:
@@ -1756,34 +1731,17 @@
 }
 
 
-/* copy newly set values from tmpsortcfg to the original cfg struct */
-static void sort_window_set (struct sortcfg *scfg)
+/* Prepare keys to be copied to prefs table */
+static void sort_window_set ()
 {
-    struct sortcfg *tsc;
-    gint i;
     gint val; /* A value from temp prefs */
     TM_item sortcol_new;
     TM_item sortcol_old;
 
-    g_return_if_fail (scfg);
-
-    tsc = clone_sortprefs ();
-
     sortcol_old = prefs_get_int("tm_sortcol");
     sortcol_new = sort_window_get_sort_col();
     prefs_set_int("tm_sortcol", sortcol_new);
 
-    /* set sort field states */
-    for (i=0; sort_ign_fields[i] != -1; ++i)
-    {
-       gchar *buf = g_strdup_printf ("sort_ign_field_%d",
-                                     sort_ign_fields[i]);
-       prefs_set_int (
-           buf,
-           GPOINTER_TO_UINT(g_list_nth_data (
-               scfg->tmp_sort_ign_fields, i)));
-       g_free (buf);
-    }
     /* update compare string keys */
     compare_string_fuzzy_generate_keys ();
 
@@ -1802,7 +1760,6 @@
     if (!temp_prefs_get_int(sort_temp_prefs, "tm_autostore"))
        tm_rows_reordered ();
 
-    sortcfg_free (tsc);
 }
 
 
@@ -1948,21 +1905,11 @@
  * sort_window_cancel
  * UI has requested sort prefs changes be ignored -- write back the
  * original values
- * Frees the tmpsortcfg and origsortcfg variable
  */
 void sort_window_cancel (void)
 {
-    g_return_if_fail (tmpsortcfg);
-    g_return_if_fail (origsortcfg);
-
     /* "save" (i.e. reset) original configs */
-    sort_window_set (origsortcfg);
-
-    /* delete cfg struct */
-    sortcfg_free (tmpsortcfg);
-    tmpsortcfg = NULL;
-    sortcfg_free (origsortcfg);
-    origsortcfg = NULL;
+    sort_window_set ();
 
     /* close the window */
     if(sort_window)
@@ -1973,20 +1920,11 @@
 /* when window is deleted, we keep the currently applied prefs */
 void sort_window_delete(void)
 {
-    g_return_if_fail (tmpsortcfg);
-    g_return_if_fail (origsortcfg);
-  
     temp_prefs_destroy(sort_temp_prefs);
     sort_temp_prefs = NULL;
     temp_lists_destroy(sort_temp_lists);
     sort_temp_lists = NULL;
 
-    /* delete sortcfg structs */
-    sortcfg_free (tmpsortcfg);
-    tmpsortcfg = NULL;
-    sortcfg_free (origsortcfg);
-    origsortcfg = NULL;
-
     /* close the window */
     if(sort_window)
        gtk_widget_destroy(sort_window);
@@ -1994,26 +1932,16 @@
 }
 
 /* apply the current settings and close the window */
-/* Frees the tmpsortcfg and origsortcfg variable */
 void sort_window_ok (void)
 {
-    g_return_if_fail (tmpsortcfg);
-    g_return_if_fail (origsortcfg);
-
     temp_prefs_apply(sort_temp_prefs);
     temp_lists_apply(sort_temp_lists);
 
     /* update the sort ignore strings */
-    sort_window_read_sort_ign (tmpsortcfg);
+    sort_window_read_sort_ign ();
     /* save current settings */
-    sort_window_set (tmpsortcfg);
+    sort_window_set ();
   
-    /* delete sortcfg structs */
-    sortcfg_free (tmpsortcfg);
-    tmpsortcfg = NULL;
-    sortcfg_free (origsortcfg);
-    origsortcfg = NULL;
-
     /* close the window */
     if(sort_window)
        gtk_widget_destroy(sort_window);
@@ -2024,16 +1952,13 @@
 /* apply the current settings, don't close the window */
 void sort_window_apply (void)
 {
-    g_return_if_fail (tmpsortcfg);
-    g_return_if_fail (origsortcfg);
-  
     temp_prefs_apply(sort_temp_prefs);
     temp_lists_apply(sort_temp_lists);
 
     /* update the sort ignore strings */
-    sort_window_read_sort_ign (tmpsortcfg);
+    sort_window_read_sort_ign ();
     /* save current settings */
-    sort_window_set (tmpsortcfg);
+    sort_window_set ();
 }
 
 void sort_window_set_tm_autostore (gboolean val)



_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to