[gtk+] Make app menu fallback a bit more reliable



commit f3d22d2a9be9573fafef74cae8d43729145c6147
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 13 01:19:12 2013 -0500

    Make app menu fallback a bit more reliable
    
    If the theme has no 'menu' control in the window decorations,
    show the menubar after all.

 gtk/gtkheaderbar.c        |   17 +++++++++++++++--
 gtk/gtkheaderbarprivate.h |    2 +-
 gtk/gtkwindow.c           |    2 +-
 3 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 70a77d7..9964f12 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -486,11 +486,24 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
 }
 
 gboolean
-_gtk_header_bar_get_shows_app_menu (GtkHeaderBar *bar)
+_gtk_header_bar_shows_app_menu (GtkHeaderBar *bar)
 {
   GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
+  GtkWindow *window;
+  gchar *layout_desc;
+  gboolean ret;
+
+  window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (bar)));
+  gtk_widget_style_get (GTK_WIDGET (window),
+                        "decoration-button-layout", &layout_desc,
+                        NULL);
+
+  ret = priv->shows_wm_decorations &&
+        (layout_desc && strstr (layout_desc, "menu"));
+
+  g_free (layout_desc);
 
-  return (priv->titlebar_menu_button != NULL);
+  return ret;
 }
 
 static void
diff --git a/gtk/gtkheaderbarprivate.h b/gtk/gtkheaderbarprivate.h
index 58cd3bb..66c5433 100644
--- a/gtk/gtkheaderbarprivate.h
+++ b/gtk/gtkheaderbarprivate.h
@@ -20,7 +20,7 @@
 #ifndef __GTK_HEADER_BAR_PRIVATE_H__
 #define __GTK_HEADER_BAR_PRIVATE_H__
 
-gboolean     _gtk_header_bar_get_shows_app_menu    (GtkHeaderBar *bar);
+gboolean     _gtk_header_bar_shows_app_menu        (GtkHeaderBar *bar);
 void         _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar);
 gboolean     _gtk_header_bar_update_window_icon    (GtkHeaderBar *bar,
                                                     GtkWindow    *window);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 66e2fd3..92b8f7e 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3619,7 +3619,7 @@ _gtk_window_titlebar_shows_app_menu (GtkWindow *window)
   GtkWindowPrivate *priv = window->priv;
 
   if (GTK_IS_HEADER_BAR (priv->title_box))
-    return gtk_header_bar_get_show_close_button (GTK_HEADER_BAR (priv->title_box));
+    return _gtk_header_bar_shows_app_menu (GTK_HEADER_BAR (priv->title_box));
 
   return FALSE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]