Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
26b2caf1
Kaydet (Commit)
26b2caf1
authored
Eyl 25, 2012
tarafından
Antonio Fernandez
Kaydeden (comit)
Bjoern Michaelsen
Kas 14, 2012
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Spare items and its actions are now removed.
Change-Id: Idb46b5dec4351e16c5c49a355c7d3cde3aab0789
üst
5178cabb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
25 deletions
+113
-25
gtksalmenu.hxx
vcl/inc/unx/gtk/gtksalmenu.hxx
+6
-7
gtksalmenu.cxx
vcl/unx/gtk/window/gtksalmenu.cxx
+107
-18
No files found.
vcl/inc/unx/gtk/gtksalmenu.hxx
Dosyayı görüntüle @
26b2caf1
...
@@ -24,15 +24,14 @@
...
@@ -24,15 +24,14 @@
#ifndef GTKSALMENU_HXX
#ifndef GTKSALMENU_HXX
#define GTKSALMENU_HXX
#define GTKSALMENU_HXX
#include <vcl/sv.h>
#include <vector>
#include <vcl/bitmap.hxx>
#include <unx/gtk/gtkframe.hxx>
#include <unx/salmenu.h>
#include <gio/gio.h>
#include <gio/gio.h>
#include "glomenu.h"
#include <unx/salmenu.h>
#include "gloactiongroup.h"
#include <unx/gtk/gtkframe.hxx>
#include <unx/gtk/glomenu.h>
#include <unx/gtk/gloactiongroup.h>
#include <vcl/sv.h>
class
MenuItemList
;
class
MenuItemList
;
...
...
vcl/unx/gtk/window/gtksalmenu.cxx
Dosyayı görüntüle @
26b2caf1
...
@@ -158,13 +158,94 @@ bool GtkSalMenu::PrepUpdate()
...
@@ -158,13 +158,94 @@ bool GtkSalMenu::PrepUpdate()
}
}
}
}
void
GtkSalMenu
::
UpdateNativeMenu
(
)
/*
* Menu updating methods
*/
void
RemoveSpareItemsFromNativeMenu
(
GLOMenu
*
pMenu
,
GList
**
pOldCommandList
,
unsigned
nSection
,
unsigned
nValidItems
)
{
sal_Int32
nSectionItems
=
g_lo_menu_get_n_items_from_section
(
pMenu
,
nSection
);
while
(
nSectionItems
>
(
sal_Int32
)
nValidItems
)
{
gchar
*
aCommand
=
g_lo_menu_get_command_from_item_in_section
(
pMenu
,
nSection
,
--
nSectionItems
);
if
(
aCommand
!=
NULL
&&
pOldCommandList
!=
NULL
)
*
pOldCommandList
=
g_list_append
(
*
pOldCommandList
,
g_strdup
(
aCommand
)
);
g_free
(
aCommand
);
g_lo_menu_remove_from_section
(
pMenu
,
nSection
,
nSectionItems
);
}
}
void
RemoveSpareSectionsFromNativeMenu
(
GLOMenu
*
pMenu
,
GList
**
pOldCommandList
,
unsigned
nLastSection
)
{
if
(
pMenu
==
NULL
||
pOldCommandList
==
NULL
)
return
;
sal_Int32
n
=
g_menu_model_get_n_items
(
G_MENU_MODEL
(
pMenu
)
)
-
1
;
for
(
;
n
>
(
sal_Int32
)
nLastSection
;
n
--
)
{
RemoveSpareItemsFromNativeMenu
(
pMenu
,
pOldCommandList
,
n
,
0
);
g_lo_menu_remove
(
pMenu
,
n
);
}
}
gint
CompareStr
(
gpointer
str1
,
gpointer
str2
)
{
return
g_strcmp0
(
(
const
gchar
*
)
str1
,
(
const
gchar
*
)
str2
);
}
void
RemoveUnusedCommands
(
GLOActionGroup
*
pActionGroup
,
GList
*
pOldCommandList
,
GList
*
pNewCommandList
)
{
if
(
pActionGroup
==
NULL
||
pOldCommandList
==
NULL
)
return
;
while
(
pNewCommandList
!=
NULL
)
{
GList
*
pNewCommand
=
g_list_first
(
pNewCommandList
);
pNewCommandList
=
g_list_remove_link
(
pNewCommandList
,
pNewCommand
);
gpointer
aCommand
=
g_list_nth_data
(
pNewCommand
,
0
);
GList
*
pOldCommand
=
g_list_find_custom
(
pOldCommandList
,
aCommand
,
(
GCompareFunc
)
CompareStr
);
if
(
pOldCommand
!=
NULL
)
{
pOldCommandList
=
g_list_remove_link
(
pOldCommandList
,
pOldCommand
);
g_list_free_full
(
pOldCommand
,
g_free
);
}
g_list_free_full
(
pNewCommand
,
g_free
);
}
while
(
pOldCommandList
!=
NULL
)
{
GList
*
pCommand
=
g_list_first
(
pOldCommandList
);
pOldCommandList
=
g_list_remove_link
(
pOldCommandList
,
pCommand
);
gchar
*
aCommand
=
(
gchar
*
)
g_list_nth_data
(
pCommand
,
0
);
g_lo_action_group_remove
(
pActionGroup
,
aCommand
);
g_list_free_full
(
pCommand
,
g_free
);
}
}
static
void
UpdateNativeSubMenu
(
GtkSalMenu
*
pMenu
)
{
{
if
(
!
PrepUpdate
())
if
(
!
PrepUpdate
())
return
;
return
;
Menu
*
pVCLMenu
=
GetMenu
();
GLOMenu
*
pLOMenu
=
G_LO_MENU
(
GetMenuModel
()
);
// SolarMutexGuard aGuard;
GActionGroup
*
pActionGroup
=
GetActionGroup
();
Menu
*
pVCLMenu
=
pMenu
->
GetMenu
();
GLOMenu
*
pLOMenu
=
G_LO_MENU
(
pMenu
->
GetMenuModel
()
);
GLOActionGroup
*
pActionGroup
=
G_LO_ACTION_GROUP
(
pMenu
->
GetActionGroup
()
);
GList
*
pOldCommandList
=
NULL
;
GList
*
pNewCommandList
=
NULL
;
sal_uInt16
nLOMenuSize
=
g_menu_model_get_n_items
(
G_MENU_MODEL
(
pLOMenu
)
);
sal_uInt16
nLOMenuSize
=
g_menu_model_get_n_items
(
G_MENU_MODEL
(
pLOMenu
)
);
...
@@ -186,11 +267,7 @@ void GtkSalMenu::UpdateNativeMenu( )
...
@@ -186,11 +267,7 @@ void GtkSalMenu::UpdateNativeMenu( )
if
(
pSalMenuItem
->
mnType
==
MENUITEM_SEPARATOR
)
if
(
pSalMenuItem
->
mnType
==
MENUITEM_SEPARATOR
)
{
{
// Delete extra items from current section.
// Delete extra items from current section.
sal_uInt16
nSectionItems
=
g_lo_menu_get_n_items_from_section
(
pLOMenu
,
nSection
);
RemoveSpareItemsFromNativeMenu
(
pLOMenu
,
&
pOldCommandList
,
nSection
,
validItems
);
while
(
nSectionItems
>
validItems
)
// FIXME Remove associated command if needed.
g_lo_menu_remove_from_section
(
pLOMenu
,
nSection
,
--
nSectionItems
);
nSection
++
;
nSection
++
;
nItemPos
=
0
;
nItemPos
=
0
;
...
@@ -221,6 +298,12 @@ void GtkSalMenu::UpdateNativeMenu( )
...
@@ -221,6 +298,12 @@ void GtkSalMenu::UpdateNativeMenu( )
gboolean
bEnabled
=
(
itemEnabled
==
sal_True
)
?
TRUE
:
FALSE
;
gboolean
bEnabled
=
(
itemEnabled
==
sal_True
)
?
TRUE
:
FALSE
;
gchar
*
aNativeCommand
=
g_strdup
(
rtl
::
OUStringToOString
(
aCommand
,
RTL_TEXTENCODING_UTF8
).
getStr
()
);
gchar
*
aNativeCommand
=
g_strdup
(
rtl
::
OUStringToOString
(
aCommand
,
RTL_TEXTENCODING_UTF8
).
getStr
()
);
// Store current item command in command list.
gchar
*
aCurrentCommand
=
g_lo_menu_get_command_from_item_in_section
(
pLOMenu
,
nSection
,
nItemPos
);
if
(
aCurrentCommand
!=
NULL
)
pOldCommandList
=
g_list_append
(
pOldCommandList
,
aCurrentCommand
);
// Force updating of native menu labels.
// Force updating of native menu labels.
NativeSetItemText
(
nSection
,
nItemPos
,
aText
);
NativeSetItemText
(
nSection
,
nItemPos
,
aText
);
NativeSetAccelerator
(
nSection
,
nItemPos
,
nAccelKey
,
nAccelKey
.
GetName
(
GetFrame
()
->
GetWindow
()
)
);
NativeSetAccelerator
(
nSection
,
nItemPos
,
nAccelKey
,
nAccelKey
.
GetName
(
GetFrame
()
->
GetWindow
()
)
);
...
@@ -242,6 +325,8 @@ void GtkSalMenu::UpdateNativeMenu( )
...
@@ -242,6 +325,8 @@ void GtkSalMenu::UpdateNativeMenu( )
NativeSetItemCommand
(
nSection
,
nItemPos
,
nId
,
aNativeCommand
,
itemBits
,
bChecked
,
FALSE
);
NativeSetItemCommand
(
nSection
,
nItemPos
,
nId
,
aNativeCommand
,
itemBits
,
bChecked
,
FALSE
);
NativeCheckItem
(
nSection
,
nItemPos
,
itemBits
,
bChecked
);
NativeCheckItem
(
nSection
,
nItemPos
,
itemBits
,
bChecked
);
NativeSetEnableItem
(
aNativeCommand
,
bEnabled
);
NativeSetEnableItem
(
aNativeCommand
,
bEnabled
);
pNewCommandList
=
g_list_append
(
pNewCommandList
,
g_strdup
(
aNativeCommand
)
);
}
}
GtkSalMenu
*
pSubmenu
=
pSalMenuItem
->
mpSubMenu
;
GtkSalMenu
*
pSubmenu
=
pSalMenuItem
->
mpSubMenu
;
...
@@ -250,6 +335,10 @@ void GtkSalMenu::UpdateNativeMenu( )
...
@@ -250,6 +335,10 @@ void GtkSalMenu::UpdateNativeMenu( )
if
(
pSubmenu
&&
pSubmenu
->
GetMenu
()
)
if
(
pSubmenu
&&
pSubmenu
->
GetMenu
()
)
{
{
NativeSetItemCommand
(
nSection
,
nItemPos
,
nId
,
aNativeCommand
,
itemBits
,
FALSE
,
TRUE
);
NativeSetItemCommand
(
nSection
,
nItemPos
,
nId
,
aNativeCommand
,
itemBits
,
FALSE
,
TRUE
);
pNewCommandList
=
g_list_append
(
pNewCommandList
,
g_strdup
(
aNativeCommand
)
);
GLOMenu
*
pSubMenuModel
=
g_lo_menu_get_submenu_from_item_in_section
(
pLOMenu
,
nSection
,
nItemPos
);
if
(
pSubMenuModel
==
NULL
)
if
(
pSubMenuModel
==
NULL
)
{
{
pSubMenuModel
=
g_lo_menu_new
();
pSubMenuModel
=
g_lo_menu_new
();
...
@@ -285,15 +374,13 @@ void GtkSalMenu::UpdateNativeMenu( )
...
@@ -285,15 +374,13 @@ void GtkSalMenu::UpdateNativeMenu( )
}
}
// Delete extra items in last section.
// Delete extra items in last section.
sal_Int32
nSectionItems
=
(
sal_Int32
)
g_lo_menu_get_n_items_from_section
(
pLOMenu
,
nSection
);
RemoveSpareItemsFromNativeMenu
(
pLOMenu
,
&
pOldCommandList
,
nSection
,
validItems
);
while
(
nSectionItems
>
validItems
)
g_lo_menu_remove_from_section
(
pLOMenu
,
nSection
,
--
nSectionItems
);
// Delete extra sections.
// Delete extra sections.
for
(
sal_Int32
n
=
nLOMenuSize
-
1
;
n
>
nSection
;
)
RemoveSpareSectionsFromNativeMenu
(
pLOMenu
,
&
pOldCommandList
,
nSection
);
// FIXME Remove associated command if needed.
g_lo_menu_remove
(
pLOMenu
,
n
--
);
// Delete unused commands.
RemoveUnusedCommands
(
pActionGroup
,
pOldCommandList
,
pNewCommandList
);
}
}
void
GtkSalMenu
::
DisconnectFrame
()
void
GtkSalMenu
::
DisconnectFrame
()
...
@@ -607,7 +694,8 @@ void GtkSalMenu::Activate( const gchar* aMenuCommand )
...
@@ -607,7 +694,8 @@ void GtkSalMenu::Activate( const gchar* aMenuCommand )
GtkSalMenu
*
pSalSubMenu
=
GetMenuForItemCommand
(
(
gchar
*
)
aMenuCommand
,
TRUE
);
GtkSalMenu
*
pSalSubMenu
=
GetMenuForItemCommand
(
(
gchar
*
)
aMenuCommand
,
TRUE
);
if
(
pSalSubMenu
!=
NULL
)
{
if
(
pSalSubMenu
!=
NULL
)
{
pSalSubMenu
->
mpVCLMenu
->
Activate
();
MenuBar
*
pMenuBar
=
static_cast
<
MenuBar
*
>
(
mpVCLMenu
);
pMenuBar
->
HandleMenuActivateEvent
(
pSalSubMenu
->
mpVCLMenu
);
pSalSubMenu
->
UpdateNativeMenu
();
pSalSubMenu
->
UpdateNativeMenu
();
}
}
}
}
...
@@ -620,7 +708,8 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
...
@@ -620,7 +708,8 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
GtkSalMenu
*
pSalSubMenu
=
GetMenuForItemCommand
(
(
gchar
*
)
aMenuCommand
,
TRUE
);
GtkSalMenu
*
pSalSubMenu
=
GetMenuForItemCommand
(
(
gchar
*
)
aMenuCommand
,
TRUE
);
if
(
pSalSubMenu
!=
NULL
)
{
if
(
pSalSubMenu
!=
NULL
)
{
pSalSubMenu
->
mpVCLMenu
->
Deactivate
();
MenuBar
*
pMenuBar
=
static_cast
<
MenuBar
*
>
(
mpVCLMenu
);
pMenuBar
->
HandleMenuDeActivateEvent
(
pSalSubMenu
->
mpVCLMenu
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment