Kaydet (Commit) 4f4f7464 authored tarafından Caolán McNamara's avatar Caolán McNamara

tdf#116290 allow menubar to shrink past its minimum size

with a scrolledwindow with a horizontal external policy which doesn't
show a scrollbar, but allows the scrolledwindow to shrink past its
child size

Change-Id: Ia73fc819a16bef49008e7e41bcc2d523c28268b0
Reviewed-on: https://gerrit.libreoffice.org/65171
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst d856ba77
...@@ -55,6 +55,7 @@ private: ...@@ -55,6 +55,7 @@ private:
bool mbReturnFocusToDocument; bool mbReturnFocusToDocument;
bool mbAddedGrab; bool mbAddedGrab;
GtkWidget* mpMenuBarContainerWidget; GtkWidget* mpMenuBarContainerWidget;
GtkWidget* mpMenuAllowShrinkWidget;
GtkWidget* mpMenuBarWidget; GtkWidget* mpMenuBarWidget;
GtkWidget* mpCloseButton; GtkWidget* mpCloseButton;
VclPtr<Menu> mpVCLMenu; VclPtr<Menu> mpVCLMenu;
......
...@@ -528,6 +528,7 @@ GtkSalMenu::GtkSalMenu( bool bMenuBar ) : ...@@ -528,6 +528,7 @@ GtkSalMenu::GtkSalMenu( bool bMenuBar ) :
mbReturnFocusToDocument( false ), mbReturnFocusToDocument( false ),
mbAddedGrab( false ), mbAddedGrab( false ),
mpMenuBarContainerWidget( nullptr ), mpMenuBarContainerWidget( nullptr ),
mpMenuAllowShrinkWidget( nullptr ),
mpMenuBarWidget( nullptr ), mpMenuBarWidget( nullptr ),
mpCloseButton( nullptr ), mpCloseButton( nullptr ),
mpVCLMenu( nullptr ), mpVCLMenu( nullptr ),
...@@ -815,10 +816,21 @@ void GtkSalMenu::CreateMenuBarWidget() ...@@ -815,10 +816,21 @@ void GtkSalMenu::CreateMenuBarWidget()
gtk_grid_insert_row(pGrid, 0); gtk_grid_insert_row(pGrid, 0);
gtk_grid_attach(pGrid, mpMenuBarContainerWidget, 0, 0, 1, 1); gtk_grid_attach(pGrid, mpMenuBarContainerWidget, 0, 0, 1, 1);
mpMenuAllowShrinkWidget = gtk_scrolled_window_new(nullptr, nullptr);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(mpMenuAllowShrinkWidget), GTK_SHADOW_NONE);
// tdf#116290 external policy on scrolledwindow will not show a scrollbar,
// but still allow scrolled window to not be sized to the child content.
// So the menubar can be shrunk past its nominal smallest width.
// Unlike a hack using GtkFixed/GtkLayout the correct placement of the menubar occurs under RTL
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(mpMenuAllowShrinkWidget), GTK_POLICY_EXTERNAL, GTK_POLICY_NEVER);
gtk_grid_attach(GTK_GRID(mpMenuBarContainerWidget), mpMenuAllowShrinkWidget, 0, 0, 1, 1);
mpMenuBarWidget = gtk_menu_bar_new_from_model(mpMenuModel); mpMenuBarWidget = gtk_menu_bar_new_from_model(mpMenuModel);
gtk_widget_insert_action_group(mpMenuBarWidget, "win", mpActionGroup); gtk_widget_insert_action_group(mpMenuBarWidget, "win", mpActionGroup);
gtk_widget_set_hexpand(GTK_WIDGET(mpMenuBarWidget), true); gtk_widget_set_hexpand(GTK_WIDGET(mpMenuBarWidget), true);
gtk_grid_attach(GTK_GRID(mpMenuBarContainerWidget), mpMenuBarWidget, 0, 0, 1, 1); gtk_widget_set_hexpand(mpMenuAllowShrinkWidget, true);
gtk_container_add(GTK_CONTAINER(mpMenuAllowShrinkWidget), mpMenuBarWidget);
g_signal_connect(G_OBJECT(mpMenuBarWidget), "deactivate", G_CALLBACK(MenuBarReturnFocus), this); g_signal_connect(G_OBJECT(mpMenuBarWidget), "deactivate", G_CALLBACK(MenuBarReturnFocus), this);
g_signal_connect(G_OBJECT(mpMenuBarWidget), "key-press-event", G_CALLBACK(MenuBarSignalKey), this); g_signal_connect(G_OBJECT(mpMenuBarWidget), "key-press-event", G_CALLBACK(MenuBarSignalKey), this);
...@@ -826,6 +838,7 @@ void GtkSalMenu::CreateMenuBarWidget() ...@@ -826,6 +838,7 @@ void GtkSalMenu::CreateMenuBarWidget()
ShowCloseButton( static_cast<MenuBar*>(mpVCLMenu.get())->HasCloseButton() ); ShowCloseButton( static_cast<MenuBar*>(mpVCLMenu.get())->HasCloseButton() );
#else #else
(void)mpMenuAllowShrinkWidget;
(void)mpMenuBarContainerWidget; (void)mpMenuBarContainerWidget;
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment