Re: [Rhythmbox-devel] [patch] Show window when not visible



Hello,

So here is the patch I promised more than two weeks ago :)

This is just the trivial player stuff, discussion's welcome about more
advanced playlist/library handling, as Bastien started. But maybe this
can wait for rhythmdb.

I've added to Rhythmbox.idl :

+		
+		void playPause ();
+		void next ();
+		void previous ();
+		void stop ();
+		
+		boolean getShuffle ();
+		void setShuffle (in boolean shuffle);
 
+		boolean getRepeat ();
+		void setRepeat (in boolean repeat);
+		
+		boolean getVisibility ();
+		void setVisibility (in boolean visible);
+    
+
+		long getPlayingSongDuration ();
+		long getPlayingTime ();
+		void setPlayingTime (in long seconds);

and the following command line options to the shell :

--print-song-length
--print-play-time
--set-play-time

--play-pause
--stop
--previous
--next

Any comments ?

By the way, I have a totally unrelated question (sorry for the noise) :
is there an automated way of doing so nice changelog entries ? Google
did not help me much, and I am doubtful that these 50-line entries were
examined and written manually :)

Cheers,

Rached

On Tue, 2003-09-02 at 21:26, Colin Walters wrote:
> On Fri, 2003-08-29 at 07:02, Rached Ben Mustapha wrote:
> > Wow! I really suck at keeping my patches alive :)
> > 
> > In fact I even had it updated for the new behaviour (no need to hide
> > window, only show it), and I was thinking of a couple more things (like
> > getting/setting play time etc.).
> > 
> > How will the recent discussions about show/hide impact the bonobo
> > interface ?
> 
> Ah, now that show/hide has now been restored to its original behavior.
> 
> > I think I'll have some time to hack on it and sync it with the current
> > source this evening or this week-end - I'm still motivated :)
> 
> Nag, nag :)
> 
> Are you running into any trouble?  
> 
> People keep asking me about extending the Bonobo interface (for writing
> a gdesklet), and more commandline options for play/pause/next etc., so
> I'd really like to see this patch in :)
> 
> _______________________________________________
> rhythmbox-devel mailing list
> rhythmbox-devel@gnome.org
> http://mail.gnome.org/mailman/listinfo/rhythmbox-devel
> 
Index: corba/Rhythmbox.idl
===================================================================
RCS file: /cvs/gnome/rhythmbox/corba/Rhythmbox.idl,v
retrieving revision 1.2
diff -u -r1.2 Rhythmbox.idl
--- corba/Rhythmbox.idl	1 Sep 2003 04:20:19 -0000	1.2
+++ corba/Rhythmbox.idl	3 Sep 2003 20:05:43 -0000
@@ -12,9 +12,27 @@
 		void handleFile (in string uri);
 
 		void grabFocus ();
+		
+		void playPause ();
+		void next ();
+		void previous ();
+		void stop ();
+		
+		boolean getShuffle ();
+		void setShuffle (in boolean shuffle);
 
+		boolean getRepeat ();
+		void setRepeat (in boolean repeat);
+		
+		boolean getVisibility ();
+		void setVisibility (in boolean visible);
+    
 		string getPlayingTitle ();
 		string getPlayingPath ();
+
+		long getPlayingSongDuration (); /* returns -1 if no current song */
+		long getPlayingTime ();         /* returns -1 if not playing */
+		void setPlayingTime (in long seconds);
 	
 		void quit ();
 	};
Index: shell/main.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/main.c,v
retrieving revision 1.30
diff -u -r1.30 main.c
--- shell/main.c	3 Sep 2003 01:28:19 -0000	1.30
+++ shell/main.c	3 Sep 2003 20:05:43 -0000
@@ -59,6 +59,13 @@
 static gboolean no_registration = FALSE;
 static gboolean print_playing = FALSE;
 static gboolean print_playing_path = FALSE;
+static gboolean playpause       = FALSE;
+static gboolean stop            = FALSE;
+static gboolean previous        = FALSE;
+static gboolean next            = FALSE;
+static gboolean print_play_time = FALSE;
+static gboolean print_song_length = FALSE;
+static long seek_time           = 0;
 
 int
 main (int argc, char **argv)
