mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
Menu icons, gtk stock icons in toolbar
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9251 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3d9f2089dd
commit
6640822be5
@ -1,3 +1,10 @@
|
||||
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:
|
||||
|
@ -285,10 +285,10 @@ void GBox::updateInnerBoxCombo()
|
||||
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
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Huang Ying
|
||||
* \author John Spray
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -12,6 +13,10 @@
|
||||
|
||||
#include "GMenubar.h"
|
||||
#include "GView.h"
|
||||
#include "ghelpers.h"
|
||||
|
||||
#include "ToolbarBackend.h" // for getIcon
|
||||
|
||||
#include "debug.h"
|
||||
#include "lyxfunc.h"
|
||||
|
||||
@ -133,6 +138,11 @@ void GMenubar::onSubMenuActivate(MenuItem const * item,
|
||||
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();
|
||||
@ -168,10 +178,32 @@ void GMenubar::onSubMenuActivate(MenuItem const * item,
|
||||
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));
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Huang Ying
|
||||
* \author John Spray
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -13,6 +14,8 @@
|
||||
#include "GToolbar.h"
|
||||
#include "GView.h"
|
||||
|
||||
#include "ghelpers.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
#include "debug.h"
|
||||
@ -219,17 +222,26 @@ 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.
|
||||
@ -237,7 +249,6 @@ void GToolbar::add(FuncRequest const & func, string const & tooltip)
|
||||
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)));
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author John Spray
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -13,6 +14,7 @@
|
||||
#include "ghelpers.h"
|
||||
|
||||
#include "lyxrc.h"
|
||||
#include "funcrequest.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
@ -24,6 +26,44 @@ using std::vector;
|
||||
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) {
|
||||
|
@ -19,9 +19,15 @@
|
||||
#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,
|
||||
|
Loading…
Reference in New Issue
Block a user