static gboolean rb_disc_recorder_plugin_start_burning (RBDiscRecorderPlugin *pi, const char *path, gboolean copy) { GtkWidget *main_window; GdkScreen *screen; GdkWindow *window; GPtrArray *array; char **args, *xid_str; GError *error = NULL; gboolean ret; array = g_ptr_array_new (); g_ptr_array_add (array, "brasero"); if (copy != FALSE) g_ptr_array_add (array, "-c"); else g_ptr_array_add (array, "-r"); g_ptr_array_add (array, (gpointer) path); main_window = gtk_widget_get_toplevel (GTK_WIDGET (pi->selected_source)); screen = gtk_widget_get_screen (main_window); window = gtk_widget_get_window (main_window); if (window) { int xid; xid = gdk_x11_drawable_get_xid (GDK_DRAWABLE (window)); xid_str = g_strdup_printf ("%d", xid); g_ptr_array_add (array, "-x"); g_ptr_array_add (array, xid_str); } else { xid_str = NULL; } g_ptr_array_add (array, NULL); args = (char **) g_ptr_array_free (array, FALSE); ret = TRUE; if (!gdk_spawn_on_screen (screen, NULL, args, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_FILE_AND_ARGV_ZERO, NULL, NULL, NULL, &error)) { if (copy != FALSE) { rb_error_dialog (GTK_WINDOW (main_window), _("Rhythmbox could not duplicate the disc"), "%s", error->message); } else { rb_error_dialog (GTK_WINDOW (main_window), _("Rhythmbox could not record the audio disc"), "%s", error->message); } ret = FALSE; g_error_free (error); } g_free (xid_str); g_free (args); return ret; }
static gboolean rb_audiocd_scan_songs (RBAudioCdSource *source, RhythmDB *db) { gint64 i, num_tracks; RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source); GstStateChangeReturn ret; gboolean ok = TRUE; ret = gst_element_set_state (priv->pipeline, GST_STATE_PAUSED); if (ret == GST_STATE_CHANGE_ASYNC) { ret = gst_element_get_state (priv->pipeline, NULL, NULL, 3 * GST_SECOND); } if (ret == GST_STATE_CHANGE_FAILURE) { gdk_threads_enter (); rb_error_dialog (NULL, _("Couldn't load Audio CD"), _("Rhythmbox couldn't access the CD.")); gdk_threads_leave (); ok = FALSE; } if (ok && !rb_audiocd_get_cd_info (source, &num_tracks)) { gdk_threads_enter (); rb_error_dialog (NULL, _("Couldn't load Audio CD"), _("Rhythmbox couldn't read the CD information.")); gdk_threads_leave (); ok = FALSE; } if (ok) { rb_debug ("importing Audio Cd %s - %d tracks", priv->device_path, (int)num_tracks); for (i = 1; i <= num_tracks; i++) { RhythmDBEntry* entry = rb_audiocd_create_track_entry (source, db, i); if (entry) priv->tracks = g_list_prepend (priv->tracks, entry); else g_warning ("Could not create audio cd track entry"); } priv->tracks = g_list_reverse (priv->tracks); } if (gst_element_set_state (priv->pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE) { rb_debug ("failed to set cd state"); } return ok; }
static void rb_removable_media_manager_eject_cb (GObject *object, GAsyncResult *result, RBRemovableMediaManager *mgr) { GError *error = NULL; if (G_IS_VOLUME (object)) { GVolume *volume = G_VOLUME (object); rb_debug ("finishing ejection of volume"); g_volume_eject_finish (volume, result, &error); if (error == NULL) { rb_removable_media_manager_remove_volume (mgr, volume); } } else if (G_IS_MOUNT (object)) { GMount *mount = G_MOUNT (object); rb_debug ("finishing ejection of mount"); g_mount_eject_finish (mount, result, &error); if (error == NULL) { rb_removable_media_manager_remove_mount (mgr, mount); } } if (error != NULL) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) { rb_error_dialog (NULL, _("Unable to eject"), "%s", error->message); } else { rb_debug ("eject failure has already been handled"); } g_error_free (error); } g_object_unref (mgr); }
gboolean rb_plugins_engine_activate_plugin (RBPluginInfo *info) { gboolean ret; g_return_val_if_fail (info != NULL, FALSE); if (info->active) return TRUE; ret = rb_plugins_engine_activate_plugin_real (info, rb_plugins_shell); if (info->visible != FALSE || ret != FALSE) { char *key_name; key_name = g_strdup_printf (CONF_PLUGIN_ACTIVE_KEY, info->location); eel_gconf_set_boolean (key_name, ret); g_free (key_name); } info->active = ret; if (ret != FALSE) return TRUE; rb_error_dialog (NULL, _("Plugin Error"), _("Unable to activate plugin %s"), info->name); return FALSE; }
/** * rb_transfer_target_track_add_error: * @target: an #RBTransferTarget * @entry: the source #RhythmDBEntry for the transfer * @uri: the destination URI * @error: the transfer error information * * This is called when a transfer fails. If the source's * impl_track_add_error implementation returns %TRUE, an error dialog * will be displayed to the user containing the error message, unless * the error indicates that the destination file already exists. */ void rb_transfer_target_track_add_error (RBTransferTarget *target, RhythmDBEntry *entry, const char *uri, GError *error) { RBTransferTargetInterface *iface = RB_TRANSFER_TARGET_GET_IFACE (target); gboolean show_dialog = TRUE; /* hrm, want the subclass to decide whether to display the error and * whether to cancel the batch (may have some device-specific errors?) * * for now we'll just cancel on the most common things.. */ if (iface->track_add_error) show_dialog = iface->track_add_error (target, entry, uri, error); if (show_dialog) { if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) { rb_debug ("not displaying 'file exists' error for %s", uri); } else { rb_error_dialog (NULL, _("Error transferring track"), "%s", error->message); } } }
static void eject_cb (GObject *object, GAsyncResult *result, gpointer nothing) { GError *error = NULL; if (G_IS_VOLUME (object)) { GVolume *volume = G_VOLUME (object); rb_debug ("finishing ejection of volume"); g_volume_eject_with_operation_finish (volume, result, &error); } else if (G_IS_MOUNT (object)) { GMount *mount = G_MOUNT (object); rb_debug ("finishing ejection of mount"); g_mount_eject_with_operation_finish (mount, result, &error); } if (error != NULL) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) { rb_error_dialog (NULL, _("Unable to eject"), "%s", error->message); } else { rb_debug ("eject failure has already been handled"); } g_error_free (error); } }
/** * rb_playlist_source_save_playlist: * @source: a #RBPlaylistSource * @uri: destination URI * @export_type: format to save in * * Saves the playlist to an external file in a standard * format (M3U, PLS, or XSPF). */ void rb_playlist_source_save_playlist (RBPlaylistSource *source, const char *uri, RBPlaylistExportType export_type) { TotemPlParser *pl; GError *error = NULL; char *name; gint totem_format; #if TOTEM_PL_PARSER_CHECK_VERSION(2,29,1) TotemPlPlaylist *playlist; GFile *file; #endif g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source)); rb_debug ("saving playlist"); pl = totem_pl_parser_new (); g_object_get (source, "name", &name, NULL); switch (export_type) { case RB_PLAYLIST_EXPORT_TYPE_XSPF: totem_format = TOTEM_PL_PARSER_XSPF; break; case RB_PLAYLIST_EXPORT_TYPE_M3U: totem_format = TOTEM_PL_PARSER_M3U; break; case RB_PLAYLIST_EXPORT_TYPE_PLS: default: totem_format = TOTEM_PL_PARSER_PLS; break; } #if TOTEM_PL_PARSER_CHECK_VERSION(2,29,1) file = g_file_new_for_uri (uri); playlist = totem_pl_playlist_new (); gtk_tree_model_foreach (GTK_TREE_MODEL (source->priv->model), (GtkTreeModelForeachFunc)playlist_iter_foreach, playlist); totem_pl_parser_save (pl, playlist, file, name, totem_format, &error); g_object_unref (playlist); g_object_unref (file); #else totem_pl_parser_write_with_title (pl, GTK_TREE_MODEL (source->priv->model), playlist_iter_func, uri, name, totem_format, NULL, &error); #endif g_object_unref (pl); g_free (name); if (error != NULL) { rb_error_dialog (NULL, _("Couldn't save playlist"), "%s", error->message); g_error_free (error); } }
static void source_burn (RBCdRecorderPlugin *pi, RBSource *source) { GtkWidget *recorder; GtkWidget *parent; char *name; RBShell *shell; gboolean res; GError *error; GtkTreeModel *model; g_object_get (G_OBJECT (source), "query-model", &model, NULL); /* don't burn if the source is empty */ if (gtk_tree_model_iter_n_children (model, NULL) == 0) { g_object_unref (model); return; } rb_debug ("burning source"); g_object_get (source, "name", &name, "shell", &shell, NULL); parent = gtk_widget_get_toplevel (GTK_WIDGET (source)); recorder = rb_playlist_source_recorder_new (parent, shell, RB_PLUGIN (pi), name); g_object_unref (shell); g_free (name); error = NULL; res = rb_playlist_source_recorder_add_from_model (RB_PLAYLIST_SOURCE_RECORDER (recorder), model, burn_source_iter_func, &error); g_object_unref (model); if (! res) { rb_error_dialog (GTK_WINDOW (parent), _("Unable to create audio CD"), "%s", error->message); g_error_free (error); gtk_widget_destroy (recorder); return; } g_signal_connect (recorder, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (recorder); }
static void error_cb (RBEncoder *encoder, GError *error, TransferData *data) { /* ignore 'file exists' */ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) { rb_debug ("ignoring 'file exists' error for %s", data->dest); data->failed = TRUE; return; } rb_debug ("Error transferring track to %s: %s", data->dest, error->message); rb_error_dialog (NULL, _("Error transferring track"), "%s", error->message); data->failed = TRUE; rb_encoder_cancel (encoder); }
static gpointer rb_audiocd_load_songs (RBAudioCdSource *source) { RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source); RhythmDB *db; GVolume *volume; g_object_get (source, "volume", &volume, NULL); priv->device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); g_object_unref (volume); db = get_db_for_source (source); rb_debug ("loading Audio CD from %s", priv->device_path); /* create a cdda gstreamer element, to get cd info from */ priv->cdda = gst_element_make_from_uri (GST_URI_SRC, "cdda://", NULL); if (!priv->cdda) { gdk_threads_enter (); rb_error_dialog (NULL, _("Couldn't load Audio CD"), _("Rhythmbox could not get access to the CD device.")); gdk_threads_leave (); goto error_out; } rb_debug ("cdda longname: %s", gst_element_factory_get_longname (gst_element_get_factory (priv->cdda))); g_object_set (G_OBJECT (priv->cdda), "device", priv->device_path, NULL); priv->pipeline = gst_pipeline_new ("pipeline"); priv->fakesink = gst_element_factory_make ("fakesink", "fakesink"); gst_bin_add_many (GST_BIN (priv->pipeline), priv->cdda, priv->fakesink, NULL); gst_element_link (priv->cdda, priv->fakesink); /* disable paranoia (if using cdparanoia) since we're only reading track information here. * this reduces cdparanoia's cache size, so the process is much faster. */ if (g_object_class_find_property (G_OBJECT_GET_CLASS (source), "paranoia-mode")) g_object_set (source, "paranoia-mode", 0, NULL); if (rb_audiocd_scan_songs (source, db)) rb_audiocd_load_metadata (source, db); error_out: g_object_unref (db); g_object_unref (source); return NULL; }
static void unmount_cb (GObject *object, GAsyncResult *result, gpointer nothing) { GMount *mount = G_MOUNT (object); GError *error = NULL; rb_debug ("finishing unmount of mount"); g_mount_unmount_with_operation_finish (mount, result, &error); if (error != NULL) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) { rb_error_dialog (NULL, _("Unable to unmount"), "%s", error->message); } else { rb_debug ("unmount failure has already been handled"); } g_error_free (error); } }
static void report_libmtp_errors (LIBMTP_mtpdevice_t *device, gboolean use_dialog) { LIBMTP_error_t *stack; for (stack = LIBMTP_Get_Errorstack (device); stack != NULL; stack = stack->next) { if (use_dialog) { rb_error_dialog (NULL, _("Media player device error"), "%s", stack->error_text); /* only display one dialog box per error */ use_dialog = FALSE; } else { g_warning ("libmtp error: %s", stack->error_text); } } LIBMTP_Clear_Errorstack (device); }
static gboolean device_open_failed_idle (RBMtpSource *source) { /* libmtp doesn't give us a useful error message in this case, so * all we can offer is this generic message. */ RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source); rb_error_dialog (NULL, _("Media player device error"), /* Translators: first %s is the device manufacturer, * second is the product name. */ _("Unable to open the %s %s device"), priv->raw_device.device_entry.vendor, priv->raw_device.device_entry.product); rb_source_delete_thyself (RB_SOURCE (source)); g_object_unref (source); return FALSE; }
void rb_mtp_thread_report_errors (RBMtpThread *thread, gboolean use_dialog) { LIBMTP_error_t *stack; for (stack = LIBMTP_Get_Errorstack (thread->device); stack != NULL; stack = stack->next) { if (use_dialog) { GDK_THREADS_ENTER (); rb_error_dialog (NULL, _("Media player device error"), "%s", stack->error_text); GDK_THREADS_LEAVE (); /* only display one dialog box per error */ use_dialog = FALSE; } else { g_warning ("libmtp error: %s", stack->error_text); } } LIBMTP_Clear_Errorstack (thread->device); }
static void source_burn (RBDiscRecorderPlugin *pi, RBSource *source) { GtkWidget *parent; char *name; char *path; GError *error = NULL; GtkTreeModel *model; g_object_get (source, "query-model", &model, NULL); /* don't burn if the source is empty */ if (gtk_tree_model_iter_n_children (model, NULL) == 0) { g_object_unref (model); return; } name = NULL; g_object_get (source, "name", &name, NULL); rb_debug ("Burning playlist %s", name); parent = gtk_widget_get_toplevel (GTK_WIDGET (source)); rb_debug ("Creating audio project"); path = rb_disc_recorder_plugin_write_audio_project (name, model, &error); g_free (name); if (! path) { rb_error_dialog (GTK_WINDOW (parent), _("Unable to create audio CD project"), "%s", error->message); g_error_free (error); return; } rb_debug ("Starting brasero"); rb_disc_recorder_plugin_start_burning (pi, path, FALSE); g_free (path); }
static void rb_removable_media_manager_unmount_cb (GObject *object, GAsyncResult *result, RBRemovableMediaManager *mgr) { GMount *mount = G_MOUNT (object); GError *error = NULL; rb_debug ("finishing unmount of mount"); g_mount_unmount_finish (mount, result, &error); if (error != NULL) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) { rb_error_dialog (NULL, _("Unable to unmount"), "%s", error->message); } else { rb_debug ("unmount failure has already been handled"); } g_error_free (error); } else { rb_removable_media_manager_remove_mount (mgr, mount); } g_object_unref (mgr); }
gboolean rb_ipod_helpers_show_first_time_dialog (GMount *mount, const char *builder_file) { /* could be an uninitialised iPod, ask the user */ GtkBuilder *builder; GtkWidget *dialog; GtkWidget *widget; GtkTreeModel *tree_model; GtkTreeIter iter; int response; char *mountpoint; const Itdb_IpodInfo *info; char *ipod_name; GFile *root; GError *error = NULL; root = g_mount_get_root (mount); if (root == NULL) { return FALSE; } mountpoint = g_file_get_path (root); g_object_unref (G_OBJECT (root)); if (mountpoint == NULL) { return FALSE; } /* create message dialog with model-number combo box * and asking whether they want to initialise the iPod */ builder = rb_builder_load (builder_file, NULL); if (builder == NULL) { return FALSE; } dialog = GTK_WIDGET (gtk_builder_get_object (builder, "ipod_init")); widget = GTK_WIDGET (gtk_builder_get_object (builder, "model_combo")); fill_model_combo (widget, mountpoint); g_object_unref (builder); rb_debug ("showing init dialog for ipod mount on '%s'", mountpoint); response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response != GTK_RESPONSE_ACCEPT) { gtk_widget_destroy (dialog); g_free (mountpoint); return FALSE; } /* get model number and name */ tree_model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) { gtk_widget_destroy (dialog); g_free (mountpoint); return FALSE; } gtk_tree_model_get (tree_model, &iter, COL_INFO, &info, -1); widget = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry")); ipod_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget))); gtk_widget_destroy (dialog); rb_debug ("attempting to init ipod on '%s', with model '%s' and name '%s'", mountpoint, info->model_number, ipod_name); if (!itdb_init_ipod (mountpoint, info->model_number, ipod_name, &error)) { rb_error_dialog (NULL, _("Unable to initialize new iPod"), "%s", error->message); g_free (mountpoint); g_free (ipod_name); g_error_free (error); return FALSE; } g_free (mountpoint); g_free (ipod_name); return TRUE; }
static void impl_activate (RBPlugin *plugin, RBShell *shell) { // rb_error_dialog (NULL, _("Spotify Plugin"), "Spotify plugin activated, with shell %p", shell); RBSpotifySource *source; RhythmDBEntryType type; RhythmDB *db; char *entry_type_name, *username, *password; int err; RBSpotifyPluginPrivate *pprivate = RB_SPOTIFY_PLUGIN_GET_PRIVATE(plugin); pthread_mutex_init(&g_notify_mutex, NULL); pthread_cond_init(&g_notify_cond, NULL); audio_fifo_init(&g_audio_fifo); spconfig.application_key_size = g_appkey_size; err = sp_session_init(&spconfig, &pprivate->sess); if (err != SP_ERROR_OK) { rb_error_dialog (NULL, _("Spotify Plugin"), "Error initialising spotify session"); pprivate->sess = NULL; return; } fprintf(stderr, "err: %x", err); err = pthread_create(&pprivate->notify_thread, 0, notification_routine, pprivate->sess); fprintf(stderr, "Thread created"); if (err != 0) { fprintf(stderr, "Error creating notification thread %x\n", err); return; } username = eel_gconf_get_string (CONF_SPOTIFY_USERNAME); password = eel_gconf_get_string (CONF_SPOTIFY_PASSWORD); if (username == NULL || password == NULL) { rb_error_dialog (NULL, _("Spotify Plugin"), "Username and password not set."); return; } err = sp_session_login(pprivate->sess, username, password); fprintf(stderr, "err: %x", err); rbspotifysrc_set_plugin(plugin); g_object_get (shell, "db", &db, NULL); entry_type_name = g_strdup_printf ("spotify"); type = rhythmdb_entry_register_type (db, entry_type_name); g_free (entry_type_name); type->save_to_disk = FALSE; type->category = RHYTHMDB_ENTRY_NORMAL; // type->get_playback_uri = (RhythmDBEntryStringFunc) rb_daap_source_get_playback_uri; g_object_unref (db); // icon = rb_daap_plugin_get_icon (RB_DAAP_PLUGIN (plugin), password_protected, FALSE); source = (RBSpotifySource*)RB_SOURCE (g_object_new (RBSPOTIFYSOURCE_TYPE, "name", "spotify", "entry-type", type, "shell", shell, "visibility", TRUE, // "sorting-key", CONF_STATE_SORTING, "source-group", RB_SOURCE_GROUP_SHARED, "plugin", RB_PLUGIN (plugin), NULL)); source->priv->sess = pprivate->sess; source->priv->db = db; source->priv->type = type; rb_shell_register_entry_type_for_source (shell, (RBSource*)source, type); rb_shell_append_source (shell, (RBSource*)source, NULL); // return source; }