From 1d85ea612523dad4ceefad49ac5a3f29b5e570dd Mon Sep 17 00:00:00 2001
From: "Maksim E. Kozlov" <maksim.e.kozlov@gmail.com>
Date: Sat, 8 Feb 2014 23:33:36 +0400
Subject: [RFC PATCH v2 1/1] gtkui: Add a custom rewinding/forwarding step

Signed-off-by: Maksim E. Kozlov <maksim.e.kozlov@gmail.com>
---
 src/gtkui/gtkui.h    |  1 +
 src/gtkui/settings.c |  5 ++++-
 src/gtkui/ui_gtk.c   | 22 +++++++++++++++++-----
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/gtkui/gtkui.h b/src/gtkui/gtkui.h
index 27a834b..e6b3457 100644
--- a/src/gtkui/gtkui.h
+++ b/src/gtkui/gtkui.h
@@ -46,5 +46,6 @@ void show_hide_statusbar (void);
 void popup_menu_rclick (unsigned button, uint32_t time);
 void popup_menu_tab (unsigned button, uint32_t time, int playlist);
 void activate_search_tool (void);
+void update_slider_properties (void);
 
 #endif
diff --git a/src/gtkui/settings.c b/src/gtkui/settings.c
index 77b73e9..7747b3f 100644
--- a/src/gtkui/settings.c
+++ b/src/gtkui/settings.c
@@ -49,7 +49,10 @@ static PreferencesWidget gtkui_widgets[] = {
      .callback = redisplay_playlists},
     {WIDGET_LABEL, N_("<b>Miscellaneous</b>")},
     {WIDGET_CHK_BTN, N_("Scroll on song change"),
-     .cfg_type = VALUE_BOOLEAN, .csect = "gtkui", .cname = "autoscroll"}
+     .cfg_type = VALUE_BOOLEAN, .csect = "gtkui", .cname = "autoscroll"},
+    {WIDGET_SPIN_BTN, N_("Rewinding and forwarding step:"),
+     .cfg_type = VALUE_INT, .csect = "gtkui", .cname = "rewind_step",
+     .callback= update_slider_properties, .data.spin_btn = {100, 10000, 100, N_("ms")}}
 };
 
 const PluginPreferences gtkui_prefs = {
diff --git a/src/gtkui/ui_gtk.c b/src/gtkui/ui_gtk.c
index a2d3bde..d06ebc1 100644
--- a/src/gtkui/ui_gtk.c
+++ b/src/gtkui/ui_gtk.c
@@ -54,6 +54,7 @@ static const char * const gtkui_defaults[] = {
  "playlist_columns", "title artist album queued length",
  "playlist_headers", "TRUE",
  "show_remaining_time", "FALSE",
+ "rewind_step", "5000",
 
  "player_x", "-1000",
  "player_y", "-1000",
@@ -396,6 +397,12 @@ static void set_slider_length (int length)
         gtk_widget_hide (slider);
 }
 
+static void set_slider_increments (void)
+{
+	int slider_step = aud_get_int("gtkui", "rewind_step");
+	gtk_range_set_increments ((GtkRange *) slider, slider_step, slider_step);
+}
+
 static void pause_cb (void)
 {
     gtk_tool_button_set_icon_name ((GtkToolButton *) button_play,
@@ -523,11 +530,11 @@ static bool_t window_keypress_cb (GtkWidget * widget, GdkEventKey * event, void
             return TRUE;
         case GDK_KEY_Left:
             if (aud_drct_get_playing ())
-                do_seek (aud_drct_get_time () - 5000);
+                do_seek (aud_drct_get_time () - aud_get_int ("gtkui", "rewind_step"));
             return TRUE;
         case GDK_KEY_Right:
             if (aud_drct_get_playing ())
-                do_seek (aud_drct_get_time () + 5000);
+                do_seek (aud_drct_get_time () + aud_get_int ("gtkui", "rewind_step"));
             return TRUE;
         }
 
@@ -563,11 +570,11 @@ static bool_t window_keypress_cb (GtkWidget * widget, GdkEventKey * event, void
         {
           case GDK_KEY_Left:
             if (aud_drct_get_playing ())
-                do_seek (aud_drct_get_time () - 5000);
+                do_seek (aud_drct_get_time () - aud_get_int ("gtkui", "rewind_step"));
             break;
           case GDK_KEY_Right:
             if (aud_drct_get_playing ())
-                do_seek (aud_drct_get_time () + 5000);
+                do_seek (aud_drct_get_time () + aud_get_int ("gtkui", "rewind_step"));
             break;
           default:
             return FALSE;
@@ -749,7 +756,7 @@ static bool_t init (void)
     gtk_container_add ((GtkContainer *) boxitem1, box1);
 
     slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
-    gtk_range_set_increments ((GtkRange *) slider, 5000, 5000);
+    set_slider_increments();
     gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
     gtk_widget_set_size_request(slider, 120, -1);
     gtk_widget_set_valign (slider, GTK_ALIGN_CENTER);
@@ -1019,3 +1026,8 @@ void activate_search_tool (void)
 
     aud_plugin_send_message (search_tool, "grab focus", NULL, 0);
 }
+
+void update_slider_properties (void)
+{
+	set_slider_increments();
+}
-- 
1.8.5.2

