From 0b25a520cfdd3983f6fa94c4293210f25cd6dfac Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Tue, 25 May 2010 17:00:42 +0200 Subject: [PATCH] Shows the video codec selected in an entry for later allow custom video codec. --- synfig-studio/src/gtkmm/dialog_targetparam.cpp | 37 +++++++++++++++++++++++--- synfig-studio/src/gtkmm/dialog_targetparam.h | 2 ++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/synfig-studio/src/gtkmm/dialog_targetparam.cpp b/synfig-studio/src/gtkmm/dialog_targetparam.cpp index 4579b8b..d94f820 100644 --- a/synfig-studio/src/gtkmm/dialog_targetparam.cpp +++ b/synfig-studio/src/gtkmm/dialog_targetparam.cpp @@ -42,6 +42,8 @@ using namespace studio; /* === M A C R O S ========================================================= */ +#define CUSTOM_VCODEC _("Custom Video Codec") + /* === G L O B A L S ======================================================= */ //! Allowed video codecs /*! \warning This variable is linked to allowed_video_codecs_description, @@ -53,7 +55,7 @@ const char* allowed_video_codecs[] = { "flv", "h263p", "huffyuv", "libtheora", "libx264", "libxvid", "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4", - "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", NULL + "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", "customvc", NULL }; //! Allowed video codecs description. @@ -77,6 +79,7 @@ const char* allowed_video_codecs_description[] = _("MPEG-4 part 2 Microsoft variant version 2."), _("Windows Media Video 7."), _("Windows Media Video 8."), + CUSTOM_VCODEC, NULL }; /* === P R O C E D U R E S ================================================= */ @@ -89,20 +92,38 @@ Dialog_TargetParam::Dialog_TargetParam(synfig::TargetParam &tparam) { set_title(_("TargetParam Dialog")); set_tparam(tparam); + // Custom Video Codec Entry + Gtk::Label* custom_label(manage(new Gtk::Label(CUSTOM_VCODEC))); + custom_label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); + get_vbox()->pack_start(*custom_label, true, true, 0); + customvcodec=Gtk::manage(new Gtk::Entry()); + get_vbox()->pack_start(*customvcodec, true, true, 0); // Available Video Codecs Combo Box Text. vcodec = Gtk::manage(new Gtk::ComboBoxText()); Gtk::Label* label(manage(new Gtk::Label(_("Available Video Codecs:")))); label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); get_vbox()->pack_start(*label, true, true, 0); + // Appends the codec descriptions to the Combo Box for (int i = 0; allowed_video_codecs[i] != NULL && allowed_video_codecs_description[i] != NULL; i++) vcodec->append_text(allowed_video_codecs_description[i]); + //Adds the Combo Box to the vertical box + get_vbox()->pack_start(*vcodec, true, true, 0); + // Connect the signal change to the handler + vcodec->signal_changed().connect(sigc::mem_fun(*this, &Dialog_TargetParam::on_vcodec_change)); + // By defaut, set the active text to the Custom Video Codec + vcodec->set_active_text(CUSTOM_VCODEC); + customvcodec->set_text("customvc"); + //Compare the passed vcodec to the available and set it active if found + bool foundvcodec=false; for (int i = 0; allowed_video_codecs[i] != NULL && allowed_video_codecs_description[i] != NULL; i++) if(!get_tparam().video_codec.compare(allowed_video_codecs[i])) + { vcodec->set_active_text(allowed_video_codecs_description[i]); - - get_vbox()->pack_start(*vcodec, true, true, 0); + customvcodec->set_text(allowed_video_codecs[i]); + foundvcodec = true; + } //Bitrate Spin Button Gtk::Adjustment* bradj(manage(new class Gtk::Adjustment(double(tparam.bitrate), 10.0,1000.0))); @@ -144,6 +165,16 @@ Dialog_TargetParam::on_cancel() hide(); } +void +Dialog_TargetParam::on_vcodec_change() +{ + std::string codecnamed = vcodec->get_active_text(); + for (int i = 0; allowed_video_codecs[i] != NULL && + allowed_video_codecs_description[i] != NULL; i++) + if(!codecnamed.compare(allowed_video_codecs_description[i])) + customvcodec->set_text(allowed_video_codecs[i]); +} + Dialog_TargetParam::~Dialog_TargetParam() { } diff --git a/synfig-studio/src/gtkmm/dialog_targetparam.h b/synfig-studio/src/gtkmm/dialog_targetparam.h index 8fa8cfb..f9a986c 100644 --- a/synfig-studio/src/gtkmm/dialog_targetparam.h +++ b/synfig-studio/src/gtkmm/dialog_targetparam.h @@ -48,9 +48,11 @@ class Dialog_TargetParam : public Gtk::Dialog Gtk::Button *cancel_button; Gtk::SpinButton *bitrate; Gtk::ComboBoxText *vcodec; + Gtk::Entry *customvcodec; void on_ok(); void on_cancel(); + void on_vcodec_change(); public: Dialog_TargetParam(synfig::TargetParam &tparam); -- 2.7.4