<commit_before>/*
 * Copyright 2000-2008, <NAME>, <<EMAIL>>. All rights reserved.
 * Distributed under the terms of the MIT License.
 */

/*
 * backgrounds ThemesAddon class
 */

#include <Application.h>
#include <fs_attr.h>
#include <File.h>
#include <FindDirectory.h>
#include <InterfaceDefs.h>
#include <Directory.h>
#include <Message.h>
#include <Messenger.h>
#include <Roster.h>
#include <Screen.h>
#include <String.h>
#include <TypeConstants.h>
#include <be_apps/Tracker/Background.h>
#include <storage/Path.h>

#include <string.h>

#include "ThemesAddon.h"
#include "UITheme.h"
#include "Utils.h"

#ifdef SINGLE_BINARY
#define instantiate_themes_addon instantiate_themes_addon_backgrounds
#endif

#define A_NAME "Backgrounds"
#define A_MSGNAME Z_THEME_BACKGROUND_SETTINGS
#define A_DESCRIPTION "Desktop backdrops"

#define B__DESKTOP_COLOR "be:desktop_color"


class BackgroundThemesAddon : public ThemesAddon {
public:
	BackgroundThemesAddon();
	~BackgroundThemesAddon();
	
const char *Description();

status_t	RunPreferencesPanel();

status_t	AddNames(BMessage &names);

status_t	ApplyTheme(BMessage &theme, uint32 flags=0L);
status_t	MakeTheme(BMessage &theme, uint32 flags=0L);

status_t	ApplyDefaultTheme(uint32 flags=0L);

//status_t	CompareToCurrent(BMessage &theme);
	
	/* Theme installation */
	
status_t	InstallFiles(BMessage &theme, BDirectory &folder);
status_t	BackupFiles(BMessage &theme, BDirectory &folder);
	
};


BackgroundThemesAddon::BackgroundThemesAddon()
	: ThemesAddon(A_NAME, A_MSGNAME)
{
}


BackgroundThemesAddon::~BackgroundThemesAddon()
{
}


const char *
BackgroundThemesAddon::Description()
{
	return A_DESCRIPTION;
}


status_t
BackgroundThemesAddon::RunPreferencesPanel()
{
/*	if (be_roster->Launch("application/x-vnd.obos-Backgrounds") < B_OK)
		if (be_roster->Launch("application/x-vnd.Be-Backgrounds") < B_OK)
			return B_ERROR;*/
	status_t err;
	entry_ref ref;
	BEntry ent;
	err = ent.SetTo("/boot/beos/preferences/Backgrounds");
	if (!err) {
		err = ent.GetRef(&ref);
		if (!err) {
			err = be_roster->Launch(&ref);
		}
	}
	if (!err)
		return B_OK;
	err = ent.SetTo("/system/add-ons/Preferences/Backgrounds");
	if (!err) {
		err = ent.GetRef(&ref);
		if (!err) {
			err = be_roster->Launch(&ref);
			if (err) {
				BMessage msg(B_REFS_RECEIVED);
				msg.AddRef("refs", &ref);
				be_app_messenger.SendMessage(&msg);
			}<commit_msg>backgrounds: Fix launching prefs<commit_after>/*
 * Copyright 2000-2008, <NAME>, <<EMAIL>>. All rights reserved.
 * Distributed under the terms of the MIT License.
 */

/*
 * backgrounds ThemesAddon class
 */

#include <Application.h>
#include <fs_attr.h>
#include <File.h>
#include <FindDirectory.h>
#include <InterfaceDefs.h>
#include <Directory.h>
#include <Message.h>
#include <Messenger.h>
#include <Roster.h>
#include <Screen.h>
#include <String.h>
#include <TypeConstants.h>
#include <be_apps/Tracker/Background.h>
#include <storage/Path.h>

#include <string.h>

#include "ThemesAddon.h"
#include "UITheme.h"
#include "Utils.h"

#ifdef SINGLE_BINARY
#define instantiate_themes_addon instantiate_themes_addon_backgrounds
#endif

#define A_NAME "Backgrounds"
#define A_MSGNAME Z_THEME_BACKGROUND_SETTINGS
#define A_DESCRIPTION "Desktop backdrops"

#define B__DESKTOP_COLOR "be:desktop_color"

#ifndef __HAIKU__
#define B_SYSTEM_PREFERENCES_DIRECTORY B_BEOS_PREFERENCES_DIRECTORY
#endif


class BackgroundThemesAddon : public ThemesAddon {
public:
	BackgroundThemesAddon();
	~BackgroundThemesAddon();
	
const char *Description();

status_t	RunPreferencesPanel();

status_t	AddNames(BMessage &names);

status_t	ApplyTheme(BMessage &theme, uint32 flags=0L);
status_t	MakeTheme(BMessage &theme, uint32 flags=0L);

status_t	ApplyDefaultTheme(uint32 flags=0L);

//status_t	CompareToCurrent(BMessage &theme);
	
	/* Theme installation */
	
status_t	InstallFiles(BMessage &theme, BDirectory &folder);
status_t	BackupFiles(BMessage &theme, BDirectory &folder);
	
};


BackgroundThemesAddon::BackgroundThemesAddon()
	: ThemesAddon(A_NAME, A_MSGNAME)
{
}


BackgroundThemesAddon::~BackgroundThemesAddon()
{
}


const char *
BackgroundThemesAddon::Description()
{
	return A_DESCRIPTION;
}


status_t
BackgroundThemesAddon::RunPreferencesPanel()
{
	if (be_roster->Launch("application/x-vnd.Haiku-Backgrounds") == B_OK)
		return B_OK;
	if (be_roster->Launch("application/x-vnd.Be-Backgrounds") == B_OK)
		return B_OK;

	status_t err;
	entry_ref ref;
	BEntry ent;

	BPath p;
	err = find_directory(B_SYSTEM_PREFERENCES_DIRECTORY, &p);
	if (err == B_OK) {
		p.Append("Backgrounds");
		err = ent.SetTo(p.Path());
	}
	if (err == B_OK) {
		err = ent.GetRef(&ref);
		if (!err) {
			err = be_roster->Launch(&ref);
		}
	}
	if (err == B_OK)
		return B_OK;

	// ZETA: single-Prefs with addons...
	err = ent.SetTo("/system/add-ons/Preferences/Backgrounds");
	if (err == B_OK) {
		err = ent.GetRef(&ref);
		if (!err) {
			err = be_roster->Launch(&ref);
			if (err) {
				BMessage msg(B_REFS_RECEIVED);
				msg.AddRef("refs", &ref);
				be_app_messenger.SendMessage(&msg);
			}
{'fraction_non_alphanumeric': 0.13737574552683895, 'fraction_numerical': 0.006759443339960238, 'mean_word_length': 5.516839378238342, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1055983', 'n_tokens_mistral': 1982, 'n_tokens_neox': 1860, 'n_words': 373}