[gtk] headerbar: Fix fallback appmenu
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] headerbar: Fix fallback appmenu
- Date: Thu, 13 Jun 2019 19:59:11 +0000 (UTC)
commit f1fe54f337453fa58b081690368d5931b5b777a0
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 13 19:31:48 2019 +0000
headerbar: Fix fallback appmenu
We were using menubuttons here in a way that
does not work anymore. Make it work again.
gtk/gtkheaderbar.c | 3 ++-
gtk/gtkmenubutton.c | 14 ++++++++++++++
gtk/gtkmenubuttonprivate.h | 3 +++
gtk/theme/Adwaita/_common.scss | 10 +++++++++-
4 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 41bc434189..35553835a8 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -37,6 +37,7 @@
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
#include "gtknative.h"
+#include "gtkmenubuttonprivate.h"
#include "a11y/gtkcontaineraccessible.h"
@@ -388,7 +389,7 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
gtk_style_context_add_class (gtk_widget_get_style_context (button), "titlebutton");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "appmenu");
image = gtk_image_new ();
- gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_menu_button_add_child (GTK_MENU_BUTTON (button), image);
gtk_widget_set_can_focus (button, FALSE);
accessible = gtk_widget_get_accessible (button);
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index c4813ebbc7..f3a6742ae3 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -1434,3 +1434,17 @@ gtk_menu_button_popdown (GtkMenuButton *menu_button)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
}
+
+void
+gtk_menu_button_add_child (GtkMenuButton *menu_button,
+ GtkWidget *new_child)
+{
+ GtkMenuButtonPrivate *priv = gtk_menu_button_get_instance_private (menu_button);
+ GtkWidget *child;
+
+ child = gtk_bin_get_child (GTK_BIN (priv->button));
+ if (child)
+ gtk_container_remove (GTK_CONTAINER (priv->button), child);
+
+ gtk_container_add (GTK_CONTAINER (priv->button), new_child);
+}
diff --git a/gtk/gtkmenubuttonprivate.h b/gtk/gtkmenubuttonprivate.h
index 982ad2bdf9..85114c3318 100644
--- a/gtk/gtkmenubuttonprivate.h
+++ b/gtk/gtkmenubuttonprivate.h
@@ -32,6 +32,9 @@ void _gtk_menu_button_set_popup_with_func (GtkMenuButton *
GtkMenuButtonShowMenuCallback func,
gpointer user_data);
+void gtk_menu_button_add_child (GtkMenuButton *button,
+ GtkWidget *child);
+
G_END_DECLS
#endif /* __GTK_MENU_BUTTON_PRIVATE_H__ */
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index 8bb956bd05..86b7d3e92a 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -1657,12 +1657,20 @@ headerbar {
min-height: 28px;
padding: 4px;
- button.titlebutton {
+ button.titlebutton,
+ menubutton.titlebutton {
min-height: 26px;
min-width: 26px;
margin: 0;
padding: 0;
}
+
+ menubutton.titlebutton button {
+ min-height: 20px;
+ min-width: 20px;
+ margin: 0;
+ padding: 4px;
+ }
}
separator.titlebutton { opacity: 0; } /* hide the close button separator */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]