spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit 51c8b6fcc07085c509f02c8b6a9f87de6aab637d
parent a058390b3f2620a3154f604e180fcd7d13d6d540
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Tue, 19 Apr 2011 21:09:24 +0800

osx: Move the main menu to where it belongs

Also fix rigth click → Quit (issue 24) and the ⌘ Q shortcut (issue 44).

Diffstat:
Msrc/spek-platform.c | 16+++++++++++++++-
Msrc/spek-platform.h | 5++++-
Msrc/spek-window.vala | 2++
Mvapi/spek-platform.vapi | 1+
4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/spek-platform.c b/src/spek-platform.c @@ -34,7 +34,7 @@ void spek_platform_init () { #ifdef G_OS_DARWIN - GtkOSXApplication *app = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL); + g_object_new (GTK_TYPE_OSX_APPLICATION, NULL); #endif } @@ -65,6 +65,20 @@ void spek_platform_fix_args (gchar **argv, gint argc) { #endif } +void spek_platform_fix_ui (GtkUIManager *ui) +{ +#ifdef G_OS_DARWIN + GtkOSXApplication *app = NULL; + GtkWidget *menubar = NULL; + + app = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL); + menubar = gtk_ui_manager_get_widget (ui, "/MenuBar"); + gtk_widget_hide (menubar); + gtk_osxapplication_set_menu_bar (app, GTK_MENU_SHELL (menubar)); + gtk_osxapplication_ready (app); +#endif +} + void spek_platform_show_uri (const gchar *uri) { #ifdef G_OS_WIN32 /* gtk_show_uri doesn't work on Windows... */ diff --git a/src/spek-platform.h b/src/spek-platform.h @@ -19,7 +19,7 @@ #ifndef __SPEK_PLATFORM_H__ #define __SPEK_PLATFORM_H__ -#include <glib.h> +#include <gtk/gtk.h> /* Platform-specific initialisation */ void spek_platform_init (); @@ -27,6 +27,9 @@ void spek_platform_init (); /* Convert from UTF-16 to UTF-8 when running on Windows */ void spek_platform_fix_args (gchar **argv, gint argc); +/* OSX has its own approach to menu bars */ +void spek_platform_fix_ui (GtkUIManager *ui); + /* Open a link in the browser */ void spek_platform_show_uri (const gchar *uri); diff --git a/src/spek-window.vala b/src/spek-window.vala @@ -123,6 +123,8 @@ namespace Spek { toolbar.show_all (); spectrogram.show_all (); vbox.show (); + + Platform.fix_ui (ui); show (); // Set up Drag and Drop diff --git a/vapi/spek-platform.vapi b/vapi/spek-platform.vapi @@ -2,6 +2,7 @@ namespace Spek.Platform { public static void init (); public static void fix_args (string[] args); + public static void fix_ui (Gtk.UIManager ui); public static void show_uri (string uri); public static string read_line (string uri); public static double get_font_scale ();