[Libreoffice-commits] core.git: sfx2/uiconfig vcl/source

Caolán McNamara caolanm at redhat.com
Thu Jun 23 13:33:16 UTC 2016


 sfx2/uiconfig/ui/startcenter.ui |    4 ++--
 vcl/source/window/builder.cxx   |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit 1413c5d39a45329b47c85511a3161c6f5a43c4f8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 23 14:31:18 2016 +0100

    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

diff --git a/sfx2/uiconfig/ui/startcenter.ui b/sfx2/uiconfig/ui/startcenter.ui
index 68ab548..79b1484 100644
--- a/sfx2/uiconfig/ui/startcenter.ui
+++ b/sfx2/uiconfig/ui/startcenter.ui
@@ -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>
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index fc8069e..2f1fd3d 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -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);


More information about the Libreoffice-commits mailing list