commit eb8b3362005847918a4b5b36a976da497115427c
Author: phantomjinx <p.g.richard...@phantomjinx.co.uk>
Date:   Thu Jan 21 22:25:43 2010 +0000

    Getting new playlist action working correctly
    
    - Removal of some of the g_warnings
    
    - misc_playlist.c
      re-enable smart playlist function
    
    - gp_itdb.c / display_itdb.c
      creation of gtkpod_playlist_added function for signalling that a new
      playlist has been added to an itdb
    
    - display_playlists
      callback created that add a playlist child to the playlist model
    
    - gtkpod_app_marshallers.list
      new closure for signals that carries a pointer and int as parameters.
      Used for signalling that a playlist has been added.

 libgtkpod/gtkpod_app-marshallers.c           |   37 ++++++++++++++++++++++++++
 libgtkpod/gtkpod_app-marshallers.h           |    8 +++++
 libgtkpod/gtkpod_app-marshallers.list        |    1 +
 libgtkpod/gtkpod_app_iface.c                 |   18 +++++++-----
 libgtkpod/gtkpod_app_iface.h                 |    2 +
 plugins/playlist_display/display_playlists.h |    1 +
 plugins/playlist_display/plugin.c            |    1 +
 src/display_itdb.c                           |    1 +
 src/display_playlists.c                      |   12 ++++----
 src/display_sorttabs.c                       |    8 -----
 src/display_tracks.c                         |    4 ---
 src/misc_playlist.c                          |    3 +-
 12 files changed, 69 insertions(+), 27 deletions(-)
---
diff --git a/libgtkpod/gtkpod_app-marshallers.c 
b/libgtkpod/gtkpod_app-marshallers.c
index aca3a66..5318b43 100644
--- a/libgtkpod/gtkpod_app-marshallers.c
+++ b/libgtkpod/gtkpod_app-marshallers.c
@@ -84,3 +84,40 @@ _gtkpod_app_marshal_VOID__POINTER_POINTER (GClosure     
*closure,
             data2);
 }
 
+/* VOID:POINTER,INT (gtkpod_app-marshallers.list:3) */
+void
+_gtkpod_app_marshal_VOID__POINTER_INT (GClosure     *closure,
+                                       GValue       *return_value 
G_GNUC_UNUSED,
+                                       guint         n_param_values,
+                                       const GValue *param_values,
+                                       gpointer      invocation_hint 
G_GNUC_UNUSED,
+                                       gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__POINTER_INT) (gpointer     data1,
+                                                  gpointer     arg_1,
+                                                  gint         arg_2,
+                                                  gpointer     data2);
+  register GMarshalFunc_VOID__POINTER_INT callback;
+  register GCClosure *cc = (GCClosure*) closure;
+  register gpointer data1, data2;
+
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__POINTER_INT) (marshal_data ? marshal_data : 
cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_pointer (param_values + 1),
+            g_marshal_value_peek_int (param_values + 2),
+            data2);
+}
+
diff --git a/libgtkpod/gtkpod_app-marshallers.h 
b/libgtkpod/gtkpod_app-marshallers.h
index 2f7556f..1fe5421 100644
--- a/libgtkpod/gtkpod_app-marshallers.h
+++ b/libgtkpod/gtkpod_app-marshallers.h
@@ -14,6 +14,14 @@ extern void _gtkpod_app_marshal_VOID__POINTER_POINTER 
(GClosure     *closure,
                                                        gpointer      
invocation_hint,
                                                        gpointer      
marshal_data);
 
+/* VOID:POINTER,INT (gtkpod_app-marshallers.list:3) */
+extern void _gtkpod_app_marshal_VOID__POINTER_INT (GClosure     *closure,
+                                                   GValue       *return_value,
+                                                   guint         
n_param_values,
+                                                   const GValue *param_values,
+                                                   gpointer      
invocation_hint,
+                                                   gpointer      marshal_data);
+
 G_END_DECLS
 
 #endif /* ___gtkpod_app_marshal_MARSHAL_H__ */
diff --git a/libgtkpod/gtkpod_app-marshallers.list 
b/libgtkpod/gtkpod_app-marshallers.list
index fd83926..8e66a11 100644
--- a/libgtkpod/gtkpod_app-marshallers.list
+++ b/libgtkpod/gtkpod_app-marshallers.list
@@ -1,2 +1,3 @@
 # these marshallers are generated with glib-genmarshal(1)
  VOID:POINTER,POINTER
