318 lines
7.3 KiB
C
318 lines
7.3 KiB
C
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
|
#include "ecdb.h"
|
|
|
|
/* Global Variables */
|
|
int ECDB_DRIVE_ACTION_FINISHED = 0;
|
|
int ECDB_DRIVE_ACTION_BEGUN = 0;
|
|
int ECDB_DRIVE_ACTION_UPDATE = 0;
|
|
unsigned int ECDB_FILELIST_SIZE_CHANGED = 0;
|
|
|
|
Ecdb_Main *em;
|
|
int ecdb_setup();
|
|
int ecdb_initialize_config();
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (!eina_init())
|
|
{
|
|
fprintf(stderr, "Cannot initialize Eina!\n");
|
|
return 1;
|
|
}
|
|
|
|
if (!eina_error_init())
|
|
{
|
|
fprintf(stderr, "Cannot initialize Eina Error!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
eina_error_log_level_set(EINA_ERROR_LEVEL_DBG);
|
|
eina_error_print_cb_set(eina_error_print_cb_file, stderr);
|
|
|
|
if (!ecore_init())
|
|
{
|
|
EINA_ERROR_PERR("Cannot initialize Ecore!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!ecore_file_init())
|
|
{
|
|
EINA_ERROR_PERR("Cannot initialize Ecore_File!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (ecore_config_init("ecdb") != ECORE_CONFIG_ERR_SUCC)
|
|
{
|
|
EINA_ERROR_PERR("Cannot intialize Ecore_Config!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!ecore_evas_init())
|
|
{
|
|
EINA_ERROR_PERR("Cannot initialize Ecore_Evas!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!edje_init())
|
|
{
|
|
EINA_ERROR_PERR("Cannot initialize Edje!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!efreet_init())
|
|
{
|
|
EINA_ERROR_PERR("Cannot initialize Efreet!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!ewl_init(&argc, argv))
|
|
{
|
|
EINA_ERROR_PERR("Connot initialize Ewl!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!e_dbus_init())
|
|
{
|
|
EINA_ERROR_PERR("Cannot initialize E_DBus!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!ecdb_image_init())
|
|
{
|
|
EINA_ERROR_PERR("Cannot initialize libisofs!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!ecdb_burn_init())
|
|
{
|
|
EINA_ERROR_PERR("Cannot initialize libburn!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!ecdb_setup())
|
|
{
|
|
EINA_ERROR_PERR("Setup failed\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
if (!ecdb_hal_init())
|
|
{
|
|
EINA_ERROR_PERR("Ecdb_Hal initialization failed!\n");
|
|
ret = 1;
|
|
goto SHUTDOWN;
|
|
}
|
|
|
|
ecdb_print_drive_info();
|
|
|
|
if (!ecdb_create_main_gui())
|
|
{
|
|
EINA_ERROR_PERR("Cannot create main window\n");
|
|
ret = 1;
|
|
ecdb_drive_info_list_free(em->drives);
|
|
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;
|
|
}
|
|
|
|
*/
|
|
|
|
ecore_main_loop_begin();
|
|
|
|
/* End testing */
|
|
|
|
SHUTDOWN:
|
|
burn_finish();
|
|
iso_finish();
|
|
e_dbus_shutdown();
|
|
ewl_shutdown();
|
|
ecore_file_shutdown();
|
|
ecore_config_shutdown();
|
|
ecore_evas_shutdown();
|
|
edje_shutdown();
|
|
ecore_shutdown();
|
|
efreet_shutdown();
|
|
ewl_shutdown();
|
|
eina_error_shutdown();
|
|
eina_shutdown();
|
|
|
|
printf("Program Done\n");
|
|
return ret;
|
|
};
|
|
|
|
int
|
|
ecdb_setup(void)
|
|
{
|
|
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();
|
|
|
|
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);
|
|
|
|
if (!ecdb_initialize_config())
|
|
{
|
|
EINA_ERROR_PERR("Initializing the configuration failed!\n");
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
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');
|
|
|
|
// 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");
|
|
gui = ecore_config_theme_with_path_from_name_get("default");
|
|
ecore_config_theme_set("theme", "default");
|
|
|
|
if (!gui)
|
|
{
|
|
EINA_ERROR_PERR("Default theme is missing! Please check"
|
|
" your installation.\n");
|
|
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");
|
|
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;
|
|
}
|
|
|