+2004-11-15 John Spray <spray_john@users.sourceforge.net>
+
+ * ghelpers.[Ch]: getGTKStockIcon added to choose gtk
+ stock icons for FuncRequests
+ * GToolbar.C: use getGTKStockIcon for toolbutton icons
+ * GMenubar.C: add icons to menu items
+
2004-11-14 John Spray <spray_john@users.sourceforge.net>
* The ERT dialog:
innerboxcombo_->set_active(i);
} else {
// we're not changing the liststore, just selecting i
- if (!frameless)
- innerboxcombo_->set_active(i);
if (frameless)
innerboxcombo_->set_active(i - 1);
+ else
+ innerboxcombo_->set_active(i);
}
// Update the width units list if we've changed inner box type
* 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 "GMenubar.h"
#include "GView.h"
+#include "ghelpers.h"
+
+#include "ToolbarBackend.h" // for getIcon
+
#include "debug.h"
#include "lyxfunc.h"
item->submenu() :
&menubackend.getMenu(item->submenuname());
+ // Choose size for icons on command items
+ int iconwidth = 16;
+ int iconheight = 16;
+ Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, iconwidth, iconheight);
+
menubackend.expand(*fmenu, lyxmenu->getBackMenu(), view_);
Menu::const_iterator i = lyxmenu->getBackMenu().begin();
Menu::const_iterator end = lyxmenu->getBackMenu().end();
gmenu->items().back());
citem.set_active(on);
} else {
- // This is necessary because add_accel_label is protected,
+ // 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 {
+ Glib::ustring xpmName =
+ Glib::locale_to_utf8(toolbarbackend.getIcon(i->func()));
+ if (xpmName.find("unknown.xpm") == -1) {
+ // Load icon and shrink it for menu size
+ Glib::RefPtr<Gdk::Pixbuf> bigicon =
+ Gdk::Pixbuf::create_from_file(xpmName);
+ Glib::RefPtr<Gdk::Pixbuf> smallicon =
+ bigicon->scale_simple(iconwidth,iconheight,Gdk::INTERP_TILES);
+ image = Gtk::manage(new Gtk::Image(smallicon));
+ }
+ }
+
+ Gtk::ImageMenuItem * item = Gtk::manage(new Gtk::ImageMenuItem);
+ if (image)
+ item->set_image(*image);
+
+ // This hbox is necessary because add_accel_label is protected,
// and even if you subclass Gtk::MenuItem then add_accel_label
// doesn't do what you'd expect.
- Gtk::MenuItem * item = Gtk::manage(new Gtk::MenuItem);
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox);
Gtk::Label * label1 = Gtk::manage(new Gtk::Label(
labelTrans(i->label(), i->shortcut()), true));
* 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 "GToolbar.h"
#include "GView.h"
+#include "ghelpers.h"
+
#include "buffer.h"
#include "bufferparams.h"
#include "debug.h"
}
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.
reinterpret_cast<void*>(&const_cast<FuncRequest &>(func)));
toolbutton->set_tooltip(*toolbar_.get_tooltips_object(),tip);
- /*toolbar_.get_tooltips_object()->set_tip(*toolbutton, tip);*/
toolbutton->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this,
>oolbar::clicked), FuncRequest(func)));
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
+ * \author John Spray
*
* Full author contact details are available in file CREDITS.
*/
#include "ghelpers.h"
#include "lyxrc.h"
+#include "funcrequest.h"
#include "debug.h"
#include "support/filetools.h"
namespace lyx {
namespace frontend {
+Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func)
+{
+ switch (func.action) {
+
+ case LFUN_MENUWRITE: return Gtk::Stock::SAVE;
+ case LFUN_MENUNEW: return Gtk::Stock::NEW;
+ case LFUN_WRITEAS: return Gtk::Stock::SAVE_AS;
+
+ case LFUN_CENTER: return Gtk::Stock::JUSTIFY_CENTER;
+ case LFUN_TOCVIEW: return Gtk::Stock::INDEX;
+ case LFUN_CLOSEBUFFER: return Gtk::Stock::CLOSE;
+ case LFUN_QUIT: return Gtk::Stock::QUIT;
+ case LFUN_UNDO: return Gtk::Stock::UNDO;
+ case LFUN_REDO: return Gtk::Stock::REDO;
+ case LFUN_PASTE: return Gtk::Stock::PASTE;
+ case LFUN_PASTESELECTION: return Gtk::Stock::PASTE;
+ case LFUN_CUT: return Gtk::Stock::CUT;
+ case LFUN_COPY: return Gtk::Stock::COPY;
+ case LFUN_BOLD: return Gtk::Stock::BOLD;
+ case LFUN_ITAL: return Gtk::Stock::ITALIC;
+ case LFUN_FILE_OPEN: return Gtk::Stock::OPEN;
+ case LFUN_RECONFIGURE: return Gtk::Stock::REFRESH;
+ case LFUN_DIALOG_SHOW:
+ if (func.argument == "findreplace")
+ return Gtk::Stock::FIND_AND_REPLACE;
+ else if (func.argument == "print")
+ return Gtk::Stock::PRINT;
+ else if (func.argument == "spellchecker")
+ return Gtk::Stock::SPELL_CHECK;
+ else if (func.argument == "prefs")
+ return Gtk::Stock::PREFERENCES;
+ else
+ return Gtk::Stock::MISSING_IMAGE;
+ break;
+ default: return Gtk::Stock::MISSING_IMAGE;
+ }
+}
+
string const getDefaultUnit()
{
switch (lyxrc.default_papersize) {
#include <string>
#include <vector>
+class FuncRequest;
+
namespace lyx {
namespace frontend {
+// 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);
+
std::string const getDefaultUnit();
void unitsComboFromLength(Gtk::ComboBox * combo,