diff --git a/rtdata/images/menuSymbol.png b/rtdata/images/menuSymbol.png new file mode 100644 index 000000000..cee408a32 Binary files /dev/null and b/rtdata/images/menuSymbol.png differ diff --git a/rtgui/curveeditor.cc b/rtgui/curveeditor.cc index 6d2b6b11b..2ea495a37 100644 --- a/rtgui/curveeditor.cc +++ b/rtgui/curveeditor.cc @@ -40,11 +40,10 @@ CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup) { group = ceGroup; if (group && text.size()) - curveType = Gtk::manage (new PopUpToggleButton(text + ":", true)); + curveType = Gtk::manage (new PopUpToggleButton(text + ":")); else curveType = Gtk::manage (new PopUpToggleButton()); - curveType->set_image_position(Gtk::POS_RIGHT); // Order set in the same order than "enum CurveType". Shouldn't change, for compatibility reason curveType->addEntry(argv0+"/images/curveType-linear.png", M("CURVEEDITOR_LINEAR")); // 0 Linear curveType->addEntry(argv0+"/images/curveType-spline.png", M("CURVEEDITOR_CUSTOM")); // 1 Spline diff --git a/rtgui/curveeditorgroup.cc b/rtgui/curveeditorgroup.cc index f94800d70..051a36d23 100644 --- a/rtgui/curveeditorgroup.cc +++ b/rtgui/curveeditorgroup.cc @@ -210,7 +210,6 @@ void CurveEditorGroup::newLine() { curve_reset->signal_clicked().connect( sigc::mem_fun(*this, &CurveEditorGroup::curveResetPressed) ); headerBox->pack_end (*curve_reset, Gtk::PACK_SHRINK, 0); - curve_reset->signal_clicked().connect( sigc::mem_fun(*this, &CurveEditorGroup::curveResetPressed) ); } int j = numberOfPackedCurve; diff --git a/rtgui/popupbutton.cc b/rtgui/popupbutton.cc index bc201ce77..0ef2bfc95 100644 --- a/rtgui/popupbutton.cc +++ b/rtgui/popupbutton.cc @@ -28,10 +28,8 @@ * * Parameters: * label = label displayed in the button - * imRight = 0: the image is displayed at the left of the label (default) - * 1: the image is displayed at the right of the label */ -PopUpButton::PopUpButton (const Glib::ustring& label, bool imgRight) : Gtk::Button(), PopUpCommon(this, label, imgRight) { } +PopUpButton::PopUpButton (const Glib::ustring& label) : Gtk::Button(), PopUpCommon(this, label) { } void PopUpButton::show() { PopUpCommon::show(); diff --git a/rtgui/popupbutton.h b/rtgui/popupbutton.h index 3cf981a16..fbb1ef67a 100644 --- a/rtgui/popupbutton.h +++ b/rtgui/popupbutton.h @@ -27,7 +27,7 @@ class PopUpButton : public Gtk::Button, public PopUpCommon { public: - PopUpButton (const Glib::ustring& label = "", bool imgRight=false); + PopUpButton (const Glib::ustring& label = ""); void show (); void set_tooltip_text (const Glib::ustring &text); }; diff --git a/rtgui/popupcommon.cc b/rtgui/popupcommon.cc index ac8d40d7b..3f24e03ed 100644 --- a/rtgui/popupcommon.cc +++ b/rtgui/popupcommon.cc @@ -23,15 +23,18 @@ #include #include -PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label, bool imgRight) { +extern Glib::ustring argv0; + +PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label) { button = thisButton; hasMenu = false; + menuSymbol = 0; + imageContainer = Gtk::manage( new Gtk::HBox()); + button->add(*imageContainer); if (label.size()) { - hasText = true; - button->set_label(label + " "); + Gtk::Label* buttonLabel = Gtk::manage ( new Gtk::Label(label + " ") ); + imageContainer->pack_start(*buttonLabel, Gtk::PACK_SHRINK, 0); } - else - hasText = false; // Create the list entry imagePaths.clear(); images.clear(); @@ -41,7 +44,6 @@ PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label, b menu = 0; buttonImage = 0; buttonHint = ""; - imageRight = imgRight; // By default, image is on the left in the menu } PopUpCommon::~PopUpCommon () { @@ -54,6 +56,7 @@ PopUpCommon::~PopUpCommon () { delete *i; } if (menu) delete menu; + if (menuSymbol) delete menuSymbol; if (buttonImage) delete buttonImage; } @@ -79,13 +82,7 @@ bool PopUpCommon::addEntry (Glib::ustring imagePath, Glib::ustring label) { // Create the image for the button buttonImage = new Gtk::Image(imagePath); // Use the first image by default - if (hasText) { - button->set_image_position(imageRight ? Gtk::POS_RIGHT : Gtk::POS_LEFT); - button->set_image(*buttonImage); - } - else { - button->add(*buttonImage); - } + imageContainer->pack_start(*buttonImage,Gtk::PACK_EXPAND_WIDGET); selected = 0; } newItem->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &PopUpCommon::entrySelected), currPos-1)); @@ -93,6 +90,8 @@ bool PopUpCommon::addEntry (Glib::ustring imagePath, Glib::ustring label) { // When there is at least 2 choice, we add the RMB connector if (images.size() == 2) { button->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &PopUpCommon::showMenu) ); + menuSymbol = new Gtk::Image(safe_locale_from_utf8(argv0+"/images/menuSymbol.png")); + imageContainer->pack_start(*menuSymbol,Gtk::PACK_SHRINK, 2); hasMenu = true; } // The item has been created @@ -128,7 +127,7 @@ void PopUpCommon::show() { menu->reposition(); setButtonHint(); menu->show_all(); - button->show(); + button->show_all(); } void PopUpCommon::setButtonHint() { diff --git a/rtgui/popupcommon.h b/rtgui/popupcommon.h index 2a23c6d24..6bd8258f2 100644 --- a/rtgui/popupcommon.h +++ b/rtgui/popupcommon.h @@ -32,7 +32,7 @@ public: typedef sigc::signal type_signal_changed; type_signal_changed signal_changed(); - PopUpCommon (Gtk::Button* button, const Glib::ustring& label = "", bool imgRight=false); + PopUpCommon (Gtk::Button* button, const Glib::ustring& label = ""); ~PopUpCommon (); bool addEntry (Glib::ustring imagePath, Glib::ustring label); bool setSelected (int entryNum); @@ -54,11 +54,11 @@ private: std::vector items; Glib::ustring buttonHint; Gtk::Image* buttonImage; + Gtk::Image* menuSymbol; + Gtk::HBox* imageContainer; Gtk::Menu* menu; Gtk::Button* button; int selected; - bool hasText; - bool imageRight; bool hasMenu; void showMenu(GdkEventButton* event); diff --git a/rtgui/popuptogglebutton.cc b/rtgui/popuptogglebutton.cc index 27e0bff30..7a9051d26 100644 --- a/rtgui/popuptogglebutton.cc +++ b/rtgui/popuptogglebutton.cc @@ -28,10 +28,8 @@ * * Parameters: * label = label displayed in the button - * imRight = 0: the image is displayed at the left of the label (default) - * 1: the image is displayed at the right of the label */ -PopUpToggleButton::PopUpToggleButton (const Glib::ustring& label, bool imgRight) : Gtk::ToggleButton(), PopUpCommon(this, label, imgRight) { } +PopUpToggleButton::PopUpToggleButton (const Glib::ustring& label) : Gtk::ToggleButton(), PopUpCommon(this, label) { } void PopUpToggleButton::show() { PopUpCommon::show(); diff --git a/rtgui/popuptogglebutton.h b/rtgui/popuptogglebutton.h index bc18a888f..86f94e6c8 100644 --- a/rtgui/popuptogglebutton.h +++ b/rtgui/popuptogglebutton.h @@ -27,7 +27,7 @@ class PopUpToggleButton : public Gtk::ToggleButton, public PopUpCommon { public: - PopUpToggleButton (const Glib::ustring& label = "", bool imgRight=false); + PopUpToggleButton (const Glib::ustring& label = ""); void show (); void set_tooltip_text (const Glib::ustring &text); };