@@ -70,8 +77,18 @@
 
 	const struct poptOption popt_options[] =
 	{
-		{ "print-playing",   0,  POPT_ARG_NONE,          &print_playing,                                  0, N_("Print the playing song and exit"),     NULL },
-		{ "print-playing-path", 0,  POPT_ARG_NONE,          &print_playing_path,                          0, N_("Print the playing song URI and exit"),     NULL },
+		{ "print-playing",	0,  POPT_ARG_NONE,          &print_playing,                                  0, N_("Print the playing song and exit"),     NULL },
+		{ "print-playing-path",	0,  POPT_ARG_NONE,          &print_playing_path,                          0, N_("Print the playing song URI and exit"),     NULL },
+        
+        { "print-song-length",	0,  POPT_ARG_NONE,			&print_song_length,		0, N_("Print the playing song length in seconds and exit"),	NULL },
+        { "print-play-time", 	0,  POPT_ARG_NONE,			&print_play_time,		0, N_("Print the current elapsed time of playing song and exit"),	NULL },
+        { "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 },
+		{ "stop",		        0,  POPT_ARG_NONE,			&stop,			        0, N_("Stop playing"),     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 },
+		
 		{ "debug",           'd',  POPT_ARG_NONE,          &debug,                                        0, N_("Enable debugging code"),     NULL },
 		{ "no-registration", 'n',  POPT_ARG_NONE,          &no_registration,                              0, N_("Do not register the shell"), NULL },
 		{ "quit",            'q',  POPT_ARG_NONE,          &quit,                                         0, N_("Quit Rhythmbox"),            NULL },
@@ -203,7 +220,7 @@
 {
 	GNOME_Rhythmbox shell;
 	int i;
-
+	gboolean grab_focus = TRUE;
 	shell = bonobo_activation_activate_from_id (RB_SHELL_OAFIID, 0, NULL, &ev);
 	if (shell == NULL)
 	{
@@ -215,9 +232,48 @@
 	}
 
 	if (print_playing)
+	{
 		printf ("%s\n", GNOME_Rhythmbox_getPlayingTitle (shell, &ev));
+		grab_focus = FALSE;
+	}
+	
 	if (print_playing_path)
+	{
 		printf ("%s\n", GNOME_Rhythmbox_getPlayingPath (shell, &ev));
+		grab_focus = FALSE;
+	}
+	
+	if (print_song_length)
+	{
+		long song_length = GNOME_Rhythmbox_getPlayingSongDuration (shell, &ev);
+		printf ("%ld\n", song_length);
+		grab_focus = FALSE;
+	}
+	
+	if (print_play_time)
+	{
+		long play_time = GNOME_Rhythmbox_getPlayingTime (shell, &ev);
+		printf ("%ld\n", play_time);
+		grab_focus = FALSE;
+	}
+	
+	if (seek_time > 0)
+	{
+		GNOME_Rhythmbox_setPlayingTime (shell, seek_time, &ev);
+		grab_focus = FALSE;
+	}
+	
+	if (playpause)
+		GNOME_Rhythmbox_playPause (shell, &ev);
+
+	if (stop)
+		GNOME_Rhythmbox_stop (shell, &ev);
+
+	if (previous)
+		GNOME_Rhythmbox_previous (shell, &ev);
+
+	if (next)
+		GNOME_Rhythmbox_next (shell, &ev);
 
 	for (i = 1; i < argc; i++)
 	{
@@ -225,10 +281,13 @@
 
 		tmp = rb_uri_resolve_relative (argv[i]);
 			
-		if (rb_uri_exists (tmp) == TRUE)
+		if (rb_uri_exists (tmp) == TRUE) {
 			GNOME_Rhythmbox_handleFile (shell, tmp, &ev);
-
+			grab_focus = TRUE;
+		}
+		
 		g_free (tmp);
+		
 	}
 	
 	if (quit == TRUE)
@@ -237,6 +296,6 @@
 	}
 
 	/* at the very least, we focus the window */
-	if (already_running == TRUE && !(print_playing_path || print_playing))
+	if (already_running == TRUE && grab_focus == TRUE)
 		GNOME_Rhythmbox_grabFocus (shell, &ev);
 }
Index: shell/rb-shell-player.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-shell-player.c,v
retrieving revision 1.82
diff -u -r1.82 rb-shell-player.c
--- shell/rb-shell-player.c	3 Sep 2003 01:28:19 -0000	1.82
+++ shell/rb-shell-player.c	3 Sep 2003 20:05:44 -0000
@@ -69,7 +69,6 @@
 					  guint prop_id,
 					  GValue *value,
 					  GParamSpec *pspec);
-static void rb_shell_player_do_previous (RBShellPlayer *player);
 static void rb_shell_player_cmd_previous (BonoboUIComponent *component,
 			                  RBShellPlayer *player,
 			                  const char *verbname);
@@ -82,7 +81,6 @@
 static void rb_shell_player_cmd_stop (BonoboUIComponent *component,
 			              RBShellPlayer *player,
 			              const char *verbname);
-static void rb_shell_player_do_next (RBShellPlayer *player);
 static void rb_shell_player_cmd_next (BonoboUIComponent *component,
 			              RBShellPlayer *player,
 			              const char *verbname);
@@ -794,7 +792,7 @@
 	rb_node_view_select_node (songs, rb_node_view_get_playing_node (songs));
 }
 
