changeset 3755:2ca446f02d97

export the fileinfopopup API.
author William Pitcock <nenolod@atheme.org>
date Sun, 14 Oct 2007 21:04:46 -0500
parents 74bed6b35161
children 698e3936f6b4
files src/audacious/plugin.h src/audacious/pluginenum.c src/audacious/ui_fileinfopopup.c src/audacious/ui_fileinfopopup.h src/audacious/ui_skinned_playlist.c
diffstat 5 files changed, 61 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/plugin.h	Sun Oct 14 19:38:49 2007 -0500
+++ b/src/audacious/plugin.h	Sun Oct 14 21:04:46 2007 -0500
@@ -544,6 +544,13 @@
 
     gint (*prefswin_page_new)(GtkWidget *container, gchar *name, gchar *imgurl);
     void (*prefswin_page_destroy)(GtkWidget *container);
+
+    /* FileInfoPopup API */
+    GtkWidget *(*fileinfopopup_create)(void);
+    void (*fileinfopopup_destroy)(GtkWidget* fileinfopopup_win);
+    void (*fileinfopopup_show_from_tuple)(GtkWidget *fileinfopopup_win, Tuple *tuple);
+    void (*fileinfopopup_show_from_title)(GtkWidget *fileinfopopup_win, gchar *title);
+    void (*fileinfopopup_hide)(GtkWidget *filepopup_win, gpointer unused);
 };
 
 /* Convenience macros for accessing the public API. */
@@ -848,6 +855,12 @@
 #define aud_prefswin_page_new			_audvt->prefswin_page_new
 #define aud_prefswin_page_destroy		_audvt->prefswin_page_destroy
 
+#define audacious_fileinfopopup_create			_audvt->fileinfopopup_create
+#define audacious_fileinfopopup_destroy			_audvt->fileinfopopup_destroy
+#define audacious_fileinfopopup_show_from_tuple		_audvt->fileinfopopup_show_from_tuple
+#define audacious_fileinfopopup_show_from_title		_audvt->fileinfopopup_show_from_title
+#define audacious_fileinfopopup_hide			_audvt->fileinfopopup_hide
+
 #include "audacious/auddrct.h"
 
 /* for multi-file plugins :( */
--- a/src/audacious/pluginenum.c	Sun Oct 14 19:38:49 2007 -0500
+++ b/src/audacious/pluginenum.c	Sun Oct 14 21:04:46 2007 -0500
@@ -348,6 +348,12 @@
 
     .prefswin_page_new = prefswin_page_new,
     .prefswin_page_destroy = prefswin_page_destroy,
+
+    .fileinfopopup_create = fileinfopopup_create,
+    .fileinfopopup_destroy = fileinfopopup_destroy,
+    .fileinfopopup_show_from_title = fileinfopopup_show_from_title,
+    .fileinfopopup_show_from_tuple = fileinfopopup_show_from_tuple,
+    .fileinfopopup_hide = fileinfopopup_hide,
 };
 
 /*****************************************************************/
--- a/src/audacious/ui_fileinfopopup.c	Sun Oct 14 19:38:49 2007 -0500
+++ b/src/audacious/ui_fileinfopopup.c	Sun Oct 14 21:04:46 2007 -0500
@@ -87,7 +87,7 @@
 }
 
 static gboolean
-audacious_fileinfopopup_progress_cb(gpointer filepopup_win)
+fileinfopopup_progress_cb(gpointer filepopup_win)
 {
     GtkWidget *progressbar =
         g_object_get_data(G_OBJECT(filepopup_win), "progressbar");
@@ -138,7 +138,7 @@
 }
 
 static gboolean
-audacious_fileinfopopup_progress_check_active(GtkWidget *filepopup_win)
+fileinfopopup_progress_check_active(GtkWidget *filepopup_win)
 {
     if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(filepopup_win),"progress_sid")) == 0)
         return FALSE;
@@ -146,23 +146,23 @@
 }
 
 static void
-audacious_fileinfopopup_progress_init(GtkWidget *filepopup_win)
+fileinfopopup_progress_init(GtkWidget *filepopup_win)
 {
     g_object_set_data( G_OBJECT(filepopup_win) , "progress_sid" , GINT_TO_POINTER(0) );
 }
 
 static void
