]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gtk/GToolbar.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / gtk / GToolbar.C
index 3cc6df480a044ec2790ed1d9fa26573bdce254de..081dacb489df861f99aa389d7245261bdb8fa134 100644 (file)
@@ -4,15 +4,23 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Huang Ying
+ * \author John Spray
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
+// Too hard to make concept checks work with this file
+#ifdef _GLIBCPP_CONCEPT_CHECKS
+#undef _GLIBCPP_CONCEPT_CHECKS
+#endif
+
 #include "GToolbar.h"
 #include "GView.h"
 
+#include "ghelpers.h"
+
 #include "buffer.h"
 #include "bufferparams.h"
 #include "debug.h"
@@ -66,9 +74,9 @@ GLayoutBox::GLayoutBox(LyXView & owner,
        combo_.pack_start(*cell, true);
        combo_.add_attribute(*cell,"text",0);
        combo_.set_wrap_width(2);
-       //Initially there's nothing in the liststore, so set the size
-       //to avoid it jumping too much when the user does something that
-       //causes the first update()
+       // Initially there's nothing in the liststore, so set the size
+       // to avoid it jumping too much when the user does something that
+       // causes the first update()
        combo_.set_size_request(130,-1);
 
 
@@ -123,8 +131,8 @@ void GLayoutBox::update()
                }
        internal_ = false;
 
-       //now that we've loaded something into the combobox, forget
-       //the initial fixed size and let GTK decide.
+       // now that we've loaded something into the combobox, forget
+       // the initial fixed size and let GTK decide.
        combo_.set_size_request(-1,-1);
 }
 
@@ -156,24 +164,11 @@ void GLayoutBox::selected()
 
        Glib::ustring layoutGuiName = (*(combo_.get_active()))[cols_.name];
 
-       // we get two signal, one of it is empty and useless
+       // we get two signal, one of them is empty and useless
        if (layoutGuiName.empty())
                return;
-       LyXTextClass const & tc = getTextClass(owner_);
 
-       LyXTextClass::const_iterator it = tc.begin();
-       LyXTextClass::const_iterator const end = tc.end();
-       for (; it != end; ++it) {
-               string const & name = (*it)->name();
-               if (name == layoutGuiName) {
-                       owner_.getLyXFunc().dispatch(
-                               FuncRequest(LFUN_LAYOUT, name),
-                               true);
-                       return;
-               }
-       }
-       lyxerr << "ERROR (GLayoutBox::selected): layout not found! name: "
-              << layoutGuiName << std::endl;
+       layoutSelected(owner_, layoutGuiName);
 }
 
 } // namespace frontend
@@ -209,7 +204,7 @@ GToolbar::GToolbar(ToolbarBackend::Toolbar const & tbb, LyXView & owner)
        owner_.getBox(position).children().push_back(
                Gtk::Box_Helpers::Element(toolbar_, Gtk::PACK_SHRINK));
 
-       tooltips_.enable();
+       toolbar_.set_tooltips(true);
 }
 
 void GToolbar::add(FuncRequest const & func, string const & tooltip)
@@ -232,23 +227,34 @@ void GToolbar::add(FuncRequest const & func, string const & tooltip)
        }
 
        default: {
-               Glib::ustring xpmName =
-                       Glib::locale_to_utf8(toolbarbackend.getIcon(func));
+               // choose an icon from the funcrequest
+               Gtk::BuiltinStockID stockID = getGTKStockIcon(func);
+
                Glib::ustring tip = Glib::locale_to_utf8(tooltip);
+
                Gtk::ToolButton * toolbutton;
-               if (xpmName.size() == 0) {
-                       toolbutton = Gtk::manage(new Gtk::ToolButton);
+               if (stockID != Gtk::Stock::MISSING_IMAGE) {
+                       // Prefer stock gtk graphics
+                       Gtk::IconSize size(Gtk::ICON_SIZE_LARGE_TOOLBAR);
+                       Gtk::Image * image = Gtk::manage(new Gtk::Image(stockID, size));
+                       image->show();
+                       toolbutton = Gtk::manage(new Gtk::ToolButton(*image));
                } else {
+                       Glib::ustring xpmName =
+                               Glib::locale_to_utf8(toolbarbackend.getIcon(func));
                        Gtk::Image * image = Gtk::manage(new Gtk::Image(xpmName));
                        image->show();
                        toolbutton = Gtk::manage(new Gtk::ToolButton(*image));
                }
+
                // This code is putting a function reference into the GObject data field
                // named gToolData.  That's how we know how to update the status of the
                // toolitem later.
                toolbutton->set_data(gToolData,
                        reinterpret_cast<void*>(&const_cast<FuncRequest &>(func)));
-               tooltips_.set_tip(*toolbutton, tip, tip);
+
+               toolbutton->set_tooltip(*toolbar_.get_tooltips_object(),tip);
+
                toolbutton->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this,
                        &GToolbar::clicked), FuncRequest(func)));
                toolbar_.append(*toolbutton);
@@ -261,7 +267,7 @@ void GToolbar::add(FuncRequest const & func, string const & tooltip)
 
 void GToolbar::clicked(FuncRequest func)
 {
-       owner_.getLyXFunc().dispatch(func, true);
+       owner_.getLyXFunc().dispatch(func);
 }