static GtkWidget * impl_create_configure_widget (PeasGtkConfigurable *bplugin) { RBAudioscrobblerPlugin *plugin; char *builderfile; GtkBuilder *builder; GtkWidget *widget; plugin = RB_AUDIOSCROBBLER_PLUGIN (bplugin); builderfile = rb_find_plugin_data_file (G_OBJECT (plugin), "audioscrobbler-preferences.ui"); if (builderfile == NULL) { g_warning ("can't find audioscrobbler-preferences.ui"); return NULL; } builder = rb_builder_load (builderfile, plugin); g_free (builderfile); widget = GTK_WIDGET (gtk_builder_get_object (builder, "config")); g_object_ref_sink (widget); plugin->lastfm_enabled_check = GTK_WIDGET (gtk_builder_get_object (builder, "lastfm_enabled_check")); g_settings_bind (plugin->lastfm_settings, AUDIOSCROBBLER_SERVICE_ENABLED_KEY, plugin->lastfm_enabled_check, "active", G_SETTINGS_BIND_DEFAULT); plugin->librefm_enabled_check = GTK_WIDGET (gtk_builder_get_object (builder, "librefm_enabled_check")); g_settings_bind (plugin->librefm_settings, AUDIOSCROBBLER_SERVICE_ENABLED_KEY, plugin->librefm_enabled_check, "active", G_SETTINGS_BIND_DEFAULT); g_object_unref (builder); return widget; }
void rb_visualizer_fullscreen_load_style (GObject *plugin) { char *file; if (style == NULL) { style = mx_style_new (); file = rb_find_plugin_data_file (plugin, "visualizer.css"); if (file != NULL) { mx_style_load_from_file (style, file, NULL); g_free (file); } } }
static void impl_activate (PeasActivatable *bplugin) { RBIpodPlugin *plugin = RB_IPOD_PLUGIN (bplugin); RBRemovableMediaManager *rmm = NULL; GtkUIManager *uimanager = NULL; RBShell *shell; gboolean scanned; char *file; g_object_get (plugin, "object", &shell, NULL); g_object_get (G_OBJECT (shell), "removable-media-manager", &rmm, "ui-manager", &uimanager, NULL); rb_media_player_source_init_actions (shell); /* add ipod UI */ plugin->action_group = gtk_action_group_new ("iPodActions"); gtk_action_group_set_translation_domain (plugin->action_group, GETTEXT_PACKAGE); _rb_action_group_add_display_page_actions (plugin->action_group, G_OBJECT (shell), rb_ipod_plugin_actions, G_N_ELEMENTS (rb_ipod_plugin_actions)); gtk_ui_manager_insert_action_group (uimanager, plugin->action_group, 0); file = rb_find_plugin_data_file (G_OBJECT (bplugin), "ipod-ui.xml"); plugin->ui_merge_id = gtk_ui_manager_add_ui_from_file (uimanager, file, NULL); g_free (file); /* watch for new removable media, and cause a rescan */ g_signal_connect (G_OBJECT (rmm), "create-source-mount", G_CALLBACK (create_source_cb), plugin); /* only scan if we're being loaded after the initial scan has been done */ g_object_get (G_OBJECT (rmm), "scanned", &scanned, NULL); if (scanned) rb_removable_media_manager_scan (rmm); g_object_unref (rmm); g_object_unref (uimanager); g_object_unref (shell); }
static void impl_activate (PeasActivatable *bplugin) { int fd; char *path; RBLircPlugin *plugin = RB_LIRC_PLUGIN (bplugin); RBShell *shell; g_object_get (plugin, "object", &shell, NULL); g_object_get (shell, "shell-player", &plugin->shell_player, NULL); rb_debug ("Activating lirc plugin"); fd = lirc_init ("Rhythmbox", 1); if (fd < 0) { rb_debug ("Couldn't initialize lirc"); g_object_unref (shell); return; } /* Load the default Rhythmbox setup */ path = rb_find_plugin_data_file (G_OBJECT (plugin), "rhythmbox_lirc_default"); if (path == NULL || lirc_readconfig (path, &plugin->lirc_config, NULL) == -1) { g_free (path); close (fd); rb_debug ("Couldn't read lirc configuration"); g_object_unref (shell); return; } g_free (path); lirc_readconfig (NULL, &plugin->lirc_config, NULL); plugin->lirc_channel = g_io_channel_unix_new (fd); g_io_channel_set_encoding (plugin->lirc_channel, NULL, NULL); g_io_channel_set_buffered (plugin->lirc_channel, FALSE); g_io_add_watch (plugin->lirc_channel, G_IO_IN | G_IO_ERR | G_IO_HUP, (GIOFunc) rb_lirc_plugin_read_code, plugin); g_object_unref (shell); }
static void impl_show_properties (RBMediaPlayerSource *source, GtkWidget *info_box, GtkWidget *notebook) { RhythmDBQueryModel *model; GtkBuilder *builder; GtkWidget *widget; GObject *plugin; char *builder_file; char *text; g_object_get (source, "plugin", &plugin, NULL); builder_file = rb_find_plugin_data_file (plugin, "android-info.ui"); g_object_unref (plugin); if (builder_file == NULL) { g_warning ("Couldn't find android-info.ui"); return; } builder = rb_builder_load (builder_file, NULL); g_free (builder_file); if (builder == NULL) { rb_debug ("Couldn't load android-info.ui"); return; } /* 'basic' tab stuff */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "android-basic-info")); gtk_box_pack_start (GTK_BOX (info_box), widget, TRUE, TRUE, 0); 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); g_object_unref (builder); }
static RBSource * create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, MPIDDevice *device_info, RBIpodPlugin *plugin) { RBSource *src; RBShell *shell; if (!rb_ipod_helpers_is_ipod (mount, device_info)) { return NULL; } if (rb_ipod_helpers_needs_init (mount)) { gboolean inited; gchar *builder_file; builder_file = rb_find_plugin_data_file (G_OBJECT (plugin), "ipod-init.ui"); inited = rb_ipod_helpers_show_first_time_dialog (mount, builder_file); g_free (builder_file); if (!inited) { return NULL; } } g_object_get (plugin, "object", &shell, NULL); src = RB_SOURCE (rb_ipod_source_new (G_OBJECT (plugin), shell, mount, device_info)); g_object_unref (shell); plugin->ipod_sources = g_list_prepend (plugin->ipod_sources, src); g_signal_connect_object (G_OBJECT (src), "deleted", G_CALLBACK (rb_ipod_plugin_source_deleted), plugin, 0); return src; }
static void impl_activate (PeasActivatable *bplugin) { RBMtpPlugin *plugin = RB_MTP_PLUGIN (bplugin); GtkUIManager *uimanager = NULL; RBRemovableMediaManager *rmm; char *file = NULL; RBShell *shell; #if defined(HAVE_GUDEV) gboolean rmm_scanned = FALSE; #else int num_mtp_devices; LIBMTP_raw_device_t *mtp_devices; #endif g_object_get (plugin, "object", &shell, NULL); g_object_get (shell, "ui-manager", &uimanager, "removable-media-manager", &rmm, NULL); /* ui */ rb_media_player_source_init_actions (shell); plugin->action_group = gtk_action_group_new ("MTPActions"); gtk_action_group_set_translation_domain (plugin->action_group, GETTEXT_PACKAGE); _rb_action_group_add_display_page_actions (plugin->action_group, G_OBJECT (shell), rb_mtp_plugin_actions, G_N_ELEMENTS (rb_mtp_plugin_actions)); gtk_ui_manager_insert_action_group (uimanager, plugin->action_group, 0); file = rb_find_plugin_data_file (G_OBJECT (bplugin), "mtp-ui.xml"); plugin->ui_merge_id = gtk_ui_manager_add_ui_from_file (uimanager, file, NULL); g_object_unref (uimanager); g_object_unref (shell); /* device detection */ #if defined(HAVE_GUDEV) plugin->create_device_source_id = g_signal_connect_object (rmm, "create-source-device", G_CALLBACK (create_source_device_cb), plugin, 0); /* only scan if we're being loaded after the initial scan has been done */ g_object_get (rmm, "scanned", &rmm_scanned, NULL); if (rmm_scanned) rb_removable_media_manager_scan (rmm); #else if (rb_mtp_plugin_setup_dbus_hal_connection (plugin) == FALSE) { rb_debug ("not scanning for MTP devices because we couldn't get a HAL context"); g_object_unref (rmm); return; } rb_profile_start ("scanning for MTP devices"); LIBMTP_Detect_Raw_Devices (&mtp_devices, &num_mtp_devices); if (num_mtp_devices > 0) { int num_hal_devices; char **hal_devices; int i; rb_debug ("%d MTP devices found", num_mtp_devices); hal_devices = libhal_get_all_devices (plugin->hal_context, &num_hal_devices, NULL); for (i = 0; i < num_hal_devices; i++) { /* should narrow this down a bit - usb only, for a start */ rb_mtp_plugin_maybe_add_source (plugin, hal_devices[i], mtp_devices, num_mtp_devices); } libhal_free_string_array (hal_devices); } if (mtp_devices != NULL) { free (mtp_devices); } rb_profile_end ("scanning for MTP devices"); #endif g_object_unref (rmm); }
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; GObject *plugin; char *text; GList *output_formats; GList *t; GString *str; g_object_get (source, "plugin", &plugin, NULL); builder_file = rb_find_plugin_data_file (G_OBJECT (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_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, "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 rb_iradio_source_constructed (GObject *object) { RBIRadioSource *source; RBShell *shell; GtkAction *action; GSettings *settings; GtkUIManager *ui_manager; GtkWidget *grid; GtkWidget *paned; RBSourceToolbar *toolbar; gint size; GdkPixbuf *pixbuf; RB_CHAIN_GOBJECT_METHOD (rb_iradio_source_parent_class, constructed, object); source = RB_IRADIO_SOURCE (object); paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); g_object_get (source, "shell", &shell, NULL); g_object_get (shell, "db", &source->priv->db, "shell-player", &source->priv->player, "ui-manager", &ui_manager, NULL); g_object_unref (shell); gtk_icon_size_lookup (RB_SOURCE_ICON_SIZE, &size, NULL); pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), IRADIO_SOURCE_ICON, size, 0, NULL); g_object_set (source, "pixbuf", pixbuf, NULL); if (pixbuf != NULL) { g_object_unref (pixbuf); } settings = g_settings_new ("org.gnome.rhythmbox.plugins.iradio"); if (g_settings_get_boolean (settings, "initial-stations-loaded") == FALSE) { GObject *plugin; char *file; g_object_get (source, "plugin", &plugin, NULL); file = rb_find_plugin_data_file (plugin, "iradio-initial.xspf"); if (file != NULL) { char *uri = g_filename_to_uri (file, NULL, NULL); if (uri != NULL) { rb_iradio_source_add_from_playlist (source, uri); g_free (uri); g_settings_set_boolean (settings, "initial-stations-loaded", TRUE); } } g_free (file); g_object_unref (plugin); } source->priv->action_group = _rb_display_page_register_action_group (RB_DISPLAY_PAGE (source), "IRadioActions", rb_iradio_source_actions, G_N_ELEMENTS (rb_iradio_source_actions), source); action = gtk_action_group_get_action (source->priv->action_group, "MusicNewInternetRadioStation"); /* Translators: this is the toolbar button label for New Internet Radio Station action. */ g_object_set (action, "short-label", C_("Radio", "Add"), NULL); /* set up stations view */ source->priv->stations = rb_entry_view_new (source->priv->db, G_OBJECT (source->priv->player), FALSE, FALSE); rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_TITLE, TRUE); rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_GENRE, FALSE); /* rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_QUALITY, FALSE); */ rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_RATING, FALSE); /* rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_PLAY_COUNT, FALSE);*/ rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_LAST_PLAYED, FALSE); g_signal_connect_object (source->priv->stations, "notify::sort-order", G_CALLBACK (rb_iradio_source_songs_view_sort_order_changed_cb), source, 0); /* set up drag and drop for the song tree view. * we don't use RBEntryView's DnD support because it does too much. * we just want to be able to drop stations in to add them. */ g_signal_connect_object (source->priv->stations, "drag_data_received", G_CALLBACK (stations_view_drag_data_received_cb), source, 0); gtk_drag_dest_set (GTK_WIDGET (source->priv->stations), GTK_DEST_DEFAULT_ALL, stations_view_drag_types, 2, GDK_ACTION_COPY | GDK_ACTION_MOVE); g_signal_connect_object (source->priv->stations, "show_popup", G_CALLBACK (rb_iradio_source_songs_show_popup_cb), source, 0); /* set up genre entry view */ source->priv->genres = rb_property_view_new (source->priv->db, RHYTHMDB_PROP_GENRE, _("Genre")); gtk_widget_show_all (GTK_WIDGET (source->priv->genres)); gtk_widget_set_no_show_all (GTK_WIDGET (source->priv->genres), TRUE); g_signal_connect_object (source->priv->genres, "property-selected", G_CALLBACK (genre_selected_cb), source, 0); g_signal_connect_object (source->priv->genres, "property-selection-reset", G_CALLBACK (genre_selection_reset_cb), source, 0); g_object_set (source->priv->genres, "vscrollbar_policy", GTK_POLICY_AUTOMATIC, NULL); gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (source->priv->genres), FALSE, FALSE); gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET (source->priv->stations), TRUE, FALSE); /* set up toolbar */ toolbar = rb_source_toolbar_new (RB_SOURCE (source), ui_manager); rb_source_toolbar_add_search_entry (toolbar, NULL, _("Search your internet radio stations")); grid = gtk_grid_new (); gtk_grid_set_column_spacing (GTK_GRID (grid), 6); gtk_grid_set_row_spacing (GTK_GRID (grid), 6); gtk_widget_set_margin_top (GTK_WIDGET (grid), 6); gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (toolbar), 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), paned, 0, 1, 1, 1); gtk_container_add (GTK_CONTAINER (source), grid); rb_source_bind_settings (RB_SOURCE (source), GTK_WIDGET (source->priv->stations), paned, GTK_WIDGET (source->priv->genres)); gtk_widget_show_all (GTK_WIDGET (source)); g_signal_connect_object (source->priv->player, "playing-source-changed", G_CALLBACK (playing_source_changed_cb), source, 0); source->priv->default_search = rb_iradio_source_search_new (); rb_iradio_source_do_query (source); }