[xiph-commits] r11085 - in trunk/maemo/OggPlay: . src

mgrimme at svn.xiph.org mgrimme at svn.xiph.org
Sun Apr 2 10:17:26 PDT 2006


Author: mgrimme
Date: 2006-04-02 10:17:20 -0700 (Sun, 02 Apr 2006)
New Revision: 11085

Modified:
   trunk/maemo/OggPlay/ChangeLog
   trunk/maemo/OggPlay/src/gui.c
   trunk/maemo/OggPlay/src/gui.h
   trunk/maemo/OggPlay/src/main.c
   trunk/maemo/OggPlay/src/playlist.c
Log:
added clear button

Modified: trunk/maemo/OggPlay/ChangeLog
===================================================================
--- trunk/maemo/OggPlay/ChangeLog	2006-04-02 16:31:34 UTC (rev 11084)
+++ trunk/maemo/OggPlay/ChangeLog	2006-04-02 17:17:20 UTC (rev 11085)
@@ -1,5 +1,9 @@
 2006-04-02  Martin Grimme  <martin.grimme at lintegra.de>
 
+	* src/gui.c: Added button for clearing the playlist.
+
+2006-04-02  Martin Grimme  <martin.grimme at lintegra.de>
+
 	* src/*: Added playlist and playlist widget.
 	Added support for freedesktop.org compliant CD covers (.directory
 	files) as "albumart" can create them for instance.

Modified: trunk/maemo/OggPlay/src/gui.c
===================================================================
--- trunk/maemo/OggPlay/src/gui.c	2006-04-02 16:31:34 UTC (rev 11084)
+++ trunk/maemo/OggPlay/src/gui.c	2006-04-02 17:17:20 UTC (rev 11085)
@@ -127,6 +127,15 @@
 
 
 static void
+clear_cb(GtkWidget *src,
+	 Gui *gui) {
+
+  (gui->control_cb)(gui->control_cb_data, CLEAR);
+
+}
+
+
+static void
 prev_cb(GtkWidget *src,
 	Gui *gui) {
 
@@ -175,6 +184,7 @@
   PLWidget *plw;
   GtkWidget *toolbar;
   GtkToolItem *tb_open;
+  GtkToolItem *tb_clear;
   GtkToolItem *tb_prev;
   GtkToolItem *tb_next;
   GtkToolItem *tb_play;
@@ -234,12 +244,13 @@
   tb_prev = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PREVIOUS);
   tb_next = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_NEXT);
 
-  tb_open = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
+  tb_open = gtk_tool_button_new_from_stock(GTK_STOCK_ADD);
+  tb_clear = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
   gui->tb_play = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PLAY);
   tb_stop = gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_STOP);
 
   gui->seekbar = hildon_seekbar_new();
-  gtk_widget_set_size_request(gui->seekbar, 240, -1);
+  gtk_widget_set_size_request(gui->seekbar, 210, -1);
   tb_seekbar = gtk_tool_item_new();
   gtk_container_add(GTK_CONTAINER(tb_seekbar), gui->seekbar);
 
@@ -248,6 +259,7 @@
   gtk_container_add(GTK_CONTAINER(tb_timelabel), gui->timelabel);
 
   gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_open, -1);
+  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_clear, -1);
   gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_prev, -1);
   gtk_toolbar_insert(GTK_TOOLBAR(toolbar), gui->tb_play, -1);
   gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tb_stop, -1);
@@ -278,6 +290,9 @@
   g_signal_connect(G_OBJECT(tb_open), "clicked",
 		   G_CALLBACK(open_cb), gui);
 
+  g_signal_connect(G_OBJECT(tb_clear), "clicked",
+		   G_CALLBACK(clear_cb), gui);
+
   g_signal_connect(G_OBJECT(gui->tb_play), "clicked",
 		   G_CALLBACK(play_cb), gui);
 

Modified: trunk/maemo/OggPlay/src/gui.h
===================================================================
--- trunk/maemo/OggPlay/src/gui.h	2006-04-02 16:31:34 UTC (rev 11084)
+++ trunk/maemo/OggPlay/src/gui.h	2006-04-02 17:17:20 UTC (rev 11085)
@@ -48,7 +48,7 @@
 #define VOLUME_CB  void (*volume_cb)  (void *userdata, int volume)
 #define CONTROL_CB void (*control_cb) (void *userdata, int command)
 
-enum Command { PLAY, STOP, PREVIOUS, NEXT };
+enum Command { PLAY, STOP, PREVIOUS, NEXT, CLEAR };
 
 
 struct _Gui {

Modified: trunk/maemo/OggPlay/src/main.c
===================================================================
--- trunk/maemo/OggPlay/src/main.c	2006-04-02 16:31:34 UTC (rev 11084)
+++ trunk/maemo/OggPlay/src/main.c	2006-04-02 17:17:20 UTC (rev 11085)
@@ -160,11 +160,11 @@
 play_cb(AppData *appdata,
 	const char *uri) {
 
-  open_uri(appdata, uri);
-  //gui_set_title(appdata->gui,
-  //	appdata->decoder->tag_title,
-  //	appdata->decoder->tag_artist,
-  //	appdata->decoder->tag_album);
+  if (uri) {
+    open_uri(appdata, uri);
+  } else {
+    decoder_stop(appdata->decoder);
+  }
 
 }
 
@@ -241,6 +241,9 @@
     playlist_next(appdata->playlist);
     break;
 
+  case (CLEAR):
+    playlist_clear(appdata->playlist);
+
   default:
     break;
   }

Modified: trunk/maemo/OggPlay/src/playlist.c
===================================================================
--- trunk/maemo/OggPlay/src/playlist.c	2006-04-02 16:31:34 UTC (rev 11084)
+++ trunk/maemo/OggPlay/src/playlist.c	2006-04-02 17:17:20 UTC (rev 11085)
@@ -39,7 +39,7 @@
 void
 playlist_free(Playlist *pl) {
 
-  g_free(pl->list);
+  g_ptr_array_free(pl->list, TRUE);
   g_free(pl);
 
 }
@@ -48,7 +48,11 @@
 void
 playlist_clear(Playlist *pl) {
 
-  // TODO: IMPLEMENT
+  if (pl->list->len > 0) {
+    g_ptr_array_foreach (pl->list, g_free, NULL);
+    g_ptr_array_remove_range(pl->list, 0, pl->list->len);
+    (pl->change_cb)(pl->change_cb_data);
+  }
 
 }
 
@@ -84,10 +88,18 @@
   
   if (pl->list->len == 0) return;
 
-  pl->position = MIN(pl->list->len - 1, pl->position + 1);
-  uri = g_ptr_array_index(pl->list, pl->position);
-  (pl->play_cb)(pl->play_cb_data, uri);
+  if (pl->position == pl->list->len - 1) {
 
+    (pl->play_cb)(pl->play_cb_data, NULL);
+
+  } else {
+
+    pl->position = MIN(pl->list->len - 1, pl->position + 1);
+    uri = g_ptr_array_index(pl->list, pl->position);
+    (pl->play_cb)(pl->play_cb_data, uri);
+
+  }
+
 }
 
 



More information about the commits mailing list