changeset 918:209bd85dc1b9 trunk

[svn] - statusicon: add an option to use mouse wheel to change playing song instead of volume
author giacomo
date Fri, 06 Apr 2007 11:47:07 -0700
parents c64da1c724b9
children d16737cc85f6
files ChangeLog src/statusicon/si.c src/statusicon/si_audacious.h src/statusicon/si_cfg.c src/statusicon/si_cfg.h src/statusicon/si_ui.c
diffstat 6 files changed, 104 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 06 10:30:17 2007 -0700
+++ b/ChangeLog	Fri Apr 06 11:47:07 2007 -0700
@@ -1,3 +1,10 @@
+2007-04-06 17:30:17 +0000  Giacomo Lozito <james@develia.org>
+  revision [1962]
+  - aosd: updated ghosd license
+  trunk/src/aosd/ghosd-license |    3 ++-
+  1 file changed, 2 insertions(+), 1 deletion(-)
+
+
 2007-04-06 04:12:59 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
   revision [1960]
   revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
--- a/src/statusicon/si.c	Fri Apr 06 10:30:17 2007 -0700
+++ b/src/statusicon/si.c	Fri Apr 06 11:47:07 2007 -0700
@@ -127,6 +127,26 @@
 }
 
 void
+si_audacious_playback_skip ( gint numsong )
+{
+  gpointer ctrl_code_gp = NULL;
+  gint i = 0;
+  
+  if ( numsong >= 0 )
+  {
+    ctrl_code_gp = GINT_TO_POINTER(SI_AUDACIOUS_PLAYBACK_CTRL_NEXT);
+  }
+  else
+  { 
+    ctrl_code_gp = GINT_TO_POINTER(SI_AUDACIOUS_PLAYBACK_CTRL_PREV);
+    numsong *= -1;
+  }
+  
+  for ( i = 0 ; i < numsong ; i++ )
+    si_audacious_playback_ctrl( ctrl_code_gp );
+}
+
+void
 si_audacious_playback_ctrl ( gpointer ctrl_code_gp )
 {
   gint ctrl_code = GPOINTER_TO_INT(ctrl_code_gp);
--- a/src/statusicon/si_audacious.h	Fri Apr 06 10:30:17 2007 -0700
+++ b/src/statusicon/si_audacious.h	Fri Apr 06 11:47:07 2007 -0700
@@ -34,6 +34,7 @@
 
 void si_audacious_toggle_visibility ( void );
 void si_audacious_volume_change ( gint );
+void si_audacious_playback_skip ( gint );
 void si_audacious_playback_ctrl ( gpointer );
 
 
--- a/src/statusicon/si_cfg.c	Fri Apr 06 10:30:17 2007 -0700
+++ b/src/statusicon/si_cfg.c	Fri Apr 06 11:47:07 2007 -0700
@@ -33,6 +33,10 @@
   if ( !bmp_cfg_db_get_int( cfgfile , "statusicon" ,
        "rclick_menu" , &(si_cfg.rclick_menu) ) )
     si_cfg.rclick_menu = SI_CFG_RCLICK_MENU_AUD;
+
+  if ( !bmp_cfg_db_get_int( cfgfile , "statusicon" ,
+       "scroll_action" , &(si_cfg.scroll_action) ) )
+    si_cfg.scroll_action = SI_CFG_SCROLL_ACTION_VOLUME;
     
   if ( !bmp_cfg_db_get_bool( cfgfile , "statusicon" ,
        "mw_visib_prevstatus" , &(si_cfg.mw_visib_prevstatus) ) )
@@ -57,6 +61,9 @@
   bmp_cfg_db_set_int( cfgfile , "statusicon" ,
     "rclick_menu" , si_cfg.rclick_menu );
   
+  bmp_cfg_db_set_int( cfgfile , "statusicon" ,
+    "scroll_action" , si_cfg.scroll_action );
+  
   bmp_cfg_db_set_bool( cfgfile , "statusicon" ,
     "mw_visib_prevstatus" , si_cfg.mw_visib_prevstatus );
   bmp_cfg_db_set_bool( cfgfile , "statusicon" ,
--- a/src/statusicon/si_cfg.h	Fri Apr 06 10:30:17 2007 -0700
+++ b/src/statusicon/si_cfg.h	Fri Apr 06 11:47:07 2007 -0700
@@ -28,9 +28,13 @@
 #define SI_CFG_RCLICK_MENU_AUD	0
 #define SI_CFG_RCLICK_MENU_SMALL	1
 
+#define SI_CFG_SCROLL_ACTION_VOLUME 0
+#define SI_CFG_SCROLL_ACTION_SKIP 1
+
 typedef struct
 {
   gint rclick_menu;
+  gint scroll_action;
   gboolean mw_visib_prevstatus;
   gboolean pw_visib_prevstatus;
   gboolean ew_visib_prevstatus;
--- a/src/statusicon/si_ui.c	Fri Apr 06 10:30:17 2007 -0700
+++ b/src/statusicon/si_ui.c	Fri Apr 06 11:47:07 2007 -0700
@@ -102,11 +102,32 @@
   switch ( event->direction )
   {
     case GDK_SCROLL_UP:
-      si_audacious_volume_change( 5 );
+    {
+      switch ( si_cfg.scroll_action )
+      {
+        case SI_CFG_SCROLL_ACTION_VOLUME:
+          si_audacious_volume_change( 5 );
+          break;
+        case SI_CFG_SCROLL_ACTION_SKIP:
+          si_audacious_playback_skip( 1 );
+          break;
+      }
       break;
+    }
+    
     case GDK_SCROLL_DOWN:
-      si_audacious_volume_change( -5 );
+    {
+      switch ( si_cfg.scroll_action )
+      {
+        case SI_CFG_SCROLL_ACTION_VOLUME:
+          si_audacious_volume_change( -5 );
+          break;
+        case SI_CFG_SCROLL_ACTION_SKIP:
+          si_audacious_playback_skip( -1 );
+          break;
+      }
       break;
+    }
   }
 
   return FALSE;
@@ -538,16 +559,28 @@
 void
 si_ui_prefs_cb_commit ( gpointer prefs_win )
 {
-  GSList *rcm_grp = g_object_get_data( G_OBJECT(prefs_win) , "rcm_grp" );
-  while ( rcm_grp != NULL )
+  GSList *list = g_object_get_data( G_OBJECT(prefs_win) , "rcm_grp" );
+  while ( list != NULL )
   {
-    if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(rcm_grp->data) ) == TRUE )
+    if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(list->data) ) == TRUE )
     {
-      si_cfg.rclick_menu = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(rcm_grp->data),"val"));
+      si_cfg.rclick_menu = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(list->data),"val"));
       break;
     }
