On Wed, 2004-09-29 at 15:31, Angus Leeming wrote:

> You don't check "!symname.empty()", so this is unsafe.
Thanks.

Revised patch attached.

> Also, why not:
> 
>         string buf;
>         if (mod & key_modifier::shift)
>                 buf = "Shift+";
>         if (mod & key_modifier::ctrl)
>                 buf = "Ctrl+";
>         if (mod & key_modifier::alt)
>                 buf = "Alt+";

Because of "Ctrl+Shift+N".

> Incidentally, whilst all these dialogs are nice, you should see how 
> the Gtk frontend looks with multiple toolbars activated. Try changing 
> lib/ui/default.ui to
I should probably explain my reasoning for the order in which I'm doing
things.

> and then whince at what Gtk does with it. Even the XForms frontend 
> makes a better job of things.
I don't get it.  See what it looks like for me:
http://icculus.org/~jcspray/lyx-gtk.png

Note that my GView.C is different to yours, with a single (yet critical)
false instead of a true.  Patch attached for you to try out if you like.

John
Index: GLyXKeySym.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/gtk/GLyXKeySym.C,v
retrieving revision 1.5
diff -u -3 -p -r1.5 GLyXKeySym.C
--- GLyXKeySym.C	2004/09/26 18:36:07	1.5
+++ GLyXKeySym.C	2004/09/29 15:36:32
@@ -13,6 +13,8 @@
 #include "GLyXKeySym.h"
 #include "kbmap.h"
 
+#include "support/lstrings.h"
+
 #include <gtkmm.h>
 #include <gdk/gdkkeysyms.h>
 
@@ -94,9 +96,27 @@ char GLyXKeySym::getISOEncoded(string co
 }
 
 
+//Produce a human readable version (eg "Ctrl+N")
 string const GLyXKeySym::print(key_modifier::state mod) const
 {
-	return kb_keymap::printKeySym(*this, mod);
+	string buf;
+
+	if (mod & key_modifier::ctrl)
+		buf += "Ctrl+";
+	if (mod & key_modifier::shift)
+		buf += "Shift+";
+	if (mod & key_modifier::alt)
+		buf += "Alt+";
+
+	//Uppercase the first letter, for Ctrl+N rather than Ctrl+n,
+	//and for Ctrl+Greater rather than Ctrl+GREATER
+	string symname = getSymbolName();
+  if (!symname.empty()) {
+	  symname[0] = lyx::support::uppercase(symname[0]);
+	  buf += symname;
+	}
+
+	return buf;
 }
 
 
Index: GMenubar.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/gtk/GMenubar.C,v
retrieving revision 1.14
diff -u -3 -p -r1.14 GMenubar.C
--- GMenubar.C	2004/09/26 18:36:07	1.14
+++ GMenubar.C	2004/09/29 15:36:32
@@ -180,9 +180,6 @@ void GMenubar::onSubMenuActivate(MenuIte
 			break;
 		case MenuItem::Command:
 		{
-#ifdef WITH_WARNINGS
-#warning Bindings are not inserted into the menu labels here. (Lgb)
-#endif
 			FuncStatus const flag =
 				view_->getLyXFunc().getStatus(i->func());
 			bool on = flag.onoff(true);
@@ -198,10 +195,21 @@ void GMenubar::onSubMenuActivate(MenuIte
 						gmenu->items().back());
 				citem.set_active(on);
 			} else {
-				gmenu->items().push_back(
-					Gtk::Menu_Helpers::MenuElem(
-						labelTrans(i->label(),
-							   i->shortcut())));
+				//This 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));
+				Gtk::Label * label2 = Gtk::manage(new Gtk::Label(
+					"   " + i->binding(), false));
+				hbox->pack_start(*label1, false, false, 0);
+				hbox->pack_end(*label2, false, false, 0);
+				item->add(*hbox);
+
+				gmenu->append(*item);
+				item->show_all();
 			}
 			Gtk::MenuItem & item = gmenu->items().back();
 			item.signal_activate().connect(
Index: GView.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/gtk/GView.C,v
retrieving revision 1.17
diff -u -3 -p -r1.17 GView.C
--- GView.C	2004/09/27 19:04:17	1.17
+++ GView.C	2004/09/29 15:45:42
@@ -47,19 +47,19 @@ void add_el(Gtk::Box::BoxList & list, Gt
 GView::GView()
 {
 	// The physical store for the boxes making up the layout.
-	box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
-	box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
-	box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
-	box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
-	box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
-	box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
+	box_store_.push_back(BoxPtr(new Gtk::VBox));
+	box_store_.push_back(BoxPtr(new Gtk::HBox));
+	box_store_.push_back(BoxPtr(new Gtk::VBox));
+	box_store_.push_back(BoxPtr(new Gtk::HBox));
+	box_store_.push_back(BoxPtr(new Gtk::HBox));
+	box_store_.push_back(BoxPtr(new Gtk::HBox));
 
 	// Lay them out correctly.
 	add(top_box_);
 
 	Gtk::Box::BoxList & layout1 = top_box_.children();
 	add_el(layout1, *box_store_[0], true);
-	add_el(layout1, *box_store_[1], true);
+	add_el(layout1, *box_store_[1], false);
 	add_el(layout1, *box_store_[2], true);
 
 	Gtk::Box::BoxList & layout2 = box_store_[1]->children();
@@ -88,7 +88,7 @@ GView::GView()
 		boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
 	view_state_changed.connect(boost::bind(&GView::showViewState, this));
 	signal_focus_in_event().connect(sigc::mem_fun(*this, &GView::onFocusIn));
-	set_default_size(500, 550);
+	set_default_size(620, 550);
 	// Make sure the buttons are disabled if needed.
 	updateToolbars();
 	string const iconName =

Reply via email to