commit b4d019586bcadf717bebefa9dd28bd76afa050f7
Author: phantomjinx <[email protected]>
Date:   Sun Nov 8 19:34:36 2009 +0000

    Add volume control to details window
    
    Patches submitted to list Andrea Odetti <[email protected]>.
    Adds a volume control slider to details window for setting the volume
    of the track. Also, fix for null-terminated list in syncdir.c
    
    Thanks to Andrea.

 data/gtkpod.glade |   15 +++++++++----
 src/details.c     |   59 ++++++++++++++++++++++++++++++++++++++++++++++++----
 src/syncdir.c     |    2 +-
 3 files changed, 65 insertions(+), 11 deletions(-)
---
diff --git a/data/gtkpod.glade b/data/gtkpod.glade
index 3b165ed..babb762 100644
--- a/data/gtkpod.glade
+++ b/data/gtkpod.glade
@@ -6816,11 +6816,16 @@ simultaneously</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkEntry" 
id="details_entry_23">
-                                        <property 
name="visible">True</property>
-                                        <property 
name="can_focus">True</property>
-                                        <property 
name="invisible_char">*</property>
-                                      </widget>
+                                     <widget class="GtkHScale" 
id="details_scale_23">
+                                       <property name="visible">True</property>
+                                       <property 
name="can_focus">True</property>
+                                       <property 
name="draw_value">True</property>
+                                       <property 
name="value_pos">GTK_POS_RIGHT</property>
+                                       <property name="digits">0</property>
+                                       <property 
name="update_policy">GTK_UPDATE_DISCONTINUOUS</property>
+                                       <property 
name="inverted">False</property>
+                                       <property name="adjustment">0 -255 255 
1 16 0</property>
+                                     </widget>
                                       <packing>
                                         <property 
name="left_attach">1</property>
                                         <property 
name="right_attach">2</property>
diff --git a/src/details.c b/src/details.c
index 8845a03..4a643b3 100644
--- a/src/details.c
+++ b/src/details.c
@@ -199,6 +199,24 @@ static void details_checkbutton_toggled (GtkCheckButton 
*button,
     details_get_item (detail, item, FALSE);
 }
 
+static gboolean details_scale_changed (GtkRange     *scale,
+                                      GtkScrollType scroll,
+                                      gdouble       value,
+                                      Detail       *detail)
+{
+    T_item item;
+
+    g_return_val_if_fail (scale, FALSE);
+
+    item = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (scale),
+                                              "details_item"));
+    
+    g_return_val_if_fail ((item > 0) && (item < T_ITEM_NUM), FALSE);
+
+    details_get_item (detail, item, FALSE);
+
+    return FALSE;
+}
 
 static void details_combobox_changed (GtkComboBox *combobox,
                                         Detail *detail)
@@ -735,7 +753,6 @@ static void details_setup_widget (Detail *detail, T_item 
item)
     case T_PLAYCOUNT:
     case T_BPM:
     case T_RATING:
-    case T_VOLUME:
     case T_SOUNDCHECK:
     case T_CD_NR:
     case T_TRACK_NR:
@@ -765,6 +782,13 @@ static void details_setup_widget (Detail *detail, T_item 
item)
                          G_CALLBACK (details_text_changed),
                          detail);
        break;
+    case T_VOLUME:
+        buf = g_strdup_printf ("details_scale_%d", item);
+        w = gtkpod_xml_get_widget (detail->xml, buf);
+        g_signal_connect (w, "change-value",
+                         G_CALLBACK (details_scale_changed),
+                         detail);
+       break;
     case T_COMPILATION:
     case T_TRANSFERRED:
     case T_CHECKED:
@@ -817,7 +841,7 @@ static void details_set_item (Detail *detail, Track *track, 
T_item item)
     GtkTextBuffer *tb;
     GtkWidget *w = NULL;
     gchar *text;
-    gchar *entry, *checkbutton, *textview, *combobox;
+    gchar *entry, *checkbutton, *textview, *combobox, *scale;
 
     g_return_if_fail (detail);
     g_return_if_fail ((item > 0) && (item < T_ITEM_NUM));
