ige-mac-menu.c revision 973e32842d0db7a0a18bb03e33a433302808cf54
/* GTK+ Integration for the Mac OS X Menubar.
*
* Copyright (C) 2007 Pioneer Research Center USA, Inc.
*
* For further information, see:
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef GDK_WINDOWING_QUARTZ
#include <gdk/gdkkeysyms.h>
#include "ige-mac-menu.h"
/* TODO
*
* - Sync adding/removing/reordering items
* - Create on demand? (can this be done with gtk+? ie fill in menu
items when the menu is opened)
*
*/
#define IGE_QUARTZ_MENU_CREATOR 'IGEC'
#define IGE_QUARTZ_ITEM_WIDGET 'IWID'
/*
* utility functions
*/
static GtkWidget *
{
if (GTK_IS_LABEL (widget))
return widget;
if (GTK_IS_CONTAINER (widget))
{
GList *l;
{
if (label)
break;
}
}
return label;
}
static const gchar *
{
if (label)
if (my_label)
return NULL;
}
static gboolean
{
}
/*
* CarbonMenu functions
*/
typedef struct
{
} CarbonMenu;
static GQuark carbon_menu_quark = 0;
static CarbonMenu *
carbon_menu_new (void)
{
return g_slice_new0 (CarbonMenu);
}
static void
{
}
static CarbonMenu *
{
}
static void
{
if (!carbon_menu)
{
carbon_menu = carbon_menu_new ();
}
}
/*
* CarbonMenuItem functions
*/
typedef struct
{
static GQuark carbon_menu_item_quark = 0;
static CarbonMenuItem *
carbon_menu_item_new (void)
{
return g_slice_new0 (CarbonMenuItem);
}
static void
{
if (menu_item->accel_closure)
}
static CarbonMenuItem *
{
}
static void
{
UInt32 clear_attrs = 0;
"sensitive", &sensitive,
"visible", &visible,
NULL);
if (!sensitive)
else
if (!visible)
else
}
static void
{
"active", &active,
NULL);
active);
}
static void
{
if (submenu)
{
const gchar *label_text;
if (label_text)
if (cfstr)
}
else
{
NULL);
}
}
static void
{
const gchar *label_text;
if (label_text)
cfstr);
if (cfstr)
}
static void
{
if (GTK_IS_ACCEL_LABEL (label) &&
{
if (key &&
{
{
if (key->accel_mods)
{
}
{
}
return;
}
}
}
/* otherwise, clear the menu shortcut */
false, 0);
}
static void
{
if (GTK_IS_ACCEL_LABEL (label) &&
}
static void
{
if (carbon_item->accel_closure)
{
widget);
}
if (GTK_IS_ACCEL_LABEL (label))
if (carbon_item->accel_closure)
{
widget, 0);
}
}
static void
{
{
}
{
}
{
}
}
static void
{
{
GTK_WIDGET (object));
}
{
GTK_WIDGET (object));
}
}
static CarbonMenuItem *
{
if (!carbon_item)
{
if (label)
}
return carbon_item;
}
/*
* carbon event handler
*/
static OSStatus
void *data)
{
switch (event_class)
{
case kEventClassCommand:
/* This is called when activating (is that the right GTK+ term?)
* a menu item.
*/
if (event_kind == kEventCommandProcess)
{
/*g_printerr ("Menu: kEventClassCommand/kEventCommandProcess\n");*/
typeHICommand, 0,
{
/* Get any GtkWidget associated with the item. */
{
return noErr;
}
}
}
break;
case kEventClassMenu:
NULL,
sizeof (menu_ref),
NULL,
&menu_ref);
switch (event_kind)
{
case kEventMenuTargetItem:
/* This is called when an item is selected (what is the
* GTK+ term? prelight?)
*/
/*g_printerr ("kEventClassMenu/kEventMenuTargetItem\n");*/
break;
case kEventMenuOpening:
/* Is it possible to dynamically build the menu here? We
* can at least set visibility/sensitivity.
*/
/*g_printerr ("kEventClassMenu/kEventMenuOpening\n");*/
break;
case kEventMenuClosed:
/*g_printerr ("kEventClassMenu/kEventMenuClosed\n");*/
break;
default:
break;
}
break;
default:
break;
}
}
static void
setup_menu_event_handler (void)
{
const EventTypeSpec menu_events[] = {
};
/* FIXME: We might have to install one per window? */
#if 0
/* FIXME: Remove the handler with: */
#endif
}
static void
{
GList *l;
if (debug)
{
continue;
"gtk-empty-menu-item"))
continue;
if (debug)
g_printerr ("%s: carbon_item %d for menu_item %d (%s, %s)\n",
{
if (debug)
carbon_item = NULL;
}
if (!carbon_item)
{
const gchar *label_text;
if (debug)
if (label_text)
if (!GTK_WIDGET_IS_SENSITIVE (menu_item))
if (!GTK_WIDGET_VISIBLE (menu_item))
carbon_index - 1,
attributes, 0);
if (cfstr)
if (GTK_IS_CHECK_MENU_ITEM (menu_item))
}
carbon_index++;
}
}
static gulong emission_hook_id = 0;
static gboolean
const GValue *param_values,
{
if (GTK_IS_MENU_ITEM (instance))
{
if (GTK_IS_MENU_SHELL (previous_parent))
{
}
{
}
if (menu_shell)
{
if (carbon_menu)
{
#if 0
#endif
FALSE);
}
}
}
return TRUE;
}
static void
{
}
/*
* public functions
*/
void
{
if (carbon_menu_quark == 0)
if (carbon_menu_item_quark == 0)
0,
NULL);
}
void
{
{
}
}
struct _IgeMacMenuGroup
{
};
{
return group;
}
void
{
{
g_warning ("%s: retrieving app menu failed",
return;
}
{
/* adjust index for the separator between groups, but not
* before the first group
*/
index++;
if (group == list_group)
{
/* add a separator before adding the first item, but not
* for the first group
*/
{
index++;
}
if (!label)
return;
}
}
if (!list)
g_warning ("%s: app menu group %p does not exist",
}
#endif /* GDK_WINDOWING_QUARTZ */