[Rhythmbox-devel] [patch] music as desktop service



Hi,

Our interaction designers have been complaining for a while that the way
Rhythmbox's tray icon works is kind of broken.  Music is really more of
a desktop background service than a traditional application.  The
typical usage will be to choose a song or set of songs (or random) then
want to get the window out of your way.

This patch changes Rhythmbox so that the primary focus is really the
tray icon, similar to how Muine does it.  Closing the main Rhythmbox
window doesn't shut it down, it just hides the window.  Ideally we would
have some animation similar to the regular Metacity minimization to show
the Rhythmbox window going into the tray icon, but for now this is at
least a step forward.

Ok to apply?

cvs server: Diffing .
cvs server: Diffing component
cvs server: Diffing corba
cvs server: Diffing data
cvs server: Diffing data/art
cvs server: Diffing data/glade
cvs server: Diffing data/node-views
cvs server: Diffing data/ui
Index: data/ui/rhythmbox-ui.xml
===================================================================
RCS file: /cvs/gnome/rhythmbox/data/ui/rhythmbox-ui.xml,v
retrieving revision 1.19
diff -u -p -r1.19 rhythmbox-ui.xml
--- data/ui/rhythmbox-ui.xml	12 Jun 2005 17:21:44 -0000	1.19
+++ data/ui/rhythmbox-ui.xml	6 Jul 2005 18:57:49 -0000
@@ -66,13 +66,14 @@
   </menubar>
 
   <popup name="RhythmboxTrayPopup">
+      <menuitem name="ShowWindowTray" action="TrayShowWindow"/>
+      <separator/>
       <menuitem name="PlayTray" action="ControlPlay"/>
       <menuitem name="PauseTray" action="ControlPause"/>
       <separator/>
       <menuitem name="PreviousTray" action="ControlPrevious"/>
       <menuitem name="NextTray" action="ControlNext"/>
       <separator/>
-      <menuitem name="ShowWindowTray" action="TrayShowWindow"/>
       <menuitem name="QuitTray" action="MusicQuit"/>
   </popup>
 
cvs server: Diffing data/views
cvs server: Diffing debian
cvs server: Diffing doc
cvs server: Diffing help
cvs server: Diffing help/C
cvs server: Diffing help/C/figures
cvs server: Diffing help/ja
cvs server: Diffing help/ja/figures
cvs server: Diffing iradio
cvs server: Diffing lib
cvs server: Diffing lib/egg
cvs server: Diffing lib/toolbar
cvs server: Diffing lib/view
cvs server: Diffing lib/widgets
cvs server: Diffing library
cvs server: Diffing macros
cvs server: Diffing metadata
cvs server: Diffing metadata/monkey-media
cvs server: Diffing metadata/monkey-media/id3-vfs
cvs server: Diffing metadata/monkey-media/stream-info-impl
cvs server: Diffing metadata/monkey-media/stream-info-impl/id3-vfs
cvs server: Diffing monkey-media
cvs server: Diffing monkey-media/id3-vfs
cvs server: Diffing monkey-media/stream-info-impl
cvs server: Diffing monkey-media/stream-info-impl/id3-vfs
cvs server: Diffing player
cvs server: Diffing po
cvs server: Diffing remote
cvs server: Diffing remote/bonobo
cvs server: Diffing remote/dbus
cvs server: Diffing rhythmdb
cvs server: Diffing shell
Index: shell/rb-shell.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-shell.c,v
retrieving revision 1.303
diff -u -p -r1.303 rb-shell.c
--- shell/rb-shell.c	19 Jun 2005 18:30:57 -0000	1.303
+++ shell/rb-shell.c	6 Jul 2005 18:57:50 -0000
@@ -1149,13 +1149,45 @@ rb_shell_window_state_cb (GtkWidget *wid
 }
 #endif
 
+static void
+rb_shell_set_visibility (RBShell *shell, gboolean visible)
+{
+	if (visible == shell->priv->visible)
+		return;
+
+	if (visible) {
+		rb_debug ("showing main window");
+		rb_shell_sync_window_state (shell);
+
+		gtk_widget_realize (shell->priv->window);
+		gdk_flush ();
+		if ((shell->priv->window_x >= 0) && (shell->priv->window_y >= 0))
+			gtk_window_move (GTK_WINDOW (shell->priv->window),
+					 shell->priv->window_x,
+					 shell->priv->window_y);
+
+		gtk_widget_show (shell->priv->window);
+	} else {
+		/* should store this stuff in gconf instead? */
+		rb_debug ("hiding main window");
+		gtk_window_get_position (GTK_WINDOW (shell->priv->window),
+					 &shell->priv->window_x,
+					 &shell->priv->window_y);
+		gtk_widget_hide (shell->priv->window);
+	}
+
+	shell->priv->visible = visible;
+	g_signal_emit_by_name (shell, "visibility_changed", visible);
+
+}
+
 static gboolean
 rb_shell_window_delete_cb (GtkWidget *win,
 			   GdkEventAny *event,
 			   RBShell *shell)
 {
-	rb_debug ("window deleted");
-	rb_shell_quit (shell);
+	rb_debug ("window deleted, toggling visibility");
+	rb_shell_set_visibility (shell, !shell->priv->visible);
 
 	return TRUE;
 };
