Exemple #1
0
/*==================================================
 * delete_array_obj - Delete element from array
 * This of course is somewhat expensive, as the array must be shifted down
 *================================================*/
BOOLEAN
delete_array_obj (ARRAY array, INT i)
{
	if (i<0 || i>ASize(array)) return FALSE;
	while (i<ASize(array)) {
		AData(array)[i] = AData(array)[i+1];
		++i;
	}
	--ASize(array);
	return TRUE;
}
Exemple #2
0
/*=========================================================
 * destroy_array -- Delete array (releasing all elements)
 *=======================================================*/
void
destroy_array (ARRAY array)
{
	int i;
	for (i=0; i<ASize(array); ++i) {
		OBJECT obj = (OBJECT)AData(array)[i];
		delete_obj(obj);
	}
	stdfree(AData(array));
	AData(array) = 0;
	stdfree(array);
}
Exemple #3
0
/*=========================================================
 * create_array_objval -- Create array (which holds objects)
 *=======================================================*/
ARRAY
create_array_objval (INT size)
{
	ARRAY array = 0;
	if (!size) size=20;
	ASSERT(size >= 1);
	array = (ARRAY)stdalloc(sizeof(*array));
	memset(array, 0, sizeof(*array));
	array->vtable = &vtable_for_array;
	ASize(array) = 0;
	AMax(array) = size;
	AData(array) = (void **)stdalloc(size * sizeof(AData(array)[0]));
	return array;
}
static void SaveProject()
{
    ASSERT( AData().IsProjectSet() );

    AStores& as = GetAStores();
    RefPtr<MenuStore> mn_store = as.mnStore;
    SaveProjectData(mn_store, as.mdStore);
    // очистка после сохранения
    AData().SetOut(true);
    for( MenuStore::iterator itr = mn_store->children().begin(), end = mn_store->children().end();
         itr != end; ++itr )
        ClearMenuSavedData(GetMenu(mn_store, itr));

    SetAppTitle();
}
Exemple #5
0
/*=========================================================
 * enlarge_array -- Make array large enough for [space] elements
 *=======================================================*/
void
enlarge_array (ARRAY array, INT space)
{
	int newsize = AMax(array);
	void ** ptr;
	int i;
	while (newsize <= space)
		newsize <<= 2;
	if (newsize<AMax(array)) return;
	ptr = (void **)stdalloc(newsize * sizeof(AData(array)[0]));
	for (i = 0; i < ASize(array); i++)
		ptr[i] = AData(array)[i];
	stdfree(AData(array));
	AData(array) = ptr;
	AMax(array) = newsize;
}
static void OnSaveProject()
{
    if( AData().IsProjectSet() )
        SaveProject();
    else
        OnSaveAsProject();
}
Exemple #7
0
/*=========================================================
 * set_array_obj -- Set element (object) in array
 *  grow if necessary
 *=======================================================*/
