[Rhythmbox-devel] [PATCH] remote control operations shouldn't focus





> If you run rhythmbox with no parameters and one is already running, you
> want to focus it and bring it on the current desktop. I agree that in
> the other cases (play/pause/backward/forward/print current song, ...)
> the window shouldn't be brought to top. Do you feel like implementing
> some smart focusing scheme along with a --focus option ?
> 

The attached patch prevents the 'remote control' operations from focusing 
the already running window.  This includes play-pause, next, previous and 
adding new songs.  An additional options '--focus' can be included in the 
command line if focus is desired.  Running 'rhythmbox' without any options 
when it is already running will focus, as if '--focus' had been specified.

A spec file patch is included for those building RPMS from the pristine 
sources.  It is not intended to be incorporated into the main tree.

David

-- 
/==============================\
| David Mansfield              |
| rb@dm.cobite.com             |
\==============================/
--- rhythmbox-0.6.1/shell/main.c	2003-11-20 10:42:39.000000000 -0500
+++ rhythmbox-0.6.1.working/shell/main.c	2003-12-09 10:46:35.000000000 -0500
@@ -65,6 +65,7 @@ static gboolean dry_run		= FALSE;
 static gboolean print_playing = FALSE;
 static gboolean print_playing_path = FALSE;
 static gboolean playpause       = FALSE;
+static gboolean focus           = FALSE;
 static gboolean previous        = FALSE;
 static gboolean next            = FALSE;
 static gboolean print_play_time = FALSE;
@@ -89,6 +90,7 @@ main (int argc, char **argv)
         { "set-play-time", 	    0,  POPT_ARG_LONG,			&seek_time,				0, N_("Seek to the specified time in playing song if possible and exit"),	NULL },
         
 		{ "play-pause",		    0,  POPT_ARG_NONE,			&playpause,	        	0, N_("Toggle play/pause mode"),     NULL },
+		{ "focus",	    0,  POPT_ARG_NONE,			&focus,	        	0, N_("Focus the running player"),     NULL },
 		{ "previous",		    0,  POPT_ARG_NONE,			&previous,	        	0, N_("Jump to previous song"),     NULL },
 		{ "next",		        0,  POPT_ARG_NONE,			&next,		        	0, N_("Jump to next song"),     NULL },
 		
@@ -272,6 +274,14 @@ rb_handle_cmdline (char **argv, int argc
 	int i;
 	gboolean grab_focus = TRUE;
 	
+	/*
+	 * All 'remote control' type actions should set grab_focus 
+	 * to false.  There are two ways to focus the window.  
+	 * Running 'rhythmbox' with no arguments when it is already
+	 * running.  Explicitly adding the --focus argument combined 
+	 * with other 'remote control' arguments.
+	 */
+
 	shell = bonobo_activation_activate_from_id (RB_SHELL_OAFIID, 0, NULL, &ev);
 	if (shell == NULL)
 	{
@@ -294,7 +304,6 @@ rb_handle_cmdline (char **argv, int argc
 			CORBA_free (song_info);
 		}
 		grab_focus = FALSE;
-
 	}
 	
 	if (print_playing_path)
@@ -338,13 +347,22 @@ rb_handle_cmdline (char **argv, int argc
 	}
 	
 	if (playpause)
+	{
 		GNOME_Rhythmbox_playPause (shell, &ev);
+		grab_focus = FALSE;
+	}
 
 	if (previous)
+	{
 		GNOME_Rhythmbox_previous (shell, &ev);
+		grab_focus = FALSE;
+	}
 
 	if (next)
+	{
 		GNOME_Rhythmbox_next (shell, &ev);
+		grab_focus = FALSE;
+	}
 
 	for (i = 1; i < argc; i++)
 	{
@@ -354,11 +372,10 @@ rb_handle_cmdline (char **argv, int argc
 			
 		if (rb_uri_exists (tmp) == TRUE) {
 			GNOME_Rhythmbox_handleFile (shell, tmp, &ev);
-			grab_focus = TRUE;
 		}
 		
 		g_free (tmp);
-		
+		grab_focus = FALSE;
 	}
 	
 	if (quit == TRUE)
@@ -366,6 +383,9 @@ rb_handle_cmdline (char **argv, int argc
 		GNOME_Rhythmbox_quit (shell, &ev);
 	}
 
+	if (focus)
+		grab_focus = TRUE;
+
 	/* at the very least, we focus the window */
 	if (already_running == TRUE && grab_focus == TRUE)
 		GNOME_Rhythmbox_grabFocus (shell, &ev);
--- rhythmbox-0.6.1/rhythmbox.spec	2003-11-21 20:27:42.000000000 -0500
+++ rhythmbox-0.6.1.working/rhythmbox.spec	2003-12-09 10:54:31.000000000 -0500
@@ -8,10 +8,11 @@
 Name:		rhythmbox
 Summary:	Music Management Application 
 Version:	0.6.1
-Release:	1
+Release:	1b
 License:	GPL
 Group:		Applications/Multimedia
 Source:		%{name}-%{version}.tar.gz
+Patch0:		rhythmbox-fix-focus.patch
 BuildRoot:	%{_tmppath}/%{name}-%{version}-root
 Requires:	gtk2 >= %{gtk2_version}
 Requires:	libgnomeui >= %{libgnomeui_version}
@@ -32,6 +33,7 @@ most popular music formats, also support
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 


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