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

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

Move sp_played_state, sp_modified_state, and sp_added_state to new prefs


Index: display_sorttabs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/display_sorttabs.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- display_sorttabs.c  4 Jun 2006 22:25:29 -0000       1.71
+++ display_sorttabs.c  5 Jun 2006 02:57:39 -0000       1.72
@@ -383,6 +383,7 @@
 {
     SortTab *st;
     TimeInfo *ti;
+    
 
     if (inst >= SORT_TAB_MAX) return NULL;
 
@@ -391,7 +392,21 @@
 
     if (ti)
     {
-       gchar *new_string = prefs_get_sp_entry (inst, item);
+      gchar *new_string; 
+      switch (item)
+      {
+      case T_TIME_PLAYED:
+          new_string = prefs_get_string_index("sp_played_state", inst);
+          break;
+      case T_TIME_MODIFIED:
+          new_string = prefs_get_string_index("sp_modified_state", inst);
+          break;
+      case T_TIME_ADDED:
+          new_string = prefs_get_string_index("sp_added_state", inst);;
+          break;
+      default:
+          break;
+  }
 
        if (force_update || !ti->int_str ||
            (strcmp (new_string, ti->int_str) != 0))
@@ -400,7 +415,9 @@
            ti->int_str = g_strdup (new_string);
            dp2_parse (ti);
        }
+    g_free(new_string);
     }
+    
     return ti;
 }
 
@@ -661,11 +678,11 @@
     /* Sanity */
     if (!st || (st->current_category != ST_CAT_SPECIAL)) return;
 
-    prefs_set_sp_entry (inst, T_TIME_PLAYED,
+    prefs_set_string_index("sp_played_state", inst,
                        gtk_entry_get_text (GTK_ENTRY(st->ti_played.entry)));
-    prefs_set_sp_entry (inst, T_TIME_MODIFIED,
+    prefs_set_string_index("sp_modified_state", inst,
                        gtk_entry_get_text (GTK_ENTRY(st->ti_modified.entry)));
-    prefs_set_sp_entry (inst, T_TIME_ADDED,
+    prefs_set_string_index("sp_added_state", inst,
                        gtk_entry_get_text (GTK_ENTRY(st->ti_added.entry)));
 }
 
@@ -883,7 +900,21 @@
 
 /*    printf ("sp_entry_activate inst: %d, item: %d\n", inst, item);*/
 
-    prefs_set_sp_entry (inst, item, buf);
+       switch (item)
+       {
+       case T_TIME_PLAYED:
+           prefs_set_string_index("sp_played_state", inst, buf);
+           break;
+       case T_TIME_MODIFIED:
+           prefs_set_string_index("sp_modified_state", inst, buf);
+           break;
+       case T_TIME_ADDED:
+           prefs_set_string_index("sp_added_state", inst, buf);
+           break;
+       default:
+           break;
+  }
+  
     g_free (buf);
     sp_update_date_interval_from_string (inst, item, TRUE);
 /*     if (prefs_get_sp_autodisplay (inst))  sp_go (inst); */
@@ -2708,6 +2739,7 @@
       SortTab   *st = sorttab[inst];
       gint i;
       GladeXML *special_xml;
+      gchar *buf;
 
       special_xml = glade_xml_new (xml_file, "special_sorttab", NULL);
       special = gtkpod_xml_get_widget (special_xml, "special_sorttab");
@@ -2778,6 +2810,8 @@
                                 prefs_get_sp_playcount_high (inst));
 
       /* PLAYED */
+      buf = prefs_get_string_index("sp_played_state", inst);
+      
       w = gtkpod_xml_get_widget (special_xml, "sp_played_button");
       st->ti_played.active = w;
       g_signal_connect ((gpointer)w,
@@ -2788,7 +2822,7 @@
       w = gtkpod_xml_get_widget (special_xml, "sp_played_entry");
       st->ti_played.entry = w;
       gtk_entry_set_text (GTK_ENTRY (w),
-                         prefs_get_sp_entry (inst, T_TIME_PLAYED));
+                         buf);
       g_signal_connect ((gpointer)w,
                        "activate", G_CALLBACK (on_sp_entry_activate),
                        GUINT_TO_POINTER((T_TIME_PLAYED<<SP_SHIFT) + inst));
@@ -2797,8 +2831,12 @@
                        "clicked",
                        G_CALLBACK (on_sp_cal_button_clicked),
                        GUINT_TO_POINTER((T_TIME_PLAYED<<SP_SHIFT) + inst));
+      
+      g_free(buf);
 
       /* MODIFIED */
