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));
52 submenu->add_submenuitem(new FolderListModify(mwindow, this));
53 submenu->add_submenuitem(new FolderListDelete(mwindow, this));
57 void FolderListMenu::update_titles()
59 format->set_text(mwindow->edl->session->folderlist_format == FOLDERS_TEXT ?
60 (char*)_("Display icons") : (char*)_("Display text"));
64 FolderListFormat::FolderListFormat(MWindow *mwindow, FolderListMenu *menu)
67 this->mwindow = mwindow;
71 int FolderListFormat::handle_event()
73 switch(mwindow->edl->session->folderlist_format) {
75 mwindow->edl->session->folderlist_format = FOLDERS_ICONS;
78 mwindow->edl->session->folderlist_format = FOLDERS_TEXT;
82 mwindow->awindow->gui->folder_list->update_format(
83 mwindow->edl->session->folderlist_format, 1);
84 menu->update_titles();
90 FolderListSort::FolderListSort(MWindow *mwindow, FolderListMenu *menu)
91 : BC_MenuItem(_("Sort items"))
93 this->mwindow = mwindow;
97 int FolderListSort::handle_event()
99 mwindow->awindow->gui->sort_folders();
103 FolderListNew::FolderListNew(MWindow *mwindow, FolderListMenu *menu)
104 : BC_MenuItem(_("New folder"))
106 this->mwindow = mwindow;
110 int FolderListNew::handle_event()
112 int cx, cy, cw = 320, ch = 120;
113 menu->gui->get_abs_cursor(cx, cy);
114 if( (cx-=cw/2) < 50 ) cx = 50;
115 if( (cy-=ch/2) < 50 ) cy = 50;
116 menu->gui->new_folder_thread->start(cx, cy, cw, ch);
120 FolderListModify::FolderListModify(MWindow *mwindow, FolderListMenu *menu)
121 : BC_MenuItem(_("Modify folder"))
123 this->mwindow = mwindow;
127 int FolderListModify::handle_event()
129 int awindow_folder = mwindow->edl->session->awindow_folder;
130 BinFolder *folder = mwindow->edl->get_folder(awindow_folder);
132 int bw = mwindow->session->bwindow_w;
133 int bh = mwindow->session->bwindow_h;
135 menu->gui->get_abs_cursor(cx, cy);
136 if( (cx-=bw/2) < 50 ) cx = 50;
137 if( (cy-=bh/2) < 50 ) cy = 50;
138 menu->gui->modify_folder_thread->start(folder, cx, cy, bw, bh);
143 FolderListDelete::FolderListDelete(MWindow *mwindow, FolderListMenu *menu)
144 : BC_MenuItem(_("Delete folder"))
146 this->mwindow = mwindow;
150 int FolderListDelete::handle_event()
152 AssetPicon *picon = (AssetPicon *)menu->gui->folder_list->get_selection(0, 0);
153 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
154 int foldernum = picon->foldernum;
155 BinFolder *folder = mwindow->edl->get_folder(foldernum);
156 mwindow->delete_folder(folder->title);
157 if( mwindow->edl->session->awindow_folder == foldernum )
158 mwindow->edl->session->awindow_folder = AW_MEDIA_FOLDER;
159 mwindow->awindow->gui->async_update_assets();