Exemple #1
0
static gboolean
parent_set_emission_hook (GSignalInvocationHint *ihint,
			  guint                  n_param_values,
			  const GValue          *param_values,
			  gpointer               data)
{
  GtkWidget *instance = g_value_get_object (param_values);

  if (GTK_IS_MENU_ITEM (instance))
    {
      GtkWidget *previous_parent = g_value_get_object (param_values + 1);
      GtkWidget *menu_shell      = NULL;

      if (GTK_IS_MENU_SHELL (previous_parent))
	{
	  menu_shell = previous_parent;
        }
      else
      {
        GtkWidget *parent;

        parent = gtk_widget_get_parent (instance);

        if (GTK_IS_MENU_SHELL (parent))
	  {
	    menu_shell = parent;
	  }
      }

      if (menu_shell)
        {
	  CarbonMenu *carbon_menu = carbon_menu_get (menu_shell);

	  if (carbon_menu)
	    {
#if 0
	      g_printerr ("%s: item %s %p (%s, %s)\n", G_STRFUNC,
			  previous_parent ? "removed from" : "added to",
			  menu_shell,
			  get_menu_label_text (instance, NULL),
			  g_type_name (G_TYPE_FROM_INSTANCE (instance)));
#endif

	      sync_menu_shell (GTK_MENU_SHELL (menu_shell),
			       carbon_menu->menu,
			       carbon_menu->toplevel,
			       FALSE);
	    }
        }
    }

  return TRUE;
}
Exemple #2
0
static void
carbon_menu_connect (GtkWidget *menu,
		     MenuRef    menuRef)
{
  CarbonMenu *carbon_menu = carbon_menu_get (menu);

  if (!carbon_menu)
    {
      carbon_menu = carbon_menu_new ();

      g_object_set_qdata_full (G_OBJECT (menu), carbon_menu_quark,
			       carbon_menu,
			       (GDestroyNotify) carbon_menu_free);
    }

  carbon_menu->menu = menuRef;
}
Exemple #3
0
void
ige_mac_menu_set_menu_bar (GtkMenuShell *menu_shell)
{
  CarbonMenu *current_menu;
  MenuRef     carbon_menubar;

  g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));

  if (carbon_menu_quark == 0)
    carbon_menu_quark = g_quark_from_static_string ("CarbonMenu");

  if (carbon_menu_item_quark == 0)
    carbon_menu_item_quark = g_quark_from_static_string ("CarbonMenuItem");

  current_menu = carbon_menu_get (GTK_WIDGET (menu_shell));
  if (current_menu)
    {
      SetRootMenu (current_menu->menu);
      return;
    }

  CreateNewMenu (0 /*id*/, 0 /*options*/, &carbon_menubar);
  SetRootMenu (carbon_menubar);

  setup_menu_event_handler ();

  if (emission_hook_id == 0)
    {
      emission_hook_id =
        g_signal_add_emission_hook (g_signal_lookup ("parent-set",
                                                     GTK_TYPE_WIDGET),
                                    0,
                                    parent_set_emission_hook,
                                    NULL, NULL);
    }

  emission_hook_count++;

  g_signal_connect (menu_shell, "destroy",
		    G_CALLBACK (parent_set_emission_hook_remove),
		    NULL);

  sync_menu_shell (menu_shell, carbon_menubar, TRUE, FALSE);
}