Esempio n. 1
0
static void assign_tooltips_from_actions(GtkWidget* widget)
{
    if(G_LIKELY(GTK_IS_MENU_ITEM(widget)))
    {
        if(GTK_IS_ACTIVATABLE(widget))
            assign_tooltip_from_action(widget);
        widget = gtk_menu_item_get_submenu((GtkMenuItem*)widget);
        if(widget)
            assign_tooltips_from_actions(widget);
    }
    else if (GTK_IS_CONTAINER(widget))
    {
        gtk_container_forall((GtkContainer*)widget,
                             (GtkCallback)assign_tooltips_from_actions, NULL);
    }
}
Esempio n. 2
0
/* get the related action of the widget or walk up the parents to find one.
 * useful for example to get the related action of a tool item from its child. */
GtkAction *
mousepad_util_find_related_action (GtkWidget *widget)
{
  GtkAction *action;

  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);

  do
    {
      if (GTK_IS_ACTIVATABLE (widget))
        action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget));

      if (G_UNLIKELY (action == NULL))
        {
          if (gtk_widget_is_toplevel (widget))
            break;
          widget = gtk_widget_get_parent (widget);
        }
    }
  while (action == NULL);

  return action;
}