Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:zebobm
Vagalume
vagalume-2-16.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File vagalume-2-16.patch of Package Vagalume
diff -up vagalume-hardy/configure.ac.fix vagalume-hardy/configure.ac --- vagalume-hardy/configure.ac.fix 2008-08-30 02:00:58.000000000 +0200 +++ vagalume-hardy/configure.ac 2008-10-02 00:40:24.000000000 +0200 @@ -104,6 +104,7 @@ if $PKG_CONFIG --exists libosso && readl DETECTED_PLATFORM=maemo else DETECTED_PLATFORM=gnome + AC_DEFINE([GNOME], [1], [Defined if building for GNOME]) fi # Platform support @@ -301,6 +302,18 @@ elif test "$PLATFORM" = "gnome"; then echo "Compiling for Gnome" + PKG_CHECK_MODULES(GIO, gio-2.0) + EXTRA_CFLAGS="$EXTRA_CFLAGS $GIO_CFLAGS" + EXTRA_LIBS="$EXTRA_LIBS $GIO_LIBS" + + PKG_CHECK_MODULES(MEDIA_PROFILES, gnome-media-profiles) + EXTRA_CFLAGS="$EXTRA_CFLAGS $MEDIA_PROFILES_CFLAGS" + EXTRA_LIBS="$EXTRA_LIBS $MEDIA_PROFILES_LIBS" + + PKG_CHECK_MODULES(GCONF, gconf-2.0) + EXTRA_CFLAGS="$EXTRA_CFLAGS $GCONF_CFLAGS" + EXTRA_LIBS="$EXTRA_LIBS $GCONF_LIBS" + # Desktop screen resolution scr_resolution=desktop diff -up vagalume-hardy/src/audio.c.fix vagalume-hardy/src/audio.c --- vagalume-hardy/src/audio.c.fix 2008-05-07 17:00:00.000000000 +0200 +++ vagalume-hardy/src/audio.c 2008-09-30 14:49:40.000000000 +0200 @@ -13,6 +13,14 @@ #include <unistd.h> #include <string.h> +#ifdef GNOME +#include <gio/gio.h> +#include <userconfig.h> +#include <profiles/gnome-media-profiles.h> +#include <profiles/audio-profile.h> +#include <gconf/gconf-client.h> +#endif + #include "audio.h" #include "controller.h" #include "http.h" @@ -27,6 +35,20 @@ static const char *default_sinks[] = { " static const char *default_converters[] = { "audioconvert", NULL }; #endif +#ifdef GNOME +static GstElement *tee = NULL; +static GstElement *playqueue = NULL; +static GstElement *writequeue =NULL; +static GstElement *resampler =NULL; +static GstElement *encoder = NULL; +static GstElement *giosink = NULL; +static GstPad *teepad = NULL; +static GstPad *queuepad = NULL; +static char *dumppath = NULL; +// fetching userconfig from controller +extern VglUserCfg *usercfg; +#endif + static GstElement *pipeline = NULL; static GstElement *source = NULL; static GstElement *decoder = NULL; @@ -108,6 +130,9 @@ bus_call (GstBus *bus, GstMessage *msg, controller_stop_playing(); controller_show_warning("Connection error"); } else { + #ifdef GNOME + controller_save_song (); + #endif controller_skip_track(); } gdk_threads_leave (); @@ -213,6 +238,18 @@ lastfm_audio_init(void) { GstBus *bus; failed_tracks_mutex = g_mutex_new(); + +#ifdef GNOME + if (pipeline != NULL) { + gst_object_unref (GST_OBJECT (pipeline)); + g_main_loop_unref(loop); + usercfg->rebuild_pipeline = FALSE; + } else { + // fetch gnome audio profiles + gnome_media_profiles_init (gconf_client_get_default ()); + } +#endif + /* initialize GStreamer */ gst_init (NULL, NULL); loop = g_main_loop_new (NULL, FALSE); @@ -220,34 +257,88 @@ lastfm_audio_init(void) /* set up */ pipeline = gst_pipeline_new (NULL); source = gst_element_factory_make ("fdsrc", NULL); -#ifdef MAEMO - decoder = source; /* Unused, this is only for the assertions */ +#ifndef GNOME + sink = audio_sink_create(); + if (!pipeline || !source || !sink){ + g_critical ("Error creating GStreamer elements"); + return FALSE; + } #else decoder = audio_decoder_create(); convert = audio_convert_create(); /* This is optional */ -#endif + resampler = gst_element_factory_make ("audioresample", NULL); + + tee = gst_element_factory_make ("tee", NULL); + playqueue = gst_element_factory_make ("queue", NULL); + writequeue = gst_element_factory_make ("queue", NULL); + + // Create a new bin from the choosed audio profile + GMAudioProfile *id; + id = gm_audio_profile_lookup (usercfg->profile); + + // the audio profile is not set or doesn't exist, open preference dialog + if (id == NULL) { + if (controller_update_profiles ()) { + id = gm_audio_profile_lookup (usercfg->profile); + } else { + return FALSE; + } + } + + const char *profile; + profile = gm_audio_profile_get_pipeline (id); + GError *encerror = NULL; + encoder = gst_parse_bin_from_description (g_strdup_printf("identity ! %s", profile), TRUE, &encerror); + if (encerror != NULL) { + g_critical ("Error creating audio profile pipeline: %s", encerror->message); + return FALSE; + } + usercfg->extension = g_strdup (gm_audio_profile_get_extension (id)); + + giosink = gst_element_factory_make ("giosink", NULL); + + // Create the temp file and link it to giosink + GFile *dumpfile; + char *dumpuri; + dumppath = g_strdup_printf ("%s/vagalume-%s", g_get_tmp_dir (), g_get_user_name ()); + dumpfile = g_file_new_for_path (dumppath); + controller_del_dump (dumppath); // delete the previous dump file if any + dumpuri = g_file_get_uri (dumpfile); + g_object_set (G_OBJECT (giosink), "location", dumpuri, NULL); + sink = audio_sink_create(); - if (!pipeline || !source || !decoder || !sink) { + if (!pipeline || !source || !decoder || !sink || !tee || !playqueue || !writequeue || !resampler || !encoder || !giosink) { g_critical ("Error creating GStreamer elements"); return FALSE; } +#endif bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_watch (bus, bus_call, NULL); gst_object_unref (bus); -#ifdef MAEMO +#ifndef GNOME gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL); gst_element_link_many (source, sink, NULL); #else - if (convert != NULL) { - gst_bin_add_many (GST_BIN (pipeline), source, decoder, - convert, sink, NULL); - gst_element_link_many (source, decoder, convert, sink, NULL); - } else { - gst_bin_add_many (GST_BIN (pipeline), source, decoder, - sink, NULL); - gst_element_link_many (source, decoder, sink, NULL); - } + // Create pipeline and link elements + gst_bin_add_many (GST_BIN (pipeline), source, tee, playqueue, writequeue, decoder, + convert, sink, resampler, encoder, giosink, NULL); + + gst_element_link_many (source, decoder, convert, tee, NULL); + gst_element_link_many (playqueue, sink, NULL); + gst_element_link_many (writequeue, resampler, encoder, giosink, NULL); + + queuepad = gst_element_get_pad (playqueue, "sink"); + teepad = gst_element_get_request_pad (tee, "src%d"); + gst_pad_link (teepad, queuepad); + gst_object_unref (queuepad); + gst_object_unref (teepad); + + queuepad = gst_element_get_pad (writequeue, "sink"); + teepad = gst_element_get_request_pad (tee, "src%d"); + gst_pad_link (teepad, queuepad); + gst_object_unref (queuepad); + gst_object_unref (teepad); #endif lastfm_audio_set_volume(80); @@ -280,6 +371,12 @@ lastfm_audio_play(const char *url, GCall lastfm_audio_set_volume(volume == 0 ? 1 : 0); lastfm_audio_set_volume(volume); #endif + + #ifdef GNOME + // The stream begins, apply the tags now + controller_set_tags(encoder); + #endif + return TRUE; } @@ -288,6 +385,14 @@ lastfm_audio_stop(void) { g_return_val_if_fail(pipeline != NULL, FALSE); gst_element_set_state(pipeline, GST_STATE_NULL); + #ifdef GNOME + // the song has ended, check if the user has changed the audio profile + if (usercfg->rebuild_pipeline == TRUE) { + lastfm_audio_init(); + } + // delete the dump file for the next song + controller_del_dump (dumppath); + #endif close_previous_playback(); return TRUE; } diff -up vagalume-hardy/src/controller.c.fix vagalume-hardy/src/controller.c --- vagalume-hardy/src/controller.c.fix 2008-08-29 18:35:08.000000000 +0200 +++ vagalume-hardy/src/controller.c 2008-10-02 00:41:29.000000000 +0200 @@ -10,8 +10,21 @@ #include <glib/gi18n.h> #include <glib.h> +#include <gst/gst.h> #include <string.h> #include <time.h> +#include <glib/gstdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> + +#ifdef GNOME +#include <gio/gio.h> +#include <profiles/gnome-media-profiles.h> +#include <profiles/audio-profile.h> +#include <gconf/gconf-client.h> +#endif #include "connection.h" #include "controller.h" @@ -41,7 +54,12 @@ static LastfmSession *session = NULL; static LastfmPls *playlist = NULL; static RspSession *rsp_sess = NULL; static VglMainWindow *mainwin = NULL; +#ifdef GNOME + // usercfg need to be accessible globally + VglUserCfg *usercfg = NULL; +#else static VglUserCfg *usercfg = NULL; +#endif static GList *friends = NULL; static GList *usertags = NULL; static LastfmTrack *nowplaying = NULL; @@ -567,6 +585,11 @@ controller_open_usercfg(void) userchanged = strcmp(olduser, usercfg->username); pwchanged = strcmp(oldpw, usercfg->password); apply_usercfg(); + #ifdef GNOME + // audio profile changed, need to revuild the pipeline + controller_update_dlbutton(); + usercfg->rebuild_pipeline = TRUE; + #endif } if (userchanged || pwchanged) { if (userchanged) { @@ -873,6 +896,9 @@ static void finish_playing_track(void) { g_return_if_fail(VGL_IS_MAIN_WINDOW(mainwin)); + #ifdef GNOME + usercfg->recording = FALSE; + #endif if (nowplaying != NULL) { controller_scrobble_track(); controller_set_nowplaying(NULL); @@ -887,6 +913,9 @@ void controller_stop_playing(void) { g_return_if_fail(VGL_IS_MAIN_WINDOW(mainwin)); + #ifdef GNOME + usercfg->recording = FALSE; + #endif VglMainWindowState new_state = session != NULL ? VGL_MAIN_WINDOW_STATE_STOPPED : VGL_MAIN_WINDOW_STATE_DISCONNECTED; @@ -917,6 +946,9 @@ void controller_skip_track(void) { g_return_if_fail(VGL_IS_MAIN_WINDOW(mainwin)); + #ifdef GNOME + usercfg->recording = FALSE; + #endif finish_playing_track(); controller_start_playing(); } @@ -945,32 +977,291 @@ controller_disconnect(void) void controller_download_track(void) { - g_return_if_fail(nowplaying && nowplaying->free_track_url && usercfg); - LastfmTrack *t = lastfm_track_ref(nowplaying); - if (controller_confirm_dialog(_("Download this track?"), FALSE)) { - char *filename, *dstpath; - gboolean download = TRUE; - filename = g_strconcat(t->artist, " - ", t->title, ".mp3", - NULL); - dstpath = g_strconcat(usercfg->download_dir, "/", filename, - NULL); - if (file_exists(dstpath)) { - download = controller_confirm_dialog(_("File exists. " - "Overwrite?"), - TRUE); - } - if (download) { - dlwin_download_file(t->free_track_url, filename, - dstpath); + #ifdef GNOME + // Update download button state + if (usercfg->auto_recording != TRUE) { + if (usercfg->recording == FALSE) { + vgl_main_window_toggle (mainwin, TRUE, TRUE); + #ifdef HAVE_TRAY_ICON + if (tray_icon != NULL) { + tray_icon_toggle(tray_icon, TRUE, TRUE); + } + #endif + usercfg->recording = TRUE; + } else { + vgl_main_window_toggle (mainwin, FALSE, TRUE); + #ifdef HAVE_TRAY_ICON + if (tray_icon != NULL) { + tray_icon_toggle(tray_icon, FALSE, TRUE); + } + #endif + usercfg->recording = FALSE; + } + } + #else + g_return_if_fail(nowplaying && nowplaying->free_track_url && usercfg); + LastfmTrack *t = lastfm_track_ref(nowplaying); + if (controller_confirm_dialog(_("Download this track?"), FALSE)) { + char *filename, *dstpath; + gboolean download = TRUE; + filename = g_strconcat(t->artist, " - ", t->title, ".mp3", + NULL); + dstpath = g_strconcat(usercfg->download_dir, "/", filename, + NULL); + if (file_exists(dstpath)) { + download = controller_confirm_dialog(_("File exists. " + "Overwrite?"), + TRUE); + } + if (download) { + dlwin_download_file(t->free_track_url, filename, + dstpath); + } + g_free(filename); + g_free(dstpath); + } else { + lastfm_track_unref(t); } - g_free(filename); - g_free(dstpath); + #endif +} + +#ifdef GNOME +/** + * Update main window and tray if auto_recording have been changed + */ +void +controller_update_dlbutton (void) +{ + if (nowplaying != NULL) { + vgl_main_window_toggle (mainwin, usercfg->auto_recording, !(usercfg->auto_recording)); + #ifdef HAVE_TRAY_ICON + if (tray_icon != NULL) { + tray_icon_toggle(tray_icon, usercfg->auto_recording, !(usercfg->auto_recording)); + } + #endif } else { - lastfm_track_unref(t); + vgl_main_window_toggle (mainwin, usercfg->auto_recording, FALSE); + #ifdef HAVE_TRAY_ICON + if (tray_icon != NULL) { + tray_icon_toggle(tray_icon, usercfg->auto_recording, FALSE); + } + #endif + } +} + +/** + * If the current audio profile is not available, open the settings dialog. + */ +gboolean +controller_update_profiles (void) +{ + GtkWidget *dialog; + int response; + + dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), + GTK_DIALOG_MODAL, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + _("The currently selected audio profile is not available on your installation.")); + + gtk_dialog_add_button (GTK_DIALOG (dialog), "gtk-quit", GTK_RESPONSE_REJECT); + gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Change Profile"), GTK_RESPONSE_ACCEPT); + response = gtk_dialog_run (GTK_DIALOG (dialog)); + if (response == GTK_RESPONSE_ACCEPT) { + gtk_widget_destroy (dialog); + controller_open_usercfg(); + if (gm_audio_profile_lookup (usercfg->profile) != '\0') { + return TRUE; + } else { + return FALSE; + } + } else { + return FALSE; + } +} + +/** + * Delete the dump file at track's end + */ +void +controller_del_dump (char *dumppath) +{ + GFile *dumpfile; + dumpfile = g_file_new_for_path (dumppath); + gboolean result; + result = g_file_delete (dumpfile, NULL, NULL); +} + +/** + * Apply the tags to the encoder pipeline + * need id3v2mux for mp3, or vorbistag support + * (via vorbisenc or flacenc for example) + */ +void +controller_set_tags (GstElement *element) +{ + LastfmTrack *t = lastfm_track_ref(nowplaying); + GstIterator *iter; + GstTagSetter *tagger; + gboolean done = FALSE; + GstTagList *taglist = gst_tag_list_new (); + + // Create a taglist base upon the current track info + gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE_ALL, GST_TAG_TITLE, + t->title, GST_TAG_ARTIST, t->artist, GST_TAG_ALBUM, t->album, NULL); + + // Search through the encoder pipeline for an element which support tag setting + // (e.g. id3v2mux or vorbisenc) + iter = gst_bin_iterate_all_by_interface (GST_BIN (element), GST_TYPE_TAG_SETTER); + + while (!done) { + switch (gst_iterator_next (iter, (gpointer)&tagger)) { + case GST_ITERATOR_OK: + // If GST_TYPE_TAG_SETTER found merge the tags + gst_tag_setter_merge_tags (tagger, taglist, GST_TAG_MERGE_REPLACE_ALL); + gst_object_unref (tagger); + break; + case GST_ITERATOR_RESYNC: + break; + case GST_ITERATOR_ERROR: + done = TRUE; + break; + case GST_ITERATOR_DONE: + done = TRUE; + break; + } } + + gst_tag_list_free (taglist); + gst_iterator_free (iter); } /** + * Copy the dump file if the user request the saving + */ +void +controller_save_song (void) +{ + LastfmTrack *t = lastfm_track_ref(nowplaying); + + if (usercfg->auto_recording == TRUE || usercfg->recording == TRUE) { + char *filename, *savedfile; + char *artist, *album, *title; + gboolean result, copyresult; + GFile *srcpath, *destpath, *pathparent; + GError *copyerror = NULL; + + // Replace the filename pattern by the correct values + GRegex *reg_artist, *reg_album, *reg_title, *reg_slash; + reg_artist = g_regex_new ("{artist}", 0, 0, NULL); + reg_album = g_regex_new ("{album}", 0, 0, NULL); + reg_title = g_regex_new ("{title}", 0, 0, NULL); + reg_slash = g_regex_new ("/", 0, 0, NULL); + + artist = g_regex_replace_literal (reg_slash, t->artist, -1, 0, "-", 0, NULL); + album = g_regex_replace_literal (reg_slash, t->album, -1, 0, "-", 0, NULL); + title = g_regex_replace_literal (reg_slash, t->title, -1, 0, "-", 0, NULL); + + filename= g_regex_replace (reg_artist, usercfg->filename, -1, 0, artist, 0, NULL); + if (album == '\0') { + filename= g_regex_replace (reg_album, filename, -1, 0, _("unknown"), 0, NULL); + } else { + filename= g_regex_replace (reg_album, filename, -1, 0, album, 0, NULL); + } + filename= g_regex_replace (reg_title, filename, -1, 0, title, 0, NULL); + + // Concatenate base directory, filename pattern and extension + savedfile = g_strconcat (usercfg->download_dir, "/", filename, ".", usercfg->extension, NULL); + + // Create the destination path if it doesn't exist + srcpath = g_file_new_for_path (g_strdup_printf ("%s/vagalume-%s", g_get_tmp_dir (), g_get_user_name ())); + destpath = g_file_new_for_path (savedfile); + pathparent = g_file_get_parent (destpath); + + //result = g_file_make_directory_with_parents (pathparent, NULL, NULL); + + GFile *parent_file, *work_file; + GList *list = NULL, *l; + GError *my_error = NULL; + + result = g_file_make_directory (pathparent, NULL, &my_error); + + work_file = destpath; + + while (!result && my_error->code == G_IO_ERROR_NOT_FOUND) + { + g_clear_error (&my_error); + + parent_file = g_file_get_parent (work_file); + if (parent_file == NULL) + break; + result = g_file_make_directory (parent_file, NULL, &my_error); + + if (!result && my_error->code == G_IO_ERROR_NOT_FOUND) + list = g_list_prepend (list, parent_file); + + work_file = parent_file; + } + + for (l = list; result && l; l = l->next) + { + result = g_file_make_directory ((GFile *) l->data, NULL, &my_error); + } + + /* Clean up */ + while (list != NULL) + { + g_object_unref ((GFile *) list->data); + list = g_list_remove (list, list->data); + } + + // End reimplement + + // Check if the file exist and overwrite it or not depending on user choice + if (usercfg->overwrite != TRUE) { + copyresult = g_file_copy (srcpath, destpath, G_FILE_COPY_OVERWRITE, + NULL, NULL, NULL, NULL); + } else { + gint nb = 1; + while (g_file_copy (srcpath, destpath, G_FILE_COPY_NONE, + NULL, NULL, NULL, ©error) == FALSE) { + if (copyerror->code == G_IO_ERROR_EXISTS) { + if ((nb < 256)&&(nb < (gint) usercfg->ownb)) { + nb++; + } else { + break; + } + gchar *testfile = savedfile; + GRegex *nb_regex = g_regex_new(g_strdup_printf(".%s", usercfg->extension), 0, 0, NULL); + testfile = g_regex_replace (nb_regex, savedfile, -1, 0, + g_strdup_printf (" (version %i).%s", nb, usercfg->extension), 0, NULL); + destpath = g_file_new_for_path (testfile); + g_regex_unref (nb_regex); + g_free (testfile); + } else { + break; + } + copyerror = NULL; + } + } + + g_regex_unref (reg_artist); + g_regex_unref (reg_album); + g_regex_unref (reg_title); + g_regex_unref (reg_slash); + g_free (artist); + g_free (album); + g_free (title); + g_free (filename); + g_free (savedfile); + g_object_unref (srcpath); + g_object_unref (destpath); + g_object_unref (pathparent); + } +} +#endif + +/** * Opens the bookmarks window */ void diff -up vagalume-hardy/src/controller.h.fix vagalume-hardy/src/controller.h --- vagalume-hardy/src/controller.h.fix 2008-08-16 22:34:41.000000000 +0200 +++ vagalume-hardy/src/controller.h 2008-09-29 22:14:35.000000000 +0200 @@ -13,6 +13,8 @@ #include "radio.h" #include "xmlrpc.h" +#include "gst/gst.h" + void controller_stop_playing(void); void controller_disconnect(void); void controller_start_playing(void); @@ -31,6 +33,13 @@ void controller_tag_track(void); void controller_recomm_track(void); void controller_add_to_playlist(void); void controller_download_track(void); +#ifndef MAEMO + void controller_update_dlbutton(void); + gboolean controller_update_profiles(void); + void controller_del_dump(char *dumppath); + void controller_set_tags(GstElement *element); + void controller_save_song(void); +#endif void controller_manage_bookmarks(void); void controller_add_bookmark(request_type type); void controller_open_usercfg(void); diff -up vagalume-hardy/src/uimisc.c.fix vagalume-hardy/src/uimisc.c --- vagalume-hardy/src/uimisc.c.fix 2008-08-16 23:23:54.000000000 +0200 +++ vagalume-hardy/src/uimisc.c 2008-10-02 00:39:37.000000000 +0200 @@ -16,6 +16,12 @@ #include <string.h> #include <gtk/gtk.h> +#ifdef GNOME +#include <profiles/gnome-media-profiles.h> +#include <profiles/audio-profile.h> +#include <gconf/gconf-client.h> +#endif + #if defined(HILDON_LIBS) # include <hildon-widgets/hildon-program.h> # include <hildon-widgets/hildon-banner.h> @@ -61,7 +67,13 @@ typedef struct { GtkDialog *dialog; GtkNotebook *nb; GtkEntry *user, *pw, *proxy, *dlentry; - GtkWidget *dlbutton, *scrobble, *discovery, *useproxy; + GtkWidget *dlbutton; + #ifdef GNOME + GtkEntry *file; + GtkWidget *autodl, *overwrite, *ownumber, *ownblabel; + GtkWidget *profilecombo, *profilebutton; + #endif + GtkWidget *scrobble, *discovery, *useproxy; GtkWidget *disableconfdiags; GtkWidget *helpbtn; #ifdef SET_IM_STATUS @@ -281,9 +293,12 @@ ui_select_download_dir(GtkWindow *parent NULL); #endif gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE); - if (curdir != NULL) { + if (curdir != '\0') { gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), curdir); + } else { + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), + g_get_home_dir()); } if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { dir = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); @@ -331,6 +346,40 @@ usercfg_user_pw_modified(GObject *obj, G GTK_RESPONSE_ACCEPT, userpw); } +#ifdef GNOME +static void +usercfg_file_modified(GObject *obj, GParamSpec *arg, usercfgwin *win) +{ + const char *dlentry = gtk_entry_get_text(win->dlentry); + const char *file = gtk_entry_get_text(GTK_ENTRY(win->file)); + gboolean filedl = (dlentry && file && strlen(dlentry) > 0 && strlen(file) > 0); + gtk_dialog_set_response_sensitive(win->dialog, + GTK_RESPONSE_ACCEPT, filedl); +} + +static void +usercfg_ownb_modified(GtkWidget *button, usercfgwin *win) +{ + gtk_widget_set_sensitive(GTK_WIDGET(win->ownumber), gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button))); + gtk_widget_set_sensitive(GTK_WIDGET(win->ownblabel), gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button))); +} + +static void +edit_profile_clicked (GtkButton *button, usercfgwin *win) +{ + GtkWidget *dialog; + dialog = gm_audio_profiles_edit_new (gconf_client_get_default (), GTK_WINDOW (win->dialog)); + gtk_widget_show_all (dialog); + gtk_dialog_run (GTK_DIALOG (dialog)); + + // update the combobox + GtkTreeModel *model; + model = gtk_combo_box_get_model (GTK_COMBO_BOX (gm_audio_profile_choose_new ())); + gtk_combo_box_set_model (GTK_COMBO_BOX (win->profilecombo), model); + gtk_combo_box_set_active (GTK_COMBO_BOX (win->profilecombo), 0); +} +#endif + static void usercfg_add_account_settings(usercfgwin *win, VglUserCfg *cfg) { @@ -443,27 +492,103 @@ usercfg_add_download_settings(usercfgwin g_return_if_fail(win != NULL && GTK_IS_NOTEBOOK(win->nb)); GtkTable *table; GtkWidget *dllabel; + #ifdef GNOME + GtkBox *dlbox, *owbox, *profilebox; + GtkWidget *filelabel, *autodllabel, *owlabel, *profilelabel; + GtkObject *owadjust; + owadjust = gtk_adjustment_new(1.0, 1.0, 255.0, 1.0, 10.0, 0.0); + #endif const char *help; /* Create widgets */ + #ifdef GNOME + table = GTK_TABLE(gtk_table_new(5, 2, FALSE)); + #else table = GTK_TABLE(gtk_table_new(2, 2, FALSE)); + #endif dllabel = gtk_label_new(_("Select download directory")); + #ifdef GNOME + filelabel = gtk_label_new(_("File Pattern:")); + autodllabel = gtk_label_new(_("Automatic download:")); + owlabel = gtk_label_new(_("Do not overwrite:")); + win->ownblabel = gtk_label_new(_("Max versions:")); + profilelabel = gtk_label_new(_("Output format:")); + #endif + win->dlbutton = compat_gtk_button_new(); win->dlentry = GTK_ENTRY(gtk_entry_new()); + #ifdef GNOME + win->file = GTK_ENTRY(gtk_entry_new()); + win->autodl = gtk_check_button_new(); + win->overwrite = gtk_check_button_new(); + win->ownumber = gtk_spin_button_new(GTK_ADJUSTMENT(owadjust), 0.5, 0.0); + win->profilecombo = gm_audio_profile_choose_new (); + win->profilebutton = compat_gtk_button_new(); + + g_signal_connect(G_OBJECT(win->dlentry), "notify::text", + G_CALLBACK(usercfg_file_modified), win); + g_signal_connect(G_OBJECT(win->file), "notify::text", + G_CALLBACK(usercfg_file_modified), win); + g_signal_connect(G_OBJECT(win->overwrite), "toggled", + G_CALLBACK(usercfg_ownb_modified), win); + g_signal_connect(G_OBJECT(win->profilebutton), "clicked", + G_CALLBACK(edit_profile_clicked), win); + #endif + /* Set widget properties */ gtk_button_set_image(GTK_BUTTON(win->dlbutton), gtk_image_new_from_stock(GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_BUTTON)); + #ifdef GNOME + gtk_button_set_image(GTK_BUTTON(win->profilebutton), + gtk_image_new_from_stock(GTK_STOCK_EDIT, + GTK_ICON_SIZE_BUTTON)); + #endif /* Set initial values */ gtk_entry_set_text(win->dlentry, cfg->download_dir); + #ifdef GNOME + gtk_entry_set_text(GTK_ENTRY(win->file), cfg->filename); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->autodl), + cfg->auto_recording); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->overwrite), + cfg->overwrite); + gtk_widget_set_sensitive(GTK_WIDGET(win->ownumber), cfg->overwrite); + gtk_widget_set_sensitive(GTK_WIDGET(win->ownblabel), cfg->overwrite); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(win->ownumber), cfg->ownb); + gm_audio_profile_choose_set_active (GTK_WIDGET(win->profilecombo), cfg->profile); + #endif /* Pack widgets */ - gtk_table_attach(table, dllabel, 0, 2, 0, 1, 0, 0, 5, 5); - gtk_table_attach(table, GTK_WIDGET(win->dlentry), 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, 0, 5, 5); - gtk_table_attach(table, win->dlbutton, 1, 2, 1, 2, 0, 0, 5, 5); + #ifdef GNOME + gtk_table_attach(table, dllabel, 0, 1, 0, 1, 0, 0, 5, 5); + dlbox = GTK_BOX(gtk_hbox_new(FALSE, 2)); + gtk_box_pack_start(dlbox, GTK_WIDGET(win->dlentry), TRUE, TRUE, 0); + gtk_box_pack_start(dlbox, win->dlbutton, FALSE, FALSE, 0); + gtk_table_attach(table, GTK_WIDGET(dlbox), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 5, 5); + + gtk_table_attach(table, filelabel, 0, 1, 1, 2, 0, 0, 5, 5); + gtk_table_attach(table, GTK_WIDGET(win->file), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 5, 5); + gtk_table_attach(table, profilelabel, 0, 1, 2, 3, 0, 0, 5, 5); + profilebox = GTK_BOX(gtk_hbox_new(FALSE, 2)); + gtk_box_pack_start(profilebox, win->profilecombo, TRUE, TRUE, 0); + gtk_box_pack_start(profilebox, win->profilebutton, FALSE, FALSE, 0); + gtk_table_attach(table, GTK_WIDGET(profilebox), 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 5, 5); + gtk_table_attach(table, owlabel, 0, 1, 3, 4, 0, 0, 5, 5); + owbox = GTK_BOX(gtk_hbox_new(FALSE, 3)); + gtk_box_pack_start(owbox, win->overwrite, FALSE, FALSE, 0); + gtk_box_pack_start(owbox, win->ownblabel, FALSE, FALSE, 0); + gtk_box_pack_start(owbox, win->ownumber, FALSE, FALSE, 0); + gtk_table_attach(table, GTK_WIDGET(owbox), 1, 2, 3, 4, 0, 0, 5, 5); + gtk_table_attach(table, autodllabel, 0, 1, 4, 5, 0, 0, 5, 5); + gtk_table_attach(table, win->autodl, 1, 2, 4, 5, 0, 0, 5, 5); + #else + gtk_table_attach(table, dllabel, 0, 2, 0, 1, 0, 0, 5, 5); + gtk_table_attach(table, GTK_WIDGET(win->dlentry), 0, 1, 1, 2, + GTK_EXPAND | GTK_FILL, 0, 5, 5); + gtk_table_attach(table, win->dlbutton, 1, 2, 1, 2, 0, 0, 5, 5); + #endif gtk_notebook_append_page(win->nb, GTK_WIDGET(table), gtk_label_new(_("Download"))); @@ -638,7 +763,7 @@ ui_usercfg_window(GtkWindow *parent, Vgl windata = g_slice_new(change_dir_selected_data); windata->win = GTK_WINDOW(win.dialog); windata->entry = GTK_ENTRY(win.dlentry); - + g_signal_connect(G_OBJECT(win.dlbutton), "clicked", G_CALLBACK(change_dir_selected), windata); g_signal_connect(G_OBJECT(win.helpbtn), "clicked", @@ -657,6 +782,25 @@ ui_usercfg_window(GtkWindow *parent, Vgl GTK_TOGGLE_BUTTON(win.discovery)); (*cfg)->use_proxy = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(win.useproxy)); + #ifdef GNOME + vgl_user_cfg_set_filename(*cfg, + g_strstrip (g_strdup(gtk_entry_get_text(GTK_ENTRY(win.file))))); + + //audio profile handling + GMAudioProfile *profile; + gchar *id; + profile = gm_audio_profile_choose_get_active (GTK_WIDGET (win.profilecombo)); + id = g_strdup (gm_audio_profile_get_id (profile)); + vgl_user_cfg_set_profile(*cfg, id); + g_free (id); + + (*cfg)->auto_recording = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(win.autodl)); + (*cfg)->overwrite = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(win.overwrite)); + vgl_user_cfg_set_ownb (*cfg, + gtk_spin_button_get_value(GTK_SPIN_BUTTON (win.ownumber))); + #endif #ifdef SET_IM_STATUS vgl_user_cfg_set_imstatus_template(*cfg, gtk_entry_get_text(win.imtemplateentry)); diff -up vagalume-hardy/src/uimisc.h.fix vagalume-hardy/src/uimisc.h diff -up vagalume-hardy/src/userconfig.c.fix vagalume-hardy/src/userconfig.c --- vagalume-hardy/src/userconfig.c.fix 2008-08-30 02:08:58.000000000 +0200 +++ vagalume-hardy/src/userconfig.c 2008-10-02 00:39:04.000000000 +0200 @@ -127,6 +127,30 @@ vgl_user_cfg_set_download_dir(VglUserCfg cfg->download_dir = g_strstrip(g_strdup(dir)); } +#ifdef GNOME +void +vgl_user_cfg_set_filename (VglUserCfg *cfg, const char *filename) +{ + g_return_if_fail(cfg != NULL && filename != NULL); + g_free(cfg->filename); + cfg->filename = g_strstrip(g_strdup(filename)); +} + +void +vgl_user_cfg_set_profile (VglUserCfg *cfg, const char *profile) +{ + g_return_if_fail(cfg != NULL && profile != NULL); + g_free(cfg->profile); + cfg->profile = g_strstrip(g_strdup(profile)); +} + +void +vgl_user_cfg_set_ownb (VglUserCfg *cfg, const gdouble ownb) +{ + cfg->ownb = ownb; +} +#endif + void vgl_user_cfg_set_imstatus_template(VglUserCfg *cfg, const char *str) { @@ -142,7 +166,19 @@ vgl_user_cfg_new(void) cfg->username = g_strdup(""); cfg->password = g_strdup(""); cfg->http_proxy = g_strdup(""); - cfg->download_dir = default_download_dir(); + #ifdef GNOME + cfg->download_dir = g_strdup(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC)); + cfg->filename = g_strdup("{artist} - {album} - {title}"); + cfg->profile = g_strdup("cdlossy"); + cfg->extension = '\0'; + cfg->rebuild_pipeline = FALSE; + cfg->recording = FALSE; + cfg->auto_recording = FALSE; + cfg->overwrite = FALSE; + cfg->ownb = 1.0; + #else + cfg->download_dir = default_download_dir(); + #endif cfg->imstatus_template = g_strdup(DEFAULT_IMSTATUS_TEMPLATE); cfg->use_proxy = FALSE; cfg->enable_scrobbling = TRUE; @@ -164,6 +200,11 @@ vgl_user_cfg_destroy(VglUserCfg *cfg) g_free(cfg->password); g_free(cfg->http_proxy); g_free(cfg->download_dir); + #ifdef GNOME + g_free(cfg->filename); + g_free(cfg->profile); + g_free(cfg->extension); + #endif g_free(cfg->imstatus_template); g_slice_free(VglUserCfg, cfg); } @@ -206,12 +247,20 @@ lastfm_old_usercfg_read(void) cfg->discovery_mode = !strcmp(val, "1"); } else if ((val = cfg_get_val(buf, "scrobble")) != NULL) { cfg->enable_scrobbling = !strcmp(val, "1"); + #ifdef GNOME + } else if ((val = cfg_get_val(buf, "auto_recording")) != NULL) { + cfg->auto_recording = !strcmp(val, "1"); + #endif } else if ((val = cfg_get_val(buf, "use_proxy")) != NULL) { cfg->use_proxy = !strcmp(val, "1"); } else if ((val = cfg_get_val(buf, "http_proxy")) != NULL) { vgl_user_cfg_set_http_proxy(cfg, val); } else if ((val = cfg_get_val(buf, "download_dir")) != NULL) { vgl_user_cfg_set_download_dir(cfg, val); + #ifdef GNOME + } else if ((val = cfg_get_val(buf, "filename")) != NULL) { + vgl_user_cfg_set_filename(cfg, val); + #endif } else if ((val = cfg_get_val(buf, "imstatus_template")) != NULL) { vgl_user_cfg_set_imstatus_template(cfg, val); } else if ((val = cfg_get_val(buf, "im_pidgin")) != NULL) { @@ -352,6 +401,12 @@ vgl_user_cfg_read (void) xml_get_string (doc, node, "http-proxy", &(cfg->http_proxy)); xml_get_string (doc, node, "download-dir", &(cfg->download_dir)); + #ifdef GNOME + xml_get_string (doc, node, "filename", + &(cfg->filename)); + xml_get_string (doc, node, "profile", + &(cfg->profile)); + #endif xml_get_string (doc, node, "imstatus-template", &(cfg->imstatus_template)); xml_get_bool (doc, node, "use-proxy", &(cfg->use_proxy)); @@ -359,6 +414,14 @@ vgl_user_cfg_read (void) &(cfg->discovery_mode)); xml_get_bool (doc, node, "enable-scrobbling", &(cfg->enable_scrobbling)); + #ifdef GNOME + xml_get_bool (doc, node, "auto-recording", + &(cfg->auto_recording)); + xml_get_bool (doc, node, "overwrite", + &(cfg->overwrite)); + xml_get_string (doc, node, "ownb", &(cfg->ownbtmp)); + cfg->ownb = strtod (cfg->ownbtmp, NULL); + #endif xml_get_bool (doc, node, "im-pidgin", &(cfg->im_pidgin)); xml_get_bool (doc, node, "im-gajim", &(cfg->im_gajim)); xml_get_bool (doc, node, "im-gossip", &(cfg->im_gossip)); @@ -398,10 +461,20 @@ vgl_user_cfg_write (VglUserCfg *cfg) obfuscate_string (cfg->password); xml_add_string (root, "http-proxy", cfg->http_proxy); xml_add_string (root, "download-dir", cfg->download_dir); + #ifdef GNOME + xml_add_string (root, "filename", cfg->filename); + xml_add_string (root, "profile", cfg->profile); + #endif xml_add_string (root, "imstatus-template", cfg->imstatus_template); xml_add_bool (root, "use-proxy", cfg->use_proxy); xml_add_bool (root, "discovery-mode", cfg->discovery_mode); xml_add_bool (root, "enable-scrobbling", cfg->enable_scrobbling); + #ifdef GNOME + xml_add_bool (root, "auto-recording", cfg->auto_recording); + xml_add_bool (root, "overwrite", cfg->overwrite); + g_sprintf(cfg->ownbtmp, "%1.0f", cfg->ownb); + xml_add_string (root, "ownb", cfg->ownbtmp); + #endif xml_add_bool (root, "im-pidgin", cfg->im_pidgin); xml_add_bool (root, "im-gajim", cfg->im_gajim); xml_add_bool (root, "im-gossip", cfg->im_gossip); diff -up vagalume-hardy/src/userconfig.h.fix vagalume-hardy/src/userconfig.h --- vagalume-hardy/src/userconfig.h.fix 2008-08-16 23:23:54.000000000 +0200 +++ vagalume-hardy/src/userconfig.h 2008-09-29 16:27:25.000000000 +0200 @@ -17,6 +17,17 @@ typedef struct { char *password; /* Never NULL, even if not defined */ char *http_proxy; /* Never NULL, even if not defined */ char *download_dir; /* Never NULL */ + #ifdef GNOME + char *filename; + char *profile; + char *extension; + gboolean rebuild_pipeline; + gboolean recording; + gboolean auto_recording; + gboolean overwrite; + char *ownbtmp; + gdouble ownb; + #endif char *imstatus_template; /* Never NULL */ gboolean use_proxy; gboolean discovery_mode; @@ -36,6 +47,11 @@ void vgl_user_cfg_set_username(VglUserCf void vgl_user_cfg_set_password(VglUserCfg *cfg, const char *password); void vgl_user_cfg_set_http_proxy(VglUserCfg *cfg, const char *proxy); void vgl_user_cfg_set_download_dir(VglUserCfg *cfg, const char *dir); +#ifdef GNOME +void vgl_user_cfg_set_filename (VglUserCfg *cfg, const char *filename); +void vgl_user_cfg_set_profile (VglUserCfg *cfg, const char *profile); +void vgl_user_cfg_set_ownb (VglUserCfg *cfg, const gdouble ownb); +#endif void vgl_user_cfg_set_imstatus_template(VglUserCfg *cfg, const char *str); VglUserCfg *vgl_user_cfg_read(void); diff -up vagalume-hardy/src/vgl-main-window.c.fix vagalume-hardy/src/vgl-main-window.c --- vagalume-hardy/src/vgl-main-window.c.fix 2008-08-29 00:29:10.000000000 +0200 +++ vagalume-hardy/src/vgl-main-window.c 2008-09-30 14:23:40.000000000 +0200 @@ -306,6 +306,19 @@ vgl_main_window_show_progress(VglMainWin set_progress_bar_text(w, count); } +#ifdef GNOME +void +vgl_main_window_toggle(VglMainWindow *w, gboolean status, gboolean sensit) +{ + g_return_if_fail(VGL_IS_MAIN_WINDOW(w)); + VglMainWindowPrivate *priv = VGL_MAIN_WINDOW_GET_PRIVATE(w); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->dloadbutton), status); + gtk_widget_set_sensitive (priv->dloadbutton, sensit); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(priv->dload), status); + gtk_widget_set_sensitive (priv->dload, sensit); +} +#endif + typedef struct { VglMainWindow *win; guint msgid; @@ -414,10 +427,18 @@ vgl_main_window_set_state(VglMainWindow gtk_widget_set_sensitive (priv->lovebutton, FALSE); gtk_widget_set_sensitive (priv->banbutton, FALSE); gtk_widget_set_sensitive (priv->recommendbutton, FALSE); - gtk_widget_set_sensitive (priv->dloadbutton, FALSE); + #ifdef GNOME + gtk_widget_set_sensitive (priv->dloadbutton, FALSE); + #else + gtk_widget_set_sensitive (priv->dloadbutton, + t->free_track_url != NULL); + #endif gtk_widget_set_sensitive (priv->tagbutton, FALSE); gtk_widget_set_sensitive (priv->addplbutton, FALSE); gtk_widget_set_sensitive (priv->settings, TRUE); + #ifdef GNOME + gtk_widget_set_sensitive (priv->dload, FALSE); + #endif gtk_widget_set_sensitive (priv->bmkartist, FALSE); gtk_widget_set_sensitive (priv->bmktrack, FALSE); gtk_window_set_title(GTK_WINDOW(w), APP_NAME); @@ -444,15 +465,20 @@ vgl_main_window_set_state(VglMainWindow gtk_widget_set_sensitive (priv->lovebutton, TRUE); gtk_widget_set_sensitive (priv->banbutton, TRUE); gtk_widget_set_sensitive (priv->recommendbutton, TRUE); - gtk_widget_set_sensitive (priv->dloadbutton, - t->free_track_url != NULL); + #ifdef GNOME + controller_update_dlbutton(); + #else + gtk_widget_set_sensitive (priv->dloadbutton, + t->free_track_url != NULL); + gtk_widget_set_sensitive (priv->dload, + t->free_track_url != NULL); + #endif gtk_widget_set_sensitive (priv->tagbutton, TRUE); gtk_widget_set_sensitive (priv->addplbutton, TRUE); gtk_widget_set_sensitive (priv->love, TRUE); gtk_widget_set_sensitive (priv->settings, TRUE); gtk_widget_set_sensitive (priv->bmkartist, t->artistid > 0); gtk_widget_set_sensitive (priv->bmktrack, t->id > 0); - gtk_widget_set_sensitive (priv->dload, t->free_track_url != NULL); break; case VGL_MAIN_WINDOW_STATE_CONNECTING: dim_labels = TRUE; @@ -474,6 +500,9 @@ vgl_main_window_set_state(VglMainWindow gtk_widget_set_sensitive (priv->tagbutton, FALSE); gtk_widget_set_sensitive (priv->addplbutton, FALSE); gtk_widget_set_sensitive (priv->settings, FALSE); + #ifdef GNOME + gtk_widget_set_sensitive (priv->dload, FALSE); + #endif gtk_window_set_title(GTK_WINDOW(w), APP_NAME); gtk_widget_set_sensitive(priv->album_cover, FALSE); gtk_check_menu_item_set_active( @@ -734,7 +763,17 @@ static GtkWidget * image_button_new(const button_data *data) { g_return_val_if_fail(data->icon_name && data->icon_size > 0, NULL); - GtkWidget *button = compat_gtk_button_new(); + #ifdef GNOME + GtkWidget *button; + if (data == &dload_button) { + button = gtk_toggle_button_new(); + } else { + button = compat_gtk_button_new(); + } + #else + GtkWidget *button; + button = compat_gtk_button_new(); + #endif GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); static GtkTooltips *tooltips = NULL; @@ -893,7 +932,11 @@ create_main_menu(VglMainWindow *w, GtkAc love = gtk_menu_item_new_with_label(_("Love this track")); ban = gtk_menu_item_new_with_label(_("Ban this track")); addtopls = gtk_menu_item_new_with_label(_("Add to playlist")); - dload = gtk_menu_item_new_with_label(_("Download this track")); + #ifdef GNOME + dload = gtk_check_menu_item_new_with_label(_("Download this track")); + #else + dload = gtk_menu_item_new_with_label(_("Download this track")); + #endif tag = gtk_menu_item_new_with_label(_("Tag...")); dorecomm = gtk_menu_item_new_with_label(_("Recommend...")); gtk_menu_shell_append(bar, GTK_WIDGET(actions)); diff -up vagalume-hardy/src/vgl-main-window.h.fix vagalume-hardy/src/vgl-main-window.h --- vagalume-hardy/src/vgl-main-window.h.fix 2008-08-16 22:34:41.000000000 +0200 +++ vagalume-hardy/src/vgl-main-window.h 2008-09-28 13:01:43.000000000 +0200 @@ -63,6 +63,8 @@ struct _VglMainWindow #endif }; + + /* UI state */ typedef enum { VGL_MAIN_WINDOW_STATE_DISCONNECTED, @@ -81,6 +83,9 @@ void vgl_main_window_set_state(VglMainWi const LastfmTrack *t); void vgl_main_window_show_progress(VglMainWindow *w, guint length, guint played); +#ifdef GNOME +void vgl_main_window_toggle(VglMainWindow *w, gboolean status, gboolean sensit); +#endif void vgl_main_window_show_status_msg(VglMainWindow *w, const char *text); void vgl_main_window_set_album_cover(VglMainWindow *w, const char *data, int size); diff -up vagalume-hardy/src/vgl-tray-icon.c.fix vagalume-hardy/src/vgl-tray-icon.c --- vagalume-hardy/src/vgl-tray-icon.c.fix 2008-08-16 22:34:41.000000000 +0200 +++ vagalume-hardy/src/vgl-tray-icon.c 2008-09-30 14:12:43.000000000 +0200 @@ -28,6 +28,9 @@ #define RECOMMEND_ITEM_STRING _("Recommend...") #define TAG_ITEM_STRING _("Tags...") #define ADD_TO_PLS_ITEM_STRING _("Add to playlist") +#ifdef GNOME +#define SAVE_SONG_ITEM_STRING _("Save this track") +#endif #define LOVE_ITEM_STRING _("Love this track") #define BAN_ITEM_STRING _("Ban this track") #define PLAY_ITEM_STRING _("Play") @@ -43,6 +46,9 @@ #define RECOMMEND_ITEM_ICON_NAME "mail-message-new" #define TAG_ITEM_ICON_NAME "accessories-text-editor" #define ADD_TO_PLS_ITEM_ICON_NAME "list-add" +#ifdef GNOME +#define SAVE_SONG_ITEM_ICON_NAME "document-save" +#endif #define LOVE_ITEM_ICON_NAME "emblem-favorite" #define BAN_ITEM_ICON_NAME "process-stop" #define PLAY_ITEM_ICON_NAME "media-playback-start" @@ -71,6 +77,9 @@ struct _VglTrayIconPrivate GtkWidget *recommend_item; GtkWidget *tag_item; GtkWidget *add_to_pls_item; +#ifdef GNOME + GtkWidget *save_song_item; +#endif GtkWidget *love_item; GtkWidget *ban_item; GtkWidget *play_item; @@ -88,6 +97,9 @@ struct _VglTrayIconPrivate gint recommend_item_handler_id; gint tag_item_handler_id; gint add_to_pls_item_handler_id; +#ifdef GNOME + gint save_song_item_handler_id; +#endif gint love_item_handler_id; gint ban_item_handler_id; gint play_item_handler_id; @@ -111,6 +123,7 @@ static void cleanup_libnotify (VglTrayI static void ctxt_menu_create (VglTrayIcon *vti); static void ctxt_menu_update (VglTrayIcon *vti); + /* Signals handlers */ static void tray_icon_clicked (GtkStatusIcon *status_icon, gpointer user_data); @@ -148,6 +161,9 @@ vgl_tray_icon_init (VglTrayIcon *vti) priv->recommend_item = NULL; priv->tag_item = NULL; priv->add_to_pls_item = NULL; +#ifdef GNOME + priv->save_song_item = NULL; +#endif priv->love_item = NULL; priv->ban_item = NULL; priv->play_item = NULL; @@ -202,6 +218,10 @@ vgl_tray_icon_finalize (GObject* object) priv->tag_item_handler_id); g_signal_handler_disconnect (priv->add_to_pls_item, priv->add_to_pls_item_handler_id); +#ifdef GNOME + g_signal_handler_disconnect (priv->save_song_item, + priv->save_song_item_handler_id); +#endif g_signal_handler_disconnect (priv->love_item, priv->love_item_handler_id); g_signal_handler_disconnect (priv->ban_item, @@ -274,11 +294,23 @@ ctxt_menu_item_create (const gchar *icon gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); g_object_unref (pixbuf); - } + } return item; } +#ifdef GNOME +static GtkWidget * +ctxt_check_menu_item_create (const gchar *icon_name, const gchar *label) +{ + g_return_val_if_fail (icon_name != NULL && label != NULL, NULL); + + GtkWidget *item = gtk_check_menu_item_new_with_label (label); + + return item; +} +#endif + static void ctxt_menu_create (VglTrayIcon *vti) { @@ -296,6 +328,10 @@ ctxt_menu_create (VglTrayIcon *vti) ctxt_menu_item_create (TAG_ITEM_ICON_NAME, TAG_ITEM_STRING); priv->add_to_pls_item = ctxt_menu_item_create (ADD_TO_PLS_ITEM_ICON_NAME, ADD_TO_PLS_ITEM_STRING); +#ifdef GNOME + priv->save_song_item = + ctxt_check_menu_item_create (SAVE_SONG_ITEM_ICON_NAME, SAVE_SONG_ITEM_STRING); +#endif priv->love_item = ctxt_menu_item_create (LOVE_ITEM_ICON_NAME, LOVE_ITEM_STRING); priv->ban_item = @@ -316,6 +352,9 @@ ctxt_menu_create (VglTrayIcon *vti) gtk_menu_append (priv->ctxt_menu, priv->recommend_item); gtk_menu_append (priv->ctxt_menu, priv->tag_item); gtk_menu_append (priv->ctxt_menu, priv->add_to_pls_item); +#ifdef GNOME + gtk_menu_append (priv->ctxt_menu, priv->save_song_item); +#endif gtk_menu_append (priv->ctxt_menu, gtk_separator_menu_item_new ()); gtk_menu_append (priv->ctxt_menu, priv->love_item); gtk_menu_append (priv->ctxt_menu, priv->ban_item); @@ -342,6 +381,11 @@ ctxt_menu_create (VglTrayIcon *vti) priv->add_to_pls_item_handler_id = g_signal_connect(priv->add_to_pls_item, "activate", G_CALLBACK (ctxt_menu_item_activated), vti); +#ifdef GNOME + priv->save_song_item_handler_id = + g_signal_connect(priv->save_song_item, "activate", + G_CALLBACK (ctxt_menu_item_activated), vti); +#endif priv->love_item_handler_id = g_signal_connect(priv->love_item, "activate", G_CALLBACK (ctxt_menu_item_activated), vti); @@ -375,6 +419,9 @@ ctxt_menu_update (VglTrayIcon *vti) gtk_widget_set_sensitive (priv->recommend_item, TRUE); gtk_widget_set_sensitive (priv->tag_item, TRUE); gtk_widget_set_sensitive (priv->add_to_pls_item, TRUE); +#ifdef GNOME + gtk_widget_set_sensitive (priv->save_song_item, TRUE); +#endif gtk_widget_set_sensitive (priv->love_item, TRUE); gtk_widget_set_sensitive (priv->ban_item, TRUE); gtk_widget_set_sensitive (priv->play_item, FALSE); @@ -387,6 +434,9 @@ ctxt_menu_update (VglTrayIcon *vti) gtk_widget_set_sensitive (priv->recommend_item, FALSE); gtk_widget_set_sensitive (priv->tag_item, FALSE); gtk_widget_set_sensitive (priv->add_to_pls_item, FALSE); +#ifdef GNOME + gtk_widget_set_sensitive (priv->save_song_item, FALSE); +#endif gtk_widget_set_sensitive (priv->love_item, FALSE); gtk_widget_set_sensitive (priv->ban_item, FALSE); gtk_widget_set_sensitive (priv->play_item, TRUE); @@ -399,6 +449,15 @@ ctxt_menu_update (VglTrayIcon *vti) gtk_widget_show (priv->close_vagalume_item); } +#ifdef GNOME +void +tray_icon_toggle(VglTrayIcon *vti, gboolean status, gboolean sensit) +{ + VglTrayIconPrivate *priv = VGL_TRAY_ICON_GET_PRIVATE (vti); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(priv->save_song_item), status); + gtk_widget_set_sensitive (priv->save_song_item, sensit); +} +#endif /* Signals handlers */ @@ -439,6 +498,10 @@ ctxt_menu_item_activated (GtkWidget *ite controller_tag_track(); } else if (item == priv->add_to_pls_item) { controller_add_to_playlist(); +#ifdef GNOME + } else if (item == priv->save_song_item) { + controller_download_track(); +#endif } else if (item == priv->love_item) { controller_love_track (TRUE); } else if (item == priv->ban_item) { diff -up vagalume-hardy/src/vgl-tray-icon.h.fix vagalume-hardy/src/vgl-tray-icon.h --- vagalume-hardy/src/vgl-tray-icon.h.fix 2008-08-16 22:34:41.000000000 +0200 +++ vagalume-hardy/src/vgl-tray-icon.h 2008-09-28 13:01:43.000000000 +0200 @@ -43,7 +43,9 @@ GType vgl_tray_icon_get_type(void) G_GNU VglTrayIcon *vgl_tray_icon_create (void); void vgl_tray_icon_notify_playback (VglTrayIcon *vti, LastfmTrack *track); void vgl_tray_icon_show_notifications (VglTrayIcon *vti, gboolean show_notifications); - +#ifdef GNOME +void tray_icon_toggle (VglTrayIcon *vti, gboolean status, gboolean sensit); +#endif G_END_DECLS #endif /* _VGL_TRAY_ICON_H */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor