Re: eject buttons on the places menu



Here is what you can currently do with tabular menus.

Note that I do not really want to advocate this as a desirable
feature, just showing what can already be done.

Matthias

Attachment: tablemenu.png
Description: PNG image

#include <gtk/gtk.h>

static gboolean
popup_menu (GtkWidget   *widget,
            gpointer     data)
{
  GtkWidget *menu, *item, *image;

  menu = gtk_menu_new ();

  item = gtk_menu_item_new_with_label ("First item");
  gtk_menu_attach (GTK_MENU (menu), item, 0, 4, 0, 1);

  item = gtk_menu_item_new_with_label ("Second Item");
  gtk_menu_attach (GTK_MENU (menu), item, 0, 3, 1, 2);

  item = gtk_menu_item_new ();
  image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
  gtk_container_add (GTK_CONTAINER (item), image);
  gtk_menu_attach (GTK_MENU (menu), item, 3, 4, 1, 2);

  item = gtk_menu_item_new_with_label ("Third Item");
  gtk_menu_attach (GTK_MENU (menu), item, 0, 4, 2, 3);

  gtk_widget_show_all (menu);
  gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time());
}

int 
main (int argc, char *argv[])
{
  GtkWidget *window, *button;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  button = gtk_button_new_with_label ("Pop");
  gtk_container_add (GTK_CONTAINER (window), button);

  g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (popup_menu), NULL);
  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]