/**
   knicked from audio scrobbler
*/
static GtkWidget*
impl_create_configure_dialog (RBPlugin *plugin)
{
    RBSpotifyPluginPrivate *pprivate = RB_SPOTIFY_PLUGIN_GET_PRIVATE(plugin);

    if (pprivate->preferences == NULL) {
        char* t;

        if (pprivate->config_widget == NULL) {
            GladeXML *xml;
            char *gladefile;

            gladefile = rb_plugin_find_file (plugin, "spotify-prefs.glade");
            g_assert (gladefile != NULL);
            xml = rb_glade_xml_new (gladefile, "spotify_vbox", plugin);
            g_free (gladefile);

            pprivate->config_widget = glade_xml_get_widget (xml, "spotify_vbox");
            pprivate->username_entry = glade_xml_get_widget (xml, "username_entry");
            pprivate->username_label = glade_xml_get_widget (xml, "username_label");
            pprivate->password_entry = glade_xml_get_widget (xml, "password_entry");
            pprivate->password_label = glade_xml_get_widget (xml, "password_label");

            g_object_unref (G_OBJECT (xml));

        }

        t = eel_gconf_get_string (CONF_SPOTIFY_USERNAME);
        gtk_entry_set_text (GTK_ENTRY (pprivate->username_entry),
                            t ? t : "");
        t = eel_gconf_get_string (CONF_SPOTIFY_USERNAME);
        gtk_entry_set_text (GTK_ENTRY (pprivate->password_entry),
                            t ? t : "");

        pprivate->preferences = gtk_dialog_new_with_buttons (_("Spotify Preferences"),
                                NULL,
                                GTK_DIALOG_DESTROY_WITH_PARENT,
                                GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                NULL);
        gtk_dialog_set_has_separator (GTK_DIALOG (pprivate->preferences), FALSE);
        gtk_container_set_border_width (GTK_CONTAINER (pprivate->preferences), 5);
        gtk_window_set_resizable (GTK_WINDOW (pprivate->preferences), FALSE);

        g_signal_connect (G_OBJECT (pprivate->preferences),
                          "response",
                          G_CALLBACK (preferences_response_cb),
                          plugin);
        gtk_widget_hide_on_delete (pprivate->preferences);

        gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pprivate->preferences)->vbox), pprivate->config_widget);
    }

    gtk_widget_show_all (pprivate->preferences);
    return pprivate->preferences;
}
示例#2
0
static void
create_share (RBShell *shell)
{
	RhythmDB *rdb;
	DMAPDb *db;
	DMAPContainerDb *container_db;
	RBPlaylistManager *playlist_manager;
	char *name;
	char *password;
	gboolean require_password;

	g_assert (share == NULL);
	rb_debug ("initialize daap sharing");

	name = eel_gconf_get_string (CONF_DAAP_SHARE_NAME);
	if (name == NULL || *name == '\0') {
		g_free (name);
		name = rb_daap_sharing_default_share_name ();
	}

	g_object_get (shell,
		      "db", &rdb,
		      "playlist-manager", &playlist_manager, NULL);
	db = DMAP_DB (rb_rhythmdb_dmap_db_adapter_new (rdb, RHYTHMDB_ENTRY_TYPE_SONG));
	container_db = DMAP_CONTAINER_DB (rb_dmap_container_db_adapter_new (playlist_manager));

	require_password = eel_gconf_get_boolean (CONF_DAAP_REQUIRE_PASSWORD);
	if (require_password) {
		password = eel_gconf_get_string (CONF_DAAP_SHARE_PASSWORD);
	} else {
		password = NULL;
	}

	share = daap_share_new (name, password, db, container_db, NULL);

	g_object_unref (db);
	g_object_unref (container_db);
	g_object_unref (rdb);
	g_object_unref (playlist_manager);

	g_free (name);
	g_free (password);
}
示例#3
0
文件: migrate.c 项目: GNOME/galeon
static void
check_mozilla_charset_pref (void)
{
	gchar * value = eel_gconf_get_string (CONF_LANGUAGE_DEFAULT_CHARSET);

	if (value && strchr (value, '('))
	{
		g_warning ("Setting encoding preference to 'ISO-8859-1', was '%s'", value);
		eel_gconf_set_string (CONF_LANGUAGE_DEFAULT_CHARSET, "ISO-8859-1");
	}

	g_free (value);
}
示例#4
0
static void
share_name_changed_cb (GConfClient *client,
		       guint cnxn_id,
		       GConfEntry *entry,
		       RBShell *shell)
{
	char *name;

	if (share == NULL) {
		return;
	}

	name = eel_gconf_get_string (CONF_DAAP_SHARE_NAME);
	if (name == NULL || name[0] == '\0') {
		g_free (name);
		name = rb_daap_sharing_default_share_name ();
	}

	g_object_set (G_OBJECT (share), "name", name, NULL);
	g_free (name);
}
示例#5
0
static void
share_password_changed_cb (GConfClient *client,
			   guint cnxn_id,
			   GConfEntry *entry,
			   RBShell *shell)
{
	gboolean require_password;
	char    *password;

	if (share == NULL) {
		return;
	}

	require_password = eel_gconf_get_boolean (CONF_DAAP_REQUIRE_PASSWORD);

	/* Don't do anything unless we require a password */
	if (! require_password) {
		return;
	}

	password = eel_gconf_get_string (CONF_DAAP_SHARE_PASSWORD);
	g_object_set (G_OBJECT (share), "password", password, NULL);
	g_free (password);
}
示例#6
0
static void
require_password_changed_cb (GConfClient *client,
			     guint cnxn_id,
			     GConfEntry *entry,
			     RBShell *shell)
{
	gboolean required;
	char    *password;

	if (share == NULL) {
		return;
	}

	required = eel_gconf_get_boolean (CONF_DAAP_REQUIRE_PASSWORD);

	if (required) {
		password = eel_gconf_get_string (CONF_DAAP_SHARE_PASSWORD);
	} else {
		password = NULL;
	}

	g_object_set (G_OBJECT (share), "password", password, NULL);
	g_free (password);
}
示例#7
0
文件: migrate.c 项目: GNOME/galeon
/*! Migrate the toolbar settings from Galeon 1.3.11 to 1.3.12
 */
