map MenuToggleButton to GtkToggleButton with a custom menu property

we don't have non-menu ToggleButtons yet, so thats not done here.

since we first started with GtkPushButton:menu_attrib to indicate
menubuttons gtk has grown menu buttons, but they don't have the
idea of a gtktogglemenu button, so this attribute still has a role
to play I guess

Change-Id: Iebfe5ccf996e22784cf9aaf2bcf367eed79ae686
This commit is contained in:
Caolán McNamara
2016-06-23 14:31:18 +01:00
parent 3881fffe42
commit 1413c5d39a
2 changed files with 29 additions and 2 deletions

View File

@@ -171,7 +171,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="open_recent:clearmenu">
<object class="GtkToggleButton" id="open_recent:clearmenu">
<property name="label" translatable="yes">_Recent Files</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -190,7 +190,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="templates_all:filtermenu">
<object class="GtkToggleButton" id="templates_all:filtermenu">
<property name="label" translatable="yes">T_emplates</property>
<property name="visible">True</property>
<property name="can_focus">True</property>

View File

@@ -942,6 +942,22 @@ namespace
return xWindow;
}
VclPtr<Button> extractStockAndBuildMenuToggleButton(vcl::Window *pParent, VclBuilder::stringmap &rMap)
{
WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK;
nBits |= extractRelief(rMap);
VclPtr<Button> xWindow = VclPtr<MenuToggleButton>::Create(pParent, nBits);
if (extractStock(rMap))
{
xWindow->SetText(getStockText(extractLabel(rMap)));
}
return xWindow;
}
OString extractUnit(const OString& sPattern)
{
OString sUnit(sPattern);
@@ -1370,6 +1386,17 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
setupFromActionName(xButton, rMap, m_xFrame);
xWindow = xButton;
}
else if (name == "GtkToggleButton")
{
VclPtr<Button> xButton;
OString sMenu = extractCustomProperty(rMap);
assert(sMenu.getLength() && "not implemented yet");
xButton = extractStockAndBuildMenuToggleButton(pParent, rMap);
m_pParserState->m_aButtonMenuMaps.push_back(ButtonMenuMap(id, sMenu));
xButton->SetImageAlign(ImageAlign::Left); //default to left
setupFromActionName(xButton, rMap, m_xFrame);
xWindow = xButton;
}
else if (name == "GtkRadioButton")
{
extractGroup(id, rMap);