legacy/experimental/ecdb/trunk/src/ecdb.c

309 lines
7.1 KiB
C
Raw Normal View History

/* vim: set sw=3 ts=3 sts=3 expandtab: */
#include "ecdb.h"
2008-04-07 01:04:15 +00:00
/* Global Variables */
int ECDB_DRIVE_ACTION_FINISHED = 0;
int ECDB_DRIVE_ACTION_BEGUN = 0;
int ECDB_DRIVE_ACTION_UPDATE = 0;
int ECDB_FILELIST_SIZE_CHANGED = 0;
2008-04-07 01:04:15 +00:00
Ecdb_Main *em;
int ecdb_setup();
2009-02-20 04:23:07 +00:00
int ecdb_initialize_config();
int
main(int argc, char **argv)
{
2008-12-09 05:47:59 +00:00
int ret = 0;
2008-12-18 18:54:50 +00:00
if (!eina_init())
{
fprintf(stderr, "Cannot initialize Eina!\n");
2008-12-18 18:54:50 +00:00
return 1;
}
if (!eina_error_init())
{
fprintf(stderr, "Cannot initialize Eina!\n");
ret = 1;
goto SHUTDOWN;
}
2008-12-09 05:47:59 +00:00
/* Do I really need all of these? */
if (!ecore_init())
{
fprintf(stderr, "Cannot initialize Ecore!\n");
ret = 1;
goto SHUTDOWN;
2008-12-09 05:47:59 +00:00
}
2009-02-20 04:23:07 +00:00
if (!ecore_file_init())
2008-12-09 05:47:59 +00:00
{
fprintf(stderr, "Cannot initialize Ecore_File!\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
2009-02-20 04:23:07 +00:00
if (ecore_config_init("ecdb") != ECORE_CONFIG_ERR_SUCC)
2008-12-09 05:47:59 +00:00
{
fprintf(stderr, "Cannot intialize Ecore_Config!\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
if (!ecore_evas_init())
{
fprintf(stderr, "Cannot initialize Ecore_Evas!\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
if (!edje_init())
{
fprintf(stderr, "Cannot initialize Edje!\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
if (!efreet_init())
{
fprintf(stderr, "Cannot initialize Efreet!\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
if (!ewl_init(&argc, argv))
{
fprintf(stderr, "Connot initialize Ewl!\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
if (!ecdb_image_init())
{
fprintf(stderr, "Cannot initialize libisofs!\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
if (!ecdb_burn_init())
{
fprintf(stderr, "Cannot initialize libburn!\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
if (!ecdb_setup())
{
fprintf(stderr, "Setup failed\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
ecdb_print_drive_info();
if (!ecdb_create_main_gui())
{
fprintf(stderr, "Cannot create main window\n");
2008-12-09 05:47:59 +00:00
ret = 1;
goto SHUTDOWN;
}
/*
Ecdb_Audio_Project *proj;
Ecdb_Source *src;
proj = ecdb_audio_project_new();
i = 1;
while ((i < argc) && (argv))
{
if (ecore_file_exists(argv[i]))
{
if (!ecore_file_is_dir(argv[i]))
{
src = ecdb_source_new();
ecdb_source_data_set(src, argv[i], 0);
ecdb_source_child_append(proj->tracks, src);
}
}
i++;
}
ecdb_audio_project_start(proj);
proj->publisher_id = proj->data_preparer_id = proj->system_id =
proj->application_id = proj->copywrite_id =
proj->abstract_id = proj->biblio_id = strdup("ecdb");
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), 0))
{
printf("Couldn't grab drive!\n");
ret = 1;
goto SHUTDOWN;
}
if (!ecdb_burn_project(proj))
{
printf("Burn was unsuccessful\n");
ret = 1;
goto SHUTDOWN;
}
*/
2009-02-20 04:23:07 +00:00
ecore_main_loop_begin();
2008-12-09 05:47:59 +00:00
/* End testing */
2008-04-07 20:40:30 +00:00
SHUTDOWN:
2008-12-09 05:47:59 +00:00
burn_finish();
iso_finish();
ewl_shutdown();
ecore_file_shutdown();
2009-02-20 04:23:07 +00:00
ecore_config_shutdown();
2008-12-09 05:47:59 +00:00
ecore_evas_shutdown();
edje_shutdown();
ecore_shutdown();
2008-12-09 05:47:59 +00:00
efreet_shutdown();
ewl_shutdown();
eina_error_shutdown();
eina_shutdown();
2008-12-09 05:47:59 +00:00
printf("Program Done\n");
return ret;
};
int
ecdb_setup(void)
{
2008-12-09 05:47:59 +00:00
em = NULL;
em = calloc(1, sizeof(Ecdb_Main));
if (!ecore_file_mkdir("/tmp/ecdb"))
{
printf("Creation of temporary directory failed!\n");
}
ECDB_DRIVE_ACTION_FINISHED = ecore_event_type_new();
ECDB_DRIVE_ACTION_BEGUN = ecore_event_type_new();
ECDB_DRIVE_ACTION_UPDATE = ecore_event_type_new();
ECDB_FILELIST_SIZE_CHANGED = ewl_callback_type_add();
2008-12-09 05:47:59 +00:00
ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, ecdb_shutdown, NULL);
ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, ecdb_dnd_position, em);
ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, ecdb_dnd_drop, em);
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, ecdb_dnd_selection,
em);
eina_error_log_level_set(EINA_ERROR_LEVEL_DBG);
eina_error_print_cb_set(eina_error_print_cb_file, stderr);
2008-12-09 05:47:59 +00:00
if (!ecdb_aquire_drive_info())
{
EINA_ERROR_PERR("Aquiring drives failed!\n");
2008-12-09 05:47:59 +00:00
return FALSE;
}
2009-02-20 04:23:07 +00:00
if (!ecdb_initialize_config())
{
EINA_ERROR_PERR("Initializing the configuration failed!\n");
2009-02-20 04:23:07 +00:00
return FALSE;
}
2008-12-09 05:47:59 +00:00
return TRUE;
}
2009-02-20 04:23:07 +00:00
int
ecdb_initialize_config(void)
{
char *gui, *engine, *tmp_eng;
Eina_List *l;
// Theme
ecore_config_theme_default("theme", "default");
ecore_config_describe("theme", "The name of the theme to use.");
ecore_config_long_opt_set("theme", "The name of the theme to use.");
ecore_config_short_opt_set("theme", 't');
// Frame rate
ecore_config_int_default("frame_rate", 60);
ecore_config_describe("frame_rate", "The frame rate of the GUI.");
ecore_config_long_opt_set("frame_rate", "The frame rate of the GUI.");
ecore_config_short_opt_set("frame_rate", 'r');
// Scale
ecore_config_float_default("scale", 1.0);
ecore_config_describe("scale", "The scaling factor.");
ecore_config_long_opt_set("scale", "The scaling factor.");
ecore_config_short_opt_set("scale", 's');
// Use scale?
ecore_config_boolean_default("use_scale", 0);
ecore_config_describe("use_scale", "Use scaling?");
ecore_config_long_opt_set("use_scale", "Use scaling?");
ecore_config_short_opt_set("use_scale", 'u');
2009-02-20 04:23:07 +00:00
// Engine
ecore_config_string_default("engine", "software_x11");
ecore_config_describe("engine", "The canvas engine.");
ecore_config_long_opt_set("engine", "The canvas engine.");
ecore_config_short_opt_set("engine", 'e');
// Load the config
ecore_config_load();
// Set up the theme path
ecore_config_theme_search_path_append(PACKAGE_DATA_DIR"/themes");
gui = ecore_config_theme_with_path_get("theme");
if ((!gui) || (!ecore_file_exists(gui)) || (!edje_file_group_exists(gui,
"ecdb/window")))
{
EINA_ERROR_PWARN("Invalid file specified, attempting to fall back "
" to default!\n");
2009-02-20 04:23:07 +00:00
gui = ecore_config_theme_with_path_from_name_get("default");
ecore_config_theme_set("theme", "default");
2009-02-20 04:23:07 +00:00
if (!gui)
{
EINA_ERROR_PERR("Default theme is missing! Please check"
" your installation.\n");
2009-02-20 04:23:07 +00:00
return 0;
}
}
em->theme_path = gui;
// Set up the engines
engine = ecore_config_string_get("engine");
l = ecore_evas_engines_get();
if (!eina_list_count(l))
{
EINA_ERROR_PERR("There are no built engines!\n");
2009-02-20 04:23:07 +00:00
return 0;
}
EINA_LIST_FOREACH(l, l, tmp_eng)
{
if (!strcmp(tmp_eng, engine))
{
em->engine = engine;
break;
}
}
// Default to last in the list
if (!em->engine)
em->engine = strdup((char *)eina_list_last(l));
ecore_evas_engines_free(l);
// Initialize the other variables
em->scalef = ecore_config_float_get("scale");
em->fps = ecore_config_int_get("frame_rate");
return 1;
}