summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-08-17 02:48:24 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-08-17 02:48:24 +0000
commit54d00408c3a1d36899fdd8b4f085aa2a2946009e (patch)
tree9bfa7a6827ef1a815ff969717d8b8dcfdeba6673 /libs/gtkmm2ext
parentf5c4c8a2931f383c76212ea1cfdb6f85f43bb72f (diff)
forward port 2.X changes up to and including rev 6842
git-svn-id: svn://localhost/ardour2/branches/3.0@7637 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/application.cc84
-rw-r--r--libs/gtkmm2ext/gtk_ui.cc26
-rw-r--r--libs/gtkmm2ext/gtkapplication_quartz.mm32
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/application.h63
-rw-r--r--libs/gtkmm2ext/wscript1
5 files changed, 180 insertions, 26 deletions
diff --git a/libs/gtkmm2ext/application.cc b/libs/gtkmm2ext/application.cc
new file mode 100644
index 0000000000..54efb4773f
--- /dev/null
+++ b/libs/gtkmm2ext/application.cc
@@ -0,0 +1,84 @@
+/* GTK+ Integration with platform-specific application-wide features
+ * such as the OS X menubar and application delegate concepts.
+ *
+ * Copyright (C) 2007 Pioneer Research Center USA, Inc.
+ * Copyright (C) 2007 Imendio AB
+ * Copyright (C) 2009 Paul Davis
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1
+ * of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtkmm/menushell.h>
+#include <gtkmm/menuitem.h>
+
+#include "gtkmm2ext/application.h"
+#include "gtkmm2ext/gtkapplication.h"
+
+using namespace Gtk;
+using namespace Gtkmm2ext;
+
+Application* Application::_instance = 0;
+
+Application*
+Application::instance ()
+{
+ if (!_instance) {
+ _instance = new Application;
+ }
+ return _instance;
+}
+
+Application::Application ()
+{
+ gtk_application_init ();
+}
+
+Application::~Application ()
+{
+ _instance = 0;
+ gtk_application_cleanup ();
+}
+
+void
+Application::ready ()
+{
+ gtk_application_ready ();
+}
+
+void
+Application::cleanup ()
+{
+ gtk_application_cleanup ();
+}
+
+void
+Application::set_menu_bar (MenuShell& shell)
+{
+ gtk_application_set_menu_bar (shell.gobj());
+}
+
+GtkApplicationMenuGroup*
+Application::add_app_menu_group ()
+{
+ return gtk_application_add_app_menu_group ();
+}
+
+void
+Application::add_app_menu_item (GtkApplicationMenuGroup* group,
+ MenuItem* item)
+{
+ gtk_application_add_app_menu_item (group, item->gobj());
+}
diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc
index 456b8e29c8..d1ef1e27c4 100644
--- a/libs/gtkmm2ext/gtk_ui.cc
+++ b/libs/gtkmm2ext/gtk_ui.cc
@@ -33,6 +33,7 @@
#include <pbd/pthread_utils.h>
#include <pbd/stacktrace.h>
+#include <gtkmm2ext/application.h>
#include <gtkmm2ext/gtk_ui.h>
#include <gtkmm2ext/textviewer.h>
#include <gtkmm2ext/popup.h>
@@ -107,6 +108,10 @@ UI::UI (string namestr, int *argc, char ***argv)
errors->set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY);
//load_rcfile (rcfile);
+
+ /* instantiate the Application singleton */
+
+ Application::instance();
}
UI::~UI ()
@@ -633,31 +638,10 @@ UI::popup_error (const string& text)
pup->touch ();
}
-#ifdef GTKOSX
-extern "C" {
- int gdk_quartz_in_carbon_menu_event_handler ();
-}
-#endif
void
UI::flush_pending ()
{
-#ifdef GTKOSX
- /* as of february 11th 2008, gtk/osx has a problem in that mac menu events
- are handled using Carbon with an "internal" event handling system that
- doesn't pass things back to the glib/gtk main loop. this makes
- gtk_main_iteration() block if we call it while in a menu event handler
- because glib gets confused and thinks there are two threads running
- g_main_poll_func().
-
- this hack (relies on code in gtk2_ardour/sync-menu.c) works
- around that.
- */
-
- if (gdk_quartz_in_carbon_menu_event_handler()) {
- return;
- }
-#endif
if (!caller_is_ui_thread()) {
error << "non-UI threads cannot call UI::flush_pending()"
<< endmsg;
diff --git a/libs/gtkmm2ext/gtkapplication_quartz.mm b/libs/gtkmm2ext/gtkapplication_quartz.mm
index b6d6b71d5d..c5fb8b12e2 100644
--- a/libs/gtkmm2ext/gtkapplication_quartz.mm
+++ b/libs/gtkmm2ext/gtkapplication_quartz.mm
@@ -50,6 +50,8 @@
*
*/
+static gint _exiting = 0;
+
static guint
gdk_quartz_keyval_to_ns_keyval (guint keyval)
{
@@ -891,9 +893,13 @@ cocoa_menu_item_accel_changed (GtkAccelGroup *accel_group,
GClosure *accel_closure,
GtkWidget *widget)
{
- GNSMenuItem *cocoa_item = cocoa_menu_item_get (widget);
+ GNSMenuItem *cocoa_item;
GtkWidget *label;
+ if (_exiting)
+ return;
+
+ cocoa_item = cocoa_menu_item_get (widget);
get_menu_label_text (widget, &label);
if (GTK_IS_ACCEL_LABEL (label) &&
@@ -945,7 +951,12 @@ cocoa_menu_item_notify_label (GObject *object,
GParamSpec *pspec,
gpointer data)
{
- GNSMenuItem *cocoa_item = cocoa_menu_item_get (GTK_WIDGET (object));
+ GNSMenuItem *cocoa_item;
+
+ if (_exiting)
+ return;
+
+ cocoa_item = cocoa_menu_item_get (GTK_WIDGET (object));
if (!strcmp (pspec->name, "label"))
{
@@ -964,6 +975,9 @@ cocoa_menu_item_notify (GObject *object,
GParamSpec *pspec,
NSMenuItem *cocoa_item)
{
+ if (_exiting)
+ return;
+
if (!strcmp (pspec->name, "sensitive") ||
!strcmp (pspec->name, "visible"))
{
@@ -1449,10 +1463,18 @@ gtk_application_ready ()
extern "C" void
gtk_application_cleanup()
{
- if (_window_menu)
+ _exiting = 1;
+
+ if (_window_menu) {
[ _window_menu release ];
- if (_app_menu)
+ _window_menu = 0;
+ }
+ if (_app_menu) {
[ _app_menu release ];
- if (_main_menubar)
+ _app_menu = 0;
+ }
+ if (_main_menubar) {
[ _main_menubar release ];
+ _main_menubar = 0;
+ }
}
diff --git a/libs/gtkmm2ext/gtkmm2ext/application.h b/libs/gtkmm2ext/gtkmm2ext/application.h
new file mode 100644
index 0000000000..3fb107b783
--- /dev/null
+++ b/libs/gtkmm2ext/gtkmm2ext/application.h
@@ -0,0 +1,63 @@
+/* GTK+ Integration with platform-specific application-wide features
+ * such as the OS X menubar and application delegate concepts.
+ *
+ * Copyright (C) 2009 Paul Davis
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1
+ * of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_APPLICATION_MM_H__
+#define __GTK_APPLICATION_MM_H__
+
+#include <gtkmm2ext/gtkapplication.h> // for GtkApplicationGroup typedef
+#include <sigc++/signal.h>
+
+namespace Gtk {
+ class MenuItem;
+ class MenuShell;
+}
+
+namespace Glib {
+ class ustring;
+}
+
+namespace Gtkmm2ext {
+
+class Application
+{
+public:
+ static Application* instance();
+ ~Application ();
+
+ void ready ();
+ void cleanup ();
+ void set_menu_bar (Gtk::MenuShell&);
+ GtkApplicationMenuGroup* add_app_menu_group ();
+ void add_app_menu_item (GtkApplicationMenuGroup*, Gtk::MenuItem*);
+
+ sigc::signal<void,bool> ActivationChanged;
+ sigc::signal<void,const Glib::ustring&> ShouldLoad;
+ sigc::signal<void> ShouldQuit;
+
+private:
+ Application ();
+
+ static Application* _instance;
+};
+
+}
+
+#endif /* __GTK_APPLICATION_MM_H__ */
diff --git a/libs/gtkmm2ext/wscript b/libs/gtkmm2ext/wscript
index ca4682a0f1..2fc711fc73 100644
--- a/libs/gtkmm2ext/wscript
+++ b/libs/gtkmm2ext/wscript
@@ -20,6 +20,7 @@ VERSION = GTKMM2EXT_VERSION
gtkmm2ext_sources = [
'actions.cc',
+ 'application.cc',
'auto_spin.cc',
'barcontroller.cc',
'binding_proxy.cc',