diff -Nur -Xtest/diff_ignore ../cvs/freeciv/client/gui-gtk/diplodlg.c test/client/gui-gtk/diplodlg.c --- ../cvs/freeciv/client/gui-gtk/diplodlg.c Thu Jun 13 09:57:29 2002 +++ test/client/gui-gtk/diplodlg.c Sat Aug 3 00:03:02 2002 @@ -194,26 +194,61 @@ /**************************************************************** -... + Create tech menu - create sub menus if techs don't fit on screen *****************************************************************/ static int fill_diplomacy_tech_menu(GtkWidget *popupmenu, struct player *plr0, struct player *plr1) { - int i, flag; + int i, j, lines, flag; + GtkWidget *parentmenu; + + parentmenu = popupmenu; + j = 1; + + /* We assume that the height of a menu item is 24 pixels, which is more * + * than the standard font used on Linux. It doesn't do much harm if font * + * is smaller. If the user chooses a much bigger font, though, the menu * + * will still run out of the screen. - ChrisK */ + lines = (gdk_screen_height() / 24) - 1; for(i=1, flag=0; iplayer_no * 10000 + - plr1->player_no * 100 + i)); - flag=1; + get_invention(plr1, i)==TECH_REACHABLE)) { + if(j == lines) { + /* Last entry for current menu: * + * create "more" item and submenu, create tech item and append * + * to submenu, make submenu current parentmenu - ChrisK */ + + GtkWidget *submenu = gtk_menu_new(); + GtkWidget *more = gtk_menu_item_new_with_label(_("more")); + GtkWidget *item = gtk_menu_item_new_with_label(advances[i].name); + + gtk_menu_item_configure(GTK_MENU_ITEM(more), FALSE, TRUE); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(more), submenu); + gtk_menu_append(GTK_MENU(parentmenu), more); + gtk_menu_append(GTK_MENU(submenu), item); + gtk_signal_connect(GTK_OBJECT(item), "activate", + GTK_SIGNAL_FUNC(diplomacy_dialog_tech_callback), + GINT_TO_POINTER(plr0->player_no * 10000 + + plr1->player_no * 100 + i)); + + parentmenu = submenu; + j = 1; + + } else { + /* create tech item and append to parentmenu - ChrisK */ + + GtkWidget *item = gtk_menu_item_new_with_label(advances[i].name); + gtk_menu_append(GTK_MENU(parentmenu), item); + gtk_signal_connect(GTK_OBJECT(item), "activate", + GTK_SIGNAL_FUNC(diplomacy_dialog_tech_callback), + GINT_TO_POINTER(plr0->player_no * 10000 + + plr1->player_no * 100 + i)); + + j++; + flag = 1; + } } } @@ -231,7 +266,10 @@ struct player *plr0, struct player *plr1) { int i = 0, j = 0, n = city_list_size(&plr0->cities); + int k, lines; struct city **city_list_ptrs; + GtkWidget *parentmenu; + if (n>0) { city_list_ptrs = fc_malloc(sizeof(struct city*)*n); } else { @@ -246,17 +284,54 @@ } city_list_iterate_end; qsort(city_list_ptrs, i, sizeof(struct city*), city_name_compare); + + parentmenu = popupmenu; + k = 1; + + /* We assume that the height of a menu item is 24 pixels, which is more * + * than the standard font used on Linux. It doesn't do much harm if font * + * is smaller. If the user chooses a much bigger font, though, the menu * + * will still run out of the screen. - ChrisK */ + lines = (gdk_screen_height() / 24) - 1; for(j=0; jname); + if(k == lines) { + /* Last entry for current menu: * + * create "more" item and submenu, create tech item and append * + * to submenu, make submenu current parentmenu - ChrisK */ + + GtkWidget *submenu = gtk_menu_new(); + GtkWidget *more = gtk_menu_item_new_with_label(_("more")); + GtkWidget *item = gtk_menu_item_new_with_label(city_list_ptrs[j]->name); + + gtk_menu_item_configure(GTK_MENU_ITEM(more), FALSE, TRUE); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(more), submenu); + gtk_menu_append(GTK_MENU(parentmenu), more); + gtk_menu_append(GTK_MENU(submenu), item); + gtk_signal_connect(GTK_OBJECT(item), "activate", + GTK_SIGNAL_FUNC(diplomacy_dialog_city_callback), + GINT_TO_POINTER(city_list_ptrs[j]->id * 1024 + + plr0->player_no * 32 + + plr1->player_no)); + + parentmenu = submenu; + k = 1; - gtk_menu_append(GTK_MENU(popupmenu),item); + } else { + /* create tech item and append to parentmenu - ChrisK */ + + GtkWidget *item = gtk_menu_item_new_with_label(city_list_ptrs[j]->name); + gtk_menu_append(GTK_MENU(parentmenu), item); gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(diplomacy_dialog_city_callback), GINT_TO_POINTER(city_list_ptrs[j]->id * 1024 + plr0->player_no * 32 + plr1->player_no)); + + k++; + } } + free(city_list_ptrs); return i; }