4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "awindowgui.h"
24 #include "folderlistmenu.h"
26 #include "edlsession.h"
28 #include "mainsession.h"
32 FolderListMenu::FolderListMenu(MWindow *mwindow, AWindowGUI *gui)
33 : BC_PopupMenu(0, 0, 0, "", 0)
35 this->mwindow = mwindow;
39 FolderListMenu::~FolderListMenu()
43 void FolderListMenu::create_objects()
45 BC_MenuItem *menu_item;
47 add_item(format = new FolderListFormat(mwindow, this));
48 add_item(new FolderListSort(mwindow, this));
49 add_item(menu_item = new BC_MenuItem(_("Folder...")));
50 menu_item->add_submenu(submenu = new BC_SubMenu());
51 submenu->add_submenuitem(new FolderListNew(mwindow, this, _("New Media"), 0));
52 submenu->add_submenuitem(new FolderListNew(mwindow, this, _("New Clips"), 1));
53 submenu->add_submenuitem(new FolderListModify(mwindow, this));
54 submenu->add_submenuitem(new FolderListDelete(mwindow, this));
58 void FolderListMenu::update_titles()
60 format->set_text(mwindow->edl->session->folderlist_format == FOLDERS_TEXT ?
61 (char*)_("Display icons") : (char*)_("Display text"));
65 FolderListFormat::FolderListFormat(MWindow *mwindow, FolderListMenu *menu)
68 this->mwindow = mwindow;
72 int FolderListFormat::handle_event()
74 switch(mwindow->edl->session->folderlist_format) {
76 mwindow->edl->session->folderlist_format = FOLDERS_ICONS;
79 mwindow->edl->session->folderlist_format = FOLDERS_TEXT;
83 mwindow->awindow->gui->folder_list->update_format(
84 mwindow->edl->session->folderlist_format, 1);
85 menu->update_titles();
91 FolderListSort::FolderListSort(MWindow *mwindow, FolderListMenu *menu)
92 : BC_MenuItem(_("Sort items"))
94 this->mwindow = mwindow;
98 int FolderListSort::handle_event()
100 mwindow->awindow->gui->sort_folders();
104 FolderListNew::FolderListNew(MWindow *mwindow, FolderListMenu *menu,
105 const char *text, int is_clips)
108 this->mwindow = mwindow;
110 this->is_clips = is_clips;
113 int FolderListNew::handle_event()
115 int cx, cy, cw = 320, ch = 120;
116 menu->gui->get_abs_cursor(cx, cy);
117 if( (cx-=cw/2) < 50 ) cx = 50;
118 if( (cy-=ch/2) < 50 ) cy = 50;
119 menu->gui->new_folder_thread->start(cx, cy, cw, ch, is_clips);
123 FolderListModify::FolderListModify(MWindow *mwindow, FolderListMenu *menu)
124 : BC_MenuItem(_("Modify folder"))
126 this->mwindow = mwindow;
130 int FolderListModify::handle_event()
132 int awindow_folder = mwindow->edl->session->awindow_folder;
133 BinFolder *folder = mwindow->edl->get_folder(awindow_folder);
135 int bw = mwindow->session->bwindow_w;
136 int bh = mwindow->session->bwindow_h;
138 menu->gui->get_abs_cursor(cx, cy);
139 if( (cx-=bw/2) < 50 ) cx = 50;
140 if( (cy-=bh/2) < 50 ) cy = 50;
141 menu->gui->modify_folder_thread->start(folder, cx, cy, bw, bh);
146 FolderListDelete::FolderListDelete(MWindow *mwindow, FolderListMenu *menu)
147 : BC_MenuItem(_("Delete folder"))
149 this->mwindow = mwindow;
153 int FolderListDelete::handle_event()
155 AssetPicon *picon = (AssetPicon *)menu->gui->folder_list->get_selection(0, 0);
156 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
157 int foldernum = picon->foldernum;
158 BinFolder *folder = mwindow->edl->get_folder(foldernum);
159 mwindow->delete_folder(folder->title);
160 if( mwindow->edl->session->awindow_folder == foldernum )
161 mwindow->edl->session->awindow_folder = AW_MEDIA_FOLDER;
162 mwindow->awindow->gui->async_update_assets();