static void
migrate_toolbar (void)
{
	gchar *tb_file = g_build_filename (g_get_home_dir (), 
					   GALEON_DIR, "toolbars.xml", NULL);

	gchar *toolbar;
	gchar **items, **item;
	GString *xml;
	FILE *file;

	if (g_file_test (tb_file, G_FILE_TEST_EXISTS))
	{
		g_free (tb_file);
		return;
	}

	toolbar = eel_gconf_get_string (CONF_TOOLBAR_SETUP);
	if (!toolbar)
	{
		g_free (tb_file);
		return;
	}

	xml = g_string_new (NULL);
	g_string_append (xml, "<?xml version=\"1.0\"?>\n"
			 "<toolbars version=\"0\">\n"
			 "  <toolbar name=\"MigratedToolbar\">\n");

	items = g_strsplit (toolbar, ";", 0);
	for (item = items; *item; item++)
	{
		gchar *str = *item;
		const gchar *new_type = NULL;
		guint i;

		for (i = 0 ; i < G_N_ELEMENTS (toolbar_map); i++)
		{
			if (g_str_has_prefix (str, toolbar_map[i].old_type))
			{
				new_type = toolbar_map[i].new_type;
				break;
			}
		}

		if (new_type)
		{
			g_string_append_printf (xml, 
				       "    <toolitem type=\"application/x-toolbar-item\""
               			       " name=\"%s\"/>\n", toolbar_map[i].new_type);

		}
		else if (strcmp (str, "=separator") == 0)
		{
			g_string_append (xml, "    <separator/>\n");
		}
		else
		{
			g_warning ("Unknown toolbar type: %s", str);
		}
	}

	g_free (toolbar);
	g_strfreev (items);
	
	g_string_append (xml, "  </toolbar>\n</toolbars>\n");

	if (!(file = fopen (tb_file, "w"))) 
	{
		g_warning ("Could not open file '%s': %s", 
			   tb_file, g_strerror (errno));
		g_string_free (xml, TRUE);
		g_free (tb_file);
		return;
	}

	if (fputs (xml->str, file) == -1)
	{
		g_warning ("Could not save to file '%s': %s",
			   tb_file, g_strerror (errno));
		g_string_free (xml, TRUE);
		g_free (tb_file);
		return;
	}
	g_string_free (xml, TRUE);

	if (fclose (file) == -1)
	{
		g_warning ("Could not close file '%s': %s",
			   tb_file, g_strerror (errno));
	}
	g_free (tb_file);
}
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;
}
示例#9
0
文件: actions.c 项目: Peliadia/gthumb
void
gth_browser_activate_action_view_slideshow (GtkAction  *action,
					    GthBrowser *browser)
{
	GList        *items;
	GList        *file_list;
	GthProjector *projector;
	GtkWidget    *slideshow;
	GthFileData  *location;
	char         *transition_id;
	GList        *transitions = NULL;

	items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
	if ((items == NULL) || (items->next == NULL))
		file_list = gth_file_store_get_visibles (GTH_FILE_STORE (gth_browser_get_file_store (browser)));
	else
		file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);

	projector = NULL;
