2006-02-12 John Spray <spray@lyx.org>
* GMenubar.C: assume backend strings in latin1 (bug 1954)
+ * GDocument.C, GtkLengthEntry.C: replace comboBoxTextSet with
+ Gtk::ComboBoxText::set_active_text
+ * ghelpers.[Ch]: remove comboBoxTextSet, rearrange GTK icon
+ lookup code in preparation for using icon themes.
+ * GMenubar.C, GToolbar.C: use the new icon lookup function
2006-02-12 Bartek Kostrzewa <bartek@runbox.com>
* GMenubar.C: Fix crash with navigation submenus
extraoptionsentry_->set_text(params.options);
// Postscript driver
- comboBoxTextSet(psdrivercombo_, params.graphicsDriver);
+ psdrivercombo_.set_active_text (params.graphicsDriver);
// Font & Size
- comboBoxTextSet(fontcombo_, params.fonts);
- comboBoxTextSet(fontsizecombo_, params.fontsize);
+ fontcombo_.set_active_text (params.fonts);
+ fontsizecombo_.set_active_text (params.fontsize);
// Line Spacing
linespacingadj_->set_value(params.spacing().getValue());
doublesidedtoggle_->set_active(params.sides == LyXTextClass::TwoSides);
- comboBoxTextSet(pagestylecombo_, params.pagestyle);
+ pagestylecombo_.set_active_text (params.pagestyle);
// *** End "Page" Page ***
defaultmargins_->set_active(!params.use_geometry);
for (int n = 0; !token(fontsizeitems, '|', n).empty(); ++n)
fontsizecombo_.append_text(token(fontsizeitems, '|', n));
- comboBoxTextSet(fontsizecombo_, params.fontsize);
+ fontsizecombo_.set_active_text (params.fontsize);
pagestylecombo_.clear();
pagestylecombo_.append_text("default");
for (int n=0; !token(pagestyleitems,'|',n).empty(); ++n)
pagestylecombo_.append_text(token(pagestyleitems,'|',n));
- comboBoxTextSet(pagestylecombo_, params.pagestyle);
+ pagestylecombo_.set_active_text (params.pagestyle);
}
} else {
classcombo_.set_active(params.textclass);
checkitem.set_active(on);
} else {
// Choose an icon from the funcrequest
- Gtk::BuiltinStockID stockID = getGTKStockIcon(i->func());
- Gtk::Image * image = NULL;
- // Prefer stock graphics
- if (stockID != Gtk::Stock::MISSING_IMAGE) {
- image = Gtk::manage(new Gtk::Image(stockID, Gtk::ICON_SIZE_MENU));
- } else {
+ Gtk::Image * image = getGTKIcon(i->func(), Gtk::ICON_SIZE_MENU);
+ if (!image) {
Glib::ustring xpmName =
Glib::locale_to_utf8(toolbarbackend.getIcon(i->func()));
if (xpmName.find("unknown.xpm") == Glib::ustring::npos) {
}
default: {
- // choose an icon from the funcrequest
- Gtk::BuiltinStockID stockID = getGTKStockIcon(func);
-
Glib::ustring tip = Glib::locale_to_utf8(tooltip);
Gtk::ToolButton * 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 {
+ Gtk::Image * image = NULL;
+ image = getGTKIcon(func, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ if (!image) {
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));
+ if (xpmName.find("unknown.xpm") == Glib::ustring::npos) {
+ 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.
if (unit.empty())
unit = getDefaultUnit();
- comboBoxTextSet(combo,unit);
+ combo.set_active_text (unit);
}
#include "support/filetools.h"
#include "support/package.h"
+#include "gtkmm/icontheme.h"
+
#include <sstream>
using std::string;
namespace lyx {
namespace frontend {
-// This function should be replaced by Gtk::ComboBoxText::set_active_text
-// Which was introduced in gtkmm 2.6
-int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target)
-{
- int const children = combo.get_model()->children().size();
- for (int i = 0; i < children; i++) {
- combo.set_active(i);
- if (combo.get_active_text() == target)
- return 0;
- }
- return -1;
-}
-
-
+// Get a GTK stockID from a lyx function id.
+// Return Gtk::Stock::MISSING_IMAGE if no suitable stock found
Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func)
{
switch (func.action) {
}
+Gtk::Image *getGTKIcon(FuncRequest const & func, Gtk::IconSize const & size)
+{
+ /*static Glib::RefPtr<Gtk::IconTheme> theme;
+ if (!theme)
+ theme = Gtk::IconTheme::get_default();*/
+
+ Gtk::Image *image = NULL;
+
+ Gtk::BuiltinStockID const stockID = getGTKStockIcon(func);
+ if (stockID != Gtk::Stock::MISSING_IMAGE) {
+ // Prefer stock gtk graphics
+ image = Gtk::manage(new Gtk::Image(stockID, size));
+ } else {
+ /*if (func.action == LFUN_MENUNEW) {
+ std::cerr << "Looking for icon\n";
+ std::vector<Glib::ustring> icons = theme->list_icons("mimetypes");
+ for (std::vector<Glib::ustring>::iterator it = icons.begin(); it != icons.end(); ++it) {
+ std::cerr << (*it) << "\n";
+ }
+ std::vector<Glib::ustring> paths = theme->get_search_path();
+ for (std::vector<Glib::ustring>::iterator it = paths.begin(); it != paths.end(); ++it) {
+ std::cerr << (*it) << "\n";
+ }
+ std::cerr << theme->get_example_icon_name() << "\n";
+ if (theme->has_icon("table-center")) {
+ std::cerr << "Found icon\n";
+ Glib::RefPtr<Gdk::Pixbuf> pbuf = theme->load_icon("table-center", 64, Gtk::ICON_LOOKUP_USE_BUILTIN);
+ image = Gtk::manage(new Gtk::Image(pbuf));
+ }
+ }*/
+ }
+
+ return image;
+}
+
+
string const getDefaultUnit()
{
switch (lyxrc.default_papersize) {
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
+ * \author John Spray
*
* Full author contact details are available in file CREDITS.
*/
namespace lyx {
namespace frontend {
-int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target);
-
-// Get a GTK stockID from a lyx function id.
-// Return Gtk::Stock::MISSING_IMAGE if no suitable stock found
-Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func);
+// Load an icon from GTK icon theme
+// Return NULL if no suitable icon found
+Gtk::Image *getGTKIcon(FuncRequest const & func, Gtk::IconSize const & size);
std::string const getDefaultUnit();