1 /* === S Y N F I G ========================================================= */
2 /*! \file dialog_targetparam.cpp
3 ** \brief Implementation for the TargetParam Dialog
8 ** Copyright (c) 2010 Carlos López González
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "dialog_targetparam.h"
38 /* === U S I N G =========================================================== */
41 using namespace studio;
43 /* === M A C R O S ========================================================= */
45 /* === G L O B A L S ======================================================= */
46 //! Allowed video codecs
47 /*! \warning This variable is linked to allowed_video_codecs_description,
48 * if you change this you must change the other acordingly.
49 * \warning These codecs are linked to the filename extensions for
50 * mod_ffmpeg. If you change this you must change the others acordingly.
52 const char* allowed_video_codecs[] =
54 "flv", "h263p", "huffyuv", "libtheora", "libx264", "libxvid",
55 "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
56 "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", NULL
59 //! Allowed video codecs description.
60 /*! \warning This variable is linked to allowed_video_codecs,
61 * if you change this you must change the other acordingly.
63 const char* allowed_video_codecs_description[] =
65 _("Flash Video (FLV) / Sorenson Spark / Sorenson H.263."),
66 _("H.263+ / H.263-1998 / H.263 version 2."),
67 _("Huffyuv / HuffYUV."),
68 _("libtheora Theora."),
69 _("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10."),
70 _("libxvidcore MPEG-4 part 2."),
71 _("MJPEG (Motion JPEG)."),
72 _("raw MPEG-1 video."),
73 _("raw MPEG-2 video."),
75 _("MPEG-4 part 2 Microsoft variant version 3."),
76 _("MPEG-4 part 2 Microsoft variant version 1."),
77 _("MPEG-4 part 2 Microsoft variant version 2."),
78 _("Windows Media Video 7."),
79 _("Windows Media Video 8."),
82 /* === P R O C E D U R E S ================================================= */
84 /* === M E T H O D S ======================================================= */
86 /* === E N T R Y P O I N T ================================================= */
88 Dialog_TargetParam::Dialog_TargetParam(synfig::TargetParam &tparam)
90 set_title(_("TargetParam Dialog"));
92 // Available Video Codecs Combo Box Text.
93 vcodec = Gtk::manage(new Gtk::ComboBoxText());
94 Gtk::Label* label(manage(new Gtk::Label(_("Available Video Codecs:"))));
95 label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
96 get_vbox()->pack_start(*label, true, true, 0);
97 for (int i = 0; allowed_video_codecs[i] != NULL &&
98 allowed_video_codecs_description[i] != NULL; i++)
99 vcodec->append_text(allowed_video_codecs_description[i]);
100 for (int i = 0; allowed_video_codecs[i] != NULL &&
101 allowed_video_codecs_description[i] != NULL; i++)
102 if(!get_tparam().video_codec.compare(allowed_video_codecs[i]))
103 vcodec->set_active_text(allowed_video_codecs_description[i]);
105 get_vbox()->pack_start(*vcodec, true, true, 0);
107 //Bitrate Spin Button
108 Gtk::Adjustment* bradj(manage(new class Gtk::Adjustment(double(tparam.bitrate), 10.0,1000.0)));
109 bitrate = Gtk::manage(new class Gtk::SpinButton(*bradj));
110 Gtk::Label* label2(manage(new Gtk::Label(_("Video Bit Rate:"))));
111 label2->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
112 get_vbox()->pack_start(*label2, true, true, 0);
113 get_vbox()->pack_start(*bitrate,true, true, 0);
115 get_vbox()->show_all();
117 ok_button = manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
119 add_action_widget(*ok_button,Gtk::RESPONSE_OK);
120 ok_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_ok));
122 cancel_button = manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
123 cancel_button->show();
124 add_action_widget(*cancel_button,Gtk::RESPONSE_CANCEL);
125 cancel_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_cancel));
130 Dialog_TargetParam::on_ok()
132 std::string codecnamed = vcodec->get_active_text();
133 for (int i = 0; allowed_video_codecs[i] != NULL &&
134 allowed_video_codecs_description[i] != NULL; i++)
135 if(!codecnamed.compare(allowed_video_codecs_description[i]))
136 tparam_.video_codec=allowed_video_codecs[i];
137 tparam_.bitrate=bitrate->get_value();
142 Dialog_TargetParam::on_cancel()
147 Dialog_TargetParam::~Dialog_TargetParam()