+      buf = prefs_get_string_index("sp_modified_state", inst);
+      
       w = gtkpod_xml_get_widget (special_xml, "sp_modified_button");
       st->ti_modified.active = w;
       g_signal_connect ((gpointer)w,
@@ -2809,7 +2847,7 @@
       w = gtkpod_xml_get_widget (special_xml, "sp_modified_entry");
       st->ti_modified.entry = w;
       gtk_entry_set_text (GTK_ENTRY (w),
-                         prefs_get_sp_entry (inst, T_TIME_MODIFIED));
+                         buf);
       g_signal_connect ((gpointer)w,
                        "activate", G_CALLBACK (on_sp_entry_activate),
                        GUINT_TO_POINTER((T_TIME_MODIFIED<<SP_SHIFT) + inst));
@@ -2818,8 +2856,12 @@
                        "clicked",
                        G_CALLBACK (on_sp_cal_button_clicked),
                        GUINT_TO_POINTER((T_TIME_MODIFIED<<SP_SHIFT) + inst));
+      
+      g_free(buf);
 
       /* ADDED */
+      buf = prefs_get_string_index("sp_added_state", inst);
+      
       w = gtkpod_xml_get_widget (special_xml, "sp_added_button");
       st->ti_added.active = w;
       g_signal_connect ((gpointer)w,
@@ -2830,7 +2872,7 @@
       w = gtkpod_xml_get_widget (special_xml, "sp_added_entry");
       st->ti_added.entry = w;
       gtk_entry_set_text (GTK_ENTRY (w),
-                         prefs_get_sp_entry (inst, T_TIME_ADDED));
+                         buf);
       g_signal_connect ((gpointer)w,
                        "activate", G_CALLBACK (on_sp_entry_activate),
                        GUINT_TO_POINTER((T_TIME_ADDED<<SP_SHIFT) + inst));

Index: prefs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.c,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -d -r1.196 -r1.197
--- prefs.c     4 Jun 2006 22:25:29 -0000       1.196
+++ prefs.c     5 Jun 2006 02:57:39 -0000       1.197
@@ -162,6 +162,9 @@
       prefs_set_int_index("sp_modified_cond", i, FALSE);
       prefs_set_int_index("sp_added_cond", i, FALSE);
       prefs_set_int_index("sp_rating_state", i, 0);
+      prefs_set_string_index("sp_played_state", i, ">4w");
+      prefs_set_string_index("sp_modified_state", i, "<1d");
+      prefs_set_string_index("sp_added_state", i, "<1d");
     }
 }
 
@@ -789,6 +792,13 @@
       prefs_set_int_index("sp_added_cond", i, int_buf);
   }
   
+  /* sp_created_state renamed to sp_added_state */
+  for (i = 0; i < SORT_TAB_MAX; i++)
+  {
+    if (prefs_get_int_value_index("sp_created_state", i, &int_buf))
+      prefs_set_int_index("sp_added_state", i, int_buf);
+  }
+  
   prefs_set_string ("version", VERSION);
 }
 
@@ -1651,9 +1661,6 @@
     {
        mycfg->st[i].sp_playcount_low = 0;
        mycfg->st[i].sp_playcount_high = -1;
-       mycfg->st[i].sp_played_state = g_strdup (">4w");
-       mycfg->st[i].sp_modified_state = g_strdup ("<1d");
-       mycfg->st[i].sp_added_state = g_strdup ("<1d");
        mycfg->st[i].sp_autodisplay = FALSE;
     }
     mycfg->mpl_autoselect = TRUE;
@@ -1909,22 +1916,6 @@
              gint i = atoi (line+off);
              prefs_set_sp_playcount_high (i, atoi (arg));
          }
-         else if(arg_comp (line, "sp_played_state", &off) == 0)
-         {
-             gint i = atoi (line+off);
-             prefs_set_sp_entry (i, T_TIME_PLAYED, arg);
-         }
-         else if(arg_comp (line, "sp_modified_state", &off) == 0)
-         {
-             gint i = atoi (line+off);
-             prefs_set_sp_entry (i, T_TIME_MODIFIED, arg);
-         }
-         else if((arg_comp (line, "sp_created_state", &off) == 0) ||
-                 (arg_comp (line, "sp_added_state", &off) == 0))
-         {
-             gint i = atoi (line+off);
-             prefs_set_sp_entry (i, T_TIME_ADDED, arg);
-         }
          else if(arg_comp (line, "sp_autodisplay", &off) == 0)
          {
              gint i = atoi (line+off);
@@ -2408,9 +2399,6 @@
     {
        fprintf(fp, "sp_playcount_low%d=%d\n", i, prefs_get_sp_playcount_low 
(i));
        fprintf(fp, "sp_playcount_high%d=%d\n", i, prefs_get_sp_playcount_high 
(i));
-       fprintf(fp, "sp_played_state%d=%s\n", i, prefs_get_sp_entry (i, 
T_TIME_PLAYED));
-       fprintf(fp, "sp_modified_state%d=%s\n", i, prefs_get_sp_entry (i, 
T_TIME_MODIFIED));
-       fprintf(fp, "sp_added_state%d=%s\n", i, prefs_get_sp_entry (i, 
T_TIME_ADDED));
        fprintf(fp, "sp_autodisplay%d=%d\n", i, prefs_get_sp_autodisplay (i));
     }
     fprintf(fp, _("# autoselect master playlist?\n"));
@@ -3343,81 +3331,6 @@
     cfg->info_window = val;
 }
 
