[gnomemm] Why hot key dosen't work? Worry



I associated each menu in menubar a hotkey, but finally the hotkey dose not work.
I spent lots of time to find the reason but failed ...

Part oof the program
==========================================

void TreeApp::install_menus()
{
  accgrp = Gtk::AccelGroup::create();	
	
  Gtk::MenuBar *menubar = manage(new class Gtk::MenuBar());
  Gtk::MenuItem *figaro_pause;
  Gtk::MenuItem *figaro_resume;
  Gtk::MenuItem *figaro_stop;
  Gtk::MenuItem *figaro_close;
  Gtk::MenuItem *figaro_exit;
  Gtk::MenuItem *view_top;
  Gtk::MenuItem *view_last;
  Gtk::MenuItem *view_up;
  Gtk::MenuItem *view_separator_1;
  Gtk::MenuItem *zoom_to_fit;
  Gtk::MenuItem *separator3;
  Gtk::MenuItem *hide_unhide;
  Gtk::MenuItem *unhide_but_failed;
  Gtk::MenuItem *hide_all;
  Gtk::MenuItem *next_solution;
  Gtk::MenuItem *all_solution;
  Gtk::MenuItem *one_step;
  Gtk::MenuItem *menu;
  Gtk::MenuItem *about;
  Gtk::MenuItem *figaro;
  Gtk::MenuItem *view;
  Gtk::MenuItem *search;
  Gtk::MenuItem *help;
{ static GnomeUIInfo figaro_menu_uiinfo[] = { { GNOME_APP_UI_ITEM, N_("_Pause"), N_("pause the seaching engine"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_p, GDK_CONTROL_MASK, 0 }, { GNOME_APP_UI_ITEM, N_("_Resume"), N_("resume the searching engine"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_r, GDK_CONTROL_MASK, 0 }, { GNOME_APP_UI_ITEM, N_("_Stop"), N_("stop the searching engine"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_s, GDK_CONTROL_MASK, 0 },
	      GNOMEUIINFO_MENU_CLOSE_ITEM(0, 0),
	      GNOMEUIINFO_MENU_EXIT_ITEM(0, 0),
GNOMEUIINFO_END }; static GnomeUIInfo view_menu_uiinfo[] = { { GNOME_APP_UI_ITEM, N_("_Top"), N_("move to root"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_t, GDK_CONTROL_MASK, 0 }, { GNOME_APP_UI_ITEM, N_("_Last"), 0, 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_l, GDK_CONTROL_MASK, 0 }, { GNOME_APP_UI_ITEM, N_("_Up"), 0, 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_u, GDK_CONTROL_MASK, 0 }, GNOMEUIINFO_SEPARATOR, { GNOME_APP_UI_ITEM, N_("_Zoom to Fit"), N_("zoom to fit the window"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_z, GDK_CONTROL_MASK, 0 }, GNOMEUIINFO_SEPARATOR, { GNOME_APP_UI_ITEM, N_("_Hide/Unhide"), N_("hide/unhide the subtree"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_h, (GdkModifierType)0, 0 }, { GNOME_APP_UI_ITEM, N_("_Unhide but Failed"), 0, 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_u, (GdkModifierType)0, 0 }, { GNOME_APP_UI_ITEM, N_("Hide _All"), 0, 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_a, (GdkModifierType)0, 0 }, GNOMEUIINFO_END }; static GnomeUIInfo search_menu_uiinfo[] = { { GNOME_APP_UI_ITEM, N_("_Next Solution"), N_("find next solution"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_n, GDK_CONTROL_MASK, 0 }, { GNOME_APP_UI_ITEM, N_("_All Solution"), N_("find all solutions"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_a, GDK_CONTROL_MASK, 0 }, { GNOME_APP_UI_ITEM, N_("_One Step"), N_("search one step"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_o, GDK_CONTROL_MASK, 0 }, GNOMEUIINFO_END }; static GnomeUIInfo help_menu_uiinfo[] = { { GNOME_APP_UI_ITEM, N_("_Menu"), N_("read the menu of figaro"), 0, 0, 0, GNOME_APP_PIXMAP_NONE, 0, GDK_KP_F1, (GdkModifierType)0, 0 },
	      GNOMEUIINFO_MENU_ABOUT_ITEM(0, 0),
GNOMEUIINFO_END }; static GnomeUIInfo menubar_uiinfo[] = { { GNOME_APP_UI_SUBTREE, N_("_Figaro"), N_("figao main"), figaro_menu_uiinfo, 0, 0, GNOME_APP_PIXMAP_NONE, 0, 0, (GdkModifierType)0, 0 }, { GNOME_APP_UI_SUBTREE, N_("_View"), 0, view_menu_uiinfo, 0, 0, GNOME_APP_PIXMAP_NONE, 0, 0, (GdkModifierType)0, 0 }, { GNOME_APP_UI_SUBTREE, N_("_Search"), 0, search_menu_uiinfo, 0, 0,
			GNOME_APP_PIXMAP_NONE, 0,  0, (GdkModifierType)0, 0 },
{ GNOME_APP_UI_SUBTREE, N_("_Help"), 0, help_menu_uiinfo, 0, 0, GNOME_APP_PIXMAP_NONE, 0, 0, (GdkModifierType)0, 0 }, GNOMEUIINFO_END }; gnome_app_fill_menu(GTK_MENU_SHELL(menubar->gtkobj()), menubar_uiinfo, accgrp->gtkobj(), true, 0);
  //   gnome_app_create_menus(this->gtkobj(),menubar_uiinfo);
figaro_pause = Gtk::wrap(GTK_MENU_ITEM(figaro_menu_uiinfo[0].widget)); figaro_resume = Gtk::wrap(GTK_MENU_ITEM(figaro_menu_uiinfo[1].widget));
     figaro_stop = Gtk::wrap(GTK_MENU_ITEM(figaro_menu_uiinfo[2].widget));
figaro_close = Gtk::wrap(GTK_MENU_ITEM(figaro_menu_uiinfo[3].widget));
     figaro_exit = Gtk::wrap(GTK_MENU_ITEM(figaro_menu_uiinfo[4].widget));
     view_top = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[0].widget));
     view_last = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[1].widget));
     view_up = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[2].widget));
view_separator_1 = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[3].widget));
     zoom_to_fit = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[4].widget));
     separator3 = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[5].widget));
     hide_unhide = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[6].widget));
