[rhythmbox] status-icon: make the mouse wheel action configurable (bug #376863)



commit f82f42945acb6f9e7a5cc6e8ced3908a8bbe1b01
Author: Gustavo Mora <gusfmora gmail com>
Date:   Wed Jul 22 23:38:56 2009 +1000

    status-icon: make the mouse wheel action configurable (bug #376863)
    
    The available actions are the existing volume control and next/previous
    track.

 data/rhythmbox.schemas                         |   14 +++++
 plugins/status-icon/rb-status-icon-plugin.c    |   66 ++++++++++++++++++++---
 plugins/status-icon/status-icon-preferences.ui |   48 +++++++++++++++++-
 3 files changed, 118 insertions(+), 10 deletions(-)
---
diff --git a/data/rhythmbox.schemas b/data/rhythmbox.schemas
index 7a15021..faaa15e 100644
--- a/data/rhythmbox.schemas
+++ b/data/rhythmbox.schemas
@@ -1521,6 +1521,20 @@
 	</locale>
       </schema>
       <schema>
+        <key>/schemas/apps/rhythmbox/plugins/status-icon/mouse-wheel-mode</key>
+        <applyto>/apps/rhythmbox/plugins/status-icon/mouse-wheel-mode</applyto>
+        <owner>rhythmbox</owner>
+        <type>int</type>
+        <default>0</default>
+        <locale name="C">
+        <short>Mouse wheel action mode.</short>
+	<long>
+          If 0, the mouse wheel action will change the rhythmbox volume.
+          If 1, the mouse wheel action will change to the next/previous song.
+        </long>
+	</locale>
+      </schema>
+      <schema>
         <key>/schemas/apps/rhythmbox/plugins/status-icon/window-visible</key>
         <applyto>/apps/rhythmbox/plugins/status-icon/window-visible</applyto>
         <owner>rhythmbox</owner>
diff --git a/plugins/status-icon/rb-status-icon-plugin.c b/plugins/status-icon/rb-status-icon-plugin.c
index ed5996e..4dd0af2 100644
--- a/plugins/status-icon/rb-status-icon-plugin.c
+++ b/plugins/status-icon/rb-status-icon-plugin.c
@@ -65,6 +65,7 @@
 #define CONF_PLUGIN_SETTINGS	"/apps/rhythmbox/plugins/status-icon"
 #define CONF_NOTIFICATION_MODE	CONF_PLUGIN_SETTINGS "/notification-mode"
 #define CONF_STATUS_ICON_MODE	CONF_PLUGIN_SETTINGS "/status-icon-mode"
+#define CONF_MOUSE_WHEEL_MODE	CONF_PLUGIN_SETTINGS "/mouse-wheel-mode"
 #define CONF_WINDOW_VISIBILITY	CONF_PLUGIN_SETTINGS "/window-visible"
 
 #define CONF_OLD_ICON_MODE	"/apps/rhythmbox/plugins/dontreallyclose/active"
@@ -100,6 +101,10 @@ struct _RBStatusIconPluginPrivate
 		NOTIFY_HIDDEN,
 		NOTIFY_ALWAYS
 	} notify_mode;
+	enum {
+		WHEEL_VOLUME = 0,
+		WHEEL_SONG
+	} wheel_mode;
 
 	/* current playing data */
 	char *current_title;
@@ -121,6 +126,7 @@ struct _RBStatusIconPluginPrivate
 	GtkWidget *config_dialog;
 	GtkWidget *notify_combo;
 	GtkWidget *icon_combo;
+	GtkWidget *wheel_combo;
 
 	RBShellPlayer *shell_player;
 	RBShell *shell;
@@ -220,18 +226,33 @@ rb_status_icon_plugin_scroll_event (RBStatusIconPlugin *plugin,
 {
 	gdouble adjust;
 
-	switch (event->direction) {
-	case GDK_SCROLL_UP:
-		adjust = 0.02;
+	switch (plugin->priv->wheel_mode) {
+	case WHEEL_VOLUME:
+		switch (event->direction) {
+		case GDK_SCROLL_UP:
+			adjust = 0.02;
+			break;
+		case GDK_SCROLL_DOWN:
+			adjust = -0.02;
+			break;
+		default:
+			return;
+		}
+		rb_shell_player_set_volume_relative (plugin->priv->shell_player, adjust, NULL);
 		break;
-	case GDK_SCROLL_DOWN:
-		adjust = -0.02;
+	case WHEEL_SONG:
+		switch (event->direction) {
+		case GDK_SCROLL_UP:
+			rb_shell_player_do_next (plugin->priv->shell_player, NULL);
+			break;
+		case GDK_SCROLL_DOWN:
+			rb_shell_player_do_previous (plugin->priv->shell_player, NULL);
+			break;
+		default:
+			return;
+		}
 		break;
-	default:
-		return;
 	}
-
-	rb_shell_player_set_volume_relative (plugin->priv->shell_player, adjust, NULL);
 }
 
 void
@@ -1093,6 +1114,15 @@ status_icon_config_changed_cb (GtkComboBox *widget, RBStatusIconPlugin *plugin)
 }
 
 static void
+mouse_wheel_config_changed_cb (GtkComboBox *widget, RBStatusIconPlugin *plugin)
+{
+	if (plugin->priv->syncing_config_widgets)
+		return;
+
+	eel_gconf_set_integer (CONF_MOUSE_WHEEL_MODE, gtk_combo_box_get_active (widget));
+}
+
+static void
 config_response_cb (GtkWidget *dialog, gint response, RBStatusIconPlugin *plugin)
 {
 	gtk_widget_hide (dialog);
@@ -1157,6 +1187,17 @@ config_notify_cb (GConfClient *client, guint connection_id, GConfEntry *entry, R
 			gtk_combo_box_set_active (GTK_COMBO_BOX (plugin->priv->notify_combo), plugin->priv->notify_mode);
 			plugin->priv->syncing_config_widgets = FALSE;
 		}
+	} else if (g_str_equal (gconf_entry_get_key (entry), CONF_MOUSE_WHEEL_MODE)) {
+		plugin->priv->wheel_mode = gconf_value_get_int (gconf_entry_get_value (entry));
+		rb_debug ("wheel mode changed to %d", plugin->priv->wheel_mode);
+
+		sync_actions (plugin);
+
+		if (plugin->priv->wheel_combo != NULL) {
+			plugin->priv->syncing_config_widgets = TRUE;
+			gtk_combo_box_set_active (GTK_COMBO_BOX (plugin->priv->wheel_combo), plugin->priv->wheel_mode);
+			plugin->priv->syncing_config_widgets = FALSE;
+		}
 	}
 }
 
@@ -1195,6 +1236,7 @@ impl_get_config_widget (RBPlugin *bplugin)
 
 	plugin->priv->icon_combo = GTK_WIDGET (gtk_builder_get_object (builder, "statusiconmode"));
 	plugin->priv->notify_combo = GTK_WIDGET (gtk_builder_get_object (builder, "notificationmode"));
+	plugin->priv->wheel_combo = GTK_WIDGET (gtk_builder_get_object (builder, "mousewheelmode"));
 	g_signal_connect_object (plugin->priv->notify_combo,
 				 "changed",
 				 G_CALLBACK (notification_config_changed_cb),
@@ -1203,8 +1245,13 @@ impl_get_config_widget (RBPlugin *bplugin)
 				 "changed",
 				 G_CALLBACK (status_icon_config_changed_cb),
 				 plugin, 0);
+	g_signal_connect_object (plugin->priv->wheel_combo,
+				 "changed",
+				 G_CALLBACK (mouse_wheel_config_changed_cb),
+				 plugin, 0);
 	gtk_combo_box_set_active (GTK_COMBO_BOX (plugin->priv->notify_combo), plugin->priv->notify_mode);
 	gtk_combo_box_set_active (GTK_COMBO_BOX (plugin->priv->icon_combo), plugin->priv->icon_mode);
+	gtk_combo_box_set_active (GTK_COMBO_BOX (plugin->priv->wheel_combo), plugin->priv->wheel_mode);
 
 	g_object_unref (builder);
 	return plugin->priv->config_dialog;
@@ -1284,6 +1331,7 @@ impl_activate (RBPlugin *bplugin,
 
 	plugin->priv->icon_mode = eel_gconf_get_integer (CONF_STATUS_ICON_MODE);
 	plugin->priv->notify_mode = eel_gconf_get_integer (CONF_NOTIFICATION_MODE);
+	plugin->priv->wheel_mode = eel_gconf_get_integer (CONF_MOUSE_WHEEL_MODE);
 
 	/* create status icon */
 	create_status_icon (plugin);
diff --git a/plugins/status-icon/status-icon-preferences.ui b/plugins/status-icon/status-icon-preferences.ui
index 4e92a37..cacb734 100644
--- a/plugins/status-icon/status-icon-preferences.ui
+++ b/plugins/status-icon/status-icon-preferences.ui
@@ -39,6 +39,20 @@
       </row>
     </data>
   </object>
+  <object class="GtkListStore" id="mousewheelmodel">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Change volume</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Change song</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="statusiconpreferences">
     <property name="border_width">5</property>
     <property name="resizable">False</property>
@@ -82,7 +96,7 @@
                 <child>
                   <object class="GtkTable" id="table1">
                     <property name="visible">True</property>
-                    <property name="n_rows">2</property>
+                    <property name="n_rows">3</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">12</property>
                     <property name="row_spacing">6</property>
@@ -146,6 +160,38 @@
                         <property name="right_attach">2</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">_Mouse Wheel</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">5</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="mousewheelmode">
+                        <property name="visible">True</property>
+                        <property name="model">mousewheelmodel</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext3"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">5</property>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="position">1</property>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]