commit 563aeaf7904bd236ec5ec656613d8f4c312e0046 Author: phantomjinx <p.g.richard...@phantomjinx.co.uk> Date: Thu Sep 8 21:04:36 2011 +0100
blah plugins/clarity/album_model.c | 4 + plugins/clarity/clarity_canvas.c | 103 ++++++++++++++++++++++++++++-- plugins/clarity/clarity_canvas.h | 11 +++ plugins/clarity/clarity_context_menu.c | 72 ++++++++------------ plugins/clarity/clarity_context_menu.h | 12 ++-- plugins/clarity/clarity_widget.c | 80 +++++++++++------------ plugins/cover_display/display_coverart.c | 3 +- plugins/details_editor/details.c | 1 + 8 files changed, 186 insertions(+), 100 deletions(-) --- diff --git a/plugins/clarity/album_model.c b/plugins/clarity/album_model.c index 2779f6a..5db9fb3 100644 --- a/plugins/clarity/album_model.c +++ b/plugins/clarity/album_model.c @@ -142,6 +142,10 @@ static gboolean _insert_track(AlbumModelPrivate *priv, Track *track) { AlbumItem *item; gchar *album_key; + Updating tracks by removing then adding is not working as the item + is never removed so the album item image is never updated! + + 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 diff --git a/plugins/clarity/clarity_canvas.c b/plugins/clarity/clarity_canvas.c index 26b86fe..be04b23 100644 --- a/plugins/clarity/clarity_canvas.c +++ b/plugins/clarity/clarity_canvas.c @@ -27,11 +27,14 @@ */ #include <clutter-gtk/clutter-gtk.h> #include "libgtkpod/gp_itdb.h" +#include "libgtkpod/fileselection.h" +#include "libgtkpod/misc.h" #include "plugin.h" #include "clarity_cover.h" #include "clarity_canvas.h" #include "clarity_preview.h" #include "clarity_utils.h" +#include "clarity_context_menu.h" G_DEFINE_TYPE( ClarityCanvas, clarity_canvas, GTK_TYPE_BOX); @@ -99,12 +102,9 @@ static void clarity_canvas_class_init(ClarityCanvasClass *klass) { 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; - +static void _preview_cover(ClarityCanvasPrivate *priv) { if (!priv->model) - return TRUE; + return; AlbumItem *item = album_model_get_item_with_index(priv->model, priv->curr_index); @@ -112,8 +112,48 @@ static gboolean _preview_cover_cb(GtkWidget *widget, GdkEvent *event, gpointer u /* Display the dialog */ gtk_widget_show_all(dialog); +} + +/** + * on_main_cover_image_clicked_cb: + * + * Call handler used for displaying the tracks associated with + * the main displayed album cover. + * + * @ClarityCanvas + * @event: event object used to determine the event type + * @data: any data needed by the function (not required) + * + */ +static gint _on_main_cover_image_clicked_cb(GtkWidget *widget, GdkEvent *event, gpointer data) { + ClarityCanvas *ccanvas = CLARITY_CANVAS(widget); + ClarityCanvasPrivate *priv = ccanvas->priv; + guint mbutton; + + if (event->type != GDK_BUTTON_PRESS) + return FALSE; - return TRUE; + mbutton = event->button.button; + + if (mbutton == 1) { + _preview_cover(priv); + } + else if ((mbutton == 3) && (event->button.state & GDK_SHIFT_MASK)) { + /* Right mouse button clicked and shift pressed. + * Go straight to edit details window + */ + AlbumItem *item = album_model_get_item_with_index(priv->model, priv->curr_index); + GList *tracks = item->tracks; + gtkpod_edit_details(tracks); + } + else if (mbutton == 3) { + /* Right mouse button clicked on its own so display + * popup menu + */ + clarity_context_menu_init(ccanvas); + } + + return FALSE; } /** @@ -154,7 +194,7 @@ static void clarity_canvas_init(ClarityCanvas *self) { clutter_actor_set_reactive(priv->container, TRUE); priv->preview_signal = g_signal_connect (self, "button-press-event", - G_CALLBACK (_preview_cover_cb), + G_CALLBACK (_on_main_cover_image_clicked_cb), priv); clutter_container_add(CLUTTER_CONTAINER(priv->container), priv->title_text, priv->artist_text, NULL); @@ -661,3 +701,52 @@ void clarity_canvas_remove_album_item(ClarityCanvas *self, AlbumItem *item) { _set_loading_complete(priv, TRUE); } + +/** + * clarity_canvas_set_cover_from_file: + * + * Add a cover to the displayed track by setting it from a + * picture file. + * + */ +void clarity_canvas_set_cover_from_file(ClarityCanvas *self) { + g_return_if_fail(self); + + ClarityCanvasPrivate *priv = CLARITY_CANVAS_GET_PRIVATE(self); + + gchar *filename; + Track *track; + GList *tracks; + + filename = fileselection_get_cover_filename(); + + if (filename) { + AlbumItem *item = album_model_get_item_with_index(priv->model, priv->curr_index); + tracks = g_list_copy(item->tracks); + + while (tracks) { + track = tracks->data; + + if (gp_track_set_thumbnails(track, filename)) { + ExtraTrackData *etd; + etd = track->userdata; + etd->tartwork_changed = TRUE; + + gtkpod_track_updated(track); + data_changed(track->itdb); + + etd->tartwork_changed = FALSE; + } + + tracks = tracks->next; + } + } + + g_free(filename); +} + +void on_clarity_set_cover_menuitem_activate(GtkMenuItem *mi, gpointer data) { + g_return_if_fail(CLARITY_IS_CANVAS(data)); + + clarity_canvas_set_cover_from_file(CLARITY_CANVAS(data)); +} diff --git a/plugins/clarity/clarity_canvas.h b/plugins/clarity/clarity_canvas.h index 3a1a691..23561fa 100644 --- a/plugins/clarity/clarity_canvas.h +++ b/plugins/clarity/clarity_canvas.h @@ -92,6 +92,17 @@ void clarity_canvas_add_album_item(ClarityCanvas *self, AlbumItem *item); void clarity_canvas_remove_album_item(ClarityCanvas *self, AlbumItem *item); +/** + * clarity_canvas_set_cover_from_file: + * + * Add a cover to the displayed track by setting it from a + * picture file. + * + */ +void clarity_canvas_set_cover_from_file(ClarityCanvas *self); + +void on_clarity_set_cover_menuitem_activate(GtkMenuItem *mi, gpointer data); + G_END_DECLS #endif /* CLARITY_CANVAS_H_ */ diff --git a/plugins/clarity/clarity_context_menu.c b/plugins/clarity/clarity_context_menu.c index aeea9ea..a863d9d 100644 --- a/plugins/clarity/clarity_context_menu.c +++ b/plugins/clarity/clarity_context_menu.c @@ -34,47 +34,33 @@ #include "libgtkpod/context_menus.h" #include "libgtkpod/misc.h" #include "clarity_context_menu.h" +#include "clarity_canvas.h" -//static GtkWidget *add_get_cover_from_file(GtkWidget *menu) { -// return hookup_menu_item(menu, _("Select Cover From File"), GTK_STOCK_FLOPPY, G_CALLBACK (clarity_set_cover_from_file), NULL); -//} -// -///* -// * display the dialog with the full size cd artwork cover -// * @mi - the menu item selected -// * @data - Ignored, should be NULL -// */ -//static void display_track_artwork(GtkMenuItem *mi, gpointer data) { -// if (gtkpod_get_selected_tracks()) -// clarity_display_big_artwork(gtkpod_get_selected_tracks()); -//} -// -//static GtkWidget *add_display_big_coverart(GtkWidget *menu) { -// return hookup_menu_item(menu, _("View Full Size Artwork"), GTK_STOCK_FULLSCREEN, G_CALLBACK (display_track_artwork), NULL); -//} -// -///** -// * cad_context_menu_init - initialize the right click menu for coverart display -// */ -//void cad_context_menu_init(void) { -// if (widgets_blocked) -// return; -// -// GtkWidget *menu = NULL; -// -// if (gtkpod_get_selected_tracks()) { -// menu = gtk_menu_new(); -// -// add_get_cover_from_file(menu); -// add_display_big_coverart(menu); -// add_edit_track_details(menu); -// -// /* -// * button should be button 0 as per the docs because we're calling -// * from a button release event -// */ -// if (menu) { -// gtk_menu_popup(GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); -// } -// } -//} +static GtkWidget *add_get_cover_from_file(GtkWidget *menu, ClarityCanvas *ccanvas) { + return hookup_menu_item(menu, _("Select Cover From File"), GTK_STOCK_FLOPPY, G_CALLBACK (on_clarity_set_cover_menuitem_activate), ccanvas); +} + +/** + * clarity_context_menu_init - initialize the right click menu for clarity + */ +void clarity_context_menu_init(ClarityCanvas *ccanvas) { + if (widgets_blocked) + return; + + GtkWidget *menu = NULL; + + if (gtkpod_get_selected_tracks()) { + menu = gtk_menu_new(); + + add_get_cover_from_file(menu, ccanvas); + add_edit_track_details(menu); + + /* + * button should be button 0 as per the docs because we're calling + * from a button release event + */ + if (menu) { + gtk_menu_popup(GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); + } + } +} diff --git a/plugins/clarity/clarity_context_menu.h b/plugins/clarity/clarity_context_menu.h index a2b4606..ce38587 100644 --- a/plugins/clarity/clarity_context_menu.h +++ b/plugins/clarity/clarity_context_menu.h @@ -26,12 +26,14 @@ | */ -#ifndef COVER_DISPLAY_CONTEXT_MENU_H_ -#define COVER_DISPLAY_CONTEXT_MENU_H_ +#ifndef CLARITY_CONTEXT_MENU_H_ +#define CLARTIY_CONTEXT_MENU_H_ + +#include "clarity_canvas.h" /** - * cad_context_menu_init - initialize the right click menu for coverart display + * clarity_context_menu_init - initialize the right click menu for clarity */ -void cad_context_menu_init(void); +void clarity_context_menu_init(ClarityCanvas *ccanvas); -#endif /* COVER_DISPLAY_CONTEXT_MENU_H_ */ +#endif /* CLARITY_CONTEXT_MENU_H_ */ diff --git a/plugins/clarity/clarity_widget.c b/plugins/clarity/clarity_widget.c index ca50d74..2bccbaf 100644 --- a/plugins/clarity/clarity_widget.c +++ b/plugins/clarity/clarity_widget.c @@ -541,72 +541,66 @@ void clarity_widget_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data) if (clarity_canvas_is_loading(ccanvas)) return; - AlbumItem *item; - gboolean findremove = FALSE; + AlbumItem *item = NULL; 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. + if (index > -1) { + /* + * 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. + * b) Artwork has been updated + * c) 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. + * in the album items track list. If it does then b) or c) is true. */ 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 */ + /* + * Track exists in the album list so determine whether + * its artwork is up to date + */ ExtraTrackData *etd; etd = track->userdata; - if (etd->tartwork_changed == TRUE) { - etd->tartwork_changed = FALSE; + if (! etd->tartwork_changed) { + /* + * Artwork is up to date so nothing changed relevant + * to the display. + */ + return; } - - return; } else { - /* Track does not exist in the album list so the artist/album - * key has definitely changed */ - findremove = TRUE; - } - } - - 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 + /* + * Track does not exist in the album list so the artist/album + * key has definitely changed so find the old album item the long + * way. */ - _remove_track(priv, item, track); + item = album_model_search_for_track(priv->album_model, track); } + } - /* Create a new album item or find existing album to house the - * "brand new" track + /* item represents the old album item containing the track */ + if (item) { + /* + * The track is in this album so remove it in preparation for + * readding it back either under the same album item but with + * a different cover or under a different album item due to a + * different album key. */ - _add_track(priv, track); + _remove_track(priv, item, track); } + + /* + * Create a new album item or find existing album to house the + * "brand new" track + */ + _add_track(priv, track); } diff --git a/plugins/cover_display/display_coverart.c b/plugins/cover_display/display_coverart.c index c797dff..ad62e06 100644 --- a/plugins/cover_display/display_coverart.c +++ b/plugins/cover_display/display_coverart.c @@ -949,8 +949,7 @@ void coverart_track_changed(Track *track, gint signal) { /* 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; + if (etd->tartwork_changed) { redraw(TRUE); } diff --git a/plugins/details_editor/details.c b/plugins/details_editor/details.c index 4e0b48c..91087ef 100644 --- a/plugins/details_editor/details.c +++ b/plugins/details_editor/details.c @@ -354,6 +354,7 @@ static void details_button_apply_clicked(GtkButton *button) { changed |= tr_changed; etr->tchanged = FALSE; + etr->tartwork_changed = FALSE; } } ------------------------------------------------------------------------------ Malware Security Report: Protecting Your Business, Customers, and the Bottom Line. Protect your business and customers by understanding the threat from malware and how it can impact your online business. http://www.accelacomm.com/jaw/sfnl/114/51427462/ _______________________________________________ gtkpod-cvs2 mailing list gtkpod-cvs2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2