コード例 #1
0
ファイル: uicommon.c プロジェクト: girish946/g2ipmsg
static GtkWidget *
create_group_menu(GtkWidget *window) {
  GtkWidget *menu;
  GtkWidget *new_item;
  GList *groups,*node;


  menu=gtk_menu_new(); 

  groups=get_group_list();

  for(node=g_list_first(groups);node;node=g_list_next (node)) {

    if (node->data){
      dbg_out("Group:%s(%x)\n",node->data,node->data);
      new_item=create_menu_item(node->data,node->data,NULL,on_usermenu_group_item);

      gtk_menu_append( GTK_MENU(menu), new_item);
      GLADE_HOOKUP_OBJECT(new_item,window,"messageWindow");
      g_free(node->data);
    }
  }

  g_list_free(groups);

  return menu;
}
コード例 #2
0
ファイル: fd-systray.c プロジェクト: wucan/freedict
static GtkWidget *create_main_menu()
{
    GtkWidget *menu;
    GtkWidget *preferences_item;
    GtkWidget *pickable_item;
    GtkWidget *quit_item;

    menu = gtk_menu_new();
    preferences_item = create_stock_menu_item("preferences_item",
                       GTK_STOCK_PREFERENCES, NULL, preferences_menu_item_activate_cb);
    gtk_menu_append(GTK_MENU(menu), preferences_item);

    /* pickable menu item */
    pickable_item = gtk_check_menu_item_new_with_label("Pickable");
    gtk_check_menu_item_set_active((GtkCheckMenuItem *)pickable_item, TRUE);
    gtk_check_menu_item_set_show_toggle((GtkCheckMenuItem *)pickable_item, TRUE);
    gtk_signal_connect_object((gpointer)pickable_item, "toggled",
                              GTK_SIGNAL_FUNC(pickable_menu_item_toggled_cb), pickable_item);
    gtk_widget_show(pickable_item);
    gtk_menu_append(GTK_MENU(menu), pickable_item);

    quit_item = create_menu_item("quit_item", "Quit",
                                 NULL, quit_menu_item_activate_cb);
    gtk_menu_append(GTK_MENU(menu), quit_item);
    GLADE_HOOKUP_OBJECT(menu, preferences_item, "preferences_item");
    GLADE_HOOKUP_OBJECT(menu, quit_item, "quit_item");

    return menu;
}
コード例 #3
0
ファイル: menu.c プロジェクト: allefant/allegro5
/* Function: al_insert_menu_item
 */
