You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(132) |
Dec
(135) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(87) |
Feb
(82) |
Mar
(117) |
Apr
(108) |
May
(231) |
Jun
(265) |
Jul
(31) |
Aug
(32) |
Sep
(89) |
Oct
(50) |
Nov
(112) |
Dec
(92) |
2007 |
Jan
(136) |
Feb
(82) |
Mar
(66) |
Apr
(104) |
May
(74) |
Jun
(103) |
Jul
(50) |
Aug
(23) |
Sep
(22) |
Oct
(39) |
Nov
(56) |
Dec
(88) |
2008 |
Jan
(51) |
Feb
(6) |
Mar
(6) |
Apr
(9) |
May
(39) |
Jun
(24) |
Jul
(48) |
Aug
(40) |
Sep
(9) |
Oct
(21) |
Nov
(12) |
Dec
(31) |
2009 |
Jan
(68) |
Feb
(14) |
Mar
(29) |
Apr
(40) |
May
(27) |
Jun
(9) |
Jul
(1) |
Aug
(10) |
Sep
(3) |
Oct
(7) |
Nov
(11) |
Dec
(165) |
2010 |
Jan
(72) |
Feb
(49) |
Mar
(30) |
Apr
(41) |
May
(17) |
Jun
(13) |
Jul
(99) |
Aug
(88) |
Sep
(59) |
Oct
(23) |
Nov
(11) |
Dec
(44) |
2011 |
Jan
(50) |
Feb
(28) |
Mar
(27) |
Apr
(18) |
May
(38) |
Jun
(5) |
Jul
(59) |
Aug
(7) |
Sep
(44) |
Oct
(12) |
Nov
(7) |
Dec
(10) |
2012 |
Jan
(8) |
Feb
(11) |
Mar
(17) |
Apr
(11) |
May
(3) |
Jun
(11) |
Jul
(26) |
Aug
(3) |
Sep
|
Oct
(17) |
Nov
(9) |
Dec
(1) |
2013 |
Jan
|
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: phantomjinx <pha...@us...> - 2011-09-08 20:09:18
|
commit 26bf8ba2b094a85c2b02be963e4470ef90bd600f Author: Matteo F. Vescovi <m.v...@re...> Date: Wed Sep 7 20:15:00 2011 +0200 version.sh: update unstable builds separator Signed-off-by: Matteo F. Vescovi <m.v...@re...> version.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) --- diff --git a/version.sh b/version.sh index 12f6c53..9434c8c 100755 --- a/version.sh +++ b/version.sh @@ -4,7 +4,7 @@ if [ -d .git ]; then COMMIT=`git rev-parse --short HEAD` # Use this line for unstable dev builds - REVISION="2.1.1.${COMMIT}" + REVISION="2.1.1~${COMMIT}" # Use this line for releases #REVISION="2.1.1" |
From: phantomjinx <pha...@us...> - 2011-09-08 20:07:33
|
commit f885a686e014aafea5568436efb7e78ba15b73b4 Author: Matteo F. Vescovi <m.v...@re...> Date: Wed Sep 7 20:14:59 2011 +0200 version.sh: update unstable builds separator Signed-off-by: Matteo F. Vescovi <m.v...@re...> version.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) --- diff --git a/version.sh b/version.sh index e08bbad..871d00d 100755 --- a/version.sh +++ b/version.sh @@ -4,7 +4,7 @@ if [ -d .git ]; then COMMIT=`git rev-parse --short HEAD` # Use this line for unstable dev builds - REVISION="2.0.3.${COMMIT}" + REVISION="2.0.3~${COMMIT}" # Use this line for releases #REVISION="2.0.3" |
From: phantomjinx <pha...@us...> - 2011-09-04 22:21:15
|
commit 533666aef411172a51ed02561fb6a71fbdbc1aa0 Author: phantomjinx <p.g...@ph...> Date: Sun Sep 4 23:17:17 2011 +0100 Support for updating clarity when a track is modified * When a track has its meta-data changed then this should update the display according to the correct affect of the change, eg. no effect is unrelated to the album key, move the track to a new album etc.. * album_model.* * remove_track function should not need to refind the relevant album item when in fact it has already been found and could be passed in as a parameter * it is not an error for the _get_index function to fail to find a key so return -1 in an if condition rather than using g_return... * search_for_track function simply iterates through all album items in an attempt to find the given track. Long winded and slow but necessary if a track has sufficiently changed to make looking it up in the index impossible * claritiy_canvas.c * Need to ensure that like the remove function, the covers are refreshed. The animate function provides this perfectly. * clarity_widget.c * Separate out _add and _remove functions as both used by respective callbacks and by the track_updated callback. * Given we already know the album item in _remove function it is unnecessary to find it again so pass it in as a parameter. * Completion of track_updated callback. plugins/clarity/album_model.c | 28 +++++++- plugins/clarity/album_model.h | 3 +- plugins/clarity/clarity_canvas.c | 2 + plugins/clarity/clarity_widget.c | 126 ++++++++++++++++++++++++++++++++----- 4 files changed, 137 insertions(+), 22 deletions(-) --- diff --git a/plugins/clarity/album_model.c b/plugins/clarity/album_model.c index 821ba40..2779f6a 100644 --- a/plugins/clarity/album_model.c +++ b/plugins/clarity/album_model.c @@ -274,14 +274,14 @@ gboolean album_model_add_track(AlbumModel *model, Track *track) { return _insert_track(priv, track); } -gboolean album_model_remove_track(AlbumModel *model, Track *track) { +gboolean album_model_remove_track(AlbumModel *model, AlbumItem *item, Track *track) { g_return_val_if_fail(model, -1); + g_return_val_if_fail(item, -1); g_return_val_if_fail(track, -1); AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE(model); - AlbumItem *item = album_model_get_item_with_track(model, track); - if (!item || !item->tracks) { + if (!item->tracks) { return FALSE; } @@ -345,7 +345,8 @@ static gint _get_index(AlbumModelPrivate *priv, gchar *trk_key) { GList *key_list = priv->album_key_list; GList *key = g_list_find_custom(key_list, trk_key, (GCompareFunc) _compare_album_keys); - g_return_val_if_fail (key, -1); + if (!key) + return -1; gint index = g_list_position(key_list, key); @@ -384,4 +385,23 @@ gint album_model_get_size(AlbumModel *model) { return g_list_length(priv->album_key_list); } +AlbumItem *album_model_search_for_track(AlbumModel *model, Track *track) { + g_return_val_if_fail(model, NULL); + g_return_val_if_fail(track, NULL); + + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); + GList *album_items = g_hash_table_get_values(priv->album_hash); + while (album_items) { + AlbumItem *item = album_items->data; + + if (g_list_index(item->tracks, track) > -1) { + return item; + } + + album_items = album_items->next; + } + + return NULL; +} + #endif /* ALBUM_MODEL_C_ */ diff --git a/plugins/clarity/album_model.h b/plugins/clarity/album_model.h index 8e20fa8..00acc8b 100644 --- a/plugins/clarity/album_model.h +++ b/plugins/clarity/album_model.h @@ -105,7 +105,7 @@ gboolean album_model_add_track(AlbumModel *model, Track *track); * @return gboolean: whether an album model was removed. * */ -gboolean album_model_remove_track(AlbumModel *model, Track *track); +gboolean album_model_remove_track(AlbumModel *model, AlbumItem *item, Track *track); AlbumItem *album_model_get_item_with_index(AlbumModel *model, gint index); @@ -119,5 +119,6 @@ gint album_model_get_size(AlbumModel *model); gint compare_tracks(Track *a, Track *b); +AlbumItem *album_model_search_for_track(AlbumModel *model, Track *track); #endif /* ALBUM_MODEL_H_ */ diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c index bb42a68..26b86fe 100644 --- a/plugins/clarity/clarity_canvas.c +++ b/plugins/clarity/clarity_canvas.c @@ -641,6 +641,8 @@ void clarity_canvas_add_album_item(ClarityCanvas *self, AlbumItem *item) { _init_album_item(item, index, self); + _animate_indices(priv, 0, 0); + _set_loading_complete(priv, TRUE); } diff --git a/plugins/clarity/clarity_widget.c b/plugins/clarity/clarity_widget.c index 6981216..ca50d74 100644 --- a/plugins/clarity/clarity_widget.c +++ b/plugins/clarity/clarity_widget.c @@ -67,9 +67,6 @@ enum { * * popup menu * drag n drop - * track added - * track removed - * track updated * set cover from file */ @@ -458,6 +455,19 @@ void clarity_widget_tracks_selected_cb(GtkPodApp *app, gpointer tks, gpointer da gtk_range_set_value(GTK_RANGE (priv->cdslider), album_index); } +static void _add_track(ClarityWidgetPrivate *priv, Track *track) { + ClarityCanvas *ccanvas = CLARITY_CANVAS(priv->draw_area); + + if (clarity_canvas_is_loading(ccanvas)) + return; + + if (album_model_add_track(priv->album_model, track)) { + AlbumItem *item = album_model_get_item_with_track(priv->album_model, track); + clarity_canvas_add_album_item(CLARITY_CANVAS(priv->draw_area), item); + _init_slider_range(priv); + } +} + void clarity_widget_track_added_cb(GtkPodApp *app, gpointer tk, gpointer data) { g_return_if_fail(CLARITY_IS_WIDGET(data)); @@ -475,16 +485,29 @@ void clarity_widget_track_added_cb(GtkPodApp *app, gpointer tk, gpointer data) { return; } + _add_track(priv, track); +} + +static void _remove_track(ClarityWidgetPrivate *priv, AlbumItem *item, Track *track) { + g_return_if_fail(priv); + ClarityCanvas *ccanvas = CLARITY_CANVAS(priv->draw_area); if (clarity_canvas_is_loading(ccanvas)) return; - if (album_model_add_track(priv->album_model, track)) { - AlbumItem *item = album_model_get_item_with_track(priv->album_model, track); - clarity_canvas_add_album_item(CLARITY_CANVAS(priv->draw_area), item); - _init_slider_range(priv); + if(!item) + return; + + if(g_list_length(item->tracks) == 1) { + // Last track in album item so remove canvas cover first + clarity_canvas_remove_album_item(CLARITY_CANVAS(priv->draw_area), item); } + + // Remove the track from the model + album_model_remove_track(priv->album_model, item, track); + + _init_slider_range(priv); } void clarity_widget_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer data) { @@ -498,23 +521,92 @@ void clarity_widget_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer data) if (!track) return; + AlbumItem *item = album_model_get_item_with_track(priv->album_model, track); + + _remove_track(priv, item, track); +} + +void clarity_widget_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data) { + g_return_if_fail(CLARITY_IS_WIDGET(data)); + + ClarityWidget *cw = CLARITY_WIDGET(data); + ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(cw); + Track *track = tk; + + if (!track) + return; + ClarityCanvas *ccanvas = CLARITY_CANVAS(priv->draw_area); if (clarity_canvas_is_loading(ccanvas)) return; - AlbumItem *item = album_model_get_item_with_track(priv->album_model, track); - if(g_list_length(item->tracks) == 1) { - // Last track in album item so remove canvas cover first - clarity_canvas_remove_album_item(CLARITY_CANVAS(priv->draw_area), item); - } + AlbumItem *item; + gboolean findremove = FALSE; - // Remove the track from the model - album_model_remove_track(priv->album_model, track); + gint index = album_model_get_index_with_track(priv->album_model, track); + if (index == -1) { + /* The track's key could not be found according to the track! + * The ONLY way this could happen is if the user changed the + * components of the track's key. Well it should be rare but the only + * way to remove it from its "old" album item is to search each one + */ + findremove = TRUE; + } + else { + /* Track has a valid key so can get the album back. + * Either has happened: + * a) Artist/Album key has been changed so the track is being moved + * to another existing album + * b) Some other change has occurred that is irrelevant to this code. + * + * To determine if a) is the case need to determine whether track exists + * in the album items track list. If it does then b) is true and nothing + * more is required. + */ + item = album_model_get_item_with_track(priv->album_model, track); + g_return_if_fail (item); + + index = g_list_index(item->tracks, track); + if (index != -1) { + /* Track exists in the album list so ignore the change and return */ + ExtraTrackData *etd; + etd = track->userdata; + if (etd->tartwork_changed == TRUE) { + etd->tartwork_changed = FALSE; + } + + return; + } + else { + /* Track does not exist in the album list so the artist/album + * key has definitely changed */ + findremove = TRUE; + } + } - _init_slider_range(priv); + if (findremove) { + /* It has been determined that the track has had its key changed + * and thus a search must be performed to find the "original" album + * that the track belonged to, remove it then add the track to the + * new album. + */ + item = album_model_search_for_track(priv->album_model, track); + /* item represents the album item containing the track */ + if (item) { + g_warning("Item %s %s", item->albumname, item->artist); + + /* The track is in this album so remove it in preparation for + * readding under the new album key + */ + _remove_track(priv, item, track); + } + + /* Create a new album item or find existing album to house the + * "brand new" track + */ + _add_track(priv, track); + } } -void clarity_widget_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data) {} - |
From: phantomjinx <pha...@us...> - 2011-09-04 22:21:08
|
commit 89cea74c669463eb8e3add95d6439515006f340a Author: phantomjinx <p.g...@ph...> Date: Sun Sep 4 13:08:59 2011 +0100 Update version to reflect for unstable builds version.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) --- diff --git a/version.sh b/version.sh index 0386123..12f6c53 100755 --- a/version.sh +++ b/version.sh @@ -4,10 +4,10 @@ if [ -d .git ]; then COMMIT=`git rev-parse --short HEAD` # Use this line for unstable dev builds - REVISION="2.1.0.${COMMIT}" + REVISION="2.1.1.${COMMIT}" # Use this line for releases - #REVISION="2.1.0" + #REVISION="2.1.1" echo $REVISION > version fi |
From: phantomjinx <pha...@us...> - 2011-09-04 12:16:34
|
commit 3a994cd81f2c780da74120e6d007291a63c5e358 Author: phantomjinx <p.g...@ph...> Date: Sun Sep 4 13:08:59 2011 +0100 Update version to reflect for unstable builds version.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) --- diff --git a/version.sh b/version.sh index f32f70e..e08bbad 100755 --- a/version.sh +++ b/version.sh @@ -4,10 +4,10 @@ if [ -d .git ]; then COMMIT=`git rev-parse --short HEAD` # Use this line for unstable dev builds - REVISION="2.0.2.${COMMIT}" + REVISION="2.0.3.${COMMIT}" # Use this line for releases - #REVISION="2.0.2" + #REVISION="2.0.3" echo $REVISION > version fi |
From: phantomjinx <pha...@us...> - 2011-09-04 12:11:57
|
commit 61d59470b36e67c79b88310e068a65aa7d652939 Author: phantomjinx <p.g...@ph...> Date: Sun Sep 4 13:08:59 2011 +0100 Update version to reflect for unstable builds version.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) --- diff --git a/version.sh b/version.sh index 0386123..12f6c53 100755 --- a/version.sh +++ b/version.sh @@ -4,10 +4,10 @@ if [ -d .git ]; then COMMIT=`git rev-parse --short HEAD` # Use this line for unstable dev builds - REVISION="2.1.0.${COMMIT}" + REVISION="2.1.1.${COMMIT}" # Use this line for releases - #REVISION="2.1.0" + #REVISION="2.1.1" echo $REVISION > version fi |
From: phantomjinx <pha...@us...> - 2011-09-03 21:54:27
|
commit 1940ff5e0fafd3d996c1bf7061ef512e8f7275c2 Author: phantomjinx <p.g...@ph...> Date: Sat Sep 3 22:48:27 2011 +0100 Clarity text not being cleared * The title and artist text actors are not being cleared by the canvas clear functions. plugins/clarity/clarity_canvas.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) --- diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c index 015775f..bb42a68 100644 --- a/plugins/clarity/clarity_canvas.c +++ b/plugins/clarity/clarity_canvas.c @@ -292,6 +292,12 @@ void clarity_canvas_clear(ClarityCanvas *self) { clutter_container_remove(CLUTTER_CONTAINER(priv->container), CLUTTER_ACTOR(ccover), NULL); iter = iter->next; } + + if (CLUTTER_IS_ACTOR(priv->artist_text)) + clutter_text_set_text(CLUTTER_TEXT(priv->artist_text), ""); + + if (CLUTTER_IS_ACTOR(priv->title_text)) + clutter_text_set_text(CLUTTER_TEXT(priv->title_text), ""); } priv->covers = NULL; |
From: phantomjinx <pha...@us...> - 2011-09-03 21:52:49
|
commit d02573e74f81b2748f5e10906640efc62f7ee700 Author: phantomjinx <p.g...@ph...> Date: Sat Sep 3 22:47:04 2011 +0100 Mistake in track plugin default preferences * Wrong logic on the conditions for setting the default values of the sort preferences. plugins/track_display/plugin.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) --- diff --git a/plugins/track_display/plugin.c b/plugins/track_display/plugin.c index 3d168df..8d24f87 100644 --- a/plugins/track_display/plugin.c +++ b/plugins/track_display/plugin.c @@ -85,13 +85,13 @@ static void set_default_preferences() { prefs_set_string("sm_sort_", NULL); } - if (prefs_get_int_value("tm_autostore", NULL)) + if (!prefs_get_int_value("tm_autostore", NULL)) prefs_set_int("tm_autostore", FALSE); - if (prefs_get_int_value("tm_sortcol", NULL)) + if (!prefs_get_int_value("tm_sortcol", NULL)) prefs_set_int("tm_sortcol", TM_COLUMN_TITLE); - if (prefs_get_int_value("tm_sort", NULL)) + if (!prefs_get_int_value("tm_sort", NULL)) prefs_set_int("tm_sort", SORT_NONE); } |
From: phantomjinx <pha...@us...> - 2011-09-02 22:32:08
|
commit f8bf1e9fdce95d3c51011afc46115fb0e1e8a2e2 Author: phantomjinx <p.g...@ph...> Date: Fri Sep 2 23:29:17 2011 +0100 Support for track removal in Clarity * Handle the updating of clarity display when a track is removed from the current playlist. Essentially removes the cover if the last track and removes it from the album model. * gp_itdb.c * Seems we are signalling track removal twice unnecessarily * clarity_canvas.c * Most of the initialisation of covers is only done for the visible ones. Not setting the position causes other covers to lie below the original visible covers and looks odd. Set the position of all covers. libgtkpod/gp_itdb.c | 2 - plugins/clarity/album_model.c | 30 ++++++++++++++++++++++ plugins/clarity/album_model.h | 8 ++++++ plugins/clarity/clarity_canvas.c | 50 +++++++++++++++++++++++++++++++------ plugins/clarity/clarity_canvas.h | 2 + plugins/clarity/clarity_cover.c | 4 +- plugins/clarity/clarity_cover.h | 2 + plugins/clarity/clarity_widget.c | 29 +++++++++++++++++++++- 8 files changed, 114 insertions(+), 13 deletions(-) --- diff --git a/libgtkpod/gp_itdb.c b/libgtkpod/gp_itdb.c index b95847e..6e5d54e 100644 --- a/libgtkpod/gp_itdb.c +++ b/libgtkpod/gp_itdb.c @@ -551,8 +551,6 @@ void gp_playlist_remove_track(Playlist *plitem, Track *track, DeleteAction delet g_return_if_fail (plitem); - gtkpod_track_removed(track); - /* remove track from playlist */ itdb_playlist_remove_track(plitem, track); diff --git a/plugins/clarity/album_model.c b/plugins/clarity/album_model.c index cab5e41..821ba40 100644 --- a/plugins/clarity/album_model.c +++ b/plugins/clarity/album_model.c @@ -274,6 +274,36 @@ gboolean album_model_add_track(AlbumModel *model, Track *track) { return _insert_track(priv, track); } +gboolean album_model_remove_track(AlbumModel *model, Track *track) { + g_return_val_if_fail(model, -1); + g_return_val_if_fail(track, -1); + + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE(model); + + AlbumItem *item = album_model_get_item_with_track(model, track); + if (!item || !item->tracks) { + return FALSE; + } + + item->tracks = g_list_remove(item->tracks, track); + + if (g_list_length(item->tracks) == 0) { + // Remove the album item + + gint index = album_model_get_index_with_album_item(model, item); + gchar *album_key = g_list_nth_data(priv->album_key_list, index); + + priv->album_key_list = g_list_remove(priv->album_key_list, album_key); + + g_hash_table_remove(priv->album_hash, item); + + g_free(album_key); + return TRUE; + } + + return FALSE; +} + void album_model_foreach (AlbumModel *model, AMFunc func, gpointer user_data) { g_return_if_fail(model); g_return_if_fail(func); diff --git a/plugins/clarity/album_model.h b/plugins/clarity/album_model.h index d91868d..8e20fa8 100644 --- a/plugins/clarity/album_model.h +++ b/plugins/clarity/album_model.h @@ -99,6 +99,14 @@ void album_model_add_tracks(AlbumModel *model, GList *tracks); */ gboolean album_model_add_track(AlbumModel *model, Track *track); +/** + * Remove a single track from the album model. + * + * @return gboolean: whether an album model was removed. + * + */ +gboolean album_model_remove_track(AlbumModel *model, Track *track); + AlbumItem *album_model_get_item_with_index(AlbumModel *model, gint index); AlbumItem *album_model_get_item_with_track(AlbumModel *model, Track *track); diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c index 8baa2e8..015775f 100644 --- a/plugins/clarity/clarity_canvas.c +++ b/plugins/clarity/clarity_canvas.c @@ -400,13 +400,18 @@ static gboolean _create_cover_actors(ClarityCanvasPrivate *priv, AlbumItem *albu clarity_cover_set_album_item(ccover, album_item); + gint pos = _calculate_index_distance(index); + clutter_actor_set_position( + CLUTTER_ACTOR(ccover), + pos - clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, + 110 - clutter_actor_get_height(CLUTTER_ACTOR(ccover))); + if((priv->curr_index + VISIBLE_ITEMS < index) || (priv->curr_index - VISIBLE_ITEMS > index)) { _set_loading_complete(priv, TRUE); return FALSE; } - gint pos = _calculate_index_distance(index); float scale = _calculate_index_scale(index); gint angle; @@ -420,11 +425,6 @@ static gboolean _create_cover_actors(ClarityCanvasPrivate *priv, AlbumItem *albu clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, 0, 0); - clutter_actor_set_position( - CLUTTER_ACTOR(ccover), - pos - clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, - 110 - clutter_actor_get_height(CLUTTER_ACTOR(ccover))); - clutter_actor_set_scale_full( CLUTTER_ACTOR(ccover), scale, @@ -453,6 +453,24 @@ void _init_album_item(gpointer value, gint index, gpointer user_data) { _create_cover_actors(priv, item, index); } +void _destroy_cover(ClarityCanvas *cc, gint index) { + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(cc); + + ClarityCover *ccover = (ClarityCover *) g_list_nth_data(priv->covers, index); + if (!ccover) + return; + + priv->covers = g_list_remove(priv->covers, ccover); + + clutter_container_remove_actor( + CLUTTER_CONTAINER(priv->container), + CLUTTER_ACTOR(ccover)); + + clarity_cover_destroy(CLUTTER_ACTOR(ccover)); + + return; +} + static gpointer _init_album_model(gpointer data) { g_return_val_if_fail(CLARITY_IS_CANVAS(data), NULL); @@ -489,7 +507,7 @@ static void _clear_rotation_behaviours(GList *covers) { } } -static void _animate_indices(ClarityCanvasPrivate *priv, enum DIRECTION direction, gint increment) { +static void _animate_indices(ClarityCanvasPrivate *priv, gint direction, gint increment) { for (gint i = 0; i < g_list_length(priv->covers); ++i) { @@ -521,7 +539,7 @@ static void _animate_indices(ClarityCanvasPrivate *priv, enum DIRECTION directio "scale-y", depth, "scale-center-x" , clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, "scale-center-y" , clutter_actor_get_height(CLUTTER_ACTOR(ccover)) / 2, - "x", pos - clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2 , + "x", pos - clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, NULL); } } @@ -619,3 +637,19 @@ void clarity_canvas_add_album_item(ClarityCanvas *self, AlbumItem *item) { _set_loading_complete(priv, TRUE); } + +void clarity_canvas_remove_album_item(ClarityCanvas *self, AlbumItem *item) { + g_return_if_fail(self); + g_return_if_fail(item); + + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + gint index = album_model_get_index_with_album_item(priv->model, item); + + _set_loading_complete(priv, FALSE); + + _destroy_cover(self, index); + + _animate_indices(priv, 0, 0); + + _set_loading_complete(priv, TRUE); +} diff --git a/plugins/clarity/clarity_canvas.h b/plugins/clarity/clarity_canvas.h index 4b20e8d..3a1a691 100644 --- a/plugins/clarity/clarity_canvas.h +++ b/plugins/clarity/clarity_canvas.h @@ -90,6 +90,8 @@ gboolean clarity_canvas_is_loading(ClarityCanvas *self); void clarity_canvas_add_album_item(ClarityCanvas *self, AlbumItem *item); +void clarity_canvas_remove_album_item(ClarityCanvas *self, AlbumItem *item); + G_END_DECLS #endif /* CLARITY_CANVAS_H_ */ diff --git a/plugins/clarity/clarity_cover.c b/plugins/clarity/clarity_cover.c index 074dc43..d5d44e6 100644 --- a/plugins/clarity/clarity_cover.c +++ b/plugins/clarity/clarity_cover.c @@ -99,7 +99,7 @@ static void clarity_cover_finalize(GObject *gobject) { * implementation destroy any actors they are composed from; * in this case, we just destroy the child ClutterBox */ -static void clarity_cover_destroy(ClutterActor *self) { +void clarity_cover_destroy(ClutterActor *self) { ClarityCoverPrivate *priv = CLARITY_COVER_GET_PRIVATE(self); if (priv) { @@ -114,7 +114,7 @@ static void clarity_cover_destroy(ClutterActor *self) { } if (G_IS_OBJECT(priv->rotateBehaviour)) - g_object_unref(priv->rotateBehaviour); + priv->rotateBehaviour = NULL; } /* chain up to destroy() on the parent ClutterActorClass; diff --git a/plugins/clarity/clarity_cover.h b/plugins/clarity/clarity_cover.h index ee6542b..8b8f18b 100644 --- a/plugins/clarity/clarity_cover.h +++ b/plugins/clarity/clarity_cover.h @@ -108,4 +108,6 @@ gchar *clarity_cover_get_artist(ClarityCover *self); /* constructor - note this returns a ClutterActor instance */ ClarityCover *clarity_cover_new (void); +void clarity_cover_destroy(ClutterActor *self); + #endif /* CLARITY_COVER_H_ */ diff --git a/plugins/clarity/clarity_widget.c b/plugins/clarity/clarity_widget.c index c549ccc..6981216 100644 --- a/plugins/clarity/clarity_widget.c +++ b/plugins/clarity/clarity_widget.c @@ -487,7 +487,34 @@ void clarity_widget_track_added_cb(GtkPodApp *app, gpointer tk, gpointer data) { } } -void clarity_widget_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer data) {} +void clarity_widget_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer data) { + g_return_if_fail(CLARITY_IS_WIDGET(data)); + + ClarityWidget *cw = CLARITY_WIDGET(data); + ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(cw); + Track *track = tk; + + + if (!track) + return; + + ClarityCanvas *ccanvas = CLARITY_CANVAS(priv->draw_area); + + if (clarity_canvas_is_loading(ccanvas)) + return; + + AlbumItem *item = album_model_get_item_with_track(priv->album_model, track); + if(g_list_length(item->tracks) == 1) { + // Last track in album item so remove canvas cover first + clarity_canvas_remove_album_item(CLARITY_CANVAS(priv->draw_area), item); + } + + // Remove the track from the model + album_model_remove_track(priv->album_model, track); + + _init_slider_range(priv); +} + void clarity_widget_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data) {} |
From: phantomjinx <pha...@us...> - 2011-09-02 22:32:01
|
commit 50b3e6dbb35a886e9bfe331a0b2b36e1b88ca0d9 Author: phantomjinx <p.g...@ph...> Date: Thu Sep 1 21:33:04 2011 +0100 Remove extraneous logging plugins/clarity/clarity_canvas.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) --- diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c index 837822c..8baa2e8 100644 --- a/plugins/clarity/clarity_canvas.c +++ b/plugins/clarity/clarity_canvas.c @@ -383,8 +383,6 @@ static void _set_loading_complete(ClarityCanvasPrivate *priv, gboolean value) { if (value) { _update_text(priv); } - - g_warning("Loading complete = %d", priv->loading_complete); } static gboolean _create_cover_actors(ClarityCanvasPrivate *priv, AlbumItem *album_item, gint index) { @@ -404,7 +402,6 @@ static gboolean _create_cover_actors(ClarityCanvasPrivate *priv, AlbumItem *albu if((priv->curr_index + VISIBLE_ITEMS < index) || (priv->curr_index - VISIBLE_ITEMS > index)) { - g_warning("Not creating anything more"); _set_loading_complete(priv, TRUE); return FALSE; } |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:55
|
commit 4d91390c29bca549e668c4c25879ace43838a59d Author: phantomjinx <p.g...@ph...> Date: Thu Sep 1 21:29:31 2011 +0100 Ensure tracks are sorted before selecting * Highlighting the displayed tracks in clarity plugin selects the first track in the list rather than the first track according to the sort preference. * Sort the tracks first before selecting the first track. plugins/clarity/album_model.c | 27 ++++++++++++++++++++------- plugins/clarity/album_model.h | 2 ++ plugins/clarity/clarity_widget.c | 22 +++++++++++++++++++++- 3 files changed, 43 insertions(+), 8 deletions(-) --- diff --git a/plugins/clarity/album_model.c b/plugins/clarity/album_model.c index f495118..cab5e41 100644 --- a/plugins/clarity/album_model.c +++ b/plugins/clarity/album_model.c @@ -85,15 +85,28 @@ static AlbumItem *_create_album_item(Track *track) { * @b: second album key to compare * */ -static gint _compare_album_item_keys(gchar *a, gchar *b) { +static gint _compare_album_keys(gchar *a, gchar *b) { if (a == NULL) return -1; if (b == NULL) - return -1; + return 1; return compare_string(a, b, prefs_get_int("clarity_case_sensitive")); } +gint compare_tracks(Track *a, Track *b) { + if (!a) + return -1; + + if (!b) + return 1; + + gchar *keya = _create_key_from_track(a); + gchar *keyb = _create_key_from_track(b); + + return _compare_album_keys(keya, keyb); +} + void _index_album_item(AlbumModelPrivate *priv, gchar *album_key, AlbumItem *item) { enum GtkPodSortTypes value = prefs_get_int("clarity_sort"); @@ -101,13 +114,13 @@ void _index_album_item(AlbumModelPrivate *priv, gchar *album_key, AlbumItem *ite switch(value) { case SORT_ASCENDING: - priv->album_key_list = g_list_insert_sorted(priv->album_key_list, album_key, (GCompareFunc) _compare_album_item_keys); + priv->album_key_list = g_list_insert_sorted(priv->album_key_list, album_key, (GCompareFunc) _compare_album_keys); break; case SORT_DESCENDING: /* Already in descending order so reverse into ascending order */ priv->album_key_list = g_list_reverse(priv->album_key_list); /* Insert the track */ - priv->album_key_list = g_list_insert_sorted(priv->album_key_list, album_key, (GCompareFunc) _compare_album_item_keys); + priv->album_key_list = g_list_insert_sorted(priv->album_key_list, album_key, (GCompareFunc) _compare_album_keys); /* Reverse again */ priv->album_key_list = g_list_reverse(priv->album_key_list); break; @@ -227,10 +240,10 @@ void album_model_resort(AlbumModel *model, GList *tracks) { switch (value) { case SORT_ASCENDING: - priv->album_key_list = g_list_sort(priv->album_key_list, (GCompareFunc) _compare_album_item_keys); + priv->album_key_list = g_list_sort(priv->album_key_list, (GCompareFunc) _compare_album_keys); break; case SORT_DESCENDING: - priv->album_key_list = g_list_sort(priv->album_key_list, (GCompareFunc) _compare_album_item_keys); + priv->album_key_list = g_list_sort(priv->album_key_list, (GCompareFunc) _compare_album_keys); priv->album_key_list = g_list_reverse(priv->album_key_list); break; default: @@ -301,7 +314,7 @@ AlbumItem *album_model_get_item_with_track(AlbumModel *model, Track *track) { static gint _get_index(AlbumModelPrivate *priv, gchar *trk_key) { GList *key_list = priv->album_key_list; - GList *key = g_list_find_custom(key_list, trk_key, (GCompareFunc) _compare_album_item_keys); + GList *key = g_list_find_custom(key_list, trk_key, (GCompareFunc) _compare_album_keys); g_return_val_if_fail (key, -1); gint index = g_list_position(key_list, key); diff --git a/plugins/clarity/album_model.h b/plugins/clarity/album_model.h index 5ce900b..d91868d 100644 --- a/plugins/clarity/album_model.h +++ b/plugins/clarity/album_model.h @@ -109,5 +109,7 @@ gint album_model_get_index_with_track(AlbumModel *model, Track *track); gint album_model_get_size(AlbumModel *model); +gint compare_tracks(Track *a, Track *b); + #endif /* ALBUM_MODEL_H_ */ diff --git a/plugins/clarity/clarity_widget.c b/plugins/clarity/clarity_widget.c index ea96e8e..c549ccc 100644 --- a/plugins/clarity/clarity_widget.c +++ b/plugins/clarity/clarity_widget.c @@ -419,16 +419,36 @@ void clarity_widget_playlist_removed_cb(GtkPodApp *app, gpointer pl, gpointer da clarity_widget_clear(cw); } +GList *_sort_track_list(GList *tracks) { + enum GtkPodSortTypes value = prefs_get_int("clarity_sort"); + + switch(value) { + case SORT_ASCENDING: + tracks = g_list_sort(tracks, (GCompareFunc) compare_tracks); + break; + case SORT_DESCENDING: + tracks = g_list_sort(tracks, (GCompareFunc) compare_tracks); + tracks = g_list_reverse(tracks); + break; + default: + // Do Nothing + break; + } + + return tracks; +} + void clarity_widget_tracks_selected_cb(GtkPodApp *app, gpointer tks, gpointer data) { g_return_if_fail(CLARITY_IS_WIDGET(data)); ClarityWidget *cw = CLARITY_WIDGET(data); ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(cw); - GList *tracks = tks; + GList *tracks = g_list_copy((GList *) tks); if (!tracks) return; + tracks = _sort_track_list(tracks); ClarityCanvas *ccanvas = CLARITY_CANVAS(priv->draw_area); if (clarity_canvas_is_loading(ccanvas)) |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:48
|
commit b7c9145bde1fb59feb7196478ddba4441cf01f15 Author: phantomjinx <p.g...@ph...> Date: Wed Aug 31 21:40:54 2011 +0100 Support for clarity detecting track additions * album_model.* * Changes to API adding functions for getting the index of an album item given an album item or track. * Include the album item index in the album_model_foreach function, avoiding the need to the canvas to refind the index which is a potential bottle neck. * clarity_canvas * Remove the threading as serves little purpose. * Modifications supporting canvas add album item function * clarity_widget * callback for track added completed plugins/clarity/album_model.c | 76 +++++++++++++++++++++++++------- plugins/clarity/album_model.h | 20 +++++++- plugins/clarity/clarity_canvas.c | 90 ++++++++++++++++++------------------- plugins/clarity/clarity_canvas.h | 2 + plugins/clarity/clarity_widget.c | 32 +++++++++++++- 5 files changed, 153 insertions(+), 67 deletions(-) --- diff --git a/plugins/clarity/album_model.c b/plugins/clarity/album_model.c index 6db251c..f495118 100644 --- a/plugins/clarity/album_model.c +++ b/plugins/clarity/album_model.c @@ -45,10 +45,14 @@ struct _AlbumModelPrivate { GList *album_key_list; }; -static gchar *_create_key(Track *track) { +static gchar *_create_key(gchar *artist, gchar *album) { + return g_strconcat(artist, "_", album, NULL); +} + +static gchar *_create_key_from_track(Track *track) { g_return_val_if_fail(track, ""); - return g_strconcat(track->artist, "_", track->album, NULL); + return _create_key(track->artist, track->album); } static void _add_track_to_album_item(AlbumItem *item, Track *track) { @@ -118,11 +122,14 @@ void _index_album_item(AlbumModelPrivate *priv, gchar *album_key, AlbumItem *ite } } -static void _insert_track(AlbumModelPrivate *priv, Track *track) { +/** + * Return true if a new album item was created. Otherwise false. + */ +static gboolean _insert_track(AlbumModelPrivate *priv, Track *track) { AlbumItem *item; gchar *album_key; - album_key = _create_key(track); + album_key = _create_key_from_track(track); /* Check whether an album item has already been created in connection * with the track's artist and album */ @@ -131,13 +138,14 @@ static void _insert_track(AlbumModelPrivate *priv, Track *track) { // Create new album item item = _create_album_item(track); _index_album_item(priv, album_key, item); + return TRUE; } - else { - /* Album Item found in the album hash so prepend the - * track to the start of the track list */ - g_free(album_key); - _add_track_to_album_item(item, track); - } + + /* Album Item found in the album hash so prepend the + * track to the start of the track list */ + g_free(album_key); + _add_track_to_album_item(item, track); + return FALSE; } /** @@ -245,24 +253,34 @@ void album_model_add_tracks(AlbumModel *model, GList *tracks) { } } -void album_model_foreach (AlbumModel *model, GFunc func, gpointer user_data) { +gboolean album_model_add_track(AlbumModel *model, Track *track) { + g_return_val_if_fail(model, -1); + g_return_val_if_fail(track, -1); + + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE(model); + return _insert_track(priv, track); +} + +void album_model_foreach (AlbumModel *model, AMFunc func, gpointer user_data) { g_return_if_fail(model); g_return_if_fail(func); AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); GList *iter = priv->album_key_list; + gint i = 0; while(iter) { gchar *key = iter->data; AlbumItem *item = g_hash_table_lookup(priv->album_hash, key); - (* func) (item, user_data); + (* func) (item, i, user_data); iter = iter->next; + i++; } } -AlbumItem *album_model_get_item(AlbumModel *model, gint index) { +AlbumItem *album_model_get_item_with_index(AlbumModel *model, gint index) { g_return_val_if_fail(model, NULL); AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); @@ -271,18 +289,44 @@ AlbumItem *album_model_get_item(AlbumModel *model, gint index) { return g_hash_table_lookup(priv->album_hash, key); } -gint album_model_get_index(AlbumModel *model, Track *track) { - g_return_val_if_fail(model, -1); +AlbumItem *album_model_get_item_with_track(AlbumModel *model, Track *track) { + g_return_val_if_fail(model, NULL); AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); - gchar *trk_key = _create_key(track); + gchar *album_key = _create_key_from_track(track); + return g_hash_table_lookup(priv->album_hash, album_key); +} + +static gint _get_index(AlbumModelPrivate *priv, gchar *trk_key) { GList *key_list = priv->album_key_list; GList *key = g_list_find_custom(key_list, trk_key, (GCompareFunc) _compare_album_item_keys); g_return_val_if_fail (key, -1); gint index = g_list_position(key_list, key); + + return index; +} + +gint album_model_get_index_with_album_item(AlbumModel *model, AlbumItem *item) { + g_return_val_if_fail(model, -1); + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); + + gchar *trk_key = _create_key(item->artist, item->albumname); + gint index = _get_index(priv, trk_key); + g_free(trk_key); + + return index; +} + +gint album_model_get_index_with_track(AlbumModel *model, Track *track) { + g_return_val_if_fail(model, -1); + + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); + + gchar *trk_key = _create_key_from_track(track); + gint index = _get_index(priv, trk_key); g_free(trk_key); return index; diff --git a/plugins/clarity/album_model.h b/plugins/clarity/album_model.h index 2314f8f..5ce900b 100644 --- a/plugins/clarity/album_model.h +++ b/plugins/clarity/album_model.h @@ -45,6 +45,8 @@ typedef struct { } AlbumItem; +typedef void (*AMFunc) (gpointer value, gint index, gpointer user_data); + GType album_model_get_type (void); #define ALBUM_TYPE_MODEL (album_model_get_type ()) @@ -83,15 +85,27 @@ void album_model_destroy(AlbumModel *model); void album_model_clear(AlbumModel *model); -void album_model_foreach(AlbumModel *model, GFunc func, gpointer user_data); +void album_model_foreach(AlbumModel *model, AMFunc func, gpointer user_data); void album_model_resort(AlbumModel *model, GList *tracks); void album_model_add_tracks(AlbumModel *model, GList *tracks); -AlbumItem *album_model_get_item(AlbumModel *model, gint index); +/** + * Add a single track to the album model. + * + * @return gboolean: whether a new album model was + * created. + */ +gboolean album_model_add_track(AlbumModel *model, Track *track); + +AlbumItem *album_model_get_item_with_index(AlbumModel *model, gint index); + +AlbumItem *album_model_get_item_with_track(AlbumModel *model, Track *track); + +gint album_model_get_index_with_album_item(AlbumModel *model, AlbumItem *item); -gint album_model_get_index(AlbumModel *model, Track *track); +gint album_model_get_index_with_track(AlbumModel *model, Track *track); gint album_model_get_size(AlbumModel *model); diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c index fbce129..837822c 100644 --- a/plugins/clarity/clarity_canvas.c +++ b/plugins/clarity/clarity_canvas.c @@ -106,7 +106,7 @@ static gboolean _preview_cover_cb(GtkWidget *widget, GdkEvent *event, gpointer u if (!priv->model) return TRUE; - AlbumItem *item = album_model_get_item(priv->model, priv->curr_index); + AlbumItem *item = album_model_get_item_with_index(priv->model, priv->curr_index); GtkWidget *dialog = clarity_preview_new(item); @@ -353,8 +353,6 @@ static void _update_text(ClarityCanvasPrivate *priv) { clutter_text_set_text(CLUTTER_TEXT(priv->title_text), title); clutter_text_set_text(CLUTTER_TEXT(priv->artist_text), artist); - g_warning("%s", clutter_text_get_font_name(CLUTTER_TEXT(priv->title_text))); - g_free(title); g_free(artist); @@ -379,26 +377,24 @@ static void _display_clarity_cover(ClarityCover *ccover, gint index) { clutter_timeline_start (timeline); } -static gboolean _set_loading_complete(gpointer data) { - ClarityCanvasPrivate *priv = (ClarityCanvasPrivate *) data; - priv->loading_complete = TRUE; - _update_text(priv); - return FALSE; -} +static void _set_loading_complete(ClarityCanvasPrivate *priv, gboolean value) { + priv->loading_complete = value; -static gboolean _create_cover_idle(gpointer data) { + if (value) { + _update_text(priv); + } + + g_warning("Loading complete = %d", priv->loading_complete); +} - AlbumItem *album_item = (AlbumItem *) data; - GObject *gobject = album_item->data; +static gboolean _create_cover_actors(ClarityCanvasPrivate *priv, AlbumItem *album_item, gint index) { + g_return_val_if_fail(priv, FALSE); - g_return_val_if_fail(CLARITY_IS_CANVAS(gobject), FALSE); - ClarityCanvas *ccanvas = CLARITY_CANVAS(gobject); - ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(ccanvas); + _set_loading_complete(priv, FALSE); - gint index = g_list_length(priv->covers); ClarityCover *ccover = clarity_cover_new(); clutter_actor_set_opacity(CLUTTER_ACTOR(ccover), 0); - priv->covers = g_list_append(priv->covers, ccover); + priv->covers = g_list_insert(priv->covers, ccover, index); clutter_container_add_actor( CLUTTER_CONTAINER(priv->container), @@ -406,15 +402,12 @@ static gboolean _create_cover_idle(gpointer data) { clarity_cover_set_album_item(ccover, album_item); - //TEXT - //FIXME -// temp.filename = filename; -// temp.filetype = filetype; - - //FIXME - // Confirm whether this does improve performance - if(index > 20) + if((priv->curr_index + VISIBLE_ITEMS < index) || + (priv->curr_index - VISIBLE_ITEMS > index)) { + g_warning("Not creating anything more"); + _set_loading_complete(priv, TRUE); return FALSE; + } gint pos = _calculate_index_distance(index); float scale = _calculate_index_scale(index); @@ -446,25 +439,24 @@ static gboolean _create_cover_idle(gpointer data) { _display_clarity_cover(ccover, index); + _set_loading_complete(priv, TRUE); + return FALSE; } -void _init_album_item(gpointer data, gpointer user_data) { - AlbumItem *item = (AlbumItem *) data; +void _init_album_item(gpointer value, gint index, gpointer user_data) { + AlbumItem *item = (AlbumItem *) value; ClarityCanvas *cc = CLARITY_CANVAS(user_data); - - gdk_threads_enter(); + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(cc); Track *track = g_list_nth_data(item->tracks, 0); item->albumart = _get_track_image(track); item->data = cc; - g_idle_add_full(G_PRIORITY_LOW, _create_cover_idle, item, NULL); - - gdk_threads_leave(); + _create_cover_actors(priv, item, index); } -static gpointer _init_album_model_threaded(gpointer data) { +static gpointer _init_album_model(gpointer data) { g_return_val_if_fail(CLARITY_IS_CANVAS(data), NULL); ClarityCanvas *cc = CLARITY_CANVAS(data); @@ -473,8 +465,6 @@ static gpointer _init_album_model_threaded(gpointer data) { album_model_foreach(model, _init_album_item, cc); - g_idle_add_full(G_PRIORITY_LOW, _set_loading_complete, priv, NULL); - return NULL; } @@ -487,13 +477,8 @@ void clarity_canvas_init_album_model(ClarityCanvas *self, AlbumModel *model) { ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); priv->model = model; - priv->loading_complete = FALSE; - g_thread_create_full(_init_album_model_threaded, self, /* user data */ - 0, /* stack size */ - FALSE, /* joinable */ - TRUE, /* bound */ - G_THREAD_PRIORITY_LOW, NULL); + _init_album_model(self); } @@ -569,6 +554,9 @@ static void _restore_z_order(ClarityCanvasPrivate *priv) { } static void _move(ClarityCanvasPrivate *priv, enum DIRECTION direction, gint increment) { + + _set_loading_complete(priv, FALSE); + /* Stop any animation */ clutter_timeline_stop(priv->timeline); @@ -583,8 +571,9 @@ static void _move(ClarityCanvasPrivate *priv, enum DIRECTION direction, gint inc priv->curr_index += ((direction * -1) * increment); - _update_text(priv); _restore_z_order(priv); + + _set_loading_complete(priv, TRUE); } void clarity_canvas_move_left(ClarityCanvas *self, gint increment) { @@ -594,8 +583,6 @@ void clarity_canvas_move_left(ClarityCanvas *self, gint increment) { if(priv->curr_index == g_list_length(priv->covers) - 1) return; - priv->loading_complete = FALSE; - _move(priv, MOVE_LEFT, increment); } @@ -606,8 +593,6 @@ void clarity_canvas_move_right(ClarityCanvas *self, gint increment) { if(priv->curr_index == 0) return; - priv->loading_complete = FALSE; - _move(priv, MOVE_RIGHT, increment); } @@ -624,3 +609,16 @@ gboolean clarity_canvas_is_loading(ClarityCanvas *self) { return !priv->loading_complete; } +void clarity_canvas_add_album_item(ClarityCanvas *self, AlbumItem *item) { + g_return_if_fail(self); + g_return_if_fail(item); + + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + gint index = album_model_get_index_with_album_item(priv->model, item); + + _set_loading_complete(priv, FALSE); + + _init_album_item(item, index, self); + + _set_loading_complete(priv, TRUE); +} diff --git a/plugins/clarity/clarity_canvas.h b/plugins/clarity/clarity_canvas.h index 346c8de..4b20e8d 100644 --- a/plugins/clarity/clarity_canvas.h +++ b/plugins/clarity/clarity_canvas.h @@ -88,6 +88,8 @@ gint clarity_canvas_get_current_index(ClarityCanvas *self); gboolean clarity_canvas_is_loading(ClarityCanvas *self); +void clarity_canvas_add_album_item(ClarityCanvas *self, AlbumItem *item); + G_END_DECLS #endif /* CLARITY_CANVAS_H_ */ diff --git a/plugins/clarity/clarity_widget.c b/plugins/clarity/clarity_widget.c index 03c9e7d..ea96e8e 100644 --- a/plugins/clarity/clarity_widget.c +++ b/plugins/clarity/clarity_widget.c @@ -434,12 +434,40 @@ void clarity_widget_tracks_selected_cb(GtkPodApp *app, gpointer tks, gpointer da if (clarity_canvas_is_loading(ccanvas)) return; - gint album_index = album_model_get_index(priv->album_model, tracks->data); + gint album_index = album_model_get_index_with_track(priv->album_model, tracks->data); gtk_range_set_value(GTK_RANGE (priv->cdslider), album_index); } +void clarity_widget_track_added_cb(GtkPodApp *app, gpointer tk, gpointer data) { + g_return_if_fail(CLARITY_IS_WIDGET(data)); + + ClarityWidget *cw = CLARITY_WIDGET(data); + ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(cw); + Track *track = tk; + + + if (!track) + return; + + GList *current_tracks = cw->current_playlist->members; + if (!g_list_find(current_tracks, track)) { + // Track not added to this playlist + return; + } + + ClarityCanvas *ccanvas = CLARITY_CANVAS(priv->draw_area); + + if (clarity_canvas_is_loading(ccanvas)) + return; + + if (album_model_add_track(priv->album_model, track)) { + AlbumItem *item = album_model_get_item_with_track(priv->album_model, track); + clarity_canvas_add_album_item(CLARITY_CANVAS(priv->draw_area), item); + _init_slider_range(priv); + } +} + void clarity_widget_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer data) {} void clarity_widget_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data) {} -void clarity_widget_track_added_cb(GtkPodApp *app, gpointer tk, gpointer data) {} |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:42
|
commit b8f951bca3bd3697741c27c2f62adb834843bfef Author: phantomjinx <p.g...@ph...> Date: Wed Aug 31 21:17:24 2011 +0100 Add a reference to current playlist to clarity widget * Makes the widget less dependent on making calls to gtkpod_* * Once we have the playlist, it is important to keep it updated by disposing it properly and removing the reference if it is removed. plugins/clarity/clarity_widget.c | 28 ++++++++++++++++++++++++---- plugins/clarity/clarity_widget.h | 7 +++++++ plugins/clarity/plugin.c | 1 + 3 files changed, 32 insertions(+), 4 deletions(-) --- diff --git a/plugins/clarity/clarity_widget.c b/plugins/clarity/clarity_widget.c index c0ac143..03c9e7d 100644 --- a/plugins/clarity/clarity_widget.c +++ b/plugins/clarity/clarity_widget.c @@ -74,7 +74,10 @@ enum { */ static void clarity_widget_dispose(GObject *gobject) { - ClarityWidgetPrivate *priv = CLARITY_WIDGET(gobject)->priv; + ClarityWidget *cw = CLARITY_WIDGET(gobject); + cw->current_playlist = NULL; + + ClarityWidgetPrivate *priv = cw->priv; if (priv) { if (GTK_IS_WIDGET(priv->contentpanel)) @@ -355,7 +358,7 @@ static void _resort_albums(ClarityWidget *self) { clarity_canvas_clear(CLARITY_CANVAS(priv->draw_area)); // Resort the albums - Playlist *playlist = gtkpod_get_current_playlist(); + Playlist *playlist = self->current_playlist; if (playlist) { album_model_resort(priv->album_model, playlist->members); @@ -386,12 +389,17 @@ void clarity_widget_playlist_selected_cb(GtkPodApp *app, gpointer pl, gpointer d ClarityWidget *cw = CLARITY_WIDGET(data); - clarity_widget_clear(cw); - Playlist *playlist = (Playlist *) pl; if (!playlist) return; + if (cw->current_playlist == playlist) + // Should already have all these tracks displayed + return; + + clarity_widget_clear(cw); + + cw->current_playlist = playlist; GList *tracks = playlist->members; if (!tracks) return; @@ -399,6 +407,18 @@ void clarity_widget_playlist_selected_cb(GtkPodApp *app, gpointer pl, gpointer d _init_tracks(cw, tracks); } +void clarity_widget_playlist_removed_cb(GtkPodApp *app, gpointer pl, gpointer data) { + g_return_if_fail(CLARITY_IS_WIDGET(data)); + + ClarityWidget *cw = CLARITY_WIDGET(data); + Playlist *playlist = (Playlist *) pl; + if (!playlist) + return; + + if (cw->current_playlist == playlist) + clarity_widget_clear(cw); +} + void clarity_widget_tracks_selected_cb(GtkPodApp *app, gpointer tks, gpointer data) { g_return_if_fail(CLARITY_IS_WIDGET(data)); diff --git a/plugins/clarity/clarity_widget.h b/plugins/clarity/clarity_widget.h index 70afb0b..d16ce08 100644 --- a/plugins/clarity/clarity_widget.h +++ b/plugins/clarity/clarity_widget.h @@ -55,6 +55,12 @@ struct _ClarityWidget { /*<private>*/ GtkBox parent_instance; + /* + * Playlist currently associated + * with the display. + */ + Playlist *current_playlist; + /* structure containing private members */ /*<private>*/ ClarityWidgetPrivate *priv; @@ -75,6 +81,7 @@ GtkWidget * clarity_widget_new(); // Signal callbacks void clarity_widget_preference_changed_cb(GtkPodApp *app, gpointer pfname, gpointer value, gpointer data); void clarity_widget_playlist_selected_cb(GtkPodApp *app, gpointer pl, gpointer data); +void clarity_widget_playlist_removed_cb(GtkPodApp *app, gpointer pl, gpointer data); void clarity_widget_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer data); void clarity_widget_tracks_selected_cb(GtkPodApp *app, gpointer tks, gpointer data); void clarity_widget_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data); diff --git a/plugins/clarity/plugin.c b/plugins/clarity/plugin.c index 8e5f9ea..030df02 100644 --- a/plugins/clarity/plugin.c +++ b/plugins/clarity/plugin.c @@ -95,6 +95,7 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) { g_signal_connect (gtkpod_app, SIGNAL_PREFERENCE_CHANGE, G_CALLBACK (clarity_widget_preference_changed_cb), clarity_plugin->clarity_widget); g_signal_connect (gtkpod_app, SIGNAL_PLAYLIST_SELECTED, G_CALLBACK (clarity_widget_playlist_selected_cb), clarity_plugin->clarity_widget); + g_signal_connect (gtkpod_app, SIGNAL_PLAYLIST_REMOVED, G_CALLBACK (clarity_widget_playlist_removed_cb), clarity_plugin->clarity_widget); g_signal_connect (gtkpod_app, SIGNAL_TRACK_REMOVED, G_CALLBACK (clarity_widget_track_removed_cb), clarity_plugin->clarity_widget); g_signal_connect (gtkpod_app, SIGNAL_TRACKS_DISPLAYED, G_CALLBACK (clarity_widget_tracks_selected_cb), clarity_plugin->clarity_widget); g_signal_connect (gtkpod_app, SIGNAL_TRACKS_SELECTED, G_CALLBACK (clarity_widget_tracks_selected_cb), clarity_plugin->clarity_widget); |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:35
|
commit 1172a33c1199a916126ea49fe2bef32b04ce1de9 Author: phantomjinx <p.g...@ph...> Date: Sat Aug 27 17:21:16 2011 +0100 clarity labelling of covers * clarity_canvas * Adds text labels for the track title and artist onto stage * Modify and implement text colour API for changing text colour. plugins/clarity/clarity.xml | 2 +- plugins/clarity/clarity_canvas.c | 96 +++++++++++++++++++++++++++++-- plugins/clarity/clarity_canvas.h | 6 ++- plugins/clarity/clarity_cover.c | 102 ++++++++++++++++++-------------- plugins/clarity/clarity_cover.h | 4 + plugins/clarity/clarity_preferences.c | 2 +- plugins/clarity/clarity_widget.c | 34 +++++++---- plugins/clarity/clarity_widget.h | 2 +- 8 files changed, 182 insertions(+), 66 deletions(-) --- diff --git a/plugins/clarity/clarity.xml b/plugins/clarity/clarity.xml index 349fa82..cfcc9c5 100644 --- a/plugins/clarity/clarity.xml +++ b/plugins/clarity/clarity.xml @@ -66,7 +66,7 @@ <property name="receives_default">True</property> <property name="use_action_appearance">False</property> <property name="use_alpha">True</property> - <property name="title" translatable="yes">Choose a Different Colour for the Clarity Foreground</property> + <property name="title" translatable="yes">Choose a Different Colour for the Clarity Text</property> <property name="color">#ffffffffffff</property> <signal name="color-set" handler="on_clarity_dialog_fg_color_set" swapped="no"/> </object> diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c index 970b876..fbce129 100644 --- a/plugins/clarity/clarity_canvas.c +++ b/plugins/clarity/clarity_canvas.c @@ -56,6 +56,8 @@ struct _ClarityCanvasPrivate { ClutterActor *container; ClutterTimeline *timeline; ClutterAlpha *alpha; + ClutterActor *title_text; + ClutterActor *artist_text; gint curr_index; @@ -142,12 +144,19 @@ static void clarity_canvas_init(ClarityCanvas *self) { priv = self->priv; + priv->title_text = clutter_text_new(); + clutter_text_set_font_name(CLUTTER_TEXT(priv->title_text), "Sans"); + + priv->artist_text = clutter_text_new(); + clutter_text_set_font_name(CLUTTER_TEXT(priv->title_text), "Sans"); + priv->container = clutter_group_new(); clutter_actor_set_reactive(priv->container, TRUE); priv->preview_signal = g_signal_connect (self, "button-press-event", G_CALLBACK (_preview_cover_cb), priv); + clutter_container_add(CLUTTER_CONTAINER(priv->container), priv->title_text, priv->artist_text, NULL); priv->embed = gtk_clutter_embed_new(); /* @@ -182,11 +191,11 @@ GtkWidget *clarity_canvas_new() { } /** - * coverart_get_background_display_color: + * clarity_canvas_get_background_display_color: * * Returns the background color of the clarity canvas. * - * The return value is a hexstring in the form "rrggbbaa" + * The return value is a GdkRGBA * */ GdkRGBA *clarity_canvas_get_background_color(ClarityCanvas *self) { @@ -212,7 +221,36 @@ GdkRGBA *clarity_canvas_get_background_color(ClarityCanvas *self) { return rgba; } -void clarity_canvas_set_background(ClarityCanvas *self, const gchar *color_string) { +/** + * clarity_canvas_get_text_color: + * + * Returns the text color of the clarity text. + * + * The return value is a GdkRGBA + * + */ +GdkRGBA *clarity_canvas_get_text_color(ClarityCanvas *self) { + g_return_val_if_fail(CLARITY_IS_CANVAS(self), NULL); + + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + ClutterColor *ccolor; + ccolor = g_malloc(sizeof(ClutterColor)); + + clutter_text_get_color(CLUTTER_TEXT(priv->title_text), ccolor); + g_return_val_if_fail(ccolor, NULL); + + GdkRGBA *rgba; + rgba = g_malloc(sizeof(GdkRGBA)); + rgba->red = ((gdouble) ccolor->red) / 255; + rgba->green = ((gdouble) ccolor->green) / 255; + rgba->blue = ((gdouble) ccolor->blue) / 255; + rgba->alpha = ((gdouble) ccolor->alpha) / 255; + + return rgba; +} + +void clarity_canvas_set_background_color(ClarityCanvas *self, const gchar *color_string) { g_return_if_fail(self); g_return_if_fail(color_string); @@ -227,6 +265,21 @@ void clarity_canvas_set_background(ClarityCanvas *self, const gchar *color_strin clutter_stage_set_color(CLUTTER_STAGE(stage), ccolor); } +void clarity_canvas_set_text_color(ClarityCanvas *self, const gchar *color_string) { + g_return_if_fail(self); + g_return_if_fail(color_string); + + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + ClutterColor *ccolor; + ccolor = g_malloc(sizeof(ClutterColor)); + + clutter_color_from_string(ccolor, color_string); + + clutter_text_set_color(CLUTTER_TEXT(priv->title_text), ccolor); + clutter_text_set_color(CLUTTER_TEXT(priv->artist_text), ccolor); +} + void clarity_canvas_clear(ClarityCanvas *self) { g_return_if_fail(self); ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); @@ -286,6 +339,37 @@ static gint _calculate_index_opacity (gint dist_from_front) { return CLAMP ( 255 * (VISIBLE_ITEMS - ABS(dist_from_front)) / VISIBLE_ITEMS, 0, 255); } +static void _update_text(ClarityCanvasPrivate *priv) { + g_return_if_fail(priv); + + if (g_list_length(priv->covers) == 0) + return; + + ClarityCover *ccover = g_list_nth_data(priv->covers, priv->curr_index); + + gchar *title = clarity_cover_get_title(ccover); + gchar *artist = clarity_cover_get_artist(ccover); + + clutter_text_set_text(CLUTTER_TEXT(priv->title_text), title); + clutter_text_set_text(CLUTTER_TEXT(priv->artist_text), artist); + + g_warning("%s", clutter_text_get_font_name(CLUTTER_TEXT(priv->title_text))); + + g_free(title); + g_free(artist); + + clutter_actor_raise_top(priv->title_text); + clutter_actor_raise_top(priv->artist_text); + + gfloat artistx = (clutter_actor_get_width(priv->artist_text) / 2) * -1; + gfloat artisty = ((clutter_actor_get_height(CLUTTER_ACTOR(ccover)) / 2) - 25) * -1; + clutter_actor_set_position(priv->artist_text, artistx, artisty); + + gfloat titlex = (clutter_actor_get_width(priv->title_text) / 2) * -1; + gfloat titley = artisty - clutter_actor_get_height(priv->artist_text) - 2; + clutter_actor_set_position(priv->title_text, titlex, titley); +} + static void _display_clarity_cover(ClarityCover *ccover, gint index) { ClutterTimeline *timeline = clutter_timeline_new(1600 * 5); ClutterAlpha *alpha = clutter_alpha_new_full (timeline, CLUTTER_EASE_OUT_EXPO); @@ -298,7 +382,8 @@ static void _display_clarity_cover(ClarityCover *ccover, gint index) { static gboolean _set_loading_complete(gpointer data) { ClarityCanvasPrivate *priv = (ClarityCanvasPrivate *) data; priv->loading_complete = TRUE; - return TRUE; + _update_text(priv); + return FALSE; } static gboolean _create_cover_idle(gpointer data) { @@ -460,6 +545,7 @@ static void _animate_indices(ClarityCanvasPrivate *priv, enum DIRECTION directio } static void _restore_z_order(ClarityCanvasPrivate *priv) { + g_return_if_fail(priv); if (g_list_length(priv->covers) == 0) return; @@ -497,7 +583,7 @@ static void _move(ClarityCanvasPrivate *priv, enum DIRECTION direction, gint inc priv->curr_index += ((direction * -1) * increment); -// update_text (); + _update_text(priv); _restore_z_order(priv); } diff --git a/plugins/clarity/clarity_canvas.h b/plugins/clarity/clarity_canvas.h index 2a6df7d..346c8de 100644 --- a/plugins/clarity/clarity_canvas.h +++ b/plugins/clarity/clarity_canvas.h @@ -70,7 +70,11 @@ GtkWidget * clarity_canvas_new(); GdkRGBA *clarity_canvas_get_background_color(ClarityCanvas *self); -void clarity_canvas_set_background(ClarityCanvas *self, const gchar *color_string); +GdkRGBA *clarity_canvas_get_text_color(ClarityCanvas *self); + +void clarity_canvas_set_background_color(ClarityCanvas *self, const gchar *color_string); + +void clarity_canvas_set_text_color(ClarityCanvas *self, const gchar *color_string); void clarity_canvas_clear(ClarityCanvas *self); diff --git a/plugins/clarity/clarity_cover.c b/plugins/clarity/clarity_cover.c index 42a969f..074dc43 100644 --- a/plugins/clarity/clarity_cover.c +++ b/plugins/clarity/clarity_cover.c @@ -162,63 +162,62 @@ static void clarity_cover_init(ClarityCover *self) { priv->reflection = NULL; } -static void _clone_paint_cb (ClutterActor *actor) -{ +static void _clone_paint_cb (ClutterActor *actor) { ClutterActor *source; - ClutterActorBox box; - CoglHandle material; - gfloat width, height; - guint8 opacity; - CoglColor color_1, color_2; - CoglTextureVertex vertices[4]; - - /* if we don't have a source actor, don't paint */ - source = clutter_clone_get_source (CLUTTER_CLONE (actor)); - if (source == NULL) + ClutterActorBox box; + CoglHandle material; + gfloat width, height; + guint8 opacity; + CoglColor color_1, color_2; + CoglTextureVertex vertices[4]; + + /* if we don't have a source actor, don't paint */ + source = clutter_clone_get_source (CLUTTER_CLONE (actor)); + if (source == NULL) goto out; - /* if the source texture does not have any content, don't paint */ - material = clutter_texture_get_cogl_material (CLUTTER_TEXTURE (source)); - if (material == NULL) + /* if the source texture does not have any content, don't paint */ + material = clutter_texture_get_cogl_material (CLUTTER_TEXTURE (source)); + if (material == NULL) goto out; - /* get the size of the reflection */ - clutter_actor_get_allocation_box (actor, &box); - clutter_actor_box_get_size (&box, &width, &height); + /* get the size of the reflection */ + clutter_actor_get_allocation_box (actor, &box); + clutter_actor_box_get_size (&box, &width, &height); - /* get the composite opacity of the actor */ - opacity = clutter_actor_get_paint_opacity (actor); + /* get the composite opacity of the actor */ + opacity = clutter_actor_get_paint_opacity (actor); - /* figure out the two colors for the reflection: the first is - * full color and the second is the same, but at 0 opacity - */ - cogl_color_init_from_4f (&color_1, 1.0, 1.0, 1.0, opacity / 255.0); - cogl_color_premultiply (&color_1); - cogl_color_init_from_4f (&color_2, 1.0, 1.0, 1.0, 0.0); - cogl_color_premultiply (&color_2); + /* figure out the two colors for the reflection: the first is + * full color and the second is the same, but at 0 opacity + */ + cogl_color_init_from_4f (&color_1, 1.0, 1.0, 1.0, opacity / 255.0); + cogl_color_premultiply (&color_1); + cogl_color_init_from_4f (&color_2, 1.0, 1.0, 1.0, 0.0); + cogl_color_premultiply (&color_2); - /* now describe the four vertices of the quad; since it has - * to be a reflection, we need to invert it as well - */ - vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; - vertices[0].tx = 0.0; vertices[0].ty = 1.0; - vertices[0].color = color_1; + /* now describe the four vertices of the quad; since it has + * to be a reflection, we need to invert it as well + */ + vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; + vertices[0].tx = 0.0; vertices[0].ty = 1.0; + vertices[0].color = color_1; - vertices[1].x = width; vertices[1].y = 0; vertices[1].z = 0; - vertices[1].tx = 1.0; vertices[1].ty = 1.0; - vertices[1].color = color_1; + vertices[1].x = width; vertices[1].y = 0; vertices[1].z = 0; + vertices[1].tx = 1.0; vertices[1].ty = 1.0; + vertices[1].color = color_1; - vertices[2].x = width; vertices[2].y = height; vertices[2].z = 0; - vertices[2].tx = 1.0; vertices[2].ty = 0.0; - vertices[2].color = color_2; + vertices[2].x = width; vertices[2].y = height; vertices[2].z = 0; + vertices[2].tx = 1.0; vertices[2].ty = 0.0; + vertices[2].color = color_2; - vertices[3].x = 0; vertices[3].y = height; vertices[3].z = 0; - vertices[3].tx = 0.0; vertices[3].ty = 0.0; - vertices[3].color = color_2; + vertices[3].x = 0; vertices[3].y = height; vertices[3].z = 0; + vertices[3].tx = 0.0; vertices[3].ty = 0.0; + vertices[3].color = color_2; - /* paint the same texture but with a different geometry */ - cogl_set_source (material); - cogl_polygon (vertices, 4, TRUE); + /* paint the same texture but with a different geometry */ + cogl_set_source (material); + cogl_polygon (vertices, 4, TRUE); out: /* prevent the default clone handler from running */ @@ -267,6 +266,10 @@ void clarity_cover_set_album_item (ClarityCover *self, AlbumItem *item) { gfloat temp = w * DEFAULT_IMG_SIZE / h; clutter_actor_set_size(priv->texture, temp, DEFAULT_IMG_SIZE); } + + // Add title / artist data + priv->title = g_strdup(item->albumname); + priv->artist = g_strdup(item->artist); } void clarity_cover_clear_rotation_behaviour(ClarityCover *self) { @@ -307,6 +310,15 @@ void clarity_cover_set_rotation_behaviour(ClarityCover *self, ClutterAlpha *alph } } +gchar *clarity_cover_get_title(ClarityCover *self) { + ClarityCoverPrivate *priv = self->priv; + return g_strdup(priv->title); +} + +gchar *clarity_cover_get_artist(ClarityCover *self) { + ClarityCoverPrivate *priv = self->priv; + return g_strdup(priv->artist); +} /** * clarity_cover_new: diff --git a/plugins/clarity/clarity_cover.h b/plugins/clarity/clarity_cover.h index a2d4928..ee6542b 100644 --- a/plugins/clarity/clarity_cover.h +++ b/plugins/clarity/clarity_cover.h @@ -101,6 +101,10 @@ void clarity_cover_clear_rotation_behaviour(ClarityCover *self); void clarity_cover_set_rotation_behaviour(ClarityCover *self, ClutterAlpha *alpha, int final_angle, ClutterRotateDirection direction); +gchar *clarity_cover_get_title(ClarityCover *self); + +gchar *clarity_cover_get_artist(ClarityCover *self); + /* constructor - note this returns a ClutterActor instance */ ClarityCover *clarity_cover_new (void); diff --git a/plugins/clarity/clarity_preferences.c b/plugins/clarity/clarity_preferences.c index 7414568..35acd91 100644 --- a/plugins/clarity/clarity_preferences.c +++ b/plugins/clarity/clarity_preferences.c @@ -107,7 +107,7 @@ GtkWidget *init_clarity_preferences(const gchar *gladepath, ClarityWidget *cw) { gtk_color_button_set_rgba (GTK_COLOR_BUTTON(coverart_bgcolorselect_button), color); gdk_rgba_free(color); - color = clarity_widget_get_foreground_display_color(cw); + color = clarity_widget_get_text_display_color(cw); gtk_color_button_set_rgba (GTK_COLOR_BUTTON(coverart_fgcolorselect_button), color); gdk_rgba_free(color); diff --git a/plugins/clarity/clarity_widget.c b/plugins/clarity/clarity_widget.c index 8636761..c0ac143 100644 --- a/plugins/clarity/clarity_widget.c +++ b/plugins/clarity/clarity_widget.c @@ -70,11 +70,7 @@ enum { * track added * track removed * track updated - * change background - * text * set cover from file - * sort - * preferences */ static void clarity_widget_dispose(GObject *gobject) { @@ -220,11 +216,9 @@ static void _init_slider_range(ClarityWidgetPrivate *priv) { g_signal_handler_unblock(G_OBJECT(priv->cdslider), priv->slider_signal_id); } -static void _set_background(ClarityWidget *self) { +static void _set_background_color(ClarityWidget *self) { gchar *hex_string; - hex_string = "#FFFFFF"; - if (!prefs_get_string_value("clarity_bg_color", NULL)) hex_string = "#000000"; else @@ -232,7 +226,20 @@ static void _set_background(ClarityWidget *self) { ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(self); - clarity_canvas_set_background(CLARITY_CANVAS(priv->draw_area), hex_string); + clarity_canvas_set_background_color(CLARITY_CANVAS(priv->draw_area), hex_string); +} + +static void _set_text_color(ClarityWidget *self) { + gchar *hex_string; + + if (!prefs_get_string_value("clarity_fg_color", NULL)) + hex_string = "#FFFFFF"; + else + prefs_get_string_value("clarity_fg_color", &hex_string); + + ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(self); + + clarity_canvas_set_text_color(CLARITY_CANVAS(priv->draw_area), hex_string); } static void clarity_widget_class_init (ClarityWidgetClass *klass) { @@ -257,7 +264,8 @@ static void clarity_widget_init (ClarityWidget *self) { G_CALLBACK(_on_scrolling_covers_cb), priv); - _set_background(self); + _set_background_color(self); + _set_text_color(self); priv->leftbutton = gtk_button_new_with_label("<"); gtk_widget_set_name(priv->leftbutton, LEFT_BUTTON); @@ -331,12 +339,12 @@ GdkRGBA *clarity_widget_get_background_display_color(ClarityWidget *self) { return clarity_canvas_get_background_color(CLARITY_CANVAS(priv->draw_area)); } -GdkRGBA *clarity_widget_get_foreground_display_color(ClarityWidget *self) { +GdkRGBA *clarity_widget_get_text_display_color(ClarityWidget *self) { g_return_val_if_fail(CLARITY_IS_WIDGET(self), NULL); ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(self); - return clarity_canvas_get_background_color(CLARITY_CANVAS(priv->draw_area)); + return clarity_canvas_get_text_color(CLARITY_CANVAS(priv->draw_area)); } static void _resort_albums(ClarityWidget *self) { @@ -366,7 +374,9 @@ void clarity_widget_preference_changed_cb(GtkPodApp *app, gpointer pfname, gpoin gchar *pref_name = pfname; if (g_str_equal(pref_name, "clarity_bg_color")) - _set_background(cw); + _set_background_color(cw); + else if (g_str_equal(pref_name, "clarity_fg_color")) + _set_text_color(cw); else if (g_str_equal(pref_name, "clarity_sort")) _resort_albums(cw); } diff --git a/plugins/clarity/clarity_widget.h b/plugins/clarity/clarity_widget.h index a6c216f..70afb0b 100644 --- a/plugins/clarity/clarity_widget.h +++ b/plugins/clarity/clarity_widget.h @@ -67,7 +67,7 @@ struct _ClarityWidgetClass { GdkRGBA *clarity_widget_get_background_display_color(ClarityWidget *self); -GdkRGBA *clarity_widget_get_foreground_display_color(ClarityWidget *self); +GdkRGBA *clarity_widget_get_text_display_color(ClarityWidget *self); GtkWidget * clarity_widget_new(); |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:29
|
commit 37e584fc99e2a697e8d85845a067caab003540b6 Author: phantomjinx <p.g...@ph...> Date: Sat Aug 27 13:00:59 2011 +0100 Implement clarity preferences * Preferences for changing background colour and artwork sorting * album_model.* * Narrowing of API and tidy up * Implementation of sort functions * clarity_canvas.* * loading_complete field introduced for stopping other signal handlers firing before the animation has completed. plugins/clarity/Makefile.am | 1 + plugins/clarity/album_model.c | 248 ++++++++++++++++++++------------- plugins/clarity/album_model.h | 11 +- plugins/clarity/clarity.xml | 38 +++--- plugins/clarity/clarity_canvas.c | 34 ++++- plugins/clarity/clarity_canvas.h | 4 +- plugins/clarity/clarity_preferences.c | 49 ++++--- plugins/clarity/clarity_preferences.h | 4 +- plugins/clarity/clarity_widget.c | 76 ++++++++--- plugins/clarity/clarity_widget.h | 6 +- plugins/clarity/plugin.c | 82 ++++++----- plugins/clarity/plugin.h | 2 + 12 files changed, 353 insertions(+), 202 deletions(-) --- diff --git a/plugins/clarity/Makefile.am b/plugins/clarity/Makefile.am index 4b0fd01..c623eda 100644 --- a/plugins/clarity/Makefile.am +++ b/plugins/clarity/Makefile.am @@ -35,6 +35,7 @@ libclarity_la_SOURCES = plugin.c plugin.h \ clarity_widget.c clarity_widget.h \ clarity_preview.c clarity_preview.h \ clarity_utils.c clarity_utils.h \ + clarity_preferences.c clarity_preferences.h \ clarity_context_menu.c clarity_context_menu.h \ fetchcover.c fetchcover.h libclarity_la_CFLAGS = $(CLUTTER_GTK_CFLAGS) diff --git a/plugins/clarity/album_model.c b/plugins/clarity/album_model.c index e09ec96..6db251c 100644 --- a/plugins/clarity/album_model.c +++ b/plugins/clarity/album_model.c @@ -32,6 +32,7 @@ #include "album_model.h" #include "libgtkpod/prefs.h" #include "libgtkpod/misc.h" +#include "libgtkpod/gp_private.h" G_DEFINE_TYPE( AlbumModel, album_model, G_TYPE_OBJECT); @@ -42,10 +43,103 @@ struct _AlbumModelPrivate { GHashTable *album_hash; GList *album_key_list; - - gint loaded; }; +static gchar *_create_key(Track *track) { + g_return_val_if_fail(track, ""); + + return g_strconcat(track->artist, "_", track->album, NULL); +} + +static void _add_track_to_album_item(AlbumItem *item, Track *track) { + item->tracks = g_list_prepend(item->tracks, track); +} + +static AlbumItem *_create_album_item(Track *track) { + AlbumItem *item = NULL; + + /* Album item not found so create a new one and populate */ + item = g_new0 (AlbumItem, 1); + item->albumart = NULL; + item->albumname = g_strdup(track->album); + item->artist = g_strdup(track->artist); + item->tracks = NULL; + _add_track_to_album_item(item, track); + + return item; +} + +/** + * compare_album_keys: + * + * Comparison function for comparing keys in + * the key list to sort them into alphabetical order. + * Could use g_ascii_strcasecmp directly but the NULL + * strings cause assertion errors. + * + * @a: first album key to compare + * @b: second album key to compare + * + */ +static gint _compare_album_item_keys(gchar *a, gchar *b) { + if (a == NULL) + return -1; + if (b == NULL) + return -1; + + return compare_string(a, b, prefs_get_int("clarity_case_sensitive")); +} + +void _index_album_item(AlbumModelPrivate *priv, gchar *album_key, AlbumItem *item) { + enum GtkPodSortTypes value = prefs_get_int("clarity_sort"); + + g_hash_table_insert(priv->album_hash, album_key, item); + + switch(value) { + case SORT_ASCENDING: + priv->album_key_list = g_list_insert_sorted(priv->album_key_list, album_key, (GCompareFunc) _compare_album_item_keys); + break; + case SORT_DESCENDING: + /* Already in descending order so reverse into ascending order */ + priv->album_key_list = g_list_reverse(priv->album_key_list); + /* Insert the track */ + priv->album_key_list = g_list_insert_sorted(priv->album_key_list, album_key, (GCompareFunc) _compare_album_item_keys); + /* Reverse again */ + priv->album_key_list = g_list_reverse(priv->album_key_list); + break; + default: + /* NO SORT */ + + // Quicker to reverse, prepend then reverse back + priv->album_key_list = g_list_reverse(priv->album_key_list); + priv->album_key_list = g_list_prepend(priv->album_key_list, album_key); + priv->album_key_list = g_list_reverse(priv->album_key_list); + break; + } +} + +static void _insert_track(AlbumModelPrivate *priv, Track *track) { + AlbumItem *item; + gchar *album_key; + + album_key = _create_key(track); + /* Check whether an album item has already been created in connection + * with the track's artist and album + */ + item = g_hash_table_lookup(priv->album_hash, album_key); + if (!item) { + // Create new album item + item = _create_album_item(track); + _index_album_item(priv, album_key, item); + } + else { + /* Album Item found in the album hash so prepend the + * track to the start of the track list */ + g_free(album_key); + _add_track_to_album_item(item, track); + } +} + /** * * clarity_widget_free_album: @@ -53,24 +147,26 @@ struct _AlbumModelPrivate { * Destroy an album struct once no longer needed. * */ -static void album_model_free_album(AlbumItem *album) { - if (album != NULL) { - if (album->tracks) { - g_list_free(album->tracks); +static void album_model_free_album_item(AlbumItem *item) { + if (item) { + if (item->tracks) { + g_list_free(item->tracks); } + item->tracks = NULL; + + g_free(item->albumname); + g_free(item->artist); - g_free(album->albumname); - g_free(album->artist); + if (item->albumart) + g_object_unref(item->albumart); - if (album->albumart) - g_object_unref(album->albumart); + item->data = NULL; } } static void album_model_finalize(GObject *gobject) { AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE(gobject); - priv->album_key_list = g_list_remove_all(priv->album_key_list, NULL); g_hash_table_foreach_remove(priv->album_hash, (GHRFunc) gtk_true, NULL); g_hash_table_destroy(priv->album_hash); g_list_free(priv->album_key_list); @@ -92,9 +188,8 @@ static void album_model_init (AlbumModel *self) { AlbumModelPrivate *priv; priv = ALBUM_MODEL_GET_PRIVATE (self); - priv->album_hash = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) album_model_free_album); + priv->album_hash = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) album_model_free_album_item); priv->album_key_list = NULL; - priv->loaded = 0; } @@ -112,64 +207,49 @@ void album_model_clear(AlbumModel *model) { priv = ALBUM_MODEL_GET_PRIVATE (model); g_hash_table_remove_all (priv->album_hash); - g_list_free(priv->album_key_list); - priv->album_key_list = NULL; -} - -static gchar *_create_key(Track *track) { - g_return_val_if_fail(track, ""); - - return g_strconcat(track->artist, "_", track->album, NULL); + if (priv->album_key_list) { + g_list_free(priv->album_key_list); + priv->album_key_list = NULL; + } } -void album_model_add_track(AlbumModel *model, Track *track) { - AlbumItem *album; - gchar *album_key; - AlbumModelPrivate *priv; - - priv = ALBUM_MODEL_GET_PRIVATE (model); - album_key = _create_key(track); - /* Check whether an album item has already been created in connection - * with the track's artist and album - */ - album = g_hash_table_lookup(priv->album_hash, album_key); - if (album == NULL) { - /* Album item not found so create a new one and populate */ - album = g_new0 (AlbumItem, 1); - album->albumart = NULL; - album->albumname = g_strdup(track->album); - album->artist = g_strdup(track->artist); - album->tracks = NULL; - album->tracks = g_list_prepend(album->tracks, track); - - /* Insert the new Album Item into the hash */ - g_hash_table_insert(priv->album_hash, album_key, album); - /* Add the key to the list for sorting and other functions */ - priv->album_key_list = g_list_prepend(priv->album_key_list, album_key); - } - else { - /* Album Item found in the album hash so - * append the track to the end of the - * track list */ - g_free(album_key); - album->tracks = g_list_prepend(album->tracks, track); +void album_model_resort(AlbumModel *model, GList *tracks) { + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); + enum GtkPodSortTypes value = prefs_get_int("clarity_sort"); + + switch (value) { + case SORT_ASCENDING: + priv->album_key_list = g_list_sort(priv->album_key_list, (GCompareFunc) _compare_album_item_keys); + break; + case SORT_DESCENDING: + priv->album_key_list = g_list_sort(priv->album_key_list, (GCompareFunc) _compare_album_item_keys); + priv->album_key_list = g_list_reverse(priv->album_key_list); + break; + default: + // No sorting needs to re-initialise the model from scratch + album_model_clear(model); + album_model_add_tracks(model, tracks); + break; } } -void album_model_reset_loaded_index(AlbumModel *model) { +void album_model_add_tracks(AlbumModel *model, GList *tracks) { g_return_if_fail(model); - AlbumModelPrivate *priv; - priv = ALBUM_MODEL_GET_PRIVATE (model); - priv->loaded = 0; + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE(model); + GList *trks = tracks; + while(trks) { + Track *track = trks->data; + _insert_track(priv, track); + trks = trks->next; + } } void album_model_foreach (AlbumModel *model, GFunc func, gpointer user_data) { g_return_if_fail(model); g_return_if_fail(func); - AlbumModelPrivate *priv; - priv = ALBUM_MODEL_GET_PRIVATE (model); + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); GList *iter = priv->album_key_list; while(iter) { @@ -182,61 +262,39 @@ void album_model_foreach (AlbumModel *model, GFunc func, gpointer user_data) { } } - -gint album_model_get_size(AlbumModel *model) { - g_return_val_if_fail(model, 0); - - AlbumModelPrivate *priv; - priv = ALBUM_MODEL_GET_PRIVATE (model); - - return g_list_length(priv->album_key_list); -} - AlbumItem *album_model_get_item(AlbumModel *model, gint index) { g_return_val_if_fail(model, NULL); - AlbumModelPrivate *priv; - priv = ALBUM_MODEL_GET_PRIVATE (model); + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); gchar *key = g_list_nth_data(priv->album_key_list, index); return g_hash_table_lookup(priv->album_hash, key); } -/** - * compare_album_keys: - * - * Comparison function for comparing keys in - * the key list to sort them into alphabetical order. - * Could use g_ascii_strcasecmp directly but the NULL - * strings cause assertion errors. - * - * @a: first album key to compare - * @b: second album key to compare - * - */ -static gint _compare_album_keys(gchar *a, gchar *b) { - if (a == NULL) - return -1; - if (b == NULL) - return -1; - - return compare_string(a, b, prefs_get_int("cad_case_sensitive")); -} - gint album_model_get_index(AlbumModel *model, Track *track) { g_return_val_if_fail(model, -1); - AlbumModelPrivate *priv; - priv = ALBUM_MODEL_GET_PRIVATE (model); + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE (model); gchar *trk_key = _create_key(track); - GList *key = g_list_find_custom(priv->album_key_list, trk_key, (GCompareFunc) _compare_album_keys); + GList *key_list = priv->album_key_list; + + GList *key = g_list_find_custom(key_list, trk_key, (GCompareFunc) _compare_album_item_keys); g_return_val_if_fail (key, -1); - gint index = g_list_position(priv->album_key_list, key); + gint index = g_list_position(key_list, key); g_free(trk_key); return index; } +gint album_model_get_size(AlbumModel *model) { + g_return_val_if_fail(model, 0); + + AlbumModelPrivate *priv; + priv = ALBUM_MODEL_GET_PRIVATE (model); + + return g_list_length(priv->album_key_list); +} + #endif /* ALBUM_MODEL_C_ */ diff --git a/plugins/clarity/album_model.h b/plugins/clarity/album_model.h index c8fd53e..2314f8f 100644 --- a/plugins/clarity/album_model.h +++ b/plugins/clarity/album_model.h @@ -83,16 +83,17 @@ void album_model_destroy(AlbumModel *model); void album_model_clear(AlbumModel *model); -void album_model_add_track(AlbumModel *model, Track *track); - -void album_model_reset_loaded_index(AlbumModel *model); - void album_model_foreach(AlbumModel *model, GFunc func, gpointer user_data); -gint album_model_get_size(AlbumModel *model); +void album_model_resort(AlbumModel *model, GList *tracks); + +void album_model_add_tracks(AlbumModel *model, GList *tracks); AlbumItem *album_model_get_item(AlbumModel *model, gint index); gint album_model_get_index(AlbumModel *model, Track *track); +gint album_model_get_size(AlbumModel *model); + + #endif /* ALBUM_MODEL_H_ */ diff --git a/plugins/clarity/clarity.xml b/plugins/clarity/clarity.xml index 063c0fe..349fa82 100644 --- a/plugins/clarity/clarity.xml +++ b/plugins/clarity/clarity.xml @@ -31,14 +31,15 @@ <property name="can_focus">False</property> <property name="spacing">12</property> <child> - <object class="GtkColorButton" id="coverart_display_bg_button"> + <object class="GtkColorButton" id="clarity_bg_button"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_action_appearance">False</property> - <property name="title" translatable="yes">Choose a Different Colour for the CoverArt Display Background</property> + <property name="use_alpha">True</property> + <property name="title" translatable="yes">Choose a Different Colour for the Clarity Background</property> <property name="color">#000000000000</property> - <signal name="color-set" handler="on_coverart_dialog_bg_color_set" swapped="no"/> + <signal name="color-set" handler="on_clarity_dialog_bg_color_set" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -59,14 +60,15 @@ </packing> </child> <child> - <object class="GtkColorButton" id="coverart_display_fg_button"> + <object class="GtkColorButton" id="clarity_fg_button"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_action_appearance">False</property> - <property name="title" translatable="yes">Choose a Different Colour for the CoverArt Display Background</property> + <property name="use_alpha">True</property> + <property name="title" translatable="yes">Choose a Different Colour for the Clarity Foreground</property> <property name="color">#ffffffffffff</property> - <signal name="color-set" handler="on_coverart_dialog_fg_color_set" swapped="no"/> + <signal name="color-set" handler="on_clarity_dialog_fg_color_set" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -94,7 +96,7 @@ <object class="GtkLabel" id="label18"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes"><b>Cover Art Display</b></property> + <property name="label" translatable="yes"><b>Clarity</b></property> <property name="use_markup">True</property> </object> </child> @@ -161,14 +163,14 @@ </packing> </child> <child> - <object class="GtkRadioButton" id="cad_ascend"> + <object class="GtkRadioButton" id="clarity_ascend"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_action_appearance">False</property> <property name="draw_indicator">True</property> - <property name="group">cad_none</property> - <signal name="toggled" handler="on_cad_ascend_toggled" swapped="no"/> + <property name="group">clarity_none</property> + <signal name="toggled" handler="on_clarity_ascend_toggled" swapped="no"/> <child> <object class="GtkImage" id="image1928"> <property name="visible">True</property> @@ -186,14 +188,14 @@ </packing> </child> <child> - <object class="GtkRadioButton" id="cad_descend"> + <object class="GtkRadioButton" id="clarity_descend"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_action_appearance">False</property> <property name="draw_indicator">True</property> - <property name="group">cad_none</property> - <signal name="toggled" handler="on_cad_descend_toggled" swapped="no"/> + <property name="group">clarity_none</property> + <signal name="toggled" handler="on_clarity_descend_toggled" swapped="no"/> <child> <object class="GtkImage" id="image1929"> <property name="visible">True</property> @@ -222,14 +224,14 @@ </packing> </child> <child> - <object class="GtkRadioButton" id="cad_none"> + <object class="GtkRadioButton" id="clarity_none"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_action_appearance">False</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <signal name="toggled" handler="on_cad_none_toggled" swapped="no"/> + <signal name="toggled" handler="on_clarity_none_toggled" swapped="no"/> <child> <object class="GtkImage" id="image1930"> <property name="visible">True</property> @@ -259,7 +261,7 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="cad_cfg_case_sensitive"> + <object class="GtkCheckButton" id="clarity_cfg_case_sensitive"> <property name="label" translatable="yes">Case sensitive sorting</property> <property name="visible">True</property> <property name="can_focus">True</property> @@ -267,7 +269,7 @@ <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property> - <signal name="toggled" handler="on_cad_sort_case_sensitive_toggled" swapped="no"/> + <signal name="toggled" handler="on_clarity_sort_case_sensitive_toggled" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -300,7 +302,7 @@ <object class="GtkLabel" id="display_page_label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">Cover Art Display</property> + <property name="label" translatable="yes">Clarity</property> </object> <packing> <property name="tab_fill">False</property> diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c index f95d2cc..970b876 100644 --- a/plugins/clarity/clarity_canvas.c +++ b/plugins/clarity/clarity_canvas.c @@ -60,6 +60,8 @@ struct _ClarityCanvasPrivate { gint curr_index; gulong preview_signal; + + gboolean loading_complete; }; enum DIRECTION { @@ -171,6 +173,7 @@ static void clarity_canvas_init(ClarityCanvas *self) { priv->timeline = clutter_timeline_new(1600); priv->alpha = clutter_alpha_new_full(priv->timeline, CLUTTER_EASE_OUT_EXPO); priv->curr_index = 0; + priv->loading_complete = FALSE; } @@ -186,7 +189,7 @@ GtkWidget *clarity_canvas_new() { * The return value is a hexstring in the form "rrggbbaa" * */ -gchar *clarity_canvas_get_background_color(ClarityCanvas *self) { +GdkRGBA *clarity_canvas_get_background_color(ClarityCanvas *self) { g_return_val_if_fail(CLARITY_IS_CANVAS(self), NULL); ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); @@ -199,7 +202,14 @@ gchar *clarity_canvas_get_background_color(ClarityCanvas *self) { clutter_stage_get_color(CLUTTER_STAGE(stage), ccolor); g_return_val_if_fail(ccolor, NULL); - return clutter_color_to_string(ccolor); + GdkRGBA *rgba; + rgba = g_malloc(sizeof(GdkRGBA)); + rgba->red = ((gdouble) ccolor->red) / 255; + rgba->green = ((gdouble) ccolor->green) / 255; + rgba->blue = ((gdouble) ccolor->blue) / 255; + rgba->alpha = ((gdouble) ccolor->alpha) / 255; + + return rgba; } void clarity_canvas_set_background(ClarityCanvas *self, const gchar *color_string) { @@ -285,6 +295,12 @@ static void _display_clarity_cover(ClarityCover *ccover, gint index) { clutter_timeline_start (timeline); } +static gboolean _set_loading_complete(gpointer data) { + ClarityCanvasPrivate *priv = (ClarityCanvasPrivate *) data; + priv->loading_complete = TRUE; + return TRUE; +} + static gboolean _create_cover_idle(gpointer data) { AlbumItem *album_item = (AlbumItem *) data; @@ -372,6 +388,8 @@ static gpointer _init_album_model_threaded(gpointer data) { album_model_foreach(model, _init_album_item, cc); + g_idle_add_full(G_PRIORITY_LOW, _set_loading_complete, priv, NULL); + return NULL; } @@ -384,7 +402,7 @@ void clarity_canvas_init_album_model(ClarityCanvas *self, AlbumModel *model) { ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); priv->model = model; - album_model_reset_loaded_index(model); + priv->loading_complete = FALSE; g_thread_create_full(_init_album_model_threaded, self, /* user data */ 0, /* stack size */ @@ -490,6 +508,8 @@ void clarity_canvas_move_left(ClarityCanvas *self, gint increment) { if(priv->curr_index == g_list_length(priv->covers) - 1) return; + priv->loading_complete = FALSE; + _move(priv, MOVE_LEFT, increment); } @@ -500,6 +520,8 @@ void clarity_canvas_move_right(ClarityCanvas *self, gint increment) { if(priv->curr_index == 0) return; + priv->loading_complete = FALSE; + _move(priv, MOVE_RIGHT, increment); } @@ -510,5 +532,9 @@ gint clarity_canvas_get_current_index(ClarityCanvas *self) { return priv->curr_index; } - +gboolean clarity_canvas_is_loading(ClarityCanvas *self) { + g_return_val_if_fail(self, FALSE); + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + return !priv->loading_complete; +} diff --git a/plugins/clarity/clarity_canvas.h b/plugins/clarity/clarity_canvas.h index cf22471..2a6df7d 100644 --- a/plugins/clarity/clarity_canvas.h +++ b/plugins/clarity/clarity_canvas.h @@ -68,7 +68,7 @@ struct _ClarityCanvasClass { GtkWidget * clarity_canvas_new(); -gchar *clarity_canvas_get_background_color(ClarityCanvas *self); +GdkRGBA *clarity_canvas_get_background_color(ClarityCanvas *self); void clarity_canvas_set_background(ClarityCanvas *self, const gchar *color_string); @@ -82,6 +82,8 @@ void clarity_canvas_move_right(ClarityCanvas *self, gint increment); gint clarity_canvas_get_current_index(ClarityCanvas *self); +gboolean clarity_canvas_is_loading(ClarityCanvas *self); + G_END_DECLS #endif /* CLARITY_CANVAS_H_ */ diff --git a/plugins/clarity/clarity_preferences.c b/plugins/clarity/clarity_preferences.c index 33167e5..7414568 100644 --- a/plugins/clarity/clarity_preferences.c +++ b/plugins/clarity/clarity_preferences.c @@ -43,8 +43,8 @@ G_MODULE_EXPORT void on_clarity_dialog_bg_color_set (GtkColorButton *widget, gpo gchar *color_string = gdk_rgba_to_string(&color); prefs_set_string ("clarity_bg_color", color_string); + gtkpod_broadcast_preference_change("clarity_bg_color", color_string); g_free (color_string); - coverart_display_update (FALSE); } /* @@ -57,32 +57,37 @@ G_MODULE_EXPORT void on_clarity_dialog_fg_color_set (GtkColorButton *widget, gpo gchar *color_string = gdk_rgba_to_string(&color); prefs_set_string ("clarity_fg_color", color_string); + gtkpod_broadcast_preference_change("clarity_fg_color", color_string); g_free (color_string); - coverart_display_update (FALSE); } -G_MODULE_EXPORT void on_cad_ascend_toggled(GtkToggleButton *togglebutton, gpointer user_data) { +static void _set_sort_preference(gint order) { + prefs_set_int("clarity_sort", order); + gtkpod_broadcast_preference_change("clarity_sort", &order); +} + +G_MODULE_EXPORT void on_clarity_ascend_toggled(GtkToggleButton *togglebutton, gpointer user_data) { if (gtk_toggle_button_get_active(togglebutton)) - coverart_display_sort(SORT_ASCENDING); + _set_sort_preference(SORT_ASCENDING); } -G_MODULE_EXPORT void on_cad_descend_toggled(GtkToggleButton *togglebutton, gpointer user_data) { +G_MODULE_EXPORT void on_clarity_descend_toggled(GtkToggleButton *togglebutton, gpointer user_data) { if (gtk_toggle_button_get_active(togglebutton)) - coverart_display_sort(SORT_DESCENDING); + _set_sort_preference(SORT_DESCENDING); } -G_MODULE_EXPORT void on_cad_none_toggled(GtkToggleButton *togglebutton, gpointer user_data) { +G_MODULE_EXPORT void on_clarity_none_toggled(GtkToggleButton *togglebutton, gpointer user_data) { if (gtk_toggle_button_get_active(togglebutton)) - coverart_display_sort(SORT_NONE); + _set_sort_preference(SORT_NONE); } -G_MODULE_EXPORT void on_cad_sort_case_sensitive_toggled(GtkToggleButton *togglebutton, gpointer user_data) { +G_MODULE_EXPORT void on_clarity_sort_case_sensitive_toggled(GtkToggleButton *togglebutton, gpointer user_data) { gboolean val = gtk_toggle_button_get_active(togglebutton); - prefs_set_int("cad_case_sensitive", val); - gtkpod_broadcast_preference_change("cad_case_sensitive", val); + prefs_set_int("clarity_case_sensitive", val); + gtkpod_broadcast_preference_change("clarity_case_sensitive", &val); } -GtkWidget *init_cover_preferences(gchar *gladepath) { +GtkWidget *init_clarity_preferences(const gchar *gladepath, ClarityWidget *cw) { GtkWidget *notebook; GtkBuilder *pref_xml; GtkWidget *coverart_bgcolorselect_button; @@ -93,36 +98,36 @@ GtkWidget *init_cover_preferences(gchar *gladepath) { pref_xml = gtkpod_builder_xml_new(gladepath); win = gtkpod_builder_xml_get_widget(pref_xml, "preference_window"); notebook = gtkpod_builder_xml_get_widget(pref_xml, "cover_settings_notebook"); - coverart_bgcolorselect_button = gtkpod_builder_xml_get_widget (pref_xml, "coverart_display_bg_button"); - coverart_fgcolorselect_button = gtkpod_builder_xml_get_widget (pref_xml, "coverart_display_fg_button"); + coverart_bgcolorselect_button = gtkpod_builder_xml_get_widget (pref_xml, "clarity_bg_button"); + coverart_fgcolorselect_button = gtkpod_builder_xml_get_widget (pref_xml, "clarity_fg_button"); g_object_ref(notebook); gtk_container_remove(GTK_CONTAINER (win), notebook); - color = coverart_get_background_display_color(); + color = clarity_widget_get_background_display_color(cw); gtk_color_button_set_rgba (GTK_COLOR_BUTTON(coverart_bgcolorselect_button), color); gdk_rgba_free(color); - color = coverart_get_foreground_display_color(); + color = clarity_widget_get_foreground_display_color(cw); gtk_color_button_set_rgba (GTK_COLOR_BUTTON(coverart_fgcolorselect_button), color); gdk_rgba_free(color); - switch (prefs_get_int("cad_sort")) { + switch (prefs_get_int("clarity_sort")) { case SORT_ASCENDING: - w = gtkpod_builder_xml_get_widget(pref_xml, "cad_ascend"); + w = gtkpod_builder_xml_get_widget(pref_xml, "clarity_ascend"); break; case SORT_DESCENDING: - w = gtkpod_builder_xml_get_widget(pref_xml, "cad_descend"); + w = gtkpod_builder_xml_get_widget(pref_xml, "clarity_descend"); break; default: - w = gtkpod_builder_xml_get_widget(pref_xml, "cad_none"); + w = gtkpod_builder_xml_get_widget(pref_xml, "clarity_none"); break; } if (w) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE); - if ((w = gtkpod_builder_xml_get_widget(pref_xml, "cad_cfg_case_sensitive"))) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), prefs_get_int("cad_case_sensitive")); + if ((w = gtkpod_builder_xml_get_widget(pref_xml, "clarity_cfg_case_sensitive"))) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), prefs_get_int("clarity_case_sensitive")); } gtk_builder_connect_signals(pref_xml, NULL); diff --git a/plugins/clarity/clarity_preferences.h b/plugins/clarity/clarity_preferences.h index 2b102fa..5316083 100644 --- a/plugins/clarity/clarity_preferences.h +++ b/plugins/clarity/clarity_preferences.h @@ -29,6 +29,8 @@ #ifndef CLARITY_PREFERENCES_H_ #define CLARITY_PREFERENCES_H_ -GtkWidget *init_clarity_preferences(); +#include "clarity_widget.h" + +GtkWidget *init_clarity_preferences(const gchar *gladepath, ClarityWidget *cw); #endif /* CLARITY_PREFERENCES_H_ */ diff --git a/plugins/clarity/clarity_widget.c b/plugins/clarity/clarity_widget.c index eed716e..8636761 100644 --- a/plugins/clarity/clarity_widget.c +++ b/plugins/clarity/clarity_widget.c @@ -72,7 +72,6 @@ enum { * track updated * change background * text - * select cover * set cover from file * sort * preferences @@ -221,6 +220,21 @@ static void _init_slider_range(ClarityWidgetPrivate *priv) { g_signal_handler_unblock(G_OBJECT(priv->cdslider), priv->slider_signal_id); } +static void _set_background(ClarityWidget *self) { + gchar *hex_string; + + hex_string = "#FFFFFF"; + + if (!prefs_get_string_value("clarity_bg_color", NULL)) + hex_string = "#000000"; + else + prefs_get_string_value("clarity_bg_color", &hex_string); + + ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(self); + + clarity_canvas_set_background(CLARITY_CANVAS(priv->draw_area), hex_string); +} + static void clarity_widget_class_init (ClarityWidgetClass *klass) { GObjectClass *gobject_class; @@ -243,7 +257,7 @@ static void clarity_widget_init (ClarityWidget *self) { G_CALLBACK(_on_scrolling_covers_cb), priv); - clarity_widget_set_background(self); + _set_background(self); priv->leftbutton = gtk_button_new_with_label("<"); gtk_widget_set_name(priv->leftbutton, LEFT_BUTTON); @@ -294,7 +308,7 @@ static void clarity_widget_clear(ClarityWidget *self) { album_model_clear(priv->album_model); } -static void clarity_widget_init_tracks(ClarityWidget *cw, GList *tracks) { +static void _init_tracks(ClarityWidget *cw, GList *tracks) { g_return_if_fail(CLARITY_IS_WIDGET(cw)); if (!tracks) @@ -302,40 +316,59 @@ static void clarity_widget_init_tracks(ClarityWidget *cw, GList *tracks) { ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(cw); - while (tracks) { - Track *track = tracks->data; - album_model_add_track(priv->album_model, track); - tracks = tracks->next; - } + album_model_add_tracks(priv->album_model, tracks); clarity_canvas_init_album_model(CLARITY_CANVAS(priv->draw_area), priv->album_model); _init_slider_range(priv); } -void clarity_widget_set_background(ClarityWidget *self) { - gchar *hex_string; +GdkRGBA *clarity_widget_get_background_display_color(ClarityWidget *self) { + g_return_val_if_fail(CLARITY_IS_WIDGET(self), NULL); - hex_string = "#FFFFFF"; + ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(self); - if (!prefs_get_string_value("clarity_bg_color", NULL)) - hex_string = "#000000"; - else - prefs_get_string_value("clarity_bg_color", &hex_string); + return clarity_canvas_get_background_color(CLARITY_CANVAS(priv->draw_area)); +} + +GdkRGBA *clarity_widget_get_foreground_display_color(ClarityWidget *self) { + g_return_val_if_fail(CLARITY_IS_WIDGET(self), NULL); ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(self); - clarity_canvas_set_background(CLARITY_CANVAS(priv->draw_area), hex_string); + return clarity_canvas_get_background_color(CLARITY_CANVAS(priv->draw_area)); } -void clarity_widget_preference_changed_cb(GtkPodApp *app, gpointer pfname, gint32 value, gpointer data) { +static void _resort_albums(ClarityWidget *self) { + g_return_if_fail(CLARITY_IS_WIDGET(self)); + ClarityWidgetPrivate *priv = CLARITY_WIDGET_GET_PRIVATE(self); + + // Need to clear away the graphics and start again + clarity_canvas_clear(CLARITY_CANVAS(priv->draw_area)); + + // Resort the albums + Playlist *playlist = gtkpod_get_current_playlist(); + if (playlist) { + album_model_resort(priv->album_model, playlist->members); + + // Re-init the graphics + clarity_canvas_init_album_model(CLARITY_CANVAS(priv->draw_area), priv->album_model); + + // Reset the slider and buttons + _init_slider_range(priv); + } +} + +void clarity_widget_preference_changed_cb(GtkPodApp *app, gpointer pfname, gpointer value, gpointer data) { g_return_if_fail(CLARITY_IS_WIDGET(data)); ClarityWidget *cw = CLARITY_WIDGET(data); gchar *pref_name = pfname; if (g_str_equal(pref_name, "clarity_bg_color")) - clarity_widget_set_background(cw); + _set_background(cw); + else if (g_str_equal(pref_name, "clarity_sort")) + _resort_albums(cw); } void clarity_widget_playlist_selected_cb(GtkPodApp *app, gpointer pl, gpointer data) { @@ -353,7 +386,7 @@ void clarity_widget_playlist_selected_cb(GtkPodApp *app, gpointer pl, gpointer d if (!tracks) return; - clarity_widget_init_tracks(cw, tracks); + _init_tracks(cw, tracks); } void clarity_widget_tracks_selected_cb(GtkPodApp *app, gpointer tks, gpointer data) { @@ -366,6 +399,11 @@ void clarity_widget_tracks_selected_cb(GtkPodApp *app, gpointer tks, gpointer da if (!tracks) return; + ClarityCanvas *ccanvas = CLARITY_CANVAS(priv->draw_area); + + if (clarity_canvas_is_loading(ccanvas)) + return; + gint album_index = album_model_get_index(priv->album_model, tracks->data); gtk_range_set_value(GTK_RANGE (priv->cdslider), album_index); } diff --git a/plugins/clarity/clarity_widget.h b/plugins/clarity/clarity_widget.h index 5debcb8..a6c216f 100644 --- a/plugins/clarity/clarity_widget.h +++ b/plugins/clarity/clarity_widget.h @@ -65,13 +65,15 @@ struct _ClarityWidgetClass { }; -void clarity_widget_set_background(ClarityWidget *self); +GdkRGBA *clarity_widget_get_background_display_color(ClarityWidget *self); + +GdkRGBA *clarity_widget_get_foreground_display_color(ClarityWidget *self); GtkWidget * clarity_widget_new(); // Signal callbacks -void clarity_widget_preference_changed_cb(GtkPodApp *app, gpointer pfname, gint32 value, gpointer data); +void clarity_widget_preference_changed_cb(GtkPodApp *app, gpointer pfname, gpointer value, gpointer data); void clarity_widget_playlist_selected_cb(GtkPodApp *app, gpointer pl, gpointer data); void clarity_widget_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer data); void clarity_widget_tracks_selected_cb(GtkPodApp *app, gpointer tks, gpointer data); diff --git a/plugins/clarity/plugin.c b/plugins/clarity/plugin.c index 11c2981..8e5f9ea 100644 --- a/plugins/clarity/plugin.c +++ b/plugins/clarity/plugin.c @@ -39,7 +39,7 @@ #include "libgtkpod/directories.h" #include "plugin.h" #include "clarity_widget.h" -//#include "clarity_preferences.h" +#include "clarity_preferences.h" #define TAB_NAME "Clarity" @@ -50,11 +50,11 @@ static GtkActionEntry cover_actions[] = { }; static void set_default_preferences() { - if (!prefs_get_string_value("clarity_display_bg_color", NULL)) - prefs_set_string("clarity_display_bg_color", "#000000"); + if (!prefs_get_string_value("clarity_bg_color", NULL)) + prefs_set_string("clarity_bg_color", "#000000"); - if (!prefs_get_string_value("clarity_display_fg_color", NULL)) - prefs_set_string("clarity_display_fg_color", "#FFFFFF"); + if (!prefs_get_string_value("clarity_fg_color", NULL)) + prefs_set_string("clarity_fg_color", "#FFFFFF"); } static gboolean activate_plugin(AnjutaPlugin *plugin) { @@ -88,18 +88,18 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) { gtk_scrolled_window_set_policy(clarity_plugin->cover_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(clarity_plugin->cover_window, GTK_SHADOW_IN); - GtkWidget* cw = clarity_widget_new (); - gtk_scrolled_window_add_with_viewport(clarity_plugin->cover_window, cw); + clarity_plugin->clarity_widget = CLARITY_WIDGET(clarity_widget_new ()); + gtk_scrolled_window_add_with_viewport(clarity_plugin->cover_window, GTK_WIDGET(clarity_plugin->clarity_widget)); gtk_widget_show_all(GTK_WIDGET(clarity_plugin->cover_window)); anjuta_shell_add_widget(plugin->shell, GTK_WIDGET(clarity_plugin->cover_window), "ClarityPlugin", "Cover Artwork", NULL, ANJUTA_SHELL_PLACEMENT_CENTER, NULL); - g_signal_connect (gtkpod_app, SIGNAL_PREFERENCE_CHANGE, G_CALLBACK (clarity_widget_preference_changed_cb), cw); - g_signal_connect (gtkpod_app, SIGNAL_PLAYLIST_SELECTED, G_CALLBACK (clarity_widget_playlist_selected_cb), cw); - g_signal_connect (gtkpod_app, SIGNAL_TRACK_REMOVED, G_CALLBACK (clarity_widget_track_removed_cb), cw); - g_signal_connect (gtkpod_app, SIGNAL_TRACKS_DISPLAYED, G_CALLBACK (clarity_widget_tracks_selected_cb), cw); - g_signal_connect (gtkpod_app, SIGNAL_TRACKS_SELECTED, G_CALLBACK (clarity_widget_tracks_selected_cb), cw); - g_signal_connect (gtkpod_app, SIGNAL_TRACK_UPDATED, G_CALLBACK (clarity_widget_track_updated_cb), cw); - g_signal_connect (gtkpod_app, SIGNAL_TRACK_ADDED, G_CALLBACK (clarity_widget_track_added_cb), cw); + g_signal_connect (gtkpod_app, SIGNAL_PREFERENCE_CHANGE, G_CALLBACK (clarity_widget_preference_changed_cb), clarity_plugin->clarity_widget); + g_signal_connect (gtkpod_app, SIGNAL_PLAYLIST_SELECTED, G_CALLBACK (clarity_widget_playlist_selected_cb), clarity_plugin->clarity_widget); + g_signal_connect (gtkpod_app, SIGNAL_TRACK_REMOVED, G_CALLBACK (clarity_widget_track_removed_cb), clarity_plugin->clarity_widget); + g_signal_connect (gtkpod_app, SIGNAL_TRACKS_DISPLAYED, G_CALLBACK (clarity_widget_tracks_selected_cb), clarity_plugin->clarity_widget); + g_signal_connect (gtkpod_app, SIGNAL_TRACKS_SELECTED, G_CALLBACK (clarity_widget_tracks_selected_cb), clarity_plugin->clarity_widget); + g_signal_connect (gtkpod_app, SIGNAL_TRACK_UPDATED, G_CALLBACK (clarity_widget_track_updated_cb), clarity_plugin->clarity_widget); + g_signal_connect (gtkpod_app, SIGNAL_TRACK_ADDED, G_CALLBACK (clarity_widget_track_added_cb), clarity_plugin->clarity_widget); return TRUE; /* FALSE if activation failed */ } @@ -109,6 +109,14 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) { ClarityPlugin *clarity_plugin; clarity_plugin = (ClarityPlugin*) plugin; + + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (clarity_widget_preference_changed_cb), clarity_plugin->clarity_widget); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (clarity_widget_playlist_selected_cb), clarity_plugin->clarity_widget); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (clarity_widget_track_removed_cb), clarity_plugin->clarity_widget); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (clarity_widget_tracks_selected_cb), clarity_plugin->clarity_widget); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (clarity_widget_track_updated_cb), clarity_plugin->clarity_widget); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (clarity_widget_track_added_cb), clarity_plugin->clarity_widget); + ui = anjuta_shell_get_ui(plugin->shell, NULL); /* Remove widgets from Shell */ @@ -117,6 +125,10 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) { /* Unmerge UI */ anjuta_ui_unmerge(ui, clarity_plugin->uiid); + /* Destroy the widget */ + gtk_widget_destroy(GTK_WIDGET(clarity_plugin->clarity_widget)); + clarity_plugin->clarity_widget = NULL; + /* Remove Action groups */ anjuta_ui_remove_action_group(ui, clarity_plugin->action_group); @@ -144,33 +156,33 @@ static void clarity_plugin_class_init(GObjectClass *klass) { } static void ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e) { -// GdkPixbuf *pixbuf; -// GError *error = NULL; -// -// ClarityPlugin* plugin = CLARITY_PLUGIN(ipref); -// plugin->prefs = init_cover_preferences(plugin->gladepath); -// if (plugin->prefs == NULL) -// return; -// -// pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), DEFAULT_COVER_ICON, 48, 0, &error); -// -// if (!pixbuf) { -// g_warning ("Couldn't load icon: %s", error->message); -// g_error_free(error); -// } -// anjuta_preferences_dialog_add_page(ANJUTA_PREFERENCES_DIALOG (anjuta_preferences_get_dialog (prefs)), "gtkpod-clarity-settings", _(TAB_NAME), pixbuf, plugin->prefs); -// g_object_unref(pixbuf); + GdkPixbuf *pixbuf; + GError *error = NULL; + + ClarityPlugin* plugin = CLARITY_PLUGIN(ipref); + plugin->prefs = init_clarity_preferences(plugin->gladepath, plugin->clarity_widget); + if (plugin->prefs == NULL) + return; + + pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), DEFAULT_COVER_ICON, 48, 0, &error); + + if (!pixbuf) { + g_warning ("Couldn't load icon: %s", error->message); + g_error_free(error); + } + anjuta_preferences_dialog_add_page(ANJUTA_PREFERENCES_DIALOG (anjuta_preferences_get_dialog (prefs)), "gtkpod-clarity-settings", _(TAB_NAME), pixbuf, plugin->prefs); + g_object_unref(pixbuf); } static void ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e) { -// anjuta_preferences_remove_page(prefs, _(TAB_NAME)); -// ClarityPlugin* plugin = CLARITY_PLUGIN(ipref); -// gtk_widget_destroy(plugin->prefs); + anjuta_preferences_remove_page(prefs, _(TAB_NAME)); + ClarityPlugin* plugin = CLARITY_PLUGIN(ipref); + gtk_widget_destroy(plugin->prefs); } static void ipreferences_iface_init(IAnjutaPreferencesIface* iface) { -// iface->merge = ipreferences_merge; -// iface->unmerge = ipreferences_unmerge; + iface->merge = ipreferences_merge; + iface->unmerge = ipreferences_unmerge; } ANJUTA_PLUGIN_BEGIN (ClarityPlugin, clarity_plugin); diff --git a/plugins/clarity/plugin.h b/plugins/clarity/plugin.h index 1b9b746..f91f2fc 100644 --- a/plugins/clarity/plugin.h +++ b/plugins/clarity/plugin.h @@ -36,6 +36,7 @@ #include <libanjuta/anjuta-plugin.h> #include "clarity_utils.h" +#include "clarity_widget.h" extern GType clarity_plugin_get_type (GTypeModule *module); #define CLARITY_TYPE_PLUGIN (clarity_plugin_get_type (NULL)) @@ -51,6 +52,7 @@ typedef struct _ClarityPluginClass ClarityPluginClass; struct _ClarityPlugin { AnjutaPlugin parent; GtkScrolledWindow *cover_window; + ClarityWidget *clarity_widget; gint uiid; GtkActionGroup *action_group; GtkWidget *prefs; |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:22
|
commit b69b39dc7583d19411e8cdbe63ffa78e6a5f0d9c Author: phantomjinx <p.g...@ph...> Date: Sat Aug 27 12:55:46 2011 +0100 Cover display not disconnecting on deactivate * Seems that deactivating the coverart display is not disconnecting the signal handlers. This is due to incorrect data paramter passed to disconnect function. plugins/cover_display/plugin.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) --- diff --git a/plugins/cover_display/plugin.c b/plugins/cover_display/plugin.c index 9e97e41..60b0cac 100644 --- a/plugins/cover_display/plugin.c +++ b/plugins/cover_display/plugin.c @@ -113,11 +113,11 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) { coverart_block_change(TRUE); - g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_update_cb), plugin); - g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_track_removed_cb), plugin); - g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_set_tracks_cb), plugin); - g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_track_updated_cb), plugin); - g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_track_added_cb), plugin); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_update_cb), NULL); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_track_removed_cb), NULL); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_set_tracks_cb), NULL); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_track_updated_cb), NULL); + g_signal_handlers_disconnect_by_func(plugin->shell, G_CALLBACK (coverart_display_track_added_cb), NULL); cover_display_plugin = (CoverDisplayPlugin*) plugin; ui = anjuta_shell_get_ui(plugin->shell, NULL); |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:16
|
commit 56885a2439081d03f081678cc6824f18c8d7b039 Author: phantomjinx <p.g...@ph...> Date: Sat Aug 27 12:54:37 2011 +0100 Allow broadcasting of all types of preference * gtkpod_app_iface.* * broadcast preference changed function assumed the data type of the value is gint. Some preferences are strings etc. so need to modify. libgtkpod/gtkpod_app_iface.c | 3 +-- libgtkpod/gtkpod_app_iface.h | 2 +- plugins/cover_display/cover_display_preferences.c | 2 +- plugins/cover_display/display_coverart.c | 2 +- plugins/playlist_display/display_playlists.c | 4 ++-- plugins/playlist_display/display_playlists.h | 2 +- .../playlist_display_preferences.c | 4 ++-- plugins/sorttab_display/display_sorttabs.c | 4 ++-- .../sorttab_display/sorttab_display_preferences.c | 2 +- plugins/track_display/display_tracks.c | 2 +- plugins/track_display/display_tracks.h | 2 +- plugins/track_display/track_display_preferences.c | 2 +- 12 files changed, 15 insertions(+), 16 deletions(-) --- diff --git a/libgtkpod/gtkpod_app_iface.c b/libgtkpod/gtkpod_app_iface.c index 85057c1..6c579e1 100644 --- a/libgtkpod/gtkpod_app_iface.c +++ b/libgtkpod/gtkpod_app_iface.c @@ -414,8 +414,7 @@ void gtkpod_notify_data_unchanged(iTunesDB *itdb) { g_signal_emit(gtkpod_app, gtkpod_app_signals[ITDB_DATA_SAVED], 0, itdb); } - -void gtkpod_broadcast_preference_change(gchar *preference_name, gint value) { +void gtkpod_broadcast_preference_change(gchar *preference_name, gpointer value) { g_return_if_fail (GTKPOD_IS_APP(gtkpod_app)); g_return_if_fail (preference_name); diff --git a/libgtkpod/gtkpod_app_iface.h b/libgtkpod/gtkpod_app_iface.h index afb67a5..9da414e 100644 --- a/libgtkpod/gtkpod_app_iface.h +++ b/libgtkpod/gtkpod_app_iface.h @@ -203,7 +203,7 @@ void gtkpod_track_updated(Track *track); void gtkpod_set_sort_enablement(gboolean enable); gboolean gtkpod_get_sort_enablement(); -void gtkpod_broadcast_preference_change(gchar *preference_name, gint value); +void gtkpod_broadcast_preference_change(gchar *preference_name, gpointer value); void gtkpod_register_exporter(Exporter *exporter); void gtkpod_unregister_exporter(); diff --git a/plugins/cover_display/cover_display_preferences.c b/plugins/cover_display/cover_display_preferences.c index bd48df0..d4f817c 100644 --- a/plugins/cover_display/cover_display_preferences.c +++ b/plugins/cover_display/cover_display_preferences.c @@ -79,7 +79,7 @@ G_MODULE_EXPORT void on_cad_none_toggled(GtkToggleButton *togglebutton, gpointer G_MODULE_EXPORT void on_cad_sort_case_sensitive_toggled(GtkToggleButton *togglebutton, gpointer user_data) { gboolean val = gtk_toggle_button_get_active(togglebutton); prefs_set_int("cad_case_sensitive", val); - gtkpod_broadcast_preference_change("cad_case_sensitive", val); + gtkpod_broadcast_preference_change("cad_case_sensitive", &val); } GtkWidget *init_cover_preferences(gchar *gladepath) { diff --git a/plugins/cover_display/display_coverart.c b/plugins/cover_display/display_coverart.c index fe563c9..c797dff 100644 --- a/plugins/cover_display/display_coverart.c +++ b/plugins/cover_display/display_coverart.c @@ -603,7 +603,7 @@ void coverart_display_update(gboolean clear_track_list) { void coverart_display_sort(gint order) { prefs_set_int("cad_sort", order); coverart_display_update(TRUE); - gtkpod_broadcast_preference_change("cad_sort", order); + gtkpod_broadcast_preference_change("cad_sort", &order); } /** diff --git a/plugins/playlist_display/display_playlists.c b/plugins/playlist_display/display_playlists.c index 6004f3b..951b9da 100644 --- a/plugins/playlist_display/display_playlists.c +++ b/plugins/playlist_display/display_playlists.c @@ -2132,10 +2132,10 @@ void playlist_display_playlist_removed_cb(GtkPodApp *app, gpointer pl, gpointer pm_remove_playlist(old_playlist, TRUE); } -void playlist_display_preference_changed_cb(GtkPodApp *app, gpointer pfname, gint32 value, gpointer data) { +void playlist_display_preference_changed_cb(GtkPodApp *app, gpointer pfname, gpointer value, gpointer data) { gchar *pref_name = pfname; if (g_str_equal(pref_name, "pm_sort")) - pm_sort(value); + pm_sort((GtkSortType) value); else if (g_str_equal(pref_name, "pm_case_sensitive")) { gint val = prefs_get_int("pm_sort"); pm_sort((GtkSortType) val); diff --git a/plugins/playlist_display/display_playlists.h b/plugins/playlist_display/display_playlists.h index 2bfe5a9..e78f68f 100644 --- a/plugins/playlist_display/display_playlists.h +++ b/plugins/playlist_display/display_playlists.h @@ -62,7 +62,7 @@ void playlist_display_select_playlist_cb (GtkPodApp *app, gpointer pl, gpointer void playlist_display_playlist_added_cb(GtkPodApp *app, gpointer pl, gint32 pos, gpointer data); void playlist_display_playlist_removed_cb(GtkPodApp *app, gpointer pl, gpointer data); void playlist_display_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer data); -void playlist_display_preference_changed_cb(GtkPodApp *app, gpointer pfname, gint32 value, gpointer data); +void playlist_display_preference_changed_cb(GtkPodApp *app, gpointer pfname, gpointer value, gpointer data); void playlist_display_itdb_data_changed_cb(GtkPodApp *app, gpointer itdb, gpointer data); #endif /* __DISPLAY_PLAYLIST_H__ */ diff --git a/plugins/playlist_display/playlist_display_preferences.c b/plugins/playlist_display/playlist_display_preferences.c index 913555d..3f69505 100644 --- a/plugins/playlist_display/playlist_display_preferences.c +++ b/plugins/playlist_display/playlist_display_preferences.c @@ -38,7 +38,7 @@ static GtkWidget *notebook = NULL; static void set_pm_sort(gint val) { prefs_set_int("pm_sort", val); - gtkpod_broadcast_preference_change("pm_sort", val); + gtkpod_broadcast_preference_change("pm_sort", &val); } G_MODULE_EXPORT void on_pm_ascend_toggled(GtkToggleButton *togglebutton, gpointer user_data) { @@ -59,7 +59,7 @@ G_MODULE_EXPORT void on_pm_none_toggled(GtkToggleButton *togglebutton, gpointer G_MODULE_EXPORT void on_pm_sort_case_sensitive_toggled(GtkToggleButton *togglebutton, gpointer user_data) { gboolean val = gtk_toggle_button_get_active(togglebutton); prefs_set_int("pm_case_sensitive", val); - gtkpod_broadcast_preference_change("pm_case_sensitive", val); + gtkpod_broadcast_preference_change("pm_case_sensitive", &val); } GtkWidget *init_playlist_display_preferences() { diff --git a/plugins/sorttab_display/display_sorttabs.c b/plugins/sorttab_display/display_sorttabs.c index 66374a9..87ec764 100644 --- a/plugins/sorttab_display/display_sorttabs.c +++ b/plugins/sorttab_display/display_sorttabs.c @@ -1059,7 +1059,7 @@ static void st_free_entry_cb(gpointer data, gpointer user_data) { void st_remove_all_entries_from_model(guint32 inst) { SortTab *st = sorttab[inst]; gint column; - GtkSortType order; + enum GtkPodSortTypes order; if (st) { if (st->current_entry) { @@ -1789,7 +1789,7 @@ void st_sort(gint order) { st_sort_inst(i, order); prefs_set_int("st_sort", order); - gtkpod_broadcast_preference_change("st_sort", order); + gtkpod_broadcast_preference_change("st_sort", &order); } gint st_get_sorttab_page_number(int inst) { diff --git a/plugins/sorttab_display/sorttab_display_preferences.c b/plugins/sorttab_display/sorttab_display_preferences.c index 6810c2e..edbddb7 100644 --- a/plugins/sorttab_display/sorttab_display_preferences.c +++ b/plugins/sorttab_display/sorttab_display_preferences.c @@ -72,7 +72,7 @@ G_MODULE_EXPORT void on_st_none_toggled(GtkToggleButton *togglebutton, gpointer G_MODULE_EXPORT void on_st_sort_case_sensitive_toggled(GtkToggleButton *togglebutton, gpointer user_data) { gboolean val = gtk_toggle_button_get_active(togglebutton); prefs_set_int("st_case_sensitive", val); - gtkpod_broadcast_preference_change("st_case_sensitive", val); + gtkpod_broadcast_preference_change("st_case_sensitive", &val); } GtkWidget *init_sorttab_preferences() { diff --git a/plugins/track_display/display_tracks.c b/plugins/track_display/display_tracks.c index 1945309..5c733be 100644 --- a/plugins/track_display/display_tracks.c +++ b/plugins/track_display/display_tracks.c @@ -2417,7 +2417,7 @@ void track_display_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data) tm_track_changed(track); } -void track_display_preference_changed_cb(GtkPodApp *app, gpointer pfname, gint32 value, gpointer data) { +void track_display_preference_changed_cb(GtkPodApp *app, gpointer pfname, gpointer value, gpointer data) { gchar *pref_name = pfname; if (g_str_equal(pref_name, "tm_sort")) { tm_sort_counter(-1); diff --git a/plugins/track_display/display_tracks.h b/plugins/track_display/display_tracks.h index 6a65577..37fc212 100644 --- a/plugins/track_display/display_tracks.h +++ b/plugins/track_display/display_tracks.h @@ -49,7 +49,7 @@ void track_display_set_playlist_cb(GtkPodApp *app, gpointer pl, gpointer data); void track_display_set_sort_enablement(GtkPodApp *app, gboolean flag, gpointer data); void track_display_track_removed_cb(GtkPodApp *app, gpointer tk, gint32 pos, gpointer data); void track_display_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data); -void track_display_preference_changed_cb(GtkPodApp *app, gpointer pfname, gint32 value, gpointer data); +void track_display_preference_changed_cb(GtkPodApp *app, gpointer pfname, gpointer value, gpointer data); void track_display_tracks_reordered_cb(GtkPodApp *app, gpointer data); void on_search_entry_changed(GtkEditable *editable, gpointer user_data); diff --git a/plugins/track_display/track_display_preferences.c b/plugins/track_display/track_display_preferences.c index a754b96..db2f263 100644 --- a/plugins/track_display/track_display_preferences.c +++ b/plugins/track_display/track_display_preferences.c @@ -416,7 +416,7 @@ static void populate_track_cmd_combo(GtkComboBox *combo) { G_MODULE_EXPORT void on_tm_sort_case_sensitive_toggled(GtkToggleButton *togglebutton, gpointer user_data) { gboolean val = gtk_toggle_button_get_active(togglebutton); prefs_set_int("tm_case_sensitive", val); - gtkpod_broadcast_preference_change("tm_case_sensitive", val); + gtkpod_broadcast_preference_change("tm_case_sensitive", &val); } GtkWidget *init_track_display_preferences() { |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:09
|
commit 0bc65d58c4c764ee84f56ec41431742127106369 Author: phantomjinx <p.g...@ph...> Date: Thu Aug 25 23:26:43 2011 +0100 New coverart display plugin 'clarity' * Display is created using clutter and clutter-gtk * Code ported and inspired by the gloobus flow project see http://bazaar.launchpad.net/~gloobus-dev/gloobus-flow * Original coverart display code migrated but tidied up into gobject classes rather than spaghetti of C function calls * TODO: * popup menu * drag n drop * track added * track removed * track updated * change background * text * set cover from file * sort * preferences configure.ac | 54 ++- data/glade/clarity.glade | 1 + data/glade/clarity.xml | 1 + data/ui/clarity.ui | 1 + plugins/Makefile.am | 3 +- plugins/clarity/Makefile.am | 56 +++ plugins/clarity/album_model.c | 242 +++++++++ plugins/clarity/album_model.h | 98 ++++ plugins/clarity/clarity.plugin | 5 + plugins/clarity/clarity.plugin.in | 4 + plugins/clarity/clarity.ui | 7 + plugins/clarity/clarity.xml | 312 ++++++++++++ plugins/clarity/clarity_canvas.c | 514 ++++++++++++++++++++ plugins/clarity/clarity_canvas.h | 87 ++++ plugins/clarity/clarity_context_menu.c | 80 +++ plugins/clarity/clarity_context_menu.h | 37 ++ plugins/clarity/clarity_cover.c | 321 ++++++++++++ plugins/clarity/clarity_cover.h | 107 ++++ plugins/clarity/clarity_preferences.c | 130 +++++ plugins/clarity/clarity_preferences.h | 34 ++ plugins/clarity/clarity_preview.c | 200 ++++++++ plugins/clarity/clarity_preview.h | 72 +++ plugins/clarity/clarity_utils.c | 78 +++ plugins/clarity/clarity_utils.h | 59 +++ plugins/clarity/clarity_widget.c | 377 ++++++++++++++ plugins/clarity/clarity_widget.h | 86 ++++ plugins/clarity/fetchcover.c | 447 +++++++++++++++++ plugins/clarity/fetchcover.h | 55 +++ plugins/clarity/icons/Makefile.am | 14 + plugins/clarity/icons/hicolor/16x16/Makefile.am | 1 + .../clarity/icons/hicolor/16x16/places/Makefile.am | 4 + .../hicolor/16x16/places/clarity-default-cover.png | Bin 0 -> 698 bytes plugins/clarity/icons/hicolor/22x22/Makefile.am | 1 + .../clarity/icons/hicolor/22x22/places/Makefile.am | 4 + .../hicolor/22x22/places/clarity-default-cover.png | Bin 0 -> 1076 bytes plugins/clarity/icons/hicolor/240x240/Makefile.am | 1 + .../icons/hicolor/240x240/places/Makefile.am | 4 + .../240x240/places/clarity-default-cover.png | Bin 0 -> 34037 bytes plugins/clarity/icons/hicolor/24x24/Makefile.am | 1 + .../clarity/icons/hicolor/24x24/places/Makefile.am | 4 + .../hicolor/24x24/places/clarity-default-cover.png | Bin 0 -> 1203 bytes plugins/clarity/icons/hicolor/32x32/Makefile.am | 1 + .../clarity/icons/hicolor/32x32/places/Makefile.am | 4 + .../hicolor/32x32/places/clarity-default-cover.png | Bin 0 -> 1835 bytes plugins/clarity/icons/hicolor/48x48/Makefile.am | 1 + .../clarity/icons/hicolor/48x48/places/Makefile.am | 4 + .../hicolor/48x48/places/clarity-default-cover.png | Bin 0 -> 3271 bytes plugins/clarity/icons/hicolor/Makefile.am | 1 + plugins/clarity/plugin.c | 181 +++++++ plugins/clarity/plugin.h | 64 +++ src/main.c | 10 + 51 files changed, 3765 insertions(+), 3 deletions(-) --- diff --git a/configure.ac b/configure.ac index a2a9069..f945310 100644 --- a/configure.ac +++ b/configure.ac @@ -93,8 +93,8 @@ GTK_CLEANLINESS_FLAGS="-DG_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_I dnl Force C99 mode (no implicit int declarations) CFLAGS="$CFLAGS -std=gnu99 -Werror-implicit-function-declaration" -CFLAGS="$CFLAGS $GTK_CFLAGS $GLIB_CFLAGS $GDK_CFLAGS $GMODULE_CFLAGS $GTHREAD_CFLAGS $LIBGLADE_CFLAGS $LIBGPOD_CFLAGS $LIBANJUTA_CFLAGS $LIBGDL_CFLAGS $LIBXML_CFLAGS $GTK_CLEANLINESS_FLAGS" -LIBS="$LIBS $GTK_LIBS $GLIB_LIBS $GDK_LIBS $GMODULE_LIBS $GTHREAD_LIBS $LIBGLADE_LIBS $LIBGPOD_LIBS $LIBANJUTA_LIBS $LIBGDL_LIBS $LIBXML_LIBS" +CFLAGS="$CFLAGS $GTK_CFLAGS $GLIB_CFLAGS $GDK_CFLAGS $GMODULE_CFLAGS $GTHREAD_CFLAGS $LIBGLADE_CFLAGS $LIBGPOD_CFLAGS $LIBANJUTA_CFLAGS $LIBGDL_CFLAGS $LIBXML_CFLAGS $CLUTTER_CFLAGS $GTK_CLEANLINESS_FLAGS" +LIBS="$LIBS $GTK_LIBS $GLIB_LIBS $GDK_LIBS $GMODULE_LIBS $GTHREAD_LIBS $LIBGLADE_LIBS $LIBGPOD_LIBS $LIBANJUTA_LIBS $LIBGDL_LIBS $LIBXML_LIBS $CLUTTER_LIBS" dnl we need 'flex' @@ -185,6 +185,40 @@ if test "x$have_coverweb" = "xyes"; then AC_SUBST(WEBKIT_LIBS) fi + +dnl Check for clutter gtk +dnl ------------------------------------------------------------- +AC_ARG_ENABLE(plugin-clarity, + AS_HELP_STRING([--disable-plugin-clarity],[Disable clarity plugin for displaying coverart in gtkpod]), + [ if test "$enableval" = "no"; then + user_disabled_clarity=1 + fi ], + [ user_disabled_clarity=0 ]) +AC_MSG_CHECKING(if clarity plugin is disabled) +if test "$user_disabled_clarity" = 1; then + AC_MSG_RESULT(yes) + have_clarity="no" +else + AC_MSG_RESULT(no) + + PKG_CHECK_MODULES(CLUTTER_GTK, + [clutter-gtk-1.0 >= 1.0], + [have_clutter_gtk="yes"], + [have_clutter_gtk="no"]) + have_clarity="yes" +fi +AM_CONDITIONAL(HAVE_CLUTTER_GTK, [test "x$have_clutter_gtk" = "xyes"]) +AM_CONDITIONAL(HAVE_PLUGIN_CLARITY, [test "x$have_clutter_gtk" = "xyes"]) +if test "x$have_clutter_gtk" = "xyes"; then + AC_DEFINE(HAVE_CLUTTER_GTK, 1, [Define if you have clutter gtk support]) + AC_SUBST(CLUTTER_GTK_CFLAGS) + AC_SUBST(CLUTTER_GTK_LIBS) + dnl Need to add to CFLAGS and LIBS so main can init correctly + CFLAGS="$CFLAGS $CLUTTER_GTK_CFLAGS" + LIBS="$LIBS $CLUTTER_GTK_LIBS" +fi + + dnl Check for gstreamer dnl ------------------------------------------------------------- AC_ARG_ENABLE(plugin-media-player, @@ -521,6 +555,21 @@ plugins/mserv/icons/hicolor/32x32/Makefile plugins/mserv/icons/hicolor/32x32/places/Makefile plugins/mserv/icons/hicolor/48x48/Makefile plugins/mserv/icons/hicolor/48x48/places/Makefile +plugins/clarity/Makefile +plugins/clarity/icons/Makefile +plugins/clarity/icons/hicolor/Makefile +plugins/clarity/icons/hicolor/16x16/Makefile +plugins/clarity/icons/hicolor/16x16/places/Makefile +plugins/clarity/icons/hicolor/22x22/Makefile +plugins/clarity/icons/hicolor/22x22/places/Makefile +plugins/clarity/icons/hicolor/24x24/Makefile +plugins/clarity/icons/hicolor/24x24/places/Makefile +plugins/clarity/icons/hicolor/32x32/Makefile +plugins/clarity/icons/hicolor/32x32/places/Makefile +plugins/clarity/icons/hicolor/48x48/Makefile +plugins/clarity/icons/hicolor/48x48/places/Makefile +plugins/clarity/icons/hicolor/240x240/Makefile +plugins/clarity/icons/hicolor/240x240/places/Makefile ]) AC_OUTPUT @@ -547,6 +596,7 @@ echo " MP4 File Type .....: $have_mp4" echo " M4A File Type .....: $have_m4a" echo " Flac File Type .....: $have_flac" echo " Ogg File Type .....: $have_ogg" +echo " Clarity Display Widget .....: $have_clarity" echo " Support for cover download .....: $have_curl" diff --git a/data/glade/clarity.glade b/data/glade/clarity.glade new file mode 120000 index 0000000..2b9cafe --- /dev/null +++ b/data/glade/clarity.glade @@ -0,0 +1 @@ +/home/phantomjinx/programming/cpp/gtkpod/plugins/clarity/clarity.glade \ No newline at end of file diff --git a/data/glade/clarity.xml b/data/glade/clarity.xml new file mode 120000 index 0000000..f1cf8b9 --- /dev/null +++ b/data/glade/clarity.xml @@ -0,0 +1 @@ +/home/phantomjinx/programming/cpp/gtkpod/plugins/clarity/clarity.xml \ No newline at end of file diff --git a/data/ui/clarity.ui b/data/ui/clarity.ui new file mode 120000 index 0000000..c6e7f30 --- /dev/null +++ b/data/ui/clarity.ui @@ -0,0 +1 @@ +/home/phantomjinx/programming/cpp/gtkpod/plugins/clarity/clarity.ui \ No newline at end of file diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 7764027..872d785 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -20,6 +20,7 @@ SUBDIRS = . \ filetype_wav \ filetype_video \ filetype_mp4 \ - filetype_m4a + filetype_m4a \ + clarity # indent diff --git a/plugins/clarity/Makefile.am b/plugins/clarity/Makefile.am new file mode 100644 index 0000000..4b0fd01 --- /dev/null +++ b/plugins/clarity/Makefile.am @@ -0,0 +1,56 @@ +plugin_name = clarity +plugin_file = $(plugin_name).plugin + +# Plugin UI file +clarity_uidir = $(gtkpod_ui_dir) +clarity_ui_DATA = $(plugin_name).ui + +# Plugin Glade file +clarity_gladedir = $(gtkpod_glade_dir) +clarity_glade_DATA = $(plugin_name).xml + +# Plugin Icon file +clarity_pixmapsdir = $(gtkpod_image_dir) +clarity_pixmaps_DATA = + +clarity_plugindir = $(gtkpod_plugin_dir) +clarity_plugin_DATA = + +SUBDIRS = icons + +if HAVE_PLUGIN_CLARITY + +include ../plugins.mk +clarity.plugin: build-plugin-file + +# The plugin +plugin_lib = lib$(plugin_name).so +plugin_LTLIBRARIES = libclarity.la + +# Plugin sources +libclarity_la_SOURCES = plugin.c plugin.h \ + album_model.c album_model.h \ + clarity_cover.c clarity_cover.h \ + clarity_canvas.c clarity_canvas.h \ + clarity_widget.c clarity_widget.h \ + clarity_preview.c clarity_preview.h \ + clarity_utils.c clarity_utils.h \ + clarity_context_menu.c clarity_context_menu.h \ + fetchcover.c fetchcover.h +libclarity_la_CFLAGS = $(CLUTTER_GTK_CFLAGS) +libclarity_la_LDFLAGS = $(GTKPOD_PLUGIN_LDFLAGS) + +# Plugin dependencies +libclarity_la_LIBADD = \ + $(LIBGTKPOD_LIBS) \ + $(LIBANJUTA_LIBS) \ + $(CLUTTER_GTK_LIBS) + +endif + +EXTRA_DIST = \ + $(plugin_file).in \ + $(clarity_plugin_DATA) \ + $(clarity_ui_DATA) \ + $(clarity_glade_DATA) \ + $(clarity_pixmaps_DATA) diff --git a/plugins/clarity/album_model.c b/plugins/clarity/album_model.c new file mode 100644 index 0000000..e09ec96 --- /dev/null +++ b/plugins/clarity/album_model.c @@ -0,0 +1,242 @@ +/* + | Copyright (C) 2002-2011 Jorg Schuler <jcsjcs at users sourceforge net> + | Paul Richardson <phantom_sf at users.sourceforge.net> + | Part of the gtkpod project. + | + | URL: http://www.gtkpod.org/ + | URL: http://gtkpod.sourceforge.net/ + | + | This program is free software; you can redistribute it and/or modify + | it under the terms of the GNU General Public License as published by + | the Free Software Foundation; either version 2 of the License, or + | (at your option) any later version. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, write to the Free Software + | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + | + | iTunes and iPod are trademarks of Apple + | + | This product is not supported/written/published by Apple! + | + */ + +#ifndef ALBUM_MODEL_C_ +#define ALBUM_MODEL_C_ + +#include "album_model.h" +#include "libgtkpod/prefs.h" +#include "libgtkpod/misc.h" + +G_DEFINE_TYPE( AlbumModel, album_model, G_TYPE_OBJECT); + +#define ALBUM_MODEL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ALBUM_TYPE_MODEL, AlbumModelPrivate)) + +struct _AlbumModelPrivate { + + GHashTable *album_hash; + GList *album_key_list; + + gint loaded; +}; + +/** + * + * clarity_widget_free_album: + * + * Destroy an album struct once no longer needed. + * + */ +static void album_model_free_album(AlbumItem *album) { + if (album != NULL) { + if (album->tracks) { + g_list_free(album->tracks); + } + + g_free(album->albumname); + g_free(album->artist); + + if (album->albumart) + g_object_unref(album->albumart); + } +} + +static void album_model_finalize(GObject *gobject) { + AlbumModelPrivate *priv = ALBUM_MODEL_GET_PRIVATE(gobject); + + priv->album_key_list = g_list_remove_all(priv->album_key_list, NULL); + g_hash_table_foreach_remove(priv->album_hash, (GHRFunc) gtk_true, NULL); + g_hash_table_destroy(priv->album_hash); + g_list_free(priv->album_key_list); + + /* call the parent class' finalize() method */ + G_OBJECT_CLASS(album_model_parent_class)->finalize(gobject); +} + +static void album_model_class_init (AlbumModelClass *klass) { + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = album_model_finalize; + + g_type_class_add_private (klass, sizeof (AlbumModelPrivate)); +} + +static void album_model_init (AlbumModel *self) { + AlbumModelPrivate *priv; + + priv = ALBUM_MODEL_GET_PRIVATE (self); + priv->album_hash = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) album_model_free_album); + priv->album_key_list = NULL; + priv->loaded = 0; + +} + +AlbumModel *album_model_new() { + return g_object_new(ALBUM_TYPE_MODEL, NULL); +} + +void album_model_destroy(AlbumModel *model) { + album_model_finalize(G_OBJECT(model)); +} + +void album_model_clear(AlbumModel *model) { + AlbumModelPrivate *priv; + + priv = ALBUM_MODEL_GET_PRIVATE (model); + g_hash_table_remove_all (priv->album_hash); + + g_list_free(priv->album_key_list); + priv->album_key_list = NULL; +} + +static gchar *_create_key(Track *track) { + g_return_val_if_fail(track, ""); + + return g_strconcat(track->artist, "_", track->album, NULL); +} + +void album_model_add_track(AlbumModel *model, Track *track) { + AlbumItem *album; + gchar *album_key; + AlbumModelPrivate *priv; + + priv = ALBUM_MODEL_GET_PRIVATE (model); + album_key = _create_key(track); + /* Check whether an album item has already been created in connection + * with the track's artist and album + */ + album = g_hash_table_lookup(priv->album_hash, album_key); + if (album == NULL) { + /* Album item not found so create a new one and populate */ + album = g_new0 (AlbumItem, 1); + album->albumart = NULL; + album->albumname = g_strdup(track->album); + album->artist = g_strdup(track->artist); + album->tracks = NULL; + album->tracks = g_list_prepend(album->tracks, track); + + /* Insert the new Album Item into the hash */ + g_hash_table_insert(priv->album_hash, album_key, album); + /* Add the key to the list for sorting and other functions */ + priv->album_key_list = g_list_prepend(priv->album_key_list, album_key); + } + else { + /* Album Item found in the album hash so + * append the track to the end of the + * track list */ + g_free(album_key); + album->tracks = g_list_prepend(album->tracks, track); + } +} + +void album_model_reset_loaded_index(AlbumModel *model) { + g_return_if_fail(model); + + AlbumModelPrivate *priv; + priv = ALBUM_MODEL_GET_PRIVATE (model); + priv->loaded = 0; +} + +void album_model_foreach (AlbumModel *model, GFunc func, gpointer user_data) { + g_return_if_fail(model); + g_return_if_fail(func); + + AlbumModelPrivate *priv; + priv = ALBUM_MODEL_GET_PRIVATE (model); + GList *iter = priv->album_key_list; + + while(iter) { + gchar *key = iter->data; + AlbumItem *item = g_hash_table_lookup(priv->album_hash, key); + + (* func) (item, user_data); + + iter = iter->next; + } +} + + +gint album_model_get_size(AlbumModel *model) { + g_return_val_if_fail(model, 0); + + AlbumModelPrivate *priv; + priv = ALBUM_MODEL_GET_PRIVATE (model); + + return g_list_length(priv->album_key_list); +} + +AlbumItem *album_model_get_item(AlbumModel *model, gint index) { + g_return_val_if_fail(model, NULL); + + AlbumModelPrivate *priv; + priv = ALBUM_MODEL_GET_PRIVATE (model); + + gchar *key = g_list_nth_data(priv->album_key_list, index); + return g_hash_table_lookup(priv->album_hash, key); +} + +/** + * compare_album_keys: + * + * Comparison function for comparing keys in + * the key list to sort them into alphabetical order. + * Could use g_ascii_strcasecmp directly but the NULL + * strings cause assertion errors. + * + * @a: first album key to compare + * @b: second album key to compare + * + */ +static gint _compare_album_keys(gchar *a, gchar *b) { + if (a == NULL) + return -1; + if (b == NULL) + return -1; + + return compare_string(a, b, prefs_get_int("cad_case_sensitive")); +} + +gint album_model_get_index(AlbumModel *model, Track *track) { + g_return_val_if_fail(model, -1); + + AlbumModelPrivate *priv; + priv = ALBUM_MODEL_GET_PRIVATE (model); + + gchar *trk_key = _create_key(track); + GList *key = g_list_find_custom(priv->album_key_list, trk_key, (GCompareFunc) _compare_album_keys); + g_return_val_if_fail (key, -1); + + gint index = g_list_position(priv->album_key_list, key); + g_free(trk_key); + + return index; +} + +#endif /* ALBUM_MODEL_C_ */ diff --git a/plugins/clarity/album_model.h b/plugins/clarity/album_model.h new file mode 100644 index 0000000..c8fd53e --- /dev/null +++ b/plugins/clarity/album_model.h @@ -0,0 +1,98 @@ +/* + | Copyright (C) 2002-2011 Jorg Schuler <jcsjcs at users sourceforge net> + | Paul Richardson <phantom_sf at users.sourceforge.net> + | Part of the gtkpod project. + | + | URL: http://www.gtkpod.org/ + | URL: http://gtkpod.sourceforge.net/ + | + | This program is free software; you can redistribute it and/or modify + | it under the terms of the GNU General Public License as published by + | the Free Software Foundation; either version 2 of the License, or + | (at your option) any later version. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, write to the Free Software + | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + | + | iTunes and iPod are trademarks of Apple + | + | This product is not supported/written/published by Apple! + | + */ + +#ifndef ALBUM_MODEL_H_ +#define ALBUM_MODEL_H_ + +#include <gtk/gtk.h> +#include "libgtkpod/itdb.h" + + +G_BEGIN_DECLS + +typedef struct { + GList *tracks; + gchar *albumname; + gchar *artist; + GdkPixbuf *albumart; + + gpointer data; + +} AlbumItem; + +GType album_model_get_type (void); + +#define ALBUM_TYPE_MODEL (album_model_get_type ()) + +#define ALBUM_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ALBUM_TYPE_MODEL, AlbumModel)) + +#define ALBUM_IS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ALBUM_TYPE_MODEL)) + +#define ALBUM_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ALBUM_TYPE_MODEL, AlbumModelClass)) + +#define ALBUM_IS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ALBUM_TYPE_MODEL)) + +#define ALBUM_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ALBUM_TYPE_MODEL, AlbumModelClass)) + +typedef struct _AlbumModelPrivate AlbumModelPrivate; +typedef struct _AlbumModel AlbumModel; +typedef struct _AlbumModelClass AlbumModelClass; + +struct _AlbumModel { + /*<private>*/ + GObject parent; + + /* structure containing private members */ + /*<private>*/ + AlbumModelPrivate *priv; +}; + +struct _AlbumModelClass { + GObjectClass parent_class; + +}; + +AlbumModel *album_model_new(); + +void album_model_destroy(AlbumModel *model); + +void album_model_clear(AlbumModel *model); + +void album_model_add_track(AlbumModel *model, Track *track); + +void album_model_reset_loaded_index(AlbumModel *model); + +void album_model_foreach(AlbumModel *model, GFunc func, gpointer user_data); + +gint album_model_get_size(AlbumModel *model); + +AlbumItem *album_model_get_item(AlbumModel *model, gint index); + +gint album_model_get_index(AlbumModel *model, Track *track); + +#endif /* ALBUM_MODEL_H_ */ diff --git a/plugins/clarity/clarity.plugin b/plugins/clarity/clarity.plugin new file mode 100644 index 0000000..d3cd6e1 --- /dev/null +++ b/plugins/clarity/clarity.plugin @@ -0,0 +1,5 @@ +[Anjuta Plugin] +Location=clarity:ClarityPlugin +Name=Clarity Plugin +Description=Display Cover Artwork of Tracks +Description[it]=Mostra le copertine delle tracce diff --git a/plugins/clarity/clarity.plugin.in b/plugins/clarity/clarity.plugin.in new file mode 100644 index 0000000..0d3469f --- /dev/null +++ b/plugins/clarity/clarity.plugin.in @@ -0,0 +1,4 @@ +[Anjuta Plugin] +Location=clarity:ClarityPlugin +_Name=Clarity Plugin +_Description=Display Cover Artwork of Tracks diff --git a/plugins/clarity/clarity.ui b/plugins/clarity/clarity.ui new file mode 100644 index 0000000..b141558 --- /dev/null +++ b/plugins/clarity/clarity.ui @@ -0,0 +1,7 @@ +<!--*- xml -*--> +<ui> + <menubar name="MenuMain"> + </menubar> + <toolbar name="ToolbarMain"> + </toolbar> +</ui> diff --git a/plugins/clarity/clarity.xml b/plugins/clarity/clarity.xml new file mode 100644 index 0000000..063c0fe --- /dev/null +++ b/plugins/clarity/clarity.xml @@ -0,0 +1,312 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="2.16"/> + <object class="GtkWindow" id="preference_window"> + <property name="can_focus">False</property> + <child> + <object class="GtkNotebook" id="cover_settings_notebook"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkVBox" id="vbox5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">12</property> + <property name="spacing">18</property> + <child> + <object class="GtkFrame" id="frame15"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment29"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkHBox" id="hbox214"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">12</property> + <child> + <object class="GtkColorButton" id="coverart_display_bg_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="title" translatable="yes">Choose a Different Colour for the CoverArt Display Background</property> + <property name="color">#000000000000</property> + <signal name="color-set" handler="on_coverart_dialog_bg_color_set" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label472"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Background color</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkColorButton" id="coverart_display_fg_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="title" translatable="yes">Choose a Different Colour for the CoverArt Display Background</property> + <property name="color">#ffffffffffff</property> + <signal name="color-set" handler="on_coverart_dialog_fg_color_set" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label50"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Text color</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label18"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes"><b>Cover Art Display</b></property> + <property name="use_markup">True</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment14"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">start</property> + <property name="spacing">10</property> + <child> + <object class="GtkHBox" id="hbox30"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="n_rows">2</property> + <property name="n_columns">3</property> + <child> + <object class="GtkLabel" id="label82"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes"><b>Ascending</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label85"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes"><b>Descending</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="cad_ascend"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="draw_indicator">True</property> + <property name="group">cad_none</property> + <signal name="toggled" handler="on_cad_ascend_toggled" swapped="no"/> + <child> + <object class="GtkImage" id="image1928"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="stock">gtk-sort-ascending</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options"></property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="cad_descend"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="draw_indicator">True</property> + <property name="group">cad_none</property> + <signal name="toggled" handler="on_cad_descend_toggled" swapped="no"/> + <child> + <object class="GtkImage" id="image1929"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="stock">gtk-sort-descending</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options"></property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label86"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes"><b>None</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="y_options"></property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="cad_none"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_cad_none_toggled" swapped="no"/> + <child> + <object class="GtkImage" id="image1930"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="stock">gtk-undo</property> + </object> + </child> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options"></property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="cad_cfg_case_sensitive"> + <property name="label" translatable="yes">Case sensitive sorting</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_cad_sort_case_sensitive_toggled" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes"><b>Album Cover Sort Order</b></property> + <property name="use_markup">True</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel" id="display_page_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Cover Art Display</property> + </object> + <packing> + <property name="tab_fill">False</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c new file mode 100644 index 0000000..f95d2cc --- /dev/null +++ b/plugins/clarity/clarity_canvas.c @@ -0,0 +1,514 @@ +/* + | Copyright (C) 2002-2011 Jorg Schuler <jcsjcs at users sourceforge net> + | Paul Richardson <phantom_sf at users.sourceforge.net> + | Part of the gtkpod project. + | + | URL: http://www.gtkpod.org/ + | URL: http://gtkpod.sourceforge.net/ + | + | This program is free software; you can redistribute it and/or modify + | it under the terms of the GNU General Public License as published by + | the Free Software Foundation; either version 2 of the License, or + | (at your option) any later version. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, write to the Free Software + | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + | + | iTunes and iPod are trademarks of Apple + | + | This product is not supported/written/published by Apple! + | + */ +#include <clutter-gtk/clutter-gtk.h> +#include "libgtkpod/gp_itdb.h" +#include "plugin.h" +#include "clarity_cover.h" +#include "clarity_canvas.h" +#include "clarity_preview.h" +#include "clarity_utils.h" + +G_DEFINE_TYPE( ClarityCanvas, clarity_canvas, GTK_TYPE_BOX); + +#define CLARITY_CANVAS_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLARITY_TYPE_CANVAS, ClarityCanvasPrivate)) + +#define MAX_ANGLE 70 +#define COVER_SPACE 50 +#define FRONT_COVER_SPACE 150 +#define MAX_SCALE 1.4 +#define VISIBLE_ITEMS 8 + +struct _ClarityCanvasPrivate { + + AlbumModel *model; + + // clutter embed widget + GtkWidget *embed; + + // clutter items + GList *covers; + ClutterActor *container; + ClutterTimeline *timeline; + ClutterAlpha *alpha; + + gint curr_index; + + gulong preview_signal; +}; + +enum DIRECTION { + MOVE_LEFT = -1, + MOVE_RIGHT = 1 +}; + +static void clarity_canvas_finalize(GObject *gobject) { + ClarityCanvasPrivate *priv = CLARITY_CANVAS(gobject)->priv; + + //FIXME +// g_list_free_full(priv->covers, clarity_cover_destroy); + + if (G_IS_OBJECT(priv->alpha)) + g_object_unref(priv->alpha); + + if (G_IS_OBJECT(priv->timeline)) + g_object_unref(priv->timeline); + + if (GTK_IS_WIDGET(priv->embed)) + gtk_widget_destroy(priv->embed); + + /* call the parent class' finalize() method */ + G_OBJECT_CLASS(clarity_canvas_parent_class)->finalize(gobject); +} + +static void clarity_canvas_class_init(ClarityCanvasClass *klass) { + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = clarity_canvas_finalize; + + g_type_class_add_private(klass, sizeof(ClarityCanvasPrivate)); +} + +static gboolean _preview_cover_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) { + ClarityCanvas *ccanvas = CLARITY_CANVAS(widget); + ClarityCanvasPrivate *priv = ccanvas->priv; + + if (!priv->model) + return TRUE; + + AlbumItem *item = album_model_get_item(priv->model, priv->curr_index); + + GtkWidget *dialog = clarity_preview_new(item); + + /* Display the dialog */ + gtk_widget_show_all(dialog); + + return TRUE; +} + +/** + * embed_widget_size_allocated_cb + * + * Ensures that when the embed gtk widget is resized or moved + * around the clutter animations are centred correctly. + * + * This finds the new dimensions of the stage each time and centres + * the group container accordingly. + * + */ +void _embed_widget_size_allocated_cb(GtkWidget *widget, + GtkAllocation *allocation, + gpointer data) { + ClarityCanvasPrivate *priv = (ClarityCanvasPrivate *) data; + ClutterActor *stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(widget)); + + gint centreX = clutter_actor_get_width(stage) / 2; + gint centreY = clutter_actor_get_height(stage) / 2; + clutter_actor_set_position(priv->container, centreX, centreY); +} + +static void clarity_canvas_init(ClarityCanvas *self) { + ClarityCanvasPrivate *priv; + + self->priv = CLARITY_CANVAS_GET_PRIVATE (self); + + priv = self->priv; + + priv->container = clutter_group_new(); + clutter_actor_set_reactive(priv->container, TRUE); + priv->preview_signal = g_signal_connect (self, + "button-press-event", + G_CALLBACK (_preview_cover_cb), + priv); + + priv->embed = gtk_clutter_embed_new(); + /* + * Minimum size before the scrollbars of the parent window + * are displayed. + */ + gtk_widget_set_size_request(GTK_WIDGET(priv->embed), DEFAULT_IMG_SIZE * 4, DEFAULT_IMG_SIZE * 2.5); + /* + * Ensure that things are always centred when the embed + * widget is resized. + */ + g_signal_connect(priv->embed, "size-allocate", + G_CALLBACK(_embed_widget_size_allocated_cb), priv); + + ClutterActor *stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->embed)); + clutter_container_add_actor(CLUTTER_CONTAINER(stage), priv->container); + + gtk_widget_show(priv->embed); + + gtk_box_pack_start(GTK_BOX(self), priv->embed, TRUE, TRUE, 0); + + priv->covers = NULL; + priv->timeline = clutter_timeline_new(1600); + priv->alpha = clutter_alpha_new_full(priv->timeline, CLUTTER_EASE_OUT_EXPO); + priv->curr_index = 0; + +} + +GtkWidget *clarity_canvas_new() { + return g_object_new(CLARITY_TYPE_CANVAS, NULL); +} + +/** + * coverart_get_background_display_color: + * + * Returns the background color of the clarity canvas. + * + * The return value is a hexstring in the form "rrggbbaa" + * + */ +gchar *clarity_canvas_get_background_color(ClarityCanvas *self) { + g_return_val_if_fail(CLARITY_IS_CANVAS(self), NULL); + + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + ClutterActor *stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->embed)); + + ClutterColor *ccolor; + ccolor = g_malloc(sizeof(ClutterColor)); + + clutter_stage_get_color(CLUTTER_STAGE(stage), ccolor); + g_return_val_if_fail(ccolor, NULL); + + return clutter_color_to_string(ccolor); +} + +void clarity_canvas_set_background(ClarityCanvas *self, const gchar *color_string) { + g_return_if_fail(self); + g_return_if_fail(color_string); + + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + ClutterActor *stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->embed)); + + ClutterColor *ccolor; + ccolor = g_malloc(sizeof(ClutterColor)); + + clutter_color_from_string(ccolor, color_string); + clutter_stage_set_color(CLUTTER_STAGE(stage), ccolor); +} + +void clarity_canvas_clear(ClarityCanvas *self) { + g_return_if_fail(self); + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + if (CLUTTER_IS_ACTOR(priv->container)) { + GList *iter = priv->covers; + while(iter) { + ClarityCover *ccover = iter->data; + // cover is not referenced anywhere else so it should be destroyed too + clutter_container_remove(CLUTTER_CONTAINER(priv->container), CLUTTER_ACTOR(ccover), NULL); + iter = iter->next; + } + } + + priv->covers = NULL; + priv->model = NULL; + priv->curr_index = 0; +} + +static void _calculate_index_angle_and_dir (gint dist_from_front, enum DIRECTION dir, gint *angle, ClutterRotateDirection *rotation_dir) { + /* The front item direction depends on the direction we came from */ + if (dist_from_front == 0) { + *rotation_dir = (dir == MOVE_RIGHT ? CLUTTER_ROTATE_CCW : CLUTTER_ROTATE_CW); + *angle = 0; + } + + /* Item on the right */ + else if (dist_from_front > 0) { + *rotation_dir = CLUTTER_ROTATE_CCW; + *angle = 360 - MAX_ANGLE; + } + + /* Item on the left */ + else if (dist_from_front < 0) { + *rotation_dir = CLUTTER_ROTATE_CW; + *angle = MAX_ANGLE; + } +} + +static gint _calculate_index_distance (gint dist_from_front) { + gint dist = ((ABS(dist_from_front) - 1) * COVER_SPACE) + FRONT_COVER_SPACE; + + if (dist_from_front == 0) + return 0; + + return (dist_from_front > 0 ? dist : 0 - dist); +} + +static float _calculate_index_scale(gint dist_from_front) { + if (dist_from_front == 0) + return MAX_SCALE; + else + return 1; +} + +static gint _calculate_index_opacity (gint dist_from_front) { + return CLAMP ( 255 * (VISIBLE_ITEMS - ABS(dist_from_front)) / VISIBLE_ITEMS, 0, 255); +} + +static void _display_clarity_cover(ClarityCover *ccover, gint index) { + ClutterTimeline *timeline = clutter_timeline_new(1600 * 5); + ClutterAlpha *alpha = clutter_alpha_new_full (timeline, CLUTTER_EASE_OUT_EXPO); + + gint opacity = _calculate_index_opacity(index); + clutter_actor_animate_with_alpha(CLUTTER_ACTOR(ccover), alpha, "opacity", opacity, NULL); + clutter_timeline_start (timeline); +} + +static gboolean _create_cover_idle(gpointer data) { + + AlbumItem *album_item = (AlbumItem *) data; + GObject *gobject = album_item->data; + + g_return_val_if_fail(CLARITY_IS_CANVAS(gobject), FALSE); + ClarityCanvas *ccanvas = CLARITY_CANVAS(gobject); + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(ccanvas); + + gint index = g_list_length(priv->covers); + ClarityCover *ccover = clarity_cover_new(); + clutter_actor_set_opacity(CLUTTER_ACTOR(ccover), 0); + priv->covers = g_list_append(priv->covers, ccover); + + clutter_container_add_actor( + CLUTTER_CONTAINER(priv->container), + CLUTTER_ACTOR(ccover)); + + clarity_cover_set_album_item(ccover, album_item); + + //TEXT + //FIXME +// temp.filename = filename; +// temp.filetype = filetype; + + //FIXME + // Confirm whether this does improve performance + if(index > 20) + return FALSE; + + gint pos = _calculate_index_distance(index); + float scale = _calculate_index_scale(index); + + gint angle; + ClutterRotateDirection rotation_dir; + _calculate_index_angle_and_dir(index, MOVE_LEFT, &angle, &rotation_dir); + + clutter_actor_set_rotation( + CLUTTER_ACTOR(ccover), + CLUTTER_Y_AXIS, + angle, + clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, + 0, 0); + + clutter_actor_set_position( + CLUTTER_ACTOR(ccover), + pos - clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, + 110 - clutter_actor_get_height(CLUTTER_ACTOR(ccover))); + + clutter_actor_set_scale_full( + CLUTTER_ACTOR(ccover), + scale, + scale, + clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, + clutter_actor_get_height(CLUTTER_ACTOR(ccover)) / 2); + + clutter_actor_lower_bottom(CLUTTER_ACTOR(ccover)); + + _display_clarity_cover(ccover, index); + + return FALSE; +} + +void _init_album_item(gpointer data, gpointer user_data) { + AlbumItem *item = (AlbumItem *) data; + ClarityCanvas *cc = CLARITY_CANVAS(user_data); + + gdk_threads_enter(); + + Track *track = g_list_nth_data(item->tracks, 0); + item->albumart = _get_track_image(track); + item->data = cc; + + g_idle_add_full(G_PRIORITY_LOW, _create_cover_idle, item, NULL); + + gdk_threads_leave(); +} + +static gpointer _init_album_model_threaded(gpointer data) { + g_return_val_if_fail(CLARITY_IS_CANVAS(data), NULL); + + ClarityCanvas *cc = CLARITY_CANVAS(data); + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(cc); + AlbumModel *model = priv->model; + + album_model_foreach(model, _init_album_item, cc); + + return NULL; +} + +void clarity_canvas_init_album_model(ClarityCanvas *self, AlbumModel *model) { + g_return_if_fail(self); + g_return_if_fail(model); + + if (album_model_get_size(model) == 0) + return; + + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + priv->model = model; + album_model_reset_loaded_index(model); + + g_thread_create_full(_init_album_model_threaded, self, /* user data */ + 0, /* stack size */ + FALSE, /* joinable */ + TRUE, /* bound */ + G_THREAD_PRIORITY_LOW, NULL); + +} + +static void _clear_rotation_behaviours(GList *covers) { + //Clear rotation behaviours + GList *iter = covers; + while (iter) { + ClarityCover *ccover = iter->data; + clarity_cover_clear_rotation_behaviour(ccover); + iter = iter->next; + } +} + +static void _animate_indices(ClarityCanvasPrivate *priv, enum DIRECTION direction, gint increment) { + + for (gint i = 0; i < g_list_length(priv->covers); ++i) { + + ClarityCover *ccover = g_list_nth_data(priv->covers, i); + + gint dist = i - priv->curr_index + (direction * increment); + gfloat depth = 1; + gint pos = 0; + gint opacity = 0; + gint angle = 0; + ClutterRotateDirection rotation_dir; + + opacity = _calculate_index_opacity(dist); + depth = _calculate_index_scale(dist); + pos = _calculate_index_distance(dist); + _calculate_index_angle_and_dir(dist, direction, &angle, &rotation_dir); + + /*Rotation*/ + clarity_cover_set_rotation_behaviour(ccover, priv->alpha, angle, rotation_dir); + + /* Opacity */ + clutter_actor_animate_with_alpha (CLUTTER_ACTOR(ccover), priv->alpha, + "opacity", opacity, + NULL); + + /* Position and scale */ + clutter_actor_animate_with_alpha (CLUTTER_ACTOR(ccover), priv->alpha, + "scale-x", depth, + "scale-y", depth, + "scale-center-x" , clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2, + "scale-center-y" , clutter_actor_get_height(CLUTTER_ACTOR(ccover)) / 2, + "x", pos - clutter_actor_get_width(CLUTTER_ACTOR(ccover)) / 2 , + NULL); + } +} + +static void _restore_z_order(ClarityCanvasPrivate *priv) { + + if (g_list_length(priv->covers) == 0) + return; + + GList *main_cover = g_list_nth(priv->covers, priv->curr_index); + g_return_if_fail(main_cover); + + GList *iter = main_cover ->prev; + while(iter) { + ClarityCover *ccover = iter->data; + clutter_actor_lower_bottom(CLUTTER_ACTOR(ccover)); + iter = iter->prev; + } + + iter = main_cover->next; + while(iter) { + ClarityCover *ccover = iter->data; + clutter_actor_lower_bottom(CLUTTER_ACTOR(ccover)); + iter = iter->next; + } +} + +static void _move(ClarityCanvasPrivate *priv, enum DIRECTION direction, gint increment) { + /* Stop any animation */ + clutter_timeline_stop(priv->timeline); + + /* Clear all current rotation behaviours */ + _clear_rotation_behaviours(priv->covers); + + /* Animate to move left */ + _animate_indices (priv, direction, increment); + + /* Begin the animation */ + clutter_timeline_start(priv->timeline); + + priv->curr_index += ((direction * -1) * increment); + +// update_text (); + _restore_z_order(priv); +} + +void clarity_canvas_move_left(ClarityCanvas *self, gint increment) { + g_return_if_fail(self); + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + if(priv->curr_index == g_list_length(priv->covers) - 1) + return; + + _move(priv, MOVE_LEFT, increment); +} + +void clarity_canvas_move_right(ClarityCanvas *self, gint increment) { + g_return_if_fail(self); + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + if(priv->curr_index == 0) + return; + + _move(priv, MOVE_RIGHT, increment); +} + +gint clarity_canvas_get_current_index(ClarityCanvas *self) { + g_return_val_if_fail(self, 0); + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + return priv->curr_index; +} + + + diff --git a/plugins/clarity/clarity_canvas.h b/plugins/clarity/clarity_canvas.h new file mode 100644 index 0000000..cf22471 --- /dev/null +++ b/plugins/clarity/clarity_canvas.h @@ -0,0 +1,87 @@ +/* + | Copyright (C) 2002-2011 Jorg Schuler <jcsjcs at users sourceforge net> + | Paul Richardson <phantom_sf at users.sourceforge.net> + | Part of the gtkpod project. + | + | URL: http://www.gtkpod.org/ + | URL: http://gtkpod.sourceforge.net/ + | + | This program is free software; you can redistribute it and/or modify + | it under the terms of the GNU General Public License as published by + | the Free Software Foundation; either version 2 of the License, or + | (at your option) any later version. + | + | This program is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + | GNU General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, write to the Free Software + | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + | + | iTunes and iPod are trademarks of Apple + | + | This product is not supported/written/published by Apple! + | + */ + +#include <gtk/gtk.h> +#include "album_model.h" + +#ifndef CLARITY_CANVAS_H_ +#define CLARITY_CANVAS_H_ + +G_BEGIN_DECLS + +GType clarity_canvas_get_type (void); + +#define CLARITY_TYPE_CANVAS (clarity_canvas_get_type ()) + +#define CLARITY_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLARITY_TYPE_CANVAS, ClarityCanvas)) + +#define CLARITY_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLARITY_TYPE_CANVAS)) + +#define CLARITY_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLARITY_TYPE_CANVAS, ClarityCanvasClass)) + +#define CLARITY_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLARITY_TYPE_CANVAS)) + +#define CLARITY_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLARITY_TYPE_CANVAS, ClarityCanvasClass)) + +typedef struct _ClarityCanvasPrivate ClarityCanvasPrivate; +typedef struct _ClarityCanvas ClarityCanvas; +typedef struct _ClarityCanvasClass ClarityCanvasClass; + +struct _ClarityCanvas { + /*<private>*/ + GtkBox parent_instance; + + /* structure containing private members */ + /*<private>*/ + ClarityCanvasPrivate *priv; +}; + +struct _ClarityCanvasClass { + GtkBoxClass parent_class; + +}; + +GtkWidget * clarity_canvas_new(); + +gchar *clarity_canvas_get_background_color(ClarityCanvas *self); + +void clarity_canvas_set_background(ClarityCanvas *self, const gchar *color_string); + +void clarity_canvas_clear(ClarityCanvas *self); + +void clarity_canvas_init_album_model(ClarityCanvas *self, AlbumModel *model); + +void clarity_canvas_move_left(ClarityCanvas *self, gint increment); + +void clarity_canvas_move_right(ClarityCanvas *self, gint increment); + +gint clarity_canvas_get_current_index(ClarityCanvas *self); + +G_END_DECLS + +#endif /* CLARITY_CANVAS_H_ */ diff --git a/plugins/clarity/clarity_context_menu.c b/plugins/clarity/clarity_context_menu.c new file mode 100644 index 0000000..aeea9ea --- /dev/null +++ b/plugins/clarity/clarity_context_menu.c @@ -0,0 +1,80 @@ +/* + | Copyright (C) 2002-2010 Jorg Schuler <jcsjcs at users sou... [truncated message content] |
From: phantomjinx <pha...@us...> - 2011-09-02 22:31:03
|
commit a88d5cc705af526c6553116725517ae6e8e7d6b2 Author: phantomjinx <p.g...@ph...> Date: Wed Aug 24 10:29:54 2011 +0100 Stop unrefing NULL album art * When loading covers in coverart display, we are unrefing the albumart regardless of whether it has been loaded or whether there is any. Check whether we actually have a reference before unrefing it. plugins/cover_display/display_coverart.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) --- diff --git a/plugins/cover_display/display_coverart.c b/plugins/cover_display/display_coverart.c index f108e93..fe563c9 100644 --- a/plugins/cover_display/display_coverart.c +++ b/plugins/cover_display/display_coverart.c @@ -398,8 +398,11 @@ static void draw(cairo_t *cairo_context) { cover->album = album; if (force_pixbuf_covers) { - g_object_unref(album->albumart); - album->albumart = NULL; + if (album->albumart) { + g_object_unref(album->albumart); + album->albumart = NULL; + } + if (album->scaled_art != NULL) { g_object_unref(album->scaled_art); album->scaled_art = NULL; |
From: phantomjinx <pha...@us...> - 2011-09-02 22:30:56
|
The branch 'clarity' was created. Summary of new commits: a88d5cc... Stop unrefing NULL album art 0bc65d5... New coverart display plugin 'clarity' 56885a2... Allow broadcasting of all types of preference b69b39d... Cover display not disconnecting on deactivate 37e584f... Implement clarity preferences 1172a33... clarity labelling of covers b8f951b... Add a reference to current playlist to clarity widget b7c9145... Support for clarity detecting track additions 4d91390... Ensure tracks are sorted before selecting 50b3e6d... Remove extraneous logging f8bf1e9... Support for track removal in Clarity |
From: phantomjinx <pha...@us...> - 2011-08-06 17:15:53
|
commit 722671aa8bc1e7edee69d1c771778c00fd075421 Author: phantomjinx <p.g...@ph...> Date: Sat Aug 6 18:14:50 2011 +0100 Update NEWS and Changelog * Final update prior to release of 2.1.0 ChangeLog | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- NEWS | 5 +++++ 2 files changed, 53 insertions(+), 1 deletions(-) --- diff --git a/ChangeLog b/ChangeLog index 9c1a602..8f32e26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,51 @@ -phantomjinx <p.g...@ph...> 2011-07-24 +phantomjinx <p.g...@ph...> 2011-08-06 + + Update NEWS and Changelog + + * Final update prior to release of 2.1.0 + +phantomjinx <p.g...@ph...> 2011-08-06 + + Replace bugs url from sourceforge to flyspray + +phantomjinx <p.g...@ph...> 2011-08-06 + + Correction of desktop file + + * Fixed as per task FS#78 + +phantomjinx <p.g...@ph...> 2011-08-02 + + Replacement of deprecated gtk_[vh]box_new + + * In gtk3, gtk_hbox_new and gtk_vbox_new have been deprecated / removed + in favor of gtk_box_new, which handles both cases. + + * Bug 3383833 + + * Thanks to dimstar for the patch. + +phantomjinx <p.g...@ph...> 2011-08-02 + + G_CONST_RETURN has been deprecated / removed in gtk3 + + * See bug 3383824. Thanks to the contributor of the bug for the patch. + +phantomjinx <p.g...@ph...> 2011-08-02 + + With move to gtk 3 assume gsealed gdk + + * Assume a gdk library greater than or equal to 3.0.11 + + * Assume the gdk library is gsealed and no longer any need for + compatibility macros for gdk_dragging. + + * These macros will be maintained in the gtk2 branches. + + * Bug identified and investigate in #3323692 - Thanks to dimstar for the + investigation and suggested fix. + +phantomjinx <p.g...@ph...> 2011-07-30 Update news and translation files for gtk 3.0 release diff --git a/NEWS b/NEWS index df38804..b8a80ea 100644 --- a/NEWS +++ b/NEWS @@ -4,10 +4,15 @@ gtkpod V2.1.0 IMPROVEMENT: Migrates the application to the new gtk 3.0 framework. + UPDATE: Removal of GSEALED checks on gdk due to assumption of gdk 3 being + sealed. + BUGFIX: Allow LDFLAGS to be specified on command line. BUGFIX: Fix compilation error for the mac port. + BUGFIX: Removed deprecated gtk / gdk function calls - thanks to dimstar + gtkpod V2.0.2 |
From: phantomjinx <pha...@us...> - 2011-08-06 17:15:46
|
commit b3bd5b26d8ceba6411cf6044adb849ae2da52dfb Author: phantomjinx <p.g...@ph...> Date: Sat Aug 6 17:50:29 2011 +0100 Replace bugs url from sourceforge to flyspray src/anjuta-action-callbacks.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) --- diff --git a/src/anjuta-action-callbacks.c b/src/anjuta-action-callbacks.c index 034785b..fc3f732 100644 --- a/src/anjuta-action-callbacks.c +++ b/src/anjuta-action-callbacks.c @@ -137,7 +137,7 @@ on_url_home_activate (GtkAction * action, gpointer user_data) void on_url_bugs_activate (GtkAction * action, gpointer user_data) { - anjuta_res_url_show("http://sourceforge.net/tracker/?group_id=67873&atid=519273"); + anjuta_res_url_show("http://gtkpod.org/bugs/"); } void |
From: phantomjinx <pha...@us...> - 2011-08-06 17:15:40
|
commit 00748fe9d99afdfd49341d0b554c07f9f843a088 Author: phantomjinx <p.g...@ph...> Date: Sat Aug 6 17:07:32 2011 +0100 Correction of desktop file * Fixed as per task FS#78 data/gtkpod.desktop.in | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) --- diff --git a/data/gtkpod.desktop.in b/data/gtkpod.desktop.in index 26e793d..30a306a 100644 --- a/data/gtkpod.desktop.in +++ b/data/gtkpod.desktop.in @@ -1,5 +1,5 @@ [Desktop Entry] -_Name=gtkpod iPod Manager +_Name=gtkpod _GenericName=iPod Manager _Comment=Manage music and video on an Apple iPod Exec=gtkpod @@ -7,3 +7,4 @@ Icon=gtkpod Terminal=false Type=Application Categories=GTK;AudioVideo; +X-GNOME-FullName=gtkpod iPod Manager |
From: phantomjinx <pha...@us...> - 2011-08-02 20:58:48
|
commit ce6e1ce2b4e9dbdb63a87527530a90d752aa843a Author: phantomjinx <p.g...@ph...> Date: Tue Aug 2 21:51:14 2011 +0100 Replacement of deprecated gtk_[vh]box_new * In gtk3, gtk_hbox_new and gtk_vbox_new have been deprecated / removed in favor of gtk_box_new, which handles both cases. * Bug 3383833 * Thanks to dimstar for the patch. libgtkpod/tools.c | 2 +- plugins/coverweb/coverweb.c | 2 +- plugins/playlist_display/display_playlists.c | 2 +- plugins/playlist_display/playlist_display_spl.c | 4 ++-- src/anjuta-app.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) --- diff --git a/libgtkpod/tools.c b/libgtkpod/tools.c index fb41a99..0fa6e19 100644 --- a/libgtkpod/tools.c +++ b/libgtkpod/tools.c @@ -309,7 +309,7 @@ void nm_tracks_list(GList *list) { gtk_label_set_selectable(GTK_LABEL (label), TRUE); /* hbox to put the image+label in */ - hbox = gtk_hbox_new(FALSE, 6); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start(GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX (hbox), label, FALSE, FALSE, 0); diff --git a/plugins/coverweb/coverweb.c b/plugins/coverweb/coverweb.c index 5877f91..26a6314 100644 --- a/plugins/coverweb/coverweb.c +++ b/plugins/coverweb/coverweb.c @@ -178,7 +178,7 @@ WebBrowser *init_web_browser(GtkWidget *parent) { create_browser(); create_statusbar(); - GtkWidget* vbox = gtk_vbox_new(FALSE, 0); + GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start(GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), browser->toolbar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), browser->browser_window, TRUE, TRUE, 0); diff --git a/plugins/playlist_display/display_playlists.c b/plugins/playlist_display/display_playlists.c index 501cf27..6004f3b 100644 --- a/plugins/playlist_display/display_playlists.c +++ b/plugins/playlist_display/display_playlists.c @@ -1986,7 +1986,7 @@ GtkWidget *pm_create_playlist_view(GtkActionGroup *action_group) { GtkBox *vbox; GtkScrolledWindow *scrolledwin; - vbox = GTK_BOX(gtk_vbox_new (FALSE, 0)); + vbox = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); pm_create_toolbar(action_group); gtk_box_pack_start(vbox, GTK_WIDGET(playlist_toolbar), FALSE, TRUE, 0); diff --git a/plugins/playlist_display/playlist_display_spl.c b/plugins/playlist_display/playlist_display_spl.c index 11f1064..88f86e8 100644 --- a/plugins/playlist_display/playlist_display_spl.c +++ b/plugins/playlist_display/playlist_display_spl.c @@ -981,7 +981,7 @@ static GtkWidget *spl_create_hbox(GtkWidget *spl_window, Itdb_SPLRule *splr) { g_return_val_if_fail (at != ITDB_SPLAT_UNKNOWN, NULL); g_return_val_if_fail (at != ITDB_SPLAT_INVALID, NULL); - hbox = gtk_hbox_new(FALSE, 3); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3); gtk_widget_show(hbox); g_object_set_data(G_OBJECT (hbox), "spl_window", spl_window); @@ -1240,7 +1240,7 @@ static void spl_update_rule(GtkWidget *spl_window, Itdb_SPLRule *splr) { hbox = g_object_get_data(G_OBJECT (table), name); if (!hbox) { /* create hbox with buttons */ - hbox = gtk_hbox_new(TRUE, 2); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_show(hbox); g_object_set_data(G_OBJECT (table), name, hbox); gtk_table_attach(table, hbox, 3, 4, row, row + 1, 0, 0, /* expand options */ diff --git a/src/anjuta-app.c b/src/anjuta-app.c index 6940d67..ec9d76b 100644 --- a/src/anjuta-app.c +++ b/src/anjuta-app.c @@ -451,7 +451,7 @@ static void anjuta_app_instance_init(AnjutaApp *app) { /* * Main box */ - main_box = gtk_vbox_new(FALSE, 0); + main_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER (app), main_box); gtk_widget_show(main_box); @@ -471,7 +471,7 @@ static void anjuta_app_instance_init(AnjutaApp *app) { g_object_add_weak_pointer(G_OBJECT (app->status), (gpointer) &app->status); /* configure dock */ - hbox = gtk_hbox_new(FALSE, 0); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_show(hbox); app->dock = gdl_dock_new(); gtk_widget_show(app->dock); |
From: phantomjinx <pha...@us...> - 2011-08-02 20:58:41
|
commit f3e5ee8f0fe1586740de3a220367ebe1d8df4afe Author: phantomjinx <p.g...@ph...> Date: Tue Aug 2 21:45:28 2011 +0100 G_CONST_RETURN has been deprecated / removed in gtk3 * See bug 3383824. Thanks to the contributor of the bug for the patch. libgtkpod/file.c | 2 +- libgtkpod/misc.c | 2 +- libgtkpod/misc.h | 6 +++--- libgtkpod/syncdir.c | 2 +- plugins/photo_editor/display_photo.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) --- diff --git a/libgtkpod/file.c b/libgtkpod/file.c index 65d3026..7eed815 100644 --- a/libgtkpod/file.c +++ b/libgtkpod/file.c @@ -394,7 +394,7 @@ gint add_directory_by_name(iTunesDB *itdb, gchar *name, Playlist *plitem, gboole GDir *dir = g_dir_open(name, 0, NULL); block_widgets(); if (dir != NULL) { - G_CONST_RETURN gchar *next; + const gchar *next; do { next = g_dir_read_name(dir); if (next != NULL) { diff --git a/libgtkpod/misc.c b/libgtkpod/misc.c index e1b3d36..bd5b757 100644 --- a/libgtkpod/misc.c +++ b/libgtkpod/misc.c @@ -161,7 +161,7 @@ void update_blocked_widget(GtkWidget *w, gboolean sens) { /* Concats @base_dir and @rel_dir if and only if @rel_dir is not * absolute (does not start with '~' or '/'). Otherwise simply return * a copy of @rel_dir. Must free return value after use */ -gchar *concat_dir_if_relative(G_CONST_RETURN gchar *base_dir, G_CONST_RETURN gchar *rel_dir) { +gchar *concat_dir_if_relative(const gchar *base_dir, const gchar *rel_dir) { /* sanity */ if (!rel_dir || !*rel_dir) return g_build_filename(base_dir, rel_dir, NULL); diff --git a/libgtkpod/misc.h b/libgtkpod/misc.h index 18741f9..8455ef1 100644 --- a/libgtkpod/misc.h +++ b/libgtkpod/misc.h @@ -80,9 +80,9 @@ Playlist *add_new_pl_user_name (iTunesDB *itdb, gchar *dflt, gint32 pos); void add_new_pl_or_spl_user_name (iTunesDB *itdb, gchar *dflt, gint32 pos); void create_add_files_fileselector (void); void create_add_playlists_fileselector (void); -gchar *concat_dir (G_CONST_RETURN gchar *dir, G_CONST_RETURN gchar *file); -gchar *concat_dir_if_relative (G_CONST_RETURN gchar *base_dir, - G_CONST_RETURN gchar *rel_dir); +gchar *concat_dir (const gchar *dir, const gchar *file); +gchar *concat_dir_if_relative (const gchar *base_dir, + const gchar *rel_dir); float get_ms_since (GTimeVal *old_time, gboolean update); gint get_sort_tab_number (gchar *text); gboolean parse_tracks_from_string (gchar **s, Track **track); diff --git a/libgtkpod/syncdir.c b/libgtkpod/syncdir.c index 2ae3216..29bc524 100644 --- a/libgtkpod/syncdir.c +++ b/libgtkpod/syncdir.c @@ -318,7 +318,7 @@ static void add_files(gpointer key, gpointer value, gpointer user_data) { if (g_file_test(dirname, G_FILE_TEST_IS_DIR)) { GDir *dir = g_dir_open(dirname, 0, NULL); if (dir != NULL) { - G_CONST_RETURN gchar *next; + const gchar *next; while ((next = g_dir_read_name(dir))) { gchar *filename = g_build_filename(dirname, next, NULL); FileType *filetype = determine_filetype(filename); diff --git a/plugins/photo_editor/display_photo.c b/plugins/photo_editor/display_photo.c index 322c792..520c124 100644 --- a/plugins/photo_editor/display_photo.c +++ b/plugins/photo_editor/display_photo.c @@ -1153,7 +1153,7 @@ static void on_photodb_add_image_dir_menuItem_activate(GtkMenuItem *menuItem, gp /* Leaf through all the files inside the directory and check if they are image * files. If they are then add them to the database. */ - G_CONST_RETURN gchar *filename; + const gchar *filename; GPtrArray* filename_arr = g_ptr_array_new(); unsigned u; |