-void prefs_set_sp_entry (guint32 inst, T_item t_item, const gchar *str)
-{
-/*    printf("psse: %d, %d, %s\n", inst, t_item, str);*/
-    if (inst < SORT_TAB_MAX)
-    {
-       gchar *cstr = NULL;
-
-       if (str)  cstr = g_strdup (str);
-
-       switch (t_item)
-       {
-       case T_TIME_PLAYED:
-           g_free (cfg->st[inst].sp_played_state);
-           cfg->st[inst].sp_played_state = cstr;
-           break;
-       case T_TIME_MODIFIED:
-           g_free (cfg->st[inst].sp_modified_state);
-           cfg->st[inst].sp_modified_state = cstr;
-           break;
-       case T_TIME_ADDED:
-           g_free (cfg->st[inst].sp_added_state);
-           cfg->st[inst].sp_added_state = cstr;
-           break;
-       default:
-           /* programming error */
-           g_free (cstr);
-           fprintf (stderr, "prefs_set_sp_entry(): inst=%d !t_item=%d!\n",
-                    inst, t_item);
-           break;
-       }
-    }
-    else
-    {
-       /* programming error */
-       fprintf (stderr, "prefs_set_sp_entry(): !inst=%d! t_item=%d\n",
-                inst, t_item);
-    }
-}
-
-
-/* Returns the current default or a pointer to "". Guaranteed to never
-   return NULL */
-gchar *prefs_get_sp_entry (guint32 inst, T_item t_item)
-{
-    gchar *result = NULL;
-
-    if (inst < SORT_TAB_MAX)
-    {
-       switch (t_item)
-       {
-       case T_TIME_PLAYED:
-           result = cfg->st[inst].sp_played_state;
-           break;
-       case T_TIME_MODIFIED:
-           result = cfg->st[inst].sp_modified_state;
-           break;
-       case T_TIME_ADDED:
-           result = cfg->st[inst].sp_added_state;
-           break;
-       default:
-           /* programming error */
-           fprintf (stderr, "prefs_get_sp_entry(): !t_item=%d!\n", t_item);
-           break;
-       }
-    }
-    else
-    {
-       /* programming error */
-       fprintf (stderr, "prefs_get_sp_entry(): !inst=%d!\n", inst);
-    }
-    if (result == NULL)    result = "";
-    return result;
-}
-
-
 void prefs_set_sp_autodisplay (guint32 inst, gboolean state)
 {
     if (inst < SORT_TAB_MAX)

Index: prefs.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.h,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- prefs.h     4 Jun 2006 22:25:30 -0000       1.123
+++ prefs.h     5 Jun 2006 02:57:39 -0000       1.124
@@ -108,9 +108,6 @@
     /* the following fields are for the "special" tab */
     guint sp_playcount_low;  /* lower limit for playcounts */
     guint sp_playcount_high; /* higher limit for playcounts */
-    gchar *sp_played_state;  /* current "played" string */
-    gchar *sp_modified_state;/* current "modified" string */
-    gchar *sp_added_state;   /* current "added" string */
     gboolean sp_autodisplay; /* display automatically? */
   } st[SORT_TAB_MAX];
   struct sortcfg
@@ -409,8 +406,6 @@
 void prefs_set_last_prefs_page (gint i);
 gboolean prefs_get_automount (void);
 gboolean prefs_get_info_window (void);
-void prefs_set_sp_entry (guint32 inst, T_item t_item, const gchar *str);
-gchar *prefs_get_sp_entry (guint32 inst, T_item t_item);
 void prefs_set_sp_autodisplay (guint32 inst, gboolean state);
 gboolean prefs_get_sp_autodisplay (guint32 inst);
 gint32 prefs_get_sp_playcount_low (guint32 inst);



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

Reply via email to