commit bf381a92d9609d0a8670bff972a8142dca84ecbe
Author: phantomjinx <p.g.richard...@phantomjinx.co.uk>
Date:   Sun May 2 21:39:54 2010 +0100

    Wire up details editor to signals
    
    * default.profile
     * Load details editor plugin upon loading of app
    
    * Connect up signals to detaisl editor track and playlist selection
      callbacks. If changes have been made to displayed tracks in the editor
      then display dialog, asking user whether they are willing to lose the
      changes.

 data/default.profile            |    7 +++++
 plugins/details_editor/plugin.c |    4 ++-
 src/details.c                   |   48 +++++++++++++++++++++++++++++++++++---
 src/details.h                   |    5 ++++
 4 files changed, 59 insertions(+), 5 deletions(-)
---
diff --git a/data/default.profile b/data/default.profile
index ac9756b..b1d15c1 100644
--- a/data/default.profile
+++ b/data/default.profile
@@ -35,4 +35,11 @@
                   attribute="Location"
                   value="repository_editor:RepositoryEditorPlugin"/>
   </plugin>
+  <plugin name="Details Editor Plugin"
+             url="http://www.gtkpod.org/plugins/";
+                 mandatory="yes">
+                 <require group="Anjuta Plugin"
+                  attribute="Location"
+                  value="details_editor:DetailsEditorPlugin"/>
+  </plugin>
 </anjuta>
diff --git a/plugins/details_editor/plugin.c b/plugins/details_editor/plugin.c
index f21b82a..60d5c26 100644
--- a/plugins/details_editor/plugin.c
+++ b/plugins/details_editor/plugin.c
@@ -61,7 +61,9 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) {
 
     gtkpod_register_details_editor (DETAILS_EDITOR(details_editor_plugin));
 
-//    g_signal_connect (gtkpod_app, SIGNAL_TRACK_REMOVED, G_CALLBACK 
(details_editor_track_removed_cb), NULL);
+    g_signal_connect (gtkpod_app, SIGNAL_TRACK_REMOVED, G_CALLBACK 
(details_editor_track_removed_cb), NULL);
+    g_signal_connect (gtkpod_app, SIGNAL_TRACKS_SELECTED, G_CALLBACK 
(details_editor_set_tracks_cb), NULL);
+    g_signal_connect (gtkpod_app, SIGNAL_PLAYLIST_SELECTED, G_CALLBACK 
(details_editor_set_playlist_cb), NULL);
 
     return TRUE; /* FALSE if activation failed */
 }
diff --git a/src/details.c b/src/details.c
index ddec243..a3df398 100644
--- a/src/details.c
+++ b/src/details.c
@@ -1278,9 +1278,28 @@ static void details_set_track(Track *track) {
  * replace. */
 static void details_set_tracks(GList *tracks) {
     GList *gl;
-    g_return_if_fail (details_view);
     g_return_if_fail (tracks);
 
+    if (! details_view) {
+        return;
+    }
+
+    if (details_view->changed) {
+        gdk_threads_enter ();
+        gchar *str = g_strdup_printf(_("Changes have been made to the tracks 
in the details editor.\nDo you want to lose those changes?"));
+        gint result = gtkpod_confirmation_simple(
+                GTK_MESSAGE_WARNING,
+                _("Tracks in details editor have been modified."),
+                str,
+                GTK_STOCK_YES);
+
+        g_free(str);
+        gdk_threads_leave ();
+        if (result == GTK_RESPONSE_CANCEL) {
+            return;
+        }
+    }
+
     if (details_view->orig_tracks) {
         g_list_free(details_view->orig_tracks);
         details_view->orig_tracks = NULL;
@@ -1494,11 +1513,14 @@ void details_edit(GList *selected_tracks) {
     GtkWidget *w;
     gint page, num_pages;
 
-    if (!details_view || !details_view->window)
+    if (!details_view || !details_view->window) {
+        g_message("Creating details editor window");
         create_details_editor_view();
-    else
+    }
+    else {
+        g_message("Redisplaying details editor window");
         gtkpod_display_widget(details_view->window);
-
+    }
     details_set_tracks(selected_tracks);
 
     /* set notebook page */
@@ -1710,3 +1732,21 @@ static void dnd_details_art_drag_data_received(GtkWidget 
*widget, GdkDragContext
     //    gtk_drag_finish(dc, FALSE, FALSE, time);
     return;
 }
+
+void details_editor_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer 
data) {
+    Track *old_track = tk;
+    details_remove_track(old_track);
+}
+
+void details_editor_set_tracks_cb(GtkPodApp *app, gpointer tks, gpointer data) 
{
+    GList *tracks = tks;
+    details_set_tracks(tracks);
+}
+
+void details_editor_set_playlist_cb(GtkPodApp *app, gpointer pl, gpointer 
data) {
+    Playlist *playlist = pl;
+
+    if (playlist && playlist->members) {
+        details_set_tracks(playlist->members);
+    }
+}
diff --git a/src/details.h b/src/details.h
index 2b8097a..4959f6d 100644
--- a/src/details.h
+++ b/src/details.h
@@ -60,4 +60,9 @@ void details_edit (GList *selected_tracks);
 void details_remove_track (Track *track);
 Detail *details_get_selected_detail ();
 void destroy_details_editor();
+
+void details_editor_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer 
data);
+void details_editor_set_tracks_cb(GtkPodApp *app, gpointer tks, gpointer data);
+void details_editor_set_playlist_cb(GtkPodApp *app, gpointer pl, gpointer 
data);
+
 #endif

------------------------------------------------------------------------------
_______________________________________________
gtkpod-cvs2 mailing list
gtkpod-cvs2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to