[PATCH] Change UI for the volume control.

View: New views
2 Messages — Rating Filter:   Alert me  

[PATCH] Change UI for the volume control.

by Andrea-60 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is a patch to change the UI control for the "volume" in the track details.
I've used a GtkHScale with range -255 - +255.
Let me know what you think.
Andrea


------------------------------------------------------------------------------
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-devel mailing list
Gtkpod-devel@...
https://lists.sourceforge.net/lists/listinfo/gtkpod-devel

[PATCH] Change UI for the volume control. It uses now a GtkHScale.

by Andrea-60 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

---
 data/gtkpod.glade |   15 +++++++++----
 src/details.c     |   59 ++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 64 insertions(+), 10 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 02b4b4c..581622b 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_if_fail (scale);
+
+    item = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (scale),
+       "details_item"));
+    
+    g_return_if_fail ((item > 0) && (item < T_ITEM_NUM));
+
+    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);
 }
--
1.6.2.5


------------------------------------------------------------------------------
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-devel mailing list
Gtkpod-devel@...
https://lists.sourceforge.net/lists/listinfo/gtkpod-devel