void
set_array_obj (ARRAY array, INT i, OBJECT obj)
{
	ASSERT(i>=0);
	ASSERT(i< 0x1000000); /* 16,777,216 */
	if (i>=AMax(array)) {
		enlarge_array(array, i);
	}
	if (i>=ASize(array)) {
		int j;
		for (j=ASize(array); j<i; ++j)
			AData(array)[j] = 0;
		ASize(array)=i+1;
	}
	AData(array)[i] = obj;
}
Exemple #8
0
void
sort_array (ARRAY array, OBJCMPFNC cmp, VPTR param)
{
	struct tag_sort_array_info info;
	info.cmp = cmp;
	info.param = param;
	partition_sort((SORTEL *)&AData(array)[0], ASize(array), array_comparator, &info);
}
static void NewProject()
{
    // * очищаем списки
    AStores& as = GetAStores();
    ClearStore(as.mnStore);
    ClearStore(as.mdStore);
    // * остальное в базе
    AData().ClearSettings();
}
Exemple #10
0
static std::string MakeProjectTitle(bool with_path_breakdown = false)
{
    ADatabase& db = AData();
    if( !db.IsProjectSet() )
        return "untitled.bmd";

    fs::path full_path(db.GetProjectFName());
    std::string res_str = fs::name_str(full_path);
    if( with_path_breakdown )
        res_str += " (" + full_path.branch_path().string() + ")";
    return res_str;
}
Exemple #11
0
void OnNewProject(ConstructorApp& app, bool on_startup)
{
    bool is_pal = Prefs().isPAL;
    Gtk::Dialog new_prj_dlg(_("New Project"), app.win, true, true);
    new_prj_dlg.set_name("NewProject");
    new_prj_dlg.set_resizable(false);

    Gtk::VBox& dlg_box = *new_prj_dlg.get_vbox();
    PackStart(dlg_box, NewManaged<Gtk::Image>(DataDirPath("cap400.png")));
    Gtk::VBox& vbox = Add(PackStart(dlg_box, NewPaddingAlg(10, 40, 20, 20)), NewManaged<Gtk::VBox>());
    
    PackStart(vbox, NewManaged<Gtk::Label>(_("Please select a Television standard for your project:"),
                                           0.0, 0.5, true));
    {
        Gtk::VBox& vbox2 = Add(PackStart(vbox, NewPaddingAlg(10, 10, 0, 0)), NewManaged<Gtk::VBox>());

        Gtk::RadioButtonGroup grp;
        PackStart(vbox2, TVSelectionButton(is_pal, true,  grp));
        PackStart(vbox2, TVSelectionButton(is_pal, false, grp));
    }

    Gtk::CheckButton r_btn(_("Remember my choice"));
    if( on_startup )
    {
        // :TRICKY: в отличие от GtkAssistant, action_area в диалоге - 
        // GtkButtonBox, который все свои виджеты делает одинаковыми,
        // не смотря на опции shrink, fill, padding (т.е. GtkButtonBox
        // заведомо хуже GtkBox в плане гибкости)
        //PackStart(*new_prj_dlg.get_action_area(), r_btn);
        PackStart(vbox, r_btn);
        new_prj_dlg.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
    }
    else
        AddCancelOKButtons(new_prj_dlg);

    dlg_box.show_all();
    if( Gtk::RESPONSE_OK == new_prj_dlg.run() )
    {
        NewProject();
        AData().SetPalTvSystem(is_pal);
        SetAppTitle();

        if( on_startup && r_btn.get_active() )
        {
            Prefs().isPAL = is_pal;
            // :TRICKY: если будут запросы обратно в false вернуть, то
            // добавим "очищающую" кнопку PackCompositeWdgButton() в диалог настроек
            Prefs().remMyTVChoice = true;
            SavePrefs();
        }
    }
}
Exemple #12
0
AStores& InitAndLoadPrj(const std::string& fname)
{
    AStores& as = InitAStores();

    ADatabase& db = AData();
    db.Load(ConvertPathToUtf8(fname));

    PublishMediaStore(as.mdStore);
    PublishMenuStore(as.mnStore, db.GetMN());

    db.SetOut(true);
    return as;
}
Exemple #13
0
void LoadApp(const std::string& fname)
{
    LoadProjectInteractive(ConvertPathToUtf8(fname));

    AStores& as = GetAStores();
    ADatabase& db = AData();

    PublishMediaStore(as.mdStore);
    PublishMenuStore(as.mnStore, db.GetMN());
    UpdateDVDSize();

    db.SetOut(true);
    SetAppTitle();
}
Exemple #14
0
static bool SaveProjectAs(Gtk::Widget& for_wdg) 
{
    bool res = false;
    std::string fname = MakeProjectTitle();
    if( ChooseFileSaveTo(fname, _("Save Project As"), for_wdg) )
    {
        fname = Project::ConvertPathToUtf8(fname);

        ASSERT( !fname.empty() );
        AData().SetProjectFName(fname);
        res = true;
    }

    return res;
}
Exemple #15
0
static void OnOpenProject(ConstructorApp& app)
{
    //bool res = false;
    //std::string fname;
    //{
    //    Gtk::FileChooserDialog dialog(_("Open Project"), Gtk::FILE_CHOOSER_ACTION_OPEN);
    //    BuildChooserDialog(dialog, true, app.win);

    //    Gtk::FileFilter prj_filter;
    //    prj_filter.set_name(_("Project files (*.bmd)"));
    //    prj_filter.add_pattern("*.bmd");
    //    // старые проекты
    //    prj_filter.add_pattern("*.xml");
    //    dialog.add_filter(prj_filter);

    //    Gtk::FileFilter all_filter;
    //    all_filter.set_name(_("All Files (*.*)"));
    //    all_filter.add_pattern("*");
    //    dialog.add_filter(all_filter);


    //    if( Gtk::RESPONSE_OK == dialog.run() )
    //    {
    //        //// в процессе загрузки не нужен
    //        //dialog.hide();
    //        //IteratePendingEvents();

    //        res = true;
    //        fname = dialog.get_filename();
    //    }
    //}

    FileFilterList pat_lst;
    FileFilter& bmd_ff = AddFileFilter(pat_lst, _("Project files (*.bmd)"));
    const char* bmd_extensions[] = { "*.bmd", "*.xml", 0 };
    AddFPs(bmd_ff, bmd_extensions);
    AddAllFF(pat_lst);

    Str::List paths;
    if( RunFileDialog(_("Open Project"), true, paths, app.win, pat_lst) )
    {
        NewProject();
        AData().SetOut(false);

        LoadApp(paths[0]);
    }
}
Exemple #16
0
static void SaveProjectData(RefPtr<MenuStore> mn_store, RefPtr<MediaStore> md_store)
{
    ADatabase& db = AData();
    // * сохраняемся
    for( MediaStore::iterator itr = md_store->children().begin(), end = md_store->children().end();
         itr != end; ++itr )
        db.GetML().Insert(md_store->GetMedia(itr));
    for( MenuStore::iterator  itr = mn_store->children().begin(), end = mn_store->children().end();
         itr != end; ++itr )
    {
        Menu mn = GetMenu(mn_store, itr);
        Project::SaveMenu(mn);
        db.GetMN().Insert(mn);
    }
    db.SetOut(false);
    db.Save();
}
Exemple #17
0
static void LoadProjectInteractive(const std::string& prj_file_name)
{
    ADatabase& db = AData();
    bool res = true;
    std::string err_str;
    try
    {
        void DbSerializeProjectImpl(Archieve& ar);
        db.LoadWithFnr(prj_file_name, DbSerializeProjectImpl);
    }
    catch (const std::exception& err)
    {
        res = false;
        err_str = err.what();
    }
    if( !res )
    {
        // мягкая очистка
        db.Clear(false);
        db.ClearSettings();
        MessageBox(BF_("Can't open project file \"%1%\"") % prj_file_name % bf::stop, Gtk::MESSAGE_ERROR, 
                   Gtk::BUTTONS_OK, err_str);
    }
}
static void ClearFirstPlayProperty(MediaItem mi)
{
    MediaItem& fp = AData().FirstPlayItem();
    if( fp == mi )
        fp = MediaItem(); // очистка
}
Exemple #19
0
/*=========================================================
 * get_array_obj -- Get element (object) from array
 *=======================================================*/
OBJECT
get_array_obj (ARRAY array, INT i)
{
	if (i<0 || i>ASize(array)) return 0;
	return (OBJECT)AData(array)[i];
}