#ifdef HAVE_CLUTTER
	if (ClutterInitResult == CLUTTER_INIT_SUCCESS)
		projector = &clutter_projector;
#endif /* HAVE_CLUTTER */
	if (projector == NULL)
		projector = &default_projector;

	slideshow = gth_slideshow_new (projector, browser, file_list);

	location = gth_browser_get_location_data (browser);
	if (g_file_info_get_attribute_boolean (location->info, "slideshow::personalize")) {
		gth_slideshow_set_delay (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_int32 (location->info, "slideshow::delay"));
		gth_slideshow_set_automatic (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_boolean (location->info, "slideshow::automatic"));
		gth_slideshow_set_wrap_around (GTH_SLIDESHOW (slideshow), g_file_info_get_attribute_boolean (location->info, "slideshow::wrap-around"));
		transition_id = g_strdup (g_file_info_get_attribute_string (location->info, "slideshow::transition"));
	}
	else {
		gth_slideshow_set_delay (GTH_SLIDESHOW (slideshow), (guint) (1000.0 * eel_gconf_get_float (PREF_SLIDESHOW_CHANGE_DELAY, 5.0)));
		gth_slideshow_set_automatic (GTH_SLIDESHOW (slideshow), eel_gconf_get_boolean (PREF_SLIDESHOW_AUTOMATIC, TRUE));
		gth_slideshow_set_wrap_around (GTH_SLIDESHOW (slideshow), eel_gconf_get_boolean (PREF_SLIDESHOW_WRAP_AROUND, FALSE));
		transition_id = eel_gconf_get_string (PREF_SLIDESHOW_TRANSITION, DEFAULT_TRANSITION);
	}

	if (g_file_info_get_attribute_status (location->info, "slideshow::playlist") == G_FILE_ATTRIBUTE_STATUS_SET)
		gth_slideshow_set_playlist (GTH_SLIDESHOW (slideshow),
					    g_file_info_get_attribute_stringv (location->info, "slideshow::playlist"));

	if (strcmp (transition_id, "random") == 0) {
		GList *scan;

		transitions = gth_main_get_registered_objects (GTH_TYPE_TRANSITION);
		for (scan = transitions; scan; scan = scan->next) {
			GthTransition *transition = scan->data;

			if (strcmp (gth_transition_get_id (transition), "none") == 0) {
				transitions = g_list_remove_link (transitions, scan);
				_g_object_list_unref (scan);
				break;
			}
		}
	}
	else {
		GthTransition *transition = gth_main_get_registered_object (GTH_TYPE_TRANSITION, transition_id);

		if (transition != NULL)
			transitions = g_list_append (NULL, transition);
		else
			transitions = NULL;
	}
	gth_slideshow_set_transitions (GTH_SLIDESHOW (slideshow), transitions);

	gtk_window_fullscreen (GTK_WINDOW (slideshow));
	/*gtk_window_set_default_size (GTK_WINDOW (slideshow), 700, 700);*/
	gtk_window_present (GTK_WINDOW (slideshow));

	_g_object_list_unref (transitions);
	g_free (transition_id);
	_g_object_list_unref (file_list);
	_gtk_tree_path_list_free (items);
}