int al_insert_menu_item(ALLEGRO_MENU *parent, int pos, char const *title,
   uint16_t id, int flags, ALLEGRO_BITMAP *icon, ALLEGRO_MENU *submenu)
{
   ALLEGRO_MENU_ITEM *item;
   ALLEGRO_MENU_ITEM **slot;
   _AL_MENU_ID *menu_id;
   size_t i;

   ASSERT(parent);

   /* If not found, then treat as an append. */
   if (!interpret_menu_id_param(&parent, &pos))
      pos = _al_vector_size(&parent->items);

   /* At this point pos == the _index_ of where to insert */

   /* The sub-menu must not already be in use. */
   if (submenu && (submenu->display || submenu->parent || submenu->is_popup_menu))
      return -1;

   item = create_menu_item(title, id, flags, submenu);
   if (!item)
      return -1;
   item->parent = parent;
   
   set_item_icon(item, icon);

   i = (size_t) pos;

   if (i >= _al_vector_size(&parent->items)) {
      /* Append */
      i = _al_vector_size(&parent->items);
      slot = _al_vector_alloc_back(&parent->items);
   }
   else {
      /* Insert */
      slot = _al_vector_alloc_mid(&parent->items, i);
   }  

   if (!slot) {
      destroy_menu_item(item);
      return -1;
   }
   *slot = item;

   if (submenu) {
      submenu->parent = item;

      if (parent->display)
         _al_walk_over_menu(submenu, set_menu_display_r, parent->display);
   }

   _al_insert_menu_item_at(item, (int) i);

   if (id) {
      /* Append the menu's ID to the search vector */
      menu_id = (_AL_MENU_ID *) _al_vector_alloc_back(&menu_ids);
      menu_id->unique_id = item->unique_id;
      menu_id->id = id;
      menu_id->menu = parent;
   }

   return (int) i;
}
コード例 #4
0
static void
plugin_windowlist_clicked (GtkWidget *w, gpointer data)
{
    gui *plugin = data;
    static GtkWidget *menu = NULL;
    GtkWidget *item, *label;
    NetkWindow *win;
    NetkWorkspace *ws, *aws, *winws;
    NetkScreen *s;
    int wscount, i;
    GList *windows, *li, *l, *unref_needed=NULL;
    GtkStyle *style;

    if (menu) {
        gtk_widget_destroy(menu);
    }

    s = netk_screen_get_default();
    windows = netk_screen_get_windows_stacked(s);
    aws = netk_screen_get_active_workspace (s);

    menu = gtk_menu_new ();

    style = gtk_widget_get_style (menu);

    item = gtk_menu_item_new_with_label N_("Window list");
    gtk_widget_set_sensitive (item, FALSE);
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
    
    item = gtk_separator_menu_item_new ();
    gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);

    if (plugin->includeAll) {
        wscount = netk_screen_get_workspace_count(s);
    } else {
        wscount = 1;
    }
    
    for (i = 0; i<wscount; i++) {
        char *ws_name;
	const char *realname;

        if (plugin->includeAll) {
            ws = netk_screen_get_workspace(s, i);
	} else {
	    ws = netk_screen_get_active_workspace (s);
	}
	
	realname = netk_workspace_get_name (ws);

	if (realname) {
	    ws_name = g_strdup_printf ("<i>%s</i>", realname);
	} else {
	    ws_name = g_strdup_printf ("<i>%d</i>", i + 1);
	}

	item = gtk_menu_item_new_with_label (ws_name);
	g_signal_connect (item, "activate", G_CALLBACK(plugin_activate_workspace), ws);
	g_free (ws_name);
	
	label = gtk_bin_get_child (GTK_BIN (item));
	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
	gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
        
	gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);

	if (ws == aws) {
	    gtk_widget_set_sensitive (item, FALSE);
	}

	item = gtk_separator_menu_item_new ();
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    	for (li = windows; li; li = li->next ) {
    	    win = li->data;
	    winws = netk_window_get_workspace (win);
	    if (ws != winws && !(netk_window_is_sticky(win) && ws == aws)) {
	        continue;
	    }

	    item = create_menu_item (win, &unref_needed);

	    if (!item)
	        continue;

	    if (ws != aws) {
		gtk_widget_modify_fg (gtk_bin_get_child (GTK_BIN (item)), GTK_STATE_NORMAL, &(style->fg[GTK_STATE_INSENSITIVE]));
	    }

	    g_signal_connect (item, "button-release-event", G_CALLBACK(menu_item_clicked), win);
	
	    gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
        }

	item = gtk_separator_menu_item_new ();
	gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
    }
    
    wscount = netk_screen_get_workspace_count (s);
    
    item = gtk_menu_item_new_with_label (_("Add workspace"));
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
    g_signal_connect_swapped (item, "activate", G_CALLBACK (set_num_screens), GINT_TO_POINTER (wscount + 1));

    item = gtk_menu_item_new_with_label (_("Delete workspace"));
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
    g_signal_connect_swapped (item, "activate", G_CALLBACK (set_num_screens), GINT_TO_POINTER (wscount - 1));

    gtk_widget_show_all (menu);
    gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);    

    if (unref_needed) {
        for(l=unref_needed; l; l=l->next) {
            g_object_unref(G_OBJECT(l->data));
        }
        g_list_free(unref_needed);
        unref_needed = NULL;
    }
}