Exemple #1
0
static void serializer_visit (Serializer* self, GtkWidget* widget) {
    g_return_if_fail (self != NULL);
    g_return_if_fail (widget != NULL);
    if (GTK_IS_MENU_BAR (widget)) {
        GtkWidget* _tmp0_;
        serializer_visit_menubar (self, (_tmp0_ = widget, GTK_IS_MENU_BAR (_tmp0_) ? ((GtkMenuBar*) _tmp0_) : NULL));
    } else {
        if (GTK_IS_MENU (widget)) {
            GtkWidget* _tmp1_;
            serializer_visit_menu (self, (_tmp1_ = widget, GTK_IS_MENU (_tmp1_) ? ((GtkMenu*) _tmp1_) : NULL));
        } else {
            if (GTK_IS_MENU_ITEM (widget)) {
                GtkWidget* _tmp2_;
                serializer_visit_menuitem (self, (_tmp2_ = widget, GTK_IS_MENU_ITEM (_tmp2_) ? ((GtkMenuItem*) _tmp2_) : NULL));
            } else {
                if (GTK_IS_LABEL (widget)) {
                    GtkWidget* _tmp3_;
                    serializer_visit_label (self, (_tmp3_ = widget, GTK_IS_LABEL (_tmp3_) ? ((GtkLabel*) _tmp3_) : NULL));
                } else {
                    if (GTK_IS_IMAGE (widget)) {
                        GtkWidget* _tmp4_;
                        serializer_visit_image (self, (_tmp4_ = widget, GTK_IS_IMAGE (_tmp4_) ? ((GtkImage*) _tmp4_) : NULL));
                    } else {
                        if (GTK_IS_CONTAINER (widget)) {
                            GtkWidget* _tmp5_;
                            serializer_visit_container (self, (_tmp5_ = widget, GTK_IS_CONTAINER (_tmp5_) ? ((GtkContainer*) _tmp5_) : NULL));
                        }
                    }
                }
            }
        }
    }
}
Exemple #2
0
static void
menu_item_keep_menubar_image (GtkImageMenuItem *imitem)
{
  if (imitem->image && GTK_IS_MENU_BAR (GTK_WIDGET (imitem)->parent) &&
      !g_object_get_long (imitem, "gxk-keep-menubar-image"))
    gtk_image_menu_item_set_image (imitem, NULL);
}
void cl_draw_menuitem_gradient (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
                                GdkRectangle *area, GtkStateType state_type, 
                                int x, int y, int width, int height, CLRectangle *r)
{
	ClearlooksStyle *clearlooks_style = (ClearlooksStyle*)style;
	gboolean menubar  = (widget->parent && GTK_IS_MENU_BAR(widget->parent)) ? TRUE : FALSE;
	GdkColor tmp;
	GdkColor lower_color;
	
	shade (&style->base[GTK_STATE_SELECTED], &lower_color, 0.8);
	
	cl_rectangle_set_corners (r, CL_CORNER_NARROW, CL_CORNER_NARROW,
	                             CL_CORNER_NARROW, CL_CORNER_NARROW);
	                             
	cl_rectangle_set_gradient (&r->fill_gradient,
	                           &style->base[GTK_STATE_SELECTED], &lower_color);

	r->gradient_type = CL_GRADIENT_VERTICAL;
	
	tmp = cl_gc_set_fg_color_shade (style->black_gc, style->colormap,
	                                &style->base[GTK_STATE_PRELIGHT], 0.8);

	r->bordergc = style->black_gc;
	r->fillgc = style->base_gc[GTK_STATE_PRELIGHT];
	
	if (menubar) height++;

	cl_rectangle_set_clip_rectangle (r, area);
	cl_draw_rectangle (window, widget, style, x, y, width, height, r);
	cl_rectangle_reset_clip_rectangle (r);
	
	gdk_gc_set_foreground (style->black_gc, &tmp);
}
Exemple #4
0
static void
gtk_image_menu_item_get_preferred_width (GtkWidget        *widget,
        gint             *minimum,
        gint             *natural)
{
    GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
    GtkImageMenuItemPrivate *priv = image_menu_item->priv;
    GtkPackDirection pack_dir;
    GtkWidget *parent;

    parent = gtk_widget_get_parent (widget);

    if (GTK_IS_MENU_BAR (parent))
        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
    else
        pack_dir = GTK_PACK_DIRECTION_LTR;

    GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural);

    if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
            priv->image &&
            gtk_widget_get_visible (priv->image))
    {
        gint child_minimum, child_natural;

        gtk_widget_get_preferred_width (priv->image, &child_minimum, &child_natural);

        *minimum = MAX (*minimum, child_minimum);
        *natural = MAX (*natural, child_natural);
    }
}
Exemple #5
0
static void
gtk_image_menu_item_get_preferred_height (GtkWidget        *widget,
        gint             *minimum,
        gint             *natural)
{
    GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
    GtkImageMenuItemPrivate *priv = image_menu_item->priv;
    gint child_height = 0;
    GtkPackDirection pack_dir;
    GtkWidget *parent;

    parent = gtk_widget_get_parent (widget);

    if (GTK_IS_MENU_BAR (parent))
        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
    else
        pack_dir = GTK_PACK_DIRECTION_LTR;

    if (priv->image && gtk_widget_get_visible (priv->image))
    {
        GtkRequisition child_requisition;

        gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);

        child_height = child_requisition.height;
    }

    GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_height (widget, minimum, natural);

    if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
    {
        *minimum = MAX (*minimum, child_height);
        *natural = MAX (*natural, child_height);
    }
}
Exemple #6
0
void
glade_gtk_menu_item_action_activate (GladeWidgetAdaptor * adaptor,
                                     GObject * object,
                                     const gchar * action_path)
{
  GObject *obj = NULL, *shell = NULL;
  GladeWidget *w = glade_widget_get_from_gobject (object);

  while ((w = glade_widget_get_parent (w)))
    {
      obj = glade_widget_get_object (w);
      if (GTK_IS_MENU_SHELL (obj))
        shell = obj;
    }

  if (strcmp (action_path, "launch_editor") == 0)
    {
      if (shell)
        object = shell;

      if (GTK_IS_MENU_BAR (object))
        glade_gtk_menu_shell_launch_editor (object, _("Edit Menu Bar"));
      else if (GTK_IS_MENU (object))
        glade_gtk_menu_shell_launch_editor (object, _("Edit Menu"));
    }
  else
    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
                                                         object, action_path);

  if (shell)
    gtk_menu_shell_deactivate (GTK_MENU_SHELL (shell));
}
/*	Insert a menu into the menu bar. */
void EvalCcRqINSERTMENU (CrossCallInfo *pcci)
{
    gint i;
    gchar *title;
    GtkWidget *parent_menu, *root_menu, *sub_menu;
    GtkAccelGroup *accel_group;
    printf("EvalCcRqINSERTMENU\n");

    title = createMnemonicString((gchar *) pcci->p3);
    parent_menu = GTK_WIDGET(pcci->p2);
    sub_menu = GTK_WIDGET(pcci->p4);

    if (GTK_IS_MENU_BAR(parent_menu))
    {
        printf("Adding to a menu bar.\n");
        GtkWidget *frame = gtk_widget_get_parent(gtk_widget_get_parent(parent_menu));
        if (!G_IS_OBJECT(frame))
            frame = gtk_widget_get_parent(parent_menu);
        accel_group = ((GtkAccelGroup*)gtk_accel_groups_from_object (G_OBJECT(frame))->data);
    }
    else
    {
        printf("We're not adding to a menu bar!?!\n");
        accel_group = gtk_menu_get_accel_group (GTK_MENU(parent_menu));
    }

    gtk_menu_set_accel_group (GTK_MENU(sub_menu), accel_group);

    root_menu = gtk_menu_item_new_with_mnemonic(title);
    gtk_widget_set_sensitive(root_menu, (gboolean) pcci->p1);
    gtk_widget_show (root_menu);

    gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), sub_menu);

    if (GTK_IS_MENU_BAR(parent_menu))
    {
        gtk_menu_shell_insert(GTK_MENU_SHELL(parent_menu), root_menu, (gint) pcci->p5);
    } else {
        gtk_menu_insert(GTK_MENU(parent_menu), root_menu, (gint) pcci->p5);
    }

    rfree(title);

    MakeReturn1Cci (pcci, (int64_t) sub_menu);
}
Exemple #8
0
static gboolean
qtcMenuShellButtonPress(GtkWidget *widget, GdkEventButton *event, void *data)
{
    QTC_UNUSED(data);
    if (GTK_IS_MENU_BAR(widget)) {
        // QtCurve's menubars have a 2 pixel border ->
        // but want the left/top to be 'active'...
        int nx, ny;
        gdk_window_get_origin(gtk_widget_get_window(widget), &nx, &ny);
        if ((event->x_root - nx) <= 2.0 || (event->y_root - ny) <= 2.0) {
            if ((event->x_root - nx) <= 2.0) {
                event->x_root += 2.0;
            }
            if ((event->y_root - ny) <= 2.0) {
                event->y_root += 2.0;
            }

            GtkMenuShell *menuShell = GTK_MENU_SHELL(widget);
            GList *children =
                gtk_container_get_children(GTK_CONTAINER(menuShell));
            bool rv = false;
            for (GList *child = children;child;child = child->next) {
                GtkWidget *item = child->data;
                QtcRect alloc = qtcWidgetGetAllocation(item);
                int cx = alloc.x + nx;
                int cy = alloc.y + ny;
                int cw = alloc.width;
                int ch = alloc.height;
                if (cx <= event->x_root && cy <= event->y_root &&
                    (cx + cw) > event->x_root && (cy + ch) > event->y_root) {
                    if (menuIsSelectable(item)) {
                        if (event->type == GDK_BUTTON_PRESS) {
                            if (item != menuShell->active_menu_item) {
                                menuShell->active = false;
                                gtk_menu_shell_select_item(menuShell, item);
                                menuShell->active = true;
                            } else {
                                menuShell->active = true;
                                gtk_menu_shell_deselect(menuShell);
                                menuShell->active = false;
                            }
                        }
                        rv = true;
                    }
                    break;
                }
            }
            if (children) {
                g_list_free(children);
            }
            return rv;
        }
    }
    return false;
}
Exemple #9
0
GuiObject GuiMenuBar_addMenu2 (GuiObject bar, const wchar_t *title, long flags, GuiObject *menuTitle) {
	GuiObject menu;
	*menuTitle = gtk_menu_item_new_with_label (Melder_peekWcsToUtf8 (title));
	menu = gtk_menu_new ();
	GtkAccelGroup *ag = (GtkAccelGroup*)(GTK_IS_MENU_BAR (bar) ? g_object_get_data (G_OBJECT (bar), "accel-group") : gtk_menu_get_accel_group (GTK_MENU (bar)));
	gtk_menu_set_accel_group (GTK_MENU (menu), ag);
	if (flags & GuiMenu_INSENSITIVE)
		gtk_widget_set_sensitive (menu, FALSE);
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (*menuTitle), menu);
	gtk_menu_shell_append (GTK_MENU_SHELL (bar), *menuTitle);
	gtk_widget_show (menu);
	gtk_widget_show (*menuTitle);
	return menu;
}
Exemple #10
0
static void
gail_menu_shell_initialize (AtkObject *accessible,
                            gpointer  data)
{
  ATK_OBJECT_CLASS (gail_menu_shell_parent_class)->initialize (accessible, data);

  if (GTK_IS_MENU_BAR (data))
    accessible->role = ATK_ROLE_MENU_BAR;
  else
    /*
     * Accessible object for Menu is created in gailmenu.c
     */
    accessible->role = ATK_ROLE_UNKNOWN;
}
Exemple #11
0
static gboolean
gail_deselect_watcher (GSignalInvocationHint *ihint,
                       guint                  n_param_values,
                       const GValue          *param_values,
                       gpointer               data)
{
  GObject *object;
  GtkWidget *widget;
  GtkWidget *menu_shell;

  object = g_value_get_object (param_values + 0);
  g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);

  widget = GTK_WIDGET (object);

  if (!GTK_IS_MENU_ITEM (widget))
    return TRUE;

  if (subsequent_focus_widget == widget)
    subsequent_focus_widget = NULL;

  menu_shell = gtk_widget_get_parent (widget);
  if (GTK_IS_MENU_SHELL (menu_shell))
    {
      GtkWidget *parent_menu_shell;

      parent_menu_shell = gtk_menu_shell_get_parent_shell (GTK_MENU_SHELL (menu_shell));
      if (parent_menu_shell)
        {
          GtkWidget *active_menu_item;

          active_menu_item = gtk_menu_shell_get_selected_item (GTK_MENU_SHELL (parent_menu_shell));
          if (active_menu_item)
            {
              gail_focus_notify_when_idle (active_menu_item);
            }
        }
      else
        {
          if (!GTK_IS_MENU_BAR (menu_shell))
            {
              gail_focus_notify_when_idle (menu_shell);
            }
        }
    }
  was_deselect = TRUE;
  return TRUE; 
}
Exemple #12
0
static void
qtcMenuShellCleanup(GtkWidget *widget)
{
    if (GTK_IS_MENU_BAR(widget)) {
        QTC_DEF_WIDGET_PROPS(props, widget);
        qtcDisconnectFromProp(props, menuShellMotion);
        qtcDisconnectFromProp(props, menuShellLeave);
        qtcDisconnectFromProp(props, menuShellDestroy);
        qtcDisconnectFromProp(props, menuShellStyleSet);
#ifdef EXTEND_MENUBAR_ITEM_HACK
        qtcDisconnectFromProp(props, menuShellButtonPress);
        qtcDisconnectFromProp(props, menuShellButtonRelease);
#endif
        qtcWidgetProps(props)->menuShellHacked = true;
    }
}
GtkWidget* GetMenuBar(CefRefPtr<CefBrowser> browser)
{
    GtkWidget* window = (GtkWidget*)getMenuParent(browser);
    GtkWidget* widget;
    GList *children, *iter;

    children = gtk_container_get_children(GTK_CONTAINER(window));
    for(iter = children; iter != NULL; iter = g_list_next(iter)) {
        widget = (GtkWidget*)iter->data;

        if (GTK_IS_MENU_BAR(widget))
            return widget;
    }

    return NULL;
}
Exemple #14
0
void
glade_gtk_menu_bar_post_create (GladeWidgetAdaptor *adaptor,
                                GObject            *object,
				GladeCreateReason   reason)
{
  GladeProject *project;
  GladeWidget *gmenubar, *gitem, *gsubmenu;

  g_return_if_fail (GTK_IS_MENU_BAR (object));
  gmenubar = glade_widget_get_from_gobject (object);
  g_return_if_fail (GLADE_IS_WIDGET (gmenubar));

  if (reason != GLADE_CREATE_USER)
    return;

  project = glade_widget_get_project (gmenubar);

  /* File */
  gitem =
      glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_File"), FALSE);
  gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-new", TRUE);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-open", TRUE);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save", TRUE);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save-as", TRUE);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, NULL, FALSE);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-quit", TRUE);

  /* Edit */
  gitem =
      glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Edit"), FALSE);
  gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-cut", TRUE);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-copy", TRUE);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-paste", TRUE);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-delete", TRUE);

  /* View */
  gitem =
      glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_View"), FALSE);

  /* Help */
  gitem =
      glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Help"), FALSE);
  gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
  glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-about", TRUE);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent
  (JNIEnv *env, jobject obj, jobject parent)
{
  void *ptr;
  void *parent_ptr;
  GtkWidget *widget;
  GtkWidget *parent_widget;

  gdk_threads_enter ();

  ptr = gtkpeer_get_widget (env, obj);
  parent_ptr = gtkpeer_get_widget (env, parent);
  
  widget = GTK_WIDGET (ptr);
  parent_widget = get_widget(GTK_WIDGET (parent_ptr));

  if (widget->parent == NULL)
    {
      if (GTK_IS_WINDOW (parent_widget))
	{
	  GList *children = gtk_container_get_children
	    (GTK_CONTAINER (parent_widget));

          if (GTK_IS_MENU_BAR (children->data))
            gtk_fixed_put (GTK_FIXED (children->next->data), widget, 0, 0);
          else
            gtk_fixed_put (GTK_FIXED (children->data), widget, 0, 0);
        }
      else
        if (GTK_IS_SCROLLED_WINDOW (parent_widget))
          {
            gtk_scrolled_window_add_with_viewport 
              (GTK_SCROLLED_WINDOW (parent_widget), widget);
            gtk_viewport_set_shadow_type (GTK_VIEWPORT (widget->parent), 
                                          GTK_SHADOW_NONE);

          }
        else
          {
            if (widget->parent == NULL)
              gtk_fixed_put (GTK_FIXED (parent_widget), widget, 0, 0);
          }
    }

  gdk_threads_leave ();
}
Exemple #16
0
static void
gtk_image_menu_item_size_request (GtkWidget      *widget,
                                  GtkRequisition *requisition)
{
  GtkImageMenuItem *image_menu_item;
  gint child_width = 0;
  gint child_height = 0;
  GtkPackDirection pack_dir;
  
  if (GTK_IS_MENU_BAR (widget->parent))
    pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent));
  else
    pack_dir = GTK_PACK_DIRECTION_LTR;

  image_menu_item = GTK_IMAGE_MENU_ITEM (widget);

  if (image_menu_item->image && gtk_widget_get_visible (image_menu_item->image))
    {
      GtkRequisition child_requisition;
      
      gtk_widget_size_request (image_menu_item->image,
                               &child_requisition);

      child_width = child_requisition.width;
      child_height = child_requisition.height;
    }

  GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_request (widget, requisition);

  /* not done with height since that happens via the
   * toggle_size_request
   */
  if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
    requisition->height = MAX (requisition->height, child_height);
  else
    requisition->width = MAX (requisition->width, child_width);
    
  
  /* Note that GtkMenuShell always size requests before
   * toggle_size_request, so toggle_size_request will be able to use
   * image_menu_item->image->requisition
   */
}
Exemple #17
0
static GtkWidget *
find_menubar (GtkContainer *container)
{
  GList      *children;
  GList      *node;
  GtkWidget  *menubar = NULL;
  
  children = gtk_container_get_children (container);
  for (node = children; ! menubar && node; node = node->next) {
    if (GTK_IS_MENU_BAR (node->data)) {
      menubar = node->data;
    } else if (GTK_IS_CONTAINER (node->data)) {
      menubar = find_menubar (node->data);
    }
  }
  g_list_free (children);
  
  return menubar;
}
Exemple #18
0
static void
gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
        gint        *requisition)
{
    GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
    GtkImageMenuItemPrivate *priv = image_menu_item->priv;
    GtkPackDirection pack_dir;
    GtkWidget *parent;
    GtkWidget *widget = GTK_WIDGET (menu_item);

    parent = gtk_widget_get_parent (widget);

    if (GTK_IS_MENU_BAR (parent))
        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
    else
        pack_dir = GTK_PACK_DIRECTION_LTR;

    *requisition = 0;

    if (priv->image && gtk_widget_get_visible (priv->image))
    {
        GtkRequisition image_requisition;
        guint toggle_spacing;

        gtk_widget_get_preferred_size (priv->image, &image_requisition, NULL);

        gtk_widget_style_get (GTK_WIDGET (menu_item),
                              "toggle-spacing", &toggle_spacing,
                              NULL);

        if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
        {
            if (image_requisition.width > 0)
                *requisition = image_requisition.width + toggle_spacing;
        }
        else
        {
            if (image_requisition.height > 0)
                *requisition = image_requisition.height + toggle_spacing;
        }
    }
}
Exemple #19
0
static gboolean
gail_deactivate_watcher (GSignalInvocationHint *ihint,
                         guint                  n_param_values,
                         const GValue          *param_values,
                         gpointer               data)
{
  GObject *object;
  GtkWidget *widget;
  GtkMenuShell *shell;
  GtkWidget *focus = NULL;

  object = g_value_get_object (param_values + 0);
  g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
  widget = GTK_WIDGET (object);

  g_return_val_if_fail (GTK_IS_MENU_SHELL(widget), TRUE);
  shell = GTK_MENU_SHELL(widget);
  if (! gtk_menu_shell_get_parent_shell (shell))
    focus = focus_before_menu;
      
  /*
   * If we are waiting to report focus on a menubar or a menu item
   * because of a previous deselect, cancel it.
   */
  if (was_deselect &&
      focus_notify_handler &&
      next_focus_widget &&
      (GTK_IS_MENU_BAR (next_focus_widget) ||
       GTK_IS_MENU_ITEM (next_focus_widget)))
    {
      void *vp_next_focus_widget = &next_focus_widget;
      g_source_remove (focus_notify_handler);
      g_object_remove_weak_pointer (G_OBJECT (next_focus_widget), vp_next_focus_widget);
      next_focus_widget = NULL;
      focus_notify_handler = 0;
      was_deselect = FALSE;
    }
  gail_focus_notify_when_idle (focus);

  return TRUE; 
}
Exemple #20
0
void
qtcMenuShellSetup(GtkWidget *widget)
{
    QTC_DEF_WIDGET_PROPS(props, widget);
    if (GTK_IS_MENU_BAR(widget) && !qtcWidgetProps(props)->menuShellHacked) {
        qtcWidgetProps(props)->menuShellHacked = true;
        qtcConnectToProp(props, menuShellMotion, "motion-notify-event",
                         qtcMenuShellMotion, NULL);
        qtcConnectToProp(props, menuShellLeave, "leave-notify-event",
                         qtcMenuShellLeave, NULL);
        qtcConnectToProp(props, menuShellDestroy, "destroy-event",
                         qtcMenuShellDestroy, NULL);
        qtcConnectToProp(props, menuShellStyleSet, "style-set",
                         qtcMenuShellStyleSet, NULL);
#ifdef EXTEND_MENUBAR_ITEM_HACK
        qtcConnectToProp(props, menuShellButtonPress, "button-press-event",
                         qtcMenuShellButtonPress, NULL);
        qtcConnectToProp(props, menuShellButtonRelease, "button-release-event",
                         qtcMenuShellButtonPress, NULL);
#endif
    }
}
Exemple #21
0
static void
gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
        gint        *requisition)
{
    GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
    GtkPackDirection pack_dir;

    if (GTK_IS_MENU_BAR (GTK_WIDGET (menu_item)->parent))
        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (GTK_WIDGET (menu_item)->parent));
    else
        pack_dir = GTK_PACK_DIRECTION_LTR;

    *requisition = 0;

    if (image_menu_item->image && GTK_WIDGET_VISIBLE (image_menu_item->image))
    {
        GtkRequisition image_requisition;
        guint toggle_spacing;
        gtk_widget_get_child_requisition (image_menu_item->image,
                                          &image_requisition);

        gtk_widget_style_get (GTK_WIDGET (menu_item),
                              "toggle-spacing", &toggle_spacing,
                              NULL);

        if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
        {
            if (image_requisition.width > 0)
                *requisition = image_requisition.width + toggle_spacing;
        }
        else
        {
            if (image_requisition.height > 0)
                *requisition = image_requisition.height + toggle_spacing;
        }
    }
}
void cl_draw_menuitem_button (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
                              GdkRectangle *area, GtkStateType state_type, 
                              int x, int y, int width, int height, CLRectangle *r)
{
	ClearlooksStyle *clearlooks_style = (ClearlooksStyle*)style;
	gboolean menubar  = (widget->parent && GTK_IS_MENU_BAR(widget->parent)) ? TRUE : FALSE;
	int corner        = CL_CORNER_NARROW;
	GdkColor lower_color;

	shade (&style->base[GTK_STATE_SELECTED], &lower_color, 0.85);
	
	if (menubar)
	{
		height++;
		corner = CL_CORNER_NONE;
		r->bordergc    = clearlooks_style->border_gc[CL_BORDER_UPPER];
	}
	else
	{
		r->bordergc    = clearlooks_style->spot3_gc;
	}
	
	cl_rectangle_set_corners (r, corner, corner, corner, corner);
	
	cl_rectangle_set_gradient (&r->fill_gradient,
	                           &style->base[GTK_STATE_SELECTED], &lower_color);

	r->gradient_type = CL_GRADIENT_VERTICAL;
	
	r->fillgc  = clearlooks_style->spot2_gc;
	r->topleft = clearlooks_style->spot1_gc;
	
	cl_rectangle_set_clip_rectangle (r, area);
	cl_draw_rectangle (window, widget, style, x, y, width, height, r);
	cl_draw_shadow (window, widget, style, x, y, width, height, r);
	cl_rectangle_reset_clip_rectangle (r);
}
Exemple #23
0
GtkWidget*
qtcWindowGetMenuBar(GtkWidget *parent, int level)
{
    if (level < 3 && GTK_IS_CONTAINER(parent) && canGetChildren(parent)
        /* && gtk_widget_get_realized(parent)*/) {
        GtkWidget *rv = NULL;
        GList *children = gtk_container_get_children(GTK_CONTAINER(parent));
        for (GList *child = children;child && !rv;child = child->next) {
            GtkWidget *boxChild = (GtkWidget*)child->data;

            if (GTK_IS_MENU_BAR(boxChild)) {
                rv = GTK_WIDGET(boxChild);
            } else if (GTK_IS_CONTAINER(boxChild)) {
                rv=qtcWindowGetMenuBar(GTK_WIDGET(boxChild), level + 1);
            }
        }

        if (children) {
            g_list_free(children);
        }
        return rv;
    }
    return NULL;
}
Exemple #24
0
static void
gtk_image_menu_item_size_allocate (GtkWidget     *widget,
                                   GtkAllocation *allocation)
{
    GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
    GtkImageMenuItemPrivate *priv = image_menu_item->priv;
    GtkAllocation widget_allocation;
    GtkPackDirection pack_dir;
    GtkWidget *parent;

    parent = gtk_widget_get_parent (widget);

    if (GTK_IS_MENU_BAR (parent))
        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
    else
        pack_dir = GTK_PACK_DIRECTION_LTR;

    GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_allocate (widget, allocation);

    if (priv->image && gtk_widget_get_visible (priv->image))
    {
        gint x, y, offset;
        GtkStyleContext *context;
        GtkStateFlags state;
        GtkBorder padding;
        GtkRequisition child_requisition;
        GtkAllocation child_allocation;
        guint horizontal_padding, toggle_spacing;
        gint toggle_size;

        toggle_size = GTK_MENU_ITEM (image_menu_item)->priv->toggle_size;
        gtk_widget_style_get (widget,
                              "horizontal-padding", &horizontal_padding,
                              "toggle-spacing", &toggle_spacing,
                              NULL);

        /* Man this is lame hardcoding action, but I can't
         * come up with a solution that's really better.
         */

        gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);

        gtk_widget_get_allocation (widget, &widget_allocation);

        context = gtk_widget_get_style_context (widget);
        state = gtk_widget_get_state_flags (widget);
        gtk_style_context_get_padding (context, state, &padding);
        offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item));

        if (pack_dir == GTK_PACK_DIRECTION_LTR ||
                pack_dir == GTK_PACK_DIRECTION_RTL)
        {
            if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
                    (pack_dir == GTK_PACK_DIRECTION_LTR))
                x = offset + horizontal_padding + padding.left +
                    (toggle_size - toggle_spacing - child_requisition.width) / 2;
            else
                x = widget_allocation.width - offset - horizontal_padding - padding.right -
                    toggle_size + toggle_spacing +
                    (toggle_size - toggle_spacing - child_requisition.width) / 2;

            y = (widget_allocation.height - child_requisition.height) / 2;
        }
        else
        {
            if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
                    (pack_dir == GTK_PACK_DIRECTION_TTB))
                y = offset + horizontal_padding + padding.top +
                    (toggle_size - toggle_spacing - child_requisition.height) / 2;
            else
                y = widget_allocation.height - offset - horizontal_padding - padding.bottom -
                    toggle_size + toggle_spacing +
                    (toggle_size - toggle_spacing - child_requisition.height) / 2;

            x = (widget_allocation.width - child_requisition.width) / 2;
        }

        child_allocation.width = child_requisition.width;
        child_allocation.height = child_requisition.height;
        child_allocation.x = widget_allocation.x + MAX (x, 0);
        child_allocation.y = widget_allocation.y + MAX (y, 0);

        gtk_widget_size_allocate (priv->image, &child_allocation);
    }
}
Exemple #25
0
/* Outputs source to add a child menu to a BonoboDock. */
static void
gb_bonobo_dock_item_write_add_child_source (GtkWidget * parent,
					   const gchar *parent_name,
					   GtkWidget *child,
					   GbWidgetWriteSourceData * data)
{
  GnomeApp *app;

  /* If we're adding a dock item to a GnomeApp's dock, we use
     the special functions to add it here. */
  if ((app = glade_gnome_is_app_dock_item (parent)))
    {
      /* Children of floating items are added as normal. */
      if (BONOBO_DOCK_ITEM (parent)->is_floating)
	{
	  source_add (data, "  gtk_container_add (GTK_CONTAINER (%s), %s);\n",
		      parent_name, data->wname);
	}
      else if (GTK_IS_MENU_BAR (child))
	{
	  source_add (data,
		      "  gnome_app_create_menus (GNOME_APP (%s), %s_uiinfo);\n",
		      data->component_name, data->real_wname);

	  /* Output the code to install the menu hints, if the GnomeApp has
	     a status bar. This must be output after the code to create the
	     GnomeAppBar is output, so we add it to the same buffer as the
	     signal connections. */
	  if (app->statusbar)
	    {
	      source_add_to_buffer (data, GLADE_SIGNAL_CONNECTIONS,
				    "  gnome_app_install_menu_hints (GNOME_APP (%s), %s_uiinfo);\n",
				    data->component_name, data->real_wname);
	    }
	}
      else
	{
	  BonoboDockPlacement placement;
	  BonoboDockItemBehavior behavior;
	  const gchar *placement_string;
	  gint idx, band_num, position, offset;
	  gchar *prefix, *prefix2;

	  if (gb_bonobo_dock_item_find_position (BONOBO_DOCK_ITEM (parent),
						&placement, &band_num,
						&position, &offset))
	    {
	      idx = glade_util_int_array_index (GladePlacementValues,
						GladePlacementSize,
						placement);
	      if (idx == -1)
		{
		  g_warning ("BonoboDock placement not found");
		  placement = 0;
		}
	      placement_string = GladePlacementSymbols[idx];

	      if (GTK_IS_TOOLBAR (child))
		{
		  source_add (data,
			      "  gnome_app_add_toolbar (GNOME_APP (%s), GTK_TOOLBAR (%s), %s,\n",
			      data->component_name, data->wname,
			      source_make_string (data->wname, FALSE));
		}
	      else
		{
		  source_add (data,
			      "  gnome_app_add_docked (GNOME_APP (%s), %s, %s,\n",
			      data->component_name, data->wname,
			      source_make_string (data->wname, FALSE));
		}

	      source_add (data, "                                ");
	      behavior = BONOBO_DOCK_ITEM (parent)->behavior;
	      prefix = "";
	      prefix2 = "\n                                | ";
	      if (behavior == BONOBO_DOCK_ITEM_BEH_NORMAL)
		{
		  source_add (data, "%sBONOBO_DOCK_ITEM_BEH_NORMAL", prefix);
		}
	      else
		{
		  if (behavior & BONOBO_DOCK_ITEM_BEH_EXCLUSIVE)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_EXCLUSIVE",
				  prefix);
		      prefix = prefix2;
		    }
		  if (behavior & BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_NEVER_FLOATING",
				  prefix);
		      prefix = prefix2;
		    }
		  if (behavior & BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL",
				  prefix);
		      prefix = prefix2;
		    }
		  if (behavior & BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL",
				  prefix);
		      prefix = prefix2;
		    }
		  if (behavior & BONOBO_DOCK_ITEM_BEH_LOCKED)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_LOCKED",
				  prefix);
		      prefix = prefix2;
		    }
		}

	      source_add (data,
			  ",\n"
			  "                                %s, %i, %i, %i);\n",
			  placement_string, band_num, position, offset);
	    }
	}
    }
  else
    {
      g_warning ("Skipping adding dock item to parent - unimplemented.");
    }
}
Exemple #26
0
static void
gtk_image_menu_item_size_allocate (GtkWidget     *widget,
                                   GtkAllocation *allocation)
{
  GtkImageMenuItem *image_menu_item;
  GtkPackDirection pack_dir;
  
  if (GTK_IS_MENU_BAR (widget->parent))
    pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent));
  else
    pack_dir = GTK_PACK_DIRECTION_LTR;
  
  image_menu_item = GTK_IMAGE_MENU_ITEM (widget);  

  GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_allocate (widget, allocation);

  if (image_menu_item->image && gtk_widget_get_visible (image_menu_item->image))
    {
      gint x, y, offset;
      GtkRequisition child_requisition;
      GtkAllocation child_allocation;
      guint horizontal_padding, toggle_spacing;

      gtk_widget_style_get (widget,
			    "horizontal-padding", &horizontal_padding,
			    "toggle-spacing", &toggle_spacing,
			    NULL);
      
      /* Man this is lame hardcoding action, but I can't
       * come up with a solution that's really better.
       */

      gtk_widget_get_child_requisition (image_menu_item->image,
                                        &child_requisition);

      if (pack_dir == GTK_PACK_DIRECTION_LTR ||
	  pack_dir == GTK_PACK_DIRECTION_RTL)
	{
	  offset = GTK_CONTAINER (image_menu_item)->border_width +
	    widget->style->xthickness;
	  
	  if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
	      (pack_dir == GTK_PACK_DIRECTION_LTR))
	    x = offset + horizontal_padding +
	      (GTK_MENU_ITEM (image_menu_item)->toggle_size -
	       toggle_spacing - child_requisition.width) / 2;
	  else
	    x = widget->allocation.width - offset - horizontal_padding -
	      GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing +
	      (GTK_MENU_ITEM (image_menu_item)->toggle_size -
	       toggle_spacing - child_requisition.width) / 2;
	  
	  y = (widget->allocation.height - child_requisition.height) / 2;
	}
      else
	{
	  offset = GTK_CONTAINER (image_menu_item)->border_width +
	    widget->style->ythickness;
	  
	  if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
	      (pack_dir == GTK_PACK_DIRECTION_TTB))
	    y = offset + horizontal_padding +
	      (GTK_MENU_ITEM (image_menu_item)->toggle_size -
	       toggle_spacing - child_requisition.height) / 2;
	  else
	    y = widget->allocation.height - offset - horizontal_padding -
	      GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing +
	      (GTK_MENU_ITEM (image_menu_item)->toggle_size -
	       toggle_spacing - child_requisition.height) / 2;

	  x = (widget->allocation.width - child_requisition.width) / 2;
	}
      
      child_allocation.width = child_requisition.width;
      child_allocation.height = child_requisition.height;
      child_allocation.x = widget->allocation.x + MAX (x, 0);
      child_allocation.y = widget->allocation.y + MAX (y, 0);

      gtk_widget_size_allocate (image_menu_item->image, &child_allocation);
    }
}
Exemple #27
0
static G_CONST_RETURN gchar*
gail_menu_item_get_keybinding (AtkAction *action,
                               gint      i)
{
  /*
   * This function returns a string of the form A;B;C where
   * A is the keybinding for the widget; B is the keybinding to traverse
   * from the menubar and C is the accelerator.
   * The items in the keybinding to traverse from the menubar are separated
   * by ":".
   */
  GailMenuItem  *gail_menu_item;
  gchar *keybinding = NULL;
  gchar *item_keybinding = NULL;
  gchar *full_keybinding = NULL;
  gchar *accelerator = NULL;

  gail_menu_item = GAIL_MENU_ITEM (action);
  if (i == 0)
    {
      GtkWidget *item;
      GtkWidget *temp_item;
      GtkWidget *child;
      GtkWidget *parent;

      item = GTK_ACCESSIBLE (action)->widget;
      if (item == NULL)
        /* State is defunct */
        return NULL;

      temp_item = item;
      while (TRUE)
        {
          GdkModifierType mnemonic_modifier = 0;
          guint key_val;
          gchar *key, *temp_keybinding;

          child = gtk_bin_get_child (GTK_BIN (temp_item));
          if (child == NULL)
            {
              /* Possibly a tear off menu item; it could also be a menu 
               * separator generated by gtk_item_factory_create_items()
               */
              return NULL;
            }
          parent = gtk_widget_get_parent (temp_item);
          if (!parent)
            {
              /*
               * parent can be NULL when activating a window from the panel
               */
              return NULL;
            }
          g_return_val_if_fail (GTK_IS_MENU_SHELL (parent), NULL);
          if (GTK_IS_MENU_BAR (parent))
            {
              GtkWidget *toplevel;

              toplevel = gtk_widget_get_toplevel (parent);
              if (toplevel && GTK_IS_WINDOW (toplevel))
                mnemonic_modifier = gtk_window_get_mnemonic_modifier (
                                       GTK_WINDOW (toplevel));
            }
          if (GTK_IS_LABEL (child))
            {
              key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (child));
              if (key_val != GDK_VoidSymbol)
                {
                  key = gtk_accelerator_name (key_val, mnemonic_modifier);
                  if (full_keybinding)
                    temp_keybinding = g_strconcat (key, ":", full_keybinding, NULL);
                  else 
                    temp_keybinding = g_strconcat (key, NULL);
                  if (temp_item == item)
                    {
                      item_keybinding = g_strdup (key); 
                    }
                  g_free (key);
                  g_free (full_keybinding);
                  full_keybinding = temp_keybinding;
                }
              else
                {
                  /* No keybinding */
                  g_free (full_keybinding);
                  full_keybinding = NULL;
                  break;
                }        
            }        
          if (GTK_IS_MENU_BAR (parent))
            /* We have reached the menu bar so we are finished */
            break;
          g_return_val_if_fail (GTK_IS_MENU (parent), NULL);
          temp_item = gtk_menu_get_attach_widget (GTK_MENU (parent));
          if (!GTK_IS_MENU_ITEM (temp_item))
            {
              /* 
               * Menu is attached to something other than a menu item;
               * probably an option menu
               */
              g_free (full_keybinding);
              full_keybinding = NULL;
              break;
            }
        }

      parent = gtk_widget_get_parent (item);
      if (GTK_IS_MENU (parent))
        {
          GtkAccelGroup *group; 
          GtkAccelKey *key;

          group = gtk_menu_get_accel_group (GTK_MENU (parent));

          if (group)
            {
              key = gtk_accel_group_find (group, find_accel, item);
            }
          else
            {
              /*
               * If the menu item is created using GtkAction and GtkUIManager
               * we get here.
               */
              key = NULL;
              child = GTK_BIN (item)->child;
              if (GTK_IS_ACCEL_LABEL (child))
                {
                  GtkAccelLabel *accel_label;

                  accel_label = GTK_ACCEL_LABEL (child);
                  if (accel_label->accel_closure)
                    {
                      key = gtk_accel_group_find (accel_label->accel_group,
                                                  find_accel_new,
                                                  accel_label->accel_closure);
                    }
               
                }
            }

          if (key)
            {           
              accelerator = gtk_accelerator_name (key->accel_key,
                                                  key->accel_mods);
            }
        }
    }
  /*
   * Concatenate the bindings
   */
  if (item_keybinding || full_keybinding || accelerator)
    {
      gchar *temp;
      if (item_keybinding)
        {
          keybinding = g_strconcat (item_keybinding, KEYBINDING_SEPARATOR, NULL);
          g_free (item_keybinding);
        }
      else
        keybinding = g_strconcat (KEYBINDING_SEPARATOR, NULL);

      if (full_keybinding)
        {
          temp = g_strconcat (keybinding, full_keybinding, 
                              KEYBINDING_SEPARATOR, NULL);
          g_free (full_keybinding);
        }
      else
        temp = g_strconcat (keybinding, KEYBINDING_SEPARATOR, NULL);

      g_free (keybinding);
      keybinding = temp;
      if (accelerator)
        {
          temp = g_strconcat (keybinding, accelerator, NULL);
          g_free (accelerator);
          g_free (keybinding);
          keybinding = temp;
      }
    }
  g_free (gail_menu_item->click_keybinding);
  gail_menu_item->click_keybinding = keybinding;
  return keybinding;
}
Exemple #28
0
static void
gail_finish_select (GtkWidget *widget)
{
  if (GTK_IS_MENU_ITEM (widget))
    {
      GtkMenuItem* menu_item;
      GtkWidget *submenu;

      menu_item = GTK_MENU_ITEM (widget);
      submenu = gtk_menu_item_get_submenu (menu_item);
      if (submenu &&
          !gtk_widget_get_mapped (submenu))
        {
          /*
           * If the submenu is not visble, wait until it is before
           * reporting focus on the menu item.
           */
          gulong handler_id;

          handler_id = g_signal_handler_find (submenu,
                                              G_SIGNAL_MATCH_FUNC,
                                              g_signal_lookup ("map",
                                                               GTK_TYPE_WINDOW),
                                              0,
                                              NULL,
                                              (gpointer) gail_map_submenu_cb,
                                              NULL); 
          if (!handler_id)
            g_signal_connect (submenu, "map",
                              G_CALLBACK (gail_map_submenu_cb),
                              NULL);

          return;
        }
      /*
       * If we are waiting to report focus on a menubar or a menu item
       * because of a previous deselect, cancel it.
       */
      if (was_deselect &&
          focus_notify_handler &&
          next_focus_widget &&
          (GTK_IS_MENU_BAR (next_focus_widget) ||
           GTK_IS_MENU_ITEM (next_focus_widget)))
        {
          void *vp_next_focus_widget = &next_focus_widget;
          g_source_remove (focus_notify_handler);
          g_object_remove_weak_pointer (G_OBJECT (next_focus_widget), vp_next_focus_widget);
	  next_focus_widget = NULL;
          focus_notify_handler = 0;
          was_deselect = FALSE;
        }
    } 
  /*
   * If previously focused widget is not a GtkMenuItem or a GtkMenu,
   * keep track of it so we can return to it after menubar is deactivated
   */
  if (_focus_widget && 
      !GTK_IS_MENU_ITEM (_focus_widget) && 
      !GTK_IS_MENU (_focus_widget))
    {
      void *vp_focus_before_menu = &focus_before_menu;
      focus_before_menu = _focus_widget;
      g_object_add_weak_pointer (G_OBJECT (focus_before_menu), vp_focus_before_menu);

    } 
  gail_focus_notify_when_idle (widget);

  return; 
}
Exemple #29
0
/* This function returns a string of the form A;B;C where A is
 * the keybinding for the widget; B is the keybinding to traverse
 * from the menubar and C is the accelerator. The items in the
 * keybinding to traverse from the menubar are separated by ":".
 */
