[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - 2 commits - sc/source vcl/inc vcl/unx

Caolán McNamara caolanm at redhat.com
Mon Jun 20 08:07:36 UTC 2016


 sc/source/ui/view/gridwin.cxx  |    3 ---
 vcl/inc/unx/gtk/glomenu.h      |   10 ++++++++++
 vcl/inc/unx/gtk/gtksalmenu.hxx |    1 +
 vcl/unx/gtk/glomenu.cxx        |   37 +++++++++++++++++++++++++++++++++++++
 vcl/unx/gtk/gtksalmenu.cxx     |   32 ++++++++++++++++++++++++++++++++
 5 files changed, 80 insertions(+), 3 deletions(-)

New commits:
commit 5bbee0969965b2f92288d87c48aaa4b1d95af569
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jun 19 17:42:56 2016 +0100

    Resolves: tdf#99310 data validity cell range dropdown empty under windows
    
    if I make this block unconditional then it also disappears under Linux
    so I speculate that this is why its missing under Windows.
    
    I can't see why this is the way it is (since initial import in 2000),
    
    This is reportedly a problem since
    
    commit dd46727b99d4bb5135451aa7e5e1bdb197373843
    Author: Caolán McNamara <caolanm at redhat.com>
    Date:   Tue Apr 5 15:27:38 2016 +0100
    
        Resolves; tdf#87120 no keyboard navigation inside floating windows
    
    (cherry picked from commit c3a5012c5a9699040698505d3e34672382c026b8)
    
    Change-Id: I6159d419bccef851c8f9e965d063882173d91620

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index f106884..fa62d3f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -283,9 +283,6 @@ void ScFilterListBox::EndInit()
 
 void ScFilterListBox::LoseFocus()
 {
-#ifndef UNX
-    Hide();
-#endif
     vcl::Window::LoseFocus();
 }
 
commit 497cb8bd5b4fa58ce01abb5359e894ae810c412d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 17 21:15:20 2016 +0100

    Resolve: tdf#100429 gtk3: set custom icons in native gtk menus
    
    Change-Id: I4798274f38c34c99d6f22f3c7959ebd9673a8966
    (cherry picked from commit 1409b974003ca69e4682507f5d34c55f346b864a)

diff --git a/vcl/inc/unx/gtk/glomenu.h b/vcl/inc/unx/gtk/glomenu.h
index b2ed606..5586aa4 100644
--- a/vcl/inc/unx/gtk/glomenu.h
+++ b/vcl/inc/unx/gtk/glomenu.h
@@ -69,11 +69,21 @@ void        g_lo_menu_set_label                                         (GLOMenu
                                                                          gint         position,
                                                                          const gchar *label);
 
+void        g_lo_menu_set_icon                                         (GLOMenu     *menu,
+                                                                        gint         position,
+                                                                        const GIcon *icon);
+
+
 void        g_lo_menu_set_label_to_item_in_section                      (GLOMenu     *menu,
                                                                          gint         section,
                                                                          gint         position,
                                                                          const gchar *label);
 
+void        g_lo_menu_set_icon_to_item_in_section                      (GLOMenu     *menu,
+                                                                        gint         section,
+                                                                        gint         position,
+                                                                        const GIcon *icon);
+
 gchar *     g_lo_menu_get_label_from_item_in_section                    (GLOMenu     *menu,
                                                                          gint         section,
                                                                          gint         position);
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index ad3e1d9..90fcb7d 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -93,6 +93,7 @@ public:
     bool                        IsItemVisible( unsigned nPos );
 
     void                        NativeSetItemText( unsigned nSection, unsigned nItemPos, const OUString& rText );
+    void                        NativeSetItemIcon( unsigned nSection, unsigned nItemPos, const Image& rImage );
     bool                        NativeSetItemCommand( unsigned nSection,
                                                       unsigned nItemPos,
                                                       sal_uInt16 nId,
diff --git a/vcl/unx/gtk/glomenu.cxx b/vcl/unx/gtk/glomenu.cxx
index bf2b701..ffa43e5 100644
--- a/vcl/unx/gtk/glomenu.cxx
+++ b/vcl/unx/gtk/glomenu.cxx
@@ -229,6 +229,23 @@ g_lo_menu_set_label (GLOMenu     *menu,
 }
 
 void
+g_lo_menu_set_icon (GLOMenu     *menu,
+                    gint         position,
+                    const GIcon *icon)
+{
+    g_return_if_fail (G_IS_LO_MENU (menu));
+
+    GVariant *value;
+
+    if (icon != nullptr)
+        value = g_icon_serialize (const_cast<GIcon*>(icon));
+    else
+        value = nullptr;
+
+    g_lo_menu_set_attribute_value (menu, position, G_MENU_ATTRIBUTE_ICON, value);
+}
+
+void
 g_lo_menu_set_label_to_item_in_section (GLOMenu     *menu,
                                         gint         section,
                                         gint         position,
@@ -248,6 +265,26 @@ g_lo_menu_set_label_to_item_in_section (GLOMenu     *menu,
     g_object_unref (model);
 }
 
+void
+g_lo_menu_set_icon_to_item_in_section (GLOMenu     *menu,
+                                       gint         section,
+                                       gint         position,
+                                       const GIcon *icon)
+{
+    g_return_if_fail (G_IS_LO_MENU (menu));
+
+    GLOMenu *model = g_lo_menu_get_section (menu, section);
+
+    g_return_if_fail (model != nullptr);
+
+    g_lo_menu_set_icon (model, position, icon);
+
+    // Notify the update.
+    g_menu_model_items_changed (G_MENU_MODEL (model), position, 1, 1);
+
+    g_object_unref (model);
+}
+
 gchar *
 g_lo_menu_get_label_from_item_in_section (GLOMenu *menu,
                                           gint     section,
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 40b6052..c981265 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -18,6 +18,7 @@
 #include <unx/gtk/gloactiongroup.h>
 #include <vcl/floatwin.hxx>
 #include <vcl/menu.hxx>
+#include <vcl/pngwrite.hxx>
 #include <unx/gtk/gtkinst.hxx>
 
 #if GTK_CHECK_VERSION(3,0,0)
@@ -236,6 +237,7 @@ void GtkSalMenu::ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries)
 
         // Get internal menu item values.
         OUString aText = pVCLMenu->GetItemText( nId );
+        Image aImage = pVCLMenu->GetItemImage( nId );
         bool bEnabled = pVCLMenu->IsItemEnabled( nId );
         vcl::KeyCode nAccelKey = pVCLMenu->GetAccelKey( nId );
         bool bChecked = pVCLMenu->IsItemChecked( nId );
@@ -252,6 +254,8 @@ void GtkSalMenu::ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries)
 
         // Force updating of native menu labels.
         NativeSetItemText( nSection, nItemPos, aText );
+        if (!!aImage)
+            NativeSetItemIcon( nSection, nItemPos, aImage );
         NativeSetAccelerator( nSection, nItemPos, nAccelKey, nAccelKey.GetName( GetFrame()->GetWindow() ) );
 
         if ( g_strcmp0( aNativeCommand, "" ) != 0 && pSalMenuItem->mpSubMenu == nullptr )
@@ -844,6 +848,34 @@ void GtkSalMenu::NativeSetItemText( unsigned nSection, unsigned nItemPos, const
         g_free( aLabel );
 }
 
+namespace
+{
+    void DestroyMemoryStream(gpointer data)
+    {
+        SvMemoryStream* pMemStm = static_cast<SvMemoryStream*>(data);
+        delete pMemStm;
+    }
+}
+
+void GtkSalMenu::NativeSetItemIcon( unsigned nSection, unsigned nItemPos, const Image& rImage )
+{
+    SolarMutexGuard aGuard;
+
+    SvMemoryStream* pMemStm = new SvMemoryStream;
+    vcl::PNGWriter aWriter(rImage.GetBitmapEx());
+    aWriter.Write(*pMemStm);
+
+    GBytes *pBytes = g_bytes_new_with_free_func(pMemStm->GetData(),
+                                                pMemStm->Seek(STREAM_SEEK_TO_END),
+                                                DestroyMemoryStream,
+                                                pMemStm);
+
+    GIcon *pIcon = g_bytes_icon_new(pBytes);
+    g_lo_menu_set_icon_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, pIcon );
+    g_object_unref(pIcon);
+    g_bytes_unref(pBytes);
+}
+
 void GtkSalMenu::NativeSetAccelerator( unsigned nSection, unsigned nItemPos, const vcl::KeyCode& rKeyCode, const OUString& rKeyName )
 {
     SolarMutexGuard aGuard;


More information about the Libreoffice-commits mailing list