-    rcm_grp = g_slist_next(rcm_grp);
+    list = g_slist_next(list);
   }
+  
+  list = g_object_get_data( G_OBJECT(prefs_win) , "msa_grp" );
+  while ( list != NULL )
+  {
+    if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(list->data) ) == TRUE )
+    {
+      si_cfg.scroll_action = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(list->data),"val"));
+      break;
+    }
+    list = g_slist_next(list);
+  }
+  
   si_cfg_save();
   gtk_widget_destroy( GTK_WIDGET(prefs_win) );
 }
@@ -560,6 +593,8 @@
   GtkWidget *prefs_vbox;
   GtkWidget *prefs_rclick_frame, *prefs_rclick_vbox;
   GtkWidget *prefs_rclick_audmenu_rbt, *prefs_rclick_smallmenu_rbt;
+  GtkWidget *prefs_scroll_frame, *prefs_scroll_vbox;
+  GtkWidget *prefs_scroll_vol_rbt, *prefs_scroll_skip_rbt;
   GtkWidget *prefs_bbar_bbox;
   GtkWidget *prefs_bbar_bt_ok, *prefs_bbar_bt_cancel;
   GdkGeometry prefs_win_hints;
@@ -606,6 +641,29 @@
   gtk_box_pack_start( GTK_BOX(prefs_rclick_vbox) , prefs_rclick_audmenu_rbt , TRUE , TRUE , 0 );
   gtk_box_pack_start( GTK_BOX(prefs_rclick_vbox) , prefs_rclick_smallmenu_rbt , TRUE , TRUE , 0 );
   gtk_box_pack_start( GTK_BOX(prefs_vbox) , prefs_rclick_frame , TRUE , TRUE , 0 );
+  
+  prefs_scroll_frame = gtk_frame_new( _("Mouse Scroll Action") );
+  prefs_scroll_vbox = gtk_vbox_new( TRUE , 0 );
+  gtk_container_set_border_width( GTK_CONTAINER(prefs_scroll_vbox) , 6 );
+  gtk_container_add( GTK_CONTAINER(prefs_scroll_frame) , prefs_scroll_vbox );
+  prefs_scroll_vol_rbt = gtk_radio_button_new_with_label( NULL ,
+                               _("Change volume") );
+  g_object_set_data( G_OBJECT(prefs_scroll_vol_rbt) , "val" ,
+                     GINT_TO_POINTER(SI_CFG_SCROLL_ACTION_VOLUME) );
+  prefs_scroll_skip_rbt = gtk_radio_button_new_with_label_from_widget(
+                                 GTK_RADIO_BUTTON(prefs_scroll_vol_rbt) ,
+                                 _("Change playing song") );
+  g_object_set_data( G_OBJECT(prefs_scroll_skip_rbt) , "val" ,
+                     GINT_TO_POINTER(SI_CFG_SCROLL_ACTION_SKIP) );
+  g_object_set_data( G_OBJECT(prefs_win) , "msa_grp" ,
+                     gtk_radio_button_get_group(GTK_RADIO_BUTTON(prefs_scroll_skip_rbt)) );
+  if ( si_cfg.scroll_action == SI_CFG_SCROLL_ACTION_VOLUME )
+    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(prefs_scroll_vol_rbt) , TRUE );
+  else
+    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(prefs_scroll_skip_rbt) , TRUE );
+  gtk_box_pack_start( GTK_BOX(prefs_scroll_vbox) , prefs_scroll_vol_rbt , TRUE , TRUE , 0 );
+  gtk_box_pack_start( GTK_BOX(prefs_scroll_vbox) , prefs_scroll_skip_rbt , TRUE , TRUE , 0 );
+  gtk_box_pack_start( GTK_BOX(prefs_vbox) , prefs_scroll_frame , TRUE , TRUE , 0 );
 
   /* horizontal separator and buttons */
   gtk_box_pack_start( GTK_BOX(prefs_vbox) , gtk_hseparator_new() , FALSE , FALSE , 4 );