+ VOID:POINTER,INT
diff --git a/libgtkpod/gtkpod_app_iface.c b/libgtkpod/gtkpod_app_iface.c
index 4864e15..09abd70 100644
--- a/libgtkpod/gtkpod_app_iface.c
+++ b/libgtkpod/gtkpod_app_iface.c
@@ -54,6 +54,9 @@ static void gtkpod_app_base_init(GtkPodAppInterface* klass) {
         gtkpod_app_signals[SORT_ENABLEMENT]
                         = g_signal_new("sort_enablement", G_OBJECT_CLASS_TYPE 
(klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, 
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
 
+        gtkpod_app_signals[PLAYLIST_ADDED]
+                        = g_signal_new("playlist_added", G_OBJECT_CLASS_TYPE 
(klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, 
_gtkpod_app_marshal_VOID__POINTER_INT, G_TYPE_NONE, 2, G_TYPE_POINTER, 
G_TYPE_INT);
+
         initialized = TRUE;
     }
 }
@@ -177,7 +180,6 @@ Playlist* gtkpod_get_current_playlist() {
 }
 
 void gtkpod_set_current_playlist(Playlist* playlist) {
-    g_warning("gtkpod_set_current_playlist");
     g_return_if_fail (GTKPOD_IS_APP(gtkpod_app));
 
     GTKPOD_APP_GET_INTERFACE (gtkpod_app)->current_playlist = playlist;
@@ -206,12 +208,6 @@ GList *gtkpod_get_current_tracks() {
 }
 
 void gtkpod_set_current_tracks(GList *tracks) {
-    if (tracks == NULL) {
-        g_warning("gtkpod_set_current_tracks (NULL)");
-    }
-    else {
-        g_warning("gtkpod_set_current_tracks (Some Tracks)");
-    }
     g_return_if_fail (GTKPOD_IS_APP(gtkpod_app));
     GTKPOD_APP_GET_INTERFACE (gtkpod_app)->current_tracks = tracks;
 
@@ -229,3 +225,11 @@ gboolean gtkpod_get_sort_enablement() {
     g_return_val_if_fail (GTKPOD_IS_APP(gtkpod_app), TRUE);
     return GTKPOD_APP_GET_INTERFACE (gtkpod_app)->sort_enablement;
 }
+
+void gtkpod_playlist_added(iTunesDB *itdb, Playlist *playlist, gint32 pos) {
+    g_return_if_fail (GTKPOD_IS_APP(gtkpod_app));
+    g_return_if_fail (playlist);
+    g_return_if_fail (playlist->itdb == itdb);
+
+    g_signal_emit(gtkpod_app, gtkpod_app_signals[PLAYLIST_ADDED], 0, playlist, 
pos);
+}
diff --git a/libgtkpod/gtkpod_app_iface.h b/libgtkpod/gtkpod_app_iface.h
index 690895d..f18512b 100644
--- a/libgtkpod/gtkpod_app_iface.h
+++ b/libgtkpod/gtkpod_app_iface.h
@@ -68,6 +68,7 @@ enum
 {
     TRACKS_SELECTED,
     PLAYLIST_SELECTED,
+    PLAYLIST_ADDED,
     ITDB_UPDATED,
     SORT_ENABLEMENT,
     LAST_SIGNAL
@@ -125,6 +126,7 @@ GList *gtkpod_get_current_tracks();
 void gtkpod_set_current_tracks(GList *tracks);
 void gtkpod_set_sort_enablement(gboolean enable);
 gboolean gtkpod_get_sort_enablement();
+void gtkpod_playlist_added(iTunesDB *itdb, Playlist *playlist, gint32 pos);
 
 GtkPodApp *gtkpod_app;
 guint gtkpod_app_signals[LAST_SIGNAL];
diff --git a/plugins/playlist_display/display_playlists.h 
b/plugins/playlist_display/display_playlists.h
index e54c88c..f784920 100644
--- a/plugins/playlist_display/display_playlists.h
+++ b/plugins/playlist_display/display_playlists.h
@@ -57,5 +57,6 @@ Playlist* pm_get_selected_playlist(void);
 void message_sb_no_itdb_selected ();
 void playlist_display_update_itdb_cb (GtkPodApp *app, gpointer olditdb, 
gpointer newitdb, gpointer data);
 void playlist_display_select_playlist_cb (GtkPodApp *app, gpointer pl, 
gpointer data);
+void playlist_display_playlist_added_cb(GtkPodApp *app, gpointer pl, gint32 
pos, gpointer data);
 
 #endif /* __DISPLAY_PLAYLIST_H__ */
diff --git a/plugins/playlist_display/plugin.c 
b/plugins/playlist_display/plugin.c
index eef915d..f4edc08 100644
--- a/plugins/playlist_display/plugin.c
+++ b/plugins/playlist_display/plugin.c
@@ -266,6 +266,7 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) {
 
     g_signal_connect (gtkpod_app, "playlist_selected", G_CALLBACK 
(playlist_display_select_playlist_cb), NULL);
     g_signal_connect (gtkpod_app, "itdb_updated", G_CALLBACK 
(playlist_display_update_itdb_cb), NULL);
+    g_signal_connect (gtkpod_app, "playlist_added", G_CALLBACK 
(playlist_display_playlist_added_cb), NULL);
 
     gtk_container_add(GTK_CONTAINER (playlist_display_plugin->pl_window), 
GTK_WIDGET (playlist_display_plugin->playlist_view));
     gtk_widget_show_all(playlist_display_plugin->pl_window);
diff --git a/src/display_itdb.c b/src/display_itdb.c
index 4d03ef0..fbc8beb 100644
--- a/src/display_itdb.c
+++ b/src/display_itdb.c
@@ -450,6 +450,7 @@ Playlist *gp_playlist_add_new(iTunesDB *itdb, gchar *name, 
gboolean spl, gint32
 
     pl = gp_playlist_new(name, spl);
     itdb_playlist_add(itdb, pl, pos);
+    gtkpod_playlist_added(itdb, pl, pos);
     data_changed(itdb);
     return pl;
 }
diff --git a/src/display_playlists.c b/src/display_playlists.c
index 7b1b3da..596ce1f 100644
--- a/src/display_playlists.c
+++ b/src/display_playlists.c
@@ -1155,7 +1155,6 @@ void pm_select_playlist(Playlist *playlist) {
     }
 
     if (gtkpod_get_current_playlist() != playlist) {
-        g_warning("pm_select_playlist");
         gtkpod_set_current_playlist(playlist);
     }
 }
@@ -1173,7 +1172,6 @@ void pm_unselect_playlist(Playlist *playlist) {
         gtk_tree_selection_unselect_iter(ts, &iter);
     }
 
-    g_warning("pm_unselect_playlist");
     gtkpod_set_current_playlist(NULL);
 }
 
@@ -1198,7 +1196,6 @@ static gboolean pm_selection_changed_cb(gpointer data) {
     if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE) { 
/* no selection -> reset sort tabs */
         //             gphoto_change_to_photo_window (FALSE);
         //             st_init (-1, 0);
-        g_warning("pm_selection_changed_cb - 1");
         gtkpod_set_current_playlist(NULL);
         gtkpod_set_current_itdb(NULL);
     }
@@ -1210,7 +1207,6 @@ static gboolean pm_selection_changed_cb(gpointer data) {
         /* handle new selection */
         gtk_tree_model_get(model, &iter, PM_COLUMN_TYPE, &type, 
PM_COLUMN_ITDB, &itdb, PM_COLUMN_PLAYLIST, &new_playlist, PM_COLUMN_PHOTOS, 
&photodb, -1);
 
-        g_warning("pm_selection_changed_cb - 2");
         gtkpod_set_current_playlist(new_playlist);
         gtkpod_set_current_itdb(itdb);
 
@@ -2146,7 +2142,6 @@ pm_get_selected_itdb(void) {
 
 /* use with care!! */
 void pm_set_selected_playlist(Playlist *pl) {
-    g_warning("pm_set_selected_playlist");
     gtkpod_set_current_playlist(pl);
 }
 
@@ -2205,6 +2200,11 @@ void playlist_display_select_playlist_cb(GtkPodApp *app, 
gpointer pl, gpointer d
     if (old_playlist)
         pm_unselect_playlist (old_playlist);
 
-    g_warning("playlist_display_select_playlist_cb");
     pm_select_playlist(new_playlist);
 }
+
+void playlist_display_playlist_added_cb(GtkPodApp *app, gpointer pl, gint32 
pos, gpointer data) {
+    Playlist *new_playlist = pl;
+
+    pm_add_child(new_playlist->itdb, PM_COLUMN_PLAYLIST, new_playlist, pos);
+}
diff --git a/src/display_sorttabs.c b/src/display_sorttabs.c
index 8358f1c..d792a40 100644
--- a/src/display_sorttabs.c
+++ b/src/display_sorttabs.c
@@ -1054,7 +1054,6 @@ static void st_free_entry_cb(gpointer data, gpointer 
user_data) {
 /* Remove all entries from the display model and the sorttab */
 /* @clear_sort: reset sorted columns to the non-sorted state */
 void st_remove_all_entries_from_model(guint32 inst) {
-    g_warning("st_remove_all_entries_from_model");
     SortTab *st = sorttab[inst];
     gint column;
     GtkSortType order;
@@ -1610,9 +1609,7 @@ void st_remove_track(Track *track, guint32 inst) {
 /* Normally we do not specifically remember the "All" entry and will
  select "All" in accordance to the prefs settings. */
 void st_init(ST_CAT_item new_category, guint32 inst) {
-    g_warning("st_init");
     if (inst == prefs_get_int("sort_tab_num")) {
-        g_warning("st_init - inst == prefs_get_int(sort_tab_num)");
         gtkpod_set_current_tracks(NULL);
         gtkpod_tracks_statusbar_update();
         return;
@@ -1882,7 +1879,6 @@ gboolean st_set_selection(Itdb_Track *track) {
 }
 
 static gboolean st_selection_changed_cb(gpointer data) {
-    g_warning("st_selection_changed_cb");
     StSelectionEvent *event = (StSelectionEvent *) data;
     GtkTreeView *tree_view = event->tree_view;
     GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
@@ -1973,7 +1969,6 @@ static gboolean st_selection_changed_cb(gpointer data) {
  "callback". Currently running display updates will be stopped
  before the st_selection_changed_cb is actually called */
 static void st_selection_changed(GtkTreeSelection *selection, gpointer 
user_data) {
-    g_warning("st_selection_changed");
 #if DEBUG_CB_INIT
     printf("st_s_c enter (inst: %d)\n", (gint)user_data);
 #endif
@@ -3342,16 +3337,13 @@ void cal_open_calendar(gint inst, T_item item) {
 }
 
 void sorttab_display_select_playlist_cb(GtkPodApp *app, gpointer pl, gpointer 
data) {
-    g_warning("sortab_display_selected_playlist_cb");
     Playlist *new_playlist = pl;
 
     /* Remove all data from tab */
-    g_warning("st_init from sorttab_display_select_playlist_cb");
     st_init(-1, 0);
 
     /* Add the tracks from the selected playlist to the sorttabs */
     if (new_playlist && new_playlist->members) {
-        g_warning("new_playlist members from 
sorttab_display_select_playlist_cb");
         GList *gl;
 
         st_enable_disable_view_sort(0, FALSE);
diff --git a/src/display_tracks.c b/src/display_tracks.c
index 5a7f72d..4e09f7e 100644
--- a/src/display_tracks.c
+++ b/src/display_tracks.c
@@ -2690,8 +2690,6 @@ void display_show_hide_searchbar(void) {
 void track_display_set_tracks_cb(GtkPodApp *app, gpointer tks, gpointer data) {
     GList *tracks = tks;
 
-    g_warning("track_display_set_tracks_cb");
-
     tm_remove_all_tracks();
 
     while (tracks != NULL) { /* add all tracks to model */
@@ -2706,8 +2704,6 @@ void track_display_set_playlist_cb(GtkPodApp *app, 
gpointer pl, gpointer data) {
     Playlist *playlist = pl;
     gchar *label_text;
 
-    g_warning("track_display_set_playlist_cb");
-
     if (!current_playlist_label)
         return;
 
diff --git a/src/misc_playlist.c b/src/misc_playlist.c
index 49aa68f..fec1d5d 100644
--- a/src/misc_playlist.c
+++ b/src/misc_playlist.c
@@ -109,8 +109,7 @@ void add_new_pl_or_spl_user_name(iTunesDB *itdb, gchar 
*dflt, gint32 position) {
             //     gtkpod_tracks_statusbar_update ();
         }
         else { /* add smart playlist */
-            g_warning("TODO tell some plugin to edit a new smart playlist\n");
-            //     spl_edit_new (itdb, name, position);
+            spl_edit_new (itdb, name, position);
         }
     }
 }

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
gtkpod-cvs2 mailing list
gtkpod-cvs2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to