@@ -826,6 +850,7 @@ static void details_set_item (Detail *detail, Track *track, 
T_item item)
     checkbutton = g_strdup_printf ("details_checkbutton_%d", item);
     textview = g_strdup_printf ("details_textview_%d", item);
     combobox = g_strdup_printf ("details_combobox_%d", item);
+    scale = g_strdup_printf ("details_scale_%d", item);
 
     if (track != NULL)
     {
@@ -869,7 +894,6 @@ static void details_set_item (Detail *detail, Track *track, 
T_item item)
     case T_PLAYCOUNT:
     case T_BPM:
     case T_RATING:
-    case T_VOLUME:
     case T_SOUNDCHECK:
     case T_CD_NR:
     case T_TRACK_NR:
@@ -895,6 +919,17 @@ static void details_set_item (Detail *detail, Track 
*track, T_item item)
        gtk_entry_set_text (GTK_ENTRY (w), text);
        g_signal_handlers_unblock_by_func(w, details_text_changed,detail);
        break;
+    case T_VOLUME:
+        w = gtkpod_xml_get_widget (detail->xml, scale);
+        if (track)
+       {
+           gtk_range_set_value (GTK_RANGE (w), track->volume);
+        }
+        else
+       {
+            gtk_range_set_value (GTK_RANGE (w), 0.0);
+        }
+        break;
     case T_COMMENT:
     case T_DESCRIPTION:
     case T_LYRICS:
@@ -1001,6 +1036,7 @@ static void details_set_item (Detail *detail, Track 
*track, T_item item)
     g_free (textview);
     g_free (combobox);
     g_free (text);
+    g_free (scale);
 }
 
 
@@ -1013,7 +1049,7 @@ static void details_get_item (Detail *detail, T_item item,
                              gboolean assumechanged)
 {
     GtkWidget *w = NULL;
-    gchar *entry, *checkbutton, *textview, *combobox;
+    gchar *entry, *checkbutton, *textview, *combobox, *scale;
     gboolean changed = FALSE;
     ExtraTrackData *etr;
     Track *track;
@@ -1030,6 +1066,7 @@ static void details_get_item (Detail *detail, T_item item,
     checkbutton = g_strdup_printf ("details_checkbutton_%d", item);
     textview = g_strdup_printf ("details_textview_%d", item);
     combobox = g_strdup_printf ("details_combobox_%d", item);
+    scale = g_strdup_printf ("details_scale_%d", item);
 
     switch (item)
     {
@@ -1049,7 +1086,6 @@ static void details_get_item (Detail *detail, T_item item,
     case T_PLAYCOUNT:
     case T_BPM:
     case T_RATING:
-    case T_VOLUME:
     case T_CD_NR:
     case T_TRACK_NR:
     case T_YEAR:
@@ -1118,6 +1154,18 @@ static void details_get_item (Detail *detail, T_item 
item,
            }
        }
        break;
+    case T_VOLUME:
+       if ((w = gtkpod_xml_get_widget (detail->xml, scale)))
+       {
+           gdouble value = gtk_range_get_value (GTK_RANGE (w));
+           gint32 new_volume = (gint32)value;
+           if (track->volume != new_volume)
+           {
+               track->volume = new_volume;
+               changed = TRUE;
+           }
+       }
+       break;
     case T_COMMENT:
     case T_DESCRIPTION:
     case T_SUBTITLE:
@@ -1254,6 +1302,7 @@ static void details_get_item (Detail *detail, T_item item,
     g_free (checkbutton);
     g_free (textview);
     g_free (combobox);
+    g_free (scale);
 
     details_update_buttons (detail);
 }
diff --git a/src/syncdir.c b/src/syncdir.c
index 1c55f05..58a10e5 100644
--- a/src/syncdir.c
+++ b/src/syncdir.c
@@ -496,7 +496,7 @@ static void cache_directory (const gchar *dir, GHashTable 
*dirs_hash)
     while ((filename = g_dir_read_name(dir_handle)))
     {
         /* Construct absolute path from dir and filename */
-        path = g_build_filename(dir, filename);
+        path = g_build_filename(dir, filename, NULL);
 
         /* If path is not directory then move on to next */
         if (! g_file_test (path, G_FILE_TEST_IS_DIR))

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to