-audacious_fileinfopopup_progress_start(GtkWidget *filepopup_win)
+fileinfopopup_progress_start(GtkWidget *filepopup_win)
 {
     gint sid =
-        g_timeout_add(500, (GSourceFunc)audacious_fileinfopopup_progress_cb,
+        g_timeout_add(500, (GSourceFunc)fileinfopopup_progress_cb,
                       filepopup_win);
     g_object_set_data(G_OBJECT(filepopup_win), "progress_sid",
                       GINT_TO_POINTER(sid));
 }
 
 static void
-audacious_fileinfopopup_progress_stop(GtkWidget *filepopup_win)
+fileinfopopup_progress_stop(GtkWidget *filepopup_win)
 {
     gint sid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(filepopup_win),
                                                  "progress_sid"));
@@ -174,7 +174,7 @@
 }
 
 static void
-audacious_fileinfopopup_add_category(GtkWidget *filepopup_win,
+fileinfopopup_add_category(GtkWidget *filepopup_win,
                                      GtkWidget *filepopup_data_table,
                                      const gchar *category,
                                      const gchar *header_data,
@@ -211,7 +211,7 @@
 
 
 GtkWidget *
-audacious_fileinfopopup_create(void)
+fileinfopopup_create(void)
 {
     GtkWidget *filepopup_win;
     GtkWidget *filepopup_hbox;
@@ -248,26 +248,26 @@
     gtk_box_pack_start(GTK_BOX(filepopup_hbox), filepopup_data_table,
                        TRUE, TRUE, 0);
 
-    audacious_fileinfopopup_add_category(filepopup_win, filepopup_data_table,
+    fileinfopopup_add_category(filepopup_win, filepopup_data_table,
                                          _("Title"),
                                          "header_title", "label_title", 0);
-    audacious_fileinfopopup_add_category(filepopup_win, filepopup_data_table,
+    fileinfopopup_add_category(filepopup_win, filepopup_data_table,
                                          _("Artist"),
                                          "header_artist", "label_artist", 1);
-    audacious_fileinfopopup_add_category(filepopup_win, filepopup_data_table,
+    fileinfopopup_add_category(filepopup_win, filepopup_data_table,
                                          _("Album"),
                                          "header_album", "label_album", 2);
-    audacious_fileinfopopup_add_category(filepopup_win, filepopup_data_table,
+    fileinfopopup_add_category(filepopup_win, filepopup_data_table,
                                          _("Genre"),
                                          "header_genre", "label_genre", 3);
-    audacious_fileinfopopup_add_category(filepopup_win, filepopup_data_table,
+    fileinfopopup_add_category(filepopup_win, filepopup_data_table,
                                          _("Year"),
                                          "header_year", "label_year", 4);
-    audacious_fileinfopopup_add_category(filepopup_win, filepopup_data_table,
+    fileinfopopup_add_category(filepopup_win, filepopup_data_table,
                                          _("Track Number"),
                                          "header_tracknum", "label_tracknum",
                                          5);
-    audacious_fileinfopopup_add_category(filepopup_win, filepopup_data_table,
+    fileinfopopup_add_category(filepopup_win, filepopup_data_table,
                                          _("Track Length"),
                                          "header_tracklen", "label_tracklen",
                                          6);
@@ -284,7 +284,7 @@
     g_object_set_data(G_OBJECT(filepopup_win), "file", NULL);
     g_object_set_data(G_OBJECT(filepopup_win), "progressbar",
                       filepopup_progress);
-    audacious_fileinfopopup_progress_init(filepopup_win);
+    fileinfopopup_progress_init(filepopup_win);
     
     /* this will realize all widgets contained in filepopup_hbox */
     gtk_widget_show_all(filepopup_hbox);
@@ -296,10 +296,10 @@
 }
 
 void
-audacious_fileinfopopup_destroy(GtkWidget *filepopup_win)
+fileinfopopup_destroy(GtkWidget *filepopup_win)
 {
     gchar *last_artwork;
-    audacious_fileinfopopup_progress_stop(filepopup_win);
+    fileinfopopup_progress_stop(filepopup_win);
 
     last_artwork =
         g_object_get_data(G_OBJECT(filepopup_win), "last_artwork");
@@ -310,7 +310,7 @@
 }
 
 static void
-audacious_fileinfopupup_update_data(GtkWidget *filepopup_win,
+fileinfopupup_update_data(GtkWidget *filepopup_win,
                                     const gchar *text,
                                     const gchar *label_data,
                                     const gchar *header_data)
@@ -329,7 +329,7 @@
 }
 
 void
-audacious_fileinfopopup_show_from_tuple(GtkWidget *filepopup_win,
+fileinfopopup_show_from_tuple(GtkWidget *filepopup_win,
                                         Tuple *tuple)
 {
     gchar *tmp = NULL;
@@ -378,17 +378,17 @@
         g_free(utf_filename);
     }
 
-    audacious_fileinfopupup_update_data(filepopup_win, tuple_get_string(tuple, FIELD_ARTIST, NULL),
+    fileinfopupup_update_data(filepopup_win, tuple_get_string(tuple, FIELD_ARTIST, NULL),
                                         "label_artist", "header_artist");
-    audacious_fileinfopupup_update_data(filepopup_win, tuple_get_string(tuple, FIELD_ALBUM, NULL),
+    fileinfopupup_update_data(filepopup_win, tuple_get_string(tuple, FIELD_ALBUM, NULL),
                                         "label_album", "header_album");
-    audacious_fileinfopupup_update_data(filepopup_win, tuple_get_string(tuple, FIELD_GENRE, NULL),
+    fileinfopupup_update_data(filepopup_win, tuple_get_string(tuple, FIELD_GENRE, NULL),
                                         "label_genre", "header_genre");
 
     length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
     length_string = (length > 0) ?
         g_strdup_printf("%d:%02d", length / 60000, (length / 1000) % 60) : NULL;
-    audacious_fileinfopupup_update_data(filepopup_win, length_string,
+    fileinfopupup_update_data(filepopup_win, length_string,
                                         "label_tracklen", "header_tracklen");
     g_free(length_string);
 
@@ -398,12 +398,12 @@
       g_object_set_data( G_OBJECT(filepopup_win), "length" , GINT_TO_POINTER(-1) );
 
     year_string = (tuple_get_int(tuple, FIELD_YEAR, NULL) == 0) ? NULL : g_strdup_printf("%d", tuple_get_int(tuple, FIELD_YEAR, NULL));
-    audacious_fileinfopupup_update_data(filepopup_win, year_string,
+    fileinfopupup_update_data(filepopup_win, year_string,
                                         "label_year", "header_year");
     g_free(year_string);
 
     track_string = (tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL) == 0) ? NULL : g_strdup_printf("%d", tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL));
-    audacious_fileinfopupup_update_data(filepopup_win, track_string,
+    fileinfopupup_update_data(filepopup_win, track_string,
                                         "label_tracknum", "header_tracknum");
     g_free(track_string);
     
@@ -433,11 +433,11 @@
 
     /* start a timer that updates a progress bar if the tooltip
        is shown for the song that is being currently played */
-    if (audacious_fileinfopopup_progress_check_active(filepopup_win) == FALSE)
+    if (fileinfopopup_progress_check_active(filepopup_win) == FALSE)
     { 
-        audacious_fileinfopopup_progress_start(filepopup_win);
+        fileinfopopup_progress_start(filepopup_win);
         /* immediately run the callback once to update progressbar status */
-        audacious_fileinfopopup_progress_cb(filepopup_win);
+        fileinfopopup_progress_cb(filepopup_win);
     }
 
     gdk_window_get_pointer(gdk_get_default_root_window(), &x, &y, NULL);
@@ -450,21 +450,21 @@
 }
 
 void
-audacious_fileinfopopup_show_from_title(GtkWidget *filepopup_win, gchar *title)
+fileinfopopup_show_from_title(GtkWidget *filepopup_win, gchar *title)
 {
     Tuple * tuple = tuple_new();
     tuple_associate_string(tuple, FIELD_TITLE, NULL, title);
-    audacious_fileinfopopup_show_from_tuple(filepopup_win, tuple);
+    fileinfopopup_show_from_tuple(filepopup_win, tuple);
     mowgli_object_unref(tuple);
     return;
 }
 
 void
-audacious_fileinfopopup_hide(GtkWidget *filepopup_win, gpointer unused)
+fileinfopopup_hide(GtkWidget *filepopup_win, gpointer unused)
 {
     if (GTK_WIDGET_VISIBLE(filepopup_win))
     {
-        audacious_fileinfopopup_progress_stop(filepopup_win);
+        fileinfopopup_progress_stop(filepopup_win);
 
         gtk_widget_hide(filepopup_win);
 
--- a/src/audacious/ui_fileinfopopup.h	Sun Oct 14 19:38:49 2007 -0500
+++ b/src/audacious/ui_fileinfopopup.h	Sun Oct 14 21:04:46 2007 -0500
@@ -25,12 +25,12 @@
 #include <gtk/gtk.h>
 
 /* create/destroy */
-GtkWidget* audacious_fileinfopopup_create(void);
-void audacious_fileinfopopup_destroy(GtkWidget* fileinfopopup_win);
+GtkWidget* fileinfopopup_create(void);
+void fileinfopopup_destroy(GtkWidget* fileinfopopup_win);
 
 /* show/hide */
-void audacious_fileinfopopup_show_from_tuple(GtkWidget *fileinfopopup_win, Tuple *tuple);
-void audacious_fileinfopopup_show_from_title(GtkWidget *fileinfopopup_win, gchar *title);
-void audacious_fileinfopopup_hide(GtkWidget *filepopup_win, gpointer unused);
+void fileinfopopup_show_from_tuple(GtkWidget *fileinfopopup_win, Tuple *tuple);
+void fileinfopopup_show_from_title(GtkWidget *fileinfopopup_win, gchar *title);
+void fileinfopopup_hide(GtkWidget *filepopup_win, gpointer unused);
 
 #endif
--- a/src/audacious/ui_skinned_playlist.c	Sun Oct 14 19:38:49 2007 -0500
+++ b/src/audacious/ui_skinned_playlist.c	Sun Oct 14 21:04:46 2007 -0500
@@ -164,7 +164,7 @@
     g_object_set_data(G_OBJECT(playlist), "timer_id", GINT_TO_POINTER(0));
     g_object_set_data(G_OBJECT(playlist), "timer_active", GINT_TO_POINTER(0));
 
-    GtkWidget *popup = audacious_fileinfopopup_create();
+    GtkWidget *popup = fileinfopopup_create();
     g_object_set_data(G_OBJECT(playlist), "popup", popup);
     g_object_set_data(G_OBJECT(playlist), "popup_active", GINT_TO_POINTER(0));
     g_object_set_data(G_OBJECT(playlist), "popup_position", GINT_TO_POINTER(-1));
@@ -1021,10 +1021,10 @@
         tuple = playlist_get_tuple(pl_active, pos);
         if ((tuple == NULL) || (tuple_get_int(tuple, FIELD_LENGTH, NULL) < 1)) {
            gchar *title = playlist_get_songtitle(pl_active, pos);
-           audacious_fileinfopopup_show_from_title(popup, title);
+           fileinfopopup_show_from_title(popup, title);
            g_free(title);
         } else {
-           audacious_fileinfopopup_show_from_tuple(popup , tuple);
+           fileinfopopup_show_from_tuple(popup , tuple);
         }
         g_object_set_data(G_OBJECT(widget), "popup_active" , GINT_TO_POINTER(1));
     }
@@ -1037,7 +1037,7 @@
     if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "popup_active")) == 1) {
         GtkWidget *popup = g_object_get_data(G_OBJECT(widget), "popup");
         g_object_set_data(G_OBJECT(widget), "popup_active", GINT_TO_POINTER(0));
-        audacious_fileinfopopup_hide(popup, NULL);
+        fileinfopopup_hide(popup, NULL);
     }
 }