-static void
+void
 rb_shell_player_do_previous (RBShellPlayer *player)
 {
 	/* If we're in the first 2 seconds go to the previous song,
@@ -812,7 +810,7 @@
 	rb_shell_player_jump_to_current (player);
 }
 
-static void
+void
 rb_shell_player_do_next (RBShellPlayer *player)
 {
 	if (player->priv->source != NULL) {
@@ -1314,6 +1312,41 @@
 	return player->priv->mmplayer;
 }
 
+long
+rb_shell_player_get_playing_time (RBShellPlayer *player)
+{
+	g_return_val_if_fail (RB_IS_SHELL_PLAYER (player), 0);
+	
+	return monkey_media_player_get_time (player->priv->mmplayer);
+}
+
+void
+rb_shell_player_set_playing_time (RBShellPlayer *player, long time)
+{
+	g_return_if_fail (RB_IS_SHELL_PLAYER (player));
+	
+	if (monkey_media_player_seekable (player->priv->mmplayer))
+		monkey_media_player_set_time (player->priv->mmplayer, time);
+}
+
+long
+rb_shell_player_get_playing_song_duration (RBShellPlayer *player)
+{
+	RBNode *current_node;
+	
+	g_return_val_if_fail (RB_IS_SHELL_PLAYER (player), -1);
+	
+	current_node = rb_shell_player_get_playing_node (player);
+
+	if (current_node == NULL)
+	{
+		rb_debug ("Did not get playing node : return -1 as length");
+		return -1;
+	}
+	
+	return rb_node_get_property_long (current_node, RB_NODE_PROP_DURATION);
+}
+
 static void
 rb_shell_player_sync_with_selected_source (RBShellPlayer *player)
 {
Index: shell/rb-shell-player.h
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-shell-player.h,v
retrieving revision 1.18
diff -u -r1.18 rb-shell-player.h
--- shell/rb-shell-player.h	3 Sep 2003 01:28:19 -0000	1.18
+++ shell/rb-shell-player.h	3 Sep 2003 20:05:44 -0000
@@ -68,8 +68,13 @@
 void			rb_shell_player_jump_to_current (RBShellPlayer *player);
 
 void			rb_shell_player_playpause	(RBShellPlayer *player);
-
-void			rb_shell_player_stop		(RBShellPlayer *shell_player);
+void			rb_shell_player_stop		(RBShellPlayer *player);
+void			rb_shell_player_do_previous	(RBShellPlayer *player);
+void			rb_shell_player_do_next		(RBShellPlayer *player);
+
+long			rb_shell_player_get_playing_time (RBShellPlayer *player);
+void			rb_shell_player_set_playing_time (RBShellPlayer *player, long time);
+long			rb_shell_player_get_playing_song_duration (RBShellPlayer *player);
 
 void			rb_shell_player_set_shuffle	(RBShellPlayer *shell_player,
 							 gboolean shuffle);
Index: shell/rb-shell.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-shell.c,v
retrieving revision 1.183
diff -u -r1.183 rb-shell.c
--- shell/rb-shell.c	3 Sep 2003 01:28:19 -0000	1.183
+++ shell/rb-shell.c	3 Sep 2003 20:05:44 -0000
@@ -98,7 +98,30 @@
 						CORBA_Environment *ev);
 static char * rb_shell_corba_get_playing_path (PortableServer_Servant _servant,
 					       CORBA_Environment *ev);
-
+static CORBA_boolean rb_shell_corba_get_repeat (PortableServer_Servant _servant,
+					       CORBA_Environment *ev);
+static void rb_shell_corba_set_repeat (PortableServer_Servant _servant,
+					       CORBA_boolean repeat,
+					       CORBA_Environment *ev);
+static CORBA_boolean rb_shell_corba_get_shuffle (PortableServer_Servant _servant,
+					       CORBA_Environment *ev);
+static void rb_shell_corba_set_shuffle (PortableServer_Servant _servant,
+					       CORBA_boolean shuffle,
+					       CORBA_Environment *ev);
+static void rb_shell_corba_playpause (PortableServer_Servant _servant,
+					       CORBA_Environment *ev);
+static void rb_shell_corba_next (PortableServer_Servant _servant,
+					       CORBA_Environment *ev);
+static void rb_shell_corba_previous (PortableServer_Servant _servant,
+					       CORBA_Environment *ev);
+static void rb_shell_corba_stop (PortableServer_Servant _servant,
+					       CORBA_Environment *ev);
+static CORBA_long rb_shell_corba_get_playing_song_duration (PortableServer_Servant _servant,
+						   CORBA_Environment *ev);
+static CORBA_long rb_shell_corba_get_playing_time (PortableServer_Servant _servant,
+						   CORBA_Environment *ev);
+static void rb_shell_corba_set_playing_time (PortableServer_Servant _servant,
+						   CORBA_long time, CORBA_Environment *ev);
 void rb_shell_handle_playlist_entry (RBShell *shell, GList *locations, const char *title,
 				     const char *genre);
 static gboolean rb_shell_window_state_cb (GtkWidget *widget,
@@ -332,6 +355,17 @@
 	epv->grabFocus    = rb_shell_corba_grab_focus;
 	epv->getPlayingTitle = rb_shell_corba_get_playing_title;
 	epv->getPlayingPath = rb_shell_corba_get_playing_path;
+	epv->playPause = rb_shell_corba_playpause;
+	epv->previous = rb_shell_corba_previous;
+	epv->next = rb_shell_corba_next;
+	epv->stop = rb_shell_corba_stop;
+	epv->getShuffle = rb_shell_corba_get_shuffle;
+	epv->setShuffle = rb_shell_corba_set_shuffle;
+	epv->getRepeat = rb_shell_corba_get_repeat;
+	epv->setRepeat = rb_shell_corba_set_repeat;
+	epv->getPlayingSongDuration = rb_shell_corba_get_playing_song_duration;
+	epv->getPlayingTime = rb_shell_corba_get_playing_time;
+	epv->setPlayingTime = rb_shell_corba_set_playing_time;
 }
 
 static void
@@ -522,6 +556,93 @@
 	return ret;
 }
 
+static void
+rb_shell_corba_set_shuffle (PortableServer_Servant _servant,
+				 CORBA_boolean shuffle,
+				 CORBA_Environment *ev)
+{
+	eel_gconf_set_boolean(CONF_STATE_SHUFFLE, shuffle);
+}
+
+static CORBA_boolean
+rb_shell_corba_get_shuffle (PortableServer_Servant _servant,
+				 CORBA_Environment *ev)
+{
+	
+	return eel_gconf_get_boolean(CONF_STATE_SHUFFLE);
+}
+
+static void
+rb_shell_corba_set_repeat (PortableServer_Servant _servant,
+				 CORBA_boolean repeat,
+				 CORBA_Environment *ev)
+{
+	eel_gconf_set_boolean(CONF_STATE_REPEAT, repeat);
+}
+
+static CORBA_boolean
+rb_shell_corba_get_repeat (PortableServer_Servant _servant,
+				 CORBA_Environment *ev)
+{
+	return eel_gconf_get_boolean(CONF_STATE_REPEAT);
+}
+
+static void
+rb_shell_corba_playpause (PortableServer_Servant _servant,
+				 CORBA_Environment *ev)
+{
+	RBShell *shell = RB_SHELL (bonobo_object (_servant));
+	rb_shell_player_playpause (shell->priv->player_shell);
+}
+
+static void
+rb_shell_corba_next (PortableServer_Servant _servant,
+				 CORBA_Environment *ev)
+{
+	RBShell *shell = RB_SHELL (bonobo_object (_servant));
+	rb_shell_player_do_next (shell->priv->player_shell);
+}
+
+static void
+rb_shell_corba_previous (PortableServer_Servant _servant,
+				 CORBA_Environment *ev)
+{
+	RBShell *shell = RB_SHELL (bonobo_object (_servant));
+	rb_shell_player_do_previous (shell->priv->player_shell);
+}
+
+static void
+rb_shell_corba_stop (PortableServer_Servant _servant,
+				 CORBA_Environment *ev)
+{
+	RBShell *shell = RB_SHELL (bonobo_object (_servant));
+	rb_shell_player_set_playing_source (shell->priv->player_shell, NULL);
+}
+
+static CORBA_long
+rb_shell_corba_get_playing_song_duration (PortableServer_Servant _servant,
+                     CORBA_Environment *ev)
+{
+	RBShell *shell = RB_SHELL (bonobo_object (_servant));
+	return rb_shell_player_get_playing_song_duration (shell->priv->player_shell);
+}
+
+static CORBA_long
+rb_shell_corba_get_playing_time (PortableServer_Servant _servant,
+                     CORBA_Environment *ev)
+{
+	RBShell *shell = RB_SHELL (bonobo_object (_servant));
+	return rb_shell_player_get_playing_time (shell->priv->player_shell);
+}
+
+static void
+rb_shell_corba_set_playing_time (PortableServer_Servant _servant,
+                     CORBA_long time, CORBA_Environment *ev)
+{
+	RBShell *shell = RB_SHELL (bonobo_object (_servant));
+	rb_shell_player_set_playing_time (shell->priv->player_shell, time);
+}
+
 static gboolean
 async_library_release_brakes (RBShell *shell)
 {
@@ -565,7 +686,7 @@
 	g_signal_connect (G_OBJECT (win), "delete_event",
 			  G_CALLBACK (rb_shell_window_delete_cb),
 			  shell);
-
+  
 	rb_debug ("shell: creating container area");
 	shell->priv->container = bonobo_window_get_ui_container (win);
 


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