unhide_but_failed = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[7].widget));
     hide_all = Gtk::wrap(GTK_MENU_ITEM(view_menu_uiinfo[8].widget));
next_solution = Gtk::wrap(GTK_MENU_ITEM(search_menu_uiinfo[0].widget)); all_solution = Gtk::wrap(GTK_MENU_ITEM(search_menu_uiinfo[1].widget));
     one_step = Gtk::wrap(GTK_MENU_ITEM(search_menu_uiinfo[2].widget));
     menu = Gtk::wrap(GTK_MENU_ITEM(help_menu_uiinfo[0].widget));
     about = Gtk::wrap(GTK_MENU_ITEM(help_menu_uiinfo[1].widget));
gnome_app_install_menu_hints (GNOME_APP (this->gtkobj()), menubar_uiinfo);
  }
Gnome::DockItem *dockitem = manage(new class Gnome::DockItem("dockitem", GnomeDockItemBehavior
	
(GNOME_DOCK_ITEM_BEH_EXCLUSIVE|GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL|GNOME_DOCK_ITEM_BEH_LOCKED)));

menubar->set_shadow_type(GTK_SHADOW_NONE);
  dockitem->set_border_width(2);
  dockitem->set_shadow_type(GTK_SHADOW_OUT);
  dockitem->add(*menubar);
