static void stations_view_drag_data_received_cb (GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint time, RBIRadioSource *source) { GList *uri_list, *i; rb_debug ("parsing uri list"); uri_list = rb_uri_list_parse ((char *) gtk_selection_data_get_data (selection_data)); if (uri_list == NULL) return; for (i = uri_list; i != NULL; i = i->next) { char *uri = NULL; uri = i->data; if (uri != NULL) { rb_iradio_source_add_station (source, uri, NULL, NULL); } if (info == 1) { /* for _NETSCAPE_URL drags, this item is the link text */ i = i->next; } } rb_list_deep_free (uri_list); return; }
static void impl_finalize (GObject *object) { RBTrackTransferBatch *batch = RB_TRACK_TRANSFER_BATCH (object); rb_list_deep_free (batch->priv->media_types); rb_list_destroy_free (batch->priv->entries, (GDestroyNotify) rhythmdb_entry_unref); rb_list_destroy_free (batch->priv->done_entries, (GDestroyNotify) rhythmdb_entry_unref); rhythmdb_entry_unref (batch->priv->current); G_OBJECT_CLASS (rb_track_transfer_batch_parent_class)->finalize (object); }
static void completed_cb (RBEncoder *encoder, guint64 dest_size, TransferData *data) { RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (data->manager); rb_debug ("completed transferring track to %s (%" G_GUINT64_FORMAT " bytes)", data->dest, dest_size); if (!data->failed) (data->callback) (data->entry, data->dest, dest_size, data->userdata); priv->transfer_running = FALSE; priv->transfer_done++; priv->transfer_fraction = 0.0; do_transfer (data->manager); g_object_unref (G_OBJECT (encoder)); g_free (data->dest); rb_list_deep_free (data->mime_types); g_free (data); }
static gboolean impl_receive_drag (RBDisplayPage *page, GtkSelectionData *data) { GdkAtom type; GList *list; RBStaticPlaylistSource *source = RB_STATIC_PLAYLIST_SOURCE (page); type = gtk_selection_data_get_data_type (data); if (type == gdk_atom_intern ("text/uri-list", TRUE) || type == gdk_atom_intern ("application/x-rhythmbox-entry", TRUE)) { list = rb_uri_list_parse ((char *)gtk_selection_data_get_data (data)); if (list == NULL) return FALSE; if (type == gdk_atom_intern ("text/uri-list", TRUE)) rb_static_playlist_source_add_uri_list (source, list); else rb_static_playlist_source_add_id_list (source, list); rb_list_deep_free (list); } return TRUE; }
static void impl_show_properties (RBMediaPlayerSource *source, GtkWidget *info_box, GtkWidget *notebook) { RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source); GtkBuilder *builder; GtkWidget *widget; GHashTableIter iter; gpointer key, value; int num_podcasts; char *device_name; char *builder_file; RBPlugin *plugin; char *text; GList *output_formats; GList *t; GString *str; g_object_get (source, "plugin", &plugin, NULL); builder_file = rb_plugin_find_file (plugin, "mtp-info.ui"); g_object_unref (plugin); if (builder_file == NULL) { g_warning ("Couldn't find mtp-info.ui"); return; } builder = rb_builder_load (builder_file, NULL); g_free (builder_file); if (builder == NULL) { rb_debug ("Couldn't load mtp-info.ui"); return; } /* 'basic' tab stuff */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "mtp-basic-info")); gtk_box_pack_start (GTK_BOX (info_box), widget, TRUE, TRUE, 0); widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry-mtp-name")); g_object_get (source, "name", &device_name, NULL); gtk_entry_set_text (GTK_ENTRY (widget), device_name); g_free (device_name); g_signal_connect (widget, "focus-out-event", (GCallback)rb_mtp_source_name_changed_cb, source); num_podcasts = 0; g_hash_table_iter_init (&iter, priv->entry_map); while (g_hash_table_iter_next (&iter, &key, &value)) { LIBMTP_track_t *track = value; if (g_strcmp0 (track->genre, "Podcast") == 0) { num_podcasts++; } } widget = GTK_WIDGET (gtk_builder_get_object (builder, "mtp-num-tracks")); text = g_strdup_printf ("%d", g_hash_table_size (priv->entry_map) - num_podcasts); gtk_label_set_text (GTK_LABEL (widget), text); g_free (text); widget = GTK_WIDGET (gtk_builder_get_object (builder, "mtp-num-podcasts")); text = g_strdup_printf ("%d", num_podcasts); gtk_label_set_text (GTK_LABEL (widget), text); g_free (text); widget = GTK_WIDGET (gtk_builder_get_object (builder, "mtp-num-playlists")); text = g_strdup_printf ("%d", 0); /* correct, but wrong */ gtk_label_set_text (GTK_LABEL (widget), text); g_free (text); /* 'advanced' tab stuff */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "mtp-advanced-tab")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, gtk_label_new (_("Advanced"))); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-mtp-model-value")); gtk_label_set_text (GTK_LABEL (widget), priv->model_name); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-serial-number-value")); gtk_label_set_text (GTK_LABEL (widget), priv->serial); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-firmware-version-value")); gtk_label_set_text (GTK_LABEL (widget), priv->device_version); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-manufacturer-value")); gtk_label_set_text (GTK_LABEL (widget), priv->manufacturer); str = g_string_new (""); output_formats = rb_removable_media_source_get_format_descriptions (RB_REMOVABLE_MEDIA_SOURCE (source)); for (t = output_formats; t != NULL; t = t->next) { if (t != output_formats) { g_string_append (str, "\n"); } g_string_append (str, t->data); } rb_list_deep_free (output_formats); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-audio-formats-value")); gtk_label_set_text (GTK_LABEL (widget), str->str); g_string_free (str, TRUE); g_object_unref (builder); }
static void impl_show_properties (RBMediaPlayerSource *source, GtkWidget *info_box, GtkWidget *notebook) { RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (source); RhythmDBQueryModel *model; GtkBuilder *builder; GtkWidget *widget; GString *str; char *device_name; char *builder_file; char *vendor_name; char *model_name; char *serial_id; GObject *plugin; char *text; GList *output_formats; GList *t; g_object_get (source, "plugin", &plugin, NULL); builder_file = rb_find_plugin_data_file (plugin, "generic-player-info.ui"); g_object_unref (plugin); if (builder_file == NULL) { g_warning ("Couldn't find generic-player-info.ui"); return; } builder = rb_builder_load (builder_file, NULL); g_free (builder_file); if (builder == NULL) { rb_debug ("Couldn't load generic-player-info.ui"); return; } /* 'basic' tab stuff */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "generic-player-basic-info")); gtk_box_pack_start (GTK_BOX (info_box), widget, TRUE, TRUE, 0); widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry-device-name")); g_object_get (source, "name", &device_name, NULL); gtk_entry_set_text (GTK_ENTRY (widget), device_name); g_free (device_name); /* don't think we can support this.. g_signal_connect (widget, "focus-out-event", (GCallback)rb_mtp_source_name_changed_cb, source); */ g_object_get (source, "base-query-model", &model, NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "num-tracks")); text = g_strdup_printf ("%d", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL)); gtk_label_set_text (GTK_LABEL (widget), text); g_free (text); g_object_unref (model); widget = GTK_WIDGET (gtk_builder_get_object (builder, "num-playlists")); text = g_strdup_printf ("%d", g_list_length (priv->playlists)); gtk_label_set_text (GTK_LABEL (widget), text); g_free (text); /* 'advanced' tab stuff */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "generic-player-advanced-tab")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, gtk_label_new (_("Advanced"))); g_object_get (priv->device_info, "model", &model_name, "vendor", &vendor_name, "serial", &serial_id, NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-model-value")); gtk_label_set_text (GTK_LABEL (widget), model_name); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-manufacturer-value")); gtk_label_set_text (GTK_LABEL (widget), vendor_name); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-serial-number-value")); gtk_label_set_text (GTK_LABEL (widget), serial_id); g_free (model_name); g_free (vendor_name); g_free (serial_id); str = g_string_new (""); output_formats = rb_transfer_target_get_format_descriptions (RB_TRANSFER_TARGET (source)); for (t = output_formats; t != NULL; t = t->next) { if (t != output_formats) { g_string_append (str, "\n"); } g_string_append (str, t->data); } rb_list_deep_free (output_formats); widget = GTK_WIDGET (gtk_builder_get_object (builder, "audio-format-list")); gtk_label_set_text (GTK_LABEL (widget), str->str); g_string_free (str, TRUE); g_object_unref (builder); }
static void do_notify (RBNotificationPlugin *plugin, guint timeout, const char *primary, const char *secondary, const char *image_uri, gboolean playback) { GError *error = NULL; NotifyNotification *notification; if (notify_is_initted () == FALSE) { GList *caps; if (notify_init ("Rhythmbox") == FALSE) { g_warning ("libnotify initialization failed"); return; } /* ask the notification server if it supports actions */ caps = notify_get_server_caps (); if (g_list_find_custom (caps, "actions", (GCompareFunc)g_strcmp0) != NULL) { rb_debug ("notification server supports actions"); plugin->notify_supports_actions = TRUE; if (g_list_find_custom (caps, "action-icons", (GCompareFunc)g_strcmp0) != NULL) { rb_debug ("notifiction server supports icon buttons"); plugin->notify_supports_icon_buttons = TRUE; } } else { rb_debug ("notification server does not support actions"); } if (g_list_find_custom (caps, "persistence", (GCompareFunc)g_strcmp0) != NULL) { rb_debug ("notification server supports persistence"); plugin->notify_supports_persistence = TRUE; } else { rb_debug ("notification server does not support persistence"); } rb_list_deep_free (caps); } if (primary == NULL) primary = ""; if (secondary == NULL) secondary = ""; if (playback) { notification = plugin->notification; } else { notification = plugin->misc_notification; } if (notification == NULL) { notification = notify_notification_new (primary, secondary, RB_APP_ICON); g_signal_connect_object (notification, "closed", G_CALLBACK (notification_closed_cb), plugin, 0); if (playback) { plugin->notification = notification; } else { plugin->misc_notification = notification; } } else { notify_notification_clear_hints (notification); notify_notification_update (notification, primary, secondary, RB_APP_ICON); } notify_notification_set_timeout (notification, timeout); if (image_uri != NULL) { notify_notification_clear_hints (notification); notify_notification_set_hint (notification, "image_path", g_variant_new_string (image_uri)); } if (playback) notify_notification_set_category (notification, "x-gnome.music"); notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("rhythmbox")); notify_notification_clear_actions (notification); if (playback && plugin->notify_supports_actions) { gboolean rtl; const char *play_icon; rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL); play_icon = rtl ? "media-playback-start-rtl" : "media-playback-start"; if (plugin->notify_supports_icon_buttons) { gboolean playing = FALSE; rb_shell_player_get_playing (plugin->shell_player, &playing, NULL); notify_notification_add_action (notification, rtl ? "media-skip-backward-rtl" : "media-skip-backward", _("Previous"), (NotifyActionCallback) notification_previous_cb, plugin, NULL); notify_notification_add_action (notification, playing ? "media-playback-pause" : play_icon, playing ? _("Pause") : _("Play"), (NotifyActionCallback) notification_playpause_cb, plugin, NULL); notify_notification_set_hint (notification, "action-icons", g_variant_new_boolean (TRUE)); } notify_notification_add_action (notification, rtl ? "media-skip-forward-rtl" : "media-skip-forward", _("Next"), (NotifyActionCallback) notification_next_cb, plugin, NULL); } if (plugin->notify_supports_persistence) { const char *hint; if (playback) { hint = "resident"; } else { hint = "transient"; } notify_notification_set_hint (notification, hint, g_variant_new_boolean (TRUE)); } if (notify_notification_show (notification, &error) == FALSE) { g_warning ("Failed to send notification (%s): %s", primary, error->message); g_error_free (error); } }