/* $Id$ */ /* * Cantus Tag Editor * Copyright © 2002-2004 by Samuel Abels * Copyright © 2007 by Tim Huetz * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see **/ #ifdef HAVE_CONFIG_H # include #endif #include //#define _DEBUG_ /****************************************************************************** * Constructor/Destructor ******************************************************************************/ Editarea::Editarea() { } Editarea::~Editarea(void) { #ifdef _DEBUG_ printf("unkowneditarea(): Editarea::~Editarea(): Called.\n"); #endif } /****************************************************************************** * Public ******************************************************************************/ GtkWidget* Editarea::build_horizontal(void) { HPaned* hpaned = new HPaned; HBox* selector = build_selector(); Label* label = new Label("", 0, 0.5); Table* form = build_form(); Table* comment = build_commentbox(); VBox* toplevel = new VBox; string text; parent = new HBox; // Build the hpaned holding the form and the commentbox. { hpaned->set_position(380); form->set_border_width(6); comment->set_border_width(6); hpaned->add1(*manage(form)); hpaned->add2(*manage(comment)); hpaned->set_focus_chain(focuschain); } // Pack everything into a vbox. { toplevel->set_border_width(6); text.append(""); text.append(_("Tag Fields")); text.append(""); label->set_markup(text); toplevel->pack_start(*manage(selector), FALSE, FALSE); //toplevel->pack_start(*manage(label), FALSE, FALSE); toplevel->pack_start(*manage(hpaned), TRUE, TRUE); } // Now, bundle everything with the buttonbox. parent->pack_start(*manage(toplevel), TRUE, TRUE); parent->pack_start(*manage(buttonbox), FALSE, TRUE); parent->show_all(); return (GtkWidget*)Glib::unwrap(parent); } GtkWidget* Editarea::build_vertical(void) { HBox* selector = build_selector(); Label* label = new Label("", 0, 0.5); Table* form = build_form(); Table* comment = build_commentbox(); string text; parent = new VBox; text.append(""); text.append(_("Tag Fields")); text.append(""); label->set_markup(text); parent->set_border_width(6); parent->pack_start(*manage(selector), FALSE, FALSE); parent->pack_start(*manage(label), FALSE, FALSE); parent->pack_start(*manage(form), FALSE, TRUE); parent->pack_start(*manage(comment), TRUE, TRUE); parent->pack_start(*manage(buttonbox), FALSE, TRUE); parent->set_focus_chain(focuschain); parent->show_all(); return (GtkWidget*)Glib::unwrap(parent); } GtkWidget* Editarea::build(bool vertical) { build_buttonbox(vertical); if (vertical) return build_vertical(); else return build_horizontal(); } Widget* Editarea::get_widget(string widgetname) { Widget* widget = widgets[widgetname]; if (!widget) g_warning("Editarea::get_widget(): Widget not found: %s\n", widgetname.c_str()); g_assert(widget != NULL); return widget; } void Editarea::set_label_text(string widgetname, string str) { #ifdef _DEBUG_ printf("Editarea::~set_label_text(): Called.\n"); #endif Label *label = (Label*)get_widget(widgetname); label->set_text(str); } bool Editarea::get_check_active(string widgetname) { CheckButton* check = (CheckButton*)get_widget(widgetname); return check->get_active(); } void Editarea::set_active(bool active) { buttonbox->set_sensitive(active); } int Editarea::get_direction(void) { ComboBoxText* combo = (ComboBoxText*)widgets["Direction"]; return combo->get_active_row_number(); } /****************************************************************************** * Private ******************************************************************************/ HBox* Editarea::build_selector(void) { HBox* selector = new HBox; Label* label = new Label(_("Copy Direction:"), 0, 0.5); ComboBoxText* combo = new ComboBoxText(); combo->insert_text(DIRECTION_V1TOV2, _("ID3 Version 1 to ID3 Version 2")); combo->insert_text(DIRECTION_V2TOV1, _("ID3 Version 2 to ID3 Version 1")); combo->set_active(DIRECTION_V1TOV2); combo->signal_changed().connect(signal_direction_changed); widgets["Direction"] = combo; selector->set_spacing(12); selector->pack_start(*manage(label), FALSE, FALSE); selector->pack_start(*manage(combo), TRUE, TRUE); return selector; } Table* Editarea::build_form(void) { Table* table = new Table(5, 4); CheckButton* check = NULL; Label* label = NULL; Viewport* view = NULL; ScrolledWindow* scroll = NULL; HBox* hbox1 = NULL; table->set_row_spacings(3); table->set_col_spacings(12); check = new CheckButton(_("Artist:")); label = new Label("", 0, 0.5); scroll = new ScrolledWindow; scroll->set_policy(POLICY_NEVER, POLICY_NEVER); scroll->add(*manage(label)); view = (Viewport*)scroll->get_child(); view->set_shadow_type(SHADOW_NONE); widgets["Artist:Check"] = check; widgets["Artist"] = label; focuschain.push_back(check); table->attach(*manage(check), 0, 1, 0, 1, FILL, FILL); table->attach(*manage(scroll), 1, 4, 0, 1, FILL|EXPAND, FILL); check = new CheckButton(_("Song:")); label = new Label("", 0, 0.5); scroll = new ScrolledWindow; scroll->set_policy(POLICY_NEVER, POLICY_NEVER); scroll->add(*manage(label)); view = (Viewport*)scroll->get_child(); view->set_shadow_type(SHADOW_NONE); widgets["Song:Check"] = check; widgets["Song"] = label; focuschain.push_back(check); table->attach(*manage(check), 0, 1, 1, 2, FILL, FILL); table->attach(*manage(scroll), 1, 4, 1, 2, FILL|EXPAND, FILL); check = new CheckButton(_("Album:")); label = new Label("", 0, 0.5); scroll = new ScrolledWindow; scroll->set_policy(POLICY_NEVER, POLICY_NEVER); scroll->add(*manage(label)); view = (Viewport*)scroll->get_child(); view->set_shadow_type(SHADOW_NONE); widgets["Album:Check"] = check; widgets["Album"] = label; focuschain.push_back(check); table->attach(*manage(check), 0, 1, 2, 3, FILL, FILL); table->attach(*manage(scroll), 1, 4, 2, 3, FILL|EXPAND, FILL); check = new CheckButton(_("Track:")); label = new Label("", 0, 0.5); scroll = new ScrolledWindow; scroll->set_policy(POLICY_NEVER, POLICY_NEVER); scroll->add(*manage(label)); view = (Viewport*)scroll->get_child(); view->set_shadow_type(SHADOW_NONE); widgets["Track:Check"] = check; widgets["Track"] = label; focuschain.push_back(check); table->attach(*manage(check), 0, 1, 3, 4, FILL, FILL); table->attach(*manage(scroll), 1, 2, 3, 4, FILL, FILL); hbox1 = new HBox; table->attach(*manage(hbox1), 3, 4, 3, 4, FILL|EXPAND, FILL); hbox1->set_size_request(80, -1); check = new CheckButton(_("Year:")); label = new Label("", 0, 0.5); scroll = new ScrolledWindow; scroll->set_policy(POLICY_NEVER, POLICY_NEVER); scroll->add(*manage(label)); view = (Viewport*)scroll->get_child(); view->set_shadow_type(SHADOW_NONE); widgets["Year:Check"] = check; widgets["Year"] = label; focuschain.push_back(check); hbox1->pack_start(*manage(check), FALSE, FALSE); hbox1->pack_start(*manage(scroll), TRUE, TRUE); check = new CheckButton(_("Genre:")); label = new Label("", 0, 0.5); scroll = new ScrolledWindow; scroll->set_policy(POLICY_NEVER, POLICY_NEVER); scroll->add(*manage(label)); view = (Viewport*)scroll->get_child(); view->set_shadow_type(SHADOW_NONE); widgets["Genre:Check"] = check; widgets["Genre"] = label; focuschain.push_back(check); table->attach(*manage(check), 0, 1, 4, 5, FILL, FILL); table->attach(*manage(scroll), 1, 2, 4, 5, FILL|EXPAND, FILL); return table; } Table* Editarea::build_commentbox(void) { Table* table = new Table(2, 1); CheckButton* check = new CheckButton(_("Comment:")); ScrolledWindow* scroll = new ScrolledWindow; Viewport* view = NULL; Label* label = new Label; widgets["Comment:Check"] = check; widgets["Comment"] = label; focuschain.push_back(check); label->set_line_wrap(); label->set_selectable(); scroll->set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC); scroll->add(*manage(label)); view = (Viewport*)scroll->get_child(); view->set_shadow_type(SHADOW_NONE); table->attach(*manage(check), 0, 1, 0, 1, FILL, FILL); table->attach(*manage(scroll), 0, 1, 1, 2, FILL|EXPAND, FILL|EXPAND); return table; } void Editarea::build_buttonbox(bool vertical) { Button* button = NULL; if (vertical) buttonbox = new HBox; else buttonbox = new VBox; buttonbox->set_spacing(6); buttonbox->set_border_width(6); Fixed* fixed = new Fixed; if (vertical) buttonbox->pack_start(*manage(fixed), TRUE, TRUE); else buttonbox->pack_end(*manage(fixed), TRUE, TRUE); // Add the "Save" button. button = new Button(Stock::SAVE); button->set_size_request(-1, 35); if (vertical) buttonbox->pack_end(*manage(button), FALSE, TRUE); else buttonbox->pack_start(*manage(button), FALSE, TRUE); button->signal_clicked().connect(signal_button_save_clicked); }