@@ -2217,32 +2249,7 @@ static void
 rb_shell_set_visibility_impl (RBRemoteProxy *proxy, gboolean visible)
 {
 	RBShell *shell = RB_SHELL (proxy);
-	if (visible == shell->priv->visible)
-		return;
-
-	if (visible) {
-		rb_debug ("showing main window");
-		rb_shell_sync_window_state (shell);
-
-		gtk_widget_realize (shell->priv->window);
-		gdk_flush ();
-		if ((shell->priv->window_x >= 0) && (shell->priv->window_y >= 0))
-			gtk_window_move (GTK_WINDOW (shell->priv->window),
-					 shell->priv->window_x,
-					 shell->priv->window_y);
-
-		gtk_widget_show (shell->priv->window);
-	} else {
-		/* should store this stuff in gconf instead? */
-		rb_debug ("hiding main window");
-		gtk_window_get_position (GTK_WINDOW (shell->priv->window),
-					 &shell->priv->window_x,
-					 &shell->priv->window_y);
-		gtk_widget_hide (shell->priv->window);
-	}
-
-	shell->priv->visible = visible;
-	g_signal_emit_by_name (proxy, "visibility_changed", visible);
+	rb_shell_set_visibility (shell, visible);
 }
 
 static gboolean
Index: shell/rb-tray-icon.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-tray-icon.c,v
retrieving revision 1.17
diff -u -p -r1.17 rb-tray-icon.c
--- shell/rb-tray-icon.c	19 Jun 2005 18:30:57 -0000	1.17
+++ shell/rb-tray-icon.c	6 Jul 2005 18:57:50 -0000
@@ -94,8 +94,8 @@ enum
 
 static GtkToggleActionEntry rb_tray_icon_toggle_entries [] =
 {
-	{ "TrayShowWindow", NULL, N_("_Show Window"), NULL,
-	  N_("Change the visibility of the main window"),
+	{ "TrayShowWindow", NULL, N_("_Show Music Player"), NULL,
+	  N_("Choose music to play"),
 	  G_CALLBACK (rb_tray_icon_show_window_changed_cb) }
 };
 static guint rb_tray_icon_n_toggle_entries = G_N_ELEMENTS (rb_tray_icon_toggle_entries);
@@ -325,37 +325,54 @@ rb_tray_icon_new (GtkUIManager *mgr,
 }
 
 static void
+tray_popup_position_menu (GtkMenu *menu,
+			  int *x,
+			  int *y,
+			  gboolean *push_in,
+			  gpointer user_data)
+{
+        GtkWidget *widget;
+        GtkRequisition requisition;
+        gint menu_xpos;
+        gint menu_ypos;
+
+        widget = GTK_WIDGET (user_data);
+
+        gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
+
+        gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos);
+
+        menu_xpos += widget->allocation.x;
+        menu_ypos += widget->allocation.y;
+
+	if (menu_ypos > gdk_screen_get_height (gtk_widget_get_screen (widget)) / 2)
+		menu_ypos -= requisition.height;
+	else
+		menu_ypos += widget->allocation.height;
+
+        *x = menu_xpos;
+        *y = menu_ypos;
+        *push_in = TRUE;
+}
+
+static void
 rb_tray_icon_button_press_event_cb (GtkWidget *ebox, GdkEventButton *event,
 				    RBTrayIcon *icon)
 {
+	GtkWidget *popup;
+
 	/* filter out double, triple clicks */
 	if (event->type != GDK_BUTTON_PRESS)
 		return;
 
 	rb_debug ("tray button press");
 
-	switch (event->button) {
-	case 1:
-	{
-		gboolean visible = rb_remote_proxy_get_visibility (icon->priv->proxy);
-		rb_remote_proxy_set_visibility (icon->priv->proxy, visible ? FALSE : TRUE);
-		break;
-	}
-
-	case 3:
-	{
-		GtkWidget *popup;
-		popup = gtk_ui_manager_get_widget (GTK_UI_MANAGER (icon->priv->ui_manager),
-						   "/RhythmboxTrayPopup");
-		gtk_menu_set_screen (GTK_MENU (popup), gtk_widget_get_screen (GTK_WIDGET (icon)));
-		gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
-				NULL, NULL, 2,
-				gtk_get_current_event_time ());
-	}
-	break;
-	default:
-		break;
-	}
+	popup = gtk_ui_manager_get_widget (GTK_UI_MANAGER (icon->priv->ui_manager),
+					   "/RhythmboxTrayPopup");
+	gtk_menu_set_screen (GTK_MENU (popup), gtk_widget_get_screen (GTK_WIDGET (icon)));
+	gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
+			tray_popup_position_menu, ebox, 2,
+			gtk_get_current_event_time ());
 }
 
 static void
cvs server: Diffing sources
cvs server: Diffing tests
cvs server: Diffing views
cvs server: Diffing widgets
cvs server: Diffing xine-output

Attachment: signature.asc
Description: This is a digitally signed message part



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