get_dock()->allow_floating_items(true);
  get_dock()->add_item(*dockitem, GNOME_DOCK_TOP, 0, 0, 0, false);
  set_modal(false);
  set_position(GTK_WIN_POS_NONE);
  add_accel_group(*accgrp);
  menubar->show();
  dockitem->show();
figaro_pause->activate.connect(SigC::slot(this, &TreeApp::on_figaro_pause_activate)); figaro_resume->activate.connect(SigC::slot(this, &TreeApp::on_figaro_resume_activate)); figaro_stop->activate.connect(SigC::slot(this, &TreeApp::on_figaro_stop_activate)); figaro_close->activate.connect(SigC::slot(this, &TreeApp::on_figaro_close_activate)); figaro_exit->activate.connect(SigC::slot(this, &TreeApp::on_figaro_exit_activate)); view_top->activate.connect(SigC::slot(this, &TreeApp::on_view_top_activate)); view_last->activate.connect(SigC::slot(this, &TreeApp::on_view_last_activate)); view_up->activate.connect(SigC::slot(this, &TreeApp::on_view_up_activate)); zoom_to_fit->activate.connect(SigC::slot(this, &TreeApp::on_zoom_to_fit_activate)); hide_unhide->activate.connect(SigC::slot(this, &TreeApp::on_hide_unhide_activate)); unhide_but_failed->activate.connect(SigC::slot(this, &TreeApp::on_unhide_but_failed_activate)); hide_all->activate.connect(SigC::slot(this, &TreeApp::on_hide_all_activate)); next_solution->activate.connect(SigC::slot(this, &TreeApp::on_next_solution_activate)); all_solution->activate.connect(SigC::slot(this, &TreeApp::on_all_solution_activate)); one_step->activate.connect(SigC::slot(this, &TreeApp::on_one_step_activate));
  menu->activate.connect(SigC::slot(this, &TreeApp::on_menu_activate));
  about->activate.connect(SigC::slot(this, &TreeApp::on_about_activate));
}

void TreeApp::install_toolbar()
{
Gtk::Toolbar *toolbar = manage(new class Gtk::Toolbar(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH)); Gnome::DockItem *dockitem = manage(new class Gnome::DockItem("dockitem",
			   GnomeDockItemBehavior(GNOME_DOCK_ITEM_BEH_EXCLUSIVE)));
toolbar->tools().push_back(Gtk::Toolbar_Helpers::ButtonElem(_("New"), *Gtk::wrap(gnome_stock_pixmap_widget(GTK_WIDGET(gtkobj()), GNOME_STOCK_PIXMAP_NEW)), 0)); Gtk::Button *button1 = static_cast<Gtk::Button *>(toolbar->tools().back()->get_widget()); toolbar->tools().push_back(Gtk::Toolbar_Helpers::ButtonElem(_("Open"), *Gtk::wrap(gnome_stock_pixmap_widget(GTK_WIDGET(gtkobj()), GNOME_STOCK_PIXMAP_OPEN)), 0)); Gtk::Button *button2 = static_cast<Gtk::Button *>(toolbar->tools().back()->get_widget()); toolbar->tools().push_back(Gtk::Toolbar_Helpers::ButtonElem(_("Save"), *Gtk::wrap(gnome_stock_pixmap_widget(GTK_WIDGET(gtkobj()), GNOME_STOCK_PIXMAP_SAVE)), 0)); Gtk::Button *button3 = static_cast<Gtk::Button *>(toolbar->tools().back()->get_widget()); _tooltips.set_tip(*button1, _("New File"), "");
  _tooltips.set_tip(*button2, _("Open File"), "");
  _tooltips.set_tip(*button3, _("Save File"), "");
  toolbar->set_border_width(1);
  toolbar->set_space_size(16);
  toolbar->set_tooltips(true);
  toolbar->set_button_relief(GTK_RELIEF_NONE);
get_dock()->add_item(*dockitem, GNOME_DOCK_TOP, 1, 0, 0, false);
  dockitem->show();
  toolbar->show();
}

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]