示例#1
0
GtkMenuBar* menu_new(gpointer userData)
{
	GtkWidget* pMenuBar = NULL;

	GtkWidget* pMenuFile = NULL;
	GtkWidget* pMenuItemFile = NULL;

	pMenuBar = gtk_menu_bar_new();

	pMenuFile = gtk_menu_new();
	pMenuItemFile = gtk_menu_item_new_with_mnemonic("_File");
		menu_item_new(GTK_MENU(pMenuFile), "_New", G_CALLBACK(map_editor_new_file), userData);
		menu_item_new(GTK_MENU(pMenuFile), "_Open", G_CALLBACK(map_editor_open_file), userData);
		menu_item_new(GTK_MENU(pMenuFile), "_Save", G_CALLBACK(map_editor_save), userData);
		menu_item_new(GTK_MENU(pMenuFile), "Save _As", G_CALLBACK(map_editor_save_as), userData);
		menu_item_new(GTK_MENU(pMenuFile), "_Close", G_CALLBACK(map_editor_close), userData);
		menu_item_new(GTK_MENU(pMenuFile), "_Quit", G_CALLBACK(map_editor_quit), userData);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItemFile), pMenuFile);
	gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItemFile);

	pMenuFile = gtk_menu_new();
	pMenuItemFile = gtk_menu_item_new_with_mnemonic("_?");
		menu_item_new(GTK_MENU(pMenuFile), "_Help", G_CALLBACK(NULL), userData);
		menu_item_new(GTK_MENU(pMenuFile), "_About", G_CALLBACK(NULL), userData);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItemFile), pMenuFile);
	gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItemFile);

	return GTK_MENU_BAR(pMenuBar);
}
示例#2
0
文件: main.c 项目: alvarezp/gophd
void print_directory(struct request_t * req){
    DIR * dir = opendir(req->path);
    struct dirent * entry = NULL;
    
    if (dir == NULL){
        perror(NULL);
        return;
    }
    
    while( (entry = readdir(dir)) != NULL ){
        if( (*entry).d_name[0] == '.' ) continue; // don't print hidden files/dirs
            
        char type = resolve_item(entry);
        char * sel = NULL;
        asprintf(&sel, "%s/%s", req->selector, entry->d_name);
        
        menu_item * item = menu_item_new(type, entry->d_name, sel, DEFAULT_HOST, DEFAULT_PORT);
        print_menu_item(req->fd, item);
        menu_item_free(item);
        free(sel);
    }
    
    print_closing(req->fd);
    if( closedir(dir) != 0 )
        perror(NULL);
}
示例#3
0
t_wid		*init_help(t_wid *wid)
{
  GtkWidget	*menu_item;

  wid->index->help = gtk_menu_new();
  menu_item = gtk_menu_item_new_with_mnemonic("_Help");
  menu_item_new(GTK_MENU(wid->index->help), "_Help",
		G_CALLBACK(help), wid);
  menu_item_new(GTK_MENU(wid->index->help), "_About Us",
		G_CALLBACK(about), wid);
  menu_item_new(GTK_MENU(wid->index->help), "_Duck Balloon",
		G_CALLBACK(duck_balloon), wid);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), wid->index->help);
  gtk_menu_shell_append(GTK_MENU_SHELL(wid->win->menu_bar), menu_item);
  return (wid);
}
示例#4
0
void menu_add_item(struct menu *m, const char *caption, 
		menu_action_cb action)
{
	struct menu_item *item;

	item = menu_item_new(caption, action);

	if (list_size(m->items) == 0) {
		item->highlighted = 1;
	}

	list_add(m->items, (void *) item);
}
示例#5
0
文件: menu.c 项目: Fantu/muffin
LOCAL_SYMBOL MetaWindowMenu*
meta_window_menu_new   (MetaFrames         *frames,
                        MetaMenuOp          ops,
                        MetaMenuOp          insensitive,
                        Window              client_xwindow,
                        unsigned long       active_workspace,
                        int                 n_workspaces,
                        MetaWindowMenuFunc  func,
                        gpointer            data)
{
  int i;
  MetaWindowMenu *menu;

  /* FIXME: Modifications to 'ops' should happen in meta_window_show_menu */
  if (n_workspaces < 2)
    ops &= ~(META_MENU_OP_STICK | META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES);
  
  menu = g_new (MetaWindowMenu, 1);
  menu->frames = frames;
  menu->client_xwindow = client_xwindow;
  menu->func = func;
  menu->data = data;
  menu->ops = ops;
  menu->insensitive = insensitive;  
  
  menu->menu = gtk_menu_new ();

  gtk_menu_set_screen (GTK_MENU (menu->menu),
                       gtk_widget_get_screen (GTK_WIDGET (frames)));

  for (i = 0; i < (int) G_N_ELEMENTS (menuitems); i++)
    {
      MenuItem menuitem = menuitems[i];
      if (ops & menuitem.op || menuitem.op == 0)
        {
          GtkWidget *mi;
          MenuData *md;
          unsigned int key;
          MetaVirtualModifier mods;

          mi = menu_item_new (&menuitem, -1);

          /* Set the activeness of radiobuttons. */
          switch (menuitem.op)
            {
            case META_MENU_OP_STICK:
              gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
                                              active_workspace == 0xFFFFFFFF);
              break;
            case META_MENU_OP_UNSTICK:
              gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
                                              active_workspace != 0xFFFFFFFF);
              break;
            default:
              break;
            }

          if (menuitem.type == MENU_ITEM_WORKSPACE_LIST)
            {
              if (ops & META_MENU_OP_WORKSPACES)
                {
                  Display *display;
                  Window xroot;
                  GdkScreen *screen;
                  GdkWindow *window;
                  GtkWidget *submenu;
                  int j;

                  MenuItem to_another_workspace = {
                    0, MENU_ITEM_NORMAL,
                    NULL, FALSE,
                    N_("Move to Another _Workspace")
                  };

                  meta_verbose ("Creating %d-workspace menu current space %lu\n",
                      n_workspaces, active_workspace);

                  window = gtk_widget_get_window (GTK_WIDGET (frames));
                  display = GDK_WINDOW_XDISPLAY (window);

                  screen = gdk_window_get_screen (window);
                  xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));

                  submenu = gtk_menu_new ();

                  g_assert (mi==NULL);
                  mi = menu_item_new (&to_another_workspace, -1);
                  gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), submenu);

                  for (j = 0; j < n_workspaces; j++)
                    {
                      char *label;
                      MenuData *md;
                      unsigned int key;
                      MetaVirtualModifier mods;
                      MenuItem moveitem;
                      GtkWidget *submi;

                      meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES,
                          j + 1,
                          &key, &mods);

                      label = get_workspace_name_with_accel (display, xroot, j);

                      moveitem.type = MENU_ITEM_NORMAL;
                      moveitem.op = META_MENU_OP_WORKSPACES;
                      moveitem.label = label;
                      submi = menu_item_new (&moveitem, j + 1);

                      g_free (label);

                      if ((active_workspace == (unsigned)j) && (ops & META_MENU_OP_UNSTICK))
                        gtk_widget_set_sensitive (submi, FALSE);

                      md = g_new (MenuData, 1);

                      md->menu = menu;
                      md->op = META_MENU_OP_WORKSPACES;

                      g_object_set_data (G_OBJECT (submi),
                          "workspace",
                          GINT_TO_POINTER (j));

                      g_signal_connect_data (G_OBJECT (submi),
                          "activate",
                          G_CALLBACK (activate_cb),
                          md,
                          (GClosureNotify) g_free, 0);

                      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi);

                      gtk_widget_show (submi);
                    }
                  }
                else
                  meta_verbose ("not creating workspace menu\n");
            }
          else if (menuitem.type != MENU_ITEM_SEPARATOR)
            {
              meta_core_get_menu_accelerator (menuitems[i].op, -1,
                                              &key, &mods);

              if (insensitive & menuitem.op)
                gtk_widget_set_sensitive (mi, FALSE);
              
              md = g_new (MenuData, 1);
              
              md->menu = menu;
              md->op = menuitem.op;
              
              g_signal_connect_data (G_OBJECT (mi),
                                     "activate",
                                     G_CALLBACK (activate_cb),
                                     md,
                                     (GClosureNotify) g_free, 0);
            }

          if (mi)
            {
              gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), mi);
          
              gtk_widget_show (mi);
            }
        }
    }

 
  g_signal_connect (menu->menu, "selection_done",
                    G_CALLBACK (menu_closed), menu);  

  return menu;
}
示例#6
0
//Fonction de création de la fenêtre principale
void creer_fenetre_principale (struct main* m)
{
  //LOCK GTK OK

  GtkWidget *p_window = NULL;
    GtkWidget *p_main_box = NULL;
      GtkWidget *p_menu_bar = NULL;
        GtkWidget *p_menu_item = NULL;
        GtkWidget *p_menu = NULL;
      GtkWidget *p_instruction = NULL;
      GtkWidget *p_box_boutons = NULL;
        GtkWidget *p_bouton_valider = NULL;
        GtkWidget *p_bouton_quitter = NULL;

  /* Creation de la fenêtre principale */
  p_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  m->fenetre_principale.sig_destroy = g_signal_connect (G_OBJECT (p_window), "destroy", G_CALLBACK (arret), m);
  gtk_window_set_title (GTK_WINDOW (p_window), "Puissance 5 en réseau");

  /*Création du conteneur principal*/
  p_main_box = gtk_vbox_new (FALSE, 10);
  gtk_container_add (GTK_CONTAINER (p_window), p_main_box);

  /*Création de la barre menu*/
  p_menu_bar = gtk_menu_bar_new ();
  gtk_box_pack_start (GTK_BOX (p_main_box), p_menu_bar, FALSE, FALSE, 0);

  /*Création du menu Quitter*/
  p_menu = gtk_menu_new ();
  p_menu_item = gtk_menu_item_new_with_mnemonic ("_Fichier");
  menu_item_new (GTK_MENU(p_menu), "Quitter", G_CALLBACK(arret), m);
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (p_menu_item), p_menu);
  gtk_menu_shell_append (GTK_MENU_SHELL (p_menu_bar), p_menu_item);

  /*Création de la ligne de boutons*/
  p_box_boutons = gtk_hbox_new (FALSE, 20); //gtk_hbutton_box_new ();
  gtk_box_pack_end (GTK_BOX (p_main_box), p_box_boutons, FALSE, FALSE, 0);

  /*Création du bouton quitter*/
  p_bouton_quitter = gtk_button_new_from_stock (GTK_STOCK_QUIT);
  g_signal_connect (G_OBJECT (p_bouton_quitter), "clicked", G_CALLBACK (arret), m);
  gtk_box_pack_end (GTK_BOX (p_box_boutons), p_bouton_quitter, FALSE, FALSE, 0);

  /*Création du bouton Valider*/
  p_bouton_valider = gtk_button_new_from_stock (GTK_STOCK_OK); //gtk_button_new_with_label("Valider");
  g_signal_connect (G_OBJECT (p_bouton_valider), "clicked", G_CALLBACK (signal_traitement_champs), (gpointer) m);
  gtk_box_pack_end (GTK_BOX (p_box_boutons), p_bouton_valider, FALSE, FALSE, 0);

  //Création du champ de mot de passe
  m->fenetre_principale.mdp = add_new_champ_end("Mot de passe :", p_main_box, 0);
  gtk_entry_set_visibility(m->fenetre_principale.mdp.entry, FALSE);
  g_signal_connect(GTK_OBJECT(m->fenetre_principale.mdp.entry), "activate", G_CALLBACK(signal_traitement_champs), (gpointer) m);

  //Création du champ de login
  m->fenetre_principale.login = add_new_champ_end("Login :"******"activate", G_CALLBACK(signal_traitement_champs), (gpointer) m);

  //Création du champ de port
  m->fenetre_principale.port = add_new_champ_end("Port :", p_main_box, 0);
  g_signal_connect(GTK_OBJECT(m->fenetre_principale.port.entry), "activate", G_CALLBACK(signal_traitement_champs), (gpointer) m);

  //Création du champ de IP
  m->fenetre_principale.ip = add_new_champ_end("IP :", p_main_box, 16);
  g_signal_connect(GTK_OBJECT(m->fenetre_principale.ip.entry), "activate", G_CALLBACK(signal_traitement_champs), (gpointer) m);

  //Création de l'instruction
  p_instruction = gtk_label_new("Veuillez rentrer les informations pour vous connecter :");
  gtk_box_pack_end (GTK_BOX (p_main_box), p_instruction, FALSE, FALSE, 0);
  m->fenetre_principale.instruction = GTK_LABEL(p_instruction);

  m->fenetre_principale.open = 1;
  m->fenetre_principale.adresse = p_window;
}