2 #include "assetpopup.h"
3 #include "assetremove.h"
5 #include "awindowgui.h"
6 #include "awindowmenu.h"
9 #include "cwindowgui.h"
11 #include "localsession.h"
12 #include "mainindexes.h"
13 #include "mainsession.h"
15 #include "mwindowgui.h"
18 #include "vwindowgui.h"
21 #define _(String) gettext(String)
22 #define gettext_noop(String) String
23 #define N_(String) gettext_noop (String)
26 AssetPopup::AssetPopup(MWindow *mwindow, AWindowGUI *gui)
33 this->mwindow = mwindow;
37 AssetPopup::~AssetPopup()
41 void AssetPopup::create_objects()
43 add_item(format = new AssetListFormat(mwindow));
44 add_item(info = new AssetPopupInfo(mwindow, this));
45 add_item(new AssetPopupSort(mwindow, this));
46 add_item(index = new AssetPopupBuildIndex(mwindow, this));
47 add_item(view = new AssetPopupView(mwindow, this));
48 add_item(new AssetPopupPaste(mwindow, this));
49 add_item(new AssetMatchSize(mwindow, this));
50 add_item(new AssetPopupProjectRemove(mwindow, this));
51 add_item(new AssetPopupDiskRemove(mwindow, this));
54 void AssetPopup::paste_assets()
56 // Collect items into the drag vectors for temporary storage
58 mwindow->gui->lock_window();
59 mwindow->cwindow->gui->lock_window();
61 gui->collect_assets();
62 mwindow->paste_assets(mwindow->edl->local_session->selectionstart,
63 mwindow->edl->tracks->first);
66 mwindow->gui->unlock_window();
67 mwindow->cwindow->gui->unlock_window();
70 void AssetPopup::match_size()
72 // Collect items into the drag vectors for temporary storage
73 gui->collect_assets();
74 mwindow->gui->lock_window();
75 mwindow->asset_to_size();
76 mwindow->gui->unlock_window();
79 int AssetPopup::update()
82 gui->collect_assets();
94 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
95 : BC_MenuItem(_("Info..."))
97 this->mwindow = mwindow;
101 AssetPopupInfo::~AssetPopupInfo()
105 int AssetPopupInfo::handle_event()
107 if(mwindow->session->drag_assets->total)
109 if(mwindow->awindow->asset_edit->running() &&
110 mwindow->awindow->asset_edit->window)
112 mwindow->awindow->asset_edit->window->raise_window();
113 mwindow->awindow->asset_edit->window->flush();
117 mwindow->awindow->asset_edit->edit_asset(
118 mwindow->session->drag_assets->values[0]);
122 if(mwindow->session->drag_clips->total)
124 popup->gui->awindow->clip_edit->edit_clip(
125 mwindow->session->drag_clips->values[0]);
136 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
137 : BC_MenuItem(_("Rebuild index"))
139 this->mwindow = mwindow;
143 AssetPopupBuildIndex::~AssetPopupBuildIndex()
147 int AssetPopupBuildIndex::handle_event()
149 //printf("AssetPopupBuildIndex::handle_event 1\n");
150 mwindow->rebuild_indices();
160 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
161 : BC_MenuItem(_("Sort items"))
163 this->mwindow = mwindow;
167 AssetPopupSort::~AssetPopupSort()
171 int AssetPopupSort::handle_event()
173 mwindow->awindow->gui->sort_assets();
183 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
184 : BC_MenuItem(_("View"))
186 this->mwindow = mwindow;
190 AssetPopupView::~AssetPopupView()
194 int AssetPopupView::handle_event()
196 mwindow->vwindow->gui->lock_window();
198 if(mwindow->session->drag_assets->total)
199 mwindow->vwindow->change_source(
200 mwindow->session->drag_assets->values[0]);
202 if(mwindow->session->drag_clips->total)
203 mwindow->vwindow->change_source(
204 mwindow->session->drag_clips->values[0]);
206 mwindow->vwindow->gui->unlock_window();
216 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
217 : BC_MenuItem(_("Paste"))
219 this->mwindow = mwindow;
223 AssetPopupPaste::~AssetPopupPaste()
227 int AssetPopupPaste::handle_event()
229 popup->paste_assets();
240 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
241 : BC_MenuItem(_("Match project size"))
243 this->mwindow = mwindow;
247 AssetMatchSize::~AssetMatchSize()
251 int AssetMatchSize::handle_event()
270 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
271 : BC_MenuItem(_("Remove from project"))
273 this->mwindow = mwindow;
279 AssetPopupProjectRemove::~AssetPopupProjectRemove()
283 int AssetPopupProjectRemove::handle_event()
285 mwindow->remove_assets_from_project(1);
292 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
293 : BC_MenuItem(_("Remove from disk"))
295 this->mwindow = mwindow;
300 AssetPopupDiskRemove::~AssetPopupDiskRemove()
305 int AssetPopupDiskRemove::handle_event()
307 mwindow->awindow->asset_remove->start();