Skip to content
This repository has been archived by the owner on Jun 16, 2019. It is now read-only.

Commit

Permalink
Rebuild labels for menu items when detaching/attaching menus (which c…
Browse files Browse the repository at this point in the history
…auses the menus to loose them).

Fixes issue #66.
  • Loading branch information
mfn committed Jan 17, 2010
1 parent 47f9829 commit 1e91449
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions radiant/gtkmisc.cpp
Expand Up @@ -761,12 +761,23 @@ GtkWidget* menu_separator (GtkWidget *menu)
return menu_item;
}

/*
mfn: rebuild menu shown menu item bindings whenever a menu is
deatached/attached as it looses the values.
*/
static void tearoff_state_changed (GtkMenu *menu, GParamSpec *pspec, gpointer data)
{
g_pParentWnd->UpdateMenuItemBindings();
}

GtkWidget* menu_tearoff (GtkWidget *menu)
{
GtkWidget *menu_item = gtk_tearoff_menu_item_new ();
gtk_menu_append (GTK_MENU (menu), menu_item);
// gtk_widget_set_sensitive (menu_item, FALSE); -- controls whether menu is detachable
gtk_widget_show (menu_item);
// listen to this signal to rebuild the bindings shown to the menu items
g_signal_connect_after(menu, "notify::tearoff-state", G_CALLBACK(tearoff_state_changed), menu_item);
return menu_item;
}

Expand Down
14 changes: 14 additions & 0 deletions radiant/mainframe.cpp
Expand Up @@ -8079,7 +8079,21 @@ void MainFrame::OnFilterWorld()
Sys_UpdateWindows (W_XY|W_CAMERA);
}

/*
mfn: this is part of a workaround to have the bindings shown *after* a menu has been detached/attached.
Since ShowMenuItemKeyBindings() directly modified the access_label, this is information gets
lost when a menu is detached. In menu_tearoff() we listen to the notify::tearoff-state signal
and whenever it changes, this method gets called to rebuild them.
TODO: this rebuilds all bindings for all commands. Would be nice if it just updates the
bindings for the menu being detached/attached.
See also http://github.com/mfn/GtkRadiant/issues#issue/66 for more details.
*/
void MainFrame::UpdateMenuItemBindings()
{
ShowMenuItemKeyBindings(m_pWidget);
}



Expand Down
1 change: 1 addition & 0 deletions radiant/mainframe.h
Expand Up @@ -908,6 +908,7 @@ class MainFrame
void OnFilterClusterportals();
void OnFilterLightgrid();
void OnSelectFuncGroup();
void UpdateMenuItemBindings();

private:
EViewStyle m_nCurrentStyle;
Expand Down

0 comments on commit 1e91449

Please sign in to comment.