static const gchar *
gtk_menu_item_accessible_get_keybinding (AtkAction *action,
                                         gint       i)
{
  gchar *keybinding = NULL;
  gchar *item_keybinding = NULL;
  gchar *full_keybinding = NULL;
  gchar *accelerator = NULL;
  GtkWidget *item;
  GtkWidget *temp_item;
  GtkWidget *child;
  GtkWidget *parent;

  item = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
  if (item == NULL)
    return NULL;

  if (i != 0)
    return NULL;

  temp_item = item;
  while (TRUE)
    {
      GdkModifierType mnemonic_modifier = 0;
      guint key_val;
      gchar *key, *temp_keybinding;

      child = gtk_bin_get_child (GTK_BIN (temp_item));
      if (child == NULL)
        return NULL;

      parent = gtk_widget_get_parent (temp_item);
      if (!parent)
        /* parent can be NULL when activating a window from the panel */
        return NULL;

      if (GTK_IS_MENU_BAR (parent))
        {
          GtkWidget *toplevel;

          toplevel = gtk_widget_get_toplevel (parent);
          if (toplevel && GTK_IS_WINDOW (toplevel))
            mnemonic_modifier =
              gtk_window_get_mnemonic_modifier (GTK_WINDOW (toplevel));
        }

      if (GTK_IS_LABEL (child))
        {
          key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (child));
          if (key_val != GDK_KEY_VoidSymbol)
            {
              key = gtk_accelerator_name (key_val, mnemonic_modifier);
              if (full_keybinding)
                temp_keybinding = g_strconcat (key, ":", full_keybinding, NULL);
              else
                temp_keybinding = g_strdup (key);

              if (temp_item == item)
                item_keybinding = g_strdup (key);

              g_free (key);
              g_free (full_keybinding);
              full_keybinding = temp_keybinding;
            }
          else
            {
              /* No keybinding */
              g_free (full_keybinding);
              full_keybinding = NULL;
              break;
            }
        }

      /* We have reached the menu bar so we are finished */
      if (GTK_IS_MENU_BAR (parent))
        break;

      g_return_val_if_fail (GTK_IS_MENU (parent), NULL);
      temp_item = gtk_menu_get_attach_widget (GTK_MENU (parent));
      if (!GTK_IS_MENU_ITEM (temp_item))
        {
          /* Menu is attached to something other than a menu item;
           * probably an option menu
           */
          g_free (full_keybinding);
          full_keybinding = NULL;
          break;
        }
    }

  parent = gtk_widget_get_parent (item);
  if (GTK_IS_MENU (parent))
    {
      GtkAccelGroup *group;
      GtkAccelKey *key;

      group = gtk_menu_get_accel_group (GTK_MENU (parent));
      if (group)
        key = gtk_accel_group_find (group, find_accel_by_widget, item);
      else
        {
          key = NULL;
          child = gtk_bin_get_child (GTK_BIN (item));
          if (GTK_IS_ACCEL_LABEL (child))
            {
              GtkAccelLabel *accel_label;
              GClosure      *accel_closure;

              accel_label = GTK_ACCEL_LABEL (child);
              g_object_get (accel_label, "accel-closure", &accel_closure, NULL);
              if (accel_closure)
                {
                  key = gtk_accel_group_find (gtk_accel_group_from_accel_closure (accel_closure),
                                              find_accel_by_closure,
                                              accel_closure);
                  g_closure_unref (accel_closure);
                }
            }
        }

     if (key)
       accelerator = gtk_accelerator_name (key->accel_key, key->accel_mods);
   }

  /* Concatenate the bindings */
  if (item_keybinding || full_keybinding || accelerator)
    {
      gchar *temp;
      if (item_keybinding)
        {
          keybinding = g_strconcat (item_keybinding, KEYBINDING_SEPARATOR, NULL);
          g_free (item_keybinding);
        }
      else
        keybinding = g_strdup (KEYBINDING_SEPARATOR);

      if (full_keybinding)
        {
          temp = g_strconcat (keybinding, full_keybinding,
                              KEYBINDING_SEPARATOR, NULL);
          g_free (full_keybinding);
        }
      else
        temp = g_strconcat (keybinding, KEYBINDING_SEPARATOR, NULL);

      g_free (keybinding);
      keybinding = temp;
      if (accelerator)
        {
          temp = g_strconcat (keybinding, accelerator, NULL);
          g_free (accelerator);
          g_free (keybinding);
          keybinding = temp;